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

pkg/openthread: add support for netdev_new_api

This commit is contained in:
Benjamin Valentin 2024-12-23 21:59:04 +01:00
parent a953ae9d9f
commit 76e06ad60c
2 changed files with 24 additions and 0 deletions

View File

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

View File

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