From 39b7d25a5746a9bcf8e52be3a007b50e796a40fd Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 16 Jun 2022 02:18:59 +0300 Subject: [PATCH] WIP: enroll device Signed-off-by: HeshamTB --- sql_app/enroll_door.py | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 sql_app/enroll_door.py diff --git a/sql_app/enroll_door.py b/sql_app/enroll_door.py new file mode 100644 index 0000000..a1d2088 --- /dev/null +++ b/sql_app/enroll_door.py @@ -0,0 +1,45 @@ +# Quick enroll new device +# Hesham T. Banafa +# Jun 12th, 2022 + +from decouple import config +import requests + +# idk if this stays in memory... +headers = { + "accept": "application/json", + "Content-type": "application/json" +} +def main(): + + if len(sys.argv) != 4: + print_help() + exit(1) + + device_type = sys.argv[1] + bluetooth_mac = sys.argv[2] + description = sys.argv[3] + if device_type == 'DOOR': + mkdoor(bluetooth_mac, description) + elif device_type == 'MONITOR': + mkmonitor(bluetooth_mac, description) + else: + print('Device type not DOOR or MONITOR', file=sys.stderr) + exit(1) + # gen print token of bluetooth_mac + print(create_iot_dev_token(bluetooth_mac)) + +def mkdoor(bluetooth_mac: str, description: str): + data = { + "bluetooth_mac": bluetooth_mac, + "description": description + } + + #response = requests.post("") + +def mkmonitor(bluetooth_mac: str, description: str): + pass + +def print_help(): + msg = 'usgae: enroll_iotdevice ' + print(msg) \ No newline at end of file