Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 KB | None | 0 0
  1.  
  2. #include "contiki.h"
  3. #include "net/rime.h"
  4. #include <stdio.h>
  5.  
  6. /*---------------------------------------------------------------------------*/
  7. PROCESS(sinknode_process, "Sink Node unicast");
  8. AUTOSTART_PROCESSES(&sinknode_process);
  9. /*---------------------------------------------------------------------------*/
  10. static void
  11. recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
  12. {
  13.   printf("Unicast message received from %d.%d: '%s'\n",
  14.      from->u8[0], from->u8[1],(char *)packetbuf_dataptr());
  15. }
  16. static const struct unicast_callbacks unicast_callbacks = {recv_uc};
  17. static struct unicast_conn uc;
  18. /*---------------------------------------------------------------------------*/
  19. PROCESS_THREAD(sinknode_process, ev, data)
  20. {
  21.   PROCESS_EXITHANDLER(unicast_close(&uc);)
  22.    
  23.   PROCESS_BEGIN();
  24.  
  25.   unicast_open(&uc, 146, &unicast_callbacks);
  26.  
  27.   while(1) {
  28.     static struct etimer et;
  29.     rimeaddr_t addr;
  30.    
  31.     etimer_set(&et, CLOCK_SECOND);
  32.    
  33.     PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
  34.  
  35.     packetbuf_copyfrom("", 0);
  36.     addr.u8[0] = 1;
  37.     addr.u8[1] = 0;
  38.     if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr)) {
  39.     }
  40.   }
  41.  
  42.   PROCESS_END();
  43. }
  44. /*---------------------------------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement