Merged in merlin17/apps/ieee802154 (pull request #90)
Switches IEEE 802.15.4 based code to using byte arrays instead of uint16_t values for short address and PAN ID Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
commit
2dc22e6b2e
@ -118,7 +118,7 @@ int netlib_getmacaddr(FAR const char *ifname, FAR uint8_t *macaddr);
|
||||
/* Set IEEE 802.15.4 extended address. */
|
||||
|
||||
int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr);
|
||||
int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid);
|
||||
int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid);
|
||||
bool netlib_eaddrconv(FAR const char *hwstr, FAR uint8_t *hw);
|
||||
#endif
|
||||
|
||||
|
@ -2,7 +2,10 @@
|
||||
* apps/include/wireless/ieee802154.h
|
||||
*
|
||||
* Copyright(C) 2015 Sebastien Lorquet. All rights reserved.
|
||||
* Copyright(C) 2017 Verge Inc. All rights reserved.
|
||||
*
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -86,11 +89,11 @@ int ieee802154_calibrate_req(int fd,
|
||||
int ieee802154_setchan(int fd, uint8_t chan);
|
||||
int ieee802154_getchan(int fd, FAR uint8_t *chan);
|
||||
|
||||
int ieee802154_setpanid(int fd, uint16_t panid);
|
||||
int ieee802154_getpanid(int fd, FAR uint16_t *panid);
|
||||
int ieee802154_setpanid(int fd, FAR const uint8_t *panid);
|
||||
int ieee802154_getpanid(int fd, FAR uint8_t *panid);
|
||||
|
||||
int ieee802154_setsaddr(int fd, uint16_t saddr);
|
||||
int ieee802154_getsaddr(int fd, FAR uint16_t *saddr);
|
||||
int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr);
|
||||
int ieee802154_getsaddr(int fd, FAR uint8_t *saddr);
|
||||
|
||||
int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr);
|
||||
int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr);
|
||||
@ -154,13 +157,15 @@ int sixlowpan_calibrate_req(int sock, FAR const char *ifname,
|
||||
int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan);
|
||||
int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan);
|
||||
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid);
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname,
|
||||
FAR const uint8_t *panid);
|
||||
int sixlowpan_getpanid(int sock, FAR const char *ifname,
|
||||
FAR uint16_t *panid);
|
||||
FAR uint8_t *panid);
|
||||
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr);
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname,
|
||||
FAR const uint8_t *saddr);
|
||||
int sixlowpan_getsaddr(int sock, FAR const char *ifname,
|
||||
FAR uint16_t *saddr);
|
||||
FAR uint8_t *saddr);
|
||||
|
||||
int sixlowpan_seteaddr(int sock, FAR const char *ifname,
|
||||
FAR const uint8_t *eaddr);
|
||||
|
@ -70,7 +70,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid)
|
||||
int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid)
|
||||
{
|
||||
int ret = ERROR;
|
||||
|
||||
|
@ -99,6 +99,8 @@
|
||||
/* /dev/ is 5 characters */
|
||||
#define I8SAK_DAEMONNAME_FMTLEN (6 + (I8SAK_MAX_DEVNAME-5) + 1)
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -148,7 +150,7 @@ struct i8sak_s
|
||||
uint8_t chpage;
|
||||
struct ieee802154_addr_s addr;
|
||||
struct ieee802154_addr_s ep;
|
||||
uint16_t next_saddr;
|
||||
uint8_t next_saddr[IEEE802154_SADDRSIZE];
|
||||
uint8_t payload[IEEE802154_MAX_MAC_PAYLOAD_SIZE];
|
||||
uint16_t payload_len;
|
||||
int blasterperiod;
|
||||
@ -166,6 +168,8 @@ uint8_t i8sak_char2nibble(char ch);
|
||||
|
||||
int i8sak_str2payload(FAR const char *str, FAR uint8_t *buf);
|
||||
void i8sak_str2eaddr(FAR const char *str, FAR uint8_t *eaddr);
|
||||
void i8sak_str2saddr(FAR const char *str, FAR uint8_t *saddr);
|
||||
void i8sak_str2panid(FAR const char *str, FAR uint8_t *panid);
|
||||
bool i8sak_str2bool(FAR const char *str);
|
||||
|
||||
void i8sak_startpan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
|
@ -137,37 +137,25 @@ static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *
|
||||
|
||||
printf("i8sak: a device is trying to associate\n");
|
||||
|
||||
/* Send a ASSOC.resp primtive to the MAC. Copy the association
|
||||
* indication address into the association response primitive
|
||||
*/
|
||||
|
||||
IEEE802154_EADDRCOPY(assocresp.devaddr, notif->u.assocind.devaddr);
|
||||
|
||||
/* If the address matches our device, accept the association.
|
||||
* Otherwise, reject the assocation.
|
||||
*/
|
||||
|
||||
if (memcmp(¬if->u.assocind.devaddr[0], &i8sak->ep.eaddr[0],
|
||||
IEEE802154_EADDR_LEN) == 0)
|
||||
if (IEEE802154_EADDRCMP(notif->u.assocind.devaddr, i8sak->ep.eaddr))
|
||||
{
|
||||
/* Send a ASSOC.resp primtive to the MAC. Copy the association
|
||||
* indication address into the association response primitive
|
||||
*/
|
||||
|
||||
memcpy(&assocresp.devaddr[0], ¬if->u.assocind.devaddr[0],
|
||||
IEEE802154_EADDR_LEN);
|
||||
|
||||
assocresp.assocsaddr = i8sak->next_saddr;
|
||||
|
||||
IEEE802154_SADDRCOPY(assocresp.assocsaddr, i8sak->next_saddr);
|
||||
assocresp.status = IEEE802154_STATUS_SUCCESS;
|
||||
|
||||
printf("i8sak: accepting association request\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Send a ASSOC.resp primtive to the MAC. Copy the association
|
||||
* indication address into the association response primitive
|
||||
*/
|
||||
|
||||
memcpy(&assocresp.devaddr[0], ¬if->u.assocind.devaddr[0],
|
||||
IEEE802154_EADDR_LEN);
|
||||
|
||||
assocresp.status = IEEE802154_STATUS_DENIED;
|
||||
|
||||
printf("i8sak: rejecting association request\n");
|
||||
}
|
||||
|
||||
|
@ -115,14 +115,14 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
case 's':
|
||||
/* Parse extended address and put it into the i8sak instance */
|
||||
|
||||
i8sak->ep.saddr = i8sak_str2luint16(optarg);
|
||||
i8sak_str2saddr(optarg, i8sak->ep.saddr);
|
||||
i8sak->ep.mode= IEEE802154_ADDRMODE_SHORT;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
/* Parse extended address and put it into the i8sak instance */
|
||||
|
||||
i8sak_str2eaddr(optarg, &i8sak->ep.eaddr[0]);
|
||||
i8sak_str2eaddr(optarg, i8sak->ep.eaddr);
|
||||
i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED;
|
||||
break;
|
||||
|
||||
@ -148,7 +148,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
|
||||
if (optcnt && argc == 2)
|
||||
{
|
||||
i8sak->ep.panid = i8sak_str2luint16(argv[1]);
|
||||
i8sak_str2panid(argv[1], i8sak->ep.panid);
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
|
@ -353,7 +353,7 @@ uint8_t i8sak_char2nibble(char ch)
|
||||
* Name: i8sak_str2eaddr
|
||||
*
|
||||
* Description:
|
||||
* Convert a string 8-byte EADAR array.
|
||||
* Convert a string 8-byte EADDR array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -387,6 +387,82 @@ void i8sak_str2eaddr(FAR const char *str, FAR uint8_t *eaddr)
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: i8sak_str2saddr
|
||||
*
|
||||
* Description:
|
||||
* Convert a string 2-byte SADDR array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void i8sak_str2saddr(FAR const char *str, FAR uint8_t *saddr)
|
||||
{
|
||||
FAR const char *src = str;
|
||||
uint8_t bvalue;
|
||||
char ch;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
bvalue = i8sak_char2nibble(ch) << 4;
|
||||
|
||||
ch = (char)*src++;
|
||||
bvalue |= i8sak_char2nibble(ch);
|
||||
|
||||
*saddr++ = bvalue;
|
||||
|
||||
if (i < 1)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
if (ch != ':')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing colon separator: %s\n", str);
|
||||
fprintf(stderr, " Expected xx:xx\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: i8sak_str2panid
|
||||
*
|
||||
* Description:
|
||||
* Convert a string 2-byte PAN ID array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void i8sak_str2panid(FAR const char *str, FAR uint8_t *panid)
|
||||
{
|
||||
FAR const char *src = str;
|
||||
uint8_t bvalue;
|
||||
char ch;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
bvalue = i8sak_char2nibble(ch) << 4;
|
||||
|
||||
ch = (char)*src++;
|
||||
bvalue |= i8sak_char2nibble(ch);
|
||||
|
||||
*panid++ = bvalue;
|
||||
|
||||
if (i < 1)
|
||||
{
|
||||
ch = (char)*src++;
|
||||
if (ch != ':')
|
||||
{
|
||||
fprintf(stderr, "ERROR: Missing colon separator: %s\n", str);
|
||||
fprintf(stderr, " Expected xx:xx\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: i8sak_str2bool
|
||||
*
|
||||
@ -496,23 +572,38 @@ static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname)
|
||||
|
||||
/* Initialze default extended address */
|
||||
|
||||
for (i = 0; i < IEEE802154_EADDR_LEN; i++)
|
||||
for (i = 0; i < IEEE802154_EADDRSIZE; i++)
|
||||
{
|
||||
i8sak->addr.eaddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_EADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
/* Initialize the default remote endpoint address */
|
||||
|
||||
for (i = 0; i < IEEE802154_EADDR_LEN; i++)
|
||||
i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
|
||||
for (i = 0; i < IEEE802154_EADDRSIZE; i++)
|
||||
{
|
||||
i8sak->ep.eaddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_EADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
i8sak->ep.saddr = CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR;
|
||||
i8sak->ep.panid = CONFIG_IEEE802154_I8SAK_PANID;
|
||||
for (i = 0; i < IEEE802154_SADDRSIZE; i++)
|
||||
{
|
||||
i8sak->ep.saddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
i8sak->next_saddr = CONFIG_IEEE802154_I8SAK_DEV_SADDR;
|
||||
for (i = 0; i < IEEE802154_PANIDSIZE; i++)
|
||||
{
|
||||
i8sak->ep.panid[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANID >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
/* Set the next association device to the default device address, so that
|
||||
* the first device to request association gets that address.
|
||||
*/
|
||||
|
||||
for (i = 0; i < IEEE802154_SADDRSIZE; i++)
|
||||
{
|
||||
i8sak->next_saddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_SADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
@ -521,7 +612,7 @@ static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname)
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
ieee802154_seteaddr(fd, &i8sak->addr.eaddr[0]);
|
||||
ieee802154_seteaddr(fd, i8sak->addr.eaddr);
|
||||
|
||||
close(fd);
|
||||
|
||||
|
@ -63,7 +63,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
static void poll_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg);
|
||||
static void poll_receiver(FAR struct mac802154dev_rxframe_s *frame, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -133,13 +132,13 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
wpanlistener_add_eventreceiver(&i8sak->wpanlistener, poll_eventcb,
|
||||
&eventfilter, (FAR void *)i8sak, true);
|
||||
|
||||
printf("i8sak: Polling coordinator. PAN ID: 0x%04X SADDR: 0x%04X\n",
|
||||
i8sak->ep.panid,
|
||||
i8sak->ep.saddr);
|
||||
printf("i8sak: Polling coordinator. PAN ID: %02X:%02X SADDR: %02X:%02X\n",
|
||||
i8sak->ep.panid[0], i8sak->ep.panid[1],
|
||||
i8sak->ep.saddr[0], i8sak->ep.saddr[1]);
|
||||
|
||||
pollreq.coordaddr.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
pollreq.coordaddr.saddr = i8sak->ep.saddr;
|
||||
pollreq.coordaddr.panid = i8sak->ep.panid;
|
||||
IEEE802154_SADDRCOPY(pollreq.coordaddr.saddr, i8sak->ep.saddr);
|
||||
IEEE802154_PANIDCOPY(pollreq.coordaddr.panid, i8sak->ep.panid);
|
||||
|
||||
ieee802154_poll_req(fd, &pollreq);
|
||||
|
||||
|
@ -129,37 +129,61 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
|
||||
if (!i8sak->addrset)
|
||||
{
|
||||
for (i = 0; i < IEEE802154_EADDR_LEN; i++)
|
||||
/* Set our address to the default PAN Coordinator configuration */
|
||||
|
||||
i8sak->addr.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
|
||||
for (i = 0; i < IEEE802154_EADDRSIZE; i++)
|
||||
{
|
||||
i8sak->addr.eaddr[i] =
|
||||
(uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_EADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
i8sak->addr.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
i8sak->addr.saddr = CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR;
|
||||
i8sak->addr.panid = CONFIG_IEEE802154_I8SAK_PANID;
|
||||
for (i = 0; i < IEEE802154_SADDRSIZE; i++)
|
||||
{
|
||||
i8sak->addr.saddr[i] =
|
||||
(uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
for (i = 0; i < IEEE802154_EADDR_LEN; i++)
|
||||
for (i = 0; i < IEEE802154_PANIDSIZE; i++)
|
||||
{
|
||||
i8sak->addr.panid[i] =
|
||||
(uint8_t)((CONFIG_IEEE802154_I8SAK_PANID >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
/* Set the endpoint address to the default endpoint device */
|
||||
|
||||
i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
|
||||
for (i = 0; i < IEEE802154_EADDRSIZE; i++)
|
||||
{
|
||||
i8sak->ep.eaddr[i] =
|
||||
(uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_EADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT;
|
||||
i8sak->ep.saddr = CONFIG_IEEE802154_I8SAK_DEV_SADDR;
|
||||
i8sak->ep.panid = CONFIG_IEEE802154_I8SAK_PANID;
|
||||
for (i = 0; i < IEEE802154_SADDRSIZE; i++)
|
||||
{
|
||||
i8sak->ep.saddr[i] =
|
||||
(uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_SADDR >> (i*8)) & 0xFF);
|
||||
}
|
||||
|
||||
for (i = 0; i < IEEE802154_PANIDSIZE; i++)
|
||||
{
|
||||
i8sak->ep.panid[i] =
|
||||
(uint8_t)((CONFIG_IEEE802154_I8SAK_PANID >> (i*8)) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set EADDR and SADDR */
|
||||
|
||||
ieee802154_seteaddr(fd, &i8sak->addr.eaddr[0]);
|
||||
ieee802154_seteaddr(fd, i8sak->addr.eaddr);
|
||||
ieee802154_setsaddr(fd, i8sak->addr.saddr);
|
||||
|
||||
/* Tell the MAC to start acting as a coordinator */
|
||||
|
||||
printf("i8sak: starting PAN\n");
|
||||
|
||||
startreq.panid = i8sak->addr.panid;
|
||||
IEEE802154_PANIDCOPY(startreq.panid, i8sak->addr.panid);
|
||||
startreq.chnum = i8sak->chnum;
|
||||
startreq.chpage = i8sak->chpage;
|
||||
startreq.beaconorder = 15;
|
||||
|
@ -61,7 +61,7 @@ int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
memcpy(eaddr, &req.attrval.mac.eaddr[0], 8);
|
||||
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getpanid(int fd, FAR uint16_t *panid)
|
||||
int ieee802154_getpanid(int fd, FAR uint8_t *panid)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
@ -60,7 +60,7 @@ int ieee802154_getpanid(int fd, FAR uint16_t *panid)
|
||||
req.attr = IEEE802154_ATTR_MAC_PANID;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*panid = req.attrval.mac.panid;
|
||||
IEEE802154_PANIDCOPY(panid, req.attrval.mac.panid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_getsaddr(int fd, FAR uint16_t *saddr)
|
||||
int ieee802154_getsaddr(int fd, FAR uint8_t *saddr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
@ -60,7 +60,7 @@ int ieee802154_getsaddr(int fd, FAR uint16_t *saddr)
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*saddr = req.attrval.mac.saddr;
|
||||
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
memcpy(&req.attrval.mac.eaddr[0], eaddr, 8);
|
||||
IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr);
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
||||
|
@ -53,12 +53,12 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setpanid(int fd, uint16_t panid)
|
||||
int ieee802154_setpanid(int fd, FAR const uint8_t *panid)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_PANID;
|
||||
req.attrval.mac.panid = panid;
|
||||
IEEE802154_PANIDCOPY(req.attrval.mac.panid, panid);
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
||||
|
@ -53,12 +53,12 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setsaddr(int fd, uint16_t saddr)
|
||||
int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
req.attrval.mac.saddr = saddr;
|
||||
IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr);
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
memcpy(eaddr, &req.attrval.mac.eaddr[0], 8);
|
||||
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid)
|
||||
int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint8_t *panid)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
@ -61,7 +61,7 @@ int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid)
|
||||
req.attr = IEEE802154_ATTR_MAC_PANID;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*panid = req.attrval.mac.panid;
|
||||
IEEE802154_PANIDCOPY(panid, req.attrval.mac.panid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr)
|
||||
int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint8_t *saddr)
|
||||
{
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
@ -61,7 +61,7 @@ int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr)
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*saddr = req.attrval.mac.saddr;
|
||||
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eadd
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
memcpy(&req.attrval.mac.eaddr[0], eaddr, 8);
|
||||
IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr);
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
||||
|
@ -53,12 +53,12 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid)
|
||||
int sixlowpan_setpanid(int sock, FAR const char *ifname, FAR const uint8_t *panid)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_PANID;
|
||||
req.attrval.mac.panid = panid;
|
||||
IEEE802154_PANIDCOPY(req.attrval.mac.panid, panid);
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
||||
|
@ -53,12 +53,12 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr)
|
||||
int sixlowpan_setsaddr(int sock, FAR const char *ifname, FAR const uint8_t *saddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
req.attrval.mac.saddr = saddr;
|
||||
IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr);
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
||||
|
@ -48,9 +48,11 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
int ieee802154_addrtostr(FAR char *buf, int len,
|
||||
FAR struct ieee802154_addr_s *addr)
|
||||
{
|
||||
#if 0
|
||||
#ifndef CONFIG_BIG_ENDIAN
|
||||
uint16_t panid = ((addr->panid & 0xff) << 8) | ((addr->panid >> 8) & 0xff);
|
||||
#else
|
||||
@ -87,5 +89,7 @@ int ieee802154_addrtostr(FAR char *buf, int len,
|
||||
return snprintf(buf,len,"<INVAL>");
|
||||
}
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ static bool iwpan_str2bool(FAR const char *str)
|
||||
|
||||
static void iwpan_show_cmd(int sock, FAR const char *ifname)
|
||||
{
|
||||
uint8_t eaddr[IEEE802154_EADDR_LEN] =
|
||||
uint8_t eaddr[IEEE802154_EADDRSIZE] =
|
||||
{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
@ -506,7 +506,7 @@ static void iwpan_devmode_cmd(int sock, FAR const char *ifname,
|
||||
static void iwpan_eaddr_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *addrstr)
|
||||
{
|
||||
uint8_t eaddr[IEEE802154_EADDR_LEN];
|
||||
uint8_t eaddr[IEEE802154_EADDRSIZE];
|
||||
int ret;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
Loading…
Reference in New Issue
Block a user