RSSI read fix (use ED register in AACK mode), add reduced power configuration for miniature mesh testing.
This commit is contained in:
parent
d14e8996ab
commit
880233a451
@ -715,9 +715,22 @@ ISR(RADIO_VECT)
|
||||
/* 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) 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);
|
||||
rf230_interrupt();
|
||||
// trx_end_callback(isr_timestamp);
|
||||
#ifdef RF230_MIN_RX_POWER
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Enable reception of next packet */
|
||||
#if RF230_CONF_AUTOACK
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* 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.
|
||||
@ -43,7 +43,7 @@
|
||||
#if defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
//#include <avr/pgmspace.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(__MSP430__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
@ -577,9 +577,16 @@ rf230_init(void)
|
||||
|
||||
/* Start the packet receive process */
|
||||
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 (?)*/
|
||||
on();
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -977,6 +984,8 @@ PROCESS_THREAD(rf230_process, ev, data)
|
||||
|
||||
packetbuf_clear();
|
||||
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;
|
||||
if(len > 0) {
|
||||
packetbuf_set_datalen(len);
|
||||
@ -1092,16 +1101,15 @@ if (RF230_receive_on) {
|
||||
PRINTF("checksum failed 0x%04x != 0x%04x\n",
|
||||
checksum, crc16_data(buf, len - AUX_LEN, 0));
|
||||
}
|
||||
|
||||
if(footer[1] & FOOTER1_CRC_OK &&
|
||||
checksum == crc16_data(buf, len - AUX_LEN, 0)) {
|
||||
#else
|
||||
if (1) {
|
||||
// if(footer[1] & FOOTER1_CRC_OK) {
|
||||
#endif /* RF230_CONF_CHECKSUM */
|
||||
// rf230_last_rssi = footer[0];
|
||||
rf230_last_rssi = hal_subregister_read(SR_RSSI);
|
||||
// rf230_last_correlation = footer[1] & FOOTER1_CORRELATION;
|
||||
|
||||
#if RF230_CONF_AUTOACK
|
||||
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;
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rf230_last_rssi);
|
||||
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);
|
||||
#endif /* RF230_CONF_TIMESTAMPS */
|
||||
|
||||
#if RF230_CONF_CHECKSUM
|
||||
} else {
|
||||
DEBUGFLOW('X');
|
||||
PRINTF("bad crc");
|
||||
RIMESTATS_ADD(badcrc);
|
||||
len = AUX_LEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clean up in case of FIFO overflow! This happens for every full
|
||||
* length frame and is signaled by FIFOP = 1 and FIFO = 0.
|
||||
@ -1186,8 +1196,12 @@ rf230_get_raw_rssi(void)
|
||||
radio_was_off = 1;
|
||||
rf230_on();
|
||||
}
|
||||
|
||||
rssi = (int)((signed char)hal_subregister_read(SR_RSSI));
|
||||
/* The energy detect register is used in extended mode (since RSSI will read 0) */
|
||||
#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) {
|
||||
rf230_off();
|
||||
|
@ -168,6 +168,16 @@
|
||||
#define UIP_CONF_TCP_SPLIT 1
|
||||
|
||||
#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_IPV6_RPL 1
|
||||
|
@ -215,6 +215,7 @@ void menu_print(void)
|
||||
#endif
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
PRINTF_P(PSTR("* N RPL Neighbors *\n\r"));
|
||||
PRINTF_P(PSTR("* G RPL Global Repair *\n\r"));
|
||||
#endif
|
||||
PRINTF_P(PSTR("* e Energy Scan *\n\r"));
|
||||
#if USB_CONF_STORAGE
|
||||
@ -438,6 +439,7 @@ void menu_process(char c)
|
||||
break;
|
||||
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
#include "rpl.h"
|
||||
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
|
||||
extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
case 'N':
|
||||
@ -469,6 +471,10 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
PRINTF_P(PSTR("\n\r---------\n\r"));
|
||||
break;
|
||||
}
|
||||
|
||||
case 'G':
|
||||
PRINTF_P(PSTR("Global repair returns %d\n\r"),rpl_repair_dag(rpl_get_dag(RPL_ANY_INSTANCE)));
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'm':
|
||||
@ -510,9 +516,9 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
);
|
||||
#if RF230BB
|
||||
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(" * Current RSSI: %ddB\n\r"), -91+3*(rf230_rssi()-1));
|
||||
PRINTF_P(PSTR(" * Last RSSI: %ddB\n\r"), -91+3*(rf230_last_rssi-1));
|
||||
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+(rf230_rssi()-1));
|
||||
PRINTF_P(PSTR(" * Last RSSI: %ddB\n\r"), -91+(rf230_last_rssi-1));
|
||||
#else // RF230BB
|
||||
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());
|
||||
@ -631,7 +637,7 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
//No more serial port
|
||||
stdout = NULL;
|
||||
#if USB_CONF_RS232
|
||||
usb_stdout = NULL;
|
||||
// usb_stdout = NULL;
|
||||
#endif
|
||||
|
||||
//RNDIS is over
|
||||
@ -643,6 +649,7 @@ extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
|
||||
//Wait a few seconds
|
||||
for(i = 0; i < 50; i++)
|
||||
watchdog_periodic();
|
||||
_delay_ms(100);
|
||||
|
||||
//Attach USB
|
||||
|
@ -62,9 +62,9 @@
|
||||
/* Mac address, RF channel, PANID from EEPROM settings manager */
|
||||
/* Generate random MAC address on first startup */
|
||||
/* 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 RNG_CONF_USE_RADIO_CLOCK 1
|
||||
#define RNG_CONF_USE_RADIO_CLOCK 1
|
||||
//#define RNG_CONF_USE_ADC 1
|
||||
|
||||
/* Since clock_time_t is 16 bits, maximum interval is 524 seconds */
|
||||
@ -73,15 +73,13 @@
|
||||
/* Maximum time interval (used for timers) */
|
||||
#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
|
||||
|
||||
/* Pre-allocated memory for loadable modules heap space (in bytes)*/
|
||||
#define MMEM_CONF_SIZE 256
|
||||
|
||||
/* Use the following address for code received via the codeprop
|
||||
* facility
|
||||
*/
|
||||
/* Use the following address for code received via the codeprop facility */
|
||||
#define EEPROMFS_ADDR_CODEPROP 0x8000
|
||||
|
||||
/* 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.
|
||||
* 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 */
|
||||
//#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
|
||||
#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
|
||||
/* ************************************************************************** */
|
||||
@ -296,7 +295,17 @@ or include the needed source files in /plaftorm/avr-ravenusb/Makefile.avr-ravenu
|
||||
// buffer_length = uip_len - uip_l2_l3_icmp_hdr_len;
|
||||
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 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
|
||||
#define UIP_CONF_STATISTICS 0
|
||||
|
||||
#define UIP_CONF_DS6_NBR_NBU 2
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 2
|
||||
#define UIP_CONF_DS6_NBR_NBU 5
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 5
|
||||
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
#define UIP_CONF_ND6_REACHABLE_TIME 600000
|
||||
|
@ -380,7 +380,10 @@ static void initialize(void) {
|
||||
);
|
||||
|
||||
#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
|
||||
|
||||
rimeaddr_set_node_addr(&tmp_addr);
|
||||
|
Loading…
Reference in New Issue
Block a user