blob: a2ed69099c23fb873264fb5bd70bff0d4de4b467 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/usr/bin/env python
import sys, random, time
lr=random.Random(6)
def execute(api):
uptime=api.args
endoff=0
for i in range(0,24):
startoff=random.randint(0,3600-uptime)
api.turn_off()
api.wait(startoff+endoff)
api.turn_on()
wakeat=api.read("clock")
wakeuntil=wakeat+uptime
# Receive until uptime seconds if elapsed
while api.read("clock") < wakeuntil:
code, data=api.receivet("wlan0",wakeuntil-api.read("clock"))
if code == 0:
api.log("Receive "+data)
api.log("Was up for {}s".format(api.read("clock")-wakeat))
endoff=3600*(i+1)-api.read("clock")
api.turn_off()
api.wait(endoff)
api.turn_on()
|