Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions pkg/opendsme/contrib/gnrc_netif_opendsme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* @file
* @author José I. Álamos <jose.alamos@haw-hamburg.de>
*/

#include "opendsme/DSMEPlatform.h"
#include "opendsme/opendsme.h"
#include "mac_services/DSME_Common.h"
#include "net/gnrc/netif/hdr.h"

Check warning on line 17 in pkg/opendsme/contrib/gnrc_netif_opendsme.cpp

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -12,6 +12,6 @@ -#include "opendsme/DSMEPlatform.h" -#include "opendsme/opendsme.h" #include "mac_services/DSME_Common.h" #include "net/gnrc/netif/hdr.h" +#include "opendsme/DSMEPlatform.h" +#include "opendsme/opendsme.h"
dsme::DSMEPlatform m_dsme;

extern "C" {
Expand All @@ -29,31 +29,44 @@
uint8_t bcast[2] = { 0xFF, 0xFF };
uint8_t *addr;

pkt = gnrc_pktbuf_start_write(pkt);
gnrc_netif_hdr_t *hdr = (gnrc_netif_hdr_t *)pkt->data;

if (hdr->flags &= GNRC_NETIF_HDR_FLAGS_MULTICAST) {
if (hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude suggested checking for ..._BROADCAST as well. I'll have to check if both have to be set (..._BROADCAST | ..._MULTICAST) or either one has to be set.

Will check again, but the session is on my office workstation which I won't see until next week or the week after.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BROADCAST and MULTICAST are the same in IEEE 802.15.4, but not in gnrc_netif (which also serves other link layers which make a difference there; e.g., Ethernet). So it does sound sensible to check both for a 802.15.4-based MAC.

addr = static_cast<uint8_t *>(&bcast[0]);
}
else if (hdr->dst_l2addr_len == IEEE802154_LONG_ADDRESS_LEN) {
addr = gnrc_netif_hdr_get_dst_addr(hdr)
+ IEEE802154_LONG_ADDRESS_LEN
- IEEE802154_SHORT_ADDRESS_LEN;
}

Check warning on line 41 in pkg/opendsme/contrib/gnrc_netif_opendsme.cpp

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -37,5 +37,4 @@ else if (hdr->dst_l2addr_len == IEEE802154_LONG_ADDRESS_LEN) { - addr = gnrc_netif_hdr_get_dst_addr(hdr) - + IEEE802154_LONG_ADDRESS_LEN - - IEEE802154_SHORT_ADDRESS_LEN; + addr = gnrc_netif_hdr_get_dst_addr(hdr) + IEEE802154_LONG_ADDRESS_LEN - + IEEE802154_SHORT_ADDRESS_LEN; }
else if (hdr->dst_l2addr_len == IEEE802154_SHORT_ADDRESS_LEN) {
addr = gnrc_netif_hdr_get_dst_addr(hdr);
}
else {
gnrc_pktbuf_release(pkt);
return -EBADMSG;
}

uint16_t _addr = byteorder_ntohs(*((network_uint16_t *)addr));
gnrc_pktsnip_t *payload = pkt->next;

pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
m_dsme.sendFrame(_addr, (iolist_t *)pkt);
if (!m_dsme.isAssociated()) {
return -ENOTCONN;
}
if (payload == NULL) {
return -ENODATA;
}

return 0;
int len = (int)gnrc_pkt_len(payload);

/* openDSME releases its own reference to the payload once the MAC confirmed the frame.
* There is no confirm_send() as there is no netdev for opendsme towards gnrc_netif,
* so report the frame as handed over right away.
* (Kind of ugly hack)
*/
Comment thread
Stopkaa marked this conversation as resolved.
Resolved
gnrc_pktbuf_hold(payload, 1);
m_dsme.sendFrame(_addr, (iolist_t *)payload);

return (len > 0) ? len : 1;
}

static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
Expand Down Expand Up @@ -93,11 +106,11 @@
break;
}
case NETOPT_LINK:
assert(opt->data_len >= sizeof(netopt_enable_t));
*((netopt_enable_t *)opt->data) = m_dsme.isAssociated()
? NETOPT_ENABLE
: NETOPT_DISABLE;
return sizeof(netopt_enable_t);

Check warning on line 113 in pkg/opendsme/contrib/gnrc_netif_opendsme.cpp

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -109,5 +108,3 @@ assert(opt->data_len >= sizeof(netopt_enable_t)); - *((netopt_enable_t *)opt->data) = m_dsme.isAssociated() - ? NETOPT_ENABLE - : NETOPT_DISABLE; + *((netopt_enable_t *)opt->data) = m_dsme.isAssociated() ? NETOPT_ENABLE : NETOPT_DISABLE; return sizeof(netopt_enable_t);
default:
res = -ENOTSUP;
break;
Expand Down Expand Up @@ -174,14 +187,14 @@
.get = _get,
.set = _set,
};

int gnrc_netif_opendsme_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, const char *name, netdev_t *dev)
{
m_dsme.setGNRCNetif(netif);
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&dsme_ops);
}

Check warning on line 197 in pkg/opendsme/contrib/gnrc_netif_opendsme.cpp

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -190,8 +187,7 @@ -int gnrc_netif_opendsme_create(gnrc_netif_t *netif, char *stack, int stacksize, - char priority, const char *name, netdev_t *dev) +int gnrc_netif_opendsme_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority, + const char *name, netdev_t *dev) { m_dsme.setGNRCNetif(netif); - return gnrc_netif_create(netif, stack, stacksize, priority, name, dev, - &dsme_ops); + return gnrc_netif_create(netif, stack, stacksize, priority, name, dev, &dsme_ops); }
}

/** @} */
5 changes: 4 additions & 1 deletion sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,30 @@
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/

#include "log.h"
#include "board.h"
#include "nrf802154.h"
#include "net/gnrc/netif/ieee802154.h"
#include "include/init_devs.h"
#include "net/netdev/ieee802154_submac.h"

#if IS_USED(MODULE_OPENDSME)
#include "opendsme/opendsme.h"
# include "opendsme/opendsme.h"
# include "nrf_clock.h"
#endif

Check warning on line 26 in sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -15,12 +15,12 @@ -#include "log.h" #include "board.h" -#include "nrf802154.h" -#include "net/gnrc/netif/ieee802154.h" #include "include/init_devs.h" +#include "log.h" +#include "net/gnrc/netif/ieee802154.h" #include "net/netdev/ieee802154_submac.h" +#include "nrf802154.h" #if IS_USED(MODULE_OPENDSME) -# include "opendsme/opendsme.h" # include "nrf_clock.h" +# include "opendsme/opendsme.h" #endif

/**
* @brief Define stack parameters for the MAC layer thread
* @{
*/
#ifndef NRF802154_MAC_STACKSIZE
#define NRF802154_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT)
#endif

Check warning on line 34 in sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -32,3 +32,3 @@ #ifndef NRF802154_MAC_STACKSIZE -#define NRF802154_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT) +# define NRF802154_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT) #endif

#ifndef NRF802154_MAC_PRIO
#define NRF802154_MAC_PRIO (GNRC_NETIF_PRIO)
#endif

Check warning on line 38 in sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -36,3 +36,3 @@ #ifndef NRF802154_MAC_PRIO -#define NRF802154_MAC_PRIO (GNRC_NETIF_PRIO) +# define NRF802154_MAC_PRIO (GNRC_NETIF_PRIO) #endif
/** @} */

static char _stack[NRF802154_MAC_STACKSIZE];
Expand All @@ -49,22 +50,24 @@
netdev_register(&nrf802154_netdev.dev.netdev, NETDEV_NRF802154, 0);

nrf802154_init();
#if IS_USED(MODULE_OPENDSME)
nrf802154_hal_setup(&nrf802154_netdev.submac.dev);
/* NOTE: This casts a Radio HAL descriptor to a netdev and should be
* addressed as soon as the GNRC<->netdev dependency is removed.
*/
gnrc_netif_opendsme_create(&_netif, _stack,
NRF802154_MAC_STACKSIZE,
NRF802154_MAC_PRIO, "nrf802154",
(netdev_t*) &nrf802154_netdev.submac.dev);

clock_hfxo_request();
#else
netdev_ieee802154_submac_init(&nrf802154_netdev);
nrf802154_hal_setup(&nrf802154_netdev.submac.dev);
gnrc_netif_ieee802154_create(&_netif, _stack,
NRF802154_MAC_STACKSIZE,
NRF802154_MAC_PRIO, "nrf802154",
&nrf802154_netdev.dev.netdev);
#endif

Check warning on line 71 in sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c

View workflow job for this annotation

GitHub Actions / static-tests

clang-format proposes the following patch

@@ -53,19 +53,15 @@ #if IS_USED(MODULE_OPENDSME) - nrf802154_hal_setup(&nrf802154_netdev.submac.dev); - /* NOTE: This casts a Radio HAL descriptor to a netdev and should be - * addressed as soon as the GNRC<->netdev dependency is removed. - */ - gnrc_netif_opendsme_create(&_netif, _stack, - NRF802154_MAC_STACKSIZE, - NRF802154_MAC_PRIO, "nrf802154", - (netdev_t*) &nrf802154_netdev.submac.dev); + nrf802154_hal_setup(&nrf802154_netdev.submac.dev); + /* NOTE: This casts a Radio HAL descriptor to a netdev and should be + * addressed as soon as the GNRC<->netdev dependency is removed. + */ + gnrc_netif_opendsme_create(&_netif, _stack, NRF802154_MAC_STACKSIZE, NRF802154_MAC_PRIO, + "nrf802154", (netdev_t *)&nrf802154_netdev.submac.dev); - clock_hfxo_request(); + clock_hfxo_request(); #else - netdev_ieee802154_submac_init(&nrf802154_netdev); - nrf802154_hal_setup(&nrf802154_netdev.submac.dev); - gnrc_netif_ieee802154_create(&_netif, _stack, - NRF802154_MAC_STACKSIZE, - NRF802154_MAC_PRIO, "nrf802154", - &nrf802154_netdev.dev.netdev); + netdev_ieee802154_submac_init(&nrf802154_netdev); + nrf802154_hal_setup(&nrf802154_netdev.submac.dev); + gnrc_netif_ieee802154_create(&_netif, _stack, NRF802154_MAC_STACKSIZE, NRF802154_MAC_PRIO, + "nrf802154", &nrf802154_netdev.dev.netdev); #endif
}
/** @} */
Loading