xbee: use last 2 octets of EUI64 for short address
Dependency two CPUID and hard coded default short address are superfluous now.
This commit is contained in:
parent
c45eaf62de
commit
92f4dec8da
@ -30,6 +30,7 @@
|
||||
#include "periph/uart.h"
|
||||
#include "periph/gpio.h"
|
||||
#include "net/ng_netbase.h"
|
||||
#include "net/ng_ieee802154.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -59,11 +60,6 @@
|
||||
#define XBEE_DEFAULT_PROTOCOL (NG_NETTYPE_UNDEF)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default short address used after initialization
|
||||
*/
|
||||
#define XBEE_DEFAULT_SHORT_ADDR (0x0230)
|
||||
|
||||
/**
|
||||
* @brief Default PAN ID used after initialization
|
||||
*/
|
||||
@ -109,7 +105,7 @@ typedef struct {
|
||||
ng_nettype_t proto; /**< protocol the interface speaks */
|
||||
uint8_t options; /**< options field */
|
||||
uint8_t addr_short[2]; /**< onw 802.15.4 short address */
|
||||
uint8_t addr_long[8]; /**< own 802.15.4 long address */
|
||||
eui64_t addr_long; /**< own 802.15.4 long address */
|
||||
/* general variables for the UART RX state machine */
|
||||
xbee_rx_state_t int_state; /**< current state if the UART RX FSM */
|
||||
uint16_t int_size; /**< temporary space for parsing the
|
||||
|
||||
@ -452,24 +452,10 @@ int xbee_init(xbee_t *dev, uart_t uart, uint32_t baudrate,
|
||||
/* exit command mode */
|
||||
_at_cmd(dev, "ATCN\r");
|
||||
|
||||
/* set default short address, use CPU ID if available */
|
||||
#if CPUID_ID_LEN
|
||||
/* get CPU ID */
|
||||
uint8_t id[CPUID_ID_LEN];
|
||||
cpuid_get(id);
|
||||
/* set address */
|
||||
memset(dev->addr_short, 0, 2);
|
||||
for (int i = 0; i < CPUID_ID_LEN; i++) {
|
||||
dev->addr_short[i & 0x01] ^= id[i];
|
||||
}
|
||||
#else
|
||||
dev->addr_short[0] = (uint8_t)(XBEE_DEFAULT_SHORT_ADDR >> 8);
|
||||
dev->addr_short[1] = (uint8_t)(XBEE_DEFAULT_SHORT_ADDR);
|
||||
#endif
|
||||
_set_addr(dev, dev->addr_short, 2);
|
||||
/* load long address (we can not set it, its read only for Xbee devices) */
|
||||
_get_addr_long(dev, dev->addr_long, 8);
|
||||
_get_addr_long(dev, dev->addr_long.uint8, 8);
|
||||
/* set default channel */
|
||||
_set_addr(dev, &((dev->addr_long).uint8[6]), 2);
|
||||
tmp[1] = 0;
|
||||
tmp[0] = XBEE_DEFAULT_CHANNEL;
|
||||
_set_channel(dev, tmp, 2);
|
||||
@ -709,7 +695,7 @@ static void _isr_event(ng_netdev_t *netdev, uint32_t event_type)
|
||||
ng_netif_hdr_set_dst_addr(hdr, dev->addr_short, 2);
|
||||
}
|
||||
else {
|
||||
ng_netif_hdr_set_dst_addr(hdr, dev->addr_long, 8);
|
||||
ng_netif_hdr_set_dst_addr(hdr, dev->addr_long.uint8, 8);
|
||||
}
|
||||
pos = 3 + addr_len;
|
||||
/* allocate and copy payload */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user