Skip to content

Commit

Permalink
fixup! opendsme: add initial support
Browse files Browse the repository at this point in the history
  • Loading branch information
jia200x committed Jun 29, 2022
1 parent 1cf723b commit 00191d9
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkg/opendsme/contrib/opendsme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,24 @@ static bool _pan_coord;
extern void heap_stats(void);
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
{
/* TODO */
uint8_t addr[IEEE802154_SHORT_ADDRESS_LEN];
/* Note that there the short address is assigned by the coordinator and the
* user should not have control over it.
* Given that, and the fact the current MAC does not communicate with
* different PANs, we can always use the short address */
uint8_t *addr;
gnrc_netif_hdr_t *hdr = (gnrc_netif_hdr_t*) pkt->data;
memcpy(addr, gnrc_netif_hdr_get_dst_addr(hdr), IEEE802154_SHORT_ADDRESS_LEN);
pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
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;
}
else {
assert(hdr->dst_l2addr_len == IEEE802154_SHORT_ADDRESS_LEN);
addr = gnrc_netif_hdr_get_dst_addr(hdr);
}

uint16_t _addr = byteorder_ntohs(*((network_uint16_t*) addr));
pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
m_dsme.sendFrame(_addr, (iolist_t*) pkt);

return 0;
Expand Down

0 comments on commit 00191d9

Please sign in to comment.