Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
static void
received_announcement(struct announcement *a, const rimeaddr_t *from,
		      uint16_t id, uint16_t value)
{
  struct neighbor_entry *e;

  printf("%d.%d: announcement from neighbor %d.%d, id %d, value %d\n",
	 rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
	 from->u8[0], from->u8[1],
	 id, value);
  
  
  for(e = list_head(neighbor_table); e != NULL; e = e->next) {
    if(rimeaddr_cmp(from, &e->addr)) {
      ctimer_set(&e->ctimer, NEIGHBOR_TIMEOUT, remove_neighbor, e);
      show_leds();
      return;
    }
  }

  
  e = memb_alloc(&neighbor_mem);
  if(e != NULL) {
    rimeaddr_copy(&e->addr, from);
    list_add(neighbor_table, e);
    ctimer_set(&e->ctimer, NEIGHBOR_TIMEOUT, remove_neighbor, e);
  } else {
  }
  show_leds();
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*/
void
leds_on(unsigned char ledv)
{
  unsigned char changed;
  changed = (~leds) & ledv;
  leds |= ledv;
  show_leds(changed);
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*/
void
leds_off(unsigned char ledv)
{
  unsigned char changed;
  changed = leds & ledv;
  leds &= ~ledv;
  show_leds(changed);
}
Ejemplo n.º 4
0
/*---------------------------------------------------------------------------*/
static void
remove_neighbor(void *dummy)
{
  struct neighbor_entry *e = dummy;

  list_remove(neighbor_table, e);
  memb_free(&neighbor_mem, e);

  show_leds();
  
  printf("%d.%d: removed %d.%d\n",
	 rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
	 e->addr.u8[0], e->addr.u8[1]);
}
Ejemplo n.º 5
0
/*   invert the invert register using the leds parameter */
void
leds_invert(unsigned char ledv) {
  invert = invert ^ ledv;
  show_leds(ledv);
}