forked from Ravensburger-Verlag-GmbH/GraviTrax-Connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_bridge_mode.py
More file actions
36 lines (30 loc) · 1.08 KB
/
example_bridge_mode.py
File metadata and controls
36 lines (30 loc) · 1.08 KB
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
30
31
32
33
34
35
36
"""Bridge Mode Example Script
When sending a Bridge Mode Signal the receiving stones will only listen to
Signals coming from a Bridge. Other Senders like the Remote are Ignored. This Script
puts all receiving devices into Bridge mode for 10 seconds and sends a Signal after
5 Seconds
"""
import asyncio
from gravitraxconnect import gravitrax_bridge as gb
from gravitraxconnect import gravitrax_constants
async def main():
"""Start the bridge Mode and send a testsignal
"""
try:
bridge = gb.Bridge()
gb.logger.disabled = False
gb.log_print("Searching for Bridge")
await bridge.connect()
await bridge.start_bridge_mode()
await asyncio.sleep(5)
await bridge.send_signal(gravitrax_constants.STATUS_STARTER, gravitrax_constants.COLOR_RED)
await asyncio.sleep(5)
await bridge.stop_bridge_mode()
await bridge.disconnect()
except asyncio.CancelledError:
return
if __name__ == "__main__":
asyncio.run(main())
gb.log_print("Press Enter to close")
input()
gb.log_print("Program finished")