Merge pull request #1795 from g-oikonomou/contrib/sensniff
Add generic sensniff example and remove legacy sniffers
This commit is contained in:
commit
7ddbe640be
53 changed files with 1180 additions and 959 deletions
|
@ -57,20 +57,6 @@ static RIE_BaseConfigs base_config = ADUCRF101_RADIO_BASE_CONFIG;
|
|||
static int current_channel = 915000000;
|
||||
static int current_power = 31;
|
||||
static int radio_is_on = 0;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Sniffer configuration. We can re-use the CC2538 sniffer application
|
||||
if we also accept CC2538_RF_CONF_SNIFFER. */
|
||||
#ifndef ADUCRF101_RF_CONF_SNIFFER
|
||||
#if CC2538_RF_CONF_SNIFFER
|
||||
#define ADUCRF101_RF_CONF_SNIFFER 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ADUCRF101_RF_CONF_SNIFFER
|
||||
#include "dev/uart.h"
|
||||
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /* Snif */
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* "Channel" is really frequency, and can be within the bands:
|
||||
431000000 Hz to 464000000 Hz
|
||||
|
@ -246,20 +232,6 @@ read(void *buf, unsigned short buf_len)
|
|||
/* Re-enter receive mode immediately after receiving a packet */
|
||||
RadioRxPacketVariableLen();
|
||||
|
||||
#if ADUCRF101_RF_CONF_SNIFFER
|
||||
uart_put(magic[0]);
|
||||
uart_put(magic[1]);
|
||||
uart_put(magic[2]);
|
||||
uart_put(magic[3]);
|
||||
uart_put(packet_len + 2);
|
||||
for(int i = 0; i < packet_len; i++) {
|
||||
uart_put(((uint8_t *)buf)[i]);
|
||||
}
|
||||
/* FCS value is Wireshark's "TI CC24xx format" option: */
|
||||
uart_put(rssi); /* RSSI */
|
||||
uart_put(0x80); /* CRC is OK, LQI correlation is 0 */
|
||||
#endif
|
||||
|
||||
return packet_len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
* On the cc2538, character I/O can be directed over USB or UART. This is
|
||||
* controlled by a series of configuration directives:
|
||||
* - SLIP_ARCH_CONF_USB: Controls the operation of slip-arch.
|
||||
* - CC2538_RF_CONF_SNIFFER_USB: Controls the output of the RF driver when
|
||||
* operating as a sniffer
|
||||
* - DBG_CONF_USB: Controls all debugging output
|
||||
*
|
||||
* Defaults for those defines are set in contiki-conf.h
|
||||
|
|
|
@ -91,29 +91,6 @@
|
|||
/* 192 usec off -> on interval (RX Callib -> SFD Wait). We wait a bit more */
|
||||
#define ONOFF_TIME RTIMER_ARCH_SECOND / 3125
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Sniffer configuration */
|
||||
#ifndef CC2538_RF_CONF_SNIFFER_USB
|
||||
#define CC2538_RF_CONF_SNIFFER_USB 0
|
||||
#endif
|
||||
|
||||
#if CC2538_RF_CONF_SNIFFER
|
||||
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /** Snif */
|
||||
|
||||
#if CC2538_RF_CONF_SNIFFER_USB
|
||||
#include "usb/usb-serial.h"
|
||||
#define write_byte(b) usb_serial_writeb(b)
|
||||
#define flush() usb_serial_flush()
|
||||
#else
|
||||
#include "dev/uart.h"
|
||||
#define write_byte(b) uart_write_byte(CC2538_RF_CONF_SNIFFER_UART, b)
|
||||
#define flush()
|
||||
#endif
|
||||
|
||||
#else /* CC2538_RF_CONF_SNIFFER */
|
||||
#define write_byte(b)
|
||||
#define flush()
|
||||
#endif /* CC2538_RF_CONF_SNIFFER */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef CC2538_RF_CONF_AUTOACK
|
||||
#define CC2538_RF_AUTOACK CC2538_RF_CONF_AUTOACK
|
||||
#else
|
||||
|
@ -526,11 +503,6 @@ init(void)
|
|||
REG(RFCORE_XREG_FRMCTRL0) |= RFCORE_XREG_FRMCTRL0_AUTOACK;
|
||||
#endif
|
||||
|
||||
/* If we are a sniffer, turn off frame filtering */
|
||||
#if CC2538_RF_CONF_SNIFFER
|
||||
REG(RFCORE_XREG_FRMFILT0) &= ~RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN;
|
||||
#endif
|
||||
|
||||
/* Disable source address matching and autopend */
|
||||
REG(RFCORE_XREG_SRCMATCH) = 0;
|
||||
|
||||
|
@ -798,20 +770,6 @@ read(void *buf, unsigned short bufsize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if CC2538_RF_CONF_SNIFFER
|
||||
write_byte(magic[0]);
|
||||
write_byte(magic[1]);
|
||||
write_byte(magic[2]);
|
||||
write_byte(magic[3]);
|
||||
write_byte(len + 2);
|
||||
for(i = 0; i < len; ++i) {
|
||||
write_byte(((unsigned char *)(buf))[i]);
|
||||
}
|
||||
write_byte(rssi);
|
||||
write_byte(crc_corr);
|
||||
flush();
|
||||
#endif
|
||||
|
||||
if(!poll_mode) {
|
||||
/* If FIFOP==1 and FIFO==0 then we had a FIFO overflow at some point. */
|
||||
if(REG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) {
|
||||
|
|
|
@ -101,11 +101,6 @@
|
|||
#define CC2530_RF_TX_POWER_TXCTRL_MIN_VAL 0x09 /* Value for min TX Power */
|
||||
#define CC2530_RF_TX_POWER_TXCTRL_DEF_VAL 0x69 /* Reset Value */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
#include "dev/io-arch.h"
|
||||
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /* Snif */
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef CC2530_RF_CONF_AUTOACK
|
||||
#define CC2530_RF_AUTOACK CC2530_RF_CONF_AUTOACK
|
||||
#else
|
||||
|
@ -531,15 +526,6 @@ read(void *buf, unsigned short bufsize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
/* If we reach here, chances are the FIFO is holding a valid frame */
|
||||
io_arch_writeb(magic[0]);
|
||||
io_arch_writeb(magic[1]);
|
||||
io_arch_writeb(magic[2]);
|
||||
io_arch_writeb(magic[3]);
|
||||
io_arch_writeb(len);
|
||||
#endif
|
||||
|
||||
RF_RX_LED_ON();
|
||||
|
||||
PUTSTRING("RF: read (0x");
|
||||
|
@ -548,9 +534,6 @@ read(void *buf, unsigned short bufsize)
|
|||
len -= CHECKSUM_LEN;
|
||||
for(i = 0; i < len; ++i) {
|
||||
((unsigned char *)(buf))[i] = RFD;
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
io_arch_writeb(((unsigned char *)(buf))[i]);
|
||||
#endif
|
||||
PUTHEX(((unsigned char *)(buf))[i]);
|
||||
}
|
||||
PUTSTRING("\n");
|
||||
|
@ -559,12 +542,6 @@ read(void *buf, unsigned short bufsize)
|
|||
rssi = ((int8_t) RFD) - RSSI_OFFSET;
|
||||
crc_corr = RFD;
|
||||
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
io_arch_writeb(rssi);
|
||||
io_arch_writeb(crc_corr);
|
||||
io_arch_flush();
|
||||
#endif
|
||||
|
||||
/* MS bit CRC OK/Not OK, 7 LS Bits, Correlation value */
|
||||
if(crc_corr & CRC_BIT_MASK) {
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rssi);
|
||||
|
|
|
@ -107,16 +107,6 @@
|
|||
#define PROP_MODE_USE_CRC16 0
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef PROP_MODE_CONF_SNIFFER
|
||||
#define PROP_MODE_SNIFFER PROP_MODE_CONF_SNIFFER
|
||||
#else
|
||||
#define PROP_MODE_SNIFFER 0
|
||||
#endif
|
||||
|
||||
#if PROP_MODE_SNIFFER
|
||||
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 };
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Returns the current status of a running Radio Op command
|
||||
* \param a A pointer with the buffer used to initiate the command
|
||||
|
@ -773,28 +763,7 @@ read_frame(void *buf, unsigned short buf_len)
|
|||
}
|
||||
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (int8_t)data_ptr[len]);
|
||||
|
||||
#if PROP_MODE_SNIFFER
|
||||
{
|
||||
int i;
|
||||
|
||||
cc26xx_uart_write_byte(magic[0]);
|
||||
cc26xx_uart_write_byte(magic[1]);
|
||||
cc26xx_uart_write_byte(magic[2]);
|
||||
cc26xx_uart_write_byte(magic[3]);
|
||||
|
||||
cc26xx_uart_write_byte(len + 2);
|
||||
|
||||
for(i = 0; i < len; ++i) {
|
||||
cc26xx_uart_write_byte(((uint8_t *)(buf))[i]);
|
||||
}
|
||||
|
||||
cc26xx_uart_write_byte((uint8_t)rx_stats.lastRssi);
|
||||
cc26xx_uart_write_byte(0x80);
|
||||
|
||||
while(cc26xx_uart_busy() == UART_BUSY);
|
||||
}
|
||||
#endif
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, 0x7F);
|
||||
}
|
||||
|
||||
/* Move read entry pointer to next entry */
|
||||
|
@ -1082,6 +1051,8 @@ set_value(radio_param_t param, radio_value_t value)
|
|||
rv = RADIO_RESULT_ERROR;
|
||||
}
|
||||
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_RX_MODE:
|
||||
return RADIO_RESULT_OK;
|
||||
case RADIO_PARAM_CCA_THRESHOLD:
|
||||
rssi_threshold = (int8_t)value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue