Hub SDK Reference

Written for ≥ v0.3.23, revision 2

Pan Nodes Database

getPanNodesInfo()
  • description
    • Get information about all nodes. The node information is automatically created and stored after successful pairing. The automatically created node information format is {nodeId:{'nwkAddr':nwkAddr}}, e.g:

      {
          2913150560251434379: {
              'nwkAddr': 3478
          },
          5149013418181165: {
              'nwkAddr': 23258
          }
      }
      
  • example
    • Print all nodeId and nwkAddr:

      from core.db_pan_nodes import DBPanNodes
      
      displayNodes = DBPanNodes()
      nodes = displayNodes.getPanNodesInfo()
      for nodeId in nodes:
          print('nodeId: %s' % hex(nodeId))
          nwkAddr = nodes[nodeId]['nwkAddr']
          print('nwkAddr: %x' % nwkAddr)
      
setPanNodesInfo(nodeDict = {})
  • description
    • Set the information for nodes.

  • parameter
    • nodeDict: Information for all nodes.

  • example
    • Set the name of the node:

      from core.db_pan_nodes import DBPanNodes
      
      displayNodes = DBPanNodes()
      nodes = displayNodes.getPanNodesInfo()
      nodeId = 2913150560251434379
      if nodeId in nodes:
          nodes[nodeId]['name'] = 'TEST'
          displayNodes.setPanNodesInfo(nodes)
      

注意

setPanNodesInfo() will write the file. This function should not be called too frequently,possibly, causing disk corruption.