Search code examples
cmsp430contiki

Z1 motes - Communication between a base station and sensing node


I have been trying for the last few days to access the individual nodes via the base station but I have been out of luck. I tried the following on a base station (unicast-receiver.c) and a sensing node (unicast-sender.c)

Firstly, I tried to create an RPL dag on the unicast sender and track it from unicast-receiver using

address= servreg_hack_lookup(SERVICE_ID_1)

and then

simple_udp_sendto(&unicast_connection, msg.value, 1, address) 

but it gave me a totally different address instead of the address of the sensing node, hence it didn't work.

Anyways, I tried to to remove the RPL dag but then I couldn't find a way to hard code the address of the sensing node.

If I can at least hardcode the address of the sensing node and use simple_udp_sendto(&unicast_connection, msg.value, 1, address) function to communicate with the sensing node then that could work, but how to do it?

(EDIT) I haven't been able to send even a byte to the remote z1 mote, and I don't think that it will help to obtain the address only, because the sensing node should be expecting something if I would to send it. But then how do I send to it in this case?


Solution

  • The only thing that is needed to solve the problem is to get the node's address using

    uip_ipaddr_t addr;
    uip_ip6addr(&addr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); // or whatever is the values for your node 
    

    and then use any of simple-udp send functions to send your data.

    simple_udp_sendto_custom(&unicast_connection, msg.value, 1, &addr); // this is my own custom function, 
    //but any other should do the same thing provided the address