Browse Source

fix sender timing typo, fix code unpacking

mcspr-patch-1
Maxim Prokhorov 4 years ago
parent
commit
5028bbdcf0
1 changed files with 14 additions and 7 deletions
  1. +14
    -7
      code/espurna/rfbridge.cpp

+ 14
- 7
code/espurna/rfbridge.cpp View File

@ -709,17 +709,22 @@ void _rfbEnqueue(uint8_t protocol, uint16_t timing, uint8_t bits, RfbMessage::co
_rfb_message_queue.push_back(RfbMessage{protocol, timing, bits, code, repeats}); _rfb_message_queue.push_back(RfbMessage{protocol, timing, bits, code, repeats});
} }
void _rfbEnqueue(const char* code, unsigned char repeats = 1u) {
void _rfbEnqueue(const char* message, unsigned char repeats = 1u) {
uint8_t buffer[RfbMessage::BufferSize] { 0u }; uint8_t buffer[RfbMessage::BufferSize] { 0u };
if (hexDecode(code, strlen(code), buffer, sizeof(buffer))) {
if (hexDecode(message, strlen(message), buffer, sizeof(buffer))) {
const auto bytes = _rfb_bytes_for_bits(buffer[4]);
uint8_t raw_code[sizeof(RfbMessage::code_type)] { 0u };
std::memcpy(&raw_code[sizeof(raw_code) - bytes], &buffer[5], bytes);
RfbMessage::code_type code; RfbMessage::code_type code;
std::memcpy(&code, &buffer[5], _rfb_bits_for_bytes(buffer[4]));
code = _rfb_bswap(code);
std::memcpy(&code, raw_code, sizeof(code));
_rfbEnqueue(buffer[1], (buffer[3] << 8) | buffer[2], buffer[4], code, repeats);
} else {
DEBUG_MSG_P(PSTR("[RF] Cannot decode the message\n"));
_rfbEnqueue(buffer[1], (buffer[2] << 8) | buffer[3], buffer[4], _rfb_bswap(code), repeats);
return;
} }
DEBUG_MSG_P(PSTR("[RF] Cannot decode the message\n"));
} }
void _rfbLearnImpl() { void _rfbLearnImpl() {
@ -737,6 +742,8 @@ void _rfbSendImpl(const RfbMessage& message) {
_rfb_modem->setPulseLength(message.timing); _rfb_modem->setPulseLength(message.timing);
} }
yield();
_rfb_modem->send(message.code, message.bits); _rfb_modem->send(message.code, message.bits);
_rfb_modem->resetAvailable(); _rfb_modem->resetAvailable();


Loading…
Cancel
Save