diff --git a/KaiSDK/Kai.py b/KaiSDK/Kai.py index 420b671..b7accd3 100644 --- a/KaiSDK/Kai.py +++ b/KaiSDK/Kai.py @@ -2,8 +2,9 @@ class Kai: - def __init__(self, id = None, capabilities = 0, hand = None): + def __init__(self, id = None, name = None, capabilities = 0, hand = None): self.id = id + self.name = name self.capabilities = capabilities self.hand = hand self.eventManager = EventManager() diff --git a/KaiSDK/WebSocketModule.py b/KaiSDK/WebSocketModule.py index 3882450..d71ad53 100644 --- a/KaiSDK/WebSocketModule.py +++ b/KaiSDK/WebSocketModule.py @@ -46,9 +46,11 @@ def close(self): # Trigger a recv() for the listener so it closes (seems kind of hacky) self.getSDKVersion() self.webSocket.close() + print('Websocket intentionally closed.') def create_connection(self): self.webSocket = websocket.create_connection(Constants.WebSockerURL) + print(f'Websocket has been successfully hosted at {Constants.WebSockerURL}') def close_connection(self): self.webSocket.close() diff --git a/KaiSDK/kai_sdk.py b/KaiSDK/kai_sdk.py index a89e434..0827ff7 100644 --- a/KaiSDK/kai_sdk.py +++ b/KaiSDK/kai_sdk.py @@ -6,16 +6,18 @@ import json import traceback import threading +nomenclature = ['alpha', 'beta', 'gamma','delta','epsilon','zeta', 'eta','theta'] class KaiSDK: - ConnectedKais = [Kai() for i in range(8)] + ConnectedKais = [Kai(name=x) for x in nomenclature] ForegroundProcess = "" - DefaultKai = Kai() - DefaultLeftKai = Kai() - DefaultRightKai = Kai() - AnyKai = Kai() + myKai = ConnectedKais[0] + DefaultKai = myKai + DefaultLeftKai = myKai + DefaultRightKai = myKai + AnyKai = myKai def __init__(self): self.initialized = False @@ -38,13 +40,15 @@ def connect(self, moduleID, moduleSecret): :rtype: bool """ self.initialize(moduleID, moduleSecret) - self.create_connection() + self.create_connection() #redundant self.sendAuth() self.handle(self.receive_data()) if self.authenticated: + print("KaiSDK successfully connected") self.running = True self.dataListener = threading.Thread(target=self.listener_thread) self.dataListener.start() + print("started event listening") return True return False @@ -83,9 +87,13 @@ def listener_thread(self): self.close() def sendAuth(self): + print("Authentication in progress") obj = dict() obj[Constants.Type] = Constants.Authentication + print(Constants.Authentication) obj[Constants.ModuleId] = self.moduleID + print(self.moduleID) + print("Authentication successful") obj[Constants.ModuleSecret] = self.moduleSecret self.send(json.dumps(obj)) @@ -94,11 +102,13 @@ def getConnectedKais(self): obj = dict() obj[Constants.Type] = Constants.ListConnectedKais self.send(json.dumps(obj)) + return Constants.ListConnectedKais def getSDKVersion(self): obj = dict() obj[Constants.Type] = Constants.GetSDKVersion self.send(json.dumps(obj)) + return Constants.GetSDKVersion def setCapabilities(self, kai, capabilities): kai.set_capabilities(capabilities)