diff --git a/pkg/openthread/contrib/netdev/openthread_netdev.c b/pkg/openthread/contrib/netdev/openthread_netdev.c index ecd243a1a4..c815f1f938 100644 --- a/pkg/openthread/contrib/netdev/openthread_netdev.c +++ b/pkg/openthread/contrib/netdev/openthread_netdev.c @@ -67,8 +67,10 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) { recv_pkt(sInstance, dev); break; case NETDEV_EVENT_TX_COMPLETE: +#ifndef MODULE_NETDEV_NEW_API case NETDEV_EVENT_TX_NOACK: case NETDEV_EVENT_TX_MEDIUM_BUSY: +#endif DEBUG("openthread_netdev: Transmission of a packet\n"); send_pkt(sInstance, dev, event); break; diff --git a/pkg/openthread/contrib/platform_radio.c b/pkg/openthread/contrib/platform_radio.c index a91a1419cc..e999d174d7 100644 --- a/pkg/openthread/contrib/platform_radio.c +++ b/pkg/openthread/contrib/platform_radio.c @@ -172,6 +172,27 @@ void recv_pkt(otInstance *aInstance, netdev_t *dev) } /* Called upon TX event */ +#ifdef MODULE_NETDEV_NEW_API +void send_pkt(otInstance *aInstance, netdev_t *dev, netdev_event_t event) +{ + (void)event; + + assert(dev->driver->confirm_send); + + int res = dev->driver->confirm_send(dev, NULL); + DEBUG("openthread: confirm_send returned %d\n", res); + + if (res > 0) { + otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NONE); + } else if (res == -EBUSY) { + otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_CHANNEL_ACCESS_FAILURE); + } else if (res == -EHOSTUNREACH) { + otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NO_ACK); + } else { + otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_FAILED); + } +} +#else void send_pkt(otInstance *aInstance, netdev_t *dev, netdev_event_t event) { (void)dev; @@ -198,6 +219,7 @@ void send_pkt(otInstance *aInstance, netdev_t *dev, netdev_event_t event) break; } } +#endif /* OpenThread will call this for setting PAN ID */ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid)