35 #include "dev/ds2411/ds2411.h"
39 #include "dev/uart1.h"
40 #include "dev/watchdog.h"
42 #include "lib/random.h"
47 #include "net/ipv6/uip-ds6.h"
52 #include "sys/node-id.h"
59 #ifndef UIP_ROUTER_MODULE
60 #ifdef UIP_CONF_ROUTER_MODULE
61 #define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE
63 #define UIP_ROUTER_MODULE rimeroute
67 extern const struct uip_router UIP_ROUTER_MODULE;
70 #if DCOSYNCH_CONF_ENABLED
71 static struct timer mgt_timer;
73 extern int msp430_dco_required;
82 #include "net/ipv4/uip-fw-drv.h"
87 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
91 #define UIP_OVER_MESH_CHANNEL 8
93 static uint8_t is_gateway;
96 #ifdef EXPERIMENT_SETUP
97 #include "experiment-setup.h"
100 void init_platform(
void);
105 force_float_inclusion()
107 extern int __fixsfsi;
108 extern int __floatsisf;
112 return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
121 force_inclusion(
int d1,
int d2)
123 snprintf(
NULL, 0,
"%d", d1 % d2);
133 memset(&addr, 0,
sizeof(linkaddr_t));
135 memcpy(addr.u8, ds2411_id,
sizeof(addr.u8));
138 for(i = 0; i <
sizeof(linkaddr_t); ++i) {
139 addr.u8[i] = ds2411_id[7 - i];
142 addr.u8[0] = node_id & 0xff;
143 addr.u8[1] = node_id >> 8;
147 printf(
"Rime started with address ");
148 for(i = 0; i <
sizeof(addr.u8) - 1; i++) {
149 printf(
"%d.", addr.u8[i]);
151 printf(
"%d\n", addr.u8[i]);
154 #if !PROCESS_CONF_NO_PROCESS_NAMES
156 print_processes(
struct process *
const processes[])
160 while(*processes !=
NULL) {
161 printf(
" '%s'", (*processes)->name);
174 printf(
"%d.%d: making myself the IP network gateway.\n\n",
176 printf(
"IPv4 address of the gateway: %d.%d.%d.%d\n\n",
179 uip_over_mesh_make_announced_gateway();
185 #if WITH_TINYOS_AUTO_IDS
186 uint16_t TOS_NODE_ID = 0x1234;
187 uint16_t TOS_LOCAL_ADDRESS = 0x1234;
190 main(
int argc,
char **argv)
201 uart1_init(BAUD2UBR(115200));
209 ds2411_id[2] &= 0xfe;
221 #if WITH_TINYOS_AUTO_IDS
222 node_id = TOS_NODE_ID;
229 #ifdef IEEE_802154_MAC_ADDRESS
231 uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
232 memcpy(ds2411_id, ieee,
sizeof(
uip_lladdr.addr));
233 ds2411_id[7] = node_id & 0xff;
263 memset(longaddr, 0,
sizeof(longaddr));
265 printf(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
266 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
267 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
269 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
272 printf(CONTIKI_VERSION_STRING
" started. ");
274 printf(
"Node id is set to %u.\n", node_id);
276 printf(
"Node id is not set.\n");
293 NETSTACK_NETWORK.init();
295 printf(
"%s %s, channel check rate %lu Hz, radio channel %u, CCA threshold %i\n",
296 NETSTACK_MAC.name, NETSTACK_RDC.name,
297 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
298 NETSTACK_RDC.channel_check_interval()),
300 CC2420_CONF_CCA_THRESH);
304 printf(
"Tentative link-local IPv6 address ");
308 lladdr = uip_ds6_get_link_local(-1);
309 for(i = 0; i < 7; ++i) {
310 printf(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
311 lladdr->ipaddr.u8[i * 2 + 1]);
313 printf(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
316 if(!UIP_CONF_IPV6_RPL) {
321 uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
322 printf(
"Tentative global IPv6 address ");
323 for(i = 0; i < 7; ++i) {
325 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
328 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
335 NETSTACK_NETWORK.init();
337 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
338 NETSTACK_MAC.name, NETSTACK_RDC.name,
339 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
340 NETSTACK_RDC.channel_check_interval()),
341 CC2420_CONF_CCA_THRESH);
344 #if !WITH_UIP && !WITH_UIP6
345 uart1_set_input(serial_line_input_byte);
351 #if TIMESYNCH_CONF_ENABLED
361 slip_set_input_callback(set_gateway);
364 uip_ipaddr_t hostaddr,
netmask;
375 uip_over_mesh_set_net(&hostaddr, &netmask);
377 uip_over_mesh_set_gateway_netif(&slipif);
379 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
380 printf(
"uIP started with IP address %d.%d.%d.%d\n",
386 ENERGEST_ON(ENERGEST_TYPE_CPU);
390 #if !PROCESS_CONF_NO_PROCESS_NAMES
391 print_processes(autostart_processes);
395 autostart_start(autostart_processes);
400 #if DCOSYNCH_CONF_ENABLED
421 static unsigned long irq_energest = 0;
423 #if DCOSYNCH_CONF_ENABLED
429 #if CC2420_CONF_SFD_TIMESTAMPS
430 cc2420_arch_sfd_init();
436 ENERGEST_OFF(ENERGEST_TYPE_CPU);
437 ENERGEST_ON(ENERGEST_TYPE_LPM);
441 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
444 if (msp430_dco_required) {
445 _BIS_SR(GIE | CPUOFF);
447 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
457 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
460 ENERGEST_OFF(ENERGEST_TYPE_LPM);
461 ENERGEST_ON(ENERGEST_TYPE_CPU);
470 log_message(
char *m1,
char *m2)
472 printf(
"%s%s\n", m1, m2);