Add status page link, show correct rssi, fix indexing off array in ipv4 builds

This commit is contained in:
dak664 2010-12-04 21:32:35 +00:00
parent a5cbd0cd94
commit 35b2ce0cdb
7 changed files with 56 additions and 16 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: rf230bb.c,v 1.15 2010/12/03 20:42:01 dak664 Exp $
* @(#)$Id: rf230bb.c,v 1.16 2010/12/04 21:32:35 dak664 Exp $
*/
/*
* This code is almost device independent and should be easy to port.
@ -123,7 +123,6 @@ struct timestamp {
#define RADIOSTATS 1
#endif
#if RADIOSTATS
uint8_t RF230_rsigsi;
uint16_t RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail;
#endif
@ -809,6 +808,9 @@ rf230_send(const void *payload, unsigned short payload_len)
ret = rf230_transmit(payload_len);
bail:
#if RADIOSTATS
if (ret) RF230_sendfail++;
#endif
return ret;
}
/*---------------------------------------------------------------------------*/
@ -968,7 +970,7 @@ if (RF230_receive_on) {
* It calls the core MAC layer which calls rf230_read to get the packet
* rf230processflag can be printed in the main idle loop for debugging
*/
#if 1
#if 0
uint8_t rf230processflag;
#define RF230PROCESSFLAG(arg) rf230processflag=arg
#else
@ -1003,6 +1005,10 @@ PROCESS_THREAD(rf230_process, ev, data)
&rf230_timetable);
timetable_clear(&rf230_timetable);
#endif /* RF230_TIMETABLE_PROFILING */
} else {
#if RADIOSTATS
RF230_receivefail++;
#endif
}
}

View file

@ -3,8 +3,6 @@
* compile. Allows you to save needing to compile all of uIP in just
* to get a few things. This file is included in the build by the contiki
* Makefile.include only when CONTIKI_NO_NET is defined */
//#if CONTIKI_NO_NET
#include "uip.h"
#include <string.h>
@ -132,4 +130,3 @@ uip_icmp6chksum(void)
{
return upper_layer_chksum(UIP_PROTO_ICMP6);
}
//#endif /* CONTIKI_NO_NET */

View file

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd-cgi.c,v 1.9 2010/12/02 15:37:13 dak664 Exp $
* $Id: httpd-cgi.c,v 1.10 2010/12/04 21:32:35 dak664 Exp $
*
*/
@ -112,7 +112,7 @@ static const char *states[] = {
extern unsigned long seconds;
#if RADIOSTATS
extern unsigned long radioontime;
extern uint8_t RF230_radio_on, RF230_rsigsi;
extern uint8_t RF230_radio_on, rf230_last_rssi;
extern uint16_t RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail;
#endif
@ -434,7 +434,7 @@ generate_radio_stats(void *arg)
uint16_t h,m,s;
uint8_t p1,p2;
static const char httpd_cgi_sensor4[] HTTPD_STRING_ATTR = "<em>Radio on:</em> %02d:%02d:%02d (%d.%02d%%)<br>";
static const char httpd_cgi_sensor5[] HTTPD_STRING_ATTR = "<em>Packets:</em> Tx=%5d Rx=%5d TxL=%5d RxL=%5d RSSI=%2d\n";
static const char httpd_cgi_sensor5[] HTTPD_STRING_ATTR = "<em>Packets:</em> Tx=%5d Rx=%5d TxL=%5d RxL=%5d RSSI=%2ddBm\n";
s=(10000UL*radioontime)/seconds;
p1=s/100;
@ -445,9 +445,18 @@ generate_radio_stats(void *arg)
s=s-m*60;
numprinted =httpd_snprintf((char *)uip_appdata , uip_mss() , httpd_cgi_sensor4,\
h,m,s,p1,p2);
h,m,s,p1,p2);
#if RF230BB
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor5,\
RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail,RF230_rsigsi);
RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail,-92+rf230_last_rssi);
#else
p1=0;
radio_get_rssi_value(&p1);
p1 = -91*3(p1-1);
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor5,\
RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail,p1);
#endif
return numprinted;
}

View file

@ -2,5 +2,5 @@
<html><head><title>Welcome to the Contiki-demo server!</title>
<link rel="stylesheet" type="text/css" href="/style.css"><link rel="icon" href="favicon.png" type="image/png">
</head><body bgcolor="#fffeec" text="black">
<div class="menublock"><div class="menu"><p class="border-title">Menu</p><p class="menu"><a href="/">Front page</a><br><a href="files.shtml">File statistics</a><br><a href="tcp.shtml">Network connections</a><br><a href="processes.shtml">System processes</a><br><a href="sensor.shtml">Sensor Readings</a></p></div></div>
<div class="menublock"><div class="menu"><p class="border-title">Menu</p><p class="menu"><a href="/">Front page</a><br><a href="status.shtml">Status</a><br><a href="files.shtml">File statistics</a><br><a href="tcp.shtml">Network connections</a><br><a href="processes.shtml">System processes</a><br><a href="sensor.shtml">Sensor Readings</a></p></div></div>
<div class="contentblock"><p class="border-title">Welcome to the <a href="http://www.sics.se/contiki/">Contiki</a> web server!</p>

View file

@ -5,6 +5,7 @@
%! neighbors
<h4>Routes</h4>
%! routes
<h4>Sensors</h4>
%! sensors
</table>
%! file-stats .

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: httpd-simple-avr.c,v 1.7 2010/12/03 20:42:02 dak664 Exp $
* $Id: httpd-simple-avr.c,v 1.8 2010/12/04 21:32:35 dak664 Exp $
*/
/**
@ -176,7 +176,6 @@ PT_THREAD(handle_input(struct httpd_state *s))
}
#if URLCONV
bomb
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename));
#else /* URLCONV */
@ -300,6 +299,10 @@ PT_THREAD(generate_routes(struct httpd_state *s))
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0;
}
#else /* UIP_CONF_IPV6 */
blen = 0;i++;
ADD("<h2>Hey, you got ip4 working!</h2>");
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
#endif /* UIP_CONF_IPV6 */
PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, BOTTOM);

View file

@ -381,6 +381,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
/* Simple Address Translation */
if(memcmp((uint8_t *)&simple_trans_ethernet_addr, &(((struct uip_eth_hdr *) ethHeader)->dest.addr[0]), 6) == 0) {
#if UIP_CONF_IPV6
//Addressed to us: make 802.15.4 address from IPv6 Address
destAddr.addr[0] = UIP_IP_BUF->destipaddr.u8[8] ^ 0x02;
destAddr.addr[1] = UIP_IP_BUF->destipaddr.u8[9];
@ -390,6 +391,18 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
destAddr.addr[5] = UIP_IP_BUF->destipaddr.u8[13];
destAddr.addr[6] = UIP_IP_BUF->destipaddr.u8[14];
destAddr.addr[7] = UIP_IP_BUF->destipaddr.u8[15];
#else
//Not intended to be functional, but allows ip4 build without errors.
destAddr.addr[0] = UIP_IP_BUF->destipaddr.u8[0] ^ 0x02;
destAddr.addr[1] = UIP_IP_BUF->destipaddr.u8[1];
destAddr.addr[2] = UIP_IP_BUF->destipaddr.u8[2];
destAddr.addr[3] = UIP_IP_BUF->destipaddr.u8[3];
destAddr.addr[4] = UIP_IP_BUF->destipaddr.u8[0];
destAddr.addr[5] = UIP_IP_BUF->destipaddr.u8[1];
destAddr.addr[6] = UIP_IP_BUF->destipaddr.u8[2];
destAddr.addr[7] = UIP_IP_BUF->destipaddr.u8[3];
#endif
destAddrPtr = &destAddr;
}
@ -414,7 +427,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
}
PRINTF(" translated OK\n\r");
destAddrPtr = &destAddr;
#endif
#endif /* UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS */
}
@ -439,6 +452,8 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);
tcpip_input();
#else
// PRINTF("Input from %x %x %x %x %x %x %x %x\n",UIP_IP_BUF->srcipaddr.u8[0],UIP_IP_BUF->srcipaddr.u8[1],UIP_IP_BUF->srcipaddr.u8[2],UIP_IP_BUF->srcipaddr.u8[3],UIP_IP_BUF->srcipaddr.u8[4],UIP_IP_BUF->srcipaddr.u8[5],UIP_IP_BUF->srcipaddr.u8[6],UIP_IP_BUF->srcipaddr.u8[7]);
// PRINTF("Output to %x %x %x %x %x %x %x %x\n",destAddr.addr[0],destAddr.addr[1],destAddr.addr[2],destAddr.addr[3],destAddr.addr[4],destAddr.addr[5],destAddr.addr[6],destAddr.addr[7]);
tcpip_output(destAddrPtr);
#endif
#else /* UIP_CONF_IPV6 */
@ -477,10 +492,19 @@ void mac_LowpanToEthernet(void)
#endif
ETHBUF(uip_buf)->dest.addr[0] = 0x33;
ETHBUF(uip_buf)->dest.addr[1] = 0x33;
#if UIP_CONF_IPV6
ETHBUF(uip_buf)->dest.addr[2] = UIP_IP_BUF->destipaddr.u8[12];
ETHBUF(uip_buf)->dest.addr[3] = UIP_IP_BUF->destipaddr.u8[13];
ETHBUF(uip_buf)->dest.addr[4] = UIP_IP_BUF->destipaddr.u8[14];
ETHBUF(uip_buf)->dest.addr[5] = UIP_IP_BUF->destipaddr.u8[15];
#else
//Not intended to be functional, but allows ip4 build without errors.
ETHBUF(uip_buf)->dest.addr[2] = UIP_IP_BUF->destipaddr.u8[0];
ETHBUF(uip_buf)->dest.addr[3] = UIP_IP_BUF->destipaddr.u8[1];
ETHBUF(uip_buf)->dest.addr[4] = UIP_IP_BUF->destipaddr.u8[2];
ETHBUF(uip_buf)->dest.addr[5] = UIP_IP_BUF->destipaddr.u8[3];
#endif
} else {
//Otherwise we have a real address
mac_createEthernetAddr((uint8_t *) &(ETHBUF(uip_buf)->dest.addr[0]),