drivers/rn2xx3: fix incorrectly terminated hex strings
When writing an array of bytes, each byte is converted on the fly to 2 hex characters and sent to the rn2xx3 module. This change ensures each string is correctly terminated, with null character, when written to the module
This commit is contained in:
parent
f5d4d41f7b
commit
1f6895d0f7
@ -228,9 +228,10 @@ void rn2xx3_cmd_start(rn2xx3_t *dev)
|
|||||||
|
|
||||||
void rn2xx3_cmd_append(rn2xx3_t *dev, const uint8_t *payload, uint8_t payload_len)
|
void rn2xx3_cmd_append(rn2xx3_t *dev, const uint8_t *payload, uint8_t payload_len)
|
||||||
{
|
{
|
||||||
char payload_str[2];
|
char payload_str[3] = { 0 };
|
||||||
for (unsigned i = 0; i < payload_len; i++) {
|
for (unsigned i = 0; i < payload_len; i++) {
|
||||||
fmt_byte_hex(payload_str, payload[i]);
|
fmt_byte_hex(payload_str, payload[i]);
|
||||||
|
DEBUG("%s", payload_str);
|
||||||
_uart_write_str(dev, payload_str);
|
_uart_write_str(dev, payload_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user