Enable radio stats in sensor cgi as default
This commit is contained in:
parent
844b3a34f7
commit
5debc183a9
@ -6,12 +6,14 @@
|
|||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
/* Experimental: RADIOSTATS should be also be defined in the radio driver and webserver */
|
/* RADIOSTATS should be also be defined in the radio driver and webserver */
|
||||||
#define RADIOSTATS 0
|
#if RF230BB && WEBSERVER
|
||||||
|
#define RADIOSTATS 1
|
||||||
|
#endif
|
||||||
#if RADIOSTATS
|
#if RADIOSTATS
|
||||||
static volatile clock_time_t count, scount, rcount;
|
static volatile clock_time_t count, scount, rcount;
|
||||||
volatile unsigned long seconds,radioontime;
|
volatile unsigned long seconds,radioontime;
|
||||||
extern uint8_t RF230_radio_on;
|
extern uint8_t RF230_receive_on;
|
||||||
#else
|
#else
|
||||||
static volatile clock_time_t count, scount;
|
static volatile clock_time_t count, scount;
|
||||||
volatile unsigned long seconds;
|
volatile unsigned long seconds;
|
||||||
@ -27,7 +29,7 @@ ISR(AVR_OUTPUT_COMPARE_INT)
|
|||||||
seconds++;
|
seconds++;
|
||||||
}
|
}
|
||||||
#if RADIOSTATS
|
#if RADIOSTATS
|
||||||
if (RF230_radio_on) {
|
if (RF230_receive_on) {
|
||||||
if (++rcount == CLOCK_SECOND) {
|
if (++rcount == CLOCK_SECOND) {
|
||||||
rcount=0;
|
rcount=0;
|
||||||
radioontime++;
|
radioontime++;
|
||||||
|
@ -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.6 2010/02/23 17:37:51 dak664 Exp $
|
* @(#)$Id: rf230bb.c,v 1.7 2010/02/26 21:38:58 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.
|
||||||
@ -119,7 +119,14 @@ struct timestamp {
|
|||||||
//#define PRINTSHORT(...) printf(__VA_ARGS__)
|
//#define PRINTSHORT(...) printf(__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//void rf230_arch_init(void);
|
/* See clock.c and httpd-cgi.c for RADIOSTATS code */
|
||||||
|
#if WEBSERVER
|
||||||
|
#define RADIOSTATS 1
|
||||||
|
#endif
|
||||||
|
#if RADIOSTATS
|
||||||
|
uint8_t RF230_rsigsi;
|
||||||
|
uint16_t RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* XXX hack: these will be made as Chameleon packet attributes */
|
/* XXX hack: these will be made as Chameleon packet attributes */
|
||||||
rtimer_clock_t rf230_time_of_arrival, rf230_time_of_departure;
|
rtimer_clock_t rf230_time_of_arrival, rf230_time_of_departure;
|
||||||
@ -185,7 +192,7 @@ const struct radio_driver rf230_driver =
|
|||||||
rf230_off,
|
rf230_off,
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t receive_on;
|
uint8_t RF230_receive_on;
|
||||||
static int channel;
|
static int channel;
|
||||||
|
|
||||||
/* Received frames are buffered to rxframe in the interrupt routine in hal.c */
|
/* Received frames are buffered to rxframe in the interrupt routine in hal.c */
|
||||||
@ -436,7 +443,7 @@ on(void)
|
|||||||
// PRINTF("on\n");
|
// PRINTF("on\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
receive_on = 1;
|
RF230_receive_on = 1;
|
||||||
|
|
||||||
hal_set_slptr_low();
|
hal_set_slptr_low();
|
||||||
//radio_is_waking=1;//can test this before tx instead of delaying
|
//radio_is_waking=1;//can test this before tx instead of delaying
|
||||||
@ -453,7 +460,7 @@ on(void)
|
|||||||
static void
|
static void
|
||||||
off(void)
|
off(void)
|
||||||
{
|
{
|
||||||
receive_on = 0;
|
RF230_receive_on = 0;
|
||||||
|
|
||||||
#if JACKDAW
|
#if JACKDAW
|
||||||
Led2_off();
|
Led2_off();
|
||||||
@ -607,11 +614,15 @@ rf230_transmit(unsigned short payload_len)
|
|||||||
hal_set_slptr_low();
|
hal_set_slptr_low();
|
||||||
hal_frame_write(buffer, total_len);
|
hal_frame_write(buffer, total_len);
|
||||||
|
|
||||||
if(receive_on) {
|
if(RF230_receive_on) {
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
||||||
}
|
}
|
||||||
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
|
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
|
||||||
|
|
||||||
|
#if RADIOSTATS
|
||||||
|
RF230_sendpackets++;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We wait until transmission has ended so that we get an
|
/* We wait until transmission has ended so that we get an
|
||||||
accurate measurement of the transmission time.*/
|
accurate measurement of the transmission time.*/
|
||||||
rf230_waitidle();
|
rf230_waitidle();
|
||||||
@ -638,7 +649,7 @@ rf230_transmit(unsigned short payload_len)
|
|||||||
ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT,rf230_get_txpower());
|
ENERGEST_OFF_LEVEL(ENERGEST_TYPE_TRANSMIT,rf230_get_txpower());
|
||||||
#endif
|
#endif
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
|
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
|
||||||
if(receive_on) {
|
if(RF230_receive_on) {
|
||||||
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
||||||
} else {
|
} else {
|
||||||
/* We need to explicitly turn off the radio,
|
/* We need to explicitly turn off the radio,
|
||||||
@ -694,7 +705,7 @@ rf230_prepare(const void *payload, unsigned short payload_len)
|
|||||||
total_len = payload_len + AUX_LEN;
|
total_len = payload_len + AUX_LEN;
|
||||||
if (total_len > RF230_MAX_TX_FRAME_LENGTH){
|
if (total_len > RF230_MAX_TX_FRAME_LENGTH){
|
||||||
#if RADIOSTATS
|
#if RADIOSTATS
|
||||||
rf230_sendfail++;
|
RF230_sendfail++;
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -780,7 +791,7 @@ int
|
|||||||
rf230_off(void)
|
rf230_off(void)
|
||||||
{
|
{
|
||||||
/* Don't do anything if we are already turned off. */
|
/* Don't do anything if we are already turned off. */
|
||||||
if(receive_on == 0) {
|
if(RF230_receive_on == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,7 +819,7 @@ rf230_off(void)
|
|||||||
int
|
int
|
||||||
rf230_on(void)
|
rf230_on(void)
|
||||||
{
|
{
|
||||||
if(receive_on) {
|
if(RF230_receive_on) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(locked) {
|
if(locked) {
|
||||||
@ -906,7 +917,10 @@ rf230_interrupt(void)
|
|||||||
#endif /* RF230_TIMETABLE_PROFILING */
|
#endif /* RF230_TIMETABLE_PROFILING */
|
||||||
|
|
||||||
pending = 1;
|
pending = 1;
|
||||||
|
|
||||||
|
#if RADIOSTATS
|
||||||
|
RF230_receivepackets++;
|
||||||
|
#endif
|
||||||
rf230_packets_seen++;
|
rf230_packets_seen++;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -930,8 +944,6 @@ PROCESS_THREAD(rf230_process, ev, data)
|
|||||||
TIMETABLE_TIMESTAMP(rf230_timetable, "poll");
|
TIMETABLE_TIMESTAMP(rf230_timetable, "poll");
|
||||||
#endif /* RF230_TIMETABLE_PROFILING */
|
#endif /* RF230_TIMETABLE_PROFILING */
|
||||||
|
|
||||||
pending = 0;
|
|
||||||
|
|
||||||
// PRINTF("rf230_process: callback\n");
|
// PRINTF("rf230_process: callback\n");
|
||||||
|
|
||||||
packetbuf_clear();
|
packetbuf_clear();
|
||||||
@ -967,6 +979,8 @@ rf230_read(void *buf, unsigned short bufsize)
|
|||||||
struct timestamp t;
|
struct timestamp t;
|
||||||
#endif /* RF230_CONF_TIMESTAMPS */
|
#endif /* RF230_CONF_TIMESTAMPS */
|
||||||
|
|
||||||
|
pending = 0;
|
||||||
|
|
||||||
len=rxframe.length;
|
len=rxframe.length;
|
||||||
if (len==0) {
|
if (len==0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1157,7 +1171,7 @@ rf230_rssi(void)
|
|||||||
int radio_was_off = 0;
|
int radio_was_off = 0;
|
||||||
|
|
||||||
/*The RSSI measurement should only be done in RX_ON or BUSY_RX.*/
|
/*The RSSI measurement should only be done in RX_ON or BUSY_RX.*/
|
||||||
if(!receive_on) {
|
if(!RF230_receive_on) {
|
||||||
radio_was_off = 1;
|
radio_was_off = 1;
|
||||||
rf230_on();
|
rf230_on();
|
||||||
}
|
}
|
||||||
@ -1184,7 +1198,7 @@ rf230_cca(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!receive_on) {
|
if(!RF230_receive_on) {
|
||||||
radio_was_off = 1;
|
radio_was_off = 1;
|
||||||
rf230_on();
|
rf230_on();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the uIP TCP/IP stack.
|
* This file is part of the uIP TCP/IP stack.
|
||||||
*
|
*
|
||||||
* $Id: httpd-cgi.c,v 1.6 2010/02/12 16:42:59 dak664 Exp $
|
* $Id: httpd-cgi.c,v 1.7 2010/02/26 21:38:58 dak664 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -62,7 +62,9 @@ extern char TCPBUF[512];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* RADIOSTATS must also be set in clock.c and the radio driver */
|
/* RADIOSTATS must also be set in clock.c and the radio driver */
|
||||||
#define RADIOSTATS 0
|
#if RF230BB
|
||||||
|
#define RADIOSTATS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct httpd_cgi_call *calls = NULL;
|
static struct httpd_cgi_call *calls = NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user