Add avr-atmega128rfa1 platform based on Michael Hartman's board (single LED peripheral)
This commit is contained in:
parent
587951cf65
commit
62b894e560
30
platform/avr-atmega128rfa1/Makefile.avr-atmega128rfa1
Normal file
30
platform/avr-atmega128rfa1/Makefile.avr-atmega128rfa1
Normal file
@ -0,0 +1,30 @@
|
||||
CONTIKI_TARGET_DIRS = . apps net loader
|
||||
|
||||
CONTIKI_CORE=contiki-main
|
||||
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
|
||||
CONTIKI_TARGET_SOURCEFILES += contiki-main.c
|
||||
|
||||
CONTIKIAVR=$(CONTIKI)/cpu/avr
|
||||
CONTIKIBOARD=.
|
||||
|
||||
CONTIKI_PLAT_DEFS = -DF_CPU=8000000UL -DAUTO_CRC_PADDING=2
|
||||
|
||||
MCU=atmega128rfa1
|
||||
|
||||
AVRDUDE_PROGRAMMER=jtag2
|
||||
|
||||
# For usb devices, you may either use PORT=usb, or (e.g. if you have more than one
|
||||
# programmer connected) you can use the following trick to find out the serial number:
|
||||
#
|
||||
# The example is for an JTAGICE mkII used to program an ATmega128:
|
||||
# avrdude -v -P usb:xxxx -c jtag2 -p atmega128
|
||||
AVRDUDE_PORT=usb:00B000000D79
|
||||
|
||||
|
||||
# Additional avrdude options
|
||||
# Verify off
|
||||
AVRDUDE_OPTIONS=-V
|
||||
|
||||
|
||||
include $(CONTIKIAVR)/Makefile.avr
|
||||
include $(CONTIKIAVR)/radio/Makefile.radio
|
@ -0,0 +1,4 @@
|
||||
raven-ipso_src = raven-ipso.c
|
||||
|
||||
|
||||
CFLAGS+=-DRAVEN_LCD_INTERFACE=1
|
262
platform/avr-atmega128rfa1/apps/raven-ipso/raven-ipso.c
Normal file
262
platform/avr-atmega128rfa1/apps/raven-ipso/raven-ipso.c
Normal file
@ -0,0 +1,262 @@
|
||||
/* Copyright (c) 2008, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of the copyright holders nor the names of
|
||||
* 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 OWNER 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief This module contains code to interface a Contiki-based
|
||||
* project on the AVR Raven platform's ATMega1284P chip to the LCD
|
||||
* driver chip (ATMega3290P) on the Raven.
|
||||
*
|
||||
* \author Durvy Mathilde <mdurvy@cisco.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/** \addtogroup raven
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup ravenserial Serial interface between Raven processors
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* This file contains code to connect the two AVR Raven processors via
|
||||
* a serial connection for the IPSO interop application
|
||||
*
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "mac.h"
|
||||
|
||||
#include "raven-lcd.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define cmd_len 8
|
||||
#define data_len 20
|
||||
|
||||
static u8_t seqno;
|
||||
uip_ipaddr_t ping_addr;
|
||||
uip_ipaddr_t udp_addr;
|
||||
static struct uip_udp_conn *udp_conn;
|
||||
char udp_data[data_len];
|
||||
|
||||
static struct{
|
||||
u8_t frame[cmd_len];
|
||||
u8_t ndx;
|
||||
u8_t len;
|
||||
u8_t cmd;
|
||||
u8_t done;
|
||||
} cmd;
|
||||
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
|
||||
void rs232_send(uint8_t port, unsigned char c);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Sends a ping packet out the radio */
|
||||
void
|
||||
raven_ping6(void)
|
||||
{
|
||||
|
||||
/* ping ipv6.google.com*/
|
||||
uip_ip6addr(&ping_addr,0x2001,0x420,0x5FFF,0x7D,0x2D0,0xB7FF,0xFE23,0xE6DB);
|
||||
//uip_ip6addr(&ping_addr, 0x2001, 0x4860, 0, 0x2001, 0, 0, 0, 0x68);
|
||||
//uip_ip6addr(&ping_addr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
UIP_IP_BUF->vtc = 0x60;
|
||||
UIP_IP_BUF->tcflow = 1;
|
||||
UIP_IP_BUF->flow = 0;
|
||||
UIP_IP_BUF->proto = UIP_PROTO_ICMP6;
|
||||
//UIP_IP_BUF->ttl = uip_netif_physical_if.cur_hop_limit;
|
||||
UIP_IP_BUF->ttl = uip_ds6_if.cur_hop_limit;
|
||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &ping_addr);
|
||||
//uip_netif_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||
UIP_ICMP_BUF->type = ICMP6_ECHO_REQUEST;
|
||||
UIP_ICMP_BUF->icode = 0;
|
||||
/* set identifier and sequence number to 0 */
|
||||
memset((void *)UIP_ICMP_BUF + UIP_ICMPH_LEN, 0, 4);
|
||||
|
||||
uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN;
|
||||
UIP_IP_BUF->len[0] = (u8_t)((uip_len - 40) >> 8);
|
||||
UIP_IP_BUF->len[1] = (u8_t)((uip_len - 40) & 0x00FF);
|
||||
|
||||
UIP_ICMP_BUF->icmpchksum = 0;
|
||||
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
|
||||
|
||||
tcpip_ipv6_output();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Send a serial command frame to the ATMega3290 Processsor on Raven
|
||||
via serial port */
|
||||
static void
|
||||
send_frame(uint8_t cmd, uint8_t len, uint8_t *payload)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
rs232_send(0, SOF_CHAR); /* Start of Frame */
|
||||
rs232_send(0, len);
|
||||
rs232_send(0, cmd);
|
||||
for (i=0;i<len;i++)
|
||||
rs232_send(0,*payload++);
|
||||
rs232_send(0, EOF_CHAR);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
raven_gui_loop(process_event_t ev, process_data_t data)
|
||||
{
|
||||
if(ev == tcpip_icmp6_event) {
|
||||
switch(*((uint8_t *)data)){
|
||||
case ICMP6_ECHO_REQUEST:
|
||||
/* We have received a ping request over the air. Tell 3290 */
|
||||
send_frame(REPORT_PING_BEEP, 0, 0);
|
||||
break;
|
||||
case ICMP6_ECHO_REPLY:
|
||||
/* We have received a ping reply over the air. Pass seqno to 3290 */
|
||||
send_frame(REPORT_PING, 1, &seqno);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(ev){
|
||||
case SERIAL_CMD:
|
||||
/* Check for command from serial port, execute it. */
|
||||
if (cmd.done){
|
||||
/* Execute the waiting command */
|
||||
switch (cmd.cmd){
|
||||
case SEND_PING:
|
||||
/* Send ping request over the air */
|
||||
seqno = cmd.frame[0];
|
||||
raven_ping6();
|
||||
break;
|
||||
case SEND_TEMP:
|
||||
/* Set temperature string in web server */
|
||||
sprintf(udp_data, "T%s\r\n", (char *)cmd.frame);
|
||||
uip_udp_packet_send(udp_conn, udp_data, data_len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* Reset command done flag. */
|
||||
cmd.done = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/* Process an input character from serial port.
|
||||
* ** This is called from an ISR!!
|
||||
*/
|
||||
int raven_lcd_serial_input(unsigned char ch)
|
||||
{
|
||||
/* Parse frame, */
|
||||
switch (cmd.ndx){
|
||||
case 0:
|
||||
/* first byte, must be 0x01 */
|
||||
cmd.done = 0;
|
||||
if (ch != 0x01){
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Second byte, length of payload */
|
||||
cmd.len = ch;
|
||||
break;
|
||||
case 2:
|
||||
/* Third byte, command byte */
|
||||
cmd.cmd = ch;
|
||||
break;
|
||||
default:
|
||||
/* Payload and ETX */
|
||||
if (cmd.ndx >= cmd.len+3){
|
||||
/* all done, check ETX */
|
||||
if (ch == 0x04){
|
||||
cmd.done = 1;
|
||||
process_post(&raven_lcd_process, SERIAL_CMD, 0);
|
||||
} else {
|
||||
/* Failed ETX */
|
||||
cmd.ndx = 0;
|
||||
}
|
||||
} else {
|
||||
/* Just grab and store payload */
|
||||
cmd.frame[cmd.ndx - 3] = ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cmd.ndx++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(raven_lcd_process, "Raven LCD interface process");
|
||||
PROCESS_THREAD(raven_lcd_process, ev, data)
|
||||
{
|
||||
u8_t error;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/*Create a udp connection to the IPSOserver*/
|
||||
|
||||
//swisscom uip_ip6addr(&udp_addr,0x2001,918,0xfff9,0,0,0,0,1);
|
||||
//HE uip_ip6addr(&udp_addr,0x2001,0x470,0x1f12,0x5ec,0x12,0x13ff,0xfe14,0x1516);
|
||||
uip_ip6addr(&udp_addr,0x2001,0x420,0x5FFF,0x7D,0x2D0,0xB7FF,0xFE23,0xE6DB);
|
||||
|
||||
/* set destination parameters*/
|
||||
udp_conn = udp_new(&udp_addr, UIP_HTONS(0xF0B0), NULL);
|
||||
/*set local port */
|
||||
udp_bind(udp_conn, UIP_HTONS(0xF0B0+1));
|
||||
|
||||
if((error = icmp6_new(NULL)) == 0) {
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
raven_gui_loop(ev, data);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/** @} */
|
||||
/** @} */
|
@ -0,0 +1,4 @@
|
||||
raven-lcd-interface_src = raven-lcd.c
|
||||
|
||||
|
||||
CFLAGS+=-DRAVEN_LCD_INTERFACE=1
|
488
platform/avr-atmega128rfa1/apps/raven-lcd-interface/raven-lcd.c
Normal file
488
platform/avr-atmega128rfa1/apps/raven-lcd-interface/raven-lcd.c
Normal file
@ -0,0 +1,488 @@
|
||||
/* Copyright (c) 2008, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of the copyright holders nor the names of
|
||||
* 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 OWNER 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.
|
||||
*
|
||||
* $Id: raven-lcd.c,v 1.11 2010/12/22 17:09:03 dak664 Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief This module contains code to interface a Contiki-based
|
||||
* project on the AVR Raven platform's ATMega1284P chip to the LCD
|
||||
* driver chip (ATMega3290P) on the Raven.
|
||||
*
|
||||
* \author Blake Leverett <bleverett@gmail.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/** \addtogroup raven
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup ravenserial Serial interface between Raven processors
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* This file contains code to connect the two AVR Raven processors via a serial connection.
|
||||
*
|
||||
*/
|
||||
|
||||
#define DEBUG 0 //Making this 1 will slightly alter command timings
|
||||
#if DEBUG
|
||||
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define DEBUGSERIAL 0 //Making this 1 will significantly alter command timings
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "contiki-net.h"
|
||||
#include "webserver-nogui.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "raven-lcd.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <dev/watchdog.h>
|
||||
|
||||
static u8_t count = 0;
|
||||
static u8_t seqno;
|
||||
uip_ipaddr_t dest_addr;
|
||||
|
||||
#define MAX_CMD_LEN 20
|
||||
static struct{
|
||||
u8_t frame[MAX_CMD_LEN];
|
||||
u8_t ndx;
|
||||
u8_t len;
|
||||
u8_t cmd;
|
||||
u8_t done;
|
||||
} cmd;
|
||||
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define PING6_DATALEN 16
|
||||
|
||||
void rs232_send(uint8_t port, unsigned char c);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Sends a ping packet out the radio */
|
||||
/* Useful for debugging so allow external calls */
|
||||
void
|
||||
raven_ping6(void)
|
||||
{
|
||||
#define PING_GOOGLE 0
|
||||
|
||||
UIP_IP_BUF->vtc = 0x60;
|
||||
UIP_IP_BUF->tcflow = 1;
|
||||
UIP_IP_BUF->flow = 0;
|
||||
UIP_IP_BUF->proto = UIP_PROTO_ICMP6;
|
||||
UIP_IP_BUF->ttl = uip_ds6_if.cur_hop_limit;
|
||||
#if PING_GOOGLE
|
||||
if (seqno==1) {
|
||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, uip_ds6_defrt_choose()); //the default router
|
||||
} else if (seqno==2) {
|
||||
uip_ip6addr(&UIP_IP_BUF->destipaddr,0x2001,0x4860,0x800f,0x0000,0x0000,0x0000,0x0000,0x0093); //ipv6.google.com
|
||||
} else if (seqno==3) {
|
||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, uip_ds6_defrt_choose()); //the default router
|
||||
} else {
|
||||
// uip_ip6addr(&UIP_IP_BUF->destipaddr,0x2001,0x0420,0x5FFF,0x007D,0x02D0,0xB7FF,0xFE23,0xE6DB); //?.cisco.com
|
||||
uip_ip6addr(&UIP_IP_BUF->destipaddr,0x2001,0x0420,0x0000,0x0010,0x0250,0x8bff,0xfee8,0xf800); //six.cisco.com
|
||||
}
|
||||
#else
|
||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, uip_ds6_defrt_choose()); //the default router
|
||||
#endif
|
||||
|
||||
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||
UIP_ICMP_BUF->type = ICMP6_ECHO_REQUEST;
|
||||
UIP_ICMP_BUF->icode = 0;
|
||||
/* set identifier and sequence number to 0 */
|
||||
memset((void *)UIP_ICMP_BUF + UIP_ICMPH_LEN, 0, 4);
|
||||
/* put one byte of data */
|
||||
memset((void *)UIP_ICMP_BUF + UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN,
|
||||
count, PING6_DATALEN);
|
||||
|
||||
|
||||
uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN + PING6_DATALEN;
|
||||
UIP_IP_BUF->len[0] = (u8_t)((uip_len - 40) >> 8);
|
||||
UIP_IP_BUF->len[1] = (u8_t)((uip_len - 40) & 0x00FF);
|
||||
|
||||
UIP_ICMP_BUF->icmpchksum = 0;
|
||||
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
|
||||
|
||||
|
||||
tcpip_ipv6_output();
|
||||
}
|
||||
#if defined(__AVR_ATmega128RFA1__)
|
||||
/* No raven 3290p to talk to but the lcd process still needed for ping reporting */
|
||||
/* Just dummy out send_frame */
|
||||
static void
|
||||
send_frame(uint8_t cmd, uint8_t len, uint8_t *payload)
|
||||
{
|
||||
}
|
||||
#else
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Send a serial command frame to the ATMega3290 Processsor on Raven via serial port */
|
||||
static void
|
||||
send_frame(uint8_t cmd, uint8_t len, uint8_t *payload)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
rs232_send(0, SOF_CHAR); /* Start of Frame */
|
||||
rs232_send(0, len);
|
||||
rs232_send(0, cmd);
|
||||
for (i=0;i<len;i++)
|
||||
rs232_send(0,*payload++);
|
||||
rs232_send(0, EOF_CHAR);
|
||||
}
|
||||
#endif
|
||||
char serial_char_received;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Sleep for howlong seconds, or until UART interrupt if howlong==0.
|
||||
* Uses TIMER2 with external 32768 Hz crystal to sleep in 1 second multiples.
|
||||
* TIMER2 may have already been set up for 125 ticks/second in clock.c
|
||||
|
||||
*
|
||||
* Until someone figures out how to get UART to wake from powerdown,
|
||||
* a three second powersave cycle is used with exit based on any character received.
|
||||
|
||||
* The system clock is adjusted to reflect the sleep time.
|
||||
*/
|
||||
|
||||
void micro_sleep(uint8_t howlong)
|
||||
{
|
||||
uint8_t saved_sreg = SREG, saved_howlong = howlong;
|
||||
#if AVR_CONF_USE32KCRYSTAL
|
||||
/* Save TIMER2 configuration if clock.c is using it */
|
||||
uint8_t savedTCNT2=TCNT2, savedTCCR2A=TCCR2A, savedTCCR2B = TCCR2B, savedOCR2A = OCR2A;
|
||||
#endif
|
||||
|
||||
// if (howlong==0) {
|
||||
// set_sleep_mode(SLEEP_MODE_PWR_DOWN); // UART can't wake from powerdown
|
||||
// } else {
|
||||
set_sleep_mode(SLEEP_MODE_PWR_SAVE); // Sleep for howlong seconds
|
||||
if (howlong==0) howlong=3; // 3*32/(32768/1024) = 3 second sleep cycle if not specified
|
||||
cli(); // Disable interrupts for the present
|
||||
ASSR |= (1 << AS2); // Set TIMER2 asyncronous from external crystal
|
||||
TCCR2A =(1<<WGM21); // CTC mode
|
||||
TCCR2B =((1<<CS22)|(1<<CS21)|(1<<CS20));// Prescale by 1024 = 32 ticks/sec
|
||||
// while(ASSR & (1 << TCR2BUB)); // Wait for TCNT2 write to finish.
|
||||
OCR2A = howlong*32; // Set TIMER2 output compare register
|
||||
// while(ASSR & (1 << OCR2AUB)); // Wait for OCR2 write to finish.
|
||||
SREG = saved_sreg; // Restore interrupt state.
|
||||
// UCSR(USART,B)&= ~(1<<RXCIE(USART)) // Disable the RX Complete interrupt;
|
||||
// UCSR0B|=(1<<RXCIE0); // Enable UART0 RX complete interrupt
|
||||
// UCSR1B|=(1<<RXCIE1); // Enable UART1 RX complete interrupt
|
||||
// TCNT2 = 0; // Reset TIMER2 timer counter value.
|
||||
// while(ASSR & (1 << TCN2UB)); // Wait for TCNT2 write to finish before entering sleep.
|
||||
// TIMSK2 |= (1 << OCIE2A); // Enable TIMER2 output compare interrupt.
|
||||
// }
|
||||
|
||||
TCNT2 = 0; // Reset timer
|
||||
watchdog_stop(); // Silence annoying distractions
|
||||
while(ASSR & (1 << TCN2UB)); // Wait for TCNT2 write to (which assures TCCR2x and OCR2A are finished!)
|
||||
TIMSK2 |= (1 << OCIE2A); // Enable TIMER2 output compare interrupt
|
||||
SMCR |= (1 << SE); // Enable sleep mode.
|
||||
while (1) {
|
||||
// TCNT2 = 0; // Cleared automatically in CTC mode
|
||||
// while(ASSR & (1 << TCN2UB)); // Wait for TCNT2 write to finish before entering sleep.
|
||||
serial_char_received=0; // Set when chars received by UART
|
||||
sleep_mode(); // Sleep
|
||||
|
||||
/* Adjust clock.c for the time spent sleeping */
|
||||
extern void clock_adjust_seconds(uint8_t howmany);
|
||||
clock_adjust_seconds(howlong);
|
||||
|
||||
// if (TIMSK2&(1<<OCIE2A)) break; // Exit sleep if not awakened by TIMER2
|
||||
PRINTF(".");
|
||||
if (saved_howlong) break; // Exit sleep if nonzero time specified
|
||||
PRINTF("%d",serial_char_received);
|
||||
if (serial_char_received) break;
|
||||
}
|
||||
|
||||
SMCR &= ~(1 << SE); //Disable sleep mode after wakeup
|
||||
|
||||
#if AVR_CONF_USE32KCRYSTAL
|
||||
/* Restore clock.c configuration */
|
||||
// OCRSetup();
|
||||
cli();
|
||||
TCCR2A = savedTCCR2A;
|
||||
TCCR2B = savedTCCR2B;
|
||||
OCR2A = savedOCR2A;
|
||||
TCNT2 = savedTCNT2;
|
||||
sei();
|
||||
#else
|
||||
TIMSK2 &= ~(1 << OCIE2A); //Disable TIMER2 interrupt
|
||||
#endif
|
||||
|
||||
watchdog_start();
|
||||
}
|
||||
#if !AVR_CONF_USE32KCRYSTAL
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* TIMER2 Interrupt service */
|
||||
|
||||
ISR(TIMER2_COMPA_vect)
|
||||
{
|
||||
// TIMSK2 &= ~(1 << OCIE2A); //Just one interrupt needed for waking
|
||||
}
|
||||
#endif /* !AVR_CONF_USE32KCRYSTAL */
|
||||
|
||||
#if DEBUGSERIAL
|
||||
u8_t serialcount;
|
||||
char dbuf[30];
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern uint16_t ledtimer;
|
||||
static u8_t
|
||||
raven_gui_loop(process_event_t ev, process_data_t data)
|
||||
{
|
||||
uint8_t i,activeconnections,radio_state;
|
||||
|
||||
// PRINTF("\nevent %d ",ev);
|
||||
#if DEBUGSERIAL
|
||||
printf_P(PSTR("Buffer [%d]="),serialcount);
|
||||
serialcount=0;
|
||||
for (i=0;i<30;i++) {
|
||||
printf_P(PSTR(" %d"),dbuf[i]);
|
||||
dbuf[i]=0;
|
||||
}
|
||||
#endif
|
||||
if(ev == tcpip_icmp6_event) switch(*((uint8_t *)data)) {
|
||||
|
||||
// case ICMP6_NS:
|
||||
/*Tell the 3290 we are being solicited. */
|
||||
// send_frame(REPORT_NS,...);
|
||||
// break; //fall through for beep
|
||||
// case ICMP6_RA:
|
||||
/*Tell the 3290 we have a router. */
|
||||
// send_frame(REPORT_NA,...);
|
||||
// break; //fall through for beep
|
||||
case ICMP6_ECHO_REQUEST:
|
||||
/* We have received a ping request over the air. Tell the 3290 */
|
||||
// send_frame(REPORT_PING_BEEP, 0, 0);
|
||||
PORTE|=(1<<PE1);ledtimer=1000; //turn on led, set counter for turnoff
|
||||
break;
|
||||
case ICMP6_ECHO_REPLY:
|
||||
/* We have received a ping reply over the air. Send frame back to 3290 */
|
||||
// send_frame(REPORT_PING, 1, &seqno);
|
||||
break;
|
||||
|
||||
} else switch (ev) {
|
||||
case SERIAL_CMD:
|
||||
/* Check for command from serial port, execute it. */
|
||||
/* Note cmd frame is written in an interrupt - delays here can cause overwriting by next command */
|
||||
PRINTF("\nCommand %d length %d done %d",cmd.cmd,cmd.len,cmd.done);
|
||||
if (cmd.done){
|
||||
/* Execute the waiting command */
|
||||
switch (cmd.cmd){
|
||||
case SEND_PING:
|
||||
/* Send ping request over the air */
|
||||
seqno = cmd.frame[0];
|
||||
raven_ping6();
|
||||
break;
|
||||
case SEND_TEMP:
|
||||
/* Set temperature string in web server */
|
||||
// web_set_temp((char *)cmd.frame);
|
||||
break;
|
||||
case SEND_ADC2:
|
||||
/* Set ext voltage string in web server */
|
||||
// web_set_voltage((char *)cmd.frame);
|
||||
break;
|
||||
case SEND_SLEEP:
|
||||
/* Sleep radio and 1284p. */
|
||||
if (cmd.frame[0]==0) { //Time to sleep in seconds
|
||||
/* Unconditional sleep. Don't wake until a serial interrupt. */
|
||||
} else {
|
||||
/* Sleep specified number of seconds (3290p "DOZE" mode) */
|
||||
/* It sleeps a bit longer so we will be always be awake for the next sleep command. */
|
||||
/* Only sleep this cycle if no active TCP/IP connections */
|
||||
activeconnections=0;
|
||||
for(i = 0; i < UIP_CONNS; ++i) {
|
||||
if((uip_conns[i].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) activeconnections++;
|
||||
}
|
||||
if (activeconnections) {
|
||||
PRINTF("\nWaiting for %d connections",activeconnections);
|
||||
break;
|
||||
}
|
||||
}
|
||||
radio_state = NETSTACK_RADIO.off();
|
||||
PRINTF ("\nsleep %d radio state %d...",cmd.frame[0],radio_state);
|
||||
|
||||
/*Sleep for specified time*/
|
||||
PRINTF("\nSleeping...");
|
||||
micro_sleep(cmd.frame[0]);
|
||||
|
||||
radio_state = NETSTACK_RADIO.on();
|
||||
if (radio_state > 0) {
|
||||
PRINTF("Awake!");
|
||||
} else {
|
||||
PRINTF("Radio wake error %d\n",radio_state);
|
||||
}
|
||||
break;
|
||||
case SEND_WAKE:
|
||||
/* 3290p requests return message showing awake status */
|
||||
send_frame(REPORT_WAKE, 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* Reset command done flag. */
|
||||
cmd.done = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Process an input character from serial port.
|
||||
* ** This is called from an ISR!!
|
||||
*/
|
||||
|
||||
int raven_lcd_serial_input(unsigned char ch)
|
||||
{
|
||||
/* Tell sleep routine if a reception occurred */
|
||||
/* Random nulls occur for some reason, so ignore those */
|
||||
if (ch) serial_char_received++;
|
||||
#if DEBUGSERIAL
|
||||
if (serialcount<25) dbuf[serialcount]=ch;
|
||||
serialcount++;
|
||||
#endif
|
||||
/* Don't overwrite an unprocessed command */
|
||||
// if (cmd.done) return 0;
|
||||
|
||||
/* Parse frame, */
|
||||
switch (cmd.ndx){
|
||||
case 0:
|
||||
/* first byte, must be 0x01 */
|
||||
if (ch == 0x01){
|
||||
// cmd.done = false;
|
||||
} else {
|
||||
#if DEBUGSERIAL
|
||||
dbuf[25]++;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Second byte, length of payload */
|
||||
cmd.len = ch;
|
||||
break;
|
||||
case 2:
|
||||
/* Third byte, command byte */
|
||||
cmd.cmd = ch;
|
||||
break;
|
||||
default:
|
||||
/* Payload and ETX */
|
||||
if (cmd.ndx >= (MAX_CMD_LEN+3)) { //buffer overflow!
|
||||
cmd.ndx=0;
|
||||
#if DEBUGSERIAL
|
||||
dbuf[26]++;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if (cmd.ndx >= cmd.len+3){
|
||||
/* all done, check ETX */
|
||||
if (ch == 0x04){
|
||||
cmd.done = 1;
|
||||
#if DEBUGSERIAL
|
||||
dbuf[27]++;
|
||||
#endif
|
||||
process_post(&raven_lcd_process, SERIAL_CMD, 0);
|
||||
} else {
|
||||
/* Failed ETX */
|
||||
#if DEBUGSERIAL
|
||||
dbuf[28]++;
|
||||
#endif
|
||||
}
|
||||
cmd.ndx=0; //set up for next command
|
||||
return 0;
|
||||
} else {
|
||||
/* Just grab and store payload */
|
||||
cmd.frame[cmd.ndx - 3] = ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cmd.ndx++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
raven_lcd_show_text(char *text) {
|
||||
uint8_t textlen=strlen(text)+1;
|
||||
if (textlen > MAX_CMD_LEN) textlen=MAX_CMD_LEN;
|
||||
send_frame(REPORT_TEXT_MSG, textlen, (uint8_t *) text);
|
||||
}
|
||||
|
||||
#if WEBSERVER
|
||||
static void
|
||||
lcd_show_servername(void) {
|
||||
|
||||
//extern uint8_t mac_address[8]; //These are defined in httpd-fsdata.c via makefsdata.h
|
||||
extern uint8_t server_name[16];
|
||||
//extern uint8_t domain_name[30];
|
||||
char buf[sizeof(server_name)+1];
|
||||
eeprom_read_block (buf,server_name, sizeof(server_name));
|
||||
buf[sizeof(server_name)]=0;
|
||||
raven_lcd_show_text(buf); //must fit in all the buffers or it will be truncated!
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(raven_lcd_process, "Raven LCD interface process");
|
||||
PROCESS_THREAD(raven_lcd_process, ev, data)
|
||||
{
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
#if WEBSERVER
|
||||
lcd_show_servername();
|
||||
#endif
|
||||
|
||||
/* Get ICMP6 callbacks from uip6 stack, perform 3290p action on pings, responses, etc. */
|
||||
if(icmp6_new(NULL) == 0) {
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
// if (ev != ?) //trap frequent strobes?
|
||||
raven_gui_loop(ev, data);
|
||||
}
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
|
||||
/** @} */
|
@ -0,0 +1,59 @@
|
||||
|
||||
raven-webserver_src = webserver-nogui.c httpd.c http-strings.c psock.c memb.c \
|
||||
httpd-fs.c httpd-cgi.c
|
||||
raven-webserver_dsc = webserver-dsc.c
|
||||
|
||||
#Tell platform main routine webserver is present, for parameter display at startup
|
||||
CFLAGS += -DWEBSERVER
|
||||
|
||||
#$(CONTIKI)/apps/webserver/http-strings.c: $(CONTIKI)/apps/webserver/http-strings
|
||||
# cd $(CONTIKI)/apps/webserver/; $(CONTIKI)/tools/makestrings $<
|
||||
#
|
||||
|
||||
#The default is fixed web content packed in program flash memory. Note the existing httpd-fs read
|
||||
#code will only work for content in the first 64KB of program flash as the linked list addresses are
|
||||
#only 16 bit and reads use pgm_read_byte_near.
|
||||
#For COFFEE_FILES=1 Fixed web content in eeprom memory. Existing files can be rewritten but not extended
|
||||
#For COFFEE_FILES=2 Initial web content in eeprom memory in a fully writeable coffee file system.
|
||||
#For COFFEE_FILES=3 Fixed web content in program flash memory. Existing files can be rewritten but not extended
|
||||
#For COFFEE_FILES=4 Initial webcontent in program flash memory in a fully writeable coffee file system.
|
||||
|
||||
#The default web content is in the /httpd-fs directory. Override with $make WEBDIR=another_directory
|
||||
#If WEBDIR is then dropped from the command line the web content will NOT revert to the default
|
||||
#unless one of the files in the default directory is changed. This means a .coffeesection may still
|
||||
#be defined when COFFEE_FILES is dropped from the make, and a section overlap will occur during the link.
|
||||
#You can always safely restore the default content with $make WEBDIR=default.
|
||||
|
||||
.PHONY : force
|
||||
ifdef WEBDIR
|
||||
FORCE=force
|
||||
ifeq ($(WEBDIR),default)
|
||||
override WEBDIR=$(CONTIKI)/platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs
|
||||
endif
|
||||
else
|
||||
WEBDIR=$(CONTIKI)/platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs
|
||||
endif
|
||||
WEBCSOURCE=$(CONTIKI)/platform/avr-atmega128rfa1/apps/raven-webserver/
|
||||
|
||||
ifdef COFFEE_ADDRESS #for now force whenever present, could test for arg passed in make
|
||||
FORCE=force
|
||||
endif
|
||||
|
||||
$(WEBCSOURCE)httpd-fs.c: $(WEBCSOURCE)httpd-fsdata.c
|
||||
$(WEBCSOURCE)httpd-fsdata.c : $(FORCE) $(WEBDIR)/*.*
|
||||
ifeq ($(COFFEE_FILES), 1) #1=eeprom static
|
||||
@echo Generating web content for static eeprom coffee file system
|
||||
$(CONTIKI)/tools/makefsdata -C -A EEPROM -l -f 16 -d $(WEBDIR) -o $(WEBCSOURCE)httpd-fsdata.c
|
||||
else ifeq ($(COFFEE_FILES), 2) #2=eeprom dynamic
|
||||
@echo Generating web content for full eeprom coffee file system
|
||||
$(CONTIKI)/tools/makefsdata -C -A EEPROM -f 20 -d $(WEBDIR) -o $(WEBCSOURCE)httpd-fsdata.c
|
||||
else ifeq ($(COFFEE_FILES), 3) #3=program flash static
|
||||
@echo Generating web content for static flash coffee file system
|
||||
$(CONTIKI)/tools/makefsdata -C -A PROGMEM -l -f 16 -d $(WEBDIR) -o $(WEBCSOURCE)httpd-fsdata.c
|
||||
else ifeq ($(COFFEE_FILES), 4) #4=program flash dynamic
|
||||
@echo Generating initial web content for full flash coffee file system
|
||||
$(CONTIKI)/tools/makefsdata -C -A PROGMEM -c -f 20 -d $(WEBDIR) -o $(WEBCSOURCE)httpd-fsdata.c
|
||||
else
|
||||
@echo Generating static web content
|
||||
$(CONTIKI)/tools/makefsdata -A PROGMEM -l -d $(WEBDIR) -o $(WEBCSOURCE)httpd-fsdata.c
|
||||
endif
|
35
platform/avr-atmega128rfa1/apps/raven-webserver/http-strings
Normal file
35
platform/avr-atmega128rfa1/apps/raven-webserver/http-strings
Normal file
@ -0,0 +1,35 @@
|
||||
http_http "http://"
|
||||
http_200 "200 "
|
||||
http_301 "301 "
|
||||
http_302 "302 "
|
||||
http_get "GET "
|
||||
http_10 "HTTP/1.0"
|
||||
http_11 "HTTP/1.1"
|
||||
http_content_type "content-type: "
|
||||
http_texthtml "text/html"
|
||||
http_location "location: "
|
||||
http_host "host: "
|
||||
http_crnl "\r\n"
|
||||
http_index_html "/index.html"
|
||||
http_404_html "/404.html"
|
||||
http_referer "Referer:"
|
||||
http_header_200 "HTTP/1.0 200 OK\r\nServer: Contiki/2.0 http://www.sics.se/contiki/\r\nConnection: close\r\n"
|
||||
http_header_404 "HTTP/1.0 404 Not found\r\nServer: Contiki/2.0 http://www.sics.se/contiki/\r\nConnection: close\r\n"
|
||||
http_content_type_plain "Content-type: text/plain\r\n\r\n"
|
||||
http_content_type_html "Content-type: text/html\r\n\r\n"
|
||||
http_content_type_css "Content-type: text/css\r\n\r\n"
|
||||
http_content_type_text "Content-type: text/text\r\n\r\n"
|
||||
http_content_type_png "Content-type: image/png\r\n\r\n"
|
||||
http_content_type_gif "Content-type: image/gif\r\n\r\n"
|
||||
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
|
||||
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
|
||||
http_html ".html"
|
||||
http_shtml ".shtml"
|
||||
http_htm ".htm"
|
||||
http_css ".css"
|
||||
http_png ".png"
|
||||
http_gif ".gif"
|
||||
http_jpg ".jpg"
|
||||
http_text ".text"
|
||||
http_txt ".txt"
|
||||
|
104
platform/avr-atmega128rfa1/apps/raven-webserver/http-strings.c
Normal file
104
platform/avr-atmega128rfa1/apps/raven-webserver/http-strings.c
Normal file
@ -0,0 +1,104 @@
|
||||
#if 0 /*This file not used when strings reside in flash memory only*/
|
||||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_referer[9] =
|
||||
/* "Referer:" */
|
||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
||||
const char http_header_200[86] =
|
||||
/* "HTTP/1.0 200 OK\r\nServer: Contiki/2.0 http://www.sics.se/contiki/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_header_404[93] =
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: Contiki/2.0 http://www.sics.se/contiki/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_content_type_plain[29] =
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, };
|
||||
const char http_text[6] =
|
||||
/* ".text" */
|
||||
{0x2e, 0x74, 0x65, 0x78, 0x74, };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
#endif
|
@ -0,0 +1,34 @@
|
||||
extern const char http_http[8];
|
||||
extern const char http_200[5];
|
||||
extern const char http_301[5];
|
||||
extern const char http_302[5];
|
||||
extern const char http_get[5];
|
||||
extern const char http_10[9];
|
||||
extern const char http_11[9];
|
||||
extern const char http_content_type[15];
|
||||
extern const char http_texthtml[10];
|
||||
extern const char http_location[11];
|
||||
extern const char http_host[7];
|
||||
extern const char http_crnl[3];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_referer[9];
|
||||
extern const char http_header_200[86];
|
||||
extern const char http_header_404[93];
|
||||
extern const char http_content_type_plain[29];
|
||||
extern const char http_content_type_html[28];
|
||||
extern const char http_content_type_css [27];
|
||||
extern const char http_content_type_text[28];
|
||||
extern const char http_content_type_png [28];
|
||||
extern const char http_content_type_gif [28];
|
||||
extern const char http_content_type_jpg [29];
|
||||
extern const char http_content_type_binary[43];
|
||||
extern const char http_html[6];
|
||||
extern const char http_shtml[7];
|
||||
extern const char http_htm[5];
|
||||
extern const char http_css[5];
|
||||
extern const char http_png[5];
|
||||
extern const char http_gif[5];
|
||||
extern const char http_jpg[5];
|
||||
extern const char http_text[6];
|
||||
extern const char http_txt[5];
|
244
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cfs.c
Normal file
244
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cfs.c
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-cfs.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "webserver.h"
|
||||
#include "cfs/cfs.h"
|
||||
#include "lib/petsciiconv.h"
|
||||
#include "http-strings.h"
|
||||
|
||||
#include "httpd-cfs.h"
|
||||
|
||||
#ifndef WEBSERVER_CONF_CFS_CONNS
|
||||
#define CONNS 4
|
||||
#else /* WEBSERVER_CONF_CFS_CONNS */
|
||||
#define CONNS WEBSERVER_CONF_CFS_CONNS
|
||||
#endif /* WEBSERVER_CONF_CFS_CONNS */
|
||||
|
||||
#define STATE_WAITING 0
|
||||
#define STATE_OUTPUT 1
|
||||
|
||||
#define SEND_STRING(s, str) PSOCK_SEND(s, (uint8_t *)str, strlen(str))
|
||||
MEMB(conns, struct httpd_state, CONNS);
|
||||
|
||||
#define ISO_nl 0x0a
|
||||
#define ISO_space 0x20
|
||||
#define ISO_period 0x2e
|
||||
#define ISO_slash 0x2f
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
do {
|
||||
/* Read data from file system into buffer */
|
||||
s->len = cfs_read(s->fd, s->outputbuf, sizeof(s->outputbuf));
|
||||
|
||||
/* If there is data in the buffer, send it */
|
||||
if(s->len > 0) {
|
||||
PSOCK_SEND(&s->sout, (uint8_t *)s->outputbuf, s->len);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while(s->len > 0);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
if(ptr == NULL) {
|
||||
SEND_STRING(&s->sout, http_content_type_plain);
|
||||
} else if(strncmp(http_html, ptr, 5) == 0) {
|
||||
SEND_STRING(&s->sout, http_content_type_html);
|
||||
} else if(strncmp(http_css, ptr, 4) == 0) {
|
||||
SEND_STRING(&s->sout, http_content_type_css);
|
||||
} else if(strncmp(http_png, ptr, 4) == 0) {
|
||||
SEND_STRING(&s->sout, http_content_type_png);
|
||||
} else if(strncmp(http_jpg, ptr, 4) == 0) {
|
||||
SEND_STRING(&s->sout, http_content_type_jpg);
|
||||
} else {
|
||||
SEND_STRING(&s->sout, http_content_type_binary);
|
||||
}
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_output(struct httpd_state *s))
|
||||
{
|
||||
PT_BEGIN(&s->outputpt);
|
||||
|
||||
petsciiconv_topetscii(s->filename, sizeof(s->filename));
|
||||
s->fd = cfs_open(s->filename, CFS_READ);
|
||||
petsciiconv_toascii(s->filename, sizeof(s->filename));
|
||||
if(s->fd < 0) {
|
||||
s->fd = cfs_open("notfound.html", CFS_READ);
|
||||
if(s->fd < 0) {
|
||||
uip_abort();
|
||||
memb_free(&conns, s);
|
||||
webserver_log_file(&uip_conn->ripaddr, "reset (no notfound.html)");
|
||||
PT_EXIT(&s->outputpt);
|
||||
}
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s, http_header_404));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s, http_header_200));
|
||||
}
|
||||
PT_WAIT_THREAD(&s->outputpt, send_file(s));
|
||||
cfs_close(s->fd);
|
||||
s->fd = -1;
|
||||
PSOCK_CLOSE(&s->sout);
|
||||
PT_END(&s->outputpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_input(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sin);
|
||||
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(strncmp(s->inputbuf, http_get, 4) != 0) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(s->inputbuf[0] != ISO_slash) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
strncpy(s->filename, &http_index_html[1], sizeof(s->filename));
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, &s->inputbuf[1], sizeof(s->filename));
|
||||
}
|
||||
|
||||
petsciiconv_topetscii(s->filename, sizeof(s->filename));
|
||||
webserver_log_file(&uip_conn->ripaddr, s->filename);
|
||||
petsciiconv_toascii(s->filename, sizeof(s->filename));
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
while(1) {
|
||||
PSOCK_READTO(&s->sin, ISO_nl);
|
||||
|
||||
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
||||
petsciiconv_topetscii(s->inputbuf, PSOCK_DATALEN(&s->sin) - 2);
|
||||
webserver_log(s->inputbuf);
|
||||
}
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
handle_connection(struct httpd_state *s)
|
||||
{
|
||||
handle_input(s);
|
||||
if(s->state == STATE_OUTPUT) {
|
||||
handle_output(s);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_appcall(void *state)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
|
||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
||||
if(s != NULL) {
|
||||
if(s->fd >= 0) {
|
||||
cfs_close(s->fd);
|
||||
s->fd = -1;
|
||||
}
|
||||
memb_free(&conns, s);
|
||||
}
|
||||
} else if(uip_connected()) {
|
||||
s = (struct httpd_state *)memb_alloc(&conns);
|
||||
if(s == NULL) {
|
||||
uip_abort();
|
||||
webserver_log_file(&uip_conn->ripaddr, "reset (no memory block)");
|
||||
return;
|
||||
}
|
||||
tcp_markconn(uip_conn, s);
|
||||
PSOCK_INIT(&s->sin, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PSOCK_INIT(&s->sout, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PT_INIT(&s->outputpt);
|
||||
s->fd = -1;
|
||||
s->state = STATE_WAITING;
|
||||
timer_set(&s->timer, CLOCK_SECOND * 10);
|
||||
handle_connection(s);
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
if(timer_expired(&s->timer)) {
|
||||
uip_abort();
|
||||
if(s->fd >= 0) {
|
||||
cfs_close(s->fd);
|
||||
s->fd = -1;
|
||||
}
|
||||
memb_free(&conns, s);
|
||||
webserver_log_file(&uip_conn->ripaddr, "reset (timeout)");
|
||||
}
|
||||
} else {
|
||||
timer_reset(&s->timer);
|
||||
}
|
||||
handle_connection(s);
|
||||
} else {
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_init(void)
|
||||
{
|
||||
tcp_listen(UIP_HTONS(80));
|
||||
memb_init(&conns);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
56
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cfs.h
Normal file
56
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cfs.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cfs.h,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_CFS_H__
|
||||
#define __HTTPD_CFS_H__
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
struct httpd_state {
|
||||
struct timer timer;
|
||||
struct psock sin, sout;
|
||||
struct pt outputpt;
|
||||
char inputbuf[50];
|
||||
char outputbuf[UIP_TCP_MSS];
|
||||
char filename[20];
|
||||
char state;
|
||||
int fd;
|
||||
int len;
|
||||
};
|
||||
|
||||
|
||||
void httpd_init(void);
|
||||
void httpd_appcall(void *state);
|
||||
|
||||
#endif /* __HTTPD_CFS_H__ */
|
602
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cgi.c
Normal file
602
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cgi.c
Normal file
@ -0,0 +1,602 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.c,v 1.13 2010/12/23 19:41:07 dak664 Exp $
|
||||
*
|
||||
*/
|
||||
#include <util/delay.h>
|
||||
#define delay_us( us ) ( _delay_us( ( us ) ) )
|
||||
/*
|
||||
* This file includes functions that are called by the web server
|
||||
* scripts. The functions takes no argument, and the return value is
|
||||
* interpreted as follows. A zero means that the function did not
|
||||
* complete and should be invoked for the next packet as well. A
|
||||
* non-zero value indicates that the function has completed and that
|
||||
* the web server should move along to the next script line.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "contiki-net.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-fsdata.h"
|
||||
#include "lib/petsciiconv.h"
|
||||
|
||||
#include "sensors.h"
|
||||
|
||||
#define DEBUGLOGIC 0 //See httpd.c, if 1 must also set it there!
|
||||
#if DEBUGLOGIC
|
||||
#define uip_mss(...) 512
|
||||
#define uip_appdata TCPBUF
|
||||
extern char TCPBUF[512];
|
||||
#endif
|
||||
|
||||
/* RADIOSTATS must also be set in clock.c and the radio driver */
|
||||
#if RF230BB
|
||||
#define RADIOSTATS 1
|
||||
#endif
|
||||
|
||||
static struct httpd_cgi_call *calls = NULL;
|
||||
|
||||
/*cgi function names*/
|
||||
#if HTTPD_FS_STATISTICS
|
||||
static const char file_name[] HTTPD_STRING_ATTR = "file-stats";
|
||||
#endif
|
||||
static const char tcp_name[] HTTPD_STRING_ATTR = "tcp-connections";
|
||||
static const char proc_name[] HTTPD_STRING_ATTR = "processes";
|
||||
static const char sensor_name[] HTTPD_STRING_ATTR = "sensors";
|
||||
static const char adrs_name[] HTTPD_STRING_ATTR = "addresses";
|
||||
static const char nbrs_name[] HTTPD_STRING_ATTR = "neighbors";
|
||||
static const char rtes_name[] HTTPD_STRING_ATTR = "routes";
|
||||
|
||||
/*Process states for processes cgi*/
|
||||
static const char closed[] HTTPD_STRING_ATTR = "CLOSED";
|
||||
static const char syn_rcvd[] HTTPD_STRING_ATTR = "SYN-RCVD";
|
||||
static const char syn_sent[] HTTPD_STRING_ATTR = "SYN-SENT";
|
||||
static const char established[] HTTPD_STRING_ATTR = "ESTABLISHED";
|
||||
static const char fin_wait_1[] HTTPD_STRING_ATTR = "FIN-WAIT-1";
|
||||
static const char fin_wait_2[] HTTPD_STRING_ATTR = "FIN-WAIT-2";
|
||||
static const char closing[] HTTPD_STRING_ATTR = "CLOSING";
|
||||
static const char time_wait[] HTTPD_STRING_ATTR = "TIME-WAIT";
|
||||
static const char last_ack[] HTTPD_STRING_ATTR = "LAST-ACK";
|
||||
static const char none[] HTTPD_STRING_ATTR = "NONE";
|
||||
static const char running[] HTTPD_STRING_ATTR = "RUNNING";
|
||||
static const char called[] HTTPD_STRING_ATTR = "CALLED";
|
||||
static const char *states[] = {
|
||||
closed,
|
||||
syn_rcvd,
|
||||
syn_sent,
|
||||
established,
|
||||
fin_wait_1,
|
||||
fin_wait_2,
|
||||
closing,
|
||||
time_wait,
|
||||
last_ack,
|
||||
none,
|
||||
running,
|
||||
called};
|
||||
|
||||
static char sensor_temperature[12]="Not Enabled";
|
||||
static char sensor_extvoltage[12]="Not Enabled";
|
||||
// static unsigned long last_tempupdate,last_extvoltageupdate;
|
||||
extern unsigned long seconds, sleepseconds;
|
||||
#if RADIOSTATS
|
||||
extern unsigned long radioontime;
|
||||
static unsigned long savedradioontime;
|
||||
extern uint8_t RF230_radio_on, rf230_last_rssi;
|
||||
extern uint16_t RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void
|
||||
web_set_temp(char *s)
|
||||
{
|
||||
strcpy(sensor_temperature, s);
|
||||
last_tempupdate=seconds;
|
||||
}
|
||||
void
|
||||
web_set_voltage(char *s)
|
||||
{
|
||||
strcpy(sensor_extvoltage, s);
|
||||
last_extvoltageupdate=seconds;
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
httpd_cgifunction
|
||||
httpd_cgi(char *name)
|
||||
{
|
||||
struct httpd_cgi_call *f;
|
||||
|
||||
/* Find the matching name in the table, return the function. */
|
||||
for(f = calls; f != NULL; f = f->next) {
|
||||
if(httpd_strncmp(name, f->name, httpd_strlen(f->name)) == 0) {
|
||||
return f->function;
|
||||
}
|
||||
}
|
||||
return nullfunction;
|
||||
}
|
||||
|
||||
#if HTTPD_FS_STATISTICS
|
||||
static char *thisfilename;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_file_stats(void *arg)
|
||||
{
|
||||
static const char httpd_cgi_filestat1[] HTTPD_STRING_ATTR = "<p class=right><br><br><i>This page has been sent %u times</i></div></body></html>";
|
||||
static const char httpd_cgi_filestat2[] HTTPD_STRING_ATTR = "<tr><td><a href=\"%s\">%s</a></td><td>%d</td>";
|
||||
static const char httpd_cgi_filestat3[] HTTPD_STRING_ATTR = "%5u";
|
||||
char tmp[20];
|
||||
struct httpd_fsdata_file_noconst *f,fram;
|
||||
u16_t i;
|
||||
unsigned short numprinted;
|
||||
|
||||
/* Transfer arg from whichever flash that contains the html file to RAM */
|
||||
httpd_fs_cpy(&tmp, (char *)arg, 20);
|
||||
|
||||
/* Count for this page, with common page footer */
|
||||
if (tmp[0]=='.') {
|
||||
numprinted=httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_filestat1, httpd_fs_open(thisfilename, 0));
|
||||
|
||||
/* Count for all files */
|
||||
/* Note buffer will overflow if there are too many files! */
|
||||
} else if (tmp[0]=='*') {
|
||||
i=0;numprinted=0;
|
||||
for(f = (struct httpd_fsdata_file_noconst *)httpd_fs_get_root();
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)fram.next) {
|
||||
|
||||
/* Get the linked list file entry into RAM from from wherever it is*/
|
||||
httpd_memcpy(&fram,f,sizeof(fram));
|
||||
|
||||
/* Get the file name from whatever memory it is in */
|
||||
httpd_fs_cpy(&tmp, fram.name, sizeof(tmp));
|
||||
#if HTTPD_FS_STATISTICS==1
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_filestat2, tmp, tmp, f->count);
|
||||
#elif HTTPD_FS_STATISTICS==2
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_filestat2, tmp, tmp, httpd_filecount[i]);
|
||||
#endif
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Count for specified file */
|
||||
} else {
|
||||
numprinted=httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_filestat3, httpd_fs_open(tmp, 0));
|
||||
}
|
||||
#if DEBUGLOGIC
|
||||
return 0;
|
||||
#endif
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
thisfilename=&s->filename[0]; //temporary way to pass filename to generate_file_stats
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
#endif /*HTTPD_FS_STATISTICS*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
make_tcp_stats(void *arg)
|
||||
{
|
||||
static const char httpd_cgi_tcpstat1[] HTTPD_STRING_ATTR = "<tr align=\"center\"><td>%d</td><td>";
|
||||
static const char httpd_cgi_tcpstat2[] HTTPD_STRING_ATTR = "-%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n";
|
||||
struct uip_conn *conn;
|
||||
struct httpd_state *s = (struct httpd_state *)arg;
|
||||
char tstate[20];
|
||||
uint16_t numprinted;
|
||||
|
||||
conn = &uip_conns[s->u.count];
|
||||
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_tcpstat1, uip_htons(conn->lport));
|
||||
numprinted += httpd_cgi_sprint_ip6(conn->ripaddr, uip_appdata + numprinted);
|
||||
httpd_strcpy(tstate,states[conn->tcpstateflags & UIP_TS_MASK]);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted,
|
||||
httpd_cgi_tcpstat2,
|
||||
uip_htons(conn->rport),
|
||||
tstate,
|
||||
conn->nrtx,
|
||||
conn->timer,
|
||||
(uip_outstanding(conn))? '*':' ',
|
||||
(uip_stopped(conn))? '!':' ');
|
||||
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
for(s->u.count = 0; s->u.count < UIP_CONNS; ++s->u.count) {
|
||||
if((uip_conns[s->u.count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_tcp_stats, s);
|
||||
}
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
make_processes(void *p)
|
||||
{
|
||||
static const char httpd_cgi_proc[] HTTPD_STRING_ATTR = "<tr align=\"center\"><td>%p</td><td>%s</td><td>%p</td><td>%s</td></tr>\r\n";
|
||||
char name[40],tstate[20];
|
||||
|
||||
strncpy(name, ((struct process *)p)->name, 40);
|
||||
petsciiconv_toascii(name, 40);
|
||||
httpd_strcpy(tstate,states[9 + ((struct process *)p)->state]);
|
||||
return httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_proc, p, name,
|
||||
*(char *)(&(((struct process *)p)->thread)),
|
||||
|
||||
tstate);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(processes(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
for(s->u.ptr = PROCESS_LIST(); s->u.ptr != NULL; s->u.ptr = ((struct process *)s->u.ptr)->next) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_processes, s->u.ptr);
|
||||
}
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const char httpd_cgi_addrh[] HTTPD_STRING_ATTR = "<code>";
|
||||
static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]";
|
||||
static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>";
|
||||
static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>";
|
||||
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
|
||||
extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
extern uip_ds6_netif_t uip_ds6_if;
|
||||
|
||||
static unsigned short
|
||||
make_addresses(void *p)
|
||||
{
|
||||
uint8_t i,j=0;
|
||||
uint16_t numprinted;
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
|
||||
for (i=0; i<UIP_DS6_ADDR_NB;i++) {
|
||||
if (uip_ds6_if.addr_list[i].isused) {
|
||||
j++;
|
||||
numprinted += httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr, uip_appdata + numprinted);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
|
||||
}
|
||||
}
|
||||
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf, UIP_DS6_ADDR_NB-j);
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(addresses(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_addresses, s->u.ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
make_neighbors(void *p)
|
||||
{
|
||||
uint8_t i,j=0;
|
||||
uint16_t numprinted;
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
|
||||
for (i=0; i<UIP_DS6_NBR_NB;i++) {
|
||||
if (uip_ds6_nbr_cache[i].isused) {
|
||||
j++;
|
||||
numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
|
||||
}
|
||||
}
|
||||
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_NBR_NB-j);
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(neighbors(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_neighbors, s->u.ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
make_routes(void *p)
|
||||
{
|
||||
static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via ";
|
||||
static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %lus<br>";
|
||||
static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")<br>";
|
||||
uint8_t i,j=0;
|
||||
uint16_t numprinted;
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
|
||||
for (i=0; i<UIP_DS6_ROUTE_NB;i++) {
|
||||
if (uip_ds6_routing_table[i].isused) {
|
||||
j++;
|
||||
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, uip_ds6_routing_table[i].length);
|
||||
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].nexthop, uip_appdata + numprinted);
|
||||
if(uip_ds6_routing_table[i].state.lifetime < 3600) {
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, uip_ds6_routing_table[i].state.lifetime);
|
||||
} else {
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_ROUTE_NB-j);
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(routes(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_routes, s->u.ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_sensor_readings(void *arg)
|
||||
{
|
||||
uint16_t numprinted;
|
||||
uint16_t h,m,s;
|
||||
uint8_t p1;
|
||||
// static const char httpd_cgi_sensor0[] HTTPD_STRING_ATTR = "[Updated %d seconds ago]<br><br>";
|
||||
// static const char httpd_cgi_sensor1[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s<br>";
|
||||
// static const char httpd_cgi_sensor2[] HTTPD_STRING_ATTR = "<em>Battery:</em> %s<br>";
|
||||
static const char httpd_cgi_sensor1_printf[] HTTPD_STRING_ATTR = "%d.%d C";
|
||||
static const char httpd_cgi_sensor2_printf[] HTTPD_STRING_ATTR = "%d mv";
|
||||
static const char httpd_cgi_sensr12[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s <em>Battery:<em> %s<br>";
|
||||
static const char httpd_cgi_sensor3[] HTTPD_STRING_ATTR = "<em>Elapsed timer :</em> %02d:%02d:%02d<br>";
|
||||
static const char httpd_cgi_sensor4[] HTTPD_STRING_ATTR = "<em>Sleeping time :</em> %02d:%02d:%02d (%d%%)<br>";
|
||||
|
||||
numprinted=0;
|
||||
// if (last_tempupdate) {
|
||||
// numprinted =httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_sensor0,seconds-last_tempupdate);
|
||||
// }
|
||||
BATMON = 16; //give BATMON time to stabilize at highest range and lowest voltage
|
||||
/* Measure internal temperature sensor, see atmega128rfa1 datasheet */
|
||||
/* This code disabled by default for safety. Selecting an internal reference will short it to
|
||||
anything connected to the AREF pin!
|
||||
*/
|
||||
#if 1
|
||||
ADCSRB|=1<<MUX5; //this bit buffered till ADMUX written to!
|
||||
ADMUX =0xc9; // Select internal 1.6 volt ref, temperature sensor ADC channel
|
||||
ADCSRA=0x85; //Enable ADC, not free running, interrupt disabled, clock divider 32 (250 KHz@ 8 MHz)
|
||||
// while ((ADCSRB&(1<<AVDDOK))==0); //wait for AVDD ok
|
||||
// while ((ADCSRB&(1<<REFOK))==0); //wait for ref ok
|
||||
ADCSRA|=1<<ADSC; //Start throwaway conversion
|
||||
while (ADCSRA&(1<<ADSC)); //Wait till done
|
||||
ADCSRA|=1<<ADSC; //Start another conversion
|
||||
while (ADCSRA&(1<<ADSC)); //Wait till done
|
||||
h=ADC; //Read adc
|
||||
h=11*h-2728+(h>>2); //Convert to celcius*10 (should be 11.3*h, approximate with 11.25*h)
|
||||
ADCSRA=0; //disable ADC
|
||||
ADMUX=0; //turn off internal vref
|
||||
m=h/10;s=h-10*m;
|
||||
httpd_snprintf(sensor_temperature,sizeof(sensor_temperature),httpd_cgi_sensor1_printf,m,s);
|
||||
#endif
|
||||
|
||||
/* Bandgap can't be measured against supply voltage in this chip. */
|
||||
/* Use BATMON register instead */
|
||||
for ( p1=16; p1<31; p1++) {
|
||||
BATMON = p1;
|
||||
// delay_us(100); //delay needed?
|
||||
if ((BATMON&(1<<BATMON_OK))==0) break;
|
||||
}
|
||||
h=2550-75*16-75+75*p1; //-75 to take the floor of the 75 mv transition window
|
||||
httpd_snprintf(sensor_extvoltage,sizeof(sensor_extvoltage),httpd_cgi_sensor2_printf,h);
|
||||
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensr12, sensor_temperature,sensor_extvoltage);
|
||||
|
||||
// numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2, sensor_extvoltage);
|
||||
#if RADIOSTATS
|
||||
/* Remember radioontime for display below - slow connection might make it report longer than cpu ontime! */
|
||||
savedradioontime = radioontime;
|
||||
#endif
|
||||
h=seconds/3600;
|
||||
s=seconds-h*3600;
|
||||
m=s/60;
|
||||
s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3, h,m,s);
|
||||
if (sleepseconds) {
|
||||
p1=100UL*sleepseconds/seconds;
|
||||
h=sleepseconds/3600;
|
||||
s=sleepseconds-h*3600;
|
||||
m=s/60;
|
||||
s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor4, h,m,s,p1);
|
||||
}
|
||||
return numprinted;
|
||||
}
|
||||
#if RADIOSTATS
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_radio_stats(void *arg)
|
||||
{
|
||||
uint16_t numprinted;
|
||||
uint16_t h,m,s;
|
||||
uint8_t p1,p2;
|
||||
static const char httpd_cgi_sensor10[] HTTPD_STRING_ATTR = "<em>Radio on time :</em> %02d:%02d:%02d (%d.%02d%%)<br>";
|
||||
static const char httpd_cgi_sensor11[] HTTPD_STRING_ATTR = "<em>Packets:</em> Tx=%5d Rx=%5d TxL=%5d RxL=%5d RSSI=%2ddBm\n";
|
||||
|
||||
s=(10000UL*savedradioontime)/seconds;
|
||||
p1=s/100;
|
||||
p2=s-p1*100;
|
||||
h=savedradioontime/3600;
|
||||
s=savedradioontime-h*3600;
|
||||
m=s/60;
|
||||
s=s-m*60;
|
||||
|
||||
numprinted =httpd_snprintf((char *)uip_appdata , uip_mss() , httpd_cgi_sensor10,\
|
||||
h,m,s,p1,p2);
|
||||
|
||||
#if RF230BB
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor11,\
|
||||
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_sensor11,\
|
||||
RF230_sendpackets,RF230_receivepackets,RF230_sendfail,RF230_receivefail,p1);
|
||||
#endif
|
||||
|
||||
return numprinted;
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(sensor_readings(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_sensor_readings, s);
|
||||
#if RADIOSTATS
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_radio_stats, s);
|
||||
#endif
|
||||
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_cgi_add(struct httpd_cgi_call *c)
|
||||
{
|
||||
struct httpd_cgi_call *l;
|
||||
|
||||
c->next = NULL;
|
||||
if(calls == NULL) {
|
||||
calls = c;
|
||||
} else {
|
||||
for(l = calls; l->next != NULL; l = l->next);
|
||||
l->next = c;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#if HTTPD_FS_STATISTICS
|
||||
HTTPD_CGI_CALL( file, file_name, file_stats);
|
||||
#endif
|
||||
HTTPD_CGI_CALL( tcp, tcp_name, tcp_stats );
|
||||
HTTPD_CGI_CALL( proc, proc_name, processes );
|
||||
HTTPD_CGI_CALL( adrs, adrs_name, addresses );
|
||||
HTTPD_CGI_CALL( nbrs, nbrs_name, neighbors );
|
||||
HTTPD_CGI_CALL( rtes, rtes_name, routes );
|
||||
HTTPD_CGI_CALL(sensors, sensor_name, sensor_readings);
|
||||
|
||||
void
|
||||
httpd_cgi_init(void)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
httpd_cgi_add( &file);
|
||||
#endif
|
||||
httpd_cgi_add( &tcp);
|
||||
httpd_cgi_add( &proc);
|
||||
httpd_cgi_add( &adrs);
|
||||
httpd_cgi_add( &nbrs);
|
||||
httpd_cgi_add( &rtes);
|
||||
httpd_cgi_add(&sensors);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result)
|
||||
{
|
||||
unsigned char zerocnt = 0;
|
||||
unsigned char numprinted = 0;
|
||||
char * starting = result;
|
||||
|
||||
unsigned char i = 0;
|
||||
|
||||
while (numprinted < 8)
|
||||
{
|
||||
//Address is zero, have we used our ability to
|
||||
//replace a bunch with : yet?
|
||||
if ((addr.u16[i] == 0) && (zerocnt == 0))
|
||||
{
|
||||
//How mant zeros?
|
||||
zerocnt = 0;
|
||||
while(addr.u16[zerocnt + i] == 0)
|
||||
zerocnt++;
|
||||
|
||||
//just one, don't waste our zeros...
|
||||
if (zerocnt == 1)
|
||||
{
|
||||
*result++ = '0';
|
||||
numprinted++;
|
||||
break;
|
||||
}
|
||||
|
||||
//Cool - can replace a bunch of zeros
|
||||
i += zerocnt;
|
||||
numprinted += zerocnt;
|
||||
}
|
||||
//Normal address, just print it
|
||||
else
|
||||
{
|
||||
result += sprintf(result, "%x", (unsigned int)(uip_ntohs(addr.u16[i])));
|
||||
i++;
|
||||
numprinted++;
|
||||
}
|
||||
|
||||
//Don't print : on last one
|
||||
if (numprinted != 8)
|
||||
*result++ = ':';
|
||||
}
|
||||
|
||||
return (result - starting);
|
||||
}
|
||||
|
61
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cgi.h
Normal file
61
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-cgi.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.h,v 1.3 2010/02/12 16:42:59 dak664 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_CGI_H__
|
||||
#define __HTTPD_CGI_H__
|
||||
|
||||
#include "contiki.h"
|
||||
#include "httpd.h"
|
||||
|
||||
typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
|
||||
|
||||
httpd_cgifunction httpd_cgi(char *name);
|
||||
|
||||
struct httpd_cgi_call {
|
||||
struct httpd_cgi_call *next;
|
||||
const char *name;
|
||||
httpd_cgifunction function;
|
||||
};
|
||||
|
||||
void httpd_cgi_add(struct httpd_cgi_call *c);
|
||||
|
||||
#define HTTPD_CGI_CALL(name, str, function) \
|
||||
static struct httpd_cgi_call name = {NULL, str, function}
|
||||
|
||||
void httpd_cgi_init(void);
|
||||
void web_set_temp(char *s);
|
||||
void web_set_voltage(char *s);
|
||||
uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result);
|
||||
|
||||
#endif /* __HTTPD_CGI_H__ */
|
137
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs.c
Normal file
137
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs.c
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fs.c,v 1.4 2009/07/24 15:41:52 dak664 Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-net.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-fsdata.h"
|
||||
#include "httpd-fsdata.c"
|
||||
|
||||
#if HTTPD_FS_STATISTICS==2
|
||||
u16_t httpd_filecount[HTTPD_FS_NUMFILES];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void *
|
||||
httpd_fs_get_root()
|
||||
{
|
||||
return (void *)HTTPD_FS_ROOT;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
httpd_fs_get_size()
|
||||
{
|
||||
return HTTPD_FS_SIZE;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t i = 0;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
struct httpd_fsdata_file_noconst *f,fram;
|
||||
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)fram.next) {
|
||||
|
||||
/*Get the linked list entry into ram from wherever it is */
|
||||
httpd_memcpy(&fram,f,sizeof(fram));
|
||||
|
||||
/*Compare name passed in RAM with name in whatever flash the file is in */
|
||||
if(httpd_fs_strcmp((char *)name, fram.name) == 0) {
|
||||
if (file) {
|
||||
file->data = fram.data;
|
||||
file->len = fram.len;
|
||||
#if HTTPD_FS_STATISTICS==1 //increment count in linked list field if it is in RAM
|
||||
f->count++;
|
||||
}
|
||||
return f->count;
|
||||
}
|
||||
++i
|
||||
#elif HTTPD_FS_STATISTICS==2 //increment count in RAM array when linked list is in flash
|
||||
++httpd_filecount[i];
|
||||
}
|
||||
return httpd_filecount[i];
|
||||
}
|
||||
++i;
|
||||
#else //no file statistics
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /*HTTPD_FS_STATISTICS*/
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_fs_init(void)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS && 0 //count will already be zero at boot
|
||||
u16_t i;
|
||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
|
||||
count[i] = 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if HTTPD_FS_STATISTICS && 0 //Not needed, httpd_fs_open returns count
|
||||
u16_t
|
||||
httpd_fs_count(char *name)
|
||||
{
|
||||
struct httpd_fsdata_file_noconst *f,fram;
|
||||
u16_t i;
|
||||
|
||||
i = 0;
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)fram.next) {
|
||||
httpd_memcpy(&fram,f,sizeof(fram));
|
||||
if(httpd_strcmp(name, fram.name) == 0) {
|
||||
#if HTTPD_FS_STATISTICS==1
|
||||
return f->count;
|
||||
#elif HTTPD_FS_STATISTICS==2
|
||||
return count[i];
|
||||
#endif
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
87
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs.h
Normal file
87
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fs.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fs.h,v 1.3 2009/07/23 16:16:07 dak664 Exp $
|
||||
*/
|
||||
#ifndef __HTTPD_FS_H__
|
||||
#define __HTTPD_FS_H__
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
//#define HTTPD_FS_STATISTICS 1 //Puts count in file system
|
||||
#define HTTPD_FS_STATISTICS 2 //Puts count in RAM array
|
||||
|
||||
#if HTTPD_FS_STATISTICS==2
|
||||
extern u16_t httpd_filecount[];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#if COFFEE_FILES
|
||||
#include "cfs-coffee-arch.h"
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
struct httpd_fs_file {
|
||||
char *data;
|
||||
int len;
|
||||
};
|
||||
/* Initialize the file system and set statistics to zero */
|
||||
void httpd_fs_init(void);
|
||||
/* Returns root of http files in program flash */
|
||||
void* httpd_fs_get_root();
|
||||
/* Returns size of http files in any flash */
|
||||
u16_t httpd_fs_get_size();
|
||||
/* Open a file in any flash and return statistics if enabled.
|
||||
If file is allocated by caller it will be filled in.
|
||||
If NULL, just file stats are returned.
|
||||
*/
|
||||
u16_t httpd_fs_open(const char *name, struct httpd_fs_file *file);
|
||||
|
||||
#if COFFEE_FILES
|
||||
/* Coffee file system can be static or dynamic. If static, new files
|
||||
can not be created and rewrites of an existing file can not be
|
||||
made beyond the initial allocation.
|
||||
*/
|
||||
#define httpd_fs_cpy avr_httpd_fs_cpy
|
||||
#define httpd_fs_getchar avr_httpd_fs_getchar
|
||||
#define httpd_fs_strcmp avr_httpd_fs_strcmp
|
||||
#define httpd_fs_strchr avr_httpd_fs_strchr
|
||||
|
||||
#else
|
||||
/* These will fail if the web content is above 64K in program flash */
|
||||
#define httpd_fs_cpy memcpy_P
|
||||
#define httpd_fs_strcmp strcmp_P
|
||||
#define httpd_fs_strchr strchr_P
|
||||
#define httpd_fs_getchar(x) pgm_read_byte(x)
|
||||
#endif
|
||||
|
||||
#endif /* __HTTPD_FS_H__ */
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="white"><center><h1>404 - file not found</h1><h3>Go <a href="/">here</a> instead.</h3></center></body></html>
|
Binary file not shown.
After Width: | Height: | Size: 353 B |
@ -0,0 +1,5 @@
|
||||
%!: /header.html
|
||||
<h1>File statistics</h1><br><table width="100%"><tr align="left"><th>Name</th><th>Accesses</th></tr>
|
||||
%! file-stats *
|
||||
</table>
|
||||
%!: /footer.html
|
@ -0,0 +1 @@
|
||||
</div></body></html>
|
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<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="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>
|
@ -0,0 +1,3 @@
|
||||
%!: /header.html
|
||||
<p class="intro">These pages are from a webserver running under the <a href="http://www.sics.se/contiki/">Contiki operating system</a>.
|
||||
%! file-stats .
|
@ -0,0 +1,7 @@
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
/* Link layer ipv6 address will become fe80::11:22ff:fe33:4455 */
|
||||
uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
|
||||
uint8_t server_name[16] EEMEM = "Contiki-Raven";
|
||||
uint8_t domain_name[30] EEMEM = "localhost";
|
||||
|
@ -0,0 +1,5 @@
|
||||
%!: /header.html
|
||||
<h1>System processes</h1><br><table width="100%"><tr><th>ID</th><th>Name</th><th>Thread</th><th>Process state</th></tr>
|
||||
%! processes
|
||||
</table>
|
||||
%! file-stats .
|
@ -0,0 +1,2 @@
|
||||
user-agent: *
|
||||
Disallow: /
|
@ -0,0 +1,4 @@
|
||||
%!: /header.html
|
||||
<h1>Sensor Readings</h1><br>
|
||||
%! sensors
|
||||
%! file-stats .
|
@ -0,0 +1,11 @@
|
||||
%!: /header.html
|
||||
<h4>Addresses</h4>
|
||||
%! addresses
|
||||
<h4>Neighbors</h4>
|
||||
%! neighbors
|
||||
<h4>Routes</h4>
|
||||
%! routes
|
||||
<h4>Sensors</h4>
|
||||
%! sensors
|
||||
</table>
|
||||
%! file-stats .
|
@ -0,0 +1,22 @@
|
||||
h1{text-align:center;font-size:14pt;font-family:arial,helvetica;font-weight:bold;padding:10px;}
|
||||
body{background-color:#fffeec;color:black;font-size:8pt;font-family:arial,helvetica;}
|
||||
.wrap{width:98%;margin:0 auto;text-align:left;font-family:arial,helvetica;}
|
||||
.menublock{margin:4px;width:15%;float:left;padding:10px;border:solid 1px;background-color:#fffcd2;text-align:left;font-size:9pt;font-family:arial,helvetica;}
|
||||
.contentblock{margin:4px;width:50%;float:left;padding:10px;border:1px dotted;background-color:white;font-size:8pt;font-family:arial,helvetica;}
|
||||
.newsblock{margin:4px;width:24%;float:left;padding:10px;border:solid 1px;background-color:#fffcd2;text-align:left;font-size:8pt;font-family:arial,helvetica;}
|
||||
.printable{margin:4px;width:24%;float:left;padding:10px;border:0;background-color:#fffeec;text-align:right;font-size:8pt;font-family:arial,helvetica;}
|
||||
div.rfig{border:solid 1px; text-align:left;padding:10px;margin:10px;font-size:8pt;float:right;}
|
||||
pre.example{border:solid 1px; padding:10px;margin:10px;text-align:left;font-size:8pt;font-family:arial,helvetica;white-space:pre;}
|
||||
p.intro{margin-left:20px;margin-right:20px;font-size:10pt;font-family:arial,helvetica;}
|
||||
p.clink{font-size:12pt;font-family:courier,monospace; text-align:center;}
|
||||
p.clink9{font-size:9pt;font-family:courier,monospace;text-align:center;}
|
||||
p.related{font-size:10pt;font-family:arial,helvetica;text-align:center;}
|
||||
img.right{float:right;margin:10px;}
|
||||
img.left{float:left;margin:10px;}
|
||||
p.fig{border:solid 1px;text-align:center;padding:10px;margin:10px;font-size:7pt;}
|
||||
p.rfig{border:solid 1px;text-align:center;padding:10px;margin:10px;font-size:7pt;float:right;}
|
||||
p.lfig{border:solid 1px;text-align:center;padding:10px;margin:10px;font-size:7pt;float:left;}
|
||||
p{padding-left:10px;}
|
||||
p.mailaddr{padding-left:10px;font-size:7pt;font-family:courier,terminal;text-align:right;}
|
||||
p.right{text-align:right;}
|
||||
p.border-title{text-align:center;font-size:14pt;padding:0px;margin:4px;margin-bottom:10px;color:black;background-color:#fffcba;border:solid 1px;}
|
@ -0,0 +1,5 @@
|
||||
%!: /header.html
|
||||
<h1>Current connections</h1><br><table width="100%"><tr><th>Local</th><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
|
||||
%! tcp-connections
|
||||
</table>
|
||||
%! file-stats .
|
@ -0,0 +1 @@
|
||||
<html><body><form action="upload.html" enctype="multipart/form-data" method="post"><input name="userfile" type="file" size="50" /><input value="Upload" type="submit" /></form></body></html>
|
643
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fsdata.c
Normal file
643
platform/avr-atmega128rfa1/apps/raven-webserver/httpd-fsdata.c
Normal file
@ -0,0 +1,643 @@
|
||||
/*********Generated by contiki/tools/makefsdata on 2011-02-06*********/
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
/* Link layer ipv6 address will become fe80::2 */
|
||||
uint8_t mac_address[8] EEMEM = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
|
||||
uint8_t server_name[16] EEMEM = "huginn";
|
||||
uint8_t domain_name[30] EEMEM = "localhost";
|
||||
|
||||
const char data_404_html[140] PROGMEM = {
|
||||
/* /404.html */
|
||||
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d,
|
||||
0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, 0x3e, 0x3c, 0x63,
|
||||
0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x68, 0x31, 0x3e,
|
||||
0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x68, 0x33, 0x3e, 0x47,
|
||||
0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d,
|
||||
0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64,
|
||||
0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0x3c, 0x2f, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x00};
|
||||
|
||||
const char data_favicon_png[367] PROGMEM = {
|
||||
/* /favicon.png */
|
||||
0x2f, 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x6e, 0x67, 0x00,
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10,
|
||||
0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f,
|
||||
0xf3, 0xff, 0x61, 0x00, 0x00, 0x01, 0x28, 0x49, 0x44, 0x41,
|
||||
0x54, 0x78, 0xda, 0x63, 0xf8, 0x4f, 0x21, 0x60, 0x18, 0x7a,
|
||||
0x06, 0xbc, 0xff, 0xfc, 0xfe, 0xff, 0xb1, 0xc3, 0x7b, 0xff,
|
||||
0x6f, 0xdd, 0xb6, 0xf5, 0xff, 0xf3, 0xc7, 0xf7, 0x70, 0x18,
|
||||
0xf0, 0x1b, 0x53, 0x68, 0xce, 0xbc, 0x39, 0xff, 0xa3, 0x12,
|
||||
0x93, 0xff, 0x7b, 0x05, 0x06, 0xfd, 0xf7, 0xf2, 0x75, 0xfa,
|
||||
0x5f, 0x5c, 0x99, 0xfd, 0x7f, 0xef, 0xbe, 0xbd, 0xd8, 0x0d,
|
||||
0xf8, 0xfe, 0xfd, 0xfb, 0xff, 0x96, 0xb6, 0x9e, 0xff, 0xd7,
|
||||
0x6e, 0xdf, 0x03, 0x1b, 0xd6, 0xd2, 0xd5, 0xf3, 0xdf, 0xd0,
|
||||
0xc6, 0xf2, 0xbf, 0x93, 0xab, 0xd3, 0xff, 0xa8, 0xd8, 0xa0,
|
||||
0xff, 0xc5, 0xa5, 0xd9, 0xff, 0xcf, 0x9d, 0x3e, 0x06, 0x96,
|
||||
0xc3, 0xe9, 0x85, 0xec, 0xc2, 0x62, 0xa0, 0x6d, 0x51, 0xff,
|
||||
0xbd, 0x42, 0xa3, 0xfe, 0x6b, 0x1a, 0x68, 0x82, 0x6d, 0xcd,
|
||||
0xce, 0x4d, 0xfe, 0xbf, 0x76, 0xd5, 0x52, 0x14, 0x17, 0x62,
|
||||
0x18, 0x70, 0xef, 0xfe, 0xf3, 0xff, 0x4b, 0x57, 0xad, 0x05,
|
||||
0x3b, 0x57, 0x51, 0x43, 0x13, 0x8c, 0x2d, 0x81, 0xb6, 0x67,
|
||||
0x17, 0x02, 0x9d, 0xbc, 0x6b, 0x2b, 0xfe, 0x40, 0x04, 0x05,
|
||||
0x8c, 0x93, 0xa7, 0x17, 0xd8, 0xb9, 0x86, 0x26, 0x86, 0x40,
|
||||
0x8d, 0x4e, 0x40, 0xdb, 0x0d, 0xff, 0x27, 0x67, 0x66, 0xff,
|
||||
0xff, 0xfe, 0xf9, 0x3b, 0xfe, 0x58, 0x80, 0x6b, 0xb6, 0x00,
|
||||
0xfa, 0xd5, 0x17, 0xe4, 0xd7, 0xa8, 0xff, 0x53, 0x66, 0x4d,
|
||||
0x01, 0x7b, 0x45, 0x51, 0x47, 0xf3, 0x7f, 0x4b, 0x53, 0xcb,
|
||||
0xff, 0xe7, 0xcf, 0x9f, 0x63, 0x37, 0x60, 0xe9, 0xb2, 0xa5,
|
||||
0x40, 0xff, 0x7a, 0x01, 0xfd, 0xe9, 0xf5, 0x3f, 0x39, 0x35,
|
||||
0xf9, 0x7f, 0x4f, 0x1f, 0x30, 0x00, 0xaf, 0x5f, 0x03, 0x2b,
|
||||
0x68, 0xe9, 0x6a, 0x81, 0xba, 0xc6, 0xf2, 0x7f, 0x0f, 0x30,
|
||||
0x30, 0xb1, 0x1a, 0x00, 0xf2, 0xdb, 0x94, 0x49, 0x3d, 0xff,
|
||||
0xb7, 0x02, 0x69, 0x74, 0xa7, 0x2e, 0x5d, 0x36, 0x07, 0x1c,
|
||||
0xea, 0xc9, 0x99, 0xc9, 0xc0, 0xf8, 0x3f, 0x46, 0x5e, 0x42,
|
||||
0xfa, 0x0e, 0x4c, 0x3c, 0xd8, 0x9c, 0x3f, 0x44, 0xf3, 0x02,
|
||||
0x3a, 0x00, 0x00, 0x23, 0x68, 0x91, 0xf2, 0x33, 0xf4, 0xe6,
|
||||
0x2c, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
|
||||
0x42, 0x60, 0x82, 0x00};
|
||||
|
||||
const char data_files_shtml[179] PROGMEM = {
|
||||
/* /files.shtml */
|
||||
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x3c, 0x68,
|
||||
0x31, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61,
|
||||
0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68,
|
||||
0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22,
|
||||
0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0x3c, 0x74, 0x72, 0x20,
|
||||
0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x6c, 0x65, 0x66,
|
||||
0x74, 0x22, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d,
|
||||
0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e,
|
||||
0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x0d, 0x0a,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2a, 0x0d, 0x0a, 0x3c, 0x2f, 0x74,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x3a,
|
||||
0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x00};
|
||||
|
||||
const char data_footer_html[34] PROGMEM = {
|
||||
/* /footer.html */
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x3c, 0x2f, 0x62, 0x6f,
|
||||
0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
|
||||
0x00};
|
||||
|
||||
const char data_header_html[809] PROGMEM = {
|
||||
/* /header.html */
|
||||
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
|
||||
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
|
||||
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
|
||||
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
|
||||
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
|
||||
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
|
||||
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
|
||||
0x22, 0x3e, 0x0d, 0x0a, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
|
||||
0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74,
|
||||
0x6c, 0x65, 0x3e, 0x48, 0x75, 0x67, 0x69, 0x6e, 0x6e, 0x3c,
|
||||
0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x3c,
|
||||
0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22,
|
||||
0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, 0x65, 0x65, 0x74,
|
||||
0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65,
|
||||
0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0x22, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65,
|
||||
0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x3c, 0x6c, 0x69, 0x6e,
|
||||
0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x69, 0x63, 0x6f,
|
||||
0x6e, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x66,
|
||||
0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x6e, 0x67,
|
||||
0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x6d,
|
||||
0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x0d,
|
||||
0x0a, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x62,
|
||||
0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x3d, 0x22, 0x23, 0x66, 0x66, 0x66, 0x65, 0x65, 0x63,
|
||||
0x22, 0x20, 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c,
|
||||
0x61, 0x63, 0x6b, 0x22, 0x3e, 0x0d, 0x0a, 0x3c, 0x64, 0x69,
|
||||
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
|
||||
0x65, 0x6e, 0x75, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e,
|
||||
0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73,
|
||||
0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 0x3c, 0x70,
|
||||
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x62, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 0x65,
|
||||
0x22, 0x3e, 0x4d, 0x65, 0x6e, 0x75, 0x3c, 0x2f, 0x70, 0x3e,
|
||||
0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22,
|
||||
0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68,
|
||||
0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 0x72,
|
||||
0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68,
|
||||
0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x53,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c,
|
||||
0x62, 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x61,
|
||||
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61,
|
||||
0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73,
|
||||
0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x53,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 0x6f, 0x63,
|
||||
0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c,
|
||||
0x62, 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x53, 0x65, 0x6e, 0x73,
|
||||
0x6f, 0x72, 0x20, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67,
|
||||
0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x70, 0x3e, 0x3c,
|
||||
0x2f, 0x64, 0x69, 0x76, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76,
|
||||
0x3e, 0x0d, 0x0a, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
|
||||
0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65,
|
||||
0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0x3c,
|
||||
0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x62,
|
||||
0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c,
|
||||
0x65, 0x22, 0x3e, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65,
|
||||
0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61,
|
||||
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74,
|
||||
0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69,
|
||||
0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x74,
|
||||
0x69, 0x6b, 0x69, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x77, 0x65,
|
||||
0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x6f,
|
||||
0x6e, 0x20, 0x48, 0x75, 0x67, 0x69, 0x6e, 0x6e, 0x21, 0x3c,
|
||||
0x2f, 0x70, 0x3e, 0x0d, 0x0a, 0x00};
|
||||
|
||||
const char data_index_html[1053] PROGMEM = {
|
||||
/* /index.html */
|
||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x25, 0x21, 0x3a, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72,
|
||||
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x3c, 0x70, 0x20,
|
||||
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x69, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x22, 0x3e, 0x49, 0x20, 0x61, 0x6d, 0x20, 0x61,
|
||||
0x6e, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77,
|
||||
0x77, 0x77, 0x2e, 0x61, 0x74, 0x6d, 0x65, 0x6c, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x64, 0x79, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x64, 0x75, 0x63, 0x74, 0x73, 0x2f, 0x74, 0x6f, 0x6f, 0x6c,
|
||||
0x73, 0x5f, 0x63, 0x61, 0x72, 0x64, 0x2e, 0x61, 0x73, 0x70,
|
||||
0x3f, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x5f, 0x69, 0x64,
|
||||
0x3d, 0x36, 0x37, 0x36, 0x26, 0x66, 0x61, 0x6d, 0x69, 0x6c,
|
||||
0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x4d, 0x43, 0x55,
|
||||
0x2b, 0x57, 0x69, 0x72, 0x65, 0x6c, 0x65, 0x73, 0x73, 0x26,
|
||||
0x74, 0x6f, 0x6f, 0x6c, 0x5f, 0x69, 0x64, 0x3d, 0x34, 0x33,
|
||||
0x39, 0x35, 0x22, 0x3e, 0x41, 0x74, 0x6d, 0x65, 0x6c, 0x20,
|
||||
0x52, 0x61, 0x76, 0x65, 0x6e, 0x3c, 0x2f, 0x61, 0x3e, 0x0d,
|
||||
0x0a, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x20,
|
||||
0x74, 0x68, 0x65, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e,
|
||||
0x73, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69,
|
||||
0x2f, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61,
|
||||
0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65,
|
||||
0x6d, 0x2e, 0x20, 0x49, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20,
|
||||
0x61, 0x20, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x20, 0x31, 0x35,
|
||||
0x30, 0x4b, 0x42, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79,
|
||||
0x20, 0x62, 0x75, 0x74, 0x20, 0x49, 0x20, 0x61, 0x6d, 0x20,
|
||||
0x76, 0x65, 0x72, 0x79, 0x20, 0x66, 0x61, 0x73, 0x74, 0x21,
|
||||
0x0d, 0x0a, 0x3c, 0x62, 0x72, 0x3e, 0x49, 0x20, 0x61, 0x6d,
|
||||
0x20, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x20, 0x61, 0x66, 0x74,
|
||||
0x65, 0x72, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x65,
|
||||
0x6e, 0x2e, 0x77, 0x69, 0x6b, 0x69, 0x70, 0x65, 0x64, 0x69,
|
||||
0x61, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x77, 0x69, 0x6b, 0x69,
|
||||
0x2f, 0x48, 0x75, 0x67, 0x69, 0x6e, 0x6e, 0x5f, 0x61, 0x6e,
|
||||
0x64, 0x5f, 0x4d, 0x75, 0x6e, 0x69, 0x6e, 0x6e, 0x22, 0x3e,
|
||||
0x61, 0x20, 0x6d, 0x79, 0x74, 0x68, 0x69, 0x63, 0x61, 0x6c,
|
||||
0x20, 0x72, 0x61, 0x76, 0x65, 0x6e, 0x3c, 0x2f, 0x61, 0x3e,
|
||||
0x20, 0x77, 0x68, 0x6f, 0x20, 0x67, 0x61, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20,
|
||||
0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
|
||||
0x65, 0x6e, 0x2e, 0x77, 0x69, 0x6b, 0x69, 0x70, 0x65, 0x64,
|
||||
0x69, 0x61, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x77, 0x69, 0x6b,
|
||||
0x69, 0x2f, 0x4f, 0x64, 0x69, 0x6e, 0x22, 0x3e, 0x4e, 0x6f,
|
||||
0x72, 0x73, 0x65, 0x20, 0x47, 0x6f, 0x64, 0x20, 0x4f, 0x64,
|
||||
0x69, 0x6e, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0x0d, 0x0a, 0x3c,
|
||||
0x62, 0x72, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x59, 0x6f, 0x75,
|
||||
0x20, 0x6d, 0x69, 0x67, 0x68, 0x74, 0x20, 0x61, 0x6c, 0x73,
|
||||
0x6f, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20,
|
||||
0x76, 0x69, 0x73, 0x69, 0x74, 0x20, 0x6d, 0x79, 0x20, 0x63,
|
||||
0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x3c,
|
||||
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x68, 0x74, 0x74,
|
||||
0x70, 0x3a, 0x2f, 0x2f, 0x6d, 0x75, 0x6e, 0x69, 0x6e, 0x6e,
|
||||
0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
|
||||
0x3e, 0x4d, 0x75, 0x6e, 0x69, 0x6e, 0x6e, 0x3c, 0x2f, 0x61,
|
||||
0x3e, 0x2e, 0x0d, 0x0a, 0x3c, 0x62, 0x72, 0x3e, 0x57, 0x65,
|
||||
0x20, 0x73, 0x68, 0x61, 0x72, 0x65, 0x20, 0x69, 0x6e, 0x66,
|
||||
0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75,
|
||||
0x73, 0x69, 0x6e, 0x67, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x70, 0x76, 0x36, 0x2e,
|
||||
0x6f, 0x72, 0x67, 0x22, 0x3e, 0x69, 0x70, 0x76, 0x36, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x0d, 0x0a, 0x20, 0x74, 0x68, 0x72, 0x6f,
|
||||
0x75, 0x67, 0x68, 0x20, 0x61, 0x20, 0x6c, 0x6f, 0x77, 0x20,
|
||||
0x70, 0x6f, 0x77, 0x65, 0x72, 0x20, 0x20, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
|
||||
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65,
|
||||
0x61, 0x72, 0x63, 0x68, 0x3f, 0x71, 0x3d, 0x36, 0x6c, 0x6f,
|
||||
0x77, 0x70, 0x61, 0x6e, 0x22, 0x3e, 0x36, 0x6c, 0x6f, 0x77,
|
||||
0x50, 0x41, 0x4e, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x77, 0x69,
|
||||
0x72, 0x65, 0x6c, 0x65, 0x73, 0x73, 0x20, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
|
||||
0x3a, 0x2f, 0x2f, 0x65, 0x6e, 0x2e, 0x77, 0x69, 0x6b, 0x69,
|
||||
0x70, 0x65, 0x64, 0x69, 0x61, 0x2e, 0x6f, 0x72, 0x67, 0x2f,
|
||||
0x77, 0x69, 0x6b, 0x69, 0x2f, 0x49, 0x45, 0x45, 0x45, 0x5f,
|
||||
0x38, 0x30, 0x32, 0x2e, 0x31, 0x35, 0x2e, 0x34, 0x22, 0x3e,
|
||||
0x38, 0x30, 0x32, 0x2e, 0x31, 0x35, 0x2e, 0x34, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x20, 0x31, 0x30, 0x4b, 0x62, 0x70, 0x73, 0x20,
|
||||
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x20, 0x0d,
|
||||
0x0a, 0x3c, 0x62, 0x72, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x3c,
|
||||
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74,
|
||||
0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73,
|
||||
0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x25, 0x37, 0x45,
|
||||
0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69,
|
||||
0x6b, 0x69, 0x2f, 0x64, 0x6f, 0x63, 0x73, 0x2d, 0x75, 0x69,
|
||||
0x70, 0x76, 0x36, 0x2f, 0x61, 0x30, 0x31, 0x31, 0x30, 0x38,
|
||||
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4a, 0x61, 0x63,
|
||||
0x6b, 0x64, 0x61, 0x77, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69,
|
||||
0x73, 0x20, 0x6f, 0x75, 0x72, 0x20, 0x6c, 0x69, 0x6e, 0x6b,
|
||||
0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x57, 0x65,
|
||||
0x62, 0x2e, 0x20, 0x49, 0x66, 0x20, 0x68, 0x65, 0x20, 0x69,
|
||||
0x73, 0x20, 0x6f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x20,
|
||||
0x79, 0x6f, 0x75, 0x20, 0x63, 0x61, 0x6e, 0x27, 0x74, 0x20,
|
||||
0x67, 0x65, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x73, 0x21,
|
||||
0x0d, 0x0a, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x62, 0x72, 0x3e,
|
||||
0x54, 0x68, 0x6f, 0x75, 0x67, 0x68, 0x74, 0x20, 0x72, 0x75,
|
||||
0x6c, 0x65, 0x73, 0x21, 0x20, 0x41, 0x77, 0x77, 0x6b, 0x21,
|
||||
0x3c, 0x2f, 0x50, 0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e,
|
||||
0x00};
|
||||
|
||||
const char data_process_shtml[196] PROGMEM = {
|
||||
/* /process.shtml */
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x3c, 0x68,
|
||||
0x31, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70,
|
||||
0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f,
|
||||
0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61,
|
||||
0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d,
|
||||
0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74,
|
||||
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54,
|
||||
0x68, 0x72, 0x65, 0x61, 0x64, 0x3c, 0x2f, 0x74, 0x68, 0x3e,
|
||||
0x3c, 0x74, 0x68, 0x3e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73,
|
||||
0x73, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x74,
|
||||
0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x0d, 0x0a, 0x25,
|
||||
0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65,
|
||||
0x73, 0x0d, 0x0a, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65,
|
||||
0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e, 0x0d, 0x0a,
|
||||
0x00};
|
||||
|
||||
const char data_robots_txt[39] PROGMEM = {
|
||||
/* /robots.txt */
|
||||
0x2f, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x73, 0x2e, 0x74, 0x78, 0x74, 0x00,
|
||||
0x75, 0x73, 0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74,
|
||||
0x3a, 0x20, 0x2a, 0x0d, 0x0a, 0x44, 0x69, 0x73, 0x61, 0x6c,
|
||||
0x6c, 0x6f, 0x77, 0x3a, 0x20, 0x2f, 0x00};
|
||||
|
||||
const char data_sensor_shtml[90] PROGMEM = {
|
||||
/* /sensor.shtml */
|
||||
0x2f, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x3c, 0x68,
|
||||
0x31, 0x3e, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x20, 0x52,
|
||||
0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x3c, 0x2f, 0x68,
|
||||
0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x0d, 0x0a, 0x25, 0x21,
|
||||
0x20, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x0d, 0x0a,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2e, 0x00};
|
||||
|
||||
const char data_status_shtml[209] PROGMEM = {
|
||||
/* /status.shtml */
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x3c, 0x68,
|
||||
0x34, 0x3e, 0x4d, 0x79, 0x20, 0x41, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e, 0x0d,
|
||||
0x0a, 0x25, 0x21, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
|
||||
0x73, 0x65, 0x73, 0x0d, 0x0a, 0x3c, 0x68, 0x34, 0x3e, 0x4d,
|
||||
0x79, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x20, 0x66, 0x72,
|
||||
0x69, 0x65, 0x6e, 0x64, 0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e,
|
||||
0x0d, 0x0a, 0x25, 0x21, 0x20, 0x6e, 0x65, 0x69, 0x67, 0x68,
|
||||
0x62, 0x6f, 0x72, 0x73, 0x0d, 0x0a, 0x3c, 0x68, 0x34, 0x3e,
|
||||
0x4d, 0x79, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20, 0x66,
|
||||
0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x3c, 0x2f, 0x68, 0x34,
|
||||
0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x20, 0x72, 0x6f, 0x75, 0x74,
|
||||
0x65, 0x73, 0x0d, 0x0a, 0x3c, 0x68, 0x34, 0x3e, 0x4d, 0x79,
|
||||
0x20, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x3c, 0x2f,
|
||||
0x68, 0x34, 0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x20, 0x73, 0x65,
|
||||
0x6e, 0x73, 0x6f, 0x72, 0x73, 0x0d, 0x0a, 0x3c, 0x2f, 0x74,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x20,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73,
|
||||
0x20, 0x2e, 0x0d, 0x0a, 0x00};
|
||||
|
||||
const char data_style_css[2063] PROGMEM = {
|
||||
/* /style.css */
|
||||
0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x00,
|
||||
0x68, 0x31, 0x7b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c,
|
||||
0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72,
|
||||
0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x3a, 0x31, 0x34, 0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74,
|
||||
0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72,
|
||||
0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74,
|
||||
0x69, 0x63, 0x61, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77,
|
||||
0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64,
|
||||
0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31,
|
||||
0x30, 0x70, 0x78, 0x3b, 0x7d, 0x0d, 0x0a, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x7b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75,
|
||||
0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23,
|
||||
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x3b, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38,
|
||||
0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
|
||||
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c,
|
||||
0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61,
|
||||
0x3b, 0x7d, 0x0d, 0x0a, 0x2e, 0x77, 0x72, 0x61, 0x70, 0x7b,
|
||||
0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x39, 0x38, 0x25, 0x3b,
|
||||
0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x30, 0x20, 0x61,
|
||||
0x75, 0x74, 0x6f, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61,
|
||||
0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c,
|
||||
0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65,
|
||||
0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x7d, 0x0d,
|
||||
0x0a, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x7b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x34,
|
||||
0x70, 0x78, 0x3b, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x31,
|
||||
0x35, 0x25, 0x3b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c,
|
||||
0x65, 0x66, 0x74, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e,
|
||||
0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x62, 0x6f, 0x72,
|
||||
0x64, 0x65, 0x72, 0x3a, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20,
|
||||
0x31, 0x70, 0x78, 0x3b, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72,
|
||||
0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
|
||||
0x3a, 0x23, 0x66, 0x66, 0x66, 0x63, 0x64, 0x32, 0x3b, 0x74,
|
||||
0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a,
|
||||
0x6c, 0x65, 0x66, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70, 0x74, 0x3b, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79,
|
||||
0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c,
|
||||
0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x7d, 0x0d, 0x0a,
|
||||
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x7b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e,
|
||||
0x3a, 0x34, 0x70, 0x78, 0x3b, 0x77, 0x69, 0x64, 0x74, 0x68,
|
||||
0x3a, 0x35, 0x30, 0x25, 0x3b, 0x66, 0x6c, 0x6f, 0x61, 0x74,
|
||||
0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x70, 0x61, 0x64, 0x64,
|
||||
0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x62,
|
||||
0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x31, 0x70, 0x78, 0x20,
|
||||
0x64, 0x6f, 0x74, 0x74, 0x65, 0x64, 0x3b, 0x62, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f,
|
||||
0x6c, 0x6f, 0x72, 0x3a, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
|
||||
0x38, 0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66,
|
||||
0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61,
|
||||
0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63,
|
||||
0x61, 0x3b, 0x7d, 0x0d, 0x0a, 0x2e, 0x6e, 0x65, 0x77, 0x73,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x7b, 0x6d, 0x61, 0x72, 0x67,
|
||||
0x69, 0x6e, 0x3a, 0x34, 0x70, 0x78, 0x3b, 0x77, 0x69, 0x64,
|
||||
0x74, 0x68, 0x3a, 0x32, 0x34, 0x25, 0x3b, 0x66, 0x6c, 0x6f,
|
||||
0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x70, 0x61,
|
||||
0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 0x78,
|
||||
0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x73, 0x6f,
|
||||
0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 0x62, 0x61,
|
||||
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x63,
|
||||
0x64, 0x32, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c,
|
||||
0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38,
|
||||
0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
|
||||
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c,
|
||||
0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61,
|
||||
0x3b, 0x7d, 0x0d, 0x0a, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x7b, 0x6d, 0x61, 0x72, 0x67, 0x69,
|
||||
0x6e, 0x3a, 0x34, 0x70, 0x78, 0x3b, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3a, 0x32, 0x34, 0x25, 0x3b, 0x66, 0x6c, 0x6f, 0x61,
|
||||
0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x70, 0x61, 0x64,
|
||||
0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b,
|
||||
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x30, 0x3b, 0x62,
|
||||
0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d,
|
||||
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66,
|
||||
0x65, 0x65, 0x63, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61,
|
||||
0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x3a, 0x38, 0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d,
|
||||
0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69,
|
||||
0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69,
|
||||
0x63, 0x61, 0x3b, 0x7d, 0x0d, 0x0a, 0x64, 0x69, 0x76, 0x2e,
|
||||
0x72, 0x66, 0x69, 0x67, 0x7b, 0x62, 0x6f, 0x72, 0x64, 0x65,
|
||||
0x72, 0x3a, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70,
|
||||
0x78, 0x3b, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c,
|
||||
0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0x70,
|
||||
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70,
|
||||
0x78, 0x3b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31,
|
||||
0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0x66, 0x6c,
|
||||
0x6f, 0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b,
|
||||
0x7d, 0x0d, 0x0a, 0x70, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61,
|
||||
0x6d, 0x70, 0x6c, 0x65, 0x7b, 0x62, 0x6f, 0x72, 0x64, 0x65,
|
||||
0x72, 0x3a, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70,
|
||||
0x78, 0x3b, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67,
|
||||
0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x6d, 0x61, 0x72, 0x67,
|
||||
0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x74, 0x65,
|
||||
0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c,
|
||||
0x65, 0x66, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a,
|
||||
0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76,
|
||||
0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x77, 0x68, 0x69, 0x74,
|
||||
0x65, 0x2d, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3a, 0x70, 0x72,
|
||||
0x65, 0x3b, 0x7d, 0x0d, 0x0a, 0x70, 0x2e, 0x69, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x7b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d,
|
||||
0x6c, 0x65, 0x66, 0x74, 0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b,
|
||||
0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67,
|
||||
0x68, 0x74, 0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, 0x30,
|
||||
0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
|
||||
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c,
|
||||
0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61,
|
||||
0x3b, 0x7d, 0x0d, 0x0a, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e,
|
||||
0x6b, 0x7b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x3a, 0x31, 0x32, 0x70, 0x74, 0x3b, 0x66, 0x6f, 0x6e,
|
||||
0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63,
|
||||
0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e,
|
||||
0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63,
|
||||
0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x7d, 0x0d, 0x0a, 0x70,
|
||||
0x2e, 0x63, 0x6c, 0x69, 0x6e, 0x6b, 0x39, 0x7b, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70,
|
||||
0x74, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d,
|
||||
0x69, 0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72, 0x69, 0x65,
|
||||
0x72, 0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70, 0x61, 0x63,
|
||||
0x65, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b,
|
||||
0x7d, 0x0d, 0x0a, 0x70, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74,
|
||||
0x65, 0x64, 0x7b, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69,
|
||||
0x7a, 0x65, 0x3a, 0x31, 0x30, 0x70, 0x74, 0x3b, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a,
|
||||
0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76,
|
||||
0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x74, 0x65, 0x78, 0x74,
|
||||
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x3b, 0x7d, 0x0d, 0x0a, 0x69, 0x6d, 0x67,
|
||||
0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0x7b, 0x66, 0x6c, 0x6f,
|
||||
0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x6d,
|
||||
0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78,
|
||||
0x3b, 0x7d, 0x0d, 0x0a, 0x69, 0x6d, 0x67, 0x2e, 0x6c, 0x65,
|
||||
0x66, 0x74, 0x7b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c,
|
||||
0x65, 0x66, 0x74, 0x3b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e,
|
||||
0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x7d, 0x0d, 0x0a, 0x70,
|
||||
0x2e, 0x66, 0x69, 0x67, 0x7b, 0x62, 0x6f, 0x72, 0x64, 0x65,
|
||||
0x72, 0x3a, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70,
|
||||
0x78, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b,
|
||||
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30,
|
||||
0x70, 0x78, 0x3b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a,
|
||||
0x31, 0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 0x7d,
|
||||
0x0d, 0x0a, 0x70, 0x2e, 0x72, 0x66, 0x69, 0x67, 0x7b, 0x62,
|
||||
0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x73, 0x6f, 0x6c, 0x69,
|
||||
0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 0x74, 0x65, 0x78, 0x74,
|
||||
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e,
|
||||
0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x6d, 0x61, 0x72,
|
||||
0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x37,
|
||||
0x70, 0x74, 0x3b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x72,
|
||||
0x69, 0x67, 0x68, 0x74, 0x3b, 0x7d, 0x0d, 0x0a, 0x70, 0x2e,
|
||||
0x6c, 0x66, 0x69, 0x67, 0x7b, 0x62, 0x6f, 0x72, 0x64, 0x65,
|
||||
0x72, 0x3a, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70,
|
||||
0x78, 0x3b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b,
|
||||
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30,
|
||||
0x70, 0x78, 0x3b, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a,
|
||||
0x31, 0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 0x66,
|
||||
0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b,
|
||||
0x7d, 0x0d, 0x0a, 0x70, 0x7b, 0x70, 0x61, 0x64, 0x64, 0x69,
|
||||
0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a, 0x31, 0x30,
|
||||
0x70, 0x78, 0x3b, 0x7d, 0x0d, 0x0a, 0x70, 0x2e, 0x6d, 0x61,
|
||||
0x69, 0x6c, 0x61, 0x64, 0x64, 0x72, 0x7b, 0x70, 0x61, 0x64,
|
||||
0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a,
|
||||
0x31, 0x30, 0x70, 0x78, 0x3b, 0x66, 0x6f, 0x6e, 0x74, 0x2d,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79,
|
||||
0x3a, 0x63, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x74,
|
||||
0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x3b, 0x74, 0x65,
|
||||
0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x72,
|
||||
0x69, 0x67, 0x68, 0x74, 0x3b, 0x7d, 0x0d, 0x0a, 0x70, 0x2e,
|
||||
0x72, 0x69, 0x67, 0x68, 0x74, 0x7b, 0x74, 0x65, 0x78, 0x74,
|
||||
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67,
|
||||
0x68, 0x74, 0x3b, 0x7d, 0x0d, 0x0a, 0x70, 0x2e, 0x62, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 0x65,
|
||||
0x7b, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67,
|
||||
0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31,
|
||||
0x34, 0x70, 0x74, 0x3b, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e,
|
||||
0x67, 0x3a, 0x30, 0x70, 0x78, 0x3b, 0x6d, 0x61, 0x72, 0x67,
|
||||
0x69, 0x6e, 0x3a, 0x34, 0x70, 0x78, 0x3b, 0x6d, 0x61, 0x72,
|
||||
0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d,
|
||||
0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0x62, 0x61,
|
||||
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x23, 0x66, 0x66, 0x66, 0x63,
|
||||
0x62, 0x61, 0x3b, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a,
|
||||
0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 0x3b,
|
||||
0x7d, 0x00};
|
||||
|
||||
const char data_tcp_shtml[233] PROGMEM = {
|
||||
/* /tcp.shtml */
|
||||
0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x3c, 0x68,
|
||||
0x31, 0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20,
|
||||
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e,
|
||||
0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64,
|
||||
0x74, 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e,
|
||||
0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f,
|
||||
0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74,
|
||||
0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68,
|
||||
0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68,
|
||||
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46,
|
||||
0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c,
|
||||
0x2f, 0x74, 0x72, 0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x20, 0x74,
|
||||
0x63, 0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x73, 0x0d, 0x0a, 0x3c, 0x2f, 0x74, 0x61,
|
||||
0x62, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x25, 0x21, 0x20, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
|
||||
0x2e, 0x00};
|
||||
|
||||
const char data_upload_html[211] PROGMEM = {
|
||||
/* /upload.html */
|
||||
0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00,
|
||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x3e, 0x0d, 0x0a, 0x3c, 0x66, 0x6f, 0x72, 0x6d, 0x20,
|
||||
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x75, 0x70,
|
||||
0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
|
||||
0x20, 0x65, 0x6e, 0x63, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22,
|
||||
0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f,
|
||||
0x66, 0x6f, 0x72, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x22,
|
||||
0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3d, 0x22, 0x70,
|
||||
0x6f, 0x73, 0x74, 0x22, 0x3e, 0x0d, 0x0a, 0x3c, 0x69, 0x6e,
|
||||
0x70, 0x75, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22,
|
||||
0x75, 0x73, 0x65, 0x72, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x20,
|
||||
0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x22, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x3d, 0x22, 0x35, 0x30,
|
||||
0x22, 0x20, 0x2f, 0x3e, 0x0d, 0x0a, 0x3c, 0x69, 0x6e, 0x70,
|
||||
0x75, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22,
|
||||
0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x20, 0x74, 0x79,
|
||||
0x70, 0x65, 0x3d, 0x22, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74,
|
||||
0x22, 0x20, 0x2f, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x66, 0x6f,
|
||||
0x72, 0x6d, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e,
|
||||
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x00};
|
||||
|
||||
|
||||
/* Structure of linked list (all offsets relative to start of section):
|
||||
struct httpd_fsdata_file {
|
||||
const struct httpd_fsdata_file *next; //actual flash address of next link
|
||||
const char *name; //offset to coffee file name
|
||||
const char *data; //offset to coffee file data
|
||||
const int len; //length of file data
|
||||
#if HTTPD_FS_STATISTICS == 1 //not enabled since list is in PROGMEM
|
||||
u16_t count; //storage for file statistics
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
const struct httpd_fsdata_file file_404_html[] PROGMEM ={{ NULL, data_404_html , data_404_html +10, sizeof(data_404_html) -10}};
|
||||
const struct httpd_fsdata_file file_favicon_png[] PROGMEM ={{ file_404_html, data_favicon_png , data_favicon_png +13, sizeof(data_favicon_png) -13}};
|
||||
const struct httpd_fsdata_file file_files_shtml[] PROGMEM ={{ file_favicon_png, data_files_shtml , data_files_shtml +13, sizeof(data_files_shtml) -13}};
|
||||
const struct httpd_fsdata_file file_footer_html[] PROGMEM ={{ file_files_shtml, data_footer_html , data_footer_html +13, sizeof(data_footer_html) -13}};
|
||||
const struct httpd_fsdata_file file_header_html[] PROGMEM ={{ file_footer_html, data_header_html , data_header_html +13, sizeof(data_header_html) -13}};
|
||||
const struct httpd_fsdata_file file_index_html[] PROGMEM ={{ file_header_html, data_index_html , data_index_html +12, sizeof(data_index_html) -12}};
|
||||
const struct httpd_fsdata_file file_process_shtml[] PROGMEM ={{ file_index_html, data_process_shtml , data_process_shtml +15, sizeof(data_process_shtml) -15}};
|
||||
const struct httpd_fsdata_file file_robots_txt[] PROGMEM ={{ file_process_shtml, data_robots_txt , data_robots_txt +12, sizeof(data_robots_txt) -12}};
|
||||
const struct httpd_fsdata_file file_sensor_shtml[] PROGMEM ={{ file_robots_txt, data_sensor_shtml , data_sensor_shtml +14, sizeof(data_sensor_shtml) -14}};
|
||||
const struct httpd_fsdata_file file_status_shtml[] PROGMEM ={{ file_sensor_shtml, data_status_shtml , data_status_shtml +14, sizeof(data_status_shtml) -14}};
|
||||
const struct httpd_fsdata_file file_style_css[] PROGMEM ={{ file_status_shtml, data_style_css , data_style_css +11, sizeof(data_style_css) -11}};
|
||||
const struct httpd_fsdata_file file_tcp_shtml[] PROGMEM ={{ file_style_css, data_tcp_shtml , data_tcp_shtml +11, sizeof(data_tcp_shtml) -11}};
|
||||
const struct httpd_fsdata_file file_upload_html[] PROGMEM ={{ file_tcp_shtml, data_upload_html , data_upload_html +13, sizeof(data_upload_html) -13}};
|
||||
|
||||
#define HTTPD_FS_ROOT file_upload_html
|
||||
#define HTTPD_FS_NUMFILES 13
|
||||
#define HTTPD_FS_SIZE 5623
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fsdata.h,v 1.2 2009/06/19 17:11:28 dak664 Exp $
|
||||
*/
|
||||
#ifndef __HTTPD_FSDATA_H__
|
||||
#define __HTTPD_FSDATA_H__
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
struct httpd_fsdata_file {
|
||||
const struct httpd_fsdata_file *next;
|
||||
const char *name;
|
||||
const char *data;
|
||||
const int len;
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t count;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
struct httpd_fsdata_file_noconst {
|
||||
struct httpd_fsdata_file *next;
|
||||
char *name;
|
||||
char *data;
|
||||
int len;
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t count;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
#endif /* __HTTPD_FSDATA_H__ */
|
504
platform/avr-atmega128rfa1/apps/raven-webserver/httpd.c
Normal file
504
platform/avr-atmega128rfa1/apps/raven-webserver/httpd.c
Normal file
@ -0,0 +1,504 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* 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.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd.c,v 1.6 2010/12/20 20:06:06 dak664 Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "webserver.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "httpd.h"
|
||||
#include "raven-lcd.h"
|
||||
|
||||
//#include "http-strings.h"
|
||||
#if COFFEE_FILES
|
||||
#include "cfs-coffee-arch.h"
|
||||
#endif /* COFFEE_FILES */
|
||||
|
||||
/* DEBUGLOGIC is a convenient way to debug in a simulator without a tcp/ip connection.
|
||||
* Break the program in the process loop and step from the entry in httpd_appcall.
|
||||
* The input file is forced to /index.html and the output directed to TCPBUF.
|
||||
* If cgi's are invoked define it in httpd-cgi.c as well!
|
||||
* psock_generator_send in /core/net/psock.c must also be modified as follows:
|
||||
* ...
|
||||
* // Wait until all data is sent and acknowledged.
|
||||
* if (!s->sendlen) break; //<---add this line
|
||||
* PT_YIELD_UNTIL(&s->psockpt, uip_acked() || uip_rexmit());
|
||||
* ...
|
||||
*/
|
||||
#define DEBUGLOGIC 0
|
||||
#define DEBUG 0
|
||||
#if DEBUGLOGIC
|
||||
struct httpd_state *sg;
|
||||
#define uip_mss(...) 512
|
||||
#define uip_appdata TCPBUF
|
||||
char TCPBUF[512];
|
||||
#endif
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#if HTTPD_STRING_TYPE==PROGMEM_TYPE
|
||||
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||
#else
|
||||
#define PRINTF printf
|
||||
#endif
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
#ifndef WEBSERVER_CONF_CGI_CONNS
|
||||
#define CONNS 4
|
||||
#else
|
||||
#define CONNS WEBSERVER_CONF_CGI_CONNS
|
||||
#endif /* WEBSERVER_CONF_CGI_CONNS */
|
||||
|
||||
#define STATE_WAITING 0
|
||||
#define STATE_OUTPUT 1
|
||||
|
||||
//#define SEND_STRING(s, str) PSOCK_SEND(s, (uint8_t *)str, (unsigned int)strlen(str))
|
||||
MEMB(conns, struct httpd_state, CONNS);
|
||||
|
||||
/* MAX_SCRIPT_NAME_LENGTH should be at least be the maximum file name length+2 for %!: includes */
|
||||
#define MAX_SCRIPT_NAME_LENGTH 20
|
||||
#define ISO_tab 0x09
|
||||
#define ISO_nl 0x0a
|
||||
#define ISO_cr 0x0d
|
||||
#define ISO_space 0x20
|
||||
#define ISO_bang 0x21
|
||||
#define ISO_percent 0x25
|
||||
#define ISO_period 0x2e
|
||||
#define ISO_slash 0x2f
|
||||
#define ISO_colon 0x3a
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate(void *state)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
s->len = s->file.len;
|
||||
}
|
||||
httpd_fs_cpy(uip_appdata, s->file.data, s->len);
|
||||
#if DEBUGLOGIC
|
||||
return 0;
|
||||
#else
|
||||
return s->len;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
do {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate, s);
|
||||
s->file.len -= s->len;
|
||||
s->file.data += s->len;
|
||||
} while(s->file.len > 0);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_part_of_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
static int oldfilelen, oldlen;
|
||||
static char * olddata;
|
||||
|
||||
//Store stuff that gets clobbered...
|
||||
oldfilelen = s->file.len;
|
||||
oldlen = s->len;
|
||||
olddata = s->file.data;
|
||||
|
||||
//How much to send
|
||||
s->file.len = s->len;
|
||||
|
||||
do {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate, s);
|
||||
s->file.len -= s->len;
|
||||
s->file.data += s->len;
|
||||
} while(s->file.len > 0);
|
||||
|
||||
s->len = oldlen;
|
||||
s->file.len = oldfilelen;
|
||||
s->file.data = olddata;
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
next_scriptstate(struct httpd_state *s)
|
||||
{
|
||||
char *p;
|
||||
/* Skip over any script parameters to the beginning of the next line */
|
||||
if((p = (char *)httpd_fs_strchr(s->scriptptr, ISO_nl)) != NULL) {
|
||||
p += 1;
|
||||
s->scriptlen -= (unsigned short)(p - s->scriptptr);
|
||||
s->scriptptr = p;
|
||||
} else {
|
||||
s->scriptlen = 0;
|
||||
}
|
||||
|
||||
/* char *p;
|
||||
p = strchr(s->scriptptr, ISO_nl) + 1;
|
||||
s->scriptlen -= (unsigned short)(p - s->scriptptr);
|
||||
s->scriptptr = p;*/
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
char *
|
||||
get_scriptname(char *dest, char *fromfile)
|
||||
{
|
||||
uint8_t i=0,skip=1;
|
||||
/* Extract a file or cgi name, trim leading spaces and replace termination with zero */
|
||||
/* Returns number of characters processed up to the next non-tab or space */
|
||||
do {
|
||||
dest[i]=httpd_fs_getchar(fromfile++);
|
||||
if (dest[i]==ISO_colon) {if (!skip) break;} //allow leading colons
|
||||
else if (dest[i]==ISO_tab ) {if (skip) continue;else break;}//skip leading tabs
|
||||
else if (dest[i]==ISO_space) {if (skip) continue;else break;}//skip leading spaces
|
||||
else if (dest[i]==ISO_nl ) break; //nl is preferred delimiter
|
||||
else if (dest[i]==ISO_cr ) break; //some editors insert cr
|
||||
else if (dest[i]==0 ) break; //files are terminated with null
|
||||
else skip=0;
|
||||
i++;
|
||||
} while (i<(MAX_SCRIPT_NAME_LENGTH+1));
|
||||
fromfile--;
|
||||
while ((dest[i]==ISO_space) || (dest[i]==ISO_tab)) dest[i]=httpd_fs_getchar(++fromfile);
|
||||
dest[i]=0;
|
||||
return (fromfile);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static
|
||||
PT_THREAD(handle_script(struct httpd_state *s))
|
||||
{
|
||||
/* Note script includes will attach a leading : to the filename and a trailing zero */
|
||||
static char scriptname[MAX_SCRIPT_NAME_LENGTH+1],*pptr;
|
||||
static uint16_t filelength;
|
||||
|
||||
PT_BEGIN(&s->scriptpt);
|
||||
|
||||
filelength=s->file.len;
|
||||
while(s->file.len > 0) {
|
||||
/* Sanity check */
|
||||
if (s->file.len > filelength) break;
|
||||
|
||||
/* Check if we should start executing a script, flagged by %! */
|
||||
if(httpd_fs_getchar(s->file.data) == ISO_percent &&
|
||||
httpd_fs_getchar(s->file.data + 1) == ISO_bang) {
|
||||
|
||||
/* Extract name, if starts with colon include file else call cgi */
|
||||
s->scriptptr=get_scriptname(scriptname,s->file.data+2);
|
||||
s->scriptlen=s->file.len-(s->scriptptr-s->file.data);
|
||||
PRINTF("httpd: Handle script named %s\n",scriptname);
|
||||
if(scriptname[0] == ISO_colon) {
|
||||
if (httpd_fs_open(&scriptname[1], &s->file)) {
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
|
||||
}
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->scriptpt,httpd_cgi(scriptname)(s, s->scriptptr));
|
||||
}
|
||||
next_scriptstate(s);
|
||||
|
||||
/* Reset the pointers and continue sending the current file. */
|
||||
s->file.data = s->scriptptr;
|
||||
s->file.len = s->scriptlen;
|
||||
} else {
|
||||
|
||||
/* Send file up to the next potential script */
|
||||
if(s->file.len > uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
s->len = s->file.len;
|
||||
}
|
||||
|
||||
if(httpd_fs_getchar(s->file.data) == ISO_percent) {
|
||||
pptr = (char *) httpd_fs_strchr(s->file.data + 1, ISO_percent);
|
||||
} else {
|
||||
pptr = (char *) httpd_fs_strchr(s->file.data, ISO_percent);
|
||||
}
|
||||
|
||||
if(pptr != NULL && pptr != s->file.data) {
|
||||
s->len = (int)(pptr - s->file.data);
|
||||
if(s->len >= uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
}
|
||||
}
|
||||
PRINTF("httpd: Sending %u bytes from 0x%04x\n",s->file.len,(unsigned int)s->file.data);
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
|
||||
s->file.data += s->len;
|
||||
s->file.len -= s->len;
|
||||
}
|
||||
}
|
||||
|
||||
PT_END(&s->scriptpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char httpd_http[] HTTPD_STRING_ATTR = "HTTP/1.0 ";
|
||||
const char httpd_server[] HTTPD_STRING_ATTR = "\r\nServer: Contiki/2.0 http://www.sics.se/contiki/\r\nConnection: close\r\n";
|
||||
static unsigned short
|
||||
generate_status(void *sstr)
|
||||
{
|
||||
uint8_t slen=httpd_strlen((char *)sstr);
|
||||
httpd_memcpy(uip_appdata, httpd_http, sizeof(httpd_http)-1);
|
||||
httpd_memcpy(uip_appdata+sizeof(httpd_http)-1, (char *)sstr, slen);
|
||||
slen+=sizeof(httpd_http)-1;
|
||||
httpd_memcpy(uip_appdata+slen, httpd_server, sizeof(httpd_server)-1);
|
||||
#if DEBUGLOGIC
|
||||
return 0;
|
||||
#else
|
||||
return slen+sizeof(httpd_server)-1;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char httpd_content[] HTTPD_STRING_ATTR = "Content-type: ";
|
||||
const char httpd_crlf[] HTTPD_STRING_ATTR = "\r\n\r\n";
|
||||
static unsigned short
|
||||
generate_header(void *hstr)
|
||||
{
|
||||
uint8_t slen=httpd_strlen((char *)hstr);
|
||||
httpd_memcpy(uip_appdata,httpd_content,sizeof(httpd_content)-1);
|
||||
httpd_memcpy(uip_appdata+sizeof(httpd_content)-1, (char *)hstr, slen);
|
||||
slen+=sizeof(httpd_content)-1;
|
||||
httpd_memcpy(uip_appdata+slen,httpd_crlf,sizeof(httpd_crlf)-1);
|
||||
#if DEBUGLOGIC
|
||||
return 0;
|
||||
#else
|
||||
return slen+4;
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
char http_htm[10] PROGMEM ="text/html";
|
||||
char http_css[ 9] PROGMEM ="text/css";
|
||||
const char httpd_mime_htm[] HTTPD_STRING_ATTR = "text/html";
|
||||
const char httpd_mime_css[] HTTPD_STRING_ATTR = "text/css";
|
||||
const char httpd_mime_png[] HTTPD_STRING_ATTR = "image/png";
|
||||
const char httpd_mime_gif[] HTTPD_STRING_ATTR = "image/gif";
|
||||
const char httpd_mime_jpg[] HTTPD_STRING_ATTR = "image/jpeg";
|
||||
const char httpd_mime_txt[] HTTPD_STRING_ATTR = "text/plain";
|
||||
const char httpd_mime_bin[] HTTPD_STRING_ATTR = "application/octet-stream";
|
||||
const char httpd_jpg [] HTTPD_STRING_ATTR = "jpg";
|
||||
const char httpd_shtml [] HTTPD_STRING_ATTR = ".shtml";
|
||||
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
char *ptr;
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_status, (char *)statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
if (httpd_strncmp("4", statushdr, 1)==0) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_htm );
|
||||
} else if(ptr == NULL) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_bin );
|
||||
} else {
|
||||
ptr++;
|
||||
if(httpd_strncmp(ptr, &httpd_mime_htm[5],3)== 0 ||httpd_strncmp(ptr, &httpd_shtml[1], 4) == 0) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_htm );
|
||||
} else if(httpd_strcmp(ptr, &httpd_mime_css[5]) == 0) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_css );
|
||||
} else if(httpd_strcmp(ptr, &httpd_mime_png[6]) == 0) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_png );
|
||||
} else if(httpd_strcmp(ptr, &httpd_mime_gif[6])== 0) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_gif );
|
||||
} else if(httpd_strcmp(ptr, httpd_mime_jpg) == 0) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_jpg );
|
||||
} else {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_txt);
|
||||
}
|
||||
}
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char httpd_indexfn [] HTTPD_STRING_ATTR = "/index.html";
|
||||
const char httpd_404fn [] HTTPD_STRING_ATTR = "/404.html";
|
||||
const char httpd_404notf [] HTTPD_STRING_ATTR = "404 Not found";
|
||||
const char httpd_200ok [] HTTPD_STRING_ATTR = "200 OK";
|
||||
static
|
||||
PT_THREAD(handle_output(struct httpd_state *s))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PT_BEGIN(&s->outputpt);
|
||||
#if DEBUGLOGIC
|
||||
httpd_strcpy(s->filename,httpd_indexfn);
|
||||
#endif
|
||||
if(!httpd_fs_open(s->filename, &s->file)) {
|
||||
httpd_strcpy(s->filename, httpd_404fn);
|
||||
httpd_fs_open(s->filename, &s->file);
|
||||
PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_404notf));
|
||||
PT_WAIT_THREAD(&s->outputpt, send_file(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_200ok));
|
||||
ptr = strchr(s->filename, ISO_period);
|
||||
if((ptr != NULL && httpd_strncmp(ptr, httpd_shtml, 6) == 0) || httpd_strcmp(s->filename,httpd_indexfn)==0) {
|
||||
PT_INIT(&s->scriptpt);
|
||||
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt, send_file(s));
|
||||
}
|
||||
}
|
||||
PSOCK_CLOSE(&s->sout);
|
||||
PT_END(&s->outputpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char httpd_get[] HTTPD_STRING_ATTR = "GET ";
|
||||
const char httpd_ref[] HTTPD_STRING_ATTR = "Referer:";
|
||||
static
|
||||
PT_THREAD(handle_input(struct httpd_state *s))
|
||||
{
|
||||
|
||||
PSOCK_BEGIN(&s->sin);
|
||||
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(httpd_strncmp(s->inputbuf, httpd_get, 4) != 0) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(s->inputbuf[0] != ISO_slash) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
httpd_strcpy(s->filename, httpd_indexfn);
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
|
||||
{
|
||||
/* Look for ?, if found strip file name and send any following text to the LCD */
|
||||
uint8_t i;
|
||||
for (i=0;i<sizeof(s->inputbuf);i++) {
|
||||
if (s->inputbuf[i]=='?') {
|
||||
raven_lcd_show_text(&s->inputbuf[i]);
|
||||
if (i<sizeof(s->filename)) s->filename[i]=0;
|
||||
// s->inputbuf[i]=0; //allow multiple beeps with multiple ?'s
|
||||
}
|
||||
if (s->inputbuf[i]==0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
webserver_log_file(&uip_conn->ripaddr, s->filename);
|
||||
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
while(1) {
|
||||
PSOCK_READTO(&s->sin, ISO_nl);
|
||||
|
||||
if(httpd_strncmp(s->inputbuf, httpd_ref, 8) == 0) {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
||||
petsciiconv_topetscii(s->inputbuf, PSOCK_DATALEN(&s->sin) - 2);
|
||||
webserver_log(s->inputbuf);
|
||||
}
|
||||
}
|
||||
PSOCK_END(&s->sin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
handle_connection(struct httpd_state *s)
|
||||
{
|
||||
#if DEBUGLOGIC
|
||||
handle_output(s);
|
||||
#else
|
||||
handle_input(s);
|
||||
if(s->state == STATE_OUTPUT) {
|
||||
handle_output(s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_appcall(void *state)
|
||||
{
|
||||
#if DEBUGLOGIC
|
||||
struct httpd_state *s; //Enter here for debugging with output directed to TCPBUF
|
||||
s = sg = (struct httpd_state *)memb_alloc(&conns);
|
||||
if (1) {
|
||||
#else
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
||||
if(s != NULL) {
|
||||
memb_free(&conns, s);
|
||||
}
|
||||
} else if(uip_connected()) {
|
||||
s = (struct httpd_state *)memb_alloc(&conns);
|
||||
if(s == NULL) {
|
||||
uip_abort();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
tcp_markconn(uip_conn, s);
|
||||
PSOCK_INIT(&s->sin, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PSOCK_INIT(&s->sout, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PT_INIT(&s->outputpt);
|
||||
s->state = STATE_WAITING;
|
||||
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
|
||||
s->timer = 0;
|
||||
handle_connection(s);
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
++s->timer;
|
||||
if(s->timer >= 20) {
|
||||
uip_abort();
|
||||
memb_free(&conns, s);
|
||||
}
|
||||
} else {
|
||||
s->timer = 0;
|
||||
}
|
||||
handle_connection(s);
|
||||
} else {
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_init(void)
|
||||
{
|
||||
tcp_listen(UIP_HTONS(80));
|
||||
memb_init(&conns);
|
||||
httpd_cgi_init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
94
platform/avr-atmega128rfa1/apps/raven-webserver/httpd.h
Normal file
94
platform/avr-atmega128rfa1/apps/raven-webserver/httpd.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd.h,v 1.4 2009/07/24 15:41:52 dak664 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_H__
|
||||
#define __HTTPD_H__
|
||||
|
||||
|
||||
#include "contiki-net.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "lib/petsciiconv.h"
|
||||
|
||||
struct httpd_state {
|
||||
unsigned char timer;
|
||||
struct psock sin, sout;
|
||||
struct pt outputpt, scriptpt;
|
||||
char inputbuf[50];
|
||||
char filename[20];
|
||||
char state;
|
||||
struct httpd_fs_file file;
|
||||
int len;
|
||||
char *scriptptr;
|
||||
int scriptlen;
|
||||
union {
|
||||
unsigned short count;
|
||||
void *ptr;
|
||||
} u;
|
||||
};
|
||||
/* httpd string storage is in RAM by default. Other storage can be defined here */
|
||||
#define HTTPD_STRING_TYPE PROGMEM_TYPE
|
||||
#define PROGMEM_TYPE 1
|
||||
#define EEPROM_TYPE 2
|
||||
|
||||
#if HTTPD_STRING_TYPE==PROGMEM_TYPE
|
||||
#define HTTPD_STRING_ATTR PROGMEM
|
||||
/* These will fail if the server strings are above 64K in program flash */
|
||||
#define httpd_memcpy memcpy_P
|
||||
#define httpd_strcpy strcpy_P
|
||||
#define httpd_strcmp strcmp_P
|
||||
#define httpd_strncmp strncmp_P
|
||||
#define httpd_strlen strlen_P
|
||||
#define httpd_snprintf snprintf_P
|
||||
#elif HTTPD_STRING_TYPE==EEPROM_TYPE
|
||||
#define HTTPD_STRING_ATTR EEPROM
|
||||
/* These are not implemented as yet */
|
||||
#define httpd_memcpy memcpy_E
|
||||
#define httpd_strcpy strcpy_E
|
||||
#define httpd_strcmp strcmp_E
|
||||
#define httpd_strncmp strncmp_E
|
||||
#define httpd_strlen strlen_E
|
||||
#define httpd_snprintf snprintf_E
|
||||
#else
|
||||
#define httpd_memcpy memcpy
|
||||
#define httpd_strcpy strcpy
|
||||
#define httpd_strcmp strcmp
|
||||
#define httpd_strncmp strncmp
|
||||
#define httpd_strlen strlen
|
||||
#define httpd_snprintf snprintf
|
||||
#endif
|
||||
|
||||
void httpd_init(void);
|
||||
void httpd_appcall(void *state);
|
||||
|
||||
#endif /* __HTTPD_H__ */
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 desktop environment
|
||||
*
|
||||
* $Id: webserver-dsc.c,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if CTK_CONF_ICON_BITMAPS
|
||||
static unsigned char webservericon_bitmap[3*3*8] = {
|
||||
0x00, 0x7f, 0x40, 0x41, 0x44, 0x48, 0x40, 0x50,
|
||||
0x00, 0xff, 0x5a, 0x00, 0x00, 0x00, 0x3c, 0x81,
|
||||
0x00, 0xfe, 0x02, 0x82, 0x22, 0x12, 0x02, 0x0a,
|
||||
|
||||
0x41, 0x60, 0x42, 0x62, 0x62, 0x42, 0x60, 0x41,
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18,
|
||||
0x82, 0x06, 0x42, 0x46, 0x46, 0x42, 0x06, 0x82,
|
||||
|
||||
0x50, 0x40, 0x48, 0x44, 0x41, 0x40, 0x7e, 0x00,
|
||||
0xc5, 0x34, 0x3c, 0x52, 0x7a, 0x7e, 0xa1, 0xfd,
|
||||
0x0a, 0x02, 0x12, 0x22, 0x82, 0x02, 0x7e, 0x00
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
||||
|
||||
#if CTK_CONF_ICON_TEXTMAPS
|
||||
static char webservericon_textmap[9] = {
|
||||
'+', '-', '+',
|
||||
'|', ')', '|',
|
||||
'+', '-', '+'
|
||||
};
|
||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
||||
|
||||
#if CTK_CONF_ICONS
|
||||
static struct ctk_icon webserver_icon =
|
||||
{CTK_ICON("Web server", webservericon_bitmap, webservericon_textmap)};
|
||||
#endif /* CTK_CONF_ICONS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
DSC(webserver_dsc,
|
||||
"The Contiki web server",
|
||||
"webserver.prg",
|
||||
webserver_process,
|
||||
&webserver_icon);
|
||||
/*-----------------------------------------------------------------------------------*/
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 desktop environment
|
||||
*
|
||||
* $Id: webserver-dsc.h,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __WEBSERVER_DSC_H__
|
||||
#define __WEBSERVER_DSC_H__
|
||||
|
||||
#include "sys/dsc.h"
|
||||
|
||||
DSC_HEADER(webserver_dsc);
|
||||
|
||||
#endif /* __WEBSERVER_DSC_H__ */
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 OS.
|
||||
*
|
||||
* $Id: webserver-nogui.c,v 1.3 2010/02/09 14:41:18 dak664 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "sys/log.h"
|
||||
|
||||
#include "http-strings.h"
|
||||
#include "webserver-nogui.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-cgi.h"
|
||||
|
||||
PROCESS(webserver_nogui_process, "Web server");
|
||||
|
||||
AUTOSTART_PROCESSES(&webserver_nogui_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(webserver_nogui_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
httpd_init();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
|
||||
httpd_appcall(data);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
webserver_log_file(uip_ipaddr_t *requester, char *file)
|
||||
{
|
||||
/* Print out IP address of requesting host. */
|
||||
#if LOG_CONF_ENABLED
|
||||
#if UIP_CONF_IPV6
|
||||
char buf[48];
|
||||
uint8_t j;
|
||||
j=httpd_cgi_sprint_ip6((uip_ip6addr_t)*requester, buf);
|
||||
buf[j]=':';buf[j+1]=' ';buf[j+2]=0;
|
||||
#else
|
||||
char buf[20];
|
||||
sprintf(buf, "%d.%d.%d.%d: ", requester->u8[0], requester->u8[1],
|
||||
requester->u8[2], requester->u8[3]);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
log_message(buf, file);
|
||||
#endif /* LOG_CONF_ENABLED */
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
webserver_log(char *msg)
|
||||
{
|
||||
log_message(msg, "");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 OS
|
||||
*
|
||||
* $Id: webserver-nogui.h,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __WEBSERVER_NOGUI_H__
|
||||
#define __WEBSERVER_NOGUI_H__
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
PROCESS_NAME(webserver_nogui_process);
|
||||
PROCESS_NAME(raven_lcd_process);
|
||||
|
||||
void webserver_log(char *msg);
|
||||
void webserver_log_file(uip_ipaddr_t *requester, char *file);
|
||||
|
||||
#endif /* __WEBSERVER_H__ */
|
127
platform/avr-atmega128rfa1/apps/raven-webserver/webserver.c
Normal file
127
platform/avr-atmega128rfa1/apps/raven-webserver/webserver.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 desktop environment for the C64.
|
||||
*
|
||||
* $Id: webserver.c,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "ctk/ctk.h"
|
||||
|
||||
#include "http-strings.h"
|
||||
#include "webserver.h"
|
||||
#include "httpd.h"
|
||||
|
||||
/* The main window. */
|
||||
static struct ctk_window mainwindow;
|
||||
|
||||
static struct ctk_label message =
|
||||
{CTK_LABEL(0, 0, 15, 1, "Latest requests")};
|
||||
|
||||
PROCESS(webserver_process, "Web server");
|
||||
|
||||
AUTOSTART_PROCESSES(&webserver_process);
|
||||
|
||||
#define LOG_WIDTH 38
|
||||
#define LOG_HEIGHT 16
|
||||
static char log[LOG_WIDTH*LOG_HEIGHT];
|
||||
|
||||
static struct ctk_label loglabel =
|
||||
{CTK_LABEL(0, 1, LOG_WIDTH, LOG_HEIGHT, log)};
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(webserver_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
ctk_window_new(&mainwindow, LOG_WIDTH, LOG_HEIGHT+1, "Web server");
|
||||
|
||||
CTK_WIDGET_ADD(&mainwindow, &message);
|
||||
CTK_WIDGET_ADD(&mainwindow, &loglabel);
|
||||
|
||||
httpd_init();
|
||||
|
||||
ctk_window_open(&mainwindow);
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == ctk_signal_window_close ||
|
||||
ev == PROCESS_EVENT_EXIT) {
|
||||
ctk_window_close(&mainwindow);
|
||||
process_exit(&webserver_process);
|
||||
LOADER_UNLOAD();
|
||||
} else if(ev == tcpip_event) {
|
||||
httpd_appcall(data);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
webserver_log_file(uip_ipaddr_t *requester, char *file)
|
||||
{
|
||||
int size;
|
||||
|
||||
/* Scroll previous entries upwards */
|
||||
memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
|
||||
|
||||
/* Print out IP address of requesting host. */
|
||||
size = sprintf(&log[LOG_WIDTH * (LOG_HEIGHT - 1)],
|
||||
"%d.%d.%d.%d: ",
|
||||
requester->u8[0],
|
||||
requester->u8[1],
|
||||
requester->u8[2],
|
||||
requester->u8[3]);
|
||||
|
||||
/* Copy filename into last line. */
|
||||
strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1) + size], file, LOG_WIDTH - size);
|
||||
|
||||
/* Update log display. */
|
||||
CTK_WIDGET_REDRAW(&loglabel);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
webserver_log(char *msg)
|
||||
{
|
||||
/* Scroll previous entries upwards */
|
||||
memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
|
||||
|
||||
/* Copy filename into last line. */
|
||||
strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1)], msg, LOG_WIDTH);
|
||||
|
||||
/* Update log display. */
|
||||
CTK_WIDGET_REDRAW(&loglabel);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
45
platform/avr-atmega128rfa1/apps/raven-webserver/webserver.h
Normal file
45
platform/avr-atmega128rfa1/apps/raven-webserver/webserver.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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
|
||||
*
|
||||
* $Id: webserver.h,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __WEBSERVER_H__
|
||||
#define __WEBSERVER_H__
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
PROCESS_NAME(webserver_process);
|
||||
|
||||
void webserver_log(char *msg);
|
||||
void webserver_log_file(uip_ipaddr_t *requester, char *file);
|
||||
|
||||
#endif /* __WEBSERVER_H__ */
|
270
platform/avr-atmega128rfa1/contiki-conf.h
Normal file
270
platform/avr-atmega128rfa1/contiki-conf.h
Normal file
@ -0,0 +1,270 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Technical University of Munich
|
||||
* 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
|
||||
* Configuration for Atmel ATmega128rfa1
|
||||
* \author
|
||||
* David Kopf <dak664@embarqmail.com>
|
||||
*/
|
||||
|
||||
#ifndef __CONTIKI_CONF_H__
|
||||
#define __CONTIKI_CONF_H__
|
||||
|
||||
/* MCU and clock rate */
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define HARWARE_REVISION ATMEGA128RFA1
|
||||
#ifndef F_CPU
|
||||
#define F_CPU 8000000UL
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int32_t s32_t;
|
||||
typedef unsigned char u8_t;
|
||||
typedef unsigned short u16_t;
|
||||
typedef unsigned long u32_t;
|
||||
typedef unsigned short clock_time_t;
|
||||
typedef unsigned short uip_stats_t;
|
||||
typedef unsigned long off_t;
|
||||
|
||||
void clock_delay(unsigned int us2);
|
||||
void clock_wait(int ms10);
|
||||
void clock_set_seconds(unsigned long s);
|
||||
unsigned long clock_seconds(void);
|
||||
|
||||
/* Maximum timer interval for 16 bit clock_time_t */
|
||||
#define INFINITE_TIME 0xffff
|
||||
|
||||
/* Clock ticks per second */
|
||||
#define CLOCK_CONF_SECOND 125
|
||||
|
||||
/* Maximum tick interval is 0xffff/125 = 524 seconds */
|
||||
#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
|
||||
#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME CLOCK_CONF_SECOND * 524UL /* Default uses 600UL */
|
||||
|
||||
/* Michael Hartman's atmega128rfa1 board has an external 32768Hz crystal connected to TOSC1 and 2 pins similar to the Raven 1284p */
|
||||
/* and theoretically can use TIMER2 with it to keep time. Else TIMER0 is used. */
|
||||
/* The sleep timer in raven-lcd.c also uses the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
|
||||
/* This has not been tested yet */
|
||||
#define AVR_CONF_USE32KCRYSTAL 0
|
||||
|
||||
/* COM port to be used for SLIP connection. Not tested on Raven */
|
||||
#define SLIP_PORT RS232_PORT_0
|
||||
|
||||
/* 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
|
||||
|
||||
/* Starting address for code received via the codeprop facility. Not tested on Raven */
|
||||
//#define EEPROMFS_ADDR_CODEPROP 0x8000
|
||||
|
||||
/* Network setup. The new NETSTACK interface requires RF230BB (as does ip4) */
|
||||
#if RF230BB
|
||||
#undef PACKETBUF_CONF_HDR_SIZE //Use the packetbuf default for header size
|
||||
#else
|
||||
#define PACKETBUF_CONF_HDR_SIZE 0 //RF230 combined driver/mac handles headers internally
|
||||
#endif /*RF230BB */
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
#define UIP_CONF_ICMP6 1
|
||||
#define UIP_CONF_UDP 1
|
||||
#define UIP_CONF_TCP 1
|
||||
#define UIP_CONF_IPV6_RPL 0
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
#else
|
||||
/* ip4 should build but is largely untested */
|
||||
#define RIMEADDR_CONF_SIZE 2
|
||||
#define NETSTACK_CONF_NETWORK rime_driver
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/* See uip-ds6.h */
|
||||
#define UIP_CONF_DS6_NBR_NBU 20
|
||||
#define UIP_CONF_DS6_DEFRT_NBU 2
|
||||
#define UIP_CONF_DS6_PREFIX_NBU 3
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 20
|
||||
#define UIP_CONF_DS6_ADDR_NBU 3
|
||||
#define UIP_CONF_DS6_MADDR_NBU 0
|
||||
#define UIP_CONF_DS6_AADDR_NBU 0
|
||||
|
||||
#define UIP_CONF_LL_802154 1
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
|
||||
/* 10 bytes per stateful address context - see sicslowpan.c */
|
||||
/* Default is 1 context with prefix aaaa::/64 */
|
||||
/* These must agree with all the other nodes or there will be a failure to communicate! */
|
||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
|
||||
#define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xaa;addr_contexts[0].prefix[1]=0xaa;}
|
||||
#define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
|
||||
#define SICSLOWPAN_CONF_ADDR_CONTEXT_2 {addr_contexts[2].prefix[0]=0x20;addr_contexts[2].prefix[1]=0x01;addr_contexts[2].prefix[2]=0x49;addr_contexts[2].prefix[3]=0x78,addr_contexts[2].prefix[4]=0x1d;addr_contexts[2].prefix[5]=0xb1;}
|
||||
|
||||
/* 211 bytes per queue buffer */
|
||||
#define QUEUEBUF_CONF_NUM 8
|
||||
|
||||
/* 54 bytes per queue ref buffer */
|
||||
#define QUEUEBUF_CONF_REF_NUM 2
|
||||
|
||||
/* Take the default TCP maximum segment size for efficiency and simpler wireshark captures */
|
||||
/* Use this to prevent 6LowPAN fragmentation (whether or not fragmentation is enabled) */
|
||||
//#define UIP_CONF_TCP_MSS 48
|
||||
|
||||
/* 30 bytes per TCP connection */
|
||||
/* 6LoWPAN does not do well with concurrent TCP streams, as new browser GETs collide with packets coming */
|
||||
/* 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
|
||||
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#define UIP_CONF_FWCACHE_SIZE 0
|
||||
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#define UIP_CONF_IPV6_QUEUE_PKT 1
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
#define UIP_CONF_TCP_SPLIT 1
|
||||
#define UIP_CONF_DHCP_LIGHT 1
|
||||
|
||||
|
||||
#if 1 /* No radio cycling */
|
||||
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
#define NETSTACK_CONF_RDC sicslowmac_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
#define NETSTACK_CONF_RADIO rf230_driver
|
||||
#define CHANNEL_802_15_4 26
|
||||
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
|
||||
#define RF230_CONF_AUTOACK 1
|
||||
/* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
|
||||
#define SICSLOWPAN_CONF_ACK_ALL 0
|
||||
/* Number of auto retry attempts 0-15 (0 implies don't use extended TX_ARET_ON mode with CCA) */
|
||||
#define RF230_CONF_AUTORETRIES 2
|
||||
/* Default is one RAM buffer for received packets. More than one may benefit multiple TCP connections or ports */
|
||||
#define RF230_CONF_RX_BUFFERS 3
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
/* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
|
||||
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||
/* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
|
||||
/* If wait is too short the connection can be reset as a result of multiple fragment reassembly timeouts */
|
||||
#define UIP_CONF_WAIT_TIMEOUT 20
|
||||
|
||||
#elif 1 /* Contiki-mac radio cycling */
|
||||
//#define NETSTACK_CONF_MAC nullmac_driver
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
#define NETSTACK_CONF_RADIO rf230_driver
|
||||
#define CHANNEL_802_15_4 26
|
||||
#define RF230_CONF_AUTOACK 0
|
||||
#define RF230_CONF_AUTORETRIES 0
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
|
||||
|
||||
#elif 1 /* cx-mac radio cycling */
|
||||
/* RF230 does clear-channel assessment in extended mode (autoretries>0) */
|
||||
#define RF230_CONF_AUTORETRIES 1
|
||||
#if RF230_CONF_AUTORETRIES
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
#else
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#endif
|
||||
#define NETSTACK_CONF_RDC cxmac_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
#define NETSTACK_CONF_RADIO rf230_driver
|
||||
#define CHANNEL_802_15_4 26
|
||||
#define RF230_CONF_AUTOACK 1
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
|
||||
|
||||
//Below gives 10% duty cycle, undef for default 5%
|
||||
//#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
|
||||
//Below gives 50% duty cycle
|
||||
//#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
|
||||
|
||||
#else
|
||||
#error Network configuration not specified!
|
||||
#endif /* Network setup */
|
||||
|
||||
/* Logging adds 200 bytes to program size */
|
||||
#define LOG_CONF_ENABLED 1
|
||||
|
||||
/* ************************************************************************** */
|
||||
//#pragma mark RPL Settings
|
||||
/* ************************************************************************** */
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
|
||||
/* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
|
||||
* Leave undefined for full power and sensitivity.
|
||||
* tx=0 (3dbm, default) to 15 (-17.2dbm)
|
||||
* RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
|
||||
* else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
|
||||
* For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set.
|
||||
* On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
|
||||
* These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm
|
||||
* and a 10 meter range to a full-sensitivity RF230 sniffer.
|
||||
#define RF230_MAX_TX_POWER 15
|
||||
#define RF230_MIN_RX_POWER 30
|
||||
*/
|
||||
|
||||
#define UIP_CONF_ROUTER 1
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
#define UIP_CONF_ND6_REACHABLE_TIME 600000
|
||||
#define UIP_CONF_ND6_RETRANS_TIMER 10000
|
||||
|
||||
#undef UIP_CONF_UDP_CONNS
|
||||
#define UIP_CONF_UDP_CONNS 12
|
||||
#undef UIP_CONF_FWCACHE_SIZE
|
||||
#define UIP_CONF_FWCACHE_SIZE 30
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
#define UIP_ARCH_IPCHKSUM 1
|
||||
#define UIP_CONF_PINGADDRCONF 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
|
||||
#endif /* RPL */
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
#endif /* __CONTIKI_CONF_H__ */
|
488
platform/avr-atmega128rfa1/contiki-main.c
Normal file
488
platform/avr-atmega128rfa1/contiki-main.c
Normal file
@ -0,0 +1,488 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Technical University of Munich
|
||||
* 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.
|
||||
*
|
||||
* @(#)$$
|
||||
*/
|
||||
#define ANNOUNCE_BOOT 1 //adds about 600 bytes to program size
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTSHORT(...)
|
||||
#endif
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/fuse.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <dev/watchdog.h>
|
||||
|
||||
#include "loader/symbols-def.h"
|
||||
#include "loader/symtab.h"
|
||||
|
||||
#if RF230BB //radio driver using contiki core mac
|
||||
#include "radio/rf230bb/rf230bb.h"
|
||||
#include "net/mac/frame802154.h"
|
||||
#include "net/mac/framer-802154.h"
|
||||
#include "net/sicslowpan.h"
|
||||
|
||||
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
||||
#include <stdbool.h>
|
||||
#include "mac.h"
|
||||
#include "sicslowmac.h"
|
||||
#include "sicslowpan.h"
|
||||
#include "ieee-15-4-manager.h"
|
||||
#endif /*RF230BB*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
|
||||
#include "dev/rs232.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/slip.h"
|
||||
|
||||
/* No 3290p to talk to but the lcd process still needed for uip stack ping callbacks */
|
||||
#ifdef RAVEN_LCD_INTERFACE
|
||||
#include "raven-lcd.h"
|
||||
#endif
|
||||
|
||||
#if WEBSERVER
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-cgi.h"
|
||||
#endif
|
||||
|
||||
#ifdef COFFEE_FILES
|
||||
#include "cfs/cfs.h"
|
||||
#include "cfs/cfs-coffee.h"
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_ROUTER&&0
|
||||
#include "net/routing/rimeroute.h"
|
||||
#include "net/rime/rime-udp.h"
|
||||
#endif
|
||||
|
||||
#include "net/rime.h"
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/*----------------------Configuration of the .elf file---------------------*/
|
||||
typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t;
|
||||
#define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
|
||||
SIGNATURE = {
|
||||
/* Older AVR-GCCs may not define the SIGNATURE_n bytes so use explicit ATmega128rfa1 values */
|
||||
.B2 = SIGNATURE_2,//0x01,//SIGNATURE_2,
|
||||
.B1 = SIGNATURE_1,//0xA7,//SIGNATURE_1,
|
||||
.B0 = SIGNATURE_0,//0x1E,//SIGNATURE_0,
|
||||
};
|
||||
//JTAG+SPI, Boot 4096 words @ $F000, Internal oscillator, startup 6 CK + 65 ms, Brownout disabled
|
||||
FUSES ={.low = 0xe2, .high = 0x99, .extended = 0xff,};
|
||||
//JTAG+SPI, Boot 4096 words @ $F000, Internal oscillator, startup 6 CK +0 ms, Brownout 1.8 volts
|
||||
//FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,};
|
||||
|
||||
/*----------------------Configuration of EEPROM---------------------------*/
|
||||
/* Use existing EEPROM if it passes the integrity test, else reinitialize with build values */
|
||||
|
||||
/* Put default MAC address in EEPROM */
|
||||
#if WEBSERVER
|
||||
extern uint8_t mac_address[8]; //These are defined in httpd-fsdata.c via makefsdata.h
|
||||
extern uint8_t server_name[16];
|
||||
extern uint8_t domain_name[30];
|
||||
#else
|
||||
uint8_t mac_address[8] PROGMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CHANNEL_802_15_4
|
||||
uint8_t rf_channel[2] EEMEM = {CHANNEL_802_15_4, ~CHANNEL_802_15_4};
|
||||
//uint8_t rf_channel[2] EEMEM = {11, ~11}; //econotag test
|
||||
#else
|
||||
uint8_t rf_channel[2] EEMEM = {26, ~26};
|
||||
#endif
|
||||
static uint8_t get_channel_from_eeprom() {
|
||||
uint8_t eeprom_channel;
|
||||
uint8_t eeprom_check;
|
||||
|
||||
eeprom_channel = eeprom_read_byte(&rf_channel[0]);
|
||||
eeprom_check = eeprom_read_byte(&rf_channel[1]);
|
||||
|
||||
if(eeprom_channel==~eeprom_check)
|
||||
return eeprom_channel;
|
||||
|
||||
#ifdef CHANNEL_802_15_4
|
||||
//return(11);
|
||||
return(CHANNEL_802_15_4);
|
||||
#else
|
||||
return 26;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool get_mac_from_eeprom(uint8_t* macptr) {
|
||||
eeprom_read_block ((void *)macptr, &mac_address, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint16_t get_panid_from_eeprom(void) {
|
||||
// TODO: Writeme!
|
||||
return IEEE802154_PANID;
|
||||
//return 0xaaaa; //econotag ack test
|
||||
}
|
||||
|
||||
static uint16_t get_panaddr_from_eeprom(void) {
|
||||
// TODO: Writeme!
|
||||
return 0;
|
||||
// return 0x1111; //econotag ack test
|
||||
}
|
||||
|
||||
void calibrate_rc_osc_32k();
|
||||
extern uint8_t osccal_calibrated;
|
||||
/*-------------------------Low level initialization------------------------*/
|
||||
/*------Done in a subroutine to keep main routine stack usage small--------*/
|
||||
void initialize(void)
|
||||
{
|
||||
watchdog_init();
|
||||
watchdog_start();
|
||||
|
||||
#ifdef RAVEN_LCD_INTERFACE
|
||||
/* First rs232 port for Raven 3290 port */
|
||||
//conflicts with led on Hartmann's board, so bypass for now
|
||||
// rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
||||
/* Set input handler for 3290 port */
|
||||
// rs232_set_input(0,raven_lcd_serial_input);
|
||||
#endif
|
||||
|
||||
/* Second rs232 port for debugging */
|
||||
rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
||||
/* Redirect stdout to second port */
|
||||
rs232_redirect_stdout(RS232_PORT_1);
|
||||
clock_init();
|
||||
|
||||
#define CONF_CALIBRATE_OSCCAL 1
|
||||
#if CONF_CALIBRATE_OSCCAL
|
||||
{
|
||||
uint8_t i;
|
||||
printf_P(PSTR("\nBefore calibration OSCCAL=%x\n"),OSCCAL);
|
||||
for (i=0;i<10;i++) {
|
||||
calibrate_rc_osc_32k();
|
||||
printf_P(PSTR("Calibrated=%x\n"),osccal_calibrated);
|
||||
//#include <util/delay_basic.h>
|
||||
//#define delay_us( us ) ( _delay_loop_2(1+(us*F_CPU)/4000000UL) )
|
||||
// delay_us(50000);
|
||||
}
|
||||
clock_init();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ANNOUNCE_BOOT
|
||||
printf_P(PSTR("\n*******Booting %s*******\n"),CONTIKI_VERSION_STRING);
|
||||
#endif
|
||||
watchdog_start();
|
||||
/* rtimers needed for radio cycling */
|
||||
rtimer_init();
|
||||
|
||||
/* Initialize process subsystem */
|
||||
process_init();
|
||||
/* etimers must be started before ctimer_init */
|
||||
process_start(&etimer_process, NULL);
|
||||
|
||||
#if RF230BB
|
||||
|
||||
ctimer_init();
|
||||
/* Start radio and radio receive process */
|
||||
NETSTACK_RADIO.init();
|
||||
|
||||
/* Set addresses BEFORE starting tcpip process */
|
||||
|
||||
rimeaddr_t addr;
|
||||
memset(&addr, 0, sizeof(rimeaddr_t));
|
||||
get_mac_from_eeprom(addr.u8);
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
memcpy(&uip_lladdr.addr, &addr.u8, 8);
|
||||
#endif
|
||||
rf230_set_pan_addr(
|
||||
get_panid_from_eeprom(),
|
||||
get_panaddr_from_eeprom(),
|
||||
(uint8_t *)&addr.u8
|
||||
);
|
||||
rf230_set_channel(get_channel_from_eeprom());
|
||||
|
||||
rimeaddr_set_node_addr(&addr);
|
||||
|
||||
PRINTF("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
|
||||
|
||||
/* Initialize stack protocols */
|
||||
queuebuf_init();
|
||||
NETSTACK_RDC.init();
|
||||
NETSTACK_MAC.init();
|
||||
NETSTACK_NETWORK.init();
|
||||
|
||||
#if ANNOUNCE_BOOT
|
||||
printf_P(PSTR("%s %s, channel %u"),NETSTACK_MAC.name, NETSTACK_RDC.name,rf230_get_channel());
|
||||
if (NETSTACK_RDC.channel_check_interval) {//function pointer is zero for sicslowmac
|
||||
unsigned short tmp;
|
||||
tmp=CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval == 0 ? 1:\
|
||||
NETSTACK_RDC.channel_check_interval());
|
||||
if (tmp<65535) printf_P(PSTR(", check rate %u Hz"),tmp);
|
||||
}
|
||||
printf_P(PSTR("\n"));
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
#if ANNOUNCE_BOOT
|
||||
printf_P(PSTR("Routing Enabled\n"));
|
||||
#endif
|
||||
// rime_init(rime_udp_init(NULL));
|
||||
// uip_router_register(&rimeroute);
|
||||
#endif
|
||||
|
||||
process_start(&tcpip_process, NULL);
|
||||
|
||||
#else
|
||||
/* mac process must be started before tcpip process! */
|
||||
process_start(&mac_process, NULL);
|
||||
process_start(&tcpip_process, NULL);
|
||||
#endif /*RF230BB*/
|
||||
|
||||
#ifdef RAVEN_LCD_INTERFACE
|
||||
process_start(&raven_lcd_process, NULL);
|
||||
#endif
|
||||
|
||||
/* Autostart other processes */
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
//Give ourselves a prefix
|
||||
// init_net();
|
||||
|
||||
/*---If using coffee file system create initial web content if necessary---*/
|
||||
#if COFFEE_FILES
|
||||
int fa = cfs_open( "/index.html", CFS_READ);
|
||||
if (fa<0) { //Make some default web content
|
||||
printf_P(PSTR("No index.html file found, creating upload.html!\n"));
|
||||
printf_P(PSTR("Formatting FLASH file system for coffee..."));
|
||||
cfs_coffee_format();
|
||||
printf_P(PSTR("Done!\n"));
|
||||
fa = cfs_open( "/index.html", CFS_WRITE);
|
||||
int r = cfs_write(fa, &"It works!", 9);
|
||||
if (r<0) printf_P(PSTR("Can''t create /index.html!\n"));
|
||||
cfs_close(fa);
|
||||
// fa = cfs_open("upload.html"), CFW_WRITE);
|
||||
// <html><body><form action="upload.html" enctype="multipart/form-data" method="post"><input name="userfile" type="file" size="50" /><input value="Upload" type="submit" /></form></body></html>
|
||||
}
|
||||
#endif /* COFFEE_FILES */
|
||||
|
||||
/* Add addresses for testing */
|
||||
#if 0
|
||||
{
|
||||
uip_ip6addr_t ipaddr;
|
||||
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
||||
// uip_ds6_prefix_add(&ipaddr,64,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*--------------------------Announce the configuration---------------------*/
|
||||
#if ANNOUNCE_BOOT
|
||||
|
||||
#if WEBSERVER
|
||||
uint8_t i;
|
||||
char buf[80];
|
||||
unsigned int size;
|
||||
|
||||
for (i=0;i<UIP_DS6_ADDR_NB;i++) {
|
||||
if (uip_ds6_if.addr_list[i].isused) {
|
||||
httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr,buf);
|
||||
printf_P(PSTR("IPv6 Address: %s\n"),buf);
|
||||
}
|
||||
}
|
||||
eeprom_read_block (buf,server_name, sizeof(server_name));
|
||||
buf[sizeof(server_name)]=0;
|
||||
printf_P(PSTR("%s"),buf);
|
||||
eeprom_read_block (buf,domain_name, sizeof(domain_name));
|
||||
buf[sizeof(domain_name)]=0;
|
||||
size=httpd_fs_get_size();
|
||||
#ifndef COFFEE_FILES
|
||||
printf_P(PSTR(".%s online with fixed %u byte web content\n"),buf,size);
|
||||
#elif COFFEE_FILES==1
|
||||
printf_P(PSTR(".%s online with static %u byte EEPROM file system\n"),buf,size);
|
||||
#elif COFFEE_FILES==2
|
||||
printf_P(PSTR(".%s online with dynamic %u KB EEPROM file system\n"),buf,size>>10);
|
||||
#elif COFFEE_FILES==3
|
||||
printf_P(PSTR(".%s online with static %u byte program memory file system\n"),buf,size);
|
||||
#elif COFFEE_FILES==4
|
||||
printf_P(PSTR(".%s online with dynamic %u KB program memory file system\n"),buf,size>>10);
|
||||
#endif /* COFFEE_FILES */
|
||||
|
||||
#else
|
||||
printf_P(PSTR("Online\n"));
|
||||
#endif /* WEBSERVER */
|
||||
|
||||
#endif /* ANNOUNCE_BOOT */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void log_message(char *m1, char *m2)
|
||||
{
|
||||
printf_P(PSTR("%s%s\n"), m1, m2);
|
||||
}
|
||||
/* Test rtimers, also useful for pings and time stamps in simulator */
|
||||
#define TESTRTIMER 0
|
||||
#if TESTRTIMER
|
||||
#define PINGS 60
|
||||
#define STAMPS 30
|
||||
uint8_t rtimerflag=1;
|
||||
uint16_t rtime;
|
||||
struct rtimer rt;
|
||||
void rtimercycle(void) {rtimerflag=1;}
|
||||
#endif /* TESTRTIMER */
|
||||
|
||||
#if RF230BB
|
||||
extern char rf230_interrupt_flag, rf230processflag;
|
||||
#endif
|
||||
|
||||
uint16_t ledtimer;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/*------------------------- Main Scheduler loop----------------------------*/
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#define CONFIG_STACK_MONITOR 1
|
||||
#if CONFIG_STACK_MONITOR
|
||||
extern uint16_t __bss_end;
|
||||
__bss_end = 0x4242;
|
||||
*(uint16_t *)(&__bss_end+100) = 0x4242;
|
||||
#endif
|
||||
|
||||
initialize();
|
||||
|
||||
/* NB: PORTE1 conflicts with UART0 */
|
||||
DDRE|=(1<<DDE1); //set led pin to output
|
||||
PORTE&=~(1<<PE1); //and low to turn led off
|
||||
|
||||
while(1) {
|
||||
process_run();
|
||||
|
||||
/* Turn off LED after a while */
|
||||
if (ledtimer) {
|
||||
if (--ledtimer==0) {
|
||||
PORTE&=~(1<<PE1);
|
||||
/* Currently LED was turned on by received ping; ping the other way for testing */
|
||||
extern void raven_ping6(void);
|
||||
raven_ping6(); //ping back
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_STACK_MONITOR
|
||||
if (*(uint16_t *)(&__bss_end+100) != 0x4242) {
|
||||
printf_P(PSTR("\nStack Warning, overflow within 100 bytes!\n"));
|
||||
if (__bss_end != 0x4242) {
|
||||
__bss_end = 0x4242;
|
||||
printf_P(PSTR("\n!!!!!!!Stack Overflow!!!!!!!!\n"));
|
||||
}
|
||||
*(uint16_t *)(&__bss_end+100) = 0x4242;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
extern uint8_t rf230_calibrated;
|
||||
if (rf230_calibrated) {
|
||||
printf_P(PSTR("\nRF230 calibrated!"));
|
||||
rf230_calibrated=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Various entry points for debugging in AVR simulator
|
||||
// NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
|
||||
// process_poll(&rf230_process);
|
||||
// packetbuf_clear();
|
||||
// len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
||||
// packetbuf_set_datalen(42);
|
||||
// NETSTACK_RDC.input();
|
||||
watchdog_periodic();
|
||||
#if TESTRTIMER
|
||||
if (rtimerflag) { //8 seconds is maximum interval, my raven 6% slow
|
||||
rtimer_set(&rt, RTIMER_NOW()+ RTIMER_ARCH_SECOND*1UL, 1,(void *) rtimercycle, NULL);
|
||||
rtimerflag=0;
|
||||
#if STAMPS
|
||||
if ((rtime%STAMPS)==0) {
|
||||
printf("%us ",rtime);
|
||||
#if 0 //test timer0
|
||||
extern unsigned long seconds;
|
||||
printf("clock= %lus ",clock_seconds());
|
||||
printf("scount=%us",scount);
|
||||
printf(" %us %us",(unsigned int)(seconds&0xffff),(unsigned int)(seconds>>16));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
rtime+=1;
|
||||
#if PINGS
|
||||
if ((rtime%PINGS)==0) {
|
||||
PRINTF("**Ping\n");
|
||||
raven_ping6();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
//Use with RF230BB DEBUGFLOW to show path through driver
|
||||
#if RF230BB&&0
|
||||
extern uint8_t debugflowsize,debugflow[];
|
||||
if (debugflowsize) {
|
||||
debugflow[debugflowsize]=0;
|
||||
printf("%s",debugflow);
|
||||
debugflowsize=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if RF230BB&&0
|
||||
if (rf230processflag) {
|
||||
printf("rf230p%d",rf230processflag);
|
||||
rf230processflag=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if RF230BB&&0
|
||||
if (rf230_interrupt_flag) {
|
||||
// if (rf230_interrupt_flag!=11) {
|
||||
PRINTSHORT("**RI%u",rf230_interrupt_flag);
|
||||
// }
|
||||
rf230_interrupt_flag=0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
27
platform/avr-atmega128rfa1/raven-lcd.h
Normal file
27
platform/avr-atmega128rfa1/raven-lcd.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef raven_lcd_h
|
||||
#define raven_lcd_h
|
||||
|
||||
int raven_lcd_serial_input(unsigned char ch);
|
||||
void raven_lcd_show_text(char *text);
|
||||
PROCESS_NAME(raven_lcd_process);
|
||||
|
||||
/* Serial protocol */
|
||||
#define SOF_CHAR 1
|
||||
#define EOF_CHAR 4
|
||||
#define NULL_CMD (0x00)
|
||||
#define SERIAL_CMD (0x01)
|
||||
|
||||
/* Messages from the 1284p to the 3290p */
|
||||
#define REPORT_PING (0xC0)
|
||||
#define REPORT_PING_BEEP (0xC1)
|
||||
#define REPORT_TEXT_MSG (0xC2)
|
||||
#define REPORT_WAKE (0xC3)
|
||||
|
||||
/* Messages from the 3290p to the 1284p */
|
||||
#define SEND_TEMP (0x80)
|
||||
#define SEND_PING (0x81)
|
||||
#define SEND_ADC2 (0x82)
|
||||
#define SEND_SLEEP (0x83)
|
||||
#define SEND_WAKE (0x84)
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user