42 #include "dev/watchdog.h"
44 #include "lib/random.h"
47 #include "dev/button-sensor.h"
62 #include "dev/battery-sensor.h"
63 #include "dev/button-sensor.h"
64 #include "dev/sht11-sensor.h"
66 SENSORS(&button_sensor);
69 #if DCOSYNCH_CONF_ENABLED
70 static struct timer mgt_timer;
80 #include "net/uip-fw-drv.h"
85 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
89 #define UIP_OVER_MESH_CHANNEL 8
91 static uint8_t is_gateway;
94 #ifdef EXPERIMENT_SETUP
95 #include "experiment-setup.h"
101 #define PRINTF(...) printf(__VA_ARGS__)
106 void init_platform(
void);
111 force_float_inclusion()
113 extern int __fixsfsi;
114 extern int __floatsisf;
118 return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
125 #define RF_CHANNEL 26
130 force_inclusion(
int d1,
int d2)
132 snprintf(
NULL, 0,
"%d", d1 % d2);
142 memset(&addr, 0,
sizeof(rimeaddr_t));
144 memcpy(addr.u8, node_mac,
sizeof(addr.u8));
147 for(i = 0; i <
sizeof(rimeaddr_t); ++i) {
148 addr.u8[i] = node_mac[7 - i];
151 addr.u8[0] = node_id & 0xff;
152 addr.u8[1] = node_id >> 8;
156 printf(
"Rime started with address ");
157 for(i = 0; i <
sizeof(addr.u8) - 1; i++) {
158 printf(
"%d.", addr.u8[i]);
160 printf(
"%d\n", addr.u8[i]);
164 print_processes(
struct process *
const processes[])
168 while(*processes !=
NULL) {
169 printf(
" '%s'", (*processes)->name);
181 printf(
"%d.%d: making myself the IP network gateway.\n\n",
183 printf(
"IPv4 address of the gateway: %d.%d.%d.%d\n\n",
186 uip_over_mesh_make_announced_gateway();
193 main(
int argc,
char **argv)
221 if(node_mac[0] | node_mac[1] | node_mac[2] | node_mac[3] |
222 node_mac[4] | node_mac[5] | node_mac[6] | node_mac[7]) {
232 node_mac[6] = node_id >> 8;
233 node_mac[7] = node_id & 0xff;
238 #warning "***** CHANGING DEFAULT MAC *****"
248 node_mac[6] = MACID >> 8;
249 node_mac[7] = MACID & 0xff;
252 #ifdef IEEE_802154_MAC_ADDRESS
255 uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
256 memcpy(node_mac, ieee,
sizeof(
uip_lladdr.addr));
257 node_mac[7] = node_id & 0xff;
282 memset(longaddr, 0,
sizeof(longaddr));
284 printf(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
285 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
286 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
288 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
290 cc2420_set_channel(RF_CHANNEL);
294 PRINTF(CONTIKI_VERSION_STRING
" started. ");
297 PRINTF(
"Node id is set to %u.\n", node_id);
299 PRINTF(
"Node id is not set.\n");
314 NETSTACK_NETWORK.init();
316 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
317 NETSTACK_MAC.name, NETSTACK_RDC.name,
318 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
319 NETSTACK_RDC.channel_check_interval()),
324 printf(
"Tentative link-local IPv6 address ");
328 lladdr = uip_ds6_get_link_local(-1);
329 for(i = 0; i < 7; ++i) {
330 printf(
"%02x%02x:", lladdr->ipaddr.u8[i * 2],
331 lladdr->ipaddr.u8[i * 2 + 1]);
333 printf(
"%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
336 if(!UIP_CONF_IPV6_RPL) {
342 printf(
"Tentative global IPv6 address ");
343 for(i = 0; i < 7; ++i) {
345 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
348 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
355 NETSTACK_NETWORK.init();
357 printf(
"%s %s, channel check rate %lu Hz, radio channel %u\n",
358 NETSTACK_MAC.name, NETSTACK_RDC.name,
359 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
360 NETSTACK_RDC.channel_check_interval()),
364 #if !WITH_UIP && !WITH_UIP6
365 uart0_set_input(serial_line_input_byte);
373 leds_off(LEDS_GREEN);
375 #if TIMESYNCH_CONF_ENABLED
385 slip_set_input_callback(set_gateway);
399 uip_over_mesh_set_net(&hostaddr, &netmask);
401 uip_over_mesh_set_gateway_netif(&slipif);
403 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
404 printf(
"uIP started with IP address %d.%d.%d.%d\n",
410 ENERGEST_ON(ENERGEST_TYPE_CPU);
412 print_processes(autostart_processes);
413 autostart_start(autostart_processes);
418 #if DCOSYNCH_CONF_ENABLED
426 profile_episode_start();
434 profile_episode_end();
445 static unsigned long irq_energest = 0;
447 #if DCOSYNCH_CONF_ENABLED
456 ENERGEST_OFF(ENERGEST_TYPE_CPU);
457 ENERGEST_ON(ENERGEST_TYPE_LPM);
461 energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
463 _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF);
473 irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
476 ENERGEST_OFF(ENERGEST_TYPE_LPM);
477 ENERGEST_ON(ENERGEST_TYPE_CPU);
486 log_message(
char *m1,
char *m2)
488 printf(
"%s%s\n", m1, m2);