1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/sx126x: fix netdev send function

This commit fixes the send function of sx126x. The loop that reads the
iolist was not considering the offset. Therefore each iolist snippet was
being written into the first position.

The loop was also setting the payload length to the size of the iolist
snippet. Then the payload was also wrong.

With this commit an iolist is copied sequentially into the framebuffer
and the payload length is set to `iolist_size`
This commit is contained in:
Jose Alamos 2021-06-18 10:02:34 +02:00
parent 2765e5463d
commit d4941604d9
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9

View File

@ -51,23 +51,24 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
return -ENOTSUP;
}
uint8_t size = iolist_size(iolist);
/* Ignore send if packet size is 0 */
if (!size) {
return 0;
}
DEBUG("[sx126x] netdev: sending packet now (size: %d).\n", size);
size_t pos = 0;
/* Write payload buffer */
for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
if (iol->iol_len > 0) {
sx126x_set_lora_payload_length(dev, iol->iol_len);
sx126x_write_buffer(dev, 0, iol->iol_base, iol->iol_len);
sx126x_write_buffer(dev, pos, iol->iol_base, iol->iol_len);
DEBUG("[sx126x] netdev: send: wrote data to payload buffer.\n");
pos += iol->iol_len;
}
}
/* Ignore send if packet size is 0 */
if (!pos) {
return 0;
}
DEBUG("[sx126x] netdev: sending packet now (size: %d).\n", pos);
sx126x_set_lora_payload_length(dev, pos);
state = NETOPT_STATE_TX;
netdev->driver->set(netdev, NETOPT_STATE, &state, sizeof(uint8_t));
DEBUG("[sx126x] netdev: send: transmission in progress.\n");