ledVal = 0 # log in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # build OAP message oap_msg = OAPMessage.build_oap( seq=0, sid=0, cmd=OAPMessage.CmdType.PUT, addr=[3, 2], tags=[OAPMessage.TLVByte(t=0, v=ledVal)], sync=True, ) oap_msg_b64 = base64.b64encode(oap_msg) # Convert from bin to base64 # send the packet, once if to one mote, 4 times if Broadcast if macaddr == "FF-FF-FF-FF-FF-FF-FF-FF": loop = 3
if mgrhost == "": mgrhost = DFLT_MGR_HOST # log-in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # Start listening for data notifications voyager.get_notifications( 'data', notif_callback = process_data, disconnect_callback = show_disconnect, ) print '\n==== Subscribing to data notifications' reply = raw_input ('Waiting for notifications. Press any key to stop\n\n') voyager.stop_notifications() print 'Script ended normally' except:
mgrhost = DFLT_VMGR_HOST # log-in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # Get the whole list of motes mote_list = voyager.motesApi.get_motes() # Get Mote Info # mote_info = voyager.motesApi.get_mote_info() # for mote in mote_list.motes: # print mote.mac_address file = open("json_numberOfPackets.json", "w") #with open(os.path.join('C:\INRIA-Victor\VManager\Scripts\smartmeshsdk\VManager Data',"teste.txt"), "w") as file: print 'Script Created Successfully !' # Start listening for data notifications
#============================ body ============================================ # create the client config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") voyager = VManagerApi(host=options.host) # Wrap a simple adapter around the manager's sendData method def send_data(mac, msg, port): 'Returns: the sendData response' msg_encoded = base64.b64encode(msg) # TODO: priority as enum rc = -1 cbid = -1 dataPacket = DataPacketSendInfo() dataPacket.src_port = port dataPacket.dest_port = port dataPacket.priority = PRIORITY dataPacket.payload = msg_encoded
if mgrhost == "": mgrhost = DFLT_MGR_HOST # log-in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # read and display network configuration netConfig = voyager.networkApi.get_network_config() print ('Current network configuration is ...\n {0}'.format(netConfig)) # start listening for data notifications voyager.get_notifications('data', notif_callback=process_data) print '\n==== Subscribing to data notifications' reply = raw_input ('\n Waiting for notifications , Press any key to stop\n') voyager.stop_notifications() print 'Script ended normally' except:
mgrhost = DFLT_MGR_HOST # log-in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # Start listening for data notifications voyager.get_notifications( 'data', notif_callback=process_data, disconnect_callback=show_disconnect, ) print '\n==== Subscribing to data notifications' reply = raw_input('Waiting for notifications. Press any key to stop\n\n') voyager.stop_notifications() print 'Script ended normally' except:
if mgrhost == "": mgrhost = DFLT_VMGR_HOST # log-in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # start listening for hr notifications voyager.get_notifications(notif_callback=process_notif) print '\n==== Subscribing to all notifications' reply = raw_input ('\n Waiting for notifications from mote, Press any key to stop\n') voyager.stop_notifications() print 'Script ended normally' except: traceback.print_exc() print ('Script ended with an error.') sys.exit()
default=DFLT_DB_PORT, help="Port to forward data to on the DB host", ) options = parser.parse_args() db_host = options.db_host db_port = options.db_port # log in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False # initialize the VManager Python library voyager = VManagerApi(host=options.vmgr_host, port=options.vmgr_port) # start listening for data notifications voyager.get_notifications('data', notif_callback=process_data) print '\n==== Subscribing to data notifications and publish to clouddata.dustcloud.org' reply = raw_input('Forwarding notifications. Press any key to stop\n\n') voyager.stop_notifications() print 'Script ended normally' except: traceback.print_exc() print('Script ended with an error.') voyager.stop_notifications() sys.exit()
def main(): writeToFile(intype='admin', indata={'msg': 'starting'}, firstline=True) try: #=== connect # banner print '\nVMgr_LogFileSnapshot (c) Dust Networks' print 'SmartMesh SDK {0}\n'.format('.'.join( [str(i) for i in sdk_version.VERSION])) # log-in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=DFLT_VMGR_HOST) fileLock = threading.RLock() voyager.get_notifications(notif_callback=_handle_notifications) #=== collect snapshot = {} while True: motes = voyager.motesApi.get_motes().to_dict() assert motes.keys() == ['motes'] motes = motes['motes'] ''' motes = [ { 'mac_address': '00-17-0D-00-00-31-CA-03', 'state': 'operational'}, { 'mac_address': '00-17-0D-00-00-38-06-D5', 'state': 'operational'}, ... ] ''' snapshot['motes'] = motes for (i, mote) in enumerate(motes): mote_info = voyager.motesApi.get_mote_info( mote['mac_address']).to_dict() mote_info = remove_datetime(mote_info) ''' mote_info = { 'app_id': 1, 'app_sw_rev': '1.4.1.8', 'avg_hops': 1.0, ... } ''' snapshot['motes'][i]['mote_info'] = mote_info connections = voyager.pathsApi.get_connections( mote['mac_address']).to_dict() assert connections.keys() == ['devices'] connections = connections['devices'] for (i, c) in enumerate(connections): connections[i] = remove_datetime(c) ''' connections = [ { 'mac_address': '00-17-0D-00-00-58-2B-4F', 'num_links': None, 'quality': None, 'rssi_ato_b': None, 'rssi_bto_a': None, }, ... ] ''' snapshot['motes'][i]['connections'] = connections network_info = voyager.networkApi.get_network_info().to_dict() network_info = remove_datetime(network_info) ''' network_info = { 'adv_state': 'on', 'cur_down_frame_size': 512, ... } ''' snapshot['network_info'] = network_info #==== write writeToFile( intype='snapshot', indata=snapshot, ) #=== wait a bit time.sleep(5 * 60) except: traceback.print_exc()
otap_options = otap_options._replace(inter_command_delay=int(options.delay)) #============================ body ============================================ # create the client config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False if os.path.isfile(certifi.where()): config.ssl_ca_cert = certifi.where() else: config.ssl_ca_cert = os.path.join(os.path.dirname(sys.executable), "cacert.pem") voyager = VManagerApi(host=options.host) # Wrap a simple adapter around the manager's sendData method def send_data(mac, msg, port): 'Returns: the sendData response' msg_encoded = base64.b64encode(msg) # TODO: priority as enum rc = -1 cbid = -1 dataPacket = DataPacketSendInfo() dataPacket.src_port = port dataPacket.dest_port = port dataPacket.priority = PRIORITY dataPacket.payload = msg_encoded mac_str = '-'.join(["%02X" % b for b in mac])