# 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 voyager.get_notifications(notif_callback=process_notif) print '\n==== Subscribing to data notifications' reply = raw_input( '\n Waiting for notifications from mote, Press any key to stop\n') file.close print 'Script Closed' voyager.stop_notifications() print 'Script ended normally' print '================================================================================' print 'alarmClosed Packets: {0}\n'.format(global_counter[0]) print 'alarmOpened Packets: {0}\n'.format(global_counter[1]) print 'apStateChanged Packets: {0}\n'.format(global_counter[2])
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: traceback.print_exc() print ('Script ended with an error.') sys.exit()
[str(i) for i in sdk_version.VERSION])) mgrhost = raw_input( 'Enter the IP address of the manager (e.g. {0} ): '.format( DFLT_VMGR_HOST)) if mgrhost == "": mgrhost = DFLT_VMGR_HOST # log in as user "dust" config = Configuration() config.username = '******' config.password = '******' config.verify_ssl = False # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # start listening for data notifications voyager.get_notifications('data', notif_callback=process_data) print '\n==== Subscribing to all Blink data notifications' reply = raw_input('Waiting for 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.') sys.exit()
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: traceback.print_exc() print ('Script ended with an error.') voyager.stop_notifications() sys.exit()
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: traceback.print_exc() print('Script ended with an error.') sys.exit()
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()
"cacert.pem") # initialize the VManager Python library voyager = VManagerApi(host=mgrhost) # first test that the mote does exist and is operational print '\n==== Verifying that the mote requested is in network and Operational' mote_list = voyager.motesApi.get_motes() for mote in mote_list.motes: if mote.mac_address == macaddr and mote.state == "operational": mote_exists = True if mote_exists: print '\n==== Sending Ping to the mote and wait for the response' # start listening for data notifications voyager.get_notifications('events', notif_callback=process_notif) # send a ping to the mote myresponse = voyager.motesApi.ping_mote(macaddr) print ' Ping sent to mote {0}, callback = {1}'.format( macaddr, myresponse.callback_id) # wait for the pingNotification response and then exit the program print '\n Waiting for the pingResponse notification' stop_event.wait() voyager.stop_notifications() print '\nScript ended normally' else: print '\n This MAC address is not joined to this network' except:
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()