def advertisement(testDevice, DUT_UUID=None): if (DUT_UUID is None): DUT_UUID = runTest.DUT_UUID_128 if (bleAdapter.getPropertie(testDevice, "Address") is None): print("Advertisement test: Waiting for Address") sys.stdout.flush() return False UUIDs = bleAdapter.getPropertie(testDevice, "UUIDs") if (UUIDs is None): print("Advertisement test: Waiting for UUIDs") sys.stdout.flush() return False else: if (DUT_UUID not in UUIDs): print("Advertisement test: Waiting for device UUID") sys.stdout.flush() return False # Remove test for service B. Advertisement messages were too small. # Should look into improving this part if it can be done. # if (runTest.DUT_SERVICEB_UUID not in UUIDs): # print("Advertisement test: Waiting for serviceB UUID") # sys.stdout.flush() # return False name = bleAdapter.getPropertie(testDevice, "Name") if (name is None): print("Advertisement test: Waiting name") sys.stdout.flush() return False else: # Names can be cached. So the complete local name may still be in # memory. Check the 4 first letter which constitutes the short name if (runTest.DUT_NAME != name[:runTest.SHORT_LOCAL_NAME_SIZE]): print("Advertisement test: name is incorrect: " + name) sys.stdout.flush() # return False if (bleAdapter.getPropertie(testDevice, "TxPower") is None): print("Advertisement test: Waiting for TxPower") sys.stdout.flush() return False if (bleAdapter.getPropertie(testDevice, "RSSI") is None): print("Advertisement test: Waiting for RSSI") sys.stdout.flush() return False return True
def get_manufacture_data(testDevice, DUT_UUID=None): manufacture_data_dict = bleAdapter.getPropertie(testDevice, "ManufacturerData") # If manufacture data doesn't exist, return None if( manufacture_data_dict == None ): print("No Manufacture Data") sys.stdout.flush() return None # If manufacture data exists, return manufacture data else: print( "Manufacturer Specific Data: " + str(manufacture_data_dict.items()) ) sys.stdout.flush() manufacture_data = manufacture_data_dict[runTest.COMPANY_ID] return manufacture_data
def get_service_data(testDevice, DUT_UUID=None): service_data_dict = bleAdapter.getPropertie(testDevice, "ServiceData") # If service data doesn't exist, return None if (service_data_dict is None): return None # If service data exists, return service data else: print("Service Data: " + str(service_data_dict.items())) sys.stdout.flush() if service_data_dict.get(runTest.SERV_UUID) != None: service_data = service_data_dict[runTest.SERV_UUID] return service_data else: return None
def advertisement(testDevice): if (bleAdapter.getPropertie(testDevice, "Address") == None): print("Advertisement test: Waiting for Address") sys.stdout.flush() return False UUIDs = bleAdapter.getPropertie(testDevice, "UUIDs") if (UUIDs == None): print("Advertisement test: Waiting for UUIDs") sys.stdout.flush() return False else: if (runTest.DUT_UUID not in UUIDs): print("Advertisement test: Waiting for device UUID") sys.stdout.flush() return False if (runTest.DUT_SERVICEB_UUID not in UUIDs): print("Advertisement test: Waiting for serviceB UUID") sys.stdout.flush() return False name = bleAdapter.getPropertie(testDevice, "Name") if (bleAdapter.getPropertie(testDevice, "Name") == None): print("Advertisement test: Waiting name") sys.stdout.flush() return False else: if (runTest.DUT_NAME != name): print("Advertisement test: Waiting for name") sys.stdout.flush() return False if (bleAdapter.getPropertie(testDevice, "TxPower") == None): print("Advertisement test: Waiting for TxPower") sys.stdout.flush() return False if (bleAdapter.getPropertie(testDevice, "RSSI") == None): print("Advertisement test: Waiting for RSSI") sys.stdout.flush() return False return True
def discoverPrimaryServices(): return bleAdapter.getPropertie(runTest.testDevice, "ServicesResolved")