ieee802154: Updated to match nuttx ieee802154 changes
This commit is contained in:
parent
a968904300
commit
4774fe4624
@ -66,3 +66,6 @@ clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean)
|
|||||||
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
|
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
|
||||||
|
|
||||||
-include Make.dep
|
-include Make.dep
|
||||||
|
|
||||||
|
.PHONY: preconfig
|
||||||
|
preconfig:
|
||||||
|
@ -41,84 +41,97 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <apps/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_addrparse(FAR struct ieee802154_packet_s *packet,
|
int ieee802154_addrparse(FAR struct ieee802154_packet_s *packet,
|
||||||
FAR struct ieee802154_addr_s *dest,
|
FAR struct ieee802154_addr_s *dest,
|
||||||
FAR struct ieee802154_addr_s *src)
|
FAR struct ieee802154_addr_s *src)
|
||||||
{
|
{
|
||||||
uint8_t fc1, fc2, daddr, saddr;
|
uint16_t frame_ctrl;
|
||||||
int index=3;
|
int index=3;
|
||||||
|
|
||||||
/* read fc */
|
/* read fc */
|
||||||
fc1 = packet->data[0];
|
|
||||||
fc2 = packet->data[1];
|
frame_ctrl = packet->data[0];
|
||||||
daddr = fc2 & IEEE802154_FC2_DADDR;
|
frame_ctrl |= packet->data[1] << 8;
|
||||||
saddr = fc2 & IEEE802154_FC2_SADDR;
|
|
||||||
|
dest->ia_mode = (frame_ctrl & IEEE802154_FRAMECTRL_DADDR)
|
||||||
|
>> IEEE802154_FRAMECTRL_SHIFT_DADDR;
|
||||||
|
|
||||||
|
|
||||||
|
src->ia_mode = (frame_ctrl & IEEE802154_FRAMECTRL_SADDR)
|
||||||
|
>> IEEE802154_FRAMECTRL_SHIFT_SADDR;
|
||||||
|
|
||||||
/* decode dest addr */
|
/* decode dest addr */
|
||||||
|
|
||||||
if(daddr == IEEE802154_DADDR_SHORT)
|
switch (dest->ia_mode)
|
||||||
{
|
{
|
||||||
memcpy(&dest->ia_panid, packet->data+index, 2);
|
case IEEE802154_ADDRMODE_SHORT:
|
||||||
index += 2; /* skip dest pan id */
|
{
|
||||||
memcpy(&dest->ia_saddr, packet->data+index, 2);
|
memcpy(&dest->ia_panid, packet->data+index, 2);
|
||||||
index += 2; /* skip dest addr */
|
index += 2; /* skip dest pan id */
|
||||||
dest->ia_len = 2;
|
memcpy(&dest->ia_saddr, packet->data+index, 2);
|
||||||
}
|
index += 2; /* skip dest addr */
|
||||||
else if(daddr == IEEE802154_DADDR_EXT)
|
}
|
||||||
{
|
break;
|
||||||
memcpy(&dest->ia_panid, packet->data+index, 2);
|
|
||||||
index += 2; /* skip dest pan id */
|
case IEEE802154_ADDRMODE_EXTENDED:
|
||||||
memcpy(dest->ia_eaddr, packet->data+index, 8);
|
{
|
||||||
index += 8; /* skip dest addr */
|
memcpy(&dest->ia_panid, packet->data+index, 2);
|
||||||
dest->ia_len = 8;
|
index += 2; /* skip dest pan id */
|
||||||
}
|
memcpy(dest->ia_eaddr, packet->data+index, 8);
|
||||||
else if(daddr == IEEE802154_DADDR_NONE)
|
index += 8; /* skip dest addr */
|
||||||
{
|
}
|
||||||
dest->ia_len = 0;
|
break;
|
||||||
}
|
|
||||||
else
|
case IEEE802154_ADDRMODE_NONE:
|
||||||
{
|
break;
|
||||||
return -EINVAL;
|
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode source pan id according to compression */
|
if ((src->ia_mode == IEEE802154_ADDRMODE_SHORT) ||
|
||||||
if( (saddr == IEEE802154_SADDR_SHORT) || (saddr == IEEE802154_SADDR_EXT) )
|
(src->ia_mode == IEEE802154_ADDRMODE_EXTENDED))
|
||||||
{
|
{
|
||||||
if(fc1 & IEEE802154_FC1_INTRA)
|
/* If PANID compression, src PAN ID is same as dest */
|
||||||
{
|
|
||||||
src->ia_panid = dest->ia_panid;
|
if(frame_ctrl & IEEE802154_FRAMECTRL_INTRA)
|
||||||
}
|
{
|
||||||
else
|
src->ia_panid = dest->ia_panid;
|
||||||
{
|
}
|
||||||
memcpy(&src->ia_panid, packet->data+index, 2);
|
else
|
||||||
index += 2; /*skip dest pan id*/
|
{
|
||||||
}
|
memcpy(&src->ia_panid, packet->data+index, 2);
|
||||||
}
|
index += 2; /*skip dest pan id*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* decode source addr */
|
/* decode source addr */
|
||||||
|
|
||||||
if(saddr == IEEE802154_SADDR_SHORT)
|
switch (src->ia_mode)
|
||||||
{
|
{
|
||||||
memcpy(&src->ia_saddr, packet->data+index, 2);
|
case IEEE802154_ADDRMODE_SHORT:
|
||||||
index += 2; /* skip dest addr */
|
{
|
||||||
src->ia_len = 2;
|
memcpy(&src->ia_saddr, packet->data+index, 2);
|
||||||
}
|
index += 2; /* skip src addr */
|
||||||
else if(saddr == IEEE802154_SADDR_EXT)
|
}
|
||||||
{
|
break;
|
||||||
memcpy(src->ia_eaddr, packet->data+index, 8);
|
|
||||||
index += 8; /* skip dest addr */
|
case IEEE802154_ADDRMODE_EXTENDED:
|
||||||
src->ia_len = 8;
|
{
|
||||||
}
|
memcpy(src->ia_eaddr, packet->data+index, 8);
|
||||||
else if(saddr == IEEE802154_SADDR_NONE)
|
index += 8; /* skip src addr */
|
||||||
{
|
}
|
||||||
src->ia_len = 0;
|
break;
|
||||||
}
|
|
||||||
else
|
case IEEE802154_ADDRMODE_NONE:
|
||||||
{
|
break;
|
||||||
return -EINVAL;
|
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
@ -41,38 +41,55 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <apps/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
|
int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
|
||||||
FAR struct ieee802154_addr_s *dest,
|
FAR struct ieee802154_addr_s *dest,
|
||||||
FAR struct ieee802154_addr_s *src)
|
FAR struct ieee802154_addr_s *src)
|
||||||
{
|
{
|
||||||
|
uint16_t frame_ctrl;
|
||||||
int index=3; //skip fc and seq
|
int index=3; //skip fc and seq
|
||||||
|
|
||||||
|
/* Get the frame control word so we can manipulate it */
|
||||||
|
|
||||||
|
frame_ctrl = packet->data[0];
|
||||||
|
frame_ctrl |= packet->data[1] << 8;
|
||||||
|
|
||||||
|
|
||||||
|
/* Clear the destination address mode */
|
||||||
|
|
||||||
|
frame_ctrl &= ~IEEE802154_FRAMECTRL_DADDR;
|
||||||
|
|
||||||
/* encode dest addr */
|
/* encode dest addr */
|
||||||
|
|
||||||
if(dest == NULL || dest->ia_len == 0)
|
if(dest == NULL || dest->ia_mode == IEEE802154_ADDRMODE_NONE)
|
||||||
{
|
{
|
||||||
packet->data[1] = (packet->data[1] & ~IEEE802154_FC2_DADDR) | IEEE802154_DADDR_NONE;
|
/* Set the destination address mode to none */
|
||||||
|
|
||||||
|
frame_ctrl |= IEEE802154_ADDRMODE_NONE << IEEE802154_FRAMECTRL_SHIFT_DADDR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memcpy(packet->data+index, &dest->ia_panid, 2);
|
memcpy(packet->data+index, &dest->ia_panid, 2);
|
||||||
index += 2; /* skip dest pan id */
|
index += 2; /* skip dest pan id */
|
||||||
if(dest->ia_len == 2)
|
|
||||||
|
/* Set the dest address mode field */
|
||||||
|
|
||||||
|
frame_ctrl |= dest->ia_mode << IEEE802154_FRAMECTRL_SHIFT_DADDR;
|
||||||
|
|
||||||
|
if(dest->ia_mode == IEEE802154_ADDRMODE_SHORT)
|
||||||
{
|
{
|
||||||
memcpy(packet->data+index, &dest->ia_saddr, 2);
|
memcpy(packet->data+index, &dest->ia_saddr, 2);
|
||||||
index += 2; /* skip dest addr */
|
index += 2; /* skip dest addr */
|
||||||
packet->data[1] = (packet->data[1] & ~IEEE802154_FC2_DADDR) | IEEE802154_DADDR_SHORT;
|
|
||||||
}
|
}
|
||||||
else if(dest->ia_len == 8)
|
else if(dest->ia_mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
memcpy(packet->data+index, &dest->ia_panid, 2);
|
memcpy(packet->data+index, &dest->ia_panid, 2);
|
||||||
index += 2; /* skip dest pan id */
|
index += 2; /* skip dest pan id */
|
||||||
memcpy(packet->data+index, dest->ia_eaddr, 8);
|
memcpy(packet->data+index, dest->ia_eaddr, 8);
|
||||||
index += 8; /* skip dest addr */
|
index += 8; /* skip dest addr */
|
||||||
packet->data[1] = (packet->data[1] & ~IEEE802154_FC2_DADDR) | IEEE802154_DADDR_EXT;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -80,42 +97,57 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packet->data[0] &= ~IEEE802154_FC1_INTRA;
|
/* Clear the PAN ID Compression Field */
|
||||||
if( (dest != NULL && dest->ia_len != 0) && (src != NULL && src->ia_len != 0) )
|
|
||||||
|
frame_ctrl &= ~IEEE802154_FRAMECTRL_INTRA;
|
||||||
|
|
||||||
|
if( (dest != NULL && dest->ia_mode != IEEE802154_ADDRMODE_NONE) &&
|
||||||
|
(src != NULL && src->ia_mode != IEEE802154_ADDRMODE_NONE) )
|
||||||
{
|
{
|
||||||
/* we have both adresses, encode source pan id according to compression */
|
/* we have both adresses, encode source pan id according to compression */
|
||||||
|
|
||||||
if( dest->ia_panid == src->ia_panid)
|
if( dest->ia_panid == src->ia_panid)
|
||||||
{
|
{
|
||||||
packet->data[0] |= IEEE802154_FC1_INTRA;
|
frame_ctrl |= IEEE802154_FRAMECTRL_INTRA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Clear the source address mode */
|
||||||
|
|
||||||
|
frame_ctrl &= ~IEEE802154_FRAMECTRL_SADDR;
|
||||||
|
|
||||||
/* encode source addr */
|
/* encode source addr */
|
||||||
|
|
||||||
if(src == NULL || src->ia_len==0)
|
if(src == NULL || src->ia_mode == IEEE802154_ADDRMODE_NONE)
|
||||||
{
|
{
|
||||||
packet->data[1] = (packet->data[1] & ~IEEE802154_FC2_SADDR) | IEEE802154_SADDR_NONE;
|
/* Set the source address mode to none */
|
||||||
|
|
||||||
|
frame_ctrl |= IEEE802154_ADDRMODE_NONE << IEEE802154_FRAMECTRL_SHIFT_SADDR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*add src pan id if it was not compressed before*/
|
/* add src pan id if it was not compressed before */
|
||||||
if(!(packet->data[0] & IEEE802154_FC1_INTRA))
|
|
||||||
|
if(!(frame_ctrl & IEEE802154_FRAMECTRL_INTRA))
|
||||||
{
|
{
|
||||||
memcpy(packet->data+index, &src->ia_panid, 2);
|
memcpy(packet->data+index, &src->ia_panid, 2);
|
||||||
index += 2; /*skip src pan id*/
|
index += 2; /*skip src pan id*/
|
||||||
}
|
}
|
||||||
if(src->ia_len == 2)
|
|
||||||
|
/* Set the source address mode field */
|
||||||
|
|
||||||
|
frame_ctrl |= src->ia_mode << IEEE802154_FRAMECTRL_SHIFT_SADDR;
|
||||||
|
|
||||||
|
if(src->ia_mode == IEEE802154_ADDRMODE_SHORT)
|
||||||
{
|
{
|
||||||
memcpy(packet->data+index, &src->ia_saddr, 2);
|
memcpy(packet->data+index, &src->ia_saddr, 2);
|
||||||
index += 2; /* skip src addr */
|
index += 2; /* skip src addr */
|
||||||
packet->data[1] = (packet->data[1] & ~IEEE802154_FC2_SADDR) | IEEE802154_SADDR_SHORT;
|
|
||||||
}
|
}
|
||||||
else if(src->ia_len == 8)
|
else if(src->ia_mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
memcpy(packet->data+index, src->ia_eaddr, 8);
|
memcpy(packet->data+index, src->ia_eaddr, 8);
|
||||||
index += 8; /* skip src addr */
|
index += 8; /* skip src addr */
|
||||||
packet->data[1] = (packet->data[1] & ~IEEE802154_FC2_SADDR) | IEEE802154_SADDR_EXT;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -123,6 +155,9 @@ int ieee802154_addrstore(FAR struct ieee802154_packet_s *packet,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy the frame control word back to the buffer */
|
||||||
|
|
||||||
|
memcpy(packet->data, &frame_ctrl, 2);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <apps/ieee802154/ieee802154.h>
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_addrtostr(FAR char *buf, int len, FAR struct ieee802154_addr_s *addr)
|
int ieee802154_addrtostr(FAR char *buf, int len, FAR struct ieee802154_addr_s *addr)
|
||||||
{
|
{
|
||||||
@ -51,11 +51,11 @@ int ieee802154_addrtostr(FAR char *buf, int len, FAR struct ieee802154_addr_s *a
|
|||||||
uint16_t panid = addr->ia_panid;
|
uint16_t panid = addr->ia_panid;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(addr->ia_len == 0)
|
if(addr->ia_mode == IEEE802154_ADDRMODE_NONE)
|
||||||
{
|
{
|
||||||
return snprintf(buf, len, "none");
|
return snprintf(buf, len, "none");
|
||||||
}
|
}
|
||||||
else if(addr->ia_len == 2)
|
else if(addr->ia_mode == IEEE802154_ADDRMODE_SHORT)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_BIG_ENDIAN
|
#ifndef CONFIG_BIG_ENDIAN
|
||||||
uint16_t saddr = ((addr->ia_saddr & 0xff)<<8) | ((addr->ia_saddr>>8) & 0xff);
|
uint16_t saddr = ((addr->ia_saddr & 0xff)<<8) | ((addr->ia_saddr>>8) & 0xff);
|
||||||
@ -64,7 +64,7 @@ int ieee802154_addrtostr(FAR char *buf, int len, FAR struct ieee802154_addr_s *a
|
|||||||
#endif
|
#endif
|
||||||
return snprintf(buf, len, "%04X/%04X", panid, saddr);
|
return snprintf(buf, len, "%04X/%04X", panid, saddr);
|
||||||
}
|
}
|
||||||
else if(addr->ia_len == 8)
|
else if(addr->ia_mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int off = snprintf(buf, len, "%04X/", panid);
|
int off = snprintf(buf, len, "%04X/", panid);
|
||||||
|
@ -42,15 +42,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
|
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCGCCA, (unsigned long)cca );
|
int ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)cca );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCGCCA failed\n");
|
printf("PHY802154IOC_GET_CCA failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_getchan(int fd, FAR uint8_t *chan)
|
int ieee802154_getchan(int fd, FAR uint8_t *chan)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCGCHAN, (unsigned long)chan );
|
int ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)chan );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCGCHAN failed\n");
|
printf("PHY802154IOC_GET_CHAN failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
|
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSCCA, (unsigned long)cca );
|
int ret = ioctl(fd, PHY802154IOC_SET_CCA, (unsigned long)cca );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSCCA failed\n");
|
printf("PHY802154IOC_SET_CCA failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_setchan(int fd, uint8_t chan)
|
int ieee802154_setchan(int fd, uint8_t chan)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSCHAN, (unsigned long)chan );
|
int ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)chan );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSCHAN failed\n");
|
printf("PHY802154IOC_SET_CHAN failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_setdevmode(int fd, uint8_t devmode)
|
int ieee802154_setdevmode(int fd, uint8_t devmode)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSDEVMODE, (unsigned long)devmode );
|
int ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, (unsigned long)devmode );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSDEVMODE failed\n");
|
printf("PHY802154IOC_SET_DEVMODE failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_seteaddr(int fd, uint8_t *eaddr)
|
int ieee802154_seteaddr(int fd, uint8_t *eaddr)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSEADDR, (unsigned long)eaddr );
|
int ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)eaddr );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSEADDR failed\n");
|
printf("PHY802154IOC_SET_EADDR failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_setpanid(int fd, uint16_t panid)
|
int ieee802154_setpanid(int fd, uint16_t panid)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSPANID, (unsigned long)panid );
|
int ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)panid );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSPANID failed\n");
|
printf("PHY802154IOC_SET_PANID failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,15 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_setpromisc(int fd, bool promisc)
|
int ieee802154_setpromisc(int fd, bool promisc)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSPROMISC, (unsigned long)promisc );
|
int ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)promisc );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSPROMISC failed\n");
|
printf("PHY802154IOC_SET_PROMISC failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
int ieee802154_setsaddr(int fd, uint16_t saddr)
|
int ieee802154_setsaddr(int fd, uint16_t saddr)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, MAC854IOCSSADDR, (unsigned long)saddr );
|
int ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)saddr );
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCSSADDR failed\n");
|
printf("PHY802154IOC_SET_SADDR failed\n");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
|
|
||||||
#include <apps/ieee802154/ieee802154.h>
|
#include <apps/ieee802154/ieee802154.h>
|
||||||
|
|
||||||
|
@ -59,9 +59,10 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
#include <nuttx/ieee802154/ieee802154_dev.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
#include <apps/ieee802154/ieee802154.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
|
#include "ieee802154/ieee802154.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
@ -97,7 +98,7 @@ int energy_scan(int fd)
|
|||||||
printf("Device is not an IEEE 802.15.4 interface!\n");
|
printf("Device is not an IEEE 802.15.4 interface!\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = ioctl(fd, MAC854IOCGED, (unsigned long)&energy);
|
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, (unsigned long)&energy);
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
{
|
{
|
||||||
printf("Device is not an IEEE 802.15.4 interface!\n");
|
printf("Device is not an IEEE 802.15.4 interface!\n");
|
||||||
@ -153,10 +154,10 @@ static int status(int fd)
|
|||||||
|
|
||||||
/* Get information */
|
/* Get information */
|
||||||
|
|
||||||
ret = ioctl(fd, MAC854IOCGPANID, (unsigned long)&panid);
|
ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)&panid);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCGPANID failed\n");
|
printf("PHY802154IOC_GET_PANID failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,22 +167,22 @@ static int status(int fd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ioctl(fd, MAC854IOCGSADDR, (unsigned long)&saddr);
|
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)&saddr);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCGSADDR failed\n");
|
printf("PHY802154IOC_GET_SADDR failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = ioctl(fd, MAC854IOCGEADDR, (unsigned long)&eaddr[0]);
|
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)&eaddr[0]);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCGEADR failed\n");
|
printf("PHY802154IOC_GET_EADDR failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = ioctl(fd, MAC854IOCGPROMISC, (unsigned long)&promisc);
|
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)&promisc);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
printf("MAC854IOCGPROMISC failed\n");
|
printf("PHY802154IOC_GET_PROMISC failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = ieee802154_getcca(fd, &cca);
|
ret = ieee802154_getcca(fd, &cca);
|
||||||
@ -548,7 +549,7 @@ data_error:
|
|||||||
gTxPacket.data[gTxPacket.len++] = 0x03; //mac command, no ack, no panid compression
|
gTxPacket.data[gTxPacket.len++] = 0x03; //mac command, no ack, no panid compression
|
||||||
gTxPacket.data[gTxPacket.len++] = 0x00; //short destination address, no source address
|
gTxPacket.data[gTxPacket.len++] = 0x00; //short destination address, no source address
|
||||||
gTxPacket.data[gTxPacket.len++] = 0; //seq
|
gTxPacket.data[gTxPacket.len++] = 0; //seq
|
||||||
dest.ia_len = 2;
|
dest.ia_mode = IEEE802154_ADDRMODE_SHORT;
|
||||||
dest.ia_panid = 0xFFFF;
|
dest.ia_panid = 0xFFFF;
|
||||||
dest.ia_saddr = 0xFFFF;
|
dest.ia_saddr = 0xFFFF;
|
||||||
|
|
||||||
|
@ -38,19 +38,8 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <nuttx/wireless/ieee802154/ieee802154.h>
|
||||||
struct ieee802154_addr_s
|
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||||
{
|
|
||||||
uint8_t ia_len; /* structure length NOT including panid, so 2/8*/
|
|
||||||
uint16_t ia_panid;
|
|
||||||
union {
|
|
||||||
uint16_t _ia_saddr;
|
|
||||||
uint8_t _ia_eaddr[8];
|
|
||||||
} ia_addr;
|
|
||||||
#define ia_saddr ia_addr._ia_saddr
|
|
||||||
#define ia_eaddr ia_addr._ia_eaddr
|
|
||||||
};
|
|
||||||
#define IEEE802154_ADDRSTRLEN 22 /* (4+1+8*2) */
|
|
||||||
|
|
||||||
int ieee802154_setchan (int fd, uint8_t chan);
|
int ieee802154_setchan (int fd, uint8_t chan);
|
||||||
int ieee802154_getchan (int fd, FAR uint8_t *chan);
|
int ieee802154_getchan (int fd, FAR uint8_t *chan);
|
||||||
|
Loading…
Reference in New Issue
Block a user