Beispiel #1
0
/*---------------------------------------------------------------------------*/
int
mesh_send(struct mesh_conn *c, const rimeaddr_t *to)
{
  int could_send;

  PRINTF("%d.%d: mesh_send to %d.%d\n",
	 rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
	 to->u8[0], to->u8[1]);
  
  could_send = multihop_send(&c->multihop, to);

  if(!could_send) {
    if(c->queued_data != NULL) {
      queuebuf_free(c->queued_data);
    }

    PRINTF("mesh_send: queueing data, sending rreq\n");
    c->queued_data = queuebuf_new_from_packetbuf();
    rimeaddr_copy(&c->queued_data_dest, to);
    route_discovery_discover(&c->route_discovery_conn, to,
			     PACKET_TIMEOUT);
    return 0;
  }
  c->cb->sent(c);
  return 1;
}
Beispiel #2
0
static void
broadcast_recv1(struct broadcast_conn *c, const rimeaddr_t *from)
{  for(i=0;i<40;i++) s1[i]='\0';
  /*printf("broadcast message received from %d.%d\n",
         from->u8[0], from->u8[1]);
  printf(" message received '%s'\n", (char *)packetbuf_dataptr());*/
  voltage=(char *)packetbuf_dataptr();
  rssi=-packetbuf_attr(PACKETBUF_ATTR_RSSI);
//printf("rssi=%u\n",rssi);
sensor = sensors_find(ADC_SENSOR);
    if(sensor) {
    rv = sensor->value(ADC_SENSOR_TYPE_VDD);

      if(rv != -1) {
        sane = (rv * 3.75)/ 2047;
        dec = sane;
        frac = sane - dec;
        //printf("Supply=%d.%02u V (%d)\n", dec, (unsigned int)(frac*100), rv);
        /* Store rv temporarily in dec so we can use it for the battery */
        dec1=dec;
        dec = rv;
      }}
  sprintf(s1,"FE%u,%u,%u,%u,%d,%s,%uEE",from->u8[0],from->u8[1],rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],rssi,voltage,dec1*100+(unsigned int)(frac*100));
   printf("%s\n",s1);
packetbuf_copyfrom(s1, sizeof(s1));
    
    multihop_send(&multihop, &to);
    //printf("send\n");
}
Beispiel #3
0
static void
recv(struct multihop_conn *c, const rimeaddr_t *sender,
     const rimeaddr_t *prevhop,
     uint8_t hops)
{
  //printf("%s\n", (char *)packetbuf_dataptr());
  s=(char *)packetbuf_dataptr();
  sprintf(S,"%s",s);
  packetbuf_copyfrom(S, sizeof(S));
  multihop_send(&multihop, &nexthop);
  //printf("prevhop is  %d.%d \n  ",prevhop->u8[0],prevhop->u8[1]);
  //printf("sender is  %d.%d\n",sender->u8[0],sender->u8[1]);
}
Beispiel #4
0
/*---------------------------------------------------------------------------*/
static void
found_route(struct route_discovery_conn *rdc, rimeaddr_t *dest)
{
  struct mesh_conn *c = (struct mesh_conn *)
    ((char *)rdc - offsetof(struct mesh_conn, route_discovery_conn));

  if(c->queued_data != NULL &&
     rimeaddr_cmp(dest, &c->queued_data_dest)) {
    queuebuf_to_packetbuf(c->queued_data);
    queuebuf_free(c->queued_data);
    c->queued_data = NULL;
    multihop_send(&c->multihop, dest);
  }
}
Beispiel #5
0
/*---------------------------------------------------------------------------*/
int
mesh_send(struct mesh_conn *c, const rimeaddr_t *to)
{
  int could_send;

  PRINTF("%d.%d: mesh_send to %d.%d\n",
	 rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
	 to->u8[0], to->u8[1]);
  
  could_send = multihop_send(&c->multihop, to);

  if(!could_send) {
    PRINTF("mesh_send: could not send\n");
    return 0;
  }
  c->cb->sent(c);
  return 1;
}