mirror of https://github.com/arendst/Tasmota.git
Merge pull request #14924 from s-hadinger/fix_zigbee_compilation
Fix Zigbee compilation with Hue emulation
This commit is contained in:
commit
a5147ae250
|
@ -623,11 +623,7 @@ void HueLightStatus2(uint8_t device, String *response)
|
|||
// it is limited to 32 devices.
|
||||
// last 24 bits of Mac address + 4 bits of local light + high bit for relays 16-31, relay 32 is mapped to 0
|
||||
// Zigbee extension: bit 29 = 1, and last 16 bits = short address of Zigbee device
|
||||
#ifndef USE_ZIGBEE
|
||||
uint32_t EncodeLightId(uint8_t relay_id)
|
||||
#else
|
||||
uint32_t EncodeLightId(uint8_t relay_id, uint16_t z_shortaddr = 0)
|
||||
#endif
|
||||
uint32_t EncodeLightIdZigbee(uint8_t relay_id, uint16_t z_shortaddr)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
WiFi.macAddress(mac);
|
||||
|
@ -650,17 +646,17 @@ uint32_t EncodeLightId(uint8_t relay_id, uint16_t z_shortaddr = 0)
|
|||
return id;
|
||||
}
|
||||
|
||||
uint32_t EncodeLightId(uint8_t relay_id)
|
||||
{
|
||||
return EncodeLightIdZigbee(relay_id, 0);
|
||||
}
|
||||
|
||||
// get hue_id and decode the relay_id
|
||||
// 4 LSB decode to 1-15, if bit 28 is set, it encodes 16-31, if 0 then 32
|
||||
// Zigbee:
|
||||
// If the Id encodes a Zigbee device (meaning bit 29 is set)
|
||||
// it returns 0 and sets the 'shortaddr' to the device short address
|
||||
#ifndef USE_ZIGBEE
|
||||
uint32_t DecodeLightId(uint32_t hue_id)
|
||||
#else
|
||||
uint32_t DecodeLightId(uint32_t hue_id, uint16_t * shortaddr = nullptr)
|
||||
#endif
|
||||
uint32_t DecodeLightIdZigbee(uint32_t hue_id, uint16_t * shortaddr)
|
||||
{
|
||||
uint8_t relay_id = hue_id & 0xF;
|
||||
if (hue_id & (1 << 28)) { // check if bit 25 is set, if so we have
|
||||
|
@ -680,6 +676,11 @@ uint32_t DecodeLightId(uint32_t hue_id, uint16_t * shortaddr = nullptr)
|
|||
return relay_id;
|
||||
}
|
||||
|
||||
uint32_t DecodeLightId(uint32_t hue_id)
|
||||
{
|
||||
return DecodeLightIdZigbee(hue_id, nullptr);
|
||||
}
|
||||
|
||||
// Check if the Echo device is of 1st generation, which triggers different results
|
||||
inline uint32_t findEchoGeneration(void) {
|
||||
// don't try to guess from User-Agent anymore but use SetOption109
|
||||
|
@ -971,7 +972,7 @@ void HueLights(String *path_req)
|
|||
device = DecodeLightId(device_id);
|
||||
#ifdef USE_ZIGBEE
|
||||
uint16_t shortaddr;
|
||||
device = DecodeLightId(device_id, &shortaddr);
|
||||
device = DecodeLightIdZigbee(device_id, &shortaddr);
|
||||
if (shortaddr) {
|
||||
code = ZigbeeHandleHue(shortaddr, device_id, response);
|
||||
goto exit;
|
||||
|
@ -1004,7 +1005,7 @@ void HueLights(String *path_req)
|
|||
device = DecodeLightId(device_id);
|
||||
#ifdef USE_ZIGBEE
|
||||
uint16_t shortaddr;
|
||||
device = DecodeLightId(device_id, &shortaddr);
|
||||
device = DecodeLightIdZigbee(device_id, &shortaddr);
|
||||
if (shortaddr) {
|
||||
code = ZigbeeHueStatus(&response, shortaddr);
|
||||
goto exit;
|
||||
|
|
|
@ -128,7 +128,7 @@ void ZigbeeCheckHue(String & response, bool * appending) {
|
|||
// this bulb is advertized
|
||||
if (*appending) { response += ","; }
|
||||
response += "\"";
|
||||
response += EncodeLightId(0, shortaddr);
|
||||
response += EncodeLightIdZigbee(0, shortaddr);
|
||||
response += F("\":{\"state\":");
|
||||
HueLightStatus1Zigbee(shortaddr, bulbtype, &response); // TODO
|
||||
HueLightStatus2Zigbee(shortaddr, &response);
|
||||
|
@ -145,7 +145,7 @@ void ZigbeeHueGroups(String * lights) {
|
|||
|
||||
if (bulbtype >= 0) {
|
||||
*lights += ",\"";
|
||||
*lights += EncodeLightId(0, shortaddr);
|
||||
*lights += EncodeLightIdZigbee(0, shortaddr);
|
||||
*lights += "\"";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue