Skip to content

Commit

Permalink
Add debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
GUVWAF committed Mar 22, 2024
1 parent e6a2c06 commit a5c08b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mesh/ProtobufModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ template <class T> class ProtobufModule : protected SinglePortModule
// it would be better to update even if the message was destined to others.

auto &p = mp.decoded;
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d\n", name, mp.from, mp.id, p.portnum, p.payload.size);
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d, bytes:", name, mp.from, mp.id, p.portnum,
p.payload.size);
for (int i = 0; i < p.payload.size; i++) {
LOG_INFO(" %02x", p.payload.bytes[i]);
}
LOG_INFO("\n");

T scratch;
T *decoded = NULL;
Expand Down
11 changes: 11 additions & 0 deletions src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
} else if (p->decoded.portnum == meshtastic_PortNum_UNKNOWN_APP) {
LOG_ERROR("Invalid portnum (bad psk?)!\n");
} else {
LOG_INFO("Decoded %d bytes:", rawSize);
for (int i = 0; i < rawSize; i++) {
LOG_INFO(" %02x", bytes[i]);
}
LOG_INFO("\n");

// parsing was successful
p->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // change type to decoded
p->channel = chIndex; // change to store the index instead of the hash
Expand Down Expand Up @@ -364,6 +370,11 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
// If the packet is not yet encrypted, do so now
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded);
LOG_INFO("Encoded %d bytes:", numbytes);
for (int i = 0; i < numbytes; i++) {
LOG_INFO(" %02x", bytes[i]);
}
LOG_INFO("\n");

// Only allow encryption on the text message app.
// TODO: Allow modules to opt into compression.
Expand Down

0 comments on commit a5c08b4

Please sign in to comment.