示例#1
0
文件: rmh.c 项目: aiss83/nucbit
/*---------------------------------------------------------------------------*/
void
rmh_open(struct rmh_conn *c, uint16_t channel,
         const struct rmh_callbacks *callbacks)
{
    runicast_open(&c->c, channel, &data_callbacks);
    c->cb = callbacks;
}
/*---------------------------------------------------------------------------*/
void
shell_rime_debug_runicast_init(void)
{
  runicast_open(&ruc, SHELL_RIME_CHANNEL_RUNICAST,
	       &runicast_callbacks);
  shell_register_command(&runicast_command);
}
示例#3
0
/*------------------------------ Main Functions ---------------------------*/
void sensor_bootstrap(struct GROOT_SENSORS *support){	
	printf("Sensor Starting.....\n");
	//Open Channels needed
	broadcast_open(&sensor_chan.bc, GROOT_ROUTING_CHANNEL, &sensor_routing_bcast);
	runicast_open(&sensor_chan.rc, GROOT_DATA_CHANNEL, &sensor_data_rcast);
	
	//Initialize protocol library
	groot_prot_init(support, &sensor_chan, 0);
}
示例#4
0
/*---------------------------------------------------------------------------*/
void
shell_netperf_init(void)
{
  runicast_open(&ctrl, SHELL_RIME_CHANNEL_NETPERF, &runicast_callbacks);
  broadcast_open(&broadcast, SHELL_RIME_CHANNEL_NETPERF + 1, &broadcast_callbacks);
  unicast_open(&unicast, SHELL_RIME_CHANNEL_NETPERF + 2, &unicast_callbacks);
  mesh_open(&mesh, SHELL_RIME_CHANNEL_NETPERF + 3, &mesh_callbacks);
  rucb_open(&rucb, SHELL_RIME_CHANNEL_NETPERF + 5, &rucb_callbacks);
  shell_register_command(&netperf_command);
}
示例#5
0
/*---------------------------------------------------------------------------*/
void
rucb_open(struct rucb_conn *c, uint16_t channel,
	  const struct rucb_callbacks *u)
{
  rimeaddr_copy(&c->sender, &rimeaddr_null);
  runicast_open(&c->c, channel, &ruc);
  c->u = u;
  c->last_seqno = -1;
  c->last_size = -1;
}
示例#6
0
文件: node.c 项目: 13416795/contiki
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_test_process, ev, data)
{
  PROCESS_BEGIN();

  puts("unicast test start");

  runicast_open(&runicast, 144, &runicast_callbacks);

  /* Receiver node: do nothing */
  if(linkaddr_node_addr.u8[0] == RX_ADDR1 &&
     linkaddr_node_addr.u8[1] == RX_ADDR2) {
    puts("wait forever");
  }
  while(1) {
    static struct etimer et;
    static int seqno;

    etimer_set(&et, CLOCK_SECOND * 5);

    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

    if(linkaddr_node_addr.u8[0] == RX_ADDR1 &&
       linkaddr_node_addr.u8[1] == RX_ADDR2) {
      puts("tick...");
      continue;
    }

    if(!runicast_is_transmitting(&runicast)) {
      static char buffer[100] = "hello";
      linkaddr_t recv;

      memset(&recv, 0, LINKADDR_SIZE);
      packetbuf_copyfrom(buffer, sizeof(buffer));
      recv.u8[0] = RX_ADDR1;
      recv.u8[1] = RX_ADDR2;

      printf("%u.%u: sending runicast to address %u.%u\n",
             linkaddr_node_addr.u8[0],
             linkaddr_node_addr.u8[1],
             recv.u8[0],
             recv.u8[1]);

      packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, ++seqno);
      runicast_send(&runicast, &recv, MAX_RETRANSMISSIONS);
    }
  }

  PROCESS_END();
}
示例#7
0
PROCESS_THREAD(shell_ruc_open_process, ev, data)
{
  uint16_t channel;
  long channel_long;
  const char *next;
  char buf[6];
  PROCESS_BEGIN();
  channel_long = shell_strtolong((char *)data, &next);
  if(channel_long <= 0 || channel_long > 65535){
    shell_output_str(&ruc_open_command, "channel has to be in range of [1-65535]", "");
    PROCESS_EXIT();
  }
  channel = (uint16_t) channel_long;
  snprintf(buf, sizeof(buf), "%d", channel);

  struct runicast_entry *to_add = memb_alloc(&runicast_mem);
  list_add(runicast_list, to_add);
  to_add->channel = channel;
  runicast_open(&to_add->c, channel, &runicast_callback);
  shell_output_str(&ruc_open_command, "opened reliable unicast connection on channel: ", buf);

  PROCESS_END();
}
示例#8
0
文件: collect.c 项目: kincki/contiki
/*---------------------------------------------------------------------------*/
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();
}
示例#9
0
void initHTRimeStack()
{
	setNodesAddresses();
	printf("My address is %d.%d\n", linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1]);
	runicast_open(&cuRunicastConnection, RUNICAST_CHANNEL, &runicast_calls);
}
void shell_sendfile_init(){
	shell_register_command(&sendfile_command);
	runicast_open(&runicastSendCommand, RUNICAST_CHANNEL_SENDCOMMAND, &sendCommandCallbacks);
}
void open_runicast(void)
{
	list_init(history_table);
	memb_init(&history_mem);
	runicast_open(&runicast, 144, &runicast_callbacks);
}