Hello friends,

I have a problem with the nesC file.
I create 8 sensors that start in slot 0 and their time window slides to slot
183 (using Block Design [183,14,1].
Of these 183 slots, 14 are active and should send a packet (denominated in
code as padrao [X]).
My problem is that it activates the radios in padrao slots, but only sends
in slot 20 (since it is the only window where it has two consecutive slots,
19 and 20).
I do not know where else to change to try to have it send one packet to each
of the 14 active slots.
Here's my code:

module testeC @safe() {
  uses {
    interface Boot;
    interface Receive;
    interface AMSend;
    interface Timer<TMilli> as TimerSlot;
    interface LocalTime<TMilli> as Clock;
    interface SplitControl as AMControl;
    interface Packet;
    interface AMPacket;
    interface Random;
    interface ParameterInit<uint16_t> as Seed;
  }
}


implementation {
  message_t packet;
  bool locked;
  bool radio;
  uint16_t slot, slotin;
  uint16_t syncwith, syncwithin;
  uint16_t seqnum;
  uint8_t synchops = 0;
  uint8_t synchopsin;
  bool padrao[183];
  uint8_t numslots = 183;  

  event void Boot.booted() {
    padrao[0] = padrao[12] = padrao[19] = padrao[20] = padrao[22] =
padrao[43] = padrao[60] = padrao[71] = padrao[76] = padrao[85] = padrao[89]
= padrao[115] = padrao[121] = padrao[168] = TRUE;
    syncwith = TOS_NODE_ID;
    slot = 0;
    dbg("teste","BOOT_NO: No %hu boot no slot %hu\n", TOS_NODE_ID, slot);
    call TimerSlot.startPeriodic(2);
  }

  event void TimerSlot.fired() {
    slot=slot%numslots; //Without this verification does not limit until
slot 183
    //if (padrao[slot/numslots]) { //If so, all slots are active and sends a
packet in each slot padrao
    if (padrao[slot]) { //Works active / inactive, but only sends in slot 20
      call AMControl.start();
      dbg("teste","SLOT_ACTIVE: No %hu no slot [%hu] com tempo=%lu.\n",
TOS_NODE_ID, slot, call Clock.get());
      if (radio == TRUE) {
         teste_msg_t* rcm = (teste_msg_t*)call Packet.getPayload(&packet,
sizeof(teste_msg_t));
         rcm->seqnum = seqnum;
         rcm->slot = slot;
         rcm->syncwith = syncwith;
         rcm->synchops = synchops;
         if (call AMSend.send(AM_BROADCAST_ADDR, &packet,
sizeof(teste_msg_t)) == SUCCESS) {
              dbg("teste", "SEND_PKT [seqnum=%hu], slot %hu no
tempo=%lu.\n", seqnum, slot, call Clock.get());
              seqnum++;
              locked = TRUE;       
            }
         }
    } else {
       dbg("teste","SLOT_INACTIVE: No %hu no slot [%hu] com tempo=%lu.\n",
TOS_NODE_ID, slot, call Clock.get());
       call AMControl.stop();
    } slot++;
  }

  event void AMControl.startDone(error_t err) {
    radio = TRUE;
    if (err == SUCCESS) {
      dbg("teste","RADIO_ON: Radio do No %hu iniciado no slot [%hu] no
tempo=%lu.\n", TOS_NODE_ID, slot, call Clock.get());
    } else {
       call AMControl.start();
    }
    return;
  }
 
  event void AMControl.stopDone(error_t err) {
    radio = FALSE;
    dbg("teste","RADIO_OFF: Radio do No %hu desligado no slot=%lu no
tempo=%hu.\n", TOS_NODE_ID, slot, call Clock.get());
  }

I discovered that it can only send when two slots are consecutive, because I
changed the default (padrao) for this, however this can not be accepted,
because it does not meet the rules of Block Design.

Once again I'm sorry for English, but I'm using Google Translate.

Thanks in advance for any help. Thank you!!!




--
View this message in context: 
http://tinyos-help.10906.n7.nabble.com/Package-submission-failed-tp25075.html
Sent from the TinyOS - Help mailing list archive at Nabble.com.
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to