static PT_THREAD(send_values(struct httpd_state *s)) { PSOCK_BEGIN(&s->sout); SEND_STRING(&s->sout, TOP); if(strncmp(s->filename, "/index", 6) == 0 || s->filename[1] == '\0') { /* Default page: show latest sensor values as text (does not require Internet connection to Google for charts). */ blen = 0; ADD("<h1>Websense</h1>\n"); #if CONTIKI_TARGET_SKY ADD("<h2>Current readings</h2>\n" "Light: %u<br>" "Temperature: %u° C", get_light(), get_temp()); #endif SEND_STRING(&s->sout, buf); } else if(s->filename[1] == '0') { /* Turn off leds */ leds_off(LEDS_ALL); SEND_STRING(&s->sout, "Turned off leds!"); } else if(s->filename[1] == '1') { /* Turn on leds */ leds_on(LEDS_ALL); SEND_STRING(&s->sout, "Turned on leds!"); } else { #if CONTIKI_TARGET_SKY if(s->filename[1] != 't') { generate_chart("Light", "Light", 0, 500, light1); SEND_STRING(&s->sout, buf); } if(s->filename[1] != 'l') { generate_chart("Temperature", "Celsius", 15, 50, temperature); SEND_STRING(&s->sout, buf); } #endif } SEND_STRING(&s->sout, BOTTOM); PSOCK_END(&s->sout); }
static PT_THREAD(send_values(struct httpd_state *s)) { PSOCK_BEGIN(&s->sout); SEND_STRING(&s->sout, TOP); if(strncmp(s->filename, "/index", 6) == 0 || s->filename[1] == '\0') { /* Default page: show latest sensor values as text (does not require Internet connection to Google for charts). */ blen = 0; float mybatt = get_mybatt(); float mytemp = get_mytemp(); ADD("<h1>Current readings</h1>\n" "Battery: %ld.%03d V<br>" "Temperature: %ld.%03d ° C", (long) mybatt, (unsigned) ((mybatt-floor(mybatt))*1000), (long) mytemp, (unsigned) ((mytemp-floor(mytemp))*1000)); SEND_STRING(&s->sout, buf); } else if(s->filename[1] == '0') { /* Turn off leds */ leds_off(LEDS_ALL); SEND_STRING(&s->sout, "Turned off leds!"); } else if(s->filename[1] == '1') { /* Turn on leds */ leds_on(LEDS_ALL); SEND_STRING(&s->sout, "Turned on leds!"); } else { if(s->filename[1] != 't') { generate_chart("Battery", "mV", 0, 4000, battery1); SEND_STRING(&s->sout, buf); } if(s->filename[1] != 'b') { generate_chart("Temperature", "Celsius", 0, 50, temperature); SEND_STRING(&s->sout, buf); } } SEND_STRING(&s->sout, BOTTOM); PSOCK_END(&s->sout); }