Add rf230_listen_channel routine to force RX_ON state for sniffing and to read rssi for energy scan.

This commit is contained in:
dak664 2010-12-15 16:50:44 +00:00
parent d86b7c4592
commit aa7ad8c807
3 changed files with 27 additions and 20 deletions

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.19 2010/12/15 14:11:06 dak664 Exp $ * @(#)$Id: rf230bb.c,v 1.20 2010/12/15 16:50:44 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.
@ -412,20 +412,11 @@ radio_set_trx_state(uint8_t new_state)
void void
rf230_set_promiscuous_mode(bool isPromiscuous) { rf230_set_promiscuous_mode(bool isPromiscuous) {
if(isPromiscuous) { is_promiscuous = isPromiscuous;
is_promiscuous = true;
#if RF230_CONF_AUTOACK #if RF230_CONF_AUTOACK
/* For now only do promiscuous in Macintosh build */ /* TODO: Figure out when to pass promisc state to 802.15.4 */
#if USB_CONF_MACINTOSH // radio_set_trx_state(is_promiscuous?RX_ON:RX_AACK_ON);
radio_set_trx_state(RX_ON);
#endif #endif
#endif
} else {
is_promiscuous = false;
#if RF230_CONF_AUTOACK
radio_set_trx_state(RX_AACK_ON);
#endif
}
} }
bool bool
@ -466,12 +457,8 @@ on(void)
rf230_waitidle(); rf230_waitidle();
#if RF230_CONF_AUTOACK #if RF230_CONF_AUTOACK
/* For now only do promiscuous on Mac build */ // radio_set_trx_state(is_promiscuous?RX_ON:RX_AACK_ON);
#if USB_CONF_MACINTOSH
radio_set_trx_state(is_promiscuous?RX_ON:RX_AACK_ON);
#else
radio_set_trx_state(RX_AACK_ON); radio_set_trx_state(RX_AACK_ON);
#endif
#else #else
radio_set_trx_state(RX_ON); radio_set_trx_state(RX_ON);
#endif #endif
@ -888,6 +875,15 @@ rf230_set_channel(uint8_t c)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
rf230_listen_channel(uint8_t c)
{
/* Same as set channel but forces RX_ON state for sniffer or energy scan */
// PRINTF("rf230: Listen Channel %u\n",c);
rf230_set_channel(c);
radio_set_trx_state(RX_ON);
}
/*---------------------------------------------------------------------------*/
void
rf230_set_pan_addr(unsigned pan, rf230_set_pan_addr(unsigned pan,
unsigned addr, unsigned addr,
const uint8_t ieee_addr[8]) const uint8_t ieee_addr[8])

View file

@ -45,7 +45,7 @@
* \file * \file
* \brief This file contains radio driver code. * \brief This file contains radio driver code.
* *
* $Id: rf230bb.h,v 1.5 2010/12/14 22:34:18 dak664 Exp $ * $Id: rf230bb.h,v 1.6 2010/12/15 16:50:44 dak664 Exp $
*/ */
#ifndef RADIO_H #ifndef RADIO_H
@ -199,6 +199,7 @@ int rf230_init(void);
//int rf230_on(void); //int rf230_on(void);
//int rf230_off(void); //int rf230_off(void);
void rf230_set_channel(uint8_t channel); void rf230_set_channel(uint8_t channel);
void rf230_listen_channel(uint8_t channel);
uint8_t rf230_get_channel(void); uint8_t rf230_get_channel(void);
void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t ieee_addr[8]); void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t ieee_addr[8]);
void rf230_set_txpower(uint8_t power); void rf230_set_txpower(uint8_t power);

View file

@ -389,12 +389,22 @@ void menu_process(char c)
PRINTF_P(PSTR("Jackdaw now in sniffer mode\n\r")); PRINTF_P(PSTR("Jackdaw now in sniffer mode\n\r"));
usbstick_mode.sendToRf = 0; usbstick_mode.sendToRf = 0;
usbstick_mode.translate = 0; usbstick_mode.translate = 0;
#if RF230BB
rf230_listen_channel(rf230_get_channel());
#else
radio_set_trx_state(RX_ON);
#endif
break; break;
case 'n': case 'n':
PRINTF_P(PSTR("Jackdaw now in network mode\n\r")); PRINTF_P(PSTR("Jackdaw now in network mode\n\r"));
usbstick_mode.sendToRf = 1; usbstick_mode.sendToRf = 1;
usbstick_mode.translate = 1; usbstick_mode.translate = 1;
#if RF230BB
rf230_set_channel(rf230_get_channel());
#else
radio_set_trx_state(RX_AACK_ON); //TODO: Use startup state which may be RX_ON
#endif
break; break;
case '6': case '6':
@ -594,7 +604,7 @@ extern uip_ds6_netif_t uip_ds6_if;
for(j=0;j<(1<<12);j++) { for(j=0;j<(1<<12);j++) {
for(i=11;i<=26;i++) { for(i=11;i<=26;i++) {
#if RF230BB #if RF230BB
rf230_set_channel(i); rf230_listen_channel(i);
#else // RF230BB #else // RF230BB
radio_set_operating_channel(i); radio_set_operating_channel(i);
#endif #endif