Skip to content

Commit d124c5d

Browse files
Damien Laidinjoextodd
authored andcommitted
fix when printing string length
1 parent c88c9e5 commit d124c5d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/MXChipSendReceive/MXChipSendReceive.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ void on_sent_callback(void *data, uint8_t *payload, size_t length, uint8_t chann
155155
{
156156
char identifier[length * 2 + 1];
157157
payload_to_hex(payload, length, identifier);
158-
158+
char strLength[8] = {0};
159+
itoa(length, strLength, 10);
159160
Screen.clean();
160161
Screen.print(0, "Sent !");
161162
Screen.print(1, (const char *) identifier, true);
162-
Screen.print(3, strlen(identifer));
163+
Screen.print(3, strLength);
163164
rgbLed.setColor(0, 255, 255);
164165
}
165166

@@ -181,11 +182,12 @@ void on_received_callback(void *data, uint8_t *payload, size_t length, uint8_t c
181182
{
182183
char identifier[length * 2 + 1];
183184
payload_to_hex(payload, length, identifier);
184-
185+
char strLength[8] = {0};
186+
itoa(length, strLength, 10);
185187
Screen.clean();
186188
Screen.print(0, "Received !");
187189
Screen.print(1, (const char *) identifier, true);
188-
Screen.print(3, strlen(identifer));
190+
Screen.print(3, strLength);
189191
rgbLed.setColor(0, 255, 0);
190192
}
191193
// A null pointer with a length of 0 means the decode has failed.

0 commit comments

Comments
 (0)