blob: 555376be8e65992eaaacaacd90b41d386d6b5b1b (
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
29
|
#!/usr/bin/env python
import sys, random, time
from esds import RCode
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 == RCode.SUCCESS:
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()
|