36 #include "dev/ds2411.h"
40 #include "dev/uart1.h"
41 #include "dev/watchdog.h"
43 #include "lib/random.h"
61 #ifndef UIP_ROUTER_MODULE
62 #ifdef UIP_CONF_ROUTER_MODULE
63 #define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE
65 #define UIP_ROUTER_MODULE rimeroute
69 extern const struct uip_router UIP_ROUTER_MODULE;
72 #if DCOSYNCH_CONF_ENABLED
73 static struct timer mgt_timer;
75 extern int msp430_dco_required;
84 #include "net/uip-fw-drv.h"
89 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
93 #define UIP_OVER_MESH_CHANNEL 8
95 static uint8_t is_gateway;
98 #ifdef EXPERIMENT_SETUP
99 #include "experiment-setup.h"
102 void init_platform(
void);
107 force_float_inclusion()
109 extern int __fixsfsi;
110 extern int __floatsisf;
114 return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
121 #define RF_CHANNEL 26
126 force_inclusion(
int d1,
int d2)
128 snprintf(
NULL, 0,
"%d", d1 % d2);
138 memset(&addr, 0,
sizeof(rimeaddr_t));
140 memcpy(addr.u8, ds2411_id,
sizeof(addr.u8));
143 for(i = 0; i <
sizeof(rimeaddr_t); ++i) {
144 addr.u8[i] = ds2411_id[7 - i];
147 addr.u8[0] = node_id & 0xff;
148 addr.u8[1] = node_id >> 8;
152 printf(
"Rime started with address ");
153 for(i = 0; i <
sizeof(addr.u8) - 1; i++) {
154 printf(
"%d.", addr.u8[i]);
156 printf(
"%d\n", addr.u8[i]);
160 print_processes(
struct process *
const processes[])
164 while(*processes !=
NULL) {
165 printf(
" '%s'", (*processes)->name);
177 printf(
"%d.%d: making myself the IP network gateway.\n\n",
179 printf(
"IPv4 address of the gateway: %d.%d.%d.%d\n\n",
182 uip_over_mesh_make_announced_gateway();
188 #if WITH_TINYOS_AUTO_IDS
189 uint16_t TOS_NODE_ID = 0x1234;
190 uint16_t TOS_LOCAL_ADDRESS = 0x1234;
193 main(
int argc,
char **argv)
204 uart1_init(BAUD2UBR(115200));
215 ds2411_id[2] &= 0xfe;
227 #if WITH_TINYOS_AUTO_IDS
228 node_id = TOS_NODE_ID;
235 #ifdef IEEE_802154_MAC_ADDRESS
237 uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
238 memcpy(ds2411_id, ieee,
sizeof(
uip_lladdr.addr));
239 ds2411_id[7] = node_id & 0xff;
243 random_init(ds2411_id[0] + node_id);
265 memset(longaddr, 0,
sizeof(longaddr));
267 printf(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
268 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
269 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
271 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
273 cc2420_set_channel(RF_CHANNEL);
275 printf(
"\n*******Booting***********\n");
276 printf(CONTIKI_VERSION_STRING
" started. ");
278 printf(
"Node id is set to %u.\n", node_id);
280 printf(
"Node id is not set.\n");
297 NETSTACK_NETWORK.init();
299 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
300 NETSTACK_MAC.name, NETSTACK_RDC.name,
301 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
302 NETSTACK_RDC.channel_check_interval()),
307 printf(
"Tentative link-local IPv6 address ");
311 lladdr = uip_ds6_get_link_local(-1);
312 for(i = 0; i < 7; ++i) {
313 printf(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
314 lladdr->ipaddr.u8[i * 2 + 1]);
316 printf(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
319 if(!UIP_CONF_IPV6_RPL) {
325 printf(
"Tentative global IPv6 address ");
326 for(i = 0; i < 7; ++i) {
328 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
331 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
338 NETSTACK_NETWORK.init();
340 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
341 NETSTACK_MAC.name, NETSTACK_RDC.name,
342 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
343 NETSTACK_RDC.channel_check_interval()),
347 #if !WITH_UIP && !WITH_UIP6
348 uart1_set_input(serial_line_input_byte);
356 leds_off(LEDS_GREEN);
358 #if TIMESYNCH_CONF_ENABLED
368 slip_set_input_callback(set_gateway);
382 uip_over_mesh_set_net(&hostaddr, &netmask);
384 uip_over_mesh_set_gateway_netif(&slipif);
386 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
387 printf(
"uIP started with IP address %d.%d.%d.%d\n",
393 ENERGEST_ON(ENERGEST_TYPE_CPU);
397 print_processes(autostart_processes);
398 autostart_start(autostart_processes);
403 #if DCOSYNCH_CONF_ENABLED
411 profile_episode_start();
419 profile_episode_end();
430 static unsigned long irq_energest = 0;
432 #if DCOSYNCH_CONF_ENABLED
438 #if CC2420_CONF_SFD_TIMESTAMPS
439 cc2420_arch_sfd_init();
445 ENERGEST_OFF(ENERGEST_TYPE_CPU);
446 ENERGEST_ON(ENERGEST_TYPE_LPM);
450 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
453 if (msp430_dco_required) {
454 _BIS_SR(GIE | CPUOFF);
456 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
466 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
469 ENERGEST_OFF(ENERGEST_TYPE_LPM);
470 ENERGEST_ON(ENERGEST_TYPE_CPU);
479 log_message(
char *m1,
char *m2)
481 printf(
"%s%s\n", m1, m2);