diff --git a/examples/sky-ip/ajax-cgi.c b/examples/sky-ip/ajax-cgi.c index ed11e5ad2..e7e4b793a 100644 --- a/examples/sky-ip/ajax-cgi.c +++ b/examples/sky-ip/ajax-cgi.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: ajax-cgi.c,v 1.2 2008/11/06 08:24:20 adamdunkels Exp $ + * $Id: ajax-cgi.c,v 1.3 2009/05/11 17:38:29 adamdunkels Exp $ * */ @@ -101,8 +101,10 @@ httpd_cgi_add(struct httpd_cgi_call *c) } } /*---------------------------------------------------------------------------*/ +#if CONTIKI_TARGET_SKY #include "dev/sht11.h" #include "dev/light.h" +#endif /* CONTIKI_TARGET_SKY */ static PT_THREAD(sensorscall(struct httpd_state *s, char *ptr)) @@ -116,23 +118,32 @@ PT_THREAD(sensorscall(struct httpd_state *s, char *ptr)) timer_set(&t, CLOCK_SECOND); i = 0; - while(1) { - timer_restart(&t); - PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t)); + /* while(1)*/ { + /* timer_restart(&t); + PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));*/ +#if CONTIKI_TARGET_SKY snprintf(buf, sizeof(buf), - "", + "t(%d);h(%d);l1(%d);l2(%d);", sht11_temp(), sht11_humidity(), sensors_light1(), sensors_light2()); +#else /* CONTIKI_TARGET_SKY */ + snprintf(buf, sizeof(buf), + "t(%d);h(%d);l1(%d);l2(%d);", + 0, + 0, + 0, + 0); +#endif /* CONTIKI_TARGET_SKY */ PSOCK_SEND_STR(&s->sout, buf); - timer_restart(&t); - PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t)); + /* timer_restart(&t); + PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));*/ snprintf(buf, sizeof(buf), - "", + "p(%lu,%lu,%lu,%lu);i(%d);", energest_type_time(ENERGEST_TYPE_CPU) - last_cpu, energest_type_time(ENERGEST_TYPE_LPM) - last_lpm, energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit, @@ -170,6 +181,8 @@ PT_THREAD(neighborscall(struct httpd_state *s, char *ptr)) { PSOCK_BEGIN(&s->sout); + announcement_listen(1); + /* printf("neighbor_num %d\n", neighbor_num());*/ for(s->u.count = 0; s->u.count < neighbor_num(); s->u.count++) { @@ -185,8 +198,8 @@ PT_THREAD(neighborscall(struct httpd_state *s, char *ptr)) /*---------------------------------------------------------------------------*/ static void -adv_received(struct neighbor_discovery_conn *c, rimeaddr_t *from, - uint16_t rtmetric) +received_announcement(struct announcement *a, rimeaddr_t *from, + uint16_t id, uint16_t value) { struct neighbor *n; @@ -195,22 +208,23 @@ adv_received(struct neighbor_discovery_conn *c, rimeaddr_t *from, n = neighbor_find(from); if(n == NULL) { - neighbor_add(from, rtmetric, 1); + neighbor_add(from, value, 1); } else { - neighbor_update(n, rtmetric); + neighbor_update(n, value); } } -static const struct neighbor_discovery_callbacks neighbor_discovery_callbacks = - { adv_received, NULL}; +/*static const struct neighbor_discovery_callbacks neighbor_discovery_callbacks = + { adv_received, NULL};*/ HTTPD_CGI_CALL(sensors, "sensors", sensorscall); HTTPD_CGI_CALL(nodeid, "nodeid", nodeidcall); HTTPD_CGI_CALL(neighbors, "neighbors", neighborscall); -static struct neighbor_discovery_conn conn; +/*static struct neighbor_discovery_conn conn;*/ +static struct announcement announcement; void httpd_cgi_init(void) @@ -220,11 +234,15 @@ httpd_cgi_init(void) httpd_cgi_add(&nodeid); httpd_cgi_add(&neighbors); - neighbor_discovery_open(&conn, 31, + announcement_register(&announcement, 31, 0, + received_announcement); + announcement_listen(2); + + /* neighbor_discovery_open(&conn, 31, CLOCK_SECOND * 4, CLOCK_SECOND * 20, CLOCK_SECOND * 60, &neighbor_discovery_callbacks); - neighbor_discovery_start(&conn, 0); + neighbor_discovery_start(&conn, 0);*/ } /*---------------------------------------------------------------------------*/ diff --git a/examples/sky-ip/httpd-fs.c b/examples/sky-ip/httpd-fs.c index 6efb8c938..8b77643fd 100644 --- a/examples/sky-ip/httpd-fs.c +++ b/examples/sky-ip/httpd-fs.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: httpd-fs.c,v 1.1 2008/07/07 23:42:32 adamdunkels Exp $ + * $Id: httpd-fs.c,v 1.2 2009/05/11 17:38:29 adamdunkels Exp $ */ #include "contiki-net.h" @@ -80,7 +80,7 @@ httpd_fs_open(const char *name, struct httpd_fs_file *file) if(httpd_fs_strcmp(name, f->name) == 0) { file->data = f->data; - file->len = f->len; + file->len = f->len - 1; #if HTTPD_FS_STATISTICS ++count[i]; #endif /* HTTPD_FS_STATISTICS */ diff --git a/examples/sky-ip/httpd-fs/header.html b/examples/sky-ip/httpd-fs/header.html index a6c9f0dab..33ee39fa0 100644 --- a/examples/sky-ip/httpd-fs/header.html +++ b/examples/sky-ip/httpd-fs/header.html @@ -3,7 +3,7 @@ Contiki - +

Contiki 

Front page
diff --git a/examples/sky-ip/httpd-fs/sensordata.shtml b/examples/sky-ip/httpd-fs/sensordata.shtml new file mode 100644 index 000000000..d53bfbd14 --- /dev/null +++ b/examples/sky-ip/httpd-fs/sensordata.shtml @@ -0,0 +1 @@ +%! sensors diff --git a/examples/sky-ip/httpd-fs/sensors.shtml b/examples/sky-ip/httpd-fs/sensors.shtml index 428ac6a43..5ae61af1c 100644 --- a/examples/sky-ip/httpd-fs/sensors.shtml +++ b/examples/sky-ip/httpd-fs/sensors.shtml @@ -1,5 +1,47 @@ %!: /header.html