2008-10-14 11:40:30 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @(#)$$
|
|
|
|
*/
|
2010-02-28 22:29:19 +01:00
|
|
|
#define ANNOUNCE_BOOT 1 //adds about 600 bytes to program size
|
|
|
|
|
2010-03-02 17:25:47 +01:00
|
|
|
#define DEBUG 0
|
2009-07-23 18:16:07 +02:00
|
|
|
#if DEBUG
|
|
|
|
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
2010-02-22 23:23:18 +01:00
|
|
|
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
2010-03-02 17:25:47 +01:00
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
#else
|
|
|
|
#define PRINTF(...)
|
2010-02-22 23:23:18 +01:00
|
|
|
#define PRINTSHORT(...)
|
2009-07-23 18:16:07 +02:00
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
|
|
|
|
#include <avr/pgmspace.h>
|
2008-10-14 23:29:23 +02:00
|
|
|
#include <avr/fuse.h>
|
|
|
|
#include <avr/eeprom.h>
|
2008-10-14 11:40:30 +02:00
|
|
|
#include <stdio.h>
|
2009-07-08 17:26:17 +02:00
|
|
|
#include <string.h>
|
2010-11-03 17:51:55 +01:00
|
|
|
#include <dev/watchdog.h>
|
2008-10-14 11:40:30 +02:00
|
|
|
|
|
|
|
#include "loader/symbols-def.h"
|
|
|
|
#include "loader/symtab.h"
|
2009-07-08 17:26:17 +02:00
|
|
|
|
2010-02-23 18:43:20 +01:00
|
|
|
#if RF230BB //radio driver using contiki core mac
|
2009-07-26 14:10:38 +02:00
|
|
|
#include "radio/rf230bb/rf230bb.h"
|
2009-07-08 17:26:17 +02:00
|
|
|
#include "net/mac/frame802154.h"
|
2010-02-18 18:23:19 +01:00
|
|
|
#include "net/mac/framer-802154.h"
|
2009-07-08 17:26:17 +02:00
|
|
|
#include "net/sicslowpan.h"
|
2010-02-16 23:22:13 +01:00
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
|
|
|
#include <stdbool.h>
|
2008-10-14 11:40:30 +02:00
|
|
|
#include "mac.h"
|
2009-07-26 14:10:38 +02:00
|
|
|
#include "sicslowmac.h"
|
2008-10-14 11:40:30 +02:00
|
|
|
#include "sicslowpan.h"
|
|
|
|
#include "ieee-15-4-manager.h"
|
2009-07-08 17:26:17 +02:00
|
|
|
#endif /*RF230BB*/
|
2008-10-14 11:40:30 +02:00
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
#include "contiki-net.h"
|
|
|
|
#include "contiki-lib.h"
|
|
|
|
|
|
|
|
#include "dev/rs232.h"
|
2009-03-17 21:19:11 +01:00
|
|
|
#include "dev/serial-line.h"
|
2008-10-14 11:40:30 +02:00
|
|
|
#include "dev/slip.h"
|
|
|
|
|
2008-10-15 16:38:20 +02:00
|
|
|
#ifdef RAVEN_LCD_INTERFACE
|
2008-10-14 11:40:30 +02:00
|
|
|
#include "raven-lcd.h"
|
2008-10-15 16:38:20 +02:00
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
|
2009-07-26 14:10:38 +02:00
|
|
|
#if WEBSERVER
|
2009-07-23 18:16:07 +02:00
|
|
|
#include "httpd-fs.h"
|
2010-02-09 15:43:16 +01:00
|
|
|
#include "httpd-cgi.h"
|
2009-07-26 14:10:38 +02:00
|
|
|
#endif
|
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
#ifdef COFFEE_FILES
|
|
|
|
#include "cfs/cfs.h"
|
|
|
|
#include "cfs/cfs-coffee.h"
|
|
|
|
#endif
|
|
|
|
|
2010-11-03 17:51:55 +01:00
|
|
|
#if UIP_CONF_ROUTER&&0
|
2009-07-08 17:26:17 +02:00
|
|
|
#include "net/routing/rimeroute.h"
|
|
|
|
#include "net/rime/rime-udp.h"
|
2009-07-26 14:10:38 +02:00
|
|
|
#endif
|
|
|
|
|
2009-07-08 17:26:17 +02:00
|
|
|
#include "net/rime.h"
|
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/*----------------------Configuration of the .elf file---------------------*/
|
|
|
|
typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t;
|
2009-07-08 17:26:17 +02:00
|
|
|
#define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
|
2009-07-23 18:16:07 +02:00
|
|
|
SIGNATURE = {
|
2009-07-08 17:26:17 +02:00
|
|
|
/* Older AVR-GCCs may not define the SIGNATURE_n bytes so use explicit 1284p values */
|
|
|
|
.B2 = 0x05,//SIGNATURE_2,
|
|
|
|
.B1 = 0x97,//SIGNATURE_1,
|
|
|
|
.B0 = 0x1E,//SIGNATURE_0,
|
|
|
|
};
|
2009-07-23 18:16:07 +02:00
|
|
|
FUSES ={.low = 0xe2, .high = 0x99, .extended = 0xff,};
|
2008-10-14 23:29:23 +02:00
|
|
|
|
2011-02-07 20:06:53 +01:00
|
|
|
/*----------------------Configuration of EEPROM---------------------------*/
|
|
|
|
/* Use existing EEPROM if it passes the integrity test, else reinitialize with build values */
|
|
|
|
|
2008-10-14 23:29:23 +02:00
|
|
|
/* Put default MAC address in EEPROM */
|
2009-07-26 14:10:38 +02:00
|
|
|
#if WEBSERVER
|
2011-02-07 20:06:53 +01:00
|
|
|
extern uint8_t mac_address[8]; //These are defined in httpd-fsdata.c via makefsdata.h
|
2009-07-23 18:16:07 +02:00
|
|
|
extern uint8_t server_name[16];
|
|
|
|
extern uint8_t domain_name[30];
|
2009-07-26 14:10:38 +02:00
|
|
|
#else
|
2011-02-07 20:06:53 +01:00
|
|
|
uint8_t mac_address[8] PROGMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
|
2009-07-26 14:10:38 +02:00
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
|
2010-09-17 23:59:09 +02:00
|
|
|
|
2011-02-07 20:06:53 +01:00
|
|
|
#ifdef CHANNEL_802_15_4
|
|
|
|
uint8_t rf_channel[2] EEMEM = {CHANNEL_802_15_4, ~CHANNEL_802_15_4};
|
|
|
|
#else
|
|
|
|
uint8_t rf_channel[2] EEMEM = {22, ~22};
|
|
|
|
#endif
|
|
|
|
volatile uint8_t eeprom_channel;
|
2010-09-17 23:59:09 +02:00
|
|
|
static uint8_t get_channel_from_eeprom() {
|
2011-02-07 20:06:53 +01:00
|
|
|
// volatile uint8_t eeprom_channel;
|
2010-09-17 23:59:09 +02:00
|
|
|
uint8_t eeprom_check;
|
2011-02-07 20:06:53 +01:00
|
|
|
eeprom_channel = eeprom_read_byte(&rf_channel[0]);
|
|
|
|
eeprom_check = eeprom_read_byte(&rf_channel[1]);
|
2010-09-17 23:59:09 +02:00
|
|
|
|
|
|
|
if(eeprom_channel==~eeprom_check)
|
|
|
|
return eeprom_channel;
|
2010-12-03 21:42:01 +01:00
|
|
|
|
|
|
|
#ifdef CHANNEL_802_15_4
|
|
|
|
return(CHANNEL_802_15_4);
|
|
|
|
#else
|
2010-09-17 23:59:09 +02:00
|
|
|
return 26;
|
2010-12-03 21:42:01 +01:00
|
|
|
#endif
|
2010-09-17 23:59:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t get_panaddr_from_eeprom(void) {
|
|
|
|
// TODO: Writeme!
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-07 20:06:53 +01:00
|
|
|
void calibrate_rc_osc_32k();
|
2010-09-17 23:59:09 +02:00
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
/*-------------------------Low level initialization------------------------*/
|
|
|
|
/*------Done in a subroutine to keep main routine stack usage small--------*/
|
|
|
|
void initialize(void)
|
2008-10-14 11:40:30 +02:00
|
|
|
{
|
2010-09-17 23:59:09 +02:00
|
|
|
watchdog_init();
|
|
|
|
watchdog_start();
|
2011-02-07 20:06:53 +01:00
|
|
|
|
|
|
|
#define CONFIG_STACK_MONITOR 1
|
|
|
|
#if CONFIG_STACK_MONITOR
|
|
|
|
extern uint16_t __bss_end;
|
|
|
|
__bss_end = 0x4242;
|
|
|
|
*(uint16_t *)(&__bss_end+100) = 0x4242;
|
|
|
|
#endif
|
|
|
|
|
2008-10-15 16:38:20 +02:00
|
|
|
#ifdef RAVEN_LCD_INTERFACE
|
2008-10-14 11:40:30 +02:00
|
|
|
/* First rs232 port for Raven 3290 port */
|
2009-07-23 18:16:07 +02:00
|
|
|
rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
2008-10-14 11:40:30 +02:00
|
|
|
/* Set input handler for 3290 port */
|
|
|
|
rs232_set_input(0,raven_lcd_serial_input);
|
2008-10-15 16:38:20 +02:00
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
|
|
|
|
/* Second rs232 port for debugging */
|
2009-07-23 18:16:07 +02:00
|
|
|
rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
2008-10-14 11:40:30 +02:00
|
|
|
/* Redirect stdout to second port */
|
|
|
|
rs232_redirect_stdout(RS232_PORT_1);
|
2009-07-23 18:16:07 +02:00
|
|
|
clock_init();
|
2011-02-07 20:06:53 +01:00
|
|
|
|
|
|
|
#define CONF_CALIBRATE_OSCCAL 0
|
|
|
|
#if CONF_CALIBRATE_OSCCAL
|
|
|
|
{
|
|
|
|
extern uint8_t osccal_calibrated;
|
|
|
|
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
|
|
|
|
|
2010-02-28 22:29:19 +01:00
|
|
|
#if ANNOUNCE_BOOT
|
2009-07-23 18:16:07 +02:00
|
|
|
printf_P(PSTR("\n*******Booting %s*******\n"),CONTIKI_VERSION_STRING);
|
2010-02-28 22:29:19 +01:00
|
|
|
#endif
|
2009-07-23 18:16:07 +02:00
|
|
|
|
2010-02-28 22:29:19 +01:00
|
|
|
/* rtimers needed for radio cycling */
|
|
|
|
rtimer_init();
|
2010-02-18 18:23:19 +01:00
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
/* Initialize process subsystem */
|
|
|
|
process_init();
|
2010-02-18 18:23:19 +01:00
|
|
|
/* etimers must be started before ctimer_init */
|
|
|
|
process_start(&etimer_process, NULL);
|
2009-07-23 18:16:07 +02:00
|
|
|
|
2010-02-23 18:43:20 +01:00
|
|
|
#if RF230BB
|
2010-02-28 22:29:19 +01:00
|
|
|
|
2010-02-18 18:23:19 +01:00
|
|
|
ctimer_init();
|
2009-07-23 18:16:07 +02:00
|
|
|
/* Start radio and radio receive process */
|
2010-02-28 22:29:19 +01:00
|
|
|
NETSTACK_RADIO.init();
|
2009-07-23 18:16:07 +02:00
|
|
|
|
|
|
|
/* Set addresses BEFORE starting tcpip process */
|
|
|
|
|
2009-07-08 17:26:17 +02:00
|
|
|
rimeaddr_t addr;
|
|
|
|
memset(&addr, 0, sizeof(rimeaddr_t));
|
2010-09-17 23:59:09 +02:00
|
|
|
get_mac_from_eeprom(addr.u8);
|
2009-07-08 17:26:17 +02:00
|
|
|
|
2010-11-12 18:15:00 +01:00
|
|
|
#if UIP_CONF_IPV6
|
|
|
|
memcpy(&uip_lladdr.addr, &addr.u8, 8);
|
|
|
|
#endif
|
2010-09-17 23:59:09 +02:00
|
|
|
rf230_set_pan_addr(
|
|
|
|
get_panid_from_eeprom(),
|
|
|
|
get_panaddr_from_eeprom(),
|
|
|
|
(uint8_t *)&addr.u8
|
|
|
|
);
|
|
|
|
rf230_set_channel(get_channel_from_eeprom());
|
2010-02-18 18:23:19 +01:00
|
|
|
|
2009-07-08 17:26:17 +02:00
|
|
|
rimeaddr_set_node_addr(&addr);
|
|
|
|
|
2010-03-02 17:25:47 +01:00
|
|
|
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]);
|
2010-02-22 23:23:18 +01:00
|
|
|
|
2010-03-02 17:25:47 +01:00
|
|
|
/* Initialize stack protocols */
|
2010-02-18 18:23:19 +01:00
|
|
|
queuebuf_init();
|
2010-02-28 22:29:19 +01:00
|
|
|
NETSTACK_RDC.init();
|
2010-02-22 23:23:18 +01:00
|
|
|
NETSTACK_MAC.init();
|
|
|
|
NETSTACK_NETWORK.init();
|
2010-02-28 22:29:19 +01:00
|
|
|
|
|
|
|
#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());
|
2010-03-02 17:25:47 +01:00
|
|
|
if (tmp<65535) printf_P(PSTR(", check rate %u Hz"),tmp);
|
2010-02-28 22:29:19 +01:00
|
|
|
}
|
|
|
|
printf_P(PSTR("\n"));
|
|
|
|
#endif
|
2009-07-08 17:26:17 +02:00
|
|
|
|
|
|
|
#if UIP_CONF_ROUTER
|
2010-02-28 22:29:19 +01:00
|
|
|
#if ANNOUNCE_BOOT
|
|
|
|
printf_P(PSTR("Routing Enabled\n"));
|
|
|
|
#endif
|
2010-08-03 21:56:27 +02:00
|
|
|
// rime_init(rime_udp_init(NULL));
|
|
|
|
// uip_router_register(&rimeroute);
|
2009-07-08 17:26:17 +02:00
|
|
|
#endif
|
2010-02-18 18:23:19 +01:00
|
|
|
|
|
|
|
process_start(&tcpip_process, NULL);
|
2010-03-02 17:25:47 +01:00
|
|
|
|
|
|
|
#else
|
2010-02-18 18:23:19 +01:00
|
|
|
/* mac process must be started before tcpip process! */
|
|
|
|
process_start(&mac_process, NULL);
|
|
|
|
process_start(&tcpip_process, NULL);
|
2010-03-02 17:25:47 +01:00
|
|
|
#endif /*RF230BB*/
|
2010-02-18 18:23:19 +01:00
|
|
|
|
|
|
|
#ifdef RAVEN_LCD_INTERFACE
|
|
|
|
process_start(&raven_lcd_process, NULL);
|
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
|
2010-02-18 18:23:19 +01:00
|
|
|
/* Autostart other processes */
|
2008-10-14 11:40:30 +02:00
|
|
|
autostart_start(autostart_processes);
|
|
|
|
|
|
|
|
//Give ourselves a prefix
|
2009-07-23 18:16:07 +02:00
|
|
|
// 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>
|
|
|
|
}
|
2010-02-28 22:29:19 +01:00
|
|
|
#endif /* COFFEE_FILES */
|
|
|
|
|
2010-03-17 21:19:33 +01:00
|
|
|
/* Add addresses for testing */
|
2010-02-28 22:29:19 +01:00
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
uip_ip6addr_t ipaddr;
|
|
|
|
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
2010-03-17 21:19:33 +01:00
|
|
|
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
|
|
|
// uip_ds6_prefix_add(&ipaddr,64,0);
|
2010-02-28 22:29:19 +01:00
|
|
|
}
|
2009-07-23 18:16:07 +02:00
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
|
2009-07-23 18:16:07 +02:00
|
|
|
/*--------------------------Announce the configuration---------------------*/
|
2010-02-09 15:43:16 +01:00
|
|
|
#if ANNOUNCE_BOOT
|
|
|
|
|
2009-07-26 14:10:38 +02:00
|
|
|
#if WEBSERVER
|
2010-02-09 15:43:16 +01:00
|
|
|
uint8_t i;
|
2009-07-26 14:10:38 +02:00
|
|
|
char buf[80];
|
|
|
|
unsigned int size;
|
2010-02-28 22:29:19 +01:00
|
|
|
|
2010-03-17 21:19:33 +01:00
|
|
|
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);
|
|
|
|
}
|
2010-02-28 22:29:19 +01:00
|
|
|
}
|
2009-07-23 18:16:07 +02:00
|
|
|
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);
|
2010-02-28 22:29:19 +01:00
|
|
|
#endif /* COFFEE_FILES */
|
2010-02-09 15:43:16 +01:00
|
|
|
|
2009-07-26 14:10:38 +02:00
|
|
|
#else
|
|
|
|
printf_P(PSTR("Online\n"));
|
|
|
|
#endif /* WEBSERVER */
|
2010-02-09 15:43:16 +01:00
|
|
|
|
|
|
|
#endif /* ANNOUNCE_BOOT */
|
2009-07-23 18:16:07 +02:00
|
|
|
}
|
2010-02-28 22:29:19 +01:00
|
|
|
|
2010-02-09 15:43:16 +01:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void log_message(char *m1, char *m2)
|
|
|
|
{
|
|
|
|
printf_P(PSTR("%s%s\n"), m1, m2);
|
|
|
|
}
|
2010-02-28 22:29:19 +01:00
|
|
|
/* 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 */
|
|
|
|
|
2010-03-02 17:25:47 +01:00
|
|
|
#if RF230BB
|
|
|
|
extern char rf230_interrupt_flag, rf230processflag;
|
|
|
|
#endif
|
2009-07-23 18:16:07 +02:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/*------------------------- Main Scheduler loop----------------------------*/
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
initialize();
|
2010-02-28 22:29:19 +01:00
|
|
|
|
2008-10-14 11:40:30 +02:00
|
|
|
while(1) {
|
|
|
|
process_run();
|
2011-02-07 20:06:53 +01:00
|
|
|
|
|
|
|
#if CONFIG_STACK_MONITOR
|
|
|
|
extern uint16_t __bss_end;
|
|
|
|
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
|
|
|
|
/* Clock.c can trigger a periodic RF PLL calibration */
|
|
|
|
extern uint8_t rf230_calibrated;
|
|
|
|
if (rf230_calibrated) {
|
|
|
|
printf_P(PSTR("\nRF230 calibrated!"));
|
|
|
|
rf230_calibrated=0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-28 22:29:19 +01:00
|
|
|
//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();
|
2010-09-17 23:59:09 +02:00
|
|
|
watchdog_periodic();
|
2010-02-28 22:29:19 +01:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
rtime+=1;
|
|
|
|
#if PINGS
|
|
|
|
if ((rtime%PINGS)==0) {
|
|
|
|
PRINTF("**Ping\n");
|
|
|
|
raven_ping6();
|
|
|
|
}
|
|
|
|
#endif
|
2010-02-18 18:23:19 +01:00
|
|
|
}
|
|
|
|
#endif
|
2010-02-28 22:29:19 +01:00
|
|
|
|
2010-03-02 17:25:47 +01:00
|
|
|
//Use with RF230BB DEBUGFLOW to show path through driver
|
2010-06-18 17:45:55 +02:00
|
|
|
#if RF230BB&&0
|
2010-03-02 17:25:47 +01:00
|
|
|
extern uint8_t debugflowsize,debugflow[];
|
|
|
|
if (debugflowsize) {
|
|
|
|
debugflow[debugflowsize]=0;
|
|
|
|
printf("%s",debugflow);
|
|
|
|
debugflowsize=0;
|
2010-02-28 22:29:19 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RF230BB&&0
|
2010-02-18 18:23:19 +01:00
|
|
|
if (rf230processflag) {
|
|
|
|
printf("rf230p%d",rf230processflag);
|
|
|
|
rf230processflag=0;
|
2010-02-28 22:29:19 +01:00
|
|
|
}
|
2010-02-18 18:23:19 +01:00
|
|
|
#endif
|
2009-07-08 17:26:17 +02:00
|
|
|
|
2010-02-28 22:29:19 +01:00
|
|
|
#if RF230BB&&0
|
2009-07-08 17:26:17 +02:00
|
|
|
if (rf230_interrupt_flag) {
|
2010-02-28 22:29:19 +01:00
|
|
|
// if (rf230_interrupt_flag!=11) {
|
2010-02-22 23:23:18 +01:00
|
|
|
PRINTSHORT("**RI%u",rf230_interrupt_flag);
|
2010-02-28 22:29:19 +01:00
|
|
|
// }
|
|
|
|
rf230_interrupt_flag=0;
|
2009-07-08 17:26:17 +02:00
|
|
|
}
|
2009-07-23 18:16:07 +02:00
|
|
|
#endif
|
2008-10-14 11:40:30 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|