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:
Alexandre Abadie 2019-06-07 10:39:31 +02:00
parent f5d4d41f7b
commit 1f6895d0f7
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -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);
} }
} }