From 9e5aed5df6554be3afda2e8fae9cb10bfe33d6b1 Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Sat, 21 Jan 2017 16:37:37 +0100 Subject: [PATCH] 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 --- cpu/avr/radio/rf230bb/rf230bb.c | 15 +++++++++++++++ platform/avr-rss2/contiki-conf.h | 4 ---- platform/avr-rss2/contiki-main.c | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index cbe8160ef..565c118d5 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -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, diff --git a/platform/avr-rss2/contiki-conf.h b/platform/avr-rss2/contiki-conf.h index 3e1f5dfc2..e69a0a637 100644 --- a/platform/avr-rss2/contiki-conf.h +++ b/platform/avr-rss2/contiki-conf.h @@ -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 diff --git a/platform/avr-rss2/contiki-main.c b/platform/avr-rss2/contiki-main.c index f220a168a..a872d0cd5 100644 --- a/platform/avr-rss2/contiki-main.c +++ b/platform/avr-rss2/contiki-main.c @@ -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