Merge from old Gitea
This commit is contained in:
27
examples/NFC.py
Normal file
27
examples/NFC.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
import time
|
||||
from esasdk import Machine
|
||||
|
||||
async def main():
|
||||
# Connect to a machine
|
||||
machine = Machine("ws://localhost:5424")
|
||||
await machine.connect()
|
||||
|
||||
# send NFC UID
|
||||
login = await machine.login_NFC("048CB772AC6D81")
|
||||
loginInfo = login.split(" ")
|
||||
userID = loginInfo[-1]
|
||||
# start a game as jon
|
||||
gameCode = "MAES"
|
||||
countdown = 5
|
||||
duration = 15
|
||||
await machine.game_start(gameCode, userID, countdown, duration)
|
||||
print(f"INFO: running {gameCode}")
|
||||
# wait a stop event
|
||||
await machine._await_message("STOPPED")
|
||||
print("INFO: game stopped")
|
||||
# Close connection
|
||||
await machine.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user