RSSI read fix (use ED register in AACK mode), add reduced power configuration for miniature mesh testing.

This commit is contained in:
dak664 2010-11-24 18:46:57 +00:00
parent d14e8996ab
commit 880233a451
6 changed files with 83 additions and 27 deletions

View file

@ -715,9 +715,22 @@ ISR(RADIO_VECT)
/* Buffer the frame and call rf230_interrupt to schedule poll for rf230 receive process */ /* Buffer the frame and call rf230_interrupt to schedule poll for rf230 receive process */
// if (rxframe.length) break; //toss packet if last one not processed yet // if (rxframe.length) break; //toss packet if last one not processed yet
if (rxframe.length) INTERRUPTDEBUG(42); else INTERRUPTDEBUG(12); if (rxframe.length) INTERRUPTDEBUG(42); else INTERRUPTDEBUG(12);
#ifdef RF230_MIN_RX_POWER
/* Discard packets weaker than the minimum if defined */
#if RF230_CONF_AUTOACK
if (hal_subregister_read(SR_ED_LEVEL) >= RF230_MIN_RX_POWER) {
#else
if (hal_subregister_read(SR_RSSI) >= RF230_MIN_RX_POWER) {
#endif
#endif
hal_frame_read(&rxframe, NULL); hal_frame_read(&rxframe, NULL);
rf230_interrupt(); rf230_interrupt();
// trx_end_callback(isr_timestamp); // trx_end_callback(isr_timestamp);
#ifdef RF230_MIN_RX_POWER
}
#endif
#if 0 #if 0
/* Enable reception of next packet */ /* Enable reception of next packet */
#if RF230_CONF_AUTOACK #if RF230_CONF_AUTOACK

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* @(#)$Id: rf230bb.c,v 1.12 2010/09/17 21:59:09 dak664 Exp $ * @(#)$Id: rf230bb.c,v 1.13 2010/11/24 18:46:59 dak664 Exp $
*/ */
/* /*
* This code is almost device independent and should be easy to port. * This code is almost device independent and should be easy to port.
@ -43,7 +43,7 @@
#if defined(__AVR__) #if defined(__AVR__)
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h> #include <util/delay.h>
//#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#elif defined(__MSP430__) #elif defined(__MSP430__)
#include <io.h> #include <io.h>
#endif #endif
@ -578,8 +578,15 @@ rf230_init(void)
/* Start the packet receive process */ /* Start the packet receive process */
process_start(&rf230_process, NULL); process_start(&rf230_process, NULL);
/* Limit tx power for testing miniature Raven mesh */
#ifdef RF230_MAX_TX_POWER
set_txpower(RF230_MAX_TX_POWER); //0=3dbm 15=-17.2dbm
#endif
/* Leave radio in on state (?)*/ /* Leave radio in on state (?)*/
on(); on();
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -977,6 +984,8 @@ PROCESS_THREAD(rf230_process, ev, data)
packetbuf_clear(); packetbuf_clear();
len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE); len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
// printf_P(PSTR("RSSI reads %x "),hal_subregister_read(SR_RSSI));
// printf_P(PSTR("ED reads %d "),hal_subregister_read(SR_ED_LEVEL));
rf230processflag=1; rf230processflag=1;
if(len > 0) { if(len > 0) {
packetbuf_set_datalen(len); packetbuf_set_datalen(len);
@ -1092,16 +1101,15 @@ if (RF230_receive_on) {
PRINTF("checksum failed 0x%04x != 0x%04x\n", PRINTF("checksum failed 0x%04x != 0x%04x\n",
checksum, crc16_data(buf, len - AUX_LEN, 0)); checksum, crc16_data(buf, len - AUX_LEN, 0));
} }
if(footer[1] & FOOTER1_CRC_OK && if(footer[1] & FOOTER1_CRC_OK &&
checksum == crc16_data(buf, len - AUX_LEN, 0)) { checksum == crc16_data(buf, len - AUX_LEN, 0)) {
#else
if (1) {
// if(footer[1] & FOOTER1_CRC_OK) {
#endif /* RF230_CONF_CHECKSUM */ #endif /* RF230_CONF_CHECKSUM */
// rf230_last_rssi = footer[0];
rf230_last_rssi = hal_subregister_read(SR_RSSI); #if RF230_CONF_AUTOACK
// rf230_last_correlation = footer[1] & FOOTER1_CORRELATION; rf230_last_rssi = hal_subregister_read(SR_ED_LEVEL); //0-84 resolution 1 dB
#else
rf230_last_rssi = 3*hal_subregister_read(SR_RSSI); //0-28 resolution 3 dB
#endif
rf230_last_correlation = rxframe.lqi; rf230_last_correlation = rxframe.lqi;
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rf230_last_rssi); packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rf230_last_rssi);
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, rf230_last_correlation); packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, rf230_last_correlation);
@ -1119,12 +1127,14 @@ if (RF230_receive_on) {
packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, t.time); packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, t.time);
#endif /* RF230_CONF_TIMESTAMPS */ #endif /* RF230_CONF_TIMESTAMPS */
#if RF230_CONF_CHECKSUM
} else { } else {
DEBUGFLOW('X'); DEBUGFLOW('X');
PRINTF("bad crc"); PRINTF("bad crc");
RIMESTATS_ADD(badcrc); RIMESTATS_ADD(badcrc);
len = AUX_LEN; len = AUX_LEN;
} }
#endif
/* Clean up in case of FIFO overflow! This happens for every full /* Clean up in case of FIFO overflow! This happens for every full
* length frame and is signaled by FIFOP = 1 and FIFO = 0. * length frame and is signaled by FIFOP = 1 and FIFO = 0.
@ -1186,8 +1196,12 @@ rf230_get_raw_rssi(void)
radio_was_off = 1; radio_was_off = 1;
rf230_on(); rf230_on();
} }
/* The energy detect register is used in extended mode (since RSSI will read 0) */
rssi = (int)((signed char)hal_subregister_read(SR_RSSI)); #if RF230_CONF_AUTOACK
rssi = hal_subregister_read(SR_ED_LEVEL); //0-84, resolution 1 dB
#else
rssi = 3*hal_subregister_read(SR_RSSI); //0-28, resolution 3 dB
#endif
if(radio_was_off) { if(radio_was_off) {
rf230_off(); rf230_off();

View file

@ -168,6 +168,16 @@
#define UIP_CONF_TCP_SPLIT 1 #define UIP_CONF_TCP_SPLIT 1
#if 0 /* RPL */ #if 0 /* RPL */
/* Define these to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
* Leave undefined for full power and sensitivity.
* tx=0 (3dbm, default) to 15 (-17.2dbm)
* RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
* else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
* For simplicity RF230_MIN_RX_POWER is based on the rssi value and multiplied by 3 when autoack is set.
* On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
*/
#define RF230_MAX_TX_POWER 15
#define RF230_MIN_RX_POWER 30
#define UIP_CONF_ROUTER 1 #define UIP_CONF_ROUTER 1
#define UIP_CONF_IPV6_RPL 1 #define UIP_CONF_IPV6_RPL 1

View file

@ -215,6 +215,7 @@ void menu_print(void)
#endif #endif
#if UIP_CONF_IPV6_RPL #if UIP_CONF_IPV6_RPL
PRINTF_P(PSTR("* N RPL Neighbors *\n\r")); PRINTF_P(PSTR("* N RPL Neighbors *\n\r"));
PRINTF_P(PSTR("* G RPL Global Repair *\n\r"));
#endif #endif
PRINTF_P(PSTR("* e Energy Scan *\n\r")); PRINTF_P(PSTR("* e Energy Scan *\n\r"));
#if USB_CONF_STORAGE #if USB_CONF_STORAGE
@ -438,6 +439,7 @@ void menu_process(char c)
break; break;
#if UIP_CONF_IPV6_RPL #if UIP_CONF_IPV6_RPL
#include "rpl.h"
extern uip_ds6_nbr_t uip_ds6_nbr_cache[]; extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[]; extern uip_ds6_route_t uip_ds6_routing_table[];
case 'N': case 'N':
@ -469,6 +471,10 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
PRINTF_P(PSTR("\n\r---------\n\r")); PRINTF_P(PSTR("\n\r---------\n\r"));
break; break;
} }
case 'G':
PRINTF_P(PSTR("Global repair returns %d\n\r"),rpl_repair_dag(rpl_get_dag(RPL_ANY_INSTANCE)));
break;
#endif #endif
case 'm': case 'm':
@ -510,9 +516,9 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
); );
#if RF230BB #if RF230BB
PRINTF_P(PSTR(" * Operates on channel %d\n\r"), rf230_get_channel()); PRINTF_P(PSTR(" * Operates on channel %d\n\r"), rf230_get_channel());
PRINTF_P(PSTR(" * TX Power Level: 0x%02X\n\r"), rf230_get_txpower()); PRINTF_P(PSTR(" * TX Power(0=3dBm, 15=-17.2dBm): %d\n\r"), rf230_get_txpower());
PRINTF_P(PSTR(" * Current RSSI: %ddB\n\r"), -91+3*(rf230_rssi()-1)); PRINTF_P(PSTR(" * Current RSSI: %ddB\n\r"), -91+(rf230_rssi()-1));
PRINTF_P(PSTR(" * Last RSSI: %ddB\n\r"), -91+3*(rf230_last_rssi-1)); PRINTF_P(PSTR(" * Last RSSI: %ddB\n\r"), -91+(rf230_last_rssi-1));
#else // RF230BB #else // RF230BB
PRINTF_P(PSTR(" * Operates on channel %d\n\r"), radio_get_operating_channel()); PRINTF_P(PSTR(" * Operates on channel %d\n\r"), radio_get_operating_channel());
PRINTF_P(PSTR(" * TX Power Level: 0x%02X\n\r"), radio_get_tx_power_level()); PRINTF_P(PSTR(" * TX Power Level: 0x%02X\n\r"), radio_get_tx_power_level());
@ -631,7 +637,7 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
//No more serial port //No more serial port
stdout = NULL; stdout = NULL;
#if USB_CONF_RS232 #if USB_CONF_RS232
usb_stdout = NULL; // usb_stdout = NULL;
#endif #endif
//RNDIS is over //RNDIS is over
@ -643,6 +649,7 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
//Wait a few seconds //Wait a few seconds
for(i = 0; i < 50; i++) for(i = 0; i < 50; i++)
watchdog_periodic();
_delay_ms(100); _delay_ms(100);
//Attach USB //Attach USB

View file

@ -62,9 +62,9 @@
/* Mac address, RF channel, PANID from EEPROM settings manager */ /* Mac address, RF channel, PANID from EEPROM settings manager */
/* Generate random MAC address on first startup */ /* Generate random MAC address on first startup */
/* Random number from radio clock skew or ADC noise */ /* Random number from radio clock skew or ADC noise */
#define JACKDAW_CONF_USE_SETTINGS 1 #define JACKDAW_CONF_USE_SETTINGS 0
#define JACKDAW_CONF_RANDOM_MAC 0 #define JACKDAW_CONF_RANDOM_MAC 0
#define RNG_CONF_USE_RADIO_CLOCK 1 #define RNG_CONF_USE_RADIO_CLOCK 1
//#define RNG_CONF_USE_ADC 1 //#define RNG_CONF_USE_ADC 1
/* Since clock_time_t is 16 bits, maximum interval is 524 seconds */ /* Since clock_time_t is 16 bits, maximum interval is 524 seconds */
@ -73,15 +73,13 @@
/* Maximum time interval (used for timers) */ /* Maximum time interval (used for timers) */
#define INFINITE_TIME 0xffff #define INFINITE_TIME 0xffff
/* COM port to be used for SLIP connection */ /* COM port to be used for SLIP connection (not implemented on jackdaw) */
#define SLIP_PORT RS232_PORT_0 #define SLIP_PORT RS232_PORT_0
/* Pre-allocated memory for loadable modules heap space (in bytes)*/ /* Pre-allocated memory for loadable modules heap space (in bytes)*/
#define MMEM_CONF_SIZE 256 #define MMEM_CONF_SIZE 256
/* Use the following address for code received via the codeprop /* Use the following address for code received via the codeprop facility */
* facility
*/
#define EEPROMFS_ADDR_CODEPROP 0x8000 #define EEPROMFS_ADDR_CODEPROP 0x8000
/* Use Atmel 'Route Under MAC', currently just in sniffer mode! */ /* Use Atmel 'Route Under MAC', currently just in sniffer mode! */
@ -212,7 +210,7 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
* The tx pad is the middle one behind the jackdaw leds. * The tx pad is the middle one behind the jackdaw leds.
* RS232 output will work with or without enabling the USB serial port * RS232 output will work with or without enabling the USB serial port
*/ */
#define USB_CONF_RS232 0 #define USB_CONF_RS232 1
/* Disable mass storage enumeration for more program space */ /* Disable mass storage enumeration for more program space */
//#define USB_CONF_STORAGE 1 /* TODO: Mass storage is currently broken */ //#define USB_CONF_STORAGE 1 /* TODO: Mass storage is currently broken */
@ -232,6 +230,7 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
#ifdef RF230BB #ifdef RF230BB
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function #define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
/* Nothing after this will work with the original RF230 combined radio/mac driver! */
/* ************************************************************************** */ /* ************************************************************************** */
//#pragma mark NETSTACK Settings //#pragma mark NETSTACK Settings
/* ************************************************************************** */ /* ************************************************************************** */
@ -297,6 +296,16 @@ or include the needed source files in /plaftorm/avr-ravenusb/Makefile.avr-ravenu
buffer_length = uip_len - uip_l2_l3_icmp_hdr_len + UIP_LLH_LEN; //Add jackdaw ethernet header buffer_length = uip_len - uip_l2_l3_icmp_hdr_len + UIP_LLH_LEN; //Add jackdaw ethernet header
*/ */
/* Define these to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
* Leave undefined for full power and sensitivity.
* tx=0 (3dbm, default) to 15 (-17.2dbm)
* RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
* else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
* For simplicity RF230_MIN_RX_POWER is based on the rssi value and multiplied by 3 when autoack is set.
* On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
*/
#define RF230_MAX_TX_POWER 15
#define RF230_MIN_RX_POWER 30
#define UIP_CONF_ROUTER 1 #define UIP_CONF_ROUTER 1
#define RPL_CONF_STATS 0 #define RPL_CONF_STATS 0
@ -315,8 +324,8 @@ or include the needed source files in /plaftorm/avr-ravenusb/Makefile.avr-ravenu
#undef UIP_CONF_STATISTICS #undef UIP_CONF_STATISTICS
#define UIP_CONF_STATISTICS 0 #define UIP_CONF_STATISTICS 0
#define UIP_CONF_DS6_NBR_NBU 2 #define UIP_CONF_DS6_NBR_NBU 5
#define UIP_CONF_DS6_ROUTE_NBU 2 #define UIP_CONF_DS6_ROUTE_NBU 5
#define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_SEND_RA 0
#define UIP_CONF_ND6_REACHABLE_TIME 600000 #define UIP_CONF_ND6_REACHABLE_TIME 600000

View file

@ -380,7 +380,10 @@ static void initialize(void) {
); );
#if JACKDAW_CONF_USE_SETTINGS #if JACKDAW_CONF_USE_SETTINGS
rf230_set_txpower(settings_get_uint8(SETTINGS_KEY_TXPOWER,0)); /* Allow radio code to overrite power for testing miniature Raven mesh */
#ifndef RF230_MAX_TX_POWER
rf230_set_txpower(settings_get_uint8(SETTINGS_KEY_TXPOWER,0));
#endif
#endif #endif
rimeaddr_set_node_addr(&tmp_addr); rimeaddr_set_node_addr(&tmp_addr);