6LoWPAN: Correct a few addressing issues. The apps/examples/udp test now appears to be fully functional. Also reserve two bytes at the end of the frame for the FCS.

This commit is contained in:
Gregory Nutt
2017-06-21 13:43:40 -06:00
parent 2397bc728b
commit 05590a2228
5 changed files with 30 additions and 13 deletions
+5 -5
View File
@@ -1533,22 +1533,22 @@ FAR struct ieee802154_radio_s *at86rf23x_init(FAR struct spi_dev_s *spi,
/* Configure the Pan id */
//at86rf23x_setpanid (&dev->ieee, IEEE802154_PAN_DEFAULT);
//at86rf23x_setpanid(&dev->ieee, IEEE802154_PAN_DEFAULT);
/* Configure the Short Addr */
//at86rf23x_setsaddr (&dev->ieee, IEEE802154_SADDR_UNSPEC);
//at86rf23x_setsaddr(&dev->ieee, IEEE802154_SADDR_UNSPEC);
/* Configure the IEEE Addr */
//at86rf23x_seteaddr (&dev->ieee, IEEE802154_EADDR_UNSPEC);
//at86rf23x_seteaddr(&dev->ieee, IEEE802154_EADDR_UNSPEC);
/* Default device params at86rf23x defaults to energy detect only */
cca.use_ed = 1;
cca.use_cs = 0;
cca.edth = 0x60; /* CCA mode ED, no carrier sense, recommenced ED
* threshold -69 dBm */
cca.edth = 0x60; /* CCA mode ED, no carrier sense, recommenced ED
* threshold -69 dBm */
at86rf23x_setcca(&dev->ieee, &cca);
/* Put the Device to RX ON Mode */
+4
View File
@@ -78,6 +78,10 @@
#define SIXLOWPAN_MAC_STDFRAME 127
/* Space for a two byte FCS must be reserved at the end of the frame */
#define SIXLOWPAN_MAC_FCSSIZE 2
/****************************************************************************
* Public Types
****************************************************************************/
+15 -3
View File
@@ -73,6 +73,18 @@
# error IOBs must be large enough to hold full IEEE802.14.5 frame
#endif
/* A IOB must also be big enought to hold the maximum MAC header (25 bytes?)
* plus the FCS and have some amount of space left for the payload.
*/
#if CONFIG_NET_6LOWPAN_FRAMELEN < (SIXLOWPAN_MAC_FCSSIZE + 25)
# error CONFIG_NET_6LOWPAN_FRAMELEN too small to hold a IEEE802.14.5 frame
#endif
/* We must reserve space at the end of the frame for a 2-byte FCS */
#define SIXLOWPAN_FRAMELEN (CONFIG_NET_6LOWPAN_FRAMELEN - SIXLOWPAN_MAC_FCSSIZE)
/* There must be at least enough IOBs to hold the full MTU. Probably still
* won't work unless there are a few more.
*/
@@ -371,7 +383,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* Check if we need to fragment the packet into several frames */
if (buflen > (CONFIG_NET_6LOWPAN_FRAMELEN - g_frame_hdrlen))
if (buflen > (SIXLOWPAN_FRAMELEN - g_frame_hdrlen))
{
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* qhead will hold the generated frame list; frames will be
@@ -429,7 +441,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
* bytes.
*/
paysize = (CONFIG_NET_6LOWPAN_FRAMELEN - g_frame_hdrlen) & ~7;
paysize = (SIXLOWPAN_FRAMELEN - g_frame_hdrlen) & ~7;
memcpy(fptr + g_frame_hdrlen, buf, paysize);
/* Set outlen to what we already sent from the IP payload */
@@ -501,7 +513,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* Copy payload and enqueue */
/* Check for the last fragment */
paysize = (CONFIG_NET_6LOWPAN_FRAMELEN - fragn_hdrlen) &
paysize = (SIXLOWPAN_FRAMELEN - fragn_hdrlen) &
SIXLOWPAN_DISPATCH_FRAG_MASK;
if (buflen - outlen < paysize)
{
+2 -1
View File
@@ -89,7 +89,8 @@ void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr,
{
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
memcpy(saddr, &ipaddr[7], NET_6LOWPAN_SADDRSIZE);
saddr->u8[0] = ipaddr[7] >> 8;
saddr->u8[1] = ipaddr[7] & 0xff;
saddr->u8[0] ^= 0x02;
}
+4 -4
View File
@@ -34,9 +34,9 @@ choice
WARNING!! The IEEE802.15.4 network device must never run on the same
work queue as does the IEEE 802.15.4 MAC. That configuration will
cause deadlocks: The network logic may be blocked on the work queue
waiting on resources that can only be free by the MAC logic but the
waiting on resources that can only be freed by the MAC logic but the
MAC is unable to run because the work queue is blocked. The
recommend configuration is: Network on the LP work queue; MAC on HP
recommended configuration is: Network on the LP work queue; MAC on HP
work queue. Blocking on the HP work queue is a very bad thing in
any case.
@@ -174,9 +174,9 @@ choice
WARNING!! The IEEE802.15.4 network device must never run on the same
work queue as does the IEEE 802.15.4 MAC. That configuration will
cause deadlocks: The network logic may be blocked on the work queue
waiting on resources that can only be free by the MAC logic but the
waiting on resources that can only be freed by the MAC logic but the
MAC is unable to run because the work queue is blocked. The
recommend configuration is: Network on the LP work queue; MAC on HP
recommended configuration is: Network on the LP work queue; MAC on HP
work queue. Blocking on the HP work queue is a very bad thing in
any case.