contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.7k stars 2.58k forks source link

Working with two (or more) contiki unicast-receivers #2625

Open radiophile opened 4 years ago

radiophile commented 4 years ago

I am in process of testing the simple-udp-rpl contiki example (unicast-sender и unicast-receiver). The system consists of two receives and multiple senders. When one unicast-receiver is running, it receives messages from unicast-sender. When two unicast-receivers work with different SERVICE_IDs (for example, 190 and 191), only the unicast-receiver that was turned on first (for example, with SERVICE_ID = 190) receives messages from the transmitter with the corresponding SERVICE_ID. When I turn off the first unicast-receiver, the second unicast-receiver starts to receive messages (SERVICE_ID = 191) from the corresponding transmitters. The broadcast messages are received by both unicast-receivers even when they work simultaneously.

Can anybody help me to solve this problem?

anesh1992 commented 4 years ago

I think (I could be wrong), that's because all unicast-receiver are DODAG root, so those nodes (unicast-sender) already are in-network and chose that previously running unicast-receiver as root. See below code, if you have this code that's making node as root.

static void
create_rpl_dag(uip_ipaddr_t *ipaddr)
{
  struct uip_ds6_addr *root_if;

  root_if = uip_ds6_addr_lookup(ipaddr);
  if(root_if != NULL) {
    rpl_dag_t *dag;
    uip_ipaddr_t prefix;

    rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr);
    dag = rpl_get_any_dag();
    uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
    rpl_set_prefix(dag, &prefix, 64);
    PRINTF("created a new RPL dag\n");
  } else {
    PRINTF("failed to create a new RPL DAG\n");
  }
}

Hope this helps, good luck.