Hi James, how are you?

Repair the code below:

include "Timer.h"
 
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 on slot %hu\n", TOS_NODE_ID, slot);
    if (TOS_NODE_ID == 0){
        synchops = 0;
        dbg("teste", "No %hu in hops %hu\n", TOS_NODE_ID, synchops);
    } else {
        synchops = 255;
        dbg("teste", "No %hu in hops %hu\n", TOS_NODE_ID, synchops);
    }
    call TimerSlot.startPeriodic(2);
  }

  event void TimerSlot.fired() {
    slot++;
    slot=slot%numslots; 
    if (padrao[slot]) { 
      call AMControl.start();
     } else {
       dbg("teste","SLOT_INACTIVO: No %hu on slot [%hu] time=%lu.\n",
TOS_NODE_ID, slot, call Clock.get());
       call AMControl.stop();
    } 
  }

  event void AMControl.startDone(error_t err) {
    radio = TRUE;
    if (err == SUCCESS) { 
      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 {
       call AMControl.start();
    }
    return;
  }
 
  event void AMControl.stopDone(error_t err) {
    radio = FALSE;
    dbg("teste","RADIO_STOPED: Radio do No %hu stop on slot=%lu
time=%hu.\n", TOS_NODE_ID, slot, call Clock.get());
  }

I'll try to explain: the first function boots the sensors (Boot.booted()),
and calls the TimeSlot.fired () function that checks if the current value of
the slot in the loop is between the default set of [x]. If so, the function
calls the AMControl.start () that connects the sensor's radio. Once
connected, the AMControl.startDone () function checks if the radio is on and
sends a beacon with the information.

My question is how to make this radio stay on for 100ms, regardless of
whether the beacon was broadcast or not.

I do not know if the function AMContral.start () allows you to configure how
long the radio is active. Also note that I already have the
AMControl.stopDone () function to stop the radio.

Thank you for your help



--
View this message in context: 
http://tinyos-help.10906.n7.nabble.com/Time-slot-time-tp25078p25080.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