Beispiel #1
0
PROCESS_THREAD(shell_broadcast_hi_process, ev, data)
{
	static struct etimer etimer;
	
//	PROCESS_EXITHANDLER(broadcast_close(&broadcast);)
//	PROCESS_EXITHANDLER(mesh_close(&mesh); broadcast_close(&broadcast);)
	PROCESS_BEGIN();

	static int8_t counter = 0;
	static uint8_t fail_count = 0;
	mesh_open(&mesh, 132, &callbacks);
	broadcast_open(&broadcast, 129, &broadcast_call);

	while(1) {
	counter++;

    leds_on(LEDS_ALL);
    etimer_set(&etimer, 3 * CLOCK_SECOND);
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
    leds_off(LEDS_ALL);

	etimer_set(&etimer, random_rand() % 5 * CLOCK_SECOND + 
		random_rand() % 100 * CLOCK_SECOND / 100);
	PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
	packetbuf_copyfrom("Hello", 6);
	broadcast_send(&broadcast);

	etimer_set(&etimer, random_rand() % 5 * CLOCK_SECOND + 
		random_rand() % 100 * CLOCK_SECOND / 100);
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
	char message[6] = "Hello";
	rimeaddr_t addr;
	packetbuf_copyfrom(message, sizeof(message));
	addr.u8[0] = 62;
	addr.u8[1] = 41;
	uint8_t mesh_sent = 0;
	mesh_sent = mesh_send(&mesh, &addr);
	if (mesh_sent == 0) {
		fail_count++;
		if (counter == 10 && fail_count >= 4)
		{
			mesh_open(&mesh, 132, &callbacks);
			counter = 0;
			fail_count = 0;
		} else if (counter == 10)
			counter = 0;
	}
	}

	PROCESS_END();
}
Beispiel #2
0
// process a decrypted channel packet
link_t link_receive(link_t link, lob_t inner, pipe_t pipe)
{
  chan_t chan;

  if(!link || !inner) return LOG("bad args");

  // see if existing channel and send there
  if((chan = xht_get(link->index, lob_get(inner,"c"))))
  {
    if(channel3_receive(chan->c3, inner)) return LOG("channel receive error, dropping %s",lob_json(inner));
    link_pipe(link,pipe); // we trust the pipe at this point
    if(chan->handle) chan->handle(link, chan->c3, chan->arg);
    // check if there's any packets to be sent back
    return link_flush(link, chan->c3, NULL);
  }

  // if it's an open, validate and fire event
  if(!lob_get(inner,"type")) return LOG("invalid channel open, no type %s",lob_json(inner));
  if(!exchange3_cid(link->x, inner)) return LOG("invalid channel open id %s",lob_json(inner));
  link_pipe(link,pipe); // we trust the pipe at this point
  inner = mesh_open(link->mesh,link,inner);
  if(inner)
  {
   LOG("unhandled channel open %s",lob_json(inner));
   lob_free(inner);
   return NULL;
  }
  
  return link;
}
Beispiel #3
0
END_TEST


START_TEST (test_unstruct_mesh_open)
{ 
    const char test_file[] = FILENAME;
    hid_t  fid, mid;
    herr_t status;
    int seed = 0xABCD0123;
    int num_meshes = generate_random_bound_int(1,10,&seed);
    int i,m;
    char mesh_name[64];


    create_random_meshes(test_file,num_meshes);

    status = output_file_open_rdonly(test_file,&fid);
    fail_unless ( status == DANU_SUCCESS,
                  "Failed to open  output file");

    for(m=1;m<=num_meshes;m++) {
	sprintf(mesh_name,"Mesh %02d",m);
	mid = mesh_open(fid,mesh_name);
	fail_unless(H5_ISA_VALID_ID(mid),
		    "Failed to open existing mesh");
    }

    output_file_close(&fid);
    danu_file_delete(test_file);


}
Beispiel #4
0
/*---------------------------------------------------------------------------*/
void shell_sequence_init(void) {
	mesh_open(&mesh, 132, &callbacks);
	shell_register_command(&sequence_command);
	shell_register_command(&seq_data0_command);
	shell_register_command(&seq_data1_command);
	shell_register_command(&seq_stats_command);
}
/*---------------------------------------------------------------------------*/
void
shell_rime_ping_init(void)
{
  mesh_open(&mesh, SHELL_RIME_CHANNEL_PING, &mesh_callbacks);

  shell_register_command(&rime_ping_command);
}
/*---------------------------------------------------------------------------*/
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);
}
Beispiel #7
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(netdb_process, ev, data)
{
  PROCESS_EXITHANDLER(mesh_close(&mesh));
  PROCESS_BEGIN();

  mesh_open(&mesh, NETDB_CHANNEL, &callbacks);
  process_start(&query_process, NULL);

  PROCESS_END();
}
Beispiel #8
0
/*---------------------------------------------------------------------------*/
void
rudolph1mh_open(struct rudolph1mh_conn *c, uint16_t channel,
    const struct rudolph1mh_callbacks *cb)
{
  mesh_open(&c->mesh, channel, &mesh);
  c->cb = cb;
  c->s_id = 0;
  c->send_interval = DEFAULT_SEND_INTERVAL;
  rimeaddr_copy(&c->partner, &rimeaddr_null);
}
Beispiel #9
0
// process a decrypted channel packet
link_t link_receive(link_t link, lob_t inner)
{
  chan_t c;

  if(!link || !inner) return LOG("bad args");

  LOG("<-- %d",lob_get_int(inner,"c"));
  // see if existing channel and send there
  if((c = link_chan_get(link, lob_get_int(inner,"c"))))
  {
    LOG("found chan");
    // consume inner
    chan_receive(c, inner);
    // process any changes
    link->chans = link_process_chan(link->chans, 0);
    return link;
  }

  // if it's an open, validate and fire event
  if(!lob_get(inner,"type"))
  {
    LOG("invalid channel open, no type %s",lob_json(inner));
    lob_free(inner);
    return NULL;
  }
  if(!e3x_exchange_cid(link->x, inner))
  {
    LOG("invalid channel open id %s",lob_json(inner));
    lob_free(inner);
    return NULL;
  }
  inner = mesh_open(link->mesh,link,inner);
  if(inner)
  {
    LOG("unhandled channel open %s",lob_json(inner));
    lob_free(inner);
    return NULL;
  }

  return link;
}
Beispiel #10
0
/*---------------------------------------------------------------------------*/
void shell_sample_stats_init(void) {
	mesh_open(&mesh, 132, &callbacks);
	shell_register_command(&sample_stats_command);
	shell_register_command(&get_stats_command);
}