From caa3225ef8c7c15b60e9e41e5a5454705fb34285 Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Wed, 30 Apr 2025 13:13:40 -0700 Subject: [PATCH] notes and minor changes to ping --- freecad/kiconnect/api.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/freecad/kiconnect/api.py b/freecad/kiconnect/api.py index 90ed7dd..31c05ed 100644 --- a/freecad/kiconnect/api.py +++ b/freecad/kiconnect/api.py @@ -26,23 +26,38 @@ class APIObject(BaseObject): parent = feature.getParent() if not parent: return + # XXX This gets all of the KiConnect::Board features but then does nothing with them + # future multi-board support? boards = [ board for board in parent.Group if hasattr(board, 'Type') and board.Type == 'KiConnect::Board' ] @property def is_connected(self): + ''' + Returns connection status + ''' + return self.feature.Connected def ping_connection(self, feature): + ''' + Ping the KiCAD API to determine if it's connected + ''' + try: self.kicad.ping() + feature.Connected = True feature.Label2 = 'Connected' + + return True + except Exception as e: print(e) feature.Connected = False feature.Label2 = 'Disconnected' - pass + + return False class APIViewProvider(BaseViewProvider):