From 6bff8839403ef6e3ebad6e27f2ab991e0ab7ff2d Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 15 Sep 2025 10:30:07 +0200 Subject: [PATCH] drivers/dose: implement netdev API async This changes the behavior of the netdev implementation to match what async drivers do. The current implementation is synchronous, but that can be fixed once an async UART API is available. In any case, we rather should not complicate testing of the network stack by having network devices come in different flavors. --- drivers/dose/dose.c | 10 +++++++--- drivers/include/dose.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/dose/dose.c b/drivers/dose/dose.c index 177c96f7cae1..2ef51a9c08f4 100644 --- a/drivers/dose/dose.c +++ b/drivers/dose/dose.c @@ -532,9 +532,9 @@ static inline void _send_done(dose_t *ctx, bool collision) static int _confirm_send(netdev_t *dev, void *info) { - (void)dev; (void)info; - return -EOPNOTSUPP; + dose_t *ctx = container_of(dev, dose_t, netdev); + return ctx->tx_result; } static int _send(netdev_t *dev, const iolist_t *iolist) @@ -543,6 +543,7 @@ static int _send(netdev_t *dev, const iolist_t *iolist) int8_t retries = 3; size_t pktlen; uint16_t crc; + ctx->tx_result = -EAGAIN; /* discard data when interface is in SLEEP mode */ if (ctx->state == DOSE_STATE_SLEEP) { @@ -603,7 +604,10 @@ static int _send(netdev_t *dev, const iolist_t *iolist) /* Get out of the SEND state */ state(ctx, DOSE_SIGNAL_END); - return pktlen; + ctx->tx_result = (int)pktlen; + dev->event_callback(dev, NETDEV_EVENT_TX_COMPLETE); + + return 0; collision: _send_done(ctx, true); diff --git a/drivers/include/dose.h b/drivers/include/dose.h index 5acdbf776907..1c31b7279bfa 100644 --- a/drivers/include/dose.h +++ b/drivers/include/dose.h @@ -204,6 +204,7 @@ typedef struct { ztimer_t timeout; /**< Timeout timer ensuring always to get back to IDLE state */ uint32_t timeout_base; /**< Base timeout in us */ uart_t uart; /**< UART device to use */ + int tx_result; /**< return code for confirm_send() */ uint8_t uart_octet; /**< Last received octet */ uint8_t flags; /**< Several flags */ } dose_t;