|
@ -92,6 +92,8 @@ static std::unique_ptr<RfbLearn> _rfb_learn; |
|
|
// EFM8BB1 PROTOCOL PARSING
|
|
|
// EFM8BB1 PROTOCOL PARSING
|
|
|
// -----------------------------------------------------------------------------
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
constexpr uint8_t RfbDefaultProtocol { 0u }; |
|
|
|
|
|
|
|
|
constexpr uint8_t CodeStart { 0xAAu }; |
|
|
constexpr uint8_t CodeStart { 0xAAu }; |
|
|
constexpr uint8_t CodeEnd { 0x55u }; |
|
|
constexpr uint8_t CodeEnd { 0x55u }; |
|
|
|
|
|
|
|
@ -591,11 +593,12 @@ void _rfbParse(uint8_t code, const std::vector<uint8_t>& payload) { |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
#if BROKER_SUPPORT
|
|
|
#if BROKER_SUPPORT
|
|
|
RfbridgeBroker::Publish(buffer + 6); |
|
|
|
|
|
|
|
|
RfbridgeBroker::Publish(RfbDefaultProtocol, buffer + 6); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case CodeRecvProto: |
|
|
case CodeRecvProto: |
|
|
case CodeRecvBucket: { |
|
|
case CodeRecvBucket: { |
|
|
_rfbAckImpl(); |
|
|
_rfbAckImpl(); |
|
@ -604,14 +607,21 @@ void _rfbParse(uint8_t code, const std::vector<uint8_t>& payload) { |
|
|
DEBUG_MSG_P(PSTR("[RF] Received %s code: %s\n"), |
|
|
DEBUG_MSG_P(PSTR("[RF] Received %s code: %s\n"), |
|
|
(CodeRecvProto == code) ? "advanced" : "bucket", buffer |
|
|
(CodeRecvProto == code) ? "advanced" : "bucket", buffer |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
#if MQTT_SUPPORT
|
|
|
#if MQTT_SUPPORT
|
|
|
mqttSend(MQTT_TOPIC_RFIN, buffer, false, false); |
|
|
mqttSend(MQTT_TOPIC_RFIN, buffer, false, false); |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if BROKER_SUPPORT
|
|
|
|
|
|
// ref. https://github.com/Portisch/RF-Bridge-EFM8BB1/wiki/0xA6#example-of-a-received-decoded-protocol
|
|
|
|
|
|
RfbridgeBroker::Publish(payload[0], buffer + 2); |
|
|
|
|
|
#endif
|
|
|
} else { |
|
|
} else { |
|
|
DEBUG_MSG_P(PSTR("[RF] Received code %02X (%u bytes)\n"), code, payload.size()); |
|
|
|
|
|
|
|
|
DEBUG_MSG_P(PSTR("[RF] Received 0x%02X (%u bytes)\n"), code, payload.size()); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -625,6 +635,7 @@ void _rfbReceiveImpl() { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// narrowing is justified, as `c` can only contain byte-sized value
|
|
|
if (!_rfb_parser.loop(static_cast<uint8_t>(c))) { |
|
|
if (!_rfb_parser.loop(static_cast<uint8_t>(c))) { |
|
|
_rfb_parser.reset(); |
|
|
_rfb_parser.reset(); |
|
|
} |
|
|
} |
|
@ -665,7 +676,7 @@ size_t _rfb_bits_for_bytes(size_t bits) { |
|
|
return bytes; |
|
|
return bytes; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO: 'Code' long unsigned int != uint32_t, thus the specialization
|
|
|
|
|
|
|
|
|
// TODO: RCSwitch code type: long unsigned int != uint32_t, thus the specialization
|
|
|
static_assert(sizeof(uint32_t) == sizeof(long unsigned int), ""); |
|
|
static_assert(sizeof(uint32_t) == sizeof(long unsigned int), ""); |
|
|
|
|
|
|
|
|
template <typename T> |
|
|
template <typename T> |
|
@ -1172,7 +1183,7 @@ void rfbSetup() { |
|
|
|
|
|
|
|
|
_rfb_repeat = getSetting("rfbRepeat", RFB_SEND_TIMES); |
|
|
_rfb_repeat = getSetting("rfbRepeat", RFB_SEND_TIMES); |
|
|
|
|
|
|
|
|
// Note: as rfbridge protocol is simplictic enough, we rely on Serial queue to deliver timely updates
|
|
|
|
|
|
|
|
|
// Note: as rfbridge protocol is simplistic enough, we rely on Serial queue to deliver timely updates
|
|
|
// learn / command acks / etc. are not queued, only RF messages are
|
|
|
// learn / command acks / etc. are not queued, only RF messages are
|
|
|
espurnaRegisterLoop([]() { |
|
|
espurnaRegisterLoop([]() { |
|
|
_rfbReceiveImpl(); |
|
|
_rfbReceiveImpl(); |
|
|