def ping_test(node_num, connection, baseStation): node = [] node.append(mscl.WirelessNode(node_num[0], baseStation)) node.append(mscl.WirelessNode(node_num[1], baseStation)) response = [] node0 = 0 node1 = 0 while True: try: # create a WirelessNode with the BaseStation we created #node = mscl.WirelessNode(NODE_ADDRESS, baseStation) print("Attempting to ping the Nodes...") # ping the Node response.append(node[0].ping()) response.append(node[1].ping()) if response[0].success(): node0 = 1 if response[1].success(): node1 = 1 if node0 + node1 == 2: print("Successfully pinged Node", node_num[0]) print("Base Station RSSI:", response[0].baseRssi()) print("Node RSSI:", response[0].nodeRssi()) print("Successfully pinged Node", node_num[1]) print("Base Station RSSI:", response[1].baseRssi()) print("Node RSSI:", response[1].nodeRssi()) return node0, node1 if node0 == 0: print("Failed to ping Node 1 address...") if node1 == 0: print("Failed to ping Node 2 address...") return node0, node1 except Exception as e: print("Error:", e) close_comms(connection)
sys.path.append("../../dependencies/Python") import mscl # TODO: change these constants to match your setup COM_PORT = "COM3" NODE_ADDRESS = 31849 try: # create a Serial Connection with the specified COM Port, default baud rate of 921600 connection = mscl.Connection.Serial(COM_PORT) # create a BaseStation with the connection baseStation = mscl.BaseStation(connection) # create a WirelessNode with the BaseStation we created node = mscl.WirelessNode(NODE_ADDRESS, baseStation) # call the set to idle function and get the resulting SetToIdleStatus object status = node.setToIdle() print "Setting Node to Idle", # using the SetToIdleStatus object, check if the Set to Idle operation is complete. # Note: we are specifying a timeout of 300 milliseconds here which is the maximum # amount of time that the complete function will block if the Set to Idle # operation has not finished. Leaving this blank defaults to a timeout of 10ms. while not status.complete(300): # Note: the Set to Idle operation can be canceled by calling status.cancel() print ".", # at this point, the Set to Idle operation has completed
def connectNode(self, bs): self.node = mscl.WirelessNode(int(self.node_addr), bs) print("Connect node: " + self.node_addr) return self.node
def connectToNode(node_addr, bs): node = mscl.WirelessNode(int(node_addr), bs) print("Connect node: " + node_addr) return node