Support for changing PANID and channel from project-conf.h

modified:   cpu/avr/radio/rf230bb/rf230bb.c
	modified:   platform/avr-rss2/contiki-conf.h
	modified:   platform/avr-rss2/contiki-main.c
This commit is contained in:
Robert Olsson 2017-01-21 16:37:37 +01:00
parent 99402348eb
commit 9e5aed5df6
3 changed files with 27 additions and 7 deletions

View File

@ -1291,6 +1291,21 @@ rf230_listen_channel(uint8_t c)
radio_set_trx_state(RX_ON);
}
/*---------------------------------------------------------------------------*/
unsigned
rf230_get_panid(void)
{
unsigned pan;
uint8_t byte;
byte = hal_register_read(RG_PAN_ID_1);
pan = byte;
byte = hal_register_read(RG_PAN_ID_0);
pan = (pan << 8) + byte;
return pan;
}
void
rf230_set_pan_addr(unsigned pan,
unsigned addr,

View File

@ -78,10 +78,6 @@
#define NETSTACK_CONF_RADIO rf230_driver
#endif
#ifndef CHANNEL_802_15_4
#define CHANNEL_802_15_4 26
#endif
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
#ifndef RF230_CONF_AUTOACK
#define RF230_CONF_AUTOACK 1

View File

@ -314,8 +314,18 @@ initialize(void)
memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t));
#endif
#ifdef IEEE802154_CONF_PANID
rf230_set_pan_addr(IEEE802154_CONF_PANID, params_get_panaddr(), (uint8_t *)&addr.u8);
#else
rf230_set_pan_addr(params_get_panid(), params_get_panaddr(), (uint8_t *)&addr.u8);
#endif
#ifdef CHANNEL_CONF_802_15_4
rf230_set_channel(CHANNEL_CONF_802_15_4);
#else
rf230_set_channel(params_get_channel());
#endif
rf230_set_txpower(params_get_txpower());
#if NETSTACK_CONF_WITH_IPV6
@ -339,8 +349,8 @@ initialize(void)
NETSTACK_NETWORK.init();
#if ANNOUNCE_BOOT
PRINTA("MAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", NETSTACK_MAC.name,
NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(),
PRINTA("PAN=0x%X, XMAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", rf230_get_panid(),
NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(),
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 : NETSTACK_RDC.channel_check_interval()),
rf230_get_txpower());
#if UIP_CONF_IPV6_RPL
@ -349,7 +359,6 @@ initialize(void)
#if UIP_CONF_ROUTER
PRINTA("Routing Enabled\n");
#endif
#endif /* ANNOUNCE_BOOT */
#if NETSTACK_CONF_WITH_IPV6 || NETSTACK_CONF_WITH_IPV4