Merge remote-tracking branch 'contiki/master' into PR2

This commit is contained in:
Peter 2017-04-11 17:00:38 +02:00
commit 1fa9dde049
38 changed files with 693 additions and 366 deletions

View file

@ -107,7 +107,7 @@ int coap_obs_remove_observee_by_token(uip_ipaddr_t *addr, uint16_t port,
int coap_obs_remove_observee_by_url(uip_ipaddr_t *addr, uint16_t port,
const char *url);
void coap_handle_notification(uip_ipaddr_t *, uint16_t port,
void coap_handle_notification(uip_ipaddr_t *addr, uint16_t port,
coap_packet_t *notification);
coap_observee_t *coap_obs_request_registration(uip_ipaddr_t *addr,

View file

@ -1338,7 +1338,9 @@ mqtt_connect(struct mqtt_connection *conn, char *host, uint16_t port,
conn->connect_vhdr_flags |= MQTT_VHDR_CLEAN_SESSION_FLAG;
/* convert the string IPv6 address to a numeric IPv6 address */
uiplib_ip6addrconv(host, &ip6addr);
if(uiplib_ip6addrconv(host, &ip6addr) == 0) {
return MQTT_STATUS_ERROR;
}
uip_ipaddr_copy(&(conn->server_ip), ipaddr);

View file

@ -148,13 +148,6 @@
#endif /* NBR_TABLE_FIND_REMOVABLE */
#endif /* UIP_CONF_IPV6_RPL */
/* RPL_CONF_MOP specifies the RPL mode of operation that will be
* advertised by the RPL root. Possible values: RPL_MOP_NO_DOWNWARD_ROUTES,
* RPL_MOP_NON_STORING, RPL_MOP_STORING_NO_MULTICAST, RPL_MOP_STORING_MULTICAST */
#ifndef RPL_CONF_MOP
#define RPL_CONF_MOP RPL_MOP_STORING_NO_MULTICAST
#endif /* RPL_CONF_MOP */
/* UIP_CONF_MAX_ROUTES specifies the maximum number of routes that each
node will be able to handle. */
#ifndef UIP_CONF_MAX_ROUTES

View file

@ -1,8 +1,8 @@
# IEEE 802.15.4e TSCH (TimeSlotted Channel Hopping)
# IEEE 802.15.4-2015 TSCH and IETF 6TiSCH
## Overview
TSCH is a MAC layer of the [IEEE 802.15.4e-2012 amendment][ieee802.15.4e-2012],
Time Slotted Channel Hopping (TSCH) is a MAC layer of the [IEEE 802.15.4e-2012 amendment][ieee802.15.4e-2012],
currently being integrated as part of the new IEEE 802.15.4-2015.
[6TiSCH][ietf-6tisch-wg] is an IETF Working Group focused on IPv6 over TSCH.
This is a Contiki implementation of TSCH and the 6TiSCH so-called "minimal configuration",
@ -13,7 +13,9 @@ It was developped by:
* Beshr Al Nahas, SICS (now Chalmers University), beshr@chalmers.se, github user: [beshrns](https://github.com/beshrns)
* Atis Elsts, Univ. Bristol, atis.elsts@bristol.ac.uk, github user: [atiselsts](https://github.com/atiselsts)
You can find an extensive evaluation of this implementation in our paper [*Orchestra: Robust Mesh Networks Through Autonomously Scheduled TSCH*](http://www.simonduquennoy.net/papers/duquennoy15orchestra.pdf), ACM SenSys'15.
This implementation is presented in depth and evaluated in our paper: [*TSCH and 6TiSCH for Contiki: Challenges, Design and Evaluation*](http://www.simonduquennoy.net/papers/duquennoy17tsch.pdf), IEEE DCOSS'17.
The scheduler Orchestra is detailled in [*Orchestra: Robust Mesh Networks Through Autonomously Scheduled TSCH*](http://www.simonduquennoy.net/papers/duquennoy15orchestra.pdf), ACM SenSys'15.
## Features
@ -27,7 +29,7 @@ This implementation includes:
* Standard TSCH link selection and slot operation (10ms slots by default)
* Standard TSCH synchronization, including with ACK/NACK time correction Information Element
* Standard TSCH queues and CSMA-CA mechanism
* Standard TSCH security
* Standard TSCH and 6TiSCH security
* Standard 6TiSCH TSCH-RPL interaction (6TiSCH Minimal Configuration and Minimal Schedule)
* A scheduling API to add/remove slotframes and links
* A system for logging from TSCH timeslot operation interrupt, with postponed printout

View file

@ -644,11 +644,17 @@ rpl_update_header(void)
/* At the root, remove headers if any, and insert SRH or HBH
* (SRH is inserted only if the destination is in the DODAG) */
rpl_remove_header();
if(rpl_get_dag(&UIP_IP_BUF->destipaddr) != NULL) {
/* dest is in a DODAG; the packet is going down. */
if(RPL_IS_NON_STORING(default_instance)) {
return insert_srh_header();
} else {
return insert_hbh_header(default_instance);
}
} else {
/* dest is outside of DODAGs; no ext header is needed. */
return 1;
}
} else {
if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)
&& UIP_IP_BUF->ttl == uip_ds6_if.cur_hop_limit) {

View file

@ -67,7 +67,7 @@ AR = ar65
# The apps coming with Contiki run even on a 0x100 byte stack.
ASFLAGS = -t $(TARGET)
CFLAGS += -t $(TARGET) -Or -W -unused-param
CFLAGS += -t $(TARGET) -Ors -W -unused-param
LDFLAGS = -t $(TARGET) -m contiki-$(TARGET).map -D __STACKSIZE__=0x200
AROPTS = a

View file

@ -236,6 +236,7 @@
#define RG_RX_SYN 0x15
/** Offset for register XAH_CTRL_1 */
#define RG_XAH_CTRL_1 0x17
#define SR_AACK_PROM_MODE 0x17, 0x02, 1
/** Access parameters for sub-register XTAL_MODE in register @ref RG_XOSC_CTRL */
#define SR_XTAL_MODE 0x12, 0xf0, 4
/** Access parameters for sub-register XTAL_TRIM in register @ref RG_XOSC_CTRL */
@ -340,6 +341,7 @@
#define SR_CSMA_SEED_0 0x2d, 0xff, 0
/** Offset for register CSMA_SEED_1 */
#define RG_CSMA_SEED_1 (0x2e)
#define SR_AACK_DIS_ACK 0x2e, 0x10, 4
/** Offset for register CSMA_BE */
#define RG_CSMA_BE 0x2f
/** Access parameters for sub-register MIN_BE in register @ref RG_CSMA_SEED_1 */

View file

@ -83,7 +83,10 @@
#define SR_CCA_DONE 0x141, 0x80, 7
#define SR_CCA_STATUS 0x141, 0x40, 6
#define SR_AACK_SET_PD 0x16e, 0x20, 5
#define SR_AACK_DIS_ACK 0x16e, 0x10, 4
#define RG_XAH_CTRL_1 (0x157)
#define SR_AACK_PROM_MODE 0x157, 0x02, 1
/* RF230 register assignments, for reference */
#if 0

View file

@ -41,6 +41,120 @@
* Registers can be read with a macro, but the args for subregisters don't expand properly so the actual address
* is used with explicit _SFR_MEM8 in the subregister read/write routines.
*/
/* Symbol Counter */
#define RG_SCCNTHH (0xE4) /* SCCNTHH7-0 */
#define RG_SCCNTHL (0xE3) /* SCCNTHL7-0 */
#define RG_SCCNTLH (0xE2) /* SCCNTLH7-0 */
#define RG_SCCNTLL (0xE1) /* SCCNTLL7-0 */
/* Counter control register 0 */
#define RG_SCCR0 (0xdc)
#define SR_SCCR0 0xdc, 0xff, 0
#define SR_SCCR0_SCRES 0xdc, 0x80, 7 /* Counter Sync. */
#define SR_SCCR0_SCMBTS 0xdc, 0x40, 6 /* Manual Beacon timestamp */
#define SR_SCCR0_SCEN 0xdc, 0x20, 5 /* Counter enable */
#define SR_SCCR0_SCCKSEL 0xdc, 0x10, 4 /* Counter clock source */
#define SR_SCCR0_SCTSE 0xdc, 0x08, 3 /* Auto timstamp Beacon, SFD */
#define SR_SCCR0_SCMP3 0xdc, 0x04, 2 /* Compare 3 counter mode sel. */
#define SR_SCCR0_SCMP2 0xdc, 0x02, 1 /* Compare 2 counter mode sel. */
#define SR_SCCR0_SCMP1 0xdc, 0x01, 0 /* Compare 1 counter mode sel. */
/* Counter control register 1 */
#define RG_SCCR1 (0xdd)
#define SR_SCCR1 0xdd, 0xff, 0
#define SR_SCCR1_SCBTSM 0xdd, 0x20, 5 /* Disable beacon timestamp */
#define SR_SCCR1_CLKDIV 0xdd, 0x1c, 2 /* CLKDIV */
#define SR_SCCR1_CLK0 0xdd, 0x10, 4 /* CLK0 */
#define SR_SCCR1_CLK1 0xdd, 0x08, 3 /* CLK1 */
#define SR_SCCR1_CLK2 0xdd, 0x04, 2 /* CLK2 */
#define SR_SCCR1_EECLK 0xdd, 0x02, 1 /* */
#define SR_SCCR1_SCENBO 0xdd, 0x01, 0 /* Backoff Slot Counter Enable */
/* Prescaler for symbol counter */
#define SCCKDIV_62_5k 0
#define SCCKDIV_125k 1
#define SCCKDIV_250k 2
#define SCCKDIV_500k 3
#define SCCKDIV_1M 4
#define SCCKDIV_2M 5
#define SCCKDIV_4M 6
/* Counter status register 1 */
#define RG_SCSR (0xde)
#define SR_SCSR 0xde, 0xff, 0
#define SR_SCBSY 0xde, 0x01, 0 /* Symbol counter busy */
/* Counter ISR */
#define RG_SCIRQS (0xe0)
#define SR_SCIRQS 0xe0, 0xff, 0
#define SR_SCIRQS_IRQSB0 0xe0, 0x10, 4 /* Backoff */
#define SR_SCIRQS_IRQSOF 0xe0, 0x08, 3 /* Counter overflow */
#define SR_SCIRQS_IRQSCP3 0xe0, 0x04, 2 /* Compare 3 counter */
#define SR_SCIRQS_IRQSCP2 0xe0, 0x02, 1 /* Compare 2 counter */
#define SR_SCIRQS_IRQSCP1 0xe0, 0x01, 0 /* Compare 1 counter */
/* Counter IRQ mask */
#define RG_SCIRQM (0xdf)
#define SR_SCIRQM 0xdf, 0xff, 0
#define SR_SCIRQM_IRQMB0 0xdf, 0x10, 4 /* Backoff mask */
#define SR_SCIRQM_IRQMOF 0xdf, 0x08, 3 /* Counter overflow mask */
#define SR_SCIRQM_IRQMCP3 0xdf, 0x04, 2 /* Compare 3 counter mask */
#define SR_SCIRQM_IRQMCP2 0xdf, 0x02, 1 /* Compare 2 counter mask */
#define SR_SCIRQM_IRQMCP1 0xdf, 0x01, 0 /* Compare 1 counter mask */
/* Timestamp SFD */
#define RG_SCTSRHH 0xFC /* SCTSRHH7-0 */
#define RG_SCTSRHL 0xFB /* SCTSRHL7-0 */
#define RG_SCTSRLH 0xFA /* SCTSRLH7-0 */
#define RG_SCTSRLL 0xF9 /* SCTSRLL7-0 */
/* Beacon Timestamp */
#define RG_SCBTSRHH (0xE8) /* SCBTSRHH7-0 */
#define RG_SCBTSRHL (0xE7) /* SCBTSRHL7-0 */
#define RG_SCBTSRLH (0xE6) /* SCBTSRLH7-0 */
#define RG_SCBTSRLL (0xE5) /* SCBTSRLL7-0 */
/* Output Compare 1 */
#define RG_SCOCR1HH (0xF8) /* SCOCR1HH7-0 */
#define RG_SCOCR1HL (0xF7) /* SCOCR1HL7-0 */
#define RG_SCOCR1LH (0xF6) /* SCOCR1LH7-0 */
#define RG_SCOCR1LL (0xF5) /* SCOCR1LL7-0 */
/* Output Compare 2 */
#define RG_SCOCR2HH (0xF4) /* SCOCR2HH7-0 */
#define RG_SCOCR2HL (0xF3) /* SCOCR2HL7-0 */
#define RG_SCOCR2LH (0xF2) /* SCOCR2LH7-0 */
#define RG_SCOCR2LL (0xF1) /* SCOCR2LL7-0 */
/* Output Compare 3 */
#define RG_SCOCR3HH (0xF0) /* SCOCR3HH7-0 */
#define RG_SCOCR3HL (0xEF) /* SCOCR3HL7-0 */
#define RG_SCOCR3LH (0xEE) /* SCOCR3LH7-0 */
#define RG_SCOCR3LL (0xED) /* SCOCR3LL7-0 */
/* Transmit Frame Timestamp */
#define RG_SCTSTRHH (0xFC) /* SCTSTRHH7-0 */
#define RG_SCTSTRHL (0xFB) /* SCTSTRHL7-0 */
#define RG_SCTSTRLH (0xFA) /* SCTSTRLH7-0 */
#define RG_SCTSTRLL (0xF9) /* SCTSTRLL7-0 */
/*
Interrupt Status
#define RG_SCIRQS (0xE0) Res2 Res1 Res0 IRQSBO IRQSOF IRQSCP3 IRQSCP2 IRQSCP1 page 173
Interrupt Mask
#define RG_SCIRQM (0xDF) Res2 Res1 Res0 IRQMBO IRQMOF IRQMCP3 IRQMCP2 IRQMCP1 page 174
Counter status
#define RG_SCSR (0xDE) Res6 Res5 Res4 Res3 Res2 Res1 Res0 SCBSY page 173
Counter Control 1
#define RG_SCCR1 (0xDD) Res6 Res5 SCBTSM SCCKDIV2 SCCKDIV1 SCCKDIV0 SCEECLK SCENBO page 172
Counter Control 0
#define RG_SCCR0 (0xDC) SCRES SCMBTS SCEN SCCKSEL SCTSE SCCMP3 SCCMP2 SCCMP1 page 171
Counter Compare Source
#define RG_SCCSR (0xDB) Res1 Res0 SCCS31 SCCS30 SCCS21 SCCS20 SCCS11 SCCS10 page 161
*/
#define RG_TRX_STATUS TRX_STATUS
#define SR_TRX_STATUS 0x141, 0x1f, 0
#define SR_TRX_CMD 0x142, 0x1f, 0
@ -48,9 +162,35 @@
#define SR_TX_PWR 0x145, 0x0f, 0
#define RG_VERSION_NUM VERSION_NUM
#define RG_MAN_ID_0 MAN_ID_0
#define RG_IRQ_MASK IRQ_MASK
#define RG_IRQ_MASK (0x14e)
/** Access parameters for sub-register IRQ_MASK in register @ref RG_IRQ_MASK */
#define SR_IRQ_MASK 0x14e, 0xff, 0
/** Offset for register IRQ_STATUS */
#define RG_IRQ_STATUS (0x14f)
#define SR_IRQ_STATUS 0x14f, 0xff, 0
/** Awake Interrupt Status */
#define SR_IRQ_AWAKE 0x14f, 0x80, 7
/** TX_END Interrupt Status */
#define SR_IRQ_TX_END 0x14f, 0x40, 6
/** Address Match */
#define SR_IRQ_AMI 0x14f, 0x20, 5
/** End of ED Measurement Interrupt Status */
#define SR_CCA_ED_DONE 0x14f, 0x10, 4
/** Access parameters for sub-register IRQ_3_TRX_END in register @ref RG_IRQ_STATUS */
#define SR_IRQ_3_TRX_END 0x14f, 0x08, 3
/** Access parameters for sub-register IRQ_2_RX_START in register @ref RG_IRQ_STATUS */
#define SR_IRQ_2_RX_START 0x14f, 0x04, 2
/** Access parameters for sub-register IRQ_1_PLL_UNLOCK in register @ref RG_IRQ_STATUS */
#define SR_IRQ_1_PLL_UNLOCK 0x14f, 0x02, 1
/** Access parameters for sub-register IRQ_0_PLL_LOCK in register @ref RG_IRQ_STATUS */
#define RG_XAH_CTRL_1 (0x157)
#define SR_AACK_PROM_MODE 0x157, 0x02, 1
#define SR_IRQ_0_PLL_LOCK 0x14f, 0x01, 0
#define SR_MAX_FRAME_RETRIES 0x16C, 0xf0, 4
#define SR_TX_AUTO_CRC_ON 0x144, 0x20, 5
#define SR_PLL_FLT 0x144, 0x10, 4
#define SR_TRAC_STATUS 0x142, 0xe0, 5
#define SR_CHANNEL 0x148, 0x1f, 0
#define SR_CCA_MODE 0x148, 0x60, 5
@ -67,7 +207,7 @@
#define RG_IEEE_ADDR_5 IEEE_ADDR_5
#define RG_IEEE_ADDR_6 IEEE_ADDR_6
#define RG_IEEE_ADDR_7 IEEE_ADDR_7
//#define SR_ED_LEVEL 0x147, 0xff, 0
/* #define SR_ED_LEVEL 0x147, 0xff, 0 */
#define RG_PHY_ED_LEVEL PHY_ED_LEVEL
#define RG_RX_SYN RX_SYN
#define SR_RSSI 0x146, 0x1f, 0
@ -81,12 +221,13 @@
#define RG_CSMA_BE CSMA_BE
#define RG_CSMA_SEED_0 CSMA_SEED_0
#define RG_PHY_RSSI PHY_RSSI
//#define SR_CCA_CS_THRES 0x149, 0xf0, 4
#define SR_CCA_CS_THRES 0x149, 0xf0, 4
#define SR_CCA_ED_THRES 0x149, 0x0f, 0
#define SR_CCA_DONE 0x141, 0x80, 7
#define SR_CCA_STATUS 0x141, 0x40, 6
#define SR_AACK_SET_PD 0x16e, 0x20, 5
#define SR_CSMA_SEED_1 0x16e, 0x10, 4
#define SR_CSMA_SEED_1 0x16e, 0x03, 0
#define SR_AACK_DIS_ACK 0x16e, 0x10, 4
/* RF230 register assignments, for reference */
#if 1
@ -216,27 +357,6 @@
///** Access parameters for sub-register CCA_ED_THRES in register @ref RG_CCA_THRES */
//#define SR_CCA_ED_THRES 0x09, 0x0f, 0
///** Offset for register IRQ_MASK */
//#define RG_IRQ_MASK (0x0e)
///** Access parameters for sub-register IRQ_MASK in register @ref RG_IRQ_MASK */
//#define SR_IRQ_MASK 0x0e, 0xff, 0
///** Offset for register IRQ_STATUS */
//#define RG_IRQ_STATUS (0x0f)
///** Access parameters for sub-register IRQ_7_BAT_LOW in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7
///** Access parameters for sub-register IRQ_6_TRX_UR in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6
///** Access parameters for sub-register IRQ_5 in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_5 0x0f, 0x20, 5
///** Access parameters for sub-register IRQ_4 in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_4 0x0f, 0x10, 4
///** Access parameters for sub-register IRQ_3_TRX_END in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_3_TRX_END 0x0f, 0x08, 3
///** Access parameters for sub-register IRQ_2_RX_START in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_2_RX_START 0x0f, 0x04, 2
///** Access parameters for sub-register IRQ_1_PLL_UNLOCK in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1
///** Access parameters for sub-register IRQ_0_PLL_LOCK in register @ref RG_IRQ_STATUS */
//#define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0
///** Offset for register VREG_CTRL */
//#define RG_VREG_CTRL (0x10)
///** Access parameters for sub-register AVREG_EXT in register @ref RG_VREG_CTRL */

View file

@ -81,10 +81,10 @@ extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE];
#include "at86rf230_registermap.h"
#endif
extern void rf230_get_last_rx_packet_timestamp(void);
/*============================ VARIABLES =====================================*/
volatile extern signed char rf230_last_rssi;
/*============================ CALLBACKS =====================================*/
@ -668,7 +668,7 @@ ISR(TRX24_RX_START_vect)
#if !RF230_CONF_AUTOACK
rf230_last_rssi = 3 * hal_subregister_read(SR_RSSI);
#endif
rf230_get_last_rx_packet_timestamp();
}
/* PLL has locked, either from a transition out of TRX_OFF or a channel change while on */

View file

@ -94,6 +94,9 @@
static bool is_promiscuous;
#endif
/* Poll mode disabled by default */
uint8_t poll_mode = 0;
/* RF230_CONF_FRAME_RETRIES is 1 plus the number written to the hardware. */
/* Valid range 1-16, zero disables extended mode. */
#ifndef RF230_CONF_FRAME_RETRIES
@ -143,6 +146,8 @@ uint8_t ack_pending,ack_seqnum;
#warning RF230 Untested Configuration!
#endif
static rtimer_clock_t rf230_last_rx_packet_timestamp;
struct timestamp {
uint16_t time;
uint8_t authority_level;
@ -201,6 +206,8 @@ extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE];
#define DEBUGFLOW(c)
#endif
static radio_status_t radio_set_trx_state(uint8_t new_state);
/* XXX hack: these will be made as Chameleon packet attributes */
#if RF230_CONF_TIMESTAMPS
rtimer_clock_t rf230_time_of_arrival, rf230_time_of_departure;
@ -254,22 +261,238 @@ static int rf230_cca(void);
uint8_t rf230_last_correlation,rf230_last_rssi,rf230_smallest_rssi;
static void
set_poll_mode(bool enable)
{
poll_mode = enable;
if(poll_mode) {
rf230_set_rpc(0x0); /* Disbable all RPC features */
radio_set_trx_state(RX_ON);
hal_subregister_write(SR_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK);
/* hal_register_write(RG_IRQ_MASK, 0xFF); */
} else {
/* Initialize and enable interrupts */
rf230_set_rpc(0xFF); /* Enable all RPC features. Only XRFR2 radios */
radio_set_trx_state(RX_AACK_ON);
}
}
static bool
get_poll_mode(void)
{
return poll_mode;
}
static void
set_frame_filtering(bool i)
{
if(i)
hal_subregister_write(SR_AACK_PROM_MODE, 0);
else {
hal_subregister_write(SR_AACK_PROM_MODE, 1);
}
}
static bool
get_frame_filtering(void)
{
int i = hal_subregister_read(SR_AACK_PROM_MODE);
if(i)
return 0;
return 1;
}
static void
set_auto_ack(bool i)
{
if(i)
hal_subregister_write(SR_AACK_DIS_ACK, 0);
else
hal_subregister_write(SR_AACK_DIS_ACK, 1);
}
static bool
get_auto_ack(void)
{
int i = hal_subregister_read(SR_AACK_DIS_ACK);
if(i)
return 0;
return 1;
}
uint16_t
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;
}
static void
rf230_set_panid(uint16_t pan)
{
hal_register_write(RG_PAN_ID_1, (pan >> 8));
hal_register_write(RG_PAN_ID_0, (pan & 0xFF));
}
static uint16_t
rf230_get_short_addr(void)
{
unsigned char a0, a1;
a0 = hal_register_read(RG_SHORT_ADDR_0);
a1 = hal_register_read(RG_SHORT_ADDR_1);
return (a1 << 8) | a0;
}
static void
rf230_set_short_addr(uint16_t addr)
{
hal_register_write(RG_SHORT_ADDR_0, (addr & 0xFF));
hal_register_write(RG_SHORT_ADDR_1, (addr >> 8));
}
/*---------------------------------------------------------------------------*/
static radio_result_t
get_value(radio_param_t param, radio_value_t *value)
{
if(!value) {
return RADIO_RESULT_INVALID_VALUE;
}
switch(param) {
case RADIO_PARAM_POWER_MODE:
/* *value = (REG(RFCORE_XREG_RXENABLE) && RFCORE_XREG_RXENABLE_RXENMASK) == 0 )?
RADIO_POWER_MODE_OFF : RADIO_POWER_MODE_ON; */
return RADIO_RESULT_OK;
case RADIO_PARAM_TX_MODE:
return RADIO_RESULT_OK;
case RADIO_PARAM_CHANNEL:
*value = (radio_value_t)rf230_get_channel();
return RADIO_RESULT_OK;
case RADIO_PARAM_PAN_ID:
*value = rf230_get_panid();
return RADIO_RESULT_OK;
case RADIO_PARAM_16BIT_ADDR:
*value = rf230_get_short_addr();
return RADIO_RESULT_OK;
case RADIO_PARAM_RX_MODE:
*value = 0;
if(get_frame_filtering()) {
*value |= RADIO_RX_MODE_ADDRESS_FILTER;
}
if(get_auto_ack()) {
*value |= RADIO_RX_MODE_AUTOACK;
}
if(get_poll_mode()) {
*value |= RADIO_RX_MODE_POLL_MODE;
}
return RADIO_RESULT_OK;
case RADIO_PARAM_TXPOWER:
*value = rf230_get_txpower();
return RADIO_RESULT_OK;
case RADIO_PARAM_CCA_THRESHOLD:
/* *value = get_cca_threshold(); */
return RADIO_RESULT_OK;
case RADIO_PARAM_RSSI:
*value = rf230_get_raw_rssi();
return RADIO_RESULT_OK;
case RADIO_CONST_CHANNEL_MIN:
*value = RF230_MIN_CHANNEL;
return RADIO_RESULT_OK;
case RADIO_CONST_CHANNEL_MAX:
*value = RF230_MAX_CHANNEL;;
return RADIO_RESULT_OK;
case RADIO_CONST_TXPOWER_MIN:
*value = TX_PWR_MIN;
return RADIO_RESULT_OK;
case RADIO_CONST_TXPOWER_MAX:
*value = TX_PWR_MAX;
return RADIO_RESULT_OK;
default:
return RADIO_RESULT_NOT_SUPPORTED;
}
}
/*---------------------------------------------------------------------------*/
static radio_result_t
set_value(radio_param_t param, radio_value_t value)
{
switch(param) {
case RADIO_PARAM_POWER_MODE:
if(value == RADIO_POWER_MODE_ON) {
rf230_on();
return RADIO_RESULT_OK;
}
if(value == RADIO_POWER_MODE_OFF) {
rf230_off();
return RADIO_RESULT_OK;
}
return RADIO_RESULT_INVALID_VALUE;
case RADIO_PARAM_CHANNEL:
if(value < RF230_MIN_CHANNEL ||
value > RF230_MAX_CHANNEL) {
return RADIO_RESULT_INVALID_VALUE;
}
rf230_set_channel(value);
return RADIO_RESULT_OK;
case RADIO_PARAM_TX_MODE:
return RADIO_RESULT_OK;
case RADIO_PARAM_PAN_ID:
rf230_set_panid(value & 0xffff);
return RADIO_RESULT_OK;
case RADIO_PARAM_16BIT_ADDR:
rf230_set_short_addr(value & 0xffff);
return RADIO_RESULT_OK;
case RADIO_PARAM_RX_MODE:
if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_POLL_MODE |
RADIO_RX_MODE_AUTOACK)) {
return RADIO_RESULT_INVALID_VALUE;
}
set_frame_filtering((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0);
set_auto_ack((value & RADIO_RX_MODE_AUTOACK) != 0);
set_poll_mode((value & RADIO_RX_MODE_POLL_MODE) != 0);
return RADIO_RESULT_OK;
case RADIO_PARAM_TXPOWER:
if(value < TX_PWR_MIN || value > TX_PWR_MAX) {
return RADIO_RESULT_INVALID_VALUE;
}
rf230_set_txpower(value);
return RADIO_RESULT_OK;
case RADIO_PARAM_CCA_THRESHOLD:
/* set_cca_threshold(value); */
return RADIO_RESULT_OK;
default:
return RADIO_RESULT_NOT_SUPPORTED;
}
}
/*---------------------------------------------------------------------------*/
static radio_result_t
get_object(radio_param_t param, void *dest, size_t size)
{
if(param == RADIO_PARAM_LAST_PACKET_TIMESTAMP) {
if(size != sizeof(rtimer_clock_t) || !dest) {
return RADIO_RESULT_INVALID_VALUE;
}
*(rtimer_clock_t *)dest = rf230_last_rx_packet_timestamp;
return RADIO_RESULT_OK;
}
return RADIO_RESULT_NOT_SUPPORTED;
}
/*---------------------------------------------------------------------------*/
@ -347,7 +570,7 @@ hal_rx_frame_t rxframe[RF230_CONF_RX_BUFFERS];
* \retval STATE_TRANSITION The radio transceiver's state machine is in
* transition between two states.
*/
//static uint8_t
uint8_t
radio_get_trx_state(void)
{
@ -878,7 +1101,7 @@ void rf230_warm_reset(void) {
DDRB &= ~(1<<7);
#endif
hal_register_write(RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK);
hal_subregister_write(SR_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK);
/* Set up number of automatic retries 0-15
* (0 implies PLL_ON sends instead of the extended TX_ARET mode */
@ -1291,24 +1514,16 @@ rf230_listen_channel(uint8_t c)
radio_set_trx_state(RX_ON);
}
/*---------------------------------------------------------------------------*/
void
rf230_set_pan_addr(unsigned pan,
unsigned addr,
const uint8_t ieee_addr[8])
//rf230_set_pan_addr(uint16_t pan,uint16_t addr,uint8_t *ieee_addr)
{
PRINTF("rf230: PAN=%x Short Addr=%x\n",pan,addr);
uint8_t abyte;
abyte = pan & 0xFF;
hal_register_write(RG_PAN_ID_0,abyte);
abyte = (pan >> 8*1) & 0xFF;
hal_register_write(RG_PAN_ID_1, abyte);
abyte = addr & 0xFF;
hal_register_write(RG_SHORT_ADDR_0, abyte);
abyte = (addr >> 8*1) & 0xFF;
hal_register_write(RG_SHORT_ADDR_1, abyte);
rf230_set_panid(pan);
rf230_set_short_addr(addr);
if (ieee_addr != NULL) {
PRINTF("MAC=%x",*ieee_addr);
@ -1330,6 +1545,14 @@ rf230_set_pan_addr(unsigned pan,
PRINTF("\n");
}
}
/* From ISR context */
void
rf230_get_last_rx_packet_timestamp(void)
{
rf230_last_rx_packet_timestamp = RTIMER_NOW();
}
/*---------------------------------------------------------------------------*/
/*
* Interrupt leaves frame intact in FIFO.

View file

@ -215,6 +215,7 @@ void rf230_set_channel(uint8_t channel);
void rf230_listen_channel(uint8_t channel);
uint8_t rf230_get_channel(void);
void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t ieee_addr[8]);
unsigned rf230_get_panid(void);
void rf230_set_txpower(uint8_t power);
uint8_t rf230_get_txpower(void);
void rf230_set_rpc(uint8_t rpc);

View file

@ -55,6 +55,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ti-lib.h"
/*---------------------------------------------------------------------------*/
PROCESS_NAME(cetic_6lbr_client_process);
PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo");
@ -85,6 +87,13 @@ static struct etimer echo_request_timer;
int def_rt_rssi = 0;
#endif
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
PROCESS(adc_process, "ADC process");
static uint16_t single_adc_sample;
static struct etimer et_adc;
#endif
/*---------------------------------------------------------------------------*/
process_event_t cc26xx_web_demo_publish_event;
process_event_t cc26xx_web_demo_config_loaded_event;
process_event_t cc26xx_web_demo_load_config_defaults;
@ -111,6 +120,12 @@ DEMO_SENSOR(batmon_volt, CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT,
"Battery Volt", "battery-volt", "batmon_volt",
CC26XX_WEB_DEMO_UNIT_VOLT);
#if CC26XX_WEB_DEMO_ADC_DEMO
DEMO_SENSOR(adc_dio23, CC26XX_WEB_DEMO_SENSOR_ADC_DIO23,
"ADC DIO23", "adc-dio23", "adc_dio23",
CC26XX_WEB_DEMO_UNIT_VOLT);
#endif
/* Sensortag sensors */
#if BOARD_SENSORTAG
DEMO_SENSOR(bmp_pres, CC26XX_WEB_DEMO_SENSOR_BMP_PRES,
@ -467,6 +482,22 @@ get_batmon_reading(void *data)
ctimer_set(&batmon_timer, next, get_batmon_reading, NULL);
}
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
static void
get_adc_reading(void *data)
{
int value;
char *buf;
if(adc_dio23_reading.publish) {
value = single_adc_sample;
buf = adc_dio23_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", (value * 4300) >> 12);
}
}
#endif
/*---------------------------------------------------------------------------*/
#if BOARD_SENSORTAG
/*---------------------------------------------------------------------------*/
static void
@ -825,6 +856,11 @@ init_sensors(void)
list_add(sensor_list, &batmon_temp_reading);
list_add(sensor_list, &batmon_volt_reading);
#if CC26XX_WEB_DEMO_ADC_DEMO
list_add(sensor_list, &adc_dio23_reading);
#endif
SENSORS_ACTIVATE(batmon_sensor);
#if BOARD_SENSORTAG
@ -864,6 +900,7 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
/* Start all other (enabled) processes first */
process_start(&httpd_simple_process, NULL);
#if CC26XX_WEB_DEMO_COAP_SERVER
process_start(&coap_server_process, NULL);
#endif
@ -880,6 +917,10 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
process_start(&net_uart_process, NULL);
#endif
#if CC26XX_WEB_DEMO_ADC_DEMO
process_start(&adc_process, NULL);
#endif
/*
* Now that processes have set their own config default values, set our
* own defaults and restore saved config from flash...
@ -967,6 +1008,56 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
PROCESS_THREAD(adc_process, ev, data)
{
PROCESS_BEGIN();
etimer_set(&et_adc, CLOCK_SECOND * 5);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_adc));
/* intialisation of ADC */
ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP);
while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON));
/*
* Enable clock for ADC digital and analog interface (not currently enabled
* in driver)
*/
ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK |
AUX_WUC_SMPH_CLOCK);
while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK |
AUX_WUC_SMPH_CLOCK)
!= AUX_WUC_CLOCK_READY);
/* Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input. */
ti_lib_aux_adc_select_input(ADC_COMPB_IN_AUXIO7);
/* Set up ADC range, AUXADC_REF_FIXED = nominally 4.3 V */
ti_lib_aux_adc_enable_sync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_2P7_US,
AUXADC_TRIGGER_MANUAL);
/* Trigger ADC converting */
ti_lib_aux_adc_gen_manual_trigger();
/* Read value */
single_adc_sample = ti_lib_aux_adc_read_fifo();
/* Shut the adc down */
ti_lib_aux_adc_disable();
get_adc_reading(NULL);
etimer_reset(&et_adc);
}
PROCESS_END();
}
#endif
/*---------------------------------------------------------------------------*/
/**
* @}
*/

View file

@ -79,6 +79,12 @@
#else
#define CC26XX_WEB_DEMO_NET_UART 1
#endif
#ifdef CC26XX_WEB_DEMO_CONF_ADC_DEMO
#define CC26XX_WEB_DEMO_ADC_DEMO CC26XX_WEB_DEMO_CONF_ADC_DEMO
#else
#define CC26XX_WEB_DEMO_ADC_DEMO 0
#endif
/*---------------------------------------------------------------------------*/
/* Active probing of RSSI from our preferred parent */
#if (CC26XX_WEB_DEMO_COAP_SERVER || CC26XX_WEB_DEMO_MQTT_CLIENT)
@ -146,6 +152,7 @@
#define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_X 12
#define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Y 13
#define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Z 14
#define CC26XX_WEB_DEMO_SENSOR_ADC_DIO23 15
/*---------------------------------------------------------------------------*/
extern process_event_t cc26xx_web_demo_publish_event;
extern process_event_t cc26xx_web_demo_config_loaded_event;

View file

@ -40,6 +40,7 @@
#include "rest-engine.h"
#include "board-peripherals.h"
#include "rf-core/rf-ble.h"
#include "cc26xx-web-demo.h"
#include <stdio.h>
#include <stdlib.h>
@ -85,6 +86,10 @@ extern resource_t res_mpu_gyro_z;
extern resource_t res_toggle_orange;
extern resource_t res_toggle_yellow;
#endif
#if CC26XX_WEB_DEMO_ADC_DEMO
extern resource_t res_adc_dio23;
#endif
/*---------------------------------------------------------------------------*/
const char *coap_server_not_found_msg = "Resource not found";
const char *coap_server_supported_msg = "Supported:"
@ -134,6 +139,10 @@ PROCESS_THREAD(coap_server_process, ev, data)
rest_activate_resource(&res_batmon_temp, "sen/batmon/temp");
rest_activate_resource(&res_batmon_volt, "sen/batmon/voltage");
#if CC26XX_WEB_DEMO_ADC_DEMO
rest_activate_resource(&res_adc_dio23, "sen/adc/dio23");
#endif
rest_activate_resource(&res_device_hw, "dev/mdl/hw");
rest_activate_resource(&res_device_sw, "dev/mdl/sw");
rest_activate_resource(&res_device_uptime, "dev/uptime");

View file

@ -1268,9 +1268,7 @@ appcall(void *state)
if(uip_closed() || uip_aborted() || uip_timedout()) {
if(s != NULL) {
s->script = NULL;
s->blen = 0;
s->tmp_buf_len = 0;
memset(s, 0, sizeof(struct httpd_state));
memb_free(&conns, s);
}
} else if(uip_connected()) {
@ -1291,7 +1289,7 @@ appcall(void *state)
if(uip_poll()) {
if(timer_expired(&s->timer)) {
uip_abort();
s->script = NULL;
memset(s, 0, sizeof(struct httpd_state));
memb_free(&conns, s);
}
} else {

View file

@ -698,10 +698,15 @@ static void
connect_to_broker(void)
{
/* Connect to MQTT server */
mqtt_connect(&conn, conf->broker_ip, conf->broker_port,
mqtt_status_t conn_attempt_result = mqtt_connect(&conn, conf->broker_ip,
conf->broker_port,
conf->pub_interval * 3);
if(conn_attempt_result == MQTT_STATUS_OK) {
state = MQTT_CLIENT_STATE_CONNECTING;
} else {
state = MQTT_CLIENT_STATE_CONFIG_ERROR;
}
}
/*---------------------------------------------------------------------------*/
static void
@ -827,8 +832,8 @@ state_machine(void)
}
break;
case MQTT_CLIENT_STATE_NEWCONFIG:
/* Only update config after we have disconnected */
if(conn.state == MQTT_CONN_STATE_NOT_CONNECTED) {
/* Only update config after we have disconnected or in the case of an error */
if(conn.state == MQTT_CONN_STATE_NOT_CONNECTED || conn.state == MQTT_CONN_STATE_ERROR) {
update_config();
DBG("New config\n");

View file

@ -41,6 +41,13 @@
#define CC26XX_WEB_DEMO_CONF_6LBR_CLIENT 1
#define CC26XX_WEB_DEMO_CONF_COAP_SERVER 1
#define CC26XX_WEB_DEMO_CONF_NET_UART 1
/*
* ADC sensor functionality. To test this, an external voltage source should be
* connected to DIO23
* Enable/Disable DIO23 ADC reading by setting CC26XX_WEB_DEMO_CONF_ADC_DEMO
*/
#define CC26XX_WEB_DEMO_CONF_ADC_DEMO 0
/*---------------------------------------------------------------------------*/
/* Enable the ROM bootloader */
#define ROM_BOOTLOADER_ENABLE 1

View file

@ -117,6 +117,21 @@ RESOURCE(res_batmon_temp, "title=\"Battery Temp\";rt=\"C\"",
RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"",
res_get_handler_batmon_volt, NULL, NULL, NULL);
/*---------------------------------------------------------------------------*/
#if CC26XX_WEB_DEMO_ADC_DEMO
/*---------------------------------------------------------------------------*/
static void
res_get_handler_adc_dio23(void *request, void *response, uint8_t *buffer,
uint16_t preferred_size, int32_t *offset)
{
res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_ADC_DIO23, request, response,
buffer, preferred_size, offset);
}
/*---------------------------------------------------------------------------*/
RESOURCE(res_adc_dio23, "title=\"ADC DIO23\";rt=\"mV\"",
res_get_handler_adc_dio23, NULL, NULL, NULL);
/*---------------------------------------------------------------------------*/
#endif
/*---------------------------------------------------------------------------*/
#if BOARD_SENSORTAG
/*---------------------------------------------------------------------------*/
/* MPU resources and handler: Accelerometer and Gyro */

View file

@ -49,6 +49,7 @@ The following radios have been tested:
* CC2538
* CC2530/CC2531
* CC1200
* RF233
Once you have the radio sorted out, you also need to configure character I/O.
The firmware captures wireless frames and streams them over a serial line to

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef AVR_RSS2_IO_H_
#define AVR_RSS2_IO_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/rs232.h"
#define sensniff_io_byte_out(b) rs232_send(0, b)
#define sensniff_io_flush()
#define sensniff_io_set_input(b) rs232_set_input(RS232_PORT_0, b)
/*---------------------------------------------------------------------------*/
#endif /* AVR_RSS2_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "avr-rss2/avr-rss2-io.h"
#define RS232_BAUDRATE USART_BAUD_500000
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -108,16 +108,9 @@ Tested applications and examples
* `rime`
* `ipv6/multicast`
* `examples/powertrace`
* `examples/sensniff` use 500kBAUD
* `example-shell`
Note that the shell example needs file `symbols.c` to be added to project also seems like
in `core/dev/serial-line.c` the function `process_poll` must be replaced with `process_post`:
/* Wake up consumer process */
- process_poll(&serial_line_process);
+ process_post(&serial_line_process, 0, 0);
Platform tutorial applications
-----------------------------
Example to read out various sensors, leds, serial numbers, and so on:

View file

@ -1,11 +0,0 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += stub-rdc.c
CONTIKI_PROJECT = sniffer
all: $(CONTIKI_PROJECT)
CONTIKI = ../../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View file

@ -1,29 +0,0 @@
Sniffer application mote side
=============================
This put the radio in sniff mode and should capure all traffic used
on the set channel.
Default channel
---------------
26
Bulld
-----
make TARGET=avr-rss2
Default serial port speed
-------------------------
38400 bps
More info & uasage
------------------
Look in the host directory
Contiki support
---------------
The code promisc for support is needed. This also adds the sensniff
format.
References
----------
https://github.com/g-oikonomou/sensniff

View file

@ -1,51 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Project specific configuration defines for the sniffer example.
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
* Robert Olsson - <robert@radio.sensors.com>
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define NETSTACK_CONF_MAC nullmac_driver
/* Can see other channels. Interesting. */
/* #define NETSTACK_CONF_MAC csma_driver */
#define NETSTACK_CONF_RDC stub_rdc_driver
#endif /* PROJECT_CONF_H_ */

View file

@ -1,67 +0,0 @@
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/*
Author: Robert Olsson <robert@radio-sensors.com>
*/
#include "contiki.h"
#include "net/rime/rime.h"
#include "random.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(sniffer_process, "Sniffer process");
AUTOSTART_PROCESSES(&sniffer_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sniffer_process, ev, data)
{
PROCESS_BEGIN();
/*
To get rf230bb radio in sniff mode we need to have radio in RX_ON.
The promisc commands fixes this for us. No need to set PAN and
address or MAC to zero is this case. Se Atmel datasheet. There is
a chance other radios works the same way.
*/
rf230_set_promiscuous_mode(1);
printf("Sniffer started\n");
while(1) {
PROCESS_YIELD();
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View file

@ -1,100 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Definition of a fake RDC driver to be used with passive
* examples. The sniffer will never send packets and it will never
* push incoming packets up the stack. We do this by defining this
* driver as our RDC. We then drop everything
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include "net/mac/mac.h"
#include "net/mac/rdc.h"
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *list)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
input(void)
{
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static int
off(int keep_radio_on)
{
return keep_radio_on;
}
/*---------------------------------------------------------------------------*/
static unsigned short
cca(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
}
/*---------------------------------------------------------------------------*/
const struct rdc_driver stub_rdc_driver = {
"stub-rdc",
init,
send,
send_list,
input,
on,
off,
cca,
};
/*---------------------------------------------------------------------------*/

View file

@ -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
@ -110,6 +106,11 @@ void clock_adjust_ticks(clock_time_t howmany);
#define AVR_CONF_USE32KCRYSTAL 1
#define SLIP_PORT RS232_PORT_0
/* Default baud rare on RS232 port */
#ifndef RS232_BAUDRATE
#define RS232_BAUDRATE USART_BAUD_38400
#endif
/* Pre-allocated memory for loadable modules heap space (in bytes)*/
/* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
/* #define MMEM_CONF_SIZE 256 */
@ -164,6 +165,16 @@ typedef unsigned short uip_stats_t;
#define RDC_CONF_MCU_SLEEP 1
#if NETSTACK_CONF_WITH_IPV6
#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#endif
#ifndef UIP_CONF_MAX_ROUTES
#define UIP_CONF_MAX_ROUTES 20
#endif
#ifndef UIP_CONF_BUFFER_SIZE
#define UIP_CONF_BUFFER_SIZE 1280
#endif
#define LINKADDR_CONF_SIZE 8
#define UIP_CONF_ICMP6 1
#define UIP_CONF_UDP 1
@ -229,16 +240,15 @@ typedef unsigned short uip_stats_t;
/* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
/* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */
/* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */
#define UIP_CONF_MAX_CONNECTIONS 4
/* 2 bytes per TCP listening port */
#define UIP_CONF_MAX_LISTENPORTS 4
/* 25 bytes per UDP connection */
#define UIP_CONF_UDP_CONNS 10
/* See uip-ds6.h */
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_MAX_ROUTES 20
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0
#define UIP_CONF_DS6_AADDR_NBU 0
@ -270,10 +280,8 @@ typedef unsigned short uip_stats_t;
#define UIP_CONF_MAX_CONNECTIONS 2
#define UIP_CONF_MAX_LISTENPORTS 4
#define UIP_CONF_UDP_CONNS 5
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_MAX_ROUTES 4
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0
#define UIP_CONF_DS6_AADDR_NBU 0
@ -299,10 +307,8 @@ typedef unsigned short uip_stats_t;
#define UIP_CONF_MAX_CONNECTIONS 2
#define UIP_CONF_MAX_LISTENPORTS 4
#define UIP_CONF_UDP_CONNS 5
#define NBR_TABLE_CONF_MAX_NEIGHBORS 4
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_MAX_ROUTES 4
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0
#define UIP_CONF_DS6_AADDR_NBU 0
@ -332,7 +338,6 @@ typedef unsigned short uip_stats_t;
/* For slow slip connections, to prevent buffer overruns */
/* #define UIP_CONF_RECEIVE_WINDOW 300 */
#undef UIP_CONF_FWCACHE_SIZE
#define UIP_CONF_BUFFER_SIZE 600 /* DHCPv4 packets by ip64 module */
#define UIP_CONF_FWCACHE_SIZE 30
#define UIP_CONF_BROADCAST 1
#define UIP_ARCH_IPCHKSUM 1

View file

@ -186,9 +186,8 @@ initialize(void)
watchdog_init();
watchdog_start();
leds_init();
serial_line_init();
rs232_init(RS232_PORT_0, USART_BAUD_38400, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
rs232_init(RS232_PORT_0, RS232_BAUDRATE, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
rs232_redirect_stdout(RS232_PORT_0);
#if 0
@ -198,8 +197,6 @@ initialize(void)
//UBRR0L = 3; UBRR0H = 0; UCSR0A = (1 << U2X0); // 500k 0%
#endif
rs232_set_input(RS232_PORT_0, serial_line_input_byte);
clock_init();
if(MCUSR & (1 << PORF)) {
@ -271,6 +268,10 @@ initialize(void)
process_start(&etimer_process, NULL);
ctimer_init();
/* After process start */
serial_line_init();
rs232_set_input(RS232_PORT_0, serial_line_input_byte);
/* Start radio and radio receive process */
NETSTACK_RADIO.init();
@ -314,8 +315,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 +350,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, MAC=%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 +360,6 @@ initialize(void)
#if UIP_CONF_ROUTER
PRINTA("Routing Enabled\n");
#endif
#endif /* ANNOUNCE_BOOT */
#if NETSTACK_CONF_WITH_IPV6 || NETSTACK_CONF_WITH_IPV4

View file

@ -33,6 +33,12 @@ leds_off(unsigned char ledv)
void
leds_toggle(unsigned char ledv)
{
if(ledv & LEDS_YELLOW) {
PORTE ^= (1 << LED_YELLOW);
}
if(ledv & LEDS_RED) {
PORTE ^= (1 << LED_RED);
}
}
void
leds_invert(unsigned char ledv)

View file

@ -137,8 +137,12 @@
* Those values are not meant to be modified by the user
* @{
*/
#define BOARD_IOID_SPI_SCK IOID_17
#define BOARD_IOID_SPI_MOSI IOID_19
#define BOARD_IOID_SPI_MISO IOID_18
#define BOARD_SPI_SCK (1 << BOARD_IOID_SPI_SCK)
#define BOARD_SPI_MOSI (1 << BOARD_IOID_SPI_MOSI)
#define BOARD_SPI_MISO (1 << BOARD_IOID_SPI_MISO)
/** @} */
/*---------------------------------------------------------------------------*/
/**

View file

@ -186,7 +186,7 @@ static void
convert(float *temp, float *hum)
{
/* Convert temperature to degrees C */
*temp = ((double)(int16_t)raw_temp / 65536) * 165 - 40;
*temp = ((double)raw_temp / 65536) * 165 - 40;
/* Convert relative humidity to a %RH value */
*hum = ((double)raw_hum / 65536) * 100;