Browse Source

log advanced sniffing methods of efm8bb1 alternative fw

mcspr-patch-1
Maxim Prokhorov 4 years ago
parent
commit
61daecee05
1 changed files with 25 additions and 11 deletions
  1. +25
    -11
      code/espurna/rfbridge.cpp

+ 25
- 11
code/espurna/rfbridge.cpp View File

@ -180,18 +180,19 @@ struct RfbParser {
} }
} }
void read_until_end(uint8_t c) {
_payload.push_back(c);
void read_end(uint8_t c) {
if (CodeEnd == c) { if (CodeEnd == c) {
read_end(c);
_callback(_payload_code, _payload);
} }
_state = &RfbParser::stop;
} }
void read_end(uint8_t c) {
void read_until_end(uint8_t c) {
if (CodeEnd == c) { if (CodeEnd == c) {
_callback(_payload_code, _payload);
read_end(c);
return;
} }
_state = &RfbParser::stop;
_payload.push_back(c);
} }
void read_until_length(uint8_t c) { void read_until_length(uint8_t c) {
@ -509,13 +510,15 @@ void _rfbEnqueue(uint8_t* code, size_t size, unsigned char times) {
_rfb_message_queue.push_back(RfbMessage(code, size, times)); _rfb_message_queue.push_back(RfbMessage(code, size, times));
} }
void _rfbEnqueue(const char* code, unsigned char times) {
bool _rfbEnqueue(const char* code, unsigned char times) {
uint8_t buffer[RfbParser::PayloadSizeBasic] { 0u }; uint8_t buffer[RfbParser::PayloadSizeBasic] { 0u };
if (hexDecode(code, strlen(code), buffer, sizeof(buffer))) { if (hexDecode(code, strlen(code), buffer, sizeof(buffer))) {
_rfbEnqueue(buffer, sizeof(buffer), times); _rfbEnqueue(buffer, sizeof(buffer), times);
} else {
DEBUG_MSG_P(PSTR("[RF] Cannot decode the message\n"));
return true;
} }
DEBUG_MSG_P(PSTR("[RF] Cannot decode the message\n"));
return false;
} }
void _rfbSendRaw(const uint8_t* message, unsigned char size) { void _rfbSendRaw(const uint8_t* message, unsigned char size) {
@ -592,11 +595,22 @@ void _rfbParse(uint8_t code, const std::vector<uint8_t>& payload) {
break; break;
} }
case CodeRecvProto: case CodeRecvProto:
case CodeRecvBucket:
case CodeRecvBucket: {
_rfbAckImpl(); _rfbAckImpl();
DEBUG_MSG_P(PSTR("[RF] CANNOT HANDLE 0x%02X, NOT IMPLEMENTED\n"), code);
char buffer[(RfbParser::MessageSizeMax * 2) + 1] = {0};
if (hexEncode(payload.data(), payload.size(), buffer, sizeof(buffer))) {
DEBUG_MSG_P(PSTR("[RF] Received %s code: %s\n"),
(CodeRecvProto == code) ? "advanced" : "bucket", buffer
);
#if MQTT_SUPPORT
mqttSend(MQTT_TOPIC_RFIN, buffer, false, false);
#endif
} else {
DEBUG_MSG_P(PSTR("[RF] Received code %02X (%u bytes)\n"), code, payload.size());
}
break; break;
} }
}
} }
static RfbParser _rfb_parser(_rfbParse); static RfbParser _rfb_parser(_rfbParse);


Loading…
Cancel
Save