mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-09 14:55:22 +00:00
30 lines
770 B
Python
30 lines
770 B
Python
![]() |
#!/usr/bin/env python
|
||
|
|
||
|
def receive(node):
|
||
|
##### Simple receive
|
||
|
code, data=node.receive("wlan0")
|
||
|
msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
|
||
|
node.log(msg)
|
||
|
|
||
|
|
||
|
def execute(api):
|
||
|
# Should works for all receivers
|
||
|
receive(api)
|
||
|
|
||
|
if api.node_id == 1:
|
||
|
receive(api) # Should works
|
||
|
else:
|
||
|
api.turn_off()
|
||
|
api.wait(1) # Node 2 should not receive anything during 1s
|
||
|
api.turn_on()
|
||
|
|
||
|
|
||
|
if api.node_id == 1:
|
||
|
receive(api) # Should works
|
||
|
else:
|
||
|
api.wait(0.5) # Check if started communication get cancelled on turning off
|
||
|
api.turn_off() # Node 2 should not receive anything
|
||
|
api.wait(0.5) # Node 2 should not receive anything during 0.5s
|
||
|
api.turn_on()
|
||
|
|