def test_examples_provisioning_ble(env, extra_data): # Acquire DUT dut1 = env.get_dut("ble_prov", "examples/provisioning/legacy/ble_prov", dut_class=ttfw_idf.ESP32DUT) # Get binary file binary_file = os.path.join(dut1.app.binary_path, "ble_prov.bin") bin_size = os.path.getsize(binary_file) ttfw_idf.log_performance("ble_prov_bin_size", "{}KB".format(bin_size // 1024)) ttfw_idf.check_performance("ble_prov_bin_size", bin_size // 1024, dut1.TARGET) # Upload binary and start testing dut1.start_app() # Parse BLE devname devname = dut1.expect(re.compile( r"Provisioning started with BLE devname : '(PROV_\S\S\S\S\S\S)'"), timeout=60)[0] print("BLE Device Alias for DUT :", devname) # Match additional headers sent in the request dut1.expect("BLE Provisioning started", timeout=30) print("Starting Provisioning") verbose = False protover = "V0.1" secver = 1 pop = "abcd1234" provmode = "ble" ap_ssid = "myssid" ap_password = "******" print("Getting security") security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError("Failed to get security") print("Getting transport") transport = esp_prov.get_transport(provmode, devname) if transport is None: raise RuntimeError("Failed to get transport") print("Verifying protocol version") if not esp_prov.version_match(transport, protover): raise RuntimeError("Mismatch in protocol version") print("Starting Session") if not esp_prov.establish_session(transport, security): raise RuntimeError("Failed to start session") print("Sending Wifi credential to DUT") if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError("Failed to send Wi-Fi config") print("Applying config") if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError("Failed to send apply config") if not esp_prov.wait_wifi_connected(transport, security): raise RuntimeError("Provisioning failed")
def test_examples_wifi_prov_mgr(env, extra_data): # Acquire DUT dut1 = env.get_dut("wifi_prov_mgr", "examples/provisioning/manager", dut_class=ttfw_idf.ESP32DUT) # Get binary file binary_file = os.path.join(dut1.app.binary_path, "wifi_prov_mgr.bin") bin_size = os.path.getsize(binary_file) ttfw_idf.log_performance("wifi_prov_mgr_bin_size", "{}KB".format(bin_size // 1024)) ttfw_idf.check_performance("wifi_prov_mgr_bin_size", bin_size // 1024) # Upload binary and start testing dut1.start_app() # Check if BT memory is released before provisioning starts dut1.expect("wifi_prov_scheme_ble: BT memory released", timeout=60) # Parse BLE devname devname = dut1.expect(re.compile( r"Provisioning started with service name : (PROV_\S\S\S\S\S\S)"), timeout=30)[0] print("BLE Device Alias for DUT :", devname) print("Starting Provisioning") verbose = False protover = "v1.1" secver = 1 pop = "abcd1234" provmode = "ble" ap_ssid = "myssid" ap_password = "******" print("Getting security") security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError("Failed to get security") print("Getting transport") transport = esp_prov.get_transport(provmode, devname) if transport is None: raise RuntimeError("Failed to get transport") print("Verifying protocol version") if not esp_prov.version_match(transport, protover): raise RuntimeError("Mismatch in protocol version") print("Verifying scan list capability") if not esp_prov.has_capability(transport, 'wifi_scan'): raise RuntimeError("Capability not present") print("Starting Session") if not esp_prov.establish_session(transport, security): raise RuntimeError("Failed to start session") print("Sending Wifi credential to DUT") if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError("Failed to send Wi-Fi config") print("Applying config") if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError("Failed to send apply config") success = False while True: time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) if (ret == 1): continue elif (ret == 0): print("Provisioning was successful") success = True break if not success: raise RuntimeError("Provisioning failed") # Check if BTDM memory is released after provisioning finishes dut1.expect("wifi_prov_scheme_ble: BTDM memory released", timeout=30)
def test_examples_provisioning_softap(env, extra_data): # Acquire DUT dut1 = env.get_dut("softap_prov", "examples/provisioning/softap_prov") # Get binary file binary_file = os.path.join(dut1.app.binary_path, "softap_prov.bin") bin_size = os.path.getsize(binary_file) IDF.log_performance("softap_prov_bin_size", "{}KB".format(bin_size // 1024)) IDF.check_performance("softap_prov_bin_size", bin_size // 1024) # Upload binary and start testing dut1.start_app() # Parse IP address of STA dut1.expect("Starting WiFi SoftAP provisioning", timeout=60) dut1.expect("SoftAP started", timeout=30) [ssid, password] = dut1.expect(re.compile( r"SoftAP Provisioning started with SSID '(\S+)', Password '(\S+)'"), timeout=30) iface = wifi_tools.get_wiface_name() if iface is None: raise RuntimeError("Failed to get Wi-Fi interface on host") print("Interface name : " + iface) print("SoftAP SSID : " + ssid) print("SoftAP Password : "******"Connecting to DUT SoftAP...") ip = ctrl.connect(ssid, password) got_ip = dut1.expect( re.compile(r"softAP assign IP to station,IP is: (\d+.\d+.\d+.\d+)"), timeout=30)[0] if ip != got_ip: raise RuntimeError("SoftAP connected to another host! " + ip + "!=" + got_ip) print("Connected to DUT SoftAP") print("Starting Provisioning") verbose = False protover = "V0.1" secver = 1 pop = "abcd1234" provmode = "softap" ap_ssid = "myssid" ap_password = "******" softap_endpoint = ip.split('.')[0] + "." + ip.split( '.')[1] + "." + ip.split('.')[2] + ".1:80" print("Getting security") security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError("Failed to get security") print("Getting transport") transport = esp_prov.get_transport(provmode, softap_endpoint) if transport is None: raise RuntimeError("Failed to get transport") print("Verifying protocol version") if not esp_prov.version_match(transport, protover): raise RuntimeError("Mismatch in protocol version") print("Starting Session") if not esp_prov.establish_session(transport, security): raise RuntimeError("Failed to start session") print("Sending Wifi credential to DUT") if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError("Failed to send Wi-Fi config") print("Applying config") if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError("Failed to send apply config") success = False while True: time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) if (ret == 1): continue elif (ret == 0): print("Provisioning was successful") success = True break if not success: raise RuntimeError("Provisioning failed")
def test_examples_provisioning_ble(env, extra_data): # Acquire DUT dut1 = env.get_dut("ble_prov", "examples/provisioning/ble_prov") # Get binary file binary_file = os.path.join(dut1.app.binary_path, "ble_prov.bin") bin_size = os.path.getsize(binary_file) IDF.log_performance("ble_prov_bin_size", "{}KB".format(bin_size // 1024)) IDF.check_performance("ble_prov_bin_size", bin_size // 1024) # Upload binary and start testing dut1.start_app() # Parse BLE devname devname = dut1.expect(re.compile(r"Provisioning started with BLE devname : '(PROV_\S\S\S\S\S\S)'"), timeout=60)[0] print("BLE Device Alias for DUT :", devname) # Match additional headers sent in the request dut1.expect("BLE Provisioning started", timeout=30) print("Starting Provisioning") verbose = False protover = "V0.1" secver = 1 pop = "abcd1234" provmode = "ble" ap_ssid = "myssid" ap_password = "******" print("Getting security") security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError("Failed to get security") print("Getting transport") transport = esp_prov.get_transport(provmode, None, devname) if transport is None: raise RuntimeError("Failed to get transport") print("Verifying protocol version") if not esp_prov.version_match(transport, protover): raise RuntimeError("Mismatch in protocol version") print("Starting Session") if not esp_prov.establish_session(transport, security): raise RuntimeError("Failed to start session") print("Sending Wifi credential to DUT") if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError("Failed to send Wi-Fi config") print("Applying config") if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError("Failed to send apply config") success = False while True: time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) if (ret == 1): continue elif (ret == 0): print("Provisioning was successful") success = True break if not success: raise RuntimeError("Provisioning failed")
def test_examples_provisioning_softap(env, extra_data): # Acquire DUT dut1 = env.get_dut("softap_prov", "examples/provisioning/softap_prov") # Get binary file binary_file = os.path.join(dut1.app.binary_path, "softap_prov.bin") bin_size = os.path.getsize(binary_file) IDF.log_performance("softap_prov_bin_size", "{}KB".format(bin_size // 1024)) IDF.check_performance("softap_prov_bin_size", bin_size // 1024) # Upload binary and start testing dut1.start_app() # Parse IP address of STA dut1.expect("Starting WiFi SoftAP provisioning", timeout=60) dut1.expect("SoftAP started", timeout=30) [ssid, password] = dut1.expect(re.compile(r"SoftAP Provisioning started with SSID '(\S+)', Password '(\S+)'"), timeout=30) iface = wifi_tools.get_wiface_name() if iface is None: raise RuntimeError("Failed to get Wi-Fi interface on host") print("Interface name : " + iface) print("SoftAP SSID : " + ssid) print("SoftAP Password : "******"Connecting to DUT SoftAP...") ip = ctrl.connect(ssid, password) got_ip = dut1.expect(re.compile(r"softAP assign IP to station,IP is: (\d+.\d+.\d+.\d+)"), timeout=30)[0] if ip != got_ip: raise RuntimeError("SoftAP connected to another host! " + ip + "!=" + got_ip) print("Connected to DUT SoftAP") print("Starting Provisioning") verbose = False protover = "V0.1" secver = 1 pop = "abcd1234" provmode = "softap" ap_ssid = "myssid" ap_password = "******" softap_endpoint = ip.split('.')[0] + "." + ip.split('.')[1] + "." + ip.split('.')[2] + ".1:80" print("Getting security") security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError("Failed to get security") print("Getting transport") transport = esp_prov.get_transport(provmode, softap_endpoint, None) if transport is None: raise RuntimeError("Failed to get transport") print("Verifying protocol version") if not esp_prov.version_match(transport, protover): raise RuntimeError("Mismatch in protocol version") print("Starting Session") if not esp_prov.establish_session(transport, security): raise RuntimeError("Failed to start session") print("Sending Wifi credential to DUT") if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError("Failed to send Wi-Fi config") print("Applying config") if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError("Failed to send apply config") success = False while True: time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) if (ret == 1): continue elif (ret == 0): print("Provisioning was successful") success = True break if not success: raise RuntimeError("Provisioning failed")
def test_examples_provisioning_ble(env, extra_data): # Acquire DUT dut1 = env.get_dut('ble_prov', 'examples/provisioning/legacy/ble_prov', dut_class=ttfw_idf.ESP32DUT) # Get binary file binary_file = os.path.join(dut1.app.binary_path, 'ble_prov.bin') bin_size = os.path.getsize(binary_file) ttfw_idf.log_performance('ble_prov_bin_size', '{}KB'.format(bin_size // 1024)) # Upload binary and start testing dut1.start_app() # Parse BLE devname devname = dut1.expect(re.compile( r"Provisioning started with BLE devname : '(PROV_\S\S\S\S\S\S)'"), timeout=60)[0] print('BLE Device Alias for DUT :', devname) # Match additional headers sent in the request dut1.expect('BLE Provisioning started', timeout=30) print('Starting Provisioning') verbose = False protover = 'V0.1' secver = 1 pop = 'abcd1234' provmode = 'ble' ap_ssid = 'myssid' ap_password = '******' print('Getting security') security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError('Failed to get security') print('Getting transport') transport = esp_prov.get_transport(provmode, devname) if transport is None: raise RuntimeError('Failed to get transport') print('Verifying protocol version') if not esp_prov.version_match(transport, protover): raise RuntimeError('Mismatch in protocol version') print('Starting Session') if not esp_prov.establish_session(transport, security): raise RuntimeError('Failed to start session') print('Sending Wifi credential to DUT') if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError('Failed to send Wi-Fi config') print('Applying config') if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError('Failed to send apply config') if not esp_prov.wait_wifi_connected(transport, security): raise RuntimeError('Provisioning failed')
def test_examples_wifi_prov_mgr(env, extra_data): # Acquire DUT dut1 = env.get_dut('wifi_prov_mgr', 'examples/provisioning/wifi_prov_mgr', dut_class=ttfw_idf.ESP32DUT) # Get binary file binary_file = os.path.join(dut1.app.binary_path, 'wifi_prov_mgr.bin') bin_size = os.path.getsize(binary_file) ttfw_idf.log_performance('wifi_prov_mgr_bin_size', '{}KB'.format(bin_size // 1024)) # Upload binary and start testing dut1.start_app() # Check if BT memory is released before provisioning starts dut1.expect('wifi_prov_scheme_ble: BT memory released', timeout=60) # Parse BLE devname devname = dut1.expect(re.compile(r'Provisioning started with service name : (PROV_\S\S\S\S\S\S)'), timeout=30)[0] print('BLE Device Alias for DUT :', devname) print('Starting Provisioning') verbose = False protover = 'v1.1' secver = 1 pop = 'abcd1234' provmode = 'ble' ap_ssid = 'myssid' ap_password = '******' print('Getting security') security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError('Failed to get security') print('Getting transport') transport = esp_prov.get_transport(provmode, devname) if transport is None: raise RuntimeError('Failed to get transport') print('Verifying protocol version') if not esp_prov.version_match(transport, protover): raise RuntimeError('Mismatch in protocol version') print('Verifying scan list capability') if not esp_prov.has_capability(transport, 'wifi_scan'): raise RuntimeError('Capability not present') print('Starting Session') if not esp_prov.establish_session(transport, security): raise RuntimeError('Failed to start session') print('Sending Custom Data') if not esp_prov.custom_data(transport, security, 'My Custom Data'): raise RuntimeError('Failed to send custom data') print('Sending Wifi credential to DUT') if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError('Failed to send Wi-Fi config') print('Applying config') if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError('Failed to send apply config') if not esp_prov.wait_wifi_connected(transport, security): raise RuntimeError('Provisioning failed') # Check if BTDM memory is released after provisioning finishes dut1.expect('wifi_prov_scheme_ble: BTDM memory released', timeout=30)
def test_examples_provisioning_softap(env, extra_data): # Acquire DUT dut1 = env.get_dut('softap_prov', 'examples/provisioning/legacy/softap_prov', dut_class=ttfw_idf.ESP32DUT) # Get binary file binary_file = os.path.join(dut1.app.binary_path, 'softap_prov.bin') bin_size = os.path.getsize(binary_file) ttfw_idf.log_performance('softap_prov_bin_size', '{}KB'.format(bin_size // 1024)) # Upload binary and start testing dut1.start_app() # Parse IP address of STA dut1.expect('Starting WiFi SoftAP provisioning', timeout=60) [ssid, password] = dut1.expect(re.compile( r"SoftAP Provisioning started with SSID '(\S+)', Password '(\S+)'"), timeout=30) iface = wifi_tools.get_wiface_name() if iface is None: raise RuntimeError('Failed to get Wi-Fi interface on host') print('Interface name : ' + iface) print('SoftAP SSID : ' + ssid) print('SoftAP Password : '******'Connecting to DUT SoftAP...') try: ip = ctrl.connect(ssid, password) except RuntimeError as err: Utility.console_log('error: {}'.format(err)) try: got_ip = dut1.expect(re.compile( r'DHCP server assigned IP to a station, IP is: (\d+.\d+.\d+.\d+)' ), timeout=60) Utility.console_log('got_ip: {}'.format(got_ip)) got_ip = got_ip[0] if ip != got_ip: raise RuntimeError( 'SoftAP connected to another host! {} != {}'.format( ip, got_ip)) except tiny_test_fw.DUT.ExpectTimeout: # print what is happening on dut side Utility.console_log('in exception tiny_test_fw.DUT.ExpectTimeout') Utility.console_log(dut1.read()) raise print('Connected to DUT SoftAP') print('Starting Provisioning') verbose = False protover = 'V0.1' secver = 1 pop = 'abcd1234' provmode = 'softap' ap_ssid = 'myssid' ap_password = '******' softap_endpoint = '{}.{}.{}.1:80'.format( ip.split('.')[0], ip.split('.')[1], ip.split('.')[2]) print('Getting security') security = esp_prov.get_security(secver, pop, verbose) if security is None: raise RuntimeError('Failed to get security') print('Getting transport') transport = esp_prov.get_transport(provmode, softap_endpoint) if transport is None: raise RuntimeError('Failed to get transport') print('Verifying protocol version') if not esp_prov.version_match(transport, protover): raise RuntimeError('Mismatch in protocol version') print('Starting Session') if not esp_prov.establish_session(transport, security): raise RuntimeError('Failed to start session') print('Sending Wifi credential to DUT') if not esp_prov.send_wifi_config(transport, security, ap_ssid, ap_password): raise RuntimeError('Failed to send Wi-Fi config') print('Applying config') if not esp_prov.apply_wifi_config(transport, security): raise RuntimeError('Failed to send apply config') if not esp_prov.wait_wifi_connected(transport, security): raise RuntimeError('Provisioning failed') finally: ctrl.reset()