In my case, I want to wake up the subnero modem in specific time and transmit the signal generated by myself. According to the unetStack handbook Chapter 25, scheduler module has the ability to organize the modem wakeup at a specific time. So I tried to test the modem by using follow groovy script. Without no doubt, it not works.
addsleep 1.minutes.later 5.minutes.later;
phy << new GetSleepScheduleReq();
plvl = -30;
signal = load('sig.txt');
5.times {
phy << new TxBasebandSignalReq(signal:signal, fc:0);
delay(5000);
}
I found there is a function named “WakeFromSleepNtf’, which would be helpful to control the modem, however, no detail illustration about such function.
Although the delay function or the parameter, named TxTime, of TxBasebandSignalReq can be used to make a schedule to control the modem working in a specific timeline, it requires the modem works all the time. In this way, the battery of the modem is a concern, especially when the modem is integrated with a vehicle.
I believe that if there is a notifying function or other method to realize run my script automatically when the subnero waked up, then the problem can be solved.
You're on the right track, but have some details incorrect. If I understand correctly, you want to sleep for 5 minutes and then transmit a signal 5 times with a delay of 5 seconds between transmissions.
If so, I would do something like this on the shell:
// part 1: wait until its time to transmit
t = 5.minutes.later // calculate time of transmission
addsleep t // schedule sleep from now until time t
while (t-time/1000 > 1) delay(1000) // wait until its time to transmit
// part 2: make your transmissions
plvl -30 // set power level
signal = load('sig.txt') // load your signal
5.times { // transmit it 5 times with 5 second delay
phy << new TxBasebandSignalReq(signal:signal, fc:0)
delay(5000)
}
The first part of the code computes the time t
(in epoch seconds) at which transmission should be made, and asks the modem to schedule a sleep until then. Putting the modem to sleep takes a few seconds, so the script will continue running during this time. Hence we need the next statement to wait until it's time to transmit, by checking the current time (time
gives current time in epoch milliseconds) against the transmit time every second.
The second part of the code is the same as yours, but do note there should be no =
after plvl
.
P.S. Some modems (e.g. unet audio
on laptop) may not have low power sleep mode, so might not really sleep. The wait loop in part 1 also ensures that this code works correctly on such modems.