Esempio n. 1
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(announce_blink_process, ev, data)
{
  PROCESS_BEGIN();

  /* XXX the Sentilla JCreate has 8 LEDs, and we need to set the ports
     correctly. */
#if CONTIKI_TARGET_SKY
  LEDS_PxDIR = 0xff;
  LEDS_PxOUT = 0xff;
#endif /* CONTIKI_TARGET_SKY */

  announcement_register(&announcement, 80, 0,
			received_announcement);

  list_init(neighbor_table);
  memb_init(&neighbor_mem);

#if CONTIKI_TARGET_NATIVE
  {
    int i;
    for(i = 0; i < 10; ++i) {
      rimeaddr_t r;
      r.u8[0] = r.u8[1] = i;
      received_announcement(NULL, &r, 0, 0);
      received_announcement(NULL, &r, 0, 0);
    }
  }
#endif /* CONTIKI_TARGET_NATIVE */
  
#if CONTIKI_TARGET_SKY
  acc_sensor.activate();

  /* Lower the transmission power for the announcements so that only
     close-range neighbors are noticed. (Makes for a nicer visual
     effect.) */
  xmac_set_announcement_radio_txpower(1);
#endif /* CONTIKI_TARGET_SKY */
  
  while(1) {
    static struct etimer e;
    static uint16_t last_value;
    
    etimer_set(&e, CLOCK_SECOND / 8);
    PROCESS_WAIT_EVENT();
#if CONTIKI_TARGET_SKY
    if(acc_sensor.value(1) / 256 != last_value) {
      last_value = acc_sensor.value(1) / 256;
      announcement_listen(1);
    }
#endif /* CONTIKI_TARGET_SKY */
  }
  
  PROCESS_END();
}
Esempio n. 2
0
void
httpd_cgi_init(void)
{
  
  httpd_cgi_add(&sensors);
  httpd_cgi_add(&nodeid);
  httpd_cgi_add(&neighbors);

  announcement_register(&announcement, 31,
			received_announcement);
  announcement_listen(2);

  /*  neighbor_discovery_open(&conn, 31,
			  CLOCK_SECOND * 4,
			  CLOCK_SECOND * 20,
			  CLOCK_SECOND * 60,
			  &neighbor_discovery_callbacks);
			  neighbor_discovery_start(&conn, 0);*/
}
Esempio n. 3
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(announce_blink_process, ev, data)
{
  PROCESS_BEGIN();

  announcement_register(&announcement, 80, received_announcement);

  list_init(neighbor_table);
  memb_init(&neighbor_mem);

  {
    int i;
    for(i = 0; i < 10; ++i) {
      rimeaddr_t r;
      r.u8[0] = r.u8[1] = i;
      received_announcement(NULL, &r, 0, 0);
      received_announcement(NULL, &r, 0, 0);
    }
  }
  
  SENSORS_ACTIVATE(acc_sensor);

  /* Lower the transmission power for the announcements so that only
     close-range neighbors are noticed. (Makes for a nicer visual
     effect.) */
  xmac_set_announcement_radio_txpower(1);
  
  while(1) {
    static struct etimer e;
    static uint16_t last_value;
    
    etimer_set(&e, CLOCK_SECOND / 8);
    PROCESS_WAIT_EVENT();
    if(acc_sensor.value(1) / 256 != last_value) {
      last_value = acc_sensor.value(1) / 256;
      announcement_listen(1);
    }
  }
  
  PROCESS_END();
}
Esempio n. 4
0
/*---------------------------------------------------------------------------*/
void
collect_open(struct collect_conn *tc, uint16_t channels,
             const struct collect_callbacks *cb)
{
#if !COLLECT_ANNOUNCEMENTS
    neighbor_discovery_open(&tc->neighbor_discovery_conn, channels,
                            CLOCK_SECOND * 2,
                            CLOCK_SECOND * 10,
                            CLOCK_SECOND * 60,
                            &neighbor_discovery_callbacks);
#endif /* !COLLECT_ANNOUNCEMENTS */
    runicast_open(&tc->runicast_conn, channels + 1, &runicast_callbacks);
    channel_set_attributes(channels + 1, attributes);
    tc->rtmetric = RTMETRIC_MAX;
    tc->cb = cb;
#if COLLECT_ANNOUNCEMENTS
    announcement_register(&tc->announcement, channels, tc->rtmetric,
                          received_announcement);
    announcement_listen(2);
#else
    neighbor_discovery_start(&tc->neighbor_discovery_conn, tc->rtmetric);
#endif /* COLLECT_ANNOUNCEMENTS */
    neighbor_init();
}