Clean up, functional webserver for further testing of low power protocols
This commit is contained in:
parent
d61676b8f7
commit
39e6f6a830
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: rtimer-arch.c,v 1.9 2010/02/26 20:51:48 dak664 Exp $
|
* $Id: rtimer-arch.c,v 1.10 2010/02/28 21:29:19 dak664 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__AVR_AT90USB1287__)
|
#if defined(__AVR_AT90USB1287__)
|
||||||
#warning AT90USB1287 rtimers not tested
|
|
||||||
#define ETIMSK TIMSK3
|
#define ETIMSK TIMSK3
|
||||||
#define ETIFR TIFR3
|
#define ETIFR TIFR3
|
||||||
#define TICIE3 ICIE3
|
#define TICIE3 ICIE3
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: raven-lcd.c,v 1.5 2010/02/12 16:46:39 dak664 Exp $
|
* $Id: raven-lcd.c,v 1.6 2010/02/28 21:29:20 dak664 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +101,8 @@ void rs232_send(uint8_t port, unsigned char c);
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Sends a ping packet out the radio */
|
/* Sends a ping packet out the radio */
|
||||||
static void
|
/* Useful for debugging so allow external calls */
|
||||||
|
void
|
||||||
raven_ping6(void)
|
raven_ping6(void)
|
||||||
{
|
{
|
||||||
/* ping the router */
|
/* ping the router */
|
||||||
|
@ -33,27 +33,20 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Configuration for sample STK 501 Contiki kernel
|
* Configuration for Atmel Raven
|
||||||
*
|
*
|
||||||
* \author
|
* \author
|
||||||
* Simon Barner <barner@in.tum.de
|
* Simon Barner <barner@in.tum.de>
|
||||||
|
* David Kopf <dak664@embarqmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CONTIKI_CONF_H__
|
#ifndef __CONTIKI_CONF_H__
|
||||||
#define __CONTIKI_CONF_H__
|
#define __CONTIKI_CONF_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
/* MCU, Clock rate, ticks per second */
|
||||||
|
|
||||||
typedef int32_t s32_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MCU and clock rate
|
|
||||||
*/
|
|
||||||
#define MCU_MHZ 8
|
|
||||||
#define PLATFORM PLATFORM_AVR
|
#define PLATFORM PLATFORM_AVR
|
||||||
#define RAVEN_REVISION RAVEN_D
|
#define RAVEN_REVISION RAVEN_D
|
||||||
|
#define MCU_MHZ 8
|
||||||
/* Clock ticks per second */
|
|
||||||
#define CLOCK_CONF_SECOND 125
|
#define CLOCK_CONF_SECOND 125
|
||||||
|
|
||||||
/* COM port to be used for SLIP connection */
|
/* COM port to be used for SLIP connection */
|
||||||
@ -69,61 +62,69 @@ typedef int32_t s32_t;
|
|||||||
|
|
||||||
#define CCIF
|
#define CCIF
|
||||||
#define CLIF
|
#define CLIF
|
||||||
|
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2
|
||||||
#define RIMEADDR_CONF_SIZE 8
|
#define RIMEADDR_CONF_SIZE 8
|
||||||
#define PACKETBUF_CONF_HDR_SIZE 0 //RF230 handles headers internally
|
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC01
|
||||||
|
//#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||||
|
|
||||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
/* RF230BB must be used with low power protocols */
|
||||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
|
||||||
#define SICSLOWPAN_CONF_FRAG 1
|
|
||||||
|
|
||||||
/* Network setup for IPv6 */
|
|
||||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
|
||||||
//#define NETSTACK_CONF_MAC nullmac_driver
|
|
||||||
#define NETSTACK_CONF_MAC csma_driver
|
|
||||||
//#define NETSTACK_CONF_RDC contikimac_driver
|
|
||||||
#define NETSTACK_CONF_RDC sicslowmac_driver
|
|
||||||
#define NETSTACK_CONF_RADIO rf230_driver
|
|
||||||
|
|
||||||
/* Below will prevent fragmentation of TCP packets, undef for faster page loads, simpler wireshark captures */
|
|
||||||
//#define UIP_CONF_TCP_MSS 48
|
|
||||||
|
|
||||||
/* Fragmentation uses queuebuf.c to save packets */
|
|
||||||
#define QUEUEBUF_CONF_NUM 1
|
|
||||||
#define QUEUEBUF_CONF_REF_NUM 1
|
|
||||||
|
|
||||||
/* Logging adds 200 bytes to program size */
|
|
||||||
#define LOG_CONF_ENABLED 1
|
|
||||||
|
|
||||||
/* RF230BB reduces program size by 6.5KB, RAM by 500 bytes */
|
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
|
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
|
||||||
#undef PACKETBUF_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
|
#undef PACKETBUF_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
|
||||||
#define UIP_CONF_ROUTER 0
|
#else
|
||||||
|
#define PACKETBUF_CONF_HDR_SIZE 0 //RF230 handles headers internally
|
||||||
#if 0
|
|
||||||
/* Specifies the default MAC driver */
|
|
||||||
//no auto_ack gives bad FCS for some reason?
|
|
||||||
//#define RF230_CONF_NO_AUTO_ACK 1
|
|
||||||
#define MAC_CONF_CSMA 1
|
|
||||||
#define XMAC_CONF_COMPOWER 1
|
|
||||||
#define CXMAC_CONF_COMPOWER 1
|
|
||||||
#define MAC_CONF_DRIVER cxmac_driver
|
|
||||||
#define MAC_CONF_CHANNEL_CHECK_RATE 8
|
|
||||||
//following gives 50% duty cycle, undef for 5%
|
|
||||||
#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
|
|
||||||
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
|
|
||||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
|
||||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#undef SICSLOWPAN_CONF_FRAG
|
|
||||||
//#define SICSLOWPAN_CONF_FRAG 0 //for sky equivalence with barebones driver
|
|
||||||
//#define UIP_CONF_BUFFER_SIZE 256 //for sky equivalence with barebones driver
|
|
||||||
//#define UIP_CONF_ROUTER 1
|
|
||||||
#endif /*RF230BB */
|
#endif /*RF230BB */
|
||||||
|
|
||||||
#define SICSLOWPAN_CONF_MAXAGE 5
|
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||||
|
|
||||||
|
#if 1 /* Network setup */
|
||||||
|
|
||||||
|
/* No radio cycling */
|
||||||
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
|
#define NETSTACK_CONF_RDC sicslowmac_driver
|
||||||
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
|
#define RF230_CONF_AUTO_ACK 1
|
||||||
|
#define RF230_CONF_AUTO_RETRIES 2
|
||||||
|
#define SICSLOWPAN_CONF_FRAG 1
|
||||||
|
//Most browsers reissue GETs after 3 seconds which stops frag reassembly, longer MAXAGE does no good
|
||||||
|
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||||
|
#define QUEUEBUF_CONF_NUM 1
|
||||||
|
#define QUEUEBUF_CONF_REF_NUM 1
|
||||||
|
|
||||||
|
#elif 0
|
||||||
|
/* Contiki-mac radio cycling */
|
||||||
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
|
#define NETSTACK_CONF_RDC contikimac_driver
|
||||||
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
|
#define RF230_CONF_AUTO_ACK 0
|
||||||
|
#define RF230_CONF_AUTO_RETRIES 0
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* cx-mac radio cycling */
|
||||||
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
|
#define NETSTACK_CONF_RDC cxmac_driver
|
||||||
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
|
#define RF230_CONF_AUTO_ACK 0
|
||||||
|
#define RF230_CONF_AUTO_RETRIES 0
|
||||||
|
#define MAC_CONF_CHANNEL_CHECK_RATE 8
|
||||||
|
#define SICSLOWPAN_CONF_FRAG 1
|
||||||
|
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||||
|
#define QUEUEBUF_CONF_NUM 4
|
||||||
|
#define QUEUEBUF_CONF_REF_NUM 2
|
||||||
|
//Below will prevent fragmentation of TCP packets, undef for faster page loads, simpler wireshark captures
|
||||||
|
//#define UIP_CONF_TCP_MSS 48
|
||||||
|
//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)
|
||||||
|
|
||||||
|
#endif /* Network setup */
|
||||||
|
|
||||||
|
/* Logging adds 200 bytes to program size */
|
||||||
|
#define LOG_CONF_ENABLED 1
|
||||||
|
|
||||||
#define UIP_CONF_LL_802154 1
|
#define UIP_CONF_LL_802154 1
|
||||||
#define UIP_CONF_LLH_LEN 0
|
#define UIP_CONF_LLH_LEN 0
|
||||||
@ -141,7 +142,7 @@ typedef int32_t s32_t;
|
|||||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||||
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
||||||
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
||||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
||||||
#define UIP_CONF_ICMP6 1
|
#define UIP_CONF_ICMP6 1
|
||||||
|
|
||||||
@ -152,6 +153,9 @@ typedef int32_t s32_t;
|
|||||||
#define UIP_CONF_TCP_SPLIT 1
|
#define UIP_CONF_TCP_SPLIT 1
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef int32_t s32_t;
|
||||||
typedef unsigned short clock_time_t;
|
typedef unsigned short clock_time_t;
|
||||||
typedef unsigned char u8_t;
|
typedef unsigned char u8_t;
|
||||||
typedef unsigned short u16_t;
|
typedef unsigned short u16_t;
|
||||||
|
@ -30,13 +30,14 @@
|
|||||||
*
|
*
|
||||||
* @(#)$$
|
* @(#)$$
|
||||||
*/
|
*/
|
||||||
|
#define ANNOUNCE_BOOT 1 //adds about 600 bytes to program size
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||||
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
#define PRINTSHORT(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
|
||||||
int pingtimer1=0,pingtimer2=0;
|
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
extern int rf230_interrupt_flag;
|
extern char rf230_interrupt_flag, rf230processflag;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define PRINTF(...)
|
#define PRINTF(...)
|
||||||
@ -67,21 +68,6 @@ extern int rf230_interrupt_flag;
|
|||||||
//#include "dev/xmem.h"
|
//#include "dev/xmem.h"
|
||||||
//#include "net/rime.h"
|
//#include "net/rime.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
#if WITH_NULLMAC
|
|
||||||
#define MAC_DRIVER nullmac_driver
|
|
||||||
#endif /* WITH_NULLMAC */
|
|
||||||
|
|
||||||
#ifndef MAC_DRIVER
|
|
||||||
#ifdef MAC_CONF_DRIVER
|
|
||||||
#define MAC_DRIVER MAC_CONF_DRIVER
|
|
||||||
#else
|
|
||||||
#define MAC_DRIVER sicslowmac1_driver
|
|
||||||
//#define MAC_DRIVER cxmac_driver
|
|
||||||
#endif /* MAC_CONF_DRIVER */
|
|
||||||
#endif /* MAC_DRIVER */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
@ -159,10 +145,12 @@ void initialize(void)
|
|||||||
/* Redirect stdout to second port */
|
/* Redirect stdout to second port */
|
||||||
rs232_redirect_stdout(RS232_PORT_1);
|
rs232_redirect_stdout(RS232_PORT_1);
|
||||||
clock_init();
|
clock_init();
|
||||||
|
#if ANNOUNCE_BOOT
|
||||||
printf_P(PSTR("\n*******Booting %s*******\n"),CONTIKI_VERSION_STRING);
|
printf_P(PSTR("\n*******Booting %s*******\n"),CONTIKI_VERSION_STRING);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* rtimers not used yet */
|
/* rtimers needed for radio cycling */
|
||||||
// rtimer_init();
|
rtimer_init();
|
||||||
|
|
||||||
/* Initialize process subsystem */
|
/* Initialize process subsystem */
|
||||||
process_init();
|
process_init();
|
||||||
@ -170,10 +158,11 @@ void initialize(void)
|
|||||||
process_start(&etimer_process, NULL);
|
process_start(&etimer_process, NULL);
|
||||||
|
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
{
|
|
||||||
ctimer_init();
|
ctimer_init();
|
||||||
/* Start radio and radio receive process */
|
/* Start radio and radio receive process */
|
||||||
rf230_init();
|
NETSTACK_RADIO.init();
|
||||||
|
//rf230_init();
|
||||||
|
|
||||||
/* Set addresses BEFORE starting tcpip process */
|
/* Set addresses BEFORE starting tcpip process */
|
||||||
|
|
||||||
@ -193,36 +182,33 @@ void initialize(void)
|
|||||||
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]);
|
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]);
|
||||||
|
|
||||||
framer_set(&framer_802154);
|
framer_set(&framer_802154);
|
||||||
|
// process_start(&tcpip_process, NULL); //must be done before network inits?
|
||||||
|
|
||||||
/* Setup X-MAC for 802.15.4 */
|
/* Setup X-MAC for 802.15.4 */
|
||||||
queuebuf_init();
|
queuebuf_init();
|
||||||
NETSTACK_RDC.init(); //prints rs2048
|
NETSTACK_RDC.init();
|
||||||
NETSTACK_MAC.init();
|
NETSTACK_MAC.init();
|
||||||
NETSTACK_NETWORK.init();
|
NETSTACK_NETWORK.init();
|
||||||
//todo: makes raven reboot
|
|
||||||
// printf(" %s, channel check rate %d Hz, radio channel %u\n",
|
|
||||||
// sicslowpan_mac->name,
|
|
||||||
// CLOCK_SECOND / (sicslowpan_mac->channel_check_interval() == 0? 1:
|
|
||||||
// sicslowpan_mac->channel_check_interval()),
|
|
||||||
// RF_CHANNEL);
|
|
||||||
|
|
||||||
// uip_ip6addr(&ipprefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
#if ANNOUNCE_BOOT
|
||||||
// uip_netif_addr_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0, AUTOCONF);
|
printf_P(PSTR("%s %s, channel %u"),NETSTACK_MAC.name, NETSTACK_RDC.name,rf230_get_channel());
|
||||||
// uip_nd6_prefix_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0);
|
if (NETSTACK_RDC.channel_check_interval) {//function pointer is zero for sicslowmac
|
||||||
// PRINTF("Prefix %x::/%u\n",ipprefix.u16[0],UIP_DEFAULT_PREFIX_LEN);
|
unsigned short tmp;
|
||||||
|
tmp=CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval == 0 ? 1:\
|
||||||
|
NETSTACK_RDC.channel_check_interval());
|
||||||
|
printf_P(PSTR(", check rate %u Hz"),tmp);
|
||||||
|
}
|
||||||
|
printf_P(PSTR("\n"));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if UIP_CONF_ROUTER
|
#if UIP_CONF_ROUTER
|
||||||
#warning Routing enabled
|
#if ANNOUNCE_BOOT
|
||||||
PRINTF("Routing Enabled\n")
|
printf_P(PSTR("Routing Enabled\n"));
|
||||||
|
#endif
|
||||||
rime_init(rime_udp_init(NULL));
|
rime_init(rime_udp_init(NULL));
|
||||||
uip_router_register(&rimeroute);
|
uip_router_register(&rimeroute);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// sicslowpan_init(MAC_DRIVER.init(&rf230_driver));
|
|
||||||
|
|
||||||
// PRINTF("Driver: %s, Channel: %u\n\r", MAC_DRIVER.name, rf230_get_channel());
|
|
||||||
PRINTF("Driver: %s, Channel: %u\n", sicslowpan_mac->name, rf230_get_channel());
|
|
||||||
}
|
|
||||||
#endif /*RF230BB*/
|
#endif /*RF230BB*/
|
||||||
|
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
@ -258,35 +244,7 @@ void initialize(void)
|
|||||||
// fa = cfs_open("upload.html"), CFW_WRITE);
|
// 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>
|
// <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
|
#endif /* COFFEE_FILES */
|
||||||
|
|
||||||
/*--------------------------Announce the configuration---------------------*/
|
|
||||||
#define ANNOUNCE_BOOT 1 //adds about 400 bytes to program size
|
|
||||||
|
|
||||||
#if ANNOUNCE_BOOT
|
|
||||||
|
|
||||||
#if WEBSERVER
|
|
||||||
|
|
||||||
uint8_t i;
|
|
||||||
char buf[80];
|
|
||||||
unsigned int size;
|
|
||||||
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
|
|
||||||
|
|
||||||
/* Add prefixes for testing */
|
/* Add prefixes for testing */
|
||||||
#if 0
|
#if 0
|
||||||
@ -306,28 +264,63 @@ void initialize(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*--------------------------Announce the configuration---------------------*/
|
||||||
|
#if ANNOUNCE_BOOT
|
||||||
|
|
||||||
|
#if WEBSERVER
|
||||||
|
uint8_t i;
|
||||||
|
char buf[80];
|
||||||
|
unsigned int size;
|
||||||
|
|
||||||
for(i = 0; i < UIP_CONF_NETIF_MAX_ADDRESSES; i ++) {
|
for(i = 0; i < UIP_CONF_NETIF_MAX_ADDRESSES; i ++) {
|
||||||
if(uip_netif_physical_if.addresses[i].state != NOT_USED) {
|
if(uip_netif_physical_if.addresses[i].state != NOT_USED) {
|
||||||
httpd_cgi_sprint_ip6(*(uip_ipaddr_t*)&uip_netif_physical_if.addresses[i],buf);
|
httpd_cgi_sprint_ip6(*(uip_ipaddr_t*)&uip_netif_physical_if.addresses[i],buf);
|
||||||
printf_P(PSTR("IPv6 Address: %s\n"),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
|
#else
|
||||||
printf_P(PSTR("Online\n"));
|
printf_P(PSTR("Online\n"));
|
||||||
#endif /* WEBSERVER */
|
#endif /* WEBSERVER */
|
||||||
|
|
||||||
#endif /* ANNOUNCE_BOOT */
|
#endif /* ANNOUNCE_BOOT */
|
||||||
|
|
||||||
}
|
}
|
||||||
#if RF230BB
|
|
||||||
extern uint8_t rf230processflag; //for debugging process call problems
|
|
||||||
#endif
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void log_message(char *m1, char *m2)
|
void log_message(char *m1, char *m2)
|
||||||
{
|
{
|
||||||
printf_P(PSTR("%s%s\n"), m1, m2);
|
printf_P(PSTR("%s%s\n"), m1, m2);
|
||||||
}
|
}
|
||||||
extern uint8_t rtimerworks;
|
/* 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 */
|
||||||
|
|
||||||
|
extern uint8_t packetreceived;
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
/*------------------------- Main Scheduler loop----------------------------*/
|
/*------------------------- Main Scheduler loop----------------------------*/
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@ -335,41 +328,63 @@ int
|
|||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
process_run();
|
process_run();
|
||||||
#if 0
|
//Various entry points for debugging in AVR simulator
|
||||||
if (rtimerworks>200) {
|
// NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
|
||||||
printf("%d",rtimerworks);
|
// process_poll(&rf230_process);
|
||||||
rtimerworks=0;
|
// packetbuf_clear();
|
||||||
|
// len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
||||||
|
// packetbuf_set_datalen(42);
|
||||||
|
// NETSTACK_RDC.input();
|
||||||
|
|
||||||
|
#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
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if RF230BB && 0
|
|
||||||
|
//Use with RF230BB RADIOALWAYSON to show packets missed when radio is "off"
|
||||||
|
#if RF230BB&&1
|
||||||
|
if (packetreceived) {
|
||||||
|
if (packetreceived==1) { //missed
|
||||||
|
printf("-");
|
||||||
|
} else { //passed to stack
|
||||||
|
printf("+");
|
||||||
|
}
|
||||||
|
packetreceived=0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if RF230BB&&0
|
||||||
if (rf230processflag) {
|
if (rf230processflag) {
|
||||||
printf("rf230p%d",rf230processflag);
|
printf("rf230p%d",rf230processflag);
|
||||||
rf230processflag=0;
|
rf230processflag=0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if RF230BB&&0
|
||||||
if (rf230_interrupt_flag) {
|
if (rf230_interrupt_flag) {
|
||||||
// if (rf230_interrupt_flag!=11) {
|
// if (rf230_interrupt_flag!=11) {
|
||||||
// PRINTF("*****Radio interrupt %u\n",rf230_interrupt_flag);
|
|
||||||
PRINTSHORT("**RI%u",rf230_interrupt_flag);
|
PRINTSHORT("**RI%u",rf230_interrupt_flag);
|
||||||
rf230_interrupt_flag=0;
|
// }
|
||||||
// }
|
rf230_interrupt_flag=0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if PINGS
|
|
||||||
if (pingtimer1++==10000) {
|
|
||||||
pingtimer1=0;
|
|
||||||
if (pingtimer2++==1000) {
|
|
||||||
PRINTF("-------Ping\n");
|
|
||||||
pingtimer2=0;
|
|
||||||
raven_ping6();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,16 @@ typedef int32_t s32_t;
|
|||||||
|
|
||||||
#define RIMEADDR_CONF_SIZE 8
|
#define RIMEADDR_CONF_SIZE 8
|
||||||
|
|
||||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
/* 0 for IPv6, or 1 for HC1, 2 for HC01 */
|
||||||
|
//#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0
|
||||||
|
//#define SICSLOWPAN_CONF_COMPRESSION_HC1 1
|
||||||
|
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2
|
||||||
|
//#ifndef SICSLOWPAN_COMPRESSION_HC06
|
||||||
|
//#warning hc06 not defined
|
||||||
|
//#endif
|
||||||
|
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC01
|
||||||
|
//#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||||
#define SICSLOWPAN_CONF_FRAG 1
|
|
||||||
|
|
||||||
#define SICSLOWPAN_CONF_MAXAGE 3
|
|
||||||
|
|
||||||
#define UIP_CONF_LL_802154 1
|
#define UIP_CONF_LL_802154 1
|
||||||
#define UIP_CONF_LLH_LEN 14
|
#define UIP_CONF_LLH_LEN 14
|
||||||
@ -114,18 +119,47 @@ typedef int32_t s32_t;
|
|||||||
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
|
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
|
||||||
//#undef PACKETBUF_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
|
//#undef PACKETBUF_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
|
||||||
|
|
||||||
/* Network setup for IPv6 */
|
#if 1 /* Network setup */
|
||||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
/* No radio cycling */
|
||||||
//#define NETSTACK_CONF_MAC nullmac_driver
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
#define NETSTACK_CONF_MAC csma_driver
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
//#define NETSTACK_CONF_RDC contikimac_driver
|
#define NETSTACK_CONF_RDC sicslowmac_driver
|
||||||
#define NETSTACK_CONF_RDC sicslowmac_driver
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
#define NETSTACK_CONF_RADIO rf230_driver
|
#define RF230_CONF_AUTO_ACK 1
|
||||||
#endif
|
#define RF230_CONF_AUTO_RETRIES 2
|
||||||
|
#define QUEUEBUF_CONF_NUM 1
|
||||||
|
#define QUEUEBUF_CONF_REF_NUM 1
|
||||||
|
#define SICSLOWPAN_CONF_FRAG 1
|
||||||
|
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||||
|
|
||||||
/* Fragmentation uses queuebuf.c to save packets */
|
#elif 0
|
||||||
#define QUEUEBUF_CONF_NUM 1
|
/* Contiki-mac radio cycling */
|
||||||
#define QUEUEBUF_CONF_REF_NUM 1
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
|
#define NETSTACK_CONF_RDC contikimac_driver
|
||||||
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
|
#define RF230_CONF_AUTO_ACK 0
|
||||||
|
#define RF230_CONF_AUTO_RETRIES 0
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* cx-mac radio cycling */
|
||||||
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
|
#define NETSTACK_CONF_RDC cxmac_driver
|
||||||
|
#define NETSTACK_CONF_RADIO rf230_driver
|
||||||
|
#define RF230_CONF_AUTO_ACK 0
|
||||||
|
#define RF230_CONF_AUTO_RETRIES 0
|
||||||
|
#define MAC_CONF_CHANNEL_CHECK_RATE 8
|
||||||
|
#define SICSLOWPAN_CONF_FRAG 1
|
||||||
|
#define QUEUEBUF_CONF_NUM 4
|
||||||
|
#define QUEUEBUF_CONF_REF_NUM 2
|
||||||
|
#define SICSLOWPAN_CONF_MAXAGE 3
|
||||||
|
//following gives 50% duty cycle, undef for default 5%
|
||||||
|
#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
|
||||||
|
|
||||||
|
#endif /* Network setup */
|
||||||
|
|
||||||
|
#endif /* RF230BB */
|
||||||
|
|
||||||
/* Route-Under-MAC uses 16-bit short addresses */
|
/* Route-Under-MAC uses 16-bit short addresses */
|
||||||
#if UIP_CONF_USE_RUM
|
#if UIP_CONF_USE_RUM
|
||||||
@ -133,37 +167,6 @@ typedef int32_t s32_t;
|
|||||||
#define UIP_DATA_RUM_OFFSET 5
|
#define UIP_DATA_RUM_OFFSET 5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if RF230BB && 0 //xmac protocol
|
|
||||||
#undef UIP_CONF_ROUTER
|
|
||||||
#undef UIP_CONF_LLH_LEN
|
|
||||||
#define UIP_CONF_LLH_LEN 14
|
|
||||||
#undef XMAC_CONF_COMPOWER
|
|
||||||
#define XMAC_CONF_COMPOWER 1
|
|
||||||
#undef XMAC_CONF_ANNOUNCEMENTS
|
|
||||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
|
||||||
#undef RF_CHANNEL
|
|
||||||
#define RF_CHANNEL 26
|
|
||||||
//#define CC2420_CONF_AUTOACK 0
|
|
||||||
#undef UIP_CONF_BUFFER_SIZE
|
|
||||||
#define UIP_CONF_BUFFER_SIZE 256
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if RF230BB && 0
|
|
||||||
/* Specifies the default MAC driver */
|
|
||||||
//no autoack gives bad FCS for some reason?
|
|
||||||
//#define RF230_CONF_NO_AUTO_ACK 1
|
|
||||||
#define MAC_CONF_CSMA 1
|
|
||||||
#define XMAC_CONF_COMPOWER 1
|
|
||||||
#define CXMAC_CONF_COMPOWER 1
|
|
||||||
//following gives 50% duty cycle, undef for 5%
|
|
||||||
#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
|
|
||||||
#define MAC_CONF_DRIVER cxmac_driver
|
|
||||||
#define MAC_CONF_CHANNEL_CHECK_RATE 8
|
|
||||||
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
|
|
||||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
|
||||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned short clock_time_t;
|
typedef unsigned short clock_time_t;
|
||||||
typedef unsigned char u8_t;
|
typedef unsigned char u8_t;
|
||||||
typedef unsigned short u16_t;
|
typedef unsigned short u16_t;
|
||||||
|
@ -60,19 +60,6 @@
|
|||||||
#include "net/mac/lpp.h"
|
#include "net/mac/lpp.h"
|
||||||
//#include "dev/xmem.h"
|
//#include "dev/xmem.h"
|
||||||
|
|
||||||
#if WITH_NULLMAC
|
|
||||||
#define MAC_DRIVER nullmac_driver
|
|
||||||
#endif /* WITH_NULLMAC */
|
|
||||||
|
|
||||||
#ifndef MAC_DRIVER
|
|
||||||
#ifdef MAC_CONF_DRIVER
|
|
||||||
#define MAC_DRIVER MAC_CONF_DRIVER
|
|
||||||
#else
|
|
||||||
#define MAC_DRIVER sicslowmac_driver
|
|
||||||
//#define MAC_DRIVER cxmac_driver
|
|
||||||
#endif /* MAC_CONF_DRIVER */
|
|
||||||
#endif /* MAC_DRIVER */
|
|
||||||
|
|
||||||
#include "net/mac/sicslowmac.h"
|
#include "net/mac/sicslowmac.h"
|
||||||
#include "net/mac/cxmac.h"
|
#include "net/mac/cxmac.h"
|
||||||
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
||||||
@ -98,7 +85,6 @@
|
|||||||
#include "storage/storage_task.h"
|
#include "storage/storage_task.h"
|
||||||
|
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
//#warning Experimental RF230BB radio selected
|
|
||||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
extern int rf230_interrupt_flag;
|
extern int rf230_interrupt_flag;
|
||||||
extern uint8_t rf230processflag;
|
extern uint8_t rf230processflag;
|
||||||
@ -118,7 +104,7 @@ tcpip_ipv6_output(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
/*----------------------Configuration of the .elf file---------------------*/
|
/*----------------------Configuration of the .elf file---------------------*/
|
||||||
typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t;
|
typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t;
|
||||||
#define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
|
#define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
|
||||||
@ -140,20 +126,23 @@ uint8_t mac_address[8] EEMEM = {0x02, 0x12, 0x13, 0xff, 0xfe, 0x14, 0x15, 0x16};
|
|||||||
rimeaddr_t macLongAddr;
|
rimeaddr_t macLongAddr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//uint8_t rtimerworks;
|
/* Test rtimers, also useful for pings and time stamps in simulator */
|
||||||
int
|
#define TESTRTIMER 0
|
||||||
main(void)
|
#if TESTRTIMER
|
||||||
{
|
#define PINGS 0
|
||||||
#if ANNOUNCE
|
#define STAMPS 30
|
||||||
uint32_t firsttime=0;
|
uint8_t rtimerflag=1;
|
||||||
#endif
|
uint16_t rtime;
|
||||||
|
struct rtimer rt;
|
||||||
|
void rtimercycle(void) {rtimerflag=1;}
|
||||||
|
#endif /* TESTRTIMER */
|
||||||
|
|
||||||
|
/*-------------------------Low level initialization-----------------*/
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
rimeaddr_t addr;
|
rimeaddr_t addr;
|
||||||
#endif
|
#endif
|
||||||
/*
|
extern uint8_t packetreceived;
|
||||||
* GCC depends on register r1 set to 0.
|
static void initialize(void) {
|
||||||
*/
|
|
||||||
asm volatile ("clr r1");
|
|
||||||
|
|
||||||
/* Initialize hardware */
|
/* Initialize hardware */
|
||||||
init_lowlevel();
|
init_lowlevel();
|
||||||
@ -175,7 +164,8 @@ main(void)
|
|||||||
ctimer_init();
|
ctimer_init();
|
||||||
/* Start radio and radio receive process */
|
/* Start radio and radio receive process */
|
||||||
/* Note this starts RF230 process, so must be done after process_init */
|
/* Note this starts RF230 process, so must be done after process_init */
|
||||||
rf230_init();
|
NETSTACK_RADIO.init();
|
||||||
|
//rf230_init();
|
||||||
|
|
||||||
/* Set addresses BEFORE starting tcpip process */
|
/* Set addresses BEFORE starting tcpip process */
|
||||||
|
|
||||||
@ -193,23 +183,21 @@ main(void)
|
|||||||
macLongAddr.u8[6]=addr.u8[1];
|
macLongAddr.u8[6]=addr.u8[1];
|
||||||
macLongAddr.u8[7]=addr.u8[0];
|
macLongAddr.u8[7]=addr.u8[0];
|
||||||
|
|
||||||
memcpy(&uip_lladdr.addr, &addr.u8, 8);
|
memcpy(&uip_lladdr.addr, &addr.u8, 8);
|
||||||
rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8);
|
rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8);
|
||||||
|
|
||||||
rf230_set_channel(24);
|
rf230_set_channel(24);
|
||||||
|
|
||||||
rimeaddr_set_node_addr(&addr);
|
rimeaddr_set_node_addr(&addr);
|
||||||
// set_rime_addr();
|
// set_rime_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]);
|
|
||||||
|
|
||||||
framer_set(&framer_802154);
|
framer_set(&framer_802154);
|
||||||
|
// process_start(&tcpip_process, NULL);
|
||||||
/* Setup X-MAC for 802.15.4 */
|
/* Setup X-MAC for 802.15.4 */
|
||||||
queuebuf_init();
|
queuebuf_init();
|
||||||
NETSTACK_RDC.init();
|
NETSTACK_RDC.init();
|
||||||
NETSTACK_MAC.init();
|
NETSTACK_MAC.init();
|
||||||
NETSTACK_NETWORK.init();
|
NETSTACK_NETWORK.init();
|
||||||
// PRINTF("Driver: %s, Channel: %u\n", sicslowpan_mac->name, rf230_get_channel());
|
|
||||||
|
|
||||||
#if UIP_CONF_ROUTER
|
#if UIP_CONF_ROUTER
|
||||||
rime_init(rime_udp_init(NULL));
|
rime_init(rime_udp_init(NULL));
|
||||||
@ -226,7 +214,7 @@ main(void)
|
|||||||
process_start(&mac_process, NULL);
|
process_start(&mac_process, NULL);
|
||||||
process_start(&tcpip_process, NULL);
|
process_start(&tcpip_process, NULL);
|
||||||
|
|
||||||
#endif
|
#endif /* RF230BB */
|
||||||
|
|
||||||
/* Setup USB */
|
/* Setup USB */
|
||||||
process_start(&usb_process, NULL);
|
process_start(&usb_process, NULL);
|
||||||
@ -236,45 +224,96 @@ main(void)
|
|||||||
|
|
||||||
//Fix MAC address
|
//Fix MAC address
|
||||||
init_net();
|
init_net();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
/*---------------------------------Main Routine----------------------------*/
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
#if ANNOUNCE
|
||||||
|
uint16_t firsttime=1;
|
||||||
|
#endif
|
||||||
|
/* GCC depends on register r1 set to 0 (?) */
|
||||||
|
asm volatile ("clr r1");
|
||||||
|
|
||||||
/* Main scheduler loop */
|
/* Initialize in a subroutine to maximize stack space */
|
||||||
|
initialize();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
process_run();
|
process_run();
|
||||||
#if 0
|
|
||||||
if (rtimerworks) {
|
#if TESTRTIMER
|
||||||
printf("i");
|
if (rtimerflag) { //8 seconds is maximum interval, my jackdaw 4% slow
|
||||||
rtimerworks=0;
|
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
|
#endif
|
||||||
|
rtime+=1;
|
||||||
|
#if PINGS
|
||||||
|
if ((rtime%PINGS)==0) {
|
||||||
|
PRINTF("**Ping\n");
|
||||||
|
pingsomebody();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* TESTRTIMER */
|
||||||
|
|
||||||
|
//Use with RF230BB RADIOALWAYSON to show packets missed when radio is "off"
|
||||||
|
//Warning, Jackdaw doesn't handle simultaneous radio and USB interrupts very well.
|
||||||
|
#if 0
|
||||||
|
if (packetreceived) {
|
||||||
|
if (packetreceived==1) {
|
||||||
|
printf("-");
|
||||||
|
} else {
|
||||||
|
printf("+");
|
||||||
|
}
|
||||||
|
packetreceived=0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Allow USB CDC to keep up with printfs */
|
/* Allow USB CDC to keep up with printfs */
|
||||||
#if ANNOUNCE
|
#if ANNOUNCE
|
||||||
if (firsttime++==36000){
|
if (firsttime) {
|
||||||
|
firsttime++;
|
||||||
|
if (firsttime==36000){
|
||||||
printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n\r"));
|
printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n\r"));
|
||||||
#if RF230BB
|
#if RF230BB
|
||||||
} else if (firsttime==44000) {
|
} else if (firsttime==44000) {
|
||||||
printf("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n\r",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
|
printf_P(PSTR("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n\r"),addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
|
||||||
|
|
||||||
} else if (firsttime==52000) {
|
} else if (firsttime==52000) {
|
||||||
printf("Driver: %s, Channel: %u\n\r", sicslowpan_mac->name, rf230_get_channel());
|
printf_P(PSTR("%s %s, channel %u"),NETSTACK_MAC.name, NETSTACK_RDC.name,rf230_get_channel());
|
||||||
#endif
|
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());
|
||||||
|
printf_P(PSTR(", check rate %u Hz"),tmp);
|
||||||
|
}
|
||||||
|
printf_P(PSTR("\n\r"));
|
||||||
|
#endif /* RF230BB */
|
||||||
} else if (firsttime==60000) {
|
} else if (firsttime==60000) {
|
||||||
printf_P(PSTR("System online.\n\r"));
|
printf_P(PSTR("System online.\n\r"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#if DEBUG && 0
|
|
||||||
if (rf230processflag) {
|
|
||||||
printf("**RF230 process flag %u\n\r",rf230processflag);
|
|
||||||
rf230processflag=0;
|
|
||||||
}
|
|
||||||
if (rf230_interrupt_flag) {
|
|
||||||
// if (rf230_interrupt_flag!=11) {
|
|
||||||
printf("**RF230 Interrupt %u\n\r",rf230_interrupt_flag);
|
|
||||||
// }
|
|
||||||
rf230_interrupt_flag=0;
|
|
||||||
}
|
|
||||||
#endif /* DEBUG */
|
|
||||||
#endif /* ANNOUNCE */
|
#endif /* ANNOUNCE */
|
||||||
|
|
||||||
|
#if DEBUG && 0
|
||||||
|
if (rf230processflag) {
|
||||||
|
printf("**RF230 process flag %u\n\r",rf230processflag);
|
||||||
|
rf230processflag=0;
|
||||||
|
}
|
||||||
|
if (rf230_interrupt_flag) {
|
||||||
|
// if (rf230_interrupt_flag!=11) {
|
||||||
|
printf("**RF230 Interrupt %u\n\r",rf230_interrupt_flag);
|
||||||
|
// }
|
||||||
|
rf230_interrupt_flag=0;
|
||||||
|
}
|
||||||
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user