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):