From 3a9762ce573f6d23cd9af37582fc70b6e8881d44 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Tue, 25 Apr 2023 15:58:06 +0530 Subject: [PATCH] Nimble: Removed files referring to old TTFW framework --- .../bluetooth/nimble/blecent/blecent_test.py | 140 --------------- examples/bluetooth/nimble/blehr/blehr_test.py | 169 ------------------ .../bluetooth/nimble/bleprph/bleprph_test.py | 160 ----------------- 3 files changed, 469 deletions(-) delete mode 100644 examples/bluetooth/nimble/blecent/blecent_test.py delete mode 100644 examples/bluetooth/nimble/blehr/blehr_test.py delete mode 100644 examples/bluetooth/nimble/bleprph/bleprph_test.py diff --git a/examples/bluetooth/nimble/blecent/blecent_test.py b/examples/bluetooth/nimble/blecent/blecent_test.py deleted file mode 100644 index 2e09579b52..0000000000 --- a/examples/bluetooth/nimble/blecent/blecent_test.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2019 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import print_function - -import os -import subprocess -import threading -import traceback - -try: - import Queue -except ImportError: - import queue as Queue - -import ttfw_idf -from ble import lib_ble_client -from tiny_test_fw import Utility - -# When running on local machine execute the following before running this script -# > make app bootloader -# > make print_flash_cmd | tail -n 1 > build/download.config - - -def blecent_client_task(dut): - interface = 'hci0' - adv_host_name = 'BleCentTestApp' - adv_type = 'peripheral' - adv_uuid = '1811' - - # Get BLE client module - ble_client_obj = lib_ble_client.BLE_Bluez_Client(iface=interface) - - # Discover Bluetooth Adapter and power on - is_adapter_set = ble_client_obj.set_adapter() - if not is_adapter_set: - return - - ''' - Blecent application run: - Create GATT data - Register GATT Application - Create Advertising data - Register advertisement - Start advertising - ''' - # Create Gatt Application - # Register GATT Application - ble_client_obj.register_gatt_app() - - # Register Advertisement - # Check read/write/subscribe is received from device - ble_client_obj.register_adv(adv_host_name, adv_type, adv_uuid) - - # Check dut responses - dut.expect('Connection established', timeout=30) - dut.expect('Service discovery complete; status=0', timeout=30) - dut.expect('GATT procedure initiated: read;', timeout=30) - dut.expect('Read complete; status=0', timeout=30) - dut.expect('GATT procedure initiated: write;', timeout=30) - dut.expect('Write complete; status=0', timeout=30) - dut.expect('GATT procedure initiated: write;', timeout=30) - dut.expect('Subscribe complete; status=0', timeout=30) - dut.expect('received notification;', timeout=30) - - -class BleCentThread(threading.Thread): - def __init__(self, dut, exceptions_queue): - threading.Thread.__init__(self) - self.dut = dut - self.exceptions_queue = exceptions_queue - - def run(self): - try: - blecent_client_task(self.dut) - except RuntimeError: - self.exceptions_queue.put(traceback.format_exc(), block=False) - - -@ttfw_idf.idf_example_test(env_tag='Example_WIFI_BT') -def test_example_app_ble_central(env, extra_data): - """ - Steps: - 1. Discover Bluetooth Adapter and Power On - 2. Connect BLE Device - 3. Start Notifications - 4. Updated value is retrieved - 5. Stop Notifications - """ - # Remove cached bluetooth devices of any previous connections - subprocess.check_output(['rm', '-rf', '/var/lib/bluetooth/*']) - subprocess.check_output(['hciconfig', 'hci0', 'reset']) - - # Acquire DUT - dut = env.get_dut('blecent', 'examples/bluetooth/nimble/blecent', dut_class=ttfw_idf.ESP32DUT) - - # Get binary file - binary_file = os.path.join(dut.app.binary_path, 'blecent.bin') - bin_size = os.path.getsize(binary_file) - ttfw_idf.log_performance('blecent_bin_size', '{}KB'.format(bin_size // 1024)) - - # Upload binary and start testing - Utility.console_log('Starting blecent example test app') - dut.start_app() - dut.reset() - - exceptions_queue = Queue.Queue() - # Starting a py-client in a separate thread - blehr_thread_obj = BleCentThread(dut, exceptions_queue) - blehr_thread_obj.start() - blehr_thread_obj.join() - - exception_msg = None - while True: - try: - exception_msg = exceptions_queue.get(block=False) - except Queue.Empty: - break - else: - Utility.console_log('\n' + exception_msg) - - if exception_msg: - raise Exception('Blecent thread did not run successfully') - - -if __name__ == '__main__': - test_example_app_ble_central() diff --git a/examples/bluetooth/nimble/blehr/blehr_test.py b/examples/bluetooth/nimble/blehr/blehr_test.py deleted file mode 100644 index 41c36fcf00..0000000000 --- a/examples/bluetooth/nimble/blehr/blehr_test.py +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2019 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import print_function - -import os -import re -import subprocess -import threading -import traceback - -try: - import Queue -except ImportError: - import queue as Queue - -import ttfw_idf -from ble import lib_ble_client -from tiny_test_fw import Utility - -# When running on local machine execute the following before running this script -# > make app bootloader -# > make print_flash_cmd | tail -n 1 > build/download.config - - -def blehr_client_task(hr_obj, dut, dut_addr): - interface = 'hci0' - ble_devname = 'blehr_sensor_1.0' - hr_srv_uuid = '180d' - hr_char_uuid = '2a37' - - # Get BLE client module - ble_client_obj = lib_ble_client.BLE_Bluez_Client(iface=interface) - - # Discover Bluetooth Adapter and power on - is_adapter_set = ble_client_obj.set_adapter() - if not is_adapter_set: - return - - # Connect BLE Device - is_connected = ble_client_obj.connect( - devname=ble_devname, - devaddr=dut_addr) - if not is_connected: - return - - # Get services of the connected device - services = ble_client_obj.get_services() - if not services: - ble_client_obj.disconnect() - return - - # Get characteristics of the connected device - ble_client_obj.get_chars() - - ''' - Blehr application run: - Start Notifications - Retrieve updated value - Stop Notifications - ''' - # Get service if exists - service = ble_client_obj.get_service_if_exists(hr_srv_uuid) - if service: - # Get characteristic if exists - char = ble_client_obj.get_char_if_exists(hr_char_uuid) - if not char: - ble_client_obj.disconnect() - return - else: - ble_client_obj.disconnect() - return - - # Start Notify - # Read updated value - # Stop Notify - notify = ble_client_obj.start_notify(char) - if not notify: - ble_client_obj.disconnect() - return - - # Check dut responses - dut.expect('subscribe event; cur_notify=1', timeout=30) - dut.expect('subscribe event; cur_notify=0', timeout=30) - - # Call disconnect to perform cleanup operations before exiting application - ble_client_obj.disconnect() - - # Check dut responses - dut.expect('disconnect;', timeout=30) - - -class BleHRThread(threading.Thread): - def __init__(self, dut, dut_addr, exceptions_queue): - threading.Thread.__init__(self) - self.dut = dut - self.dut_addr = dut_addr - self.exceptions_queue = exceptions_queue - - def run(self): - try: - blehr_client_task(self, self.dut, self.dut_addr) - except RuntimeError: - self.exceptions_queue.put(traceback.format_exc(), block=False) - - -@ttfw_idf.idf_example_test(env_tag='Example_WIFI_BT') -def test_example_app_ble_hr(env, extra_data): - """ - Steps: - 1. Discover Bluetooth Adapter and Power On - 2. Connect BLE Device - 3. Start Notifications - 4. Updated value is retrieved - 5. Stop Notifications - """ - # Remove cached bluetooth devices of any previous connections - subprocess.check_output(['rm', '-rf', '/var/lib/bluetooth/*']) - subprocess.check_output(['hciconfig', 'hci0', 'reset']) - - # Acquire DUT - dut = env.get_dut('blehr', 'examples/bluetooth/nimble/blehr', dut_class=ttfw_idf.ESP32DUT) - - # Get binary file - binary_file = os.path.join(dut.app.binary_path, 'blehr.bin') - bin_size = os.path.getsize(binary_file) - ttfw_idf.log_performance('blehr_bin_size', '{}KB'.format(bin_size // 1024)) - - # Upload binary and start testing - Utility.console_log('Starting blehr simple example test app') - dut.start_app() - dut.reset() - - # Get device address from dut - dut_addr = dut.expect(re.compile(r'Device Address: ([a-fA-F0-9:]+)'), timeout=30)[0] - exceptions_queue = Queue.Queue() - # Starting a py-client in a separate thread - blehr_thread_obj = BleHRThread(dut, dut_addr, exceptions_queue) - blehr_thread_obj.start() - blehr_thread_obj.join() - - exception_msg = None - while True: - try: - exception_msg = exceptions_queue.get(block=False) - except Queue.Empty: - break - else: - Utility.console_log('\n' + exception_msg) - - if exception_msg: - raise Exception('Blehr thread did not run successfully') - - -if __name__ == '__main__': - test_example_app_ble_hr() diff --git a/examples/bluetooth/nimble/bleprph/bleprph_test.py b/examples/bluetooth/nimble/bleprph/bleprph_test.py deleted file mode 100644 index 978c1d004a..0000000000 --- a/examples/bluetooth/nimble/bleprph/bleprph_test.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2019 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import print_function - -import os -import re -import subprocess -import threading -import traceback - -try: - import Queue -except ImportError: - import queue as Queue - -import ttfw_idf -from ble import lib_ble_client -from tiny_test_fw import Utility - -# When running on local machine execute the following before running this script -# > make app bootloader -# > make print_flash_cmd | tail -n 1 > build/download.config -# > export TEST_FW_PATH=~/esp/esp-idf/tools/tiny-test-fw - - -def bleprph_client_task(dut, dut_addr): - interface = 'hci0' - ble_devname = 'nimble-bleprph' - srv_uuid = '2f12' - write_value = b'A' - - # Get BLE client module - ble_client_obj = lib_ble_client.BLE_Bluez_Client(iface=interface) - - # Discover Bluetooth Adapter and power on - is_adapter_set = ble_client_obj.set_adapter() - if not is_adapter_set: - return - - # Connect BLE Device - is_connected = ble_client_obj.connect( - devname=ble_devname, - devaddr=dut_addr) - if not is_connected: - return - - # Get services of the connected device - services = ble_client_obj.get_services() - if not services: - ble_client_obj.disconnect() - return - # Verify service uuid exists - service_exists = ble_client_obj.get_service_if_exists(srv_uuid) - if not service_exists: - ble_client_obj.disconnect() - return - - # Get characteristics of the connected device - ble_client_obj.get_chars() - - # Read properties of characteristics (uuid, value and permissions) - ble_client_obj.read_chars() - - # Write new value to characteristic having read and write permission - # and display updated value - write_char = ble_client_obj.write_chars(write_value) - if not write_char: - ble_client_obj.disconnect() - return - - # Disconnect device - ble_client_obj.disconnect() - - # Check dut responses - dut.expect('connection established; status=0', timeout=30) - dut.expect('disconnect;', timeout=30) - - -class BlePrphThread(threading.Thread): - def __init__(self, dut, dut_addr, exceptions_queue): - threading.Thread.__init__(self) - self.dut = dut - self.dut_addr = dut_addr - self.exceptions_queue = exceptions_queue - - def run(self): - try: - bleprph_client_task(self.dut, self.dut_addr) - except RuntimeError: - self.exceptions_queue.put(traceback.format_exc(), block=False) - - -@ttfw_idf.idf_example_test(env_tag='Example_WIFI_BT') -def test_example_app_ble_peripheral(env, extra_data): - """ - Steps: - 1. Discover Bluetooth Adapter and Power On - 2. Connect BLE Device - 3. Read Services - 4. Read Characteristics - 5. Write Characteristics - """ - # Remove cached bluetooth devices of any previous connections - subprocess.check_output(['rm', '-rf', '/var/lib/bluetooth/*']) - subprocess.check_output(['hciconfig', 'hci0', 'reset']) - - # Acquire DUT - dut = env.get_dut('bleprph', 'examples/bluetooth/nimble/bleprph', dut_class=ttfw_idf.ESP32DUT) - - # Get binary file - binary_file = os.path.join(dut.app.binary_path, 'bleprph.bin') - bin_size = os.path.getsize(binary_file) - ttfw_idf.log_performance('bleprph_bin_size', '{}KB'.format(bin_size // 1024)) - - # Upload binary and start testing - Utility.console_log('Starting bleprph simple example test app') - dut.start_app() - dut.reset() - - # Get device address from dut - dut_addr = dut.expect(re.compile(r'Device Address: ([a-fA-F0-9:]+)'), timeout=30)[0] - - # Check dut responses - dut.expect('GAP procedure initiated: advertise;', timeout=30) - - # Starting a py-client in a separate thread - exceptions_queue = Queue.Queue() - bleprph_thread_obj = BlePrphThread(dut, dut_addr, exceptions_queue) - bleprph_thread_obj.start() - bleprph_thread_obj.join() - - exception_msg = None - while True: - try: - exception_msg = exceptions_queue.get(block=False) - except Queue.Empty: - break - else: - Utility.console_log('\n' + exception_msg) - - if exception_msg: - raise Exception('BlePrph thread did not run successfully') - - -if __name__ == '__main__': - test_example_app_ble_peripheral()