Re: [Tinyos-help] Time slot time

2017-03-21 Thread arsaraiva
Hi James, how are you?

Repair the code below:

include "Timer.h"
 
module testeC @safe() {
  uses {
interface Boot;
interface Receive;
interface AMSend;
interface Timer as TimerSlot;
interface LocalTime as Clock;
interface SplitControl as AMControl;
interface Packet;
interface AMPacket;
interface Random;
interface ParameterInit 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(,
sizeof(teste_msg_t));
  rcm->seqnum = seqnum;
  rcm->slot = slot;
  rcm->syncwith = syncwith;
  rcm->synchops = synchops;
  if (call AMSend.send(AM_BROADCAST_ADDR, , 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


Re: [Tinyos-help] Time slot time

2017-03-21 Thread James Allen (PGR)
Hi,

Sorry but I can't figure out from your post what exactly the question is. Can 
you rephrase the question with more detail or give some context of what you're 
trying to achieve?

James

From: arsaraiva<mailto:andresara...@id.uff.br>
Sent: ‎20/‎03/‎2017 18:02
To: 
tinyos-help@millennium.berkeley.edu<mailto:tinyos-help@millennium.berkeley.edu>
Subject: [Tinyos-help] Time slot time

Hello friends,

I would like a help on TinyOS / TOSSIM how to setup the time slot in a
simulation.
I set up my time window with 183 slots, with only 14 active.
I have a call to function call type TimerSlot.startPeriodic (2); Which
checks which slot is in the loop and turns it on or off.
My question is that this function comes from the "interface Timer as
TimerSlot;" And I do not know where it has to configure for each slot to
have a time of 100ms.

Thanks in advance for your help.



--
View this message in context: 
http://tinyos-help.10906.n7.nabble.com/Time-slot-time-tp25078.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
___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

[Tinyos-help] Time slot time

2017-03-20 Thread arsaraiva
Hello friends,

I would like a help on TinyOS / TOSSIM how to setup the time slot in a
simulation.
I set up my time window with 183 slots, with only 14 active.
I have a call to function call type TimerSlot.startPeriodic (2); Which
checks which slot is in the loop and turns it on or off.
My question is that this function comes from the "interface Timer as
TimerSlot;" And I do not know where it has to configure for each slot to
have a time of 100ms.

Thanks in advance for your help.



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