35 #include "dev/cc2520/cc2520.h"
40 #include "dev/uart1.h"
41 #include "dev/watchdog.h"
43 #include "lib/random.h"
53 #include "sys/node-id.h"
58 #ifndef UIP_ROUTER_MODULE
59 #ifdef UIP_CONF_ROUTER_MODULE
60 #define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE
62 #define UIP_ROUTER_MODULE rimeroute
66 extern const struct uip_router UIP_ROUTER_MODULE;
76 #include "net/uip-fw-drv.h"
81 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
85 #define UIP_OVER_MESH_CHANNEL 8
87 static uint8_t is_gateway;
90 #ifdef EXPERIMENT_SETUP
91 #include "experiment-setup.h"
94 void init_platform(
void);
99 force_float_inclusion()
101 extern int __fixsfsi;
102 extern int __floatsisf;
106 return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
113 #define RF_CHANNEL 26
118 force_inclusion(
int d1,
int d2)
120 snprintf(
NULL, 0,
"%d", d1 % d2);
133 memset(&n_addr, 0,
sizeof(linkaddr_t));
138 n_addr.u8[7] = node_id & 0xff;
139 n_addr.u8[6] = node_id >> 8;
149 n_addr.u8[0] = node_id & 0xff;
150 n_addr.u8[1] = node_id >> 8;
154 printf(
"Rime started with address ");
155 for(i = 0; i <
sizeof(n_addr.u8) - 1; i++) {
156 printf(
"%d.", n_addr.u8[i]);
158 printf(
"%d\n", n_addr.u8[i]);
161 #if !PROCESS_CONF_NO_PROCESS_NAMES
163 print_processes(
struct process *
const processes[])
167 while(*processes !=
NULL) {
168 printf(
" '%s'", (*processes)->name);
186 uip_over_mesh_make_announced_gateway();
193 main(
int argc,
char **argv)
238 #ifdef IEEE_802154_MAC_ADDRESS
240 uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
268 memset(longaddr, 0,
sizeof(longaddr));
271 printf(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
272 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
273 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
275 cc2520_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
277 cc2520_set_channel(RF_CHANNEL);
279 printf(CONTIKI_VERSION_STRING
" started. ");
281 printf(
"Node id is set to %u.\n", node_id);
283 printf(
"Node id is not set.\n");
289 UIP_LLADDR_LEN > LINKADDR_SIZE ? LINKADDR_SIZE : UIP_LLADDR_LEN);
299 NETSTACK_NETWORK.init();
301 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
302 NETSTACK_MAC.name, NETSTACK_RDC.name,
303 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
304 NETSTACK_RDC.channel_check_interval()),
309 printf(
"Tentative link-local IPv6 address ");
313 lladdr = uip_ds6_get_link_local(-1);
314 for(i = 0; i < 7; ++i) {
315 printf(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
316 lladdr->ipaddr.u8[i * 2 + 1]);
318 printf(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
321 if(!UIP_CONF_IPV6_RPL) {
327 printf(
"Tentative global IPv6 address ");
328 for(i = 0; i < 7; ++i) {
330 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
333 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
340 NETSTACK_NETWORK.init();
342 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
343 NETSTACK_MAC.name, NETSTACK_RDC.name,
344 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
345 NETSTACK_RDC.channel_check_interval()),
349 #if !WITH_UIP && !WITH_UIP6
356 #if TIMESYNCH_CONF_ENABLED
366 slip_set_input_callback(set_gateway);
369 uip_ipaddr_t hostaddr,
netmask;
380 uip_over_mesh_set_net(&hostaddr, &netmask);
382 uip_over_mesh_set_gateway_netif(&slipif);
384 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
385 printf(
"uIP started with IP address %d.%d.%d.%d\n",
391 ENERGEST_ON(ENERGEST_TYPE_CPU);
397 #if !PROCESS_CONF_NO_PROCESS_NAMES
398 print_processes(autostart_processes);
402 autostart_start(autostart_processes);
424 static unsigned long irq_energest = 0;
427 ENERGEST_OFF(ENERGEST_TYPE_CPU);
428 ENERGEST_ON(ENERGEST_TYPE_LPM);
432 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
434 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
444 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
447 ENERGEST_OFF(ENERGEST_TYPE_LPM);
448 ENERGEST_ON(ENERGEST_TYPE_CPU);
455 log_message(
char *m1,
char *m2)
457 printf(
"%s%s\n", m1, m2);
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
#define uip_sethostaddr(addr)
Set the IP address of this host.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
uIP packet forwarding header file.
int process_nevents(void)
Number of events waiting to be processed.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
802.15.4 frame creation and parsing functions
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
Representation of a uIP network interface.
#define LEDS_RED
LED1 (Red) -> PC0.
Unicast address structure.
void timesynch_init(void)
Initialize the timesynch module.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
uip_ipaddr_t ipaddr
The IP address of this interface.
Header file for the uIP TCP/IP stack.
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
void rtimer_init(void)
Initialize the real-time scheduler.
Network interface and stateless autoconfiguration (RFC 4862)
#define NULL
The null pointer.
void uip_log(char *msg)
Print out a uIP log message.
Header file for tunnelling uIP over Rime mesh
void clock_init(void)
Initialize the clock library.
int main(void)
This is main...
void process_init(void)
Initialize the process module.
Header file for the Rime stack
void timesynch_set_authority_level(int level)
Set the authority level of the current time.
#define LEDS_GREEN
LED3 (Green) -> PC2.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
void watchdog_stop(void)
In watchdog mode, the WDT can not be stopped.
Generic serial I/O process header filer.
void watchdog_periodic(void)
Writes the WDT clear sequence.
Header file for module for automatically starting and exiting a list of processes.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
void ctimer_init(void)
Initialize the callback timer library.
#define uip_ipaddr_to_quad(a)
Convert an IP address to four bytes separated by commas.
void uip_init(void)
uIP initialization function.
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
uip_ipaddr_t netmask
The netmask of the interface.
void process_start(struct process *p, process_data_t data)
Start a process.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
int process_run(void)
Run the system once - call poll handlers and process one event.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
void clock_wait(clock_time_t t)
Wait for a given number of ticks.
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
#define uip_setnetmask(addr)
Set the netmask.
Include file for the Contiki low-layer network stack (NETSTACK)
#define CLOCK_SECOND
A second, measured in system clock time.