### Run Blatann Examples from Command Line Source: https://blatann.readthedocs.io/en/latest/getting_started.html Execute Blatann examples by specifying the example name and the communication port. This is useful for testing and demonstrating library functionality. ```shell python -m blatann.examples ``` -------------------------------- ### Configuring and Starting Advertising Source: https://blatann.readthedocs.io/en/latest/core_classes.html Configure advertising data using AdvertisingData objects and start the advertiser with a specified interval. ```Python from blatann.gap.advertising import AdvertisingData adv_data = AdvertisingData(flags=0x06, local_name="My Name") scan_data = AdvertisingData(service_uuid16s="123F") ble_device.advertiser.set_advertise_data(adv_data, scan_data) ble_device.advertiser.start(adv_interval_ms=50) ``` -------------------------------- ### Run Scanner Example for Smoke Test Source: https://blatann.readthedocs.io/en/latest/getting_started.html Execute the 'scanner' example to perform a smoke test of your Blatann setup. This example streams advertising packets for approximately 4 seconds. ```shell python -m blatann.examples scanner ``` -------------------------------- ### blatann.examples.example_utils module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Utility functions for Blatann examples. ```APIDOC ## Module: blatann.examples.example_utils ### Description This module provides helper functions commonly used across various Blatann examples. ### Functions - `find_target_device(name)`: Finds a Bluetooth device by its name (synchronous). - `find_target_device_async(name)`: Finds a Bluetooth device by its name (asynchronous). ``` -------------------------------- ### blatann.examples.peripheral_uart_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral with a UART Service. ```APIDOC ## Module: blatann.examples.peripheral_uart_service ### Description This module implements a peripheral that exposes a UART Service for serial communication. ### Functions - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `on_mtu_size_update(mtu)`: Callback for MTU size updates. - `on_data_rx(data)`: Callback for receiving data. - `on_tx_complete()`: Callback executed when data transmission is complete. - `main()`: Main function to run the peripheral UART service example. ``` -------------------------------- ### blatann.examples.peripheral module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral device implementation. ```APIDOC ## Module: blatann.examples.peripheral ### Description This module implements a Bluetooth Low Energy peripheral with various services and characteristics. ### Classes - `CountingCharacteristicThread`: - `CountingCharacteristicThread.join()`: Waits for the counting thread to complete. - `CountingCharacteristicThread.run()`: The main execution method for the counting thread. ### Functions - `on_connect()`: Callback executed when a central device connects. - `on_disconnect()`: Callback executed when a central device disconnects. - `on_hex_conversion_characteristic_write(data)`: Handles writes to the hex conversion characteristic. - `on_gatts_subscription_state_changed(ccc)`: Callback for GATT server subscription state changes. - `on_time_char_read()`: Handles read requests for the time characteristic. - `on_discovery_complete()`: Callback executed when service discovery is complete. - `on_security_level_changed(level)`: Callback for security level changes. - `on_client_pairing_complete()`: Callback executed after client pairing is complete. - `on_passkey_display(passkey)`: Displays the passkey for pairing. - `on_passkey_entry()`: Callback for handling passkey entry during pairing. - `on_conn_params_updated()`: Callback for connection parameter updates. - `main()`: Main function to run the peripheral example. ``` -------------------------------- ### blatann.examples.peripheral_device_info_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral with a Device Information Service. ```APIDOC ## Module: blatann.examples.peripheral_device_info_service ### Description This module implements a peripheral that exposes a Device Information Service. ### Functions - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `main()`: Main function to run the peripheral device info service example. ``` -------------------------------- ### Main Function for Central Event-Driven Example Source: https://blatann.readthedocs.io/en/latest/blatann.examples.central_event_driven.html The main entry point for the central event-driven example. It takes a serial port argument to initialize the BLE device and orchestrates the overall program flow. ```python def main(_serial_port_): pass ``` -------------------------------- ### Install Blatann using Pip Source: https://blatann.readthedocs.io/en/latest/getting_started.html Install the Blatann library using pip. This is the primary method for adding the library to your Python environment. ```shell pip install blatann ``` -------------------------------- ### blatann.examples.peripheral_battery_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral with a Battery Service. ```APIDOC ## Module: blatann.examples.peripheral_battery_service ### Description This module implements a peripheral that exposes a Battery Service. ### Functions - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `main()`: Main function to run the peripheral battery service example. ``` -------------------------------- ### main Source: https://blatann.readthedocs.io/en/latest/blatann.examples.peripheral_rssi.html Main function to run the peripheral RSSI example. ```APIDOC ## main ### Description Main function to run the peripheral RSSI example. ### Parameters - **serial_port** (string) - Required - The serial port to use for communication ``` -------------------------------- ### blatann.examples.peripheral_rssi module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral reporting RSSI. ```APIDOC ## Module: blatann.examples.peripheral_rssi ### Description This module demonstrates a peripheral that reports its Received Signal Strength Indicator (RSSI). ### Functions - `on_rssi_changed(rssi)`: Callback executed when RSSI changes. - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `main()`: Main function to run the peripheral RSSI example. ``` -------------------------------- ### blatann.examples.central_event_driven module Source: https://blatann.readthedocs.io/en/latest/api_reference.html An event-driven example for a central device. ```APIDOC ## Module: blatann.examples.central_event_driven ### Description This module showcases an event-driven approach for central device operations, including scanning and connecting. ### Classes - `HexConverterTest`: A test class for hex conversion functionality. - `HexConverterTest.start()`: Starts the hex converter test. - `MyPeripheralConnection`: Represents a connection to a peripheral. - `ConnectionManager`: Manages connections to peripherals. - `ConnectionManager.scan_and_connect(name)`: Scans for a device by name and initiates a connection. ### Functions - `main()`: The main entry point for the event-driven central example. ``` -------------------------------- ### blatann.examples.peripheral_glucose_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral with a Glucose Service. ```APIDOC ## Module: blatann.examples.peripheral_glucose_service ### Description This module implements a peripheral that exposes a Glucose Service, including features for security and data simulation. ### Functions - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `on_security_level_changed(level)`: Callback for security level changes. - `display_passkey(passkey)`: Displays the passkey for pairing. - `add_fake_glucose_readings()`: Adds simulated glucose readings. - `main()`: Main function to run the peripheral glucose service example. ``` -------------------------------- ### blatann.examples.peripheral_descriptors module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example of a peripheral with custom descriptors. ```APIDOC ## Module: blatann.examples.peripheral_descriptors ### Description This module demonstrates how to implement a peripheral with custom GATT descriptors. ### Functions - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `on_read()`: Handles read requests for characteristics. - `main()`: Main function to run the peripheral descriptors example. ``` -------------------------------- ### blatann.examples.central_device_info_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example for interacting with a Device Information Service on a central device. ```APIDOC ## Module: blatann.examples.central_device_info_service ### Description This module demonstrates how to retrieve device information from a connected peripheral. ### Functions - `main()`: Main function to run the device information service example. ``` -------------------------------- ### blatann.examples.central_async module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Provides asynchronous central role examples for Bluetooth Low Energy. ```APIDOC ## Module: blatann.examples.central_async ### Description This module demonstrates asynchronous operations for a Bluetooth Low Energy central device. ### Functions - `handle_counting_char()`: Handles counting characteristic operations. - `on_passkey_entry()`: Callback for passkey entry events. - `main()`: Entry point for the asynchronous central example. ``` -------------------------------- ### blatann.examples.central_uart_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example for interacting with a UART Service on a central device. ```APIDOC ## Module: blatann.examples.central_uart_service ### Description This module demonstrates how to use the UART service for serial communication with a peripheral. ### Functions - `on_connect()`: Callback executed upon successful connection. - `on_disconnect()`: Callback executed upon disconnection. - `on_mtu_size_update(mtu)`: Callback for MTU size updates. - `on_data_rx(data)`: Callback for receiving data. - `main()`: Main function to run the UART service example. ``` -------------------------------- ### blatann.examples.central_battery_service module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Example for interacting with a Battery Service on a central device. ```APIDOC ## Module: blatann.examples.central_battery_service ### Description This module shows how to read battery level information from a connected peripheral. ### Functions - `on_battery_level_update(level)`: Callback function that is invoked when the battery level changes. - `main()`: Main function to run the battery service example. ``` -------------------------------- ### DatabaseDiscoverer.start Source: https://blatann.readthedocs.io/en/latest/api_reference.html Starts the database discovery process. This method is part of the DatabaseDiscoverer class. ```APIDOC ## DatabaseDiscoverer.start ### Description Starts the database discovery process. ### Method Not Applicable (Method Call) ### Endpoint Not Applicable (Method Call) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### Starting a Scan and Waiting for Results Source: https://blatann.readthedocs.io/en/latest/core_classes.html Initiate a scan for Bluetooth devices and wait for a specified timeout for scan reports. ```Python scan_report_collection = ble_device.scanner.start_scan().wait(timeout=20) ``` -------------------------------- ### discover_services Source: https://blatann.readthedocs.io/en/latest/blatann.peer.html Starts the database discovery process of the peer, discovering all services, characteristics, and descriptors on the peer’s database. Returns a waitable that triggers upon completion. ```APIDOC ## discover_services ### Description Starts the database discovery process of the peer. This will discover all services, characteristics, and descriptors on the peer’s database. ### Method POST ### Endpoint /discover_services ### Response #### Success Response (200) - **waitable** (EventWaitable) - A waitable that will trigger when service discovery is complete ``` -------------------------------- ### DisClient.get() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets information from the Device Information Service (DIS). ```APIDOC ## DisClient.get() ### Description Gets information from the Device Information Service (DIS). ### Method N/A ### Endpoint N/A ``` -------------------------------- ### GapEvtSecInfoRequest Source: https://blatann.readthedocs.io/en/latest/blatann.nrf.nrf_events.smp_events.html Requests security information about the peer device. This event is part of the security setup process, allowing the local device to obtain necessary details for secure communication. ```APIDOC ## Class: GapEvtSecInfoRequest ### Description Requests security information about the peer device. This event is part of the security setup process, allowing the local device to obtain necessary details for secure communication. ### Parameters * **_conn_handle_**: Connection handle. * **_peer_addr_**: Address of the peer device. * **_master_id_**: Master identification. * **_enc_info_**: Encryption information. * **_id_info_**: Identity information. * **_sign_info_**: Signing information. ``` -------------------------------- ### Synchronous Write Queue Example Source: https://blatann.readthedocs.io/en/latest/blatann.gatt.gatts.html Iterate synchronously over a queue to receive write requests. The iterator continues until the peripheral disconnects. Requires waiting for connection. ```python client.wait_for_connection() for _, event_args in characteristic.write_queue(): print(f"Got write event: {event_args}") print("Peer disconnected") ``` -------------------------------- ### start_rssi_reporting Source: https://blatann.readthedocs.io/en/latest/blatann.peer.html Starts collecting RSSI readings for the connection. An optional threshold can be set to trigger events on significant changes. ```APIDOC ## start_rssi_reporting ### Description Starts collecting RSSI readings for the connection. ### Method POST ### Endpoint /start_rssi_reporting ### Parameters #### Query Parameters - **threshold_dbm** (Optional[int]) - Minimum change in dBm before triggering an RSSI changed event. The default value `None` disables the RSSI event (RSSI polled via the `rssi` property) - **skip_count** (int) - Number of RSSI samples with a change of threshold_dbm or more before sending a new RSSI update event. Parameter ignored if threshold_dbm is None ### Response #### Success Response (200) - **waitable** (EventWaitable) - A waitable that will trigger when the RSSI reading process completes ``` -------------------------------- ### Advertiser Methods Source: https://blatann.readthedocs.io/en/latest/api_reference.html Methods for controlling Bluetooth advertising, including starting, stopping, and configuring advertising parameters. ```APIDOC ## Advertiser Methods ### Description Methods for controlling Bluetooth advertising, including starting, stopping, and configuring advertising parameters. ### Constants * `Advertiser.ADVERTISE_FOREVER` ### Methods * `Advertiser.on_advertising_timeout` * `Advertiser.is_advertising` * `Advertiser.min_interval_ms` * `Advertiser.max_interval_ms` * `Advertiser.auto_restart` * `Advertiser.set_channel_mask()` * `Advertiser.set_advertise_data()` * `Advertiser.set_default_advertise_params()` * `Advertiser.start()` * `Advertiser.stop()` ``` -------------------------------- ### Asynchronous Write Queue Example Source: https://blatann.readthedocs.io/en/latest/blatann.gatt.gatts.html Iterate asynchronously over a queue to receive write requests. The iterator continues until the peripheral disconnects. Requires waiting for connection. ```python await client.wait_for_connection_async() async for _, event_args in characteristic.write_queue_async(): print(f"Got write event: {event_args}") print("Peer disconnected") ``` -------------------------------- ### blatann.utils.setup_logger Source: https://blatann.readthedocs.io/en/latest/blatann.utils.html Sets up a logger with a specified name and logging level. ```APIDOC ## blatann.utils.setup_logger ### Description Sets up a logger with a specified name and logging level. ### Method N/A (Function) ### Parameters * **_name** (string) - Optional - The name of the logger. * **_level** (string) - Optional - The logging level (default is 'DEBUG'). ``` -------------------------------- ### find_target_device_async Source: https://blatann.readthedocs.io/en/latest/blatann.examples.example_utils.html Asynchronously starts scanning for BLE devices and searches for a specific device name in the advertising reports. If the device is found, its address is returned for connection. ```APIDOC ## find_target_device_async ### Description Asynchronously starts the scanner and searches the advertising report for the desired name. If found, returns the peer’s address that can be connected to. ### Method Not specified (likely asynchronous SDK call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **ble_device** (`BleDevice`) – The ble device to operate on * **name** (`str`) – The device’s local name that is advertised ### Response #### Success Response Returns the peer’s address if found, or None if not found. #### Response Example None specified ``` -------------------------------- ### blatann.examples.peripheral_async module Source: https://blatann.readthedocs.io/en/latest/api_reference.html Asynchronous peripheral device implementation. ```APIDOC ## Module: blatann.examples.peripheral_async ### Description This module provides an asynchronous implementation of a Bluetooth Low Energy peripheral. ### Functions - `on_connect()`: Callback executed upon connection. - `on_disconnect()`: Callback executed upon disconnection. - `handle_hex_conversion_characteristic()`: Handles the hex conversion characteristic. - `on_time_char_read()`: Handles read requests for the time characteristic. - `handle_counting_characteristic()`: Handles the counting characteristic. - `on_passkey_display(passkey)`: Displays the passkey for pairing. - `on_passkey_entry()`: Callback for handling passkey entry during pairing. - `main()`: Main function to run the asynchronous peripheral example. ``` -------------------------------- ### DisClient.get_regulatory_certifications() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Regulatory Certifications from the Device Information Service. ```APIDOC ## DisClient.get_regulatory_certifications() ### Description Gets the Regulatory Certifications from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DatabaseDiscoverer.start() Source: https://blatann.readthedocs.io/en/latest/blatann.gatt.service_discovery.html Initiates the service discovery process on a connected BLE device. This method should be called after the DatabaseDiscoverer has been initialized with the target device and peer information. ```APIDOC ## start() ### Description Initiates the service discovery process on a connected BLE device. ### Method N/A (Method of DatabaseDiscoverer class) ### Parameters None ### Request Example ```python discoverer.start() ``` ### Response None (This method initiates an asynchronous process) ### Event - **on_discovery_complete**: Event[blatann.peer.Peripheral, DatabaseDiscoveryCompleteEventArgs] - This event is triggered when the discovery process is completed. ``` -------------------------------- ### DisClient.get_manufacturer_name() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Manufacturer Name from the Device Information Service. ```APIDOC ## DisClient.get_manufacturer_name() ### Description Gets the Manufacturer Name from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DisClient.get_software_revision() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Software Revision from the Device Information Service. ```APIDOC ## DisClient.get_software_revision() ### Description Gets the Software Revision from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DisClient.get_hardware_revision() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Hardware Revision from the Device Information Service. ```APIDOC ## DisClient.get_hardware_revision() ### Description Gets the Hardware Revision from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DisClient.get_firmware_revision() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Firmware Revision from the Device Information Service. ```APIDOC ## DisClient.get_firmware_revision() ### Description Gets the Firmware Revision from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DisClient.get_serial_number() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Serial Number from the Device Information Service. ```APIDOC ## DisClient.get_serial_number() ### Description Gets the Serial Number from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DisClient.get_model_number() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the Model Number from the Device Information Service. ```APIDOC ## DisClient.get_model_number() ### Description Gets the Model Number from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### DisClient.get_system_id() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Gets the System ID from the Device Information Service. ```APIDOC ## DisClient.get_system_id() ### Description Gets the System ID from the Device Information Service. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### Instantiating and Opening BleDevice Source: https://blatann.readthedocs.io/en/latest/core_classes.html Instantiate a BleDevice object with the specified serial port and then configure and open the connection to the device. ```Python from blatann import BleDevice ble_device = BleDevice("COM1") ble_device.configure() ble_device.open() # Ready to use ``` -------------------------------- ### GattcEvtHvx.from_c Source: https://blatann.readthedocs.io/en/latest/api_reference.html Creates a GattcEvtHvx object from C-style data. This method is part of the GattcEvtHvx class. ```APIDOC ## GattcEvtHvx.from_c ### Description Creates a GattcEvtHvx object from C-style data. ### Method Not Applicable (Static Method) ### Endpoint Not Applicable (Static Method) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### configure Source: https://blatann.readthedocs.io/en/latest/blatann.device.html Configures the BLE Device with the given settings. This method must be called before opening the device. ```APIDOC ## configure ### Description Configures the BLE Device with the given settings. Note Configuration must be set before opening the device ### Parameters #### Parameters - **vendor_specific_uuid_count** (int) - The Nordic hardware limits number of 128-bit Base UUIDs that the device can know about. This normally equals the number of custom services that are to be supported, since characteristic UUIDs are usually derived from the service base UUID. - **service_changed** (bool) - Whether the Service Changed characteristic is exposed in the GAP service - **max_connected_peripherals** (int) - The maximum number of concurrent connections with peripheral devices - **max_connected_clients** (int) - The maximum number of concurrent connections with client devices (NOTE: blatann currently only supports 1) - **max_secured_peripherals** (int) - The maximum number of concurrent peripheral connections that will need security (bonding/pairing) enabled - **attribute_table_size** (int) - The maximum size of the attribute table. Increase this number if there’s a lot of services/characteristics in your GATT database. - **att_mtu_max_size** (int) - The maximum ATT MTU size supported. The default supports an MTU which will fit into a single transmission if Data Length Extensions is set to its max (251) - **event_length** (int) - The number of 1.25ms event cycles to dedicate for each connection. The default value (6, =7.5ms) will support the max DLE length of 251 bytes. Minimum value is 2, typical values are 3-8 depending on desired throughput and number of concurrent connections ``` -------------------------------- ### NordicUartClient Methods Source: https://blatann.readthedocs.io/en/latest/api_reference.html Provides documentation for the NordicUartClient class, including methods for initialization, writing data, and checking status. ```APIDOC ## NordicUartClient ### Description Provides methods for interacting with the Nordic UART service, including writing data and checking initialization status. ### Methods * `on_write_complete`: Callback for write completion. * `max_write_length`: Maximum length of data that can be written. * `is_initialized`: Checks if the client is initialized. * `initialize()`: Initializes the Nordic UART client. * `write(data)`: Writes data to the UART service. * `find_in_database()`: Finds the UART service in the database. ``` -------------------------------- ### NrfDriverObserver Methods Source: https://blatann.readthedocs.io/en/latest/api_reference.html Methods for observing events from the nRF driver. ```APIDOC ## NrfDriverObserver Methods ### Description Defines the interface for observers that wish to receive notifications about driver events. ### Methods - `on_driver_event()`: Callback method invoked when a driver event occurs. ``` -------------------------------- ### on_connect Source: https://blatann.readthedocs.io/en/latest/blatann.examples.peripheral_rssi.html Event callback for when a central device connects to us. ```APIDOC ## on_connect ### Description Event callback for when a central device connects to us. ### Parameters - **peer** (_blatann.peer.Client_) - Required - The peer that connected to us - **event_args** - None ``` -------------------------------- ### GattcEvtWriteCmdTxComplete.from_c Source: https://blatann.readthedocs.io/en/latest/api_reference.html Creates a GattcEvtWriteCmdTxComplete object from C-style data. This method is part of the GattcEvtWriteCmdTxComplete class. ```APIDOC ## GattcEvtWriteCmdTxComplete.from_c ### Description Creates a GattcEvtWriteCmdTxComplete object from C-style data. ### Method Not Applicable (Static Method) ### Endpoint Not Applicable (Static Method) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### connect Source: https://blatann.readthedocs.io/en/latest/blatann.device.html Initiates a connection to a peripheral peer. Allows specifying custom connection parameters, preferred MTU size, and preferred PHY layer. The connection outcome can be monitored via the returned Waitable object. ```APIDOC ## connect ### Description Initiates a connection to a peripheral peer with the specified connection parameters, or uses the default connection parameters if not specified. The connection will not be complete until the returned waitable either times out or reports the newly connected peer. ### Method N/A (SDK method) ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **peer_address** (PeerAddress) - Required - The address of the peer to connect to. * **connection_params** (Optional[ConnectionParameters]) - Optional - Connection parameters to use. If not specified, uses the set default. * **preferred_mtu_size** (Optional[int]) - Optional - The preferred MTU size that will be used if the peripheral initiates an MTU exchange. If not provided, uses the values set in `set_default_peripheral_preferred_settings()`. * **preferred_phy** (Optional[Phy]) - Optional - The preferred PHY layer to use for the connection if the peripheral updates the PHY. If not provided, uses the value set in `set_default_peripheral_preferred_settings()`. ### Return Type `PeripheralConnectionWaitable` ### Returns A Waitable which can be used to wait until the connection is successful or times out. Waitable returns a peer.Peripheral object. ``` -------------------------------- ### address Source: https://blatann.readthedocs.io/en/latest/blatann.device.html Gets or sets the MAC address of the BLE device. The address cannot be changed while the device is actively connected or advertising. ```APIDOC ## address ### Description The MAC Address of the BLE device ### Getter Gets the MAC address of the BLE device ### Setter Sets the MAC address for the device to use Note The MAC address cannot be changed while the device is advertising, scanning, or initiating a connection ``` -------------------------------- ### DisServer Methods Source: https://blatann.readthedocs.io/en/latest/blatann.services.device_info.service.html Methods for a server to set device information that can be read by clients. ```APIDOC ## DisServer ### Description Represents a server for the Device Information Service (DIS) GATT service. Allows setting device-specific information. ### Methods #### set_system_id(_system_id_) Sets the System ID characteristic. **Parameters** * **system_id** (SystemID) - The System ID value to set. #### set_model_number(_model_number_, _max_len =None_) Sets the Model Number characteristic. **Parameters** * **model_number** (string) - The model number value to set. * **max_len** (int, optional) - The maximum length for the model number. #### set_serial_number(_serial_number_, _max_len =None_) Sets the Serial Number characteristic. **Parameters** * **serial_number** (string) - The serial number value to set. * **max_len** (int, optional) - The maximum length for the serial number. #### set_firmware_revision(_firmware_revision_, _max_len =None_) Sets the Firmware Revision characteristic. **Parameters** * **firmware_revision** (string) - The firmware revision value to set. * **max_len** (int, optional) - The maximum length for the firmware revision. #### set_hardware_revision(_hardware_revision_, _max_len =None_) Sets the Hardware Revision characteristic. **Parameters** * **hardware_revision** (string) - The hardware revision value to set. * **max_len** (int, optional) - The maximum length for the hardware revision. #### set_software_revision(_software_revision_, _max_len =None_) Sets the Software Revision characteristic. **Parameters** * **software_revision** (string) - The software revision value to set. * **max_len** (int, optional) - The maximum length for the software revision. #### set_manufacturer_name(_manufacturer_name_, _max_len =None_) Sets the Manufacturer Name characteristic. **Parameters** * **manufacturer_name** (string) - The manufacturer name value to set. * **max_len** (int, optional) - The maximum length for the manufacturer name. #### set_regulatory_certifications(_certs_) Sets the Regulatory Certifications characteristic. **Parameters** * **certs** (list) - A list of regulatory certifications. #### set_pnp_id(_pnp_id_) Sets the PNP ID characteristic. **Parameters** * **pnp_id** (PnpID) - The PNP ID value to set. #### _classmethod _add_to_database(_gatts_database_) Adds an instance of DisServer to a GATT server database. **Parameters** * **gatts_database** (_gatts_database_) - The GATT server database to add to. ``` -------------------------------- ### Stopwatch Utility Source: https://blatann.readthedocs.io/en/latest/modules.html Utility class for measuring elapsed time. Provides methods to start, stop, and mark time points. ```APIDOC ## Stopwatch Utility ### Description A utility class for timing operations. It allows starting, stopping, and marking specific points in time to measure durations. ### Methods - `start()`: Starts or resumes the stopwatch. - `stop()`: Stops the stopwatch. - `mark()`: Records a marked time point. ### Properties - `is_running`: Boolean indicating if the stopwatch is currently running. - `start_time`: The timestamp when the stopwatch was started. - `stop_time`: The timestamp when the stopwatch was stopped. - `elapsed`: The total elapsed time measured by the stopwatch. ``` -------------------------------- ### find_target_device Source: https://blatann.readthedocs.io/en/latest/blatann.examples.example_utils.html Starts scanning for BLE devices and searches for a specific device name in the advertising reports. If the device is found, its address is returned for connection. ```APIDOC ## find_target_device ### Description Starts the scanner and searches the advertising report for the desired name. If found, returns the peer’s address that can be connected to. ### Method Not specified (likely synchronous SDK call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **ble_device** (`BleDevice`) – The ble device to operate on * **name** (`str`) – The device’s local name that is advertised ### Response #### Success Response Returns the peer’s address if found, or None if not found. #### Response Example None specified ``` -------------------------------- ### BleDevice.configure() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Configures the Bluetooth Low Energy device. ```APIDOC ## BleDevice.configure() ### Description Configures the Bluetooth Low Energy device. ### Method N/A (Method call) ### Parameters None ### Response None ``` -------------------------------- ### AsyncEventQueue.get Source: https://blatann.readthedocs.io/en/latest/blatann.waitables.event_queue.html Asynchronously gets the next item from the AsyncEventQueue. This method yields control until an event is received. If a disconnect event is signaled, it returns None. ```APIDOC ## AsyncEventQueue.get ### Description Asynchronously gets the next item in the queue. If a disconnect event occurs, the queue will return `None` and not provide any other events afterward. ### Method `_async _get() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response - **Optional[Tuple[TSender, TEvent]]**: The next item in the queue, or None if the disconnect event occurred ``` -------------------------------- ### DefaultBondDatabaseLoader Methods Source: https://blatann.readthedocs.io/en/latest/api_reference.html Methods for loading and migrating bond databases. ```APIDOC ## DefaultBondDatabaseLoader.migrate_to_json() ### Description Migrates the bond database to JSON format. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabaseLoader.load() ### Description Loads data from the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabaseLoader.save() ### Description Saves data to the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ``` -------------------------------- ### EventQueue.get Source: https://blatann.readthedocs.io/en/latest/blatann.waitables.event_queue.html Gets the next item from the EventQueue. This method blocks until an event is received or a timeout occurs. If a disconnect event is signaled, it returns None. ```APIDOC ## EventQueue.get ### Description Gets the next item in the queue. If a disconnect event occurs, the queue will return `None` and not return any other events afterward. ### Method `get(_block =True_, _timeout =None_) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response - **Optional[Tuple[TSender, TEvent]]**: The next item in the queue. ### Raises - `queue.Empty`: if a timeout is provided and no event was received ``` -------------------------------- ### GattcEvtTimeout.from_c Source: https://blatann.readthedocs.io/en/latest/api_reference.html Creates a GattcEvtTimeout object from C-style data. This method is part of the GattcEvtTimeout class. ```APIDOC ## GattcEvtTimeout.from_c ### Description Creates a GattcEvtTimeout object from C-style data. ### Method Not Applicable (Static Method) ### Endpoint Not Applicable (Static Method) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### open Source: https://blatann.readthedocs.io/en/latest/blatann.device.html Opens the connection to the BLE device. This must be called before performing any BLE operations. ```APIDOC ## open ### Description Opens the connection to the BLE device. Must be called prior to performing any BLE operations ### Parameters #### Parameters - **clear_bonding_data** (bool) - Flag that the bonding data should be cleared prior to opening the device. ``` -------------------------------- ### Example 'no_mem' Error Message Source: https://blatann.readthedocs.io/en/latest/troubleshooting.html This error indicates an out-of-memory situation on nRF52 devices. It typically occurs when memory configuration exceeds available RAM. ```text pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_enable. Error code: NrfError.no_mem ``` -------------------------------- ### Initialize GattsDatabase Source: https://blatann.readthedocs.io/en/latest/blatann.gatt.gatts.html Represents the local GATT server on the device. It manages services and characteristics for client interactions. ```python _class _blatann.gatt.gatts.GattsDatabase(_ble_device_ , _peer_ , _notification_hardware_queue_size =1_) ``` -------------------------------- ### MyPeripheralConnection Class for Post-Connection Processes Source: https://blatann.readthedocs.io/en/latest/blatann.examples.central_event_driven.html Handles database discovery and pairing after a BLE device connection. It takes the peer information and a waitable object as arguments. ```python class MyPeripheralConnection(_peer_ , _waitable_): """Class to handle the post-connection database discovery and pairing process""" pass ``` -------------------------------- ### update_connection_parameters Source: https://blatann.readthedocs.io/en/latest/blatann.peer.html Starts the process to re-negotiate the connection parameters using the configured preferred connection parameters. Returns a waitable that triggers when the connection parameters are updated. ```APIDOC ## update_connection_parameters ### Description Starts the process to re-negotiate the connection parameters using the configured preferred connection parameters. ### Method POST ### Endpoint /update_connection_parameters ### Response #### Success Response (200) - **waitable** (EventWaitable) - A waitable that will trigger when the connection parameters are updated ``` -------------------------------- ### Configure Connection MTU and PHY Source: https://blatann.readthedocs.io/en/latest/changelog.html Set preferred MTU size and PHY when connecting as a client, particularly useful if the peripheral initiates these BLE operations first. ```python set_preferred_mtu_size() ``` ```python set_preferred_phy() ``` -------------------------------- ### GapEvtAdvReport Source: https://blatann.readthedocs.io/en/latest/api_reference.html Represents an advertising report event in the GAP layer, including event ID and methods to get device name and create from C representation. ```APIDOC ## GapEvtAdvReport ### Description Represents a GAP advertising report event, which contains information about discovered Bluetooth devices. ### Attributes - `evt_id` (int): The unique identifier for this event type. ### Methods - `get_device_name()`: Retrieves the device name from the advertising data. - `from_c()`: Creates an instance from a C representation. ``` -------------------------------- ### Utility and Configuration Source: https://blatann.readthedocs.io/en/latest/genindex.html Utility functions and configuration methods. ```APIDOC ## ble_gattc_attr_info128_array_to_list() ### Description Converts an array of 128-bit attribute info to a list. ### Method Module function (blatann.nrf.nrf_driver_types) ## ble_gattc_attr_info16_array_to_list() ### Description Converts an array of 16-bit attribute info to a list. ### Method Module function (blatann.nrf.nrf_driver_types) ## ble_gattc_char_array_to_list() ### Description Converts a characteristic array to a list. ### Method Module function (blatann.nrf.nrf_driver_types) ## ble_opt_set() ### Description Sets a generic BLE option. ### Method NrfDriver method ## ble_user_mem_reply() ### Description Replies to a user memory request from the stack. ### Method NrfDriver method ## ble_vs_uuid_add() ### Description Adds a vendor-specific UUID. ### Method NrfDriver method ``` -------------------------------- ### NordicUartServer Methods Source: https://blatann.readthedocs.io/en/latest/api_reference.html Methods for managing the Nordic UART service server, including data handling and writing. ```APIDOC ## NordicUartServer Methods ### Description Provides server-side functionality for the Nordic UART service, handling incoming data and managing write operations. ### Methods - `on_data_received`: Callback function invoked when data is received over the UART service. - `on_write_complete`: Callback function invoked when a write operation to the UART service is completed. - `max_write_length`: Property indicating the maximum length of data that can be written in a single operation. - `write()`: Writes data to the Nordic UART service. - `add_to_database()`: Adds received data to a database. ``` -------------------------------- ### Read RSSI of Active Connection Source: https://blatann.readthedocs.io/en/latest/changelog.html API to retrieve the Received Signal Strength Indicator (RSSI) for an active BLE connection. Example usage is provided in the documentation. ```python Read RSSI of an active connection ``` -------------------------------- ### BatteryServer.add_to_database() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Adds the BatteryServer to the database. ```APIDOC ## BatteryServer.add_to_database() ### Description Adds the BatteryServer to the database. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### GapEvtTimeout.from_c Source: https://blatann.readthedocs.io/en/latest/api_reference.html Creates a GapEvtTimeout object from C-style data. This method is part of the GapEvtTimeout class. ```APIDOC ## GapEvtTimeout.from_c ### Description Creates a GapEvtTimeout object from C-style data. ### Method Not Applicable (Static Method) ### Endpoint Not Applicable (Static Method) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### GattsEvtWrite.from_c Source: https://blatann.readthedocs.io/en/latest/api_reference.html Creates a GattsEvtWrite object from C-style data. This method is part of the GattsEvtWrite class. ```APIDOC ## GattsEvtWrite.from_c ### Description Creates a GattsEvtWrite object from C-style data. ### Method Not Applicable (Static Method) ### Endpoint Not Applicable (Static Method) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### update_data_length Source: https://blatann.readthedocs.io/en/latest/blatann.peer.html Starts the process to update the link layer data length to the optimal value given the MTU. For best results, call this method after the MTU is set to the desired size. ```APIDOC ## update_data_length ### Description Starts the process which updates the link layer data length to the optimal value given the MTU. ### Method POST ### Endpoint /update_data_length ### Parameters #### Query Parameters - **data_length** (Optional[int]) - Optional value to override the data length to. If not provided, uses the optimal value based on the current MTU ### Response #### Success Response (200) - **waitable** (EventWaitable) - A waitable that will trigger when the process finishes ``` -------------------------------- ### Asynchronous Notification Queue Source: https://blatann.readthedocs.io/en/latest/blatann.gatt.gattc.html Use this method to get an asynchronous queue for receiving notifications. The iterator continues until the peripheral disconnects. Ensure you subscribe to the characteristic first using `.as_async()`. ```python await characteristic.subscribe().as_async() async for _, event_args in characteristic.notification_queue_async(): print(f"Got notification: {event_args}") print("Peer disconnected") ``` -------------------------------- ### DefaultBondDatabase Methods Source: https://blatann.readthedocs.io/en/latest/api_reference.html Methods for managing bond database entries. ```APIDOC ## DefaultBondDatabase.create() ### Description Creates a new entry in the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabase.add() ### Description Adds an entry to the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabase.update() ### Description Updates an existing entry in the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabase.delete() ### Description Deletes an entry from the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabase.delete_all() ### Description Deletes all entries from the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ## DefaultBondDatabase.find_entry() ### Description Finds an entry in the bond database. ### Method Not specified (likely a class method or instance method) ### Endpoint N/A ``` -------------------------------- ### Getting GattsAttribute Value Source: https://blatann.readthedocs.io/en/latest/blatann.gatt.gatts_attribute.html Fetches the current value of the attribute from hardware and updates the local copy. It's generally recommended to use the 'value' property for local access to avoid unnecessary hardware reads. ```python get_value() ``` -------------------------------- ### BleEnableConfig.get_configs() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Retrieves all BLE enable configurations from BleEnableConfig. ```APIDOC ## BleEnableConfig.get_configs() ### Description Retrieves all available BLE enable configuration settings stored within the `BleEnableConfig` object. This provides a comprehensive set of parameters for enabling Bluetooth functionality. ### Method Not applicable (getter method) ### Parameters None. ### Returns A collection or dictionary of all BLE enable configuration settings. ``` -------------------------------- ### HexConverterTest Class for Hex Conversion Source: https://blatann.readthedocs.io/en/latest/blatann.examples.central_event_driven.html Class to manage the hex conversion process. It requires the hex conversion characteristic and a waitable object to signal completion. Call start() to initiate the conversion by writing data to the peripheral. ```python class HexConverterTest(_characteristic_ , _waitable_): """Class to perform the hex conversion process. It is passed in the hex conversion characteristic and the waitable to signal when the process completes""" def start(self): """Starts a new hex conversion process by writing the data to the peripheral’s characteristic""" pass ``` -------------------------------- ### BLEUUID Class Source: https://blatann.readthedocs.io/en/latest/blatann.nrf.nrf_types.generic.html Represents a Bluetooth UUID, supporting initialization with a value and optional base. It includes methods for getting the value, converting to an array, creating from C-style UUIDs or 128-bit UUIDs, and converting to a C-style representation. ```APIDOC ## Class BLEUUID ### Description Represents a Bluetooth UUID, supporting initialization with a value and optional base. It includes methods for getting the value, converting to an array, creating from C-style UUIDs or 128-bit UUIDs, and converting to a C-style representation. ### Methods - `__init__(_value_, _base= )` - `get_value()` - `as_array()` - `from_c(_uuid_)` (classmethod) - `from_uuid128(_uuid128_)` (classmethod) - `to_c()` - `from_array(_uuid_array_lt_)` (classmethod) ### Inner Class - `Standard(_value_)` (Enum): An enumeration for standard UUID values like unknown, service_primary, service_secondary, characteristic, cccd, battery_level, and heart_rate. ``` -------------------------------- ### PasskeyDisplayEventArgs.match_confirm() Source: https://blatann.readthedocs.io/en/latest/api_reference.html Confirms a match for the PasskeyDisplayEventArgs. ```APIDOC ## PasskeyDisplayEventArgs.match_confirm() ### Description Confirms a match for the PasskeyDisplayEventArgs. ### Method N/A (Method call) ### Parameters None ### Response None ``` -------------------------------- ### Scanner Class Source: https://blatann.readthedocs.io/en/latest/blatann.gap.scanning.html The Scanner class manages Bluetooth Low Energy scanning operations. It allows setting default scan parameters, starting and stopping scans, and provides events for received scan reports and scan timeouts. ```APIDOC ## class blatann.gap.scanning.Scanner(_ble_device_) ### Description Manages Bluetooth Low Energy scanning operations. ### Properties - **on_scan_received**: Event[Scanner, ScanReport] - Event that is raised whenever a scan report is received. - **on_scan_timeout**: Event[Scanner, ScanReportCollection] - Event that is raised when scanning completes/times out. - **is_scanning**: bool - Read Only. Current state of scanning. ### Methods #### set_default_scan_params ##### Description Sets the default scan parameters so they do not have to be specified each time a scan is started. Reference the Bluetooth specification for valid ranges for parameters. ##### Parameters - **interval_ms** (float) - The interval which to scan for advertising packets, in milliseconds. - **window_ms** (float) - How long within a single scan interval to be actively listening for advertising packets, in milliseconds. - **timeout_seconds** (int) - How long to advertise for, in seconds. - **active_scanning** (bool) - Whether or not to fetch scan response packets from advertisers. #### start_scan ##### Description Starts a scan and returns a waitable for when the scan completes. ##### Parameters - **scan_parameters** (Optional[ScanParameters]) - Optional scan parameters. Uses default if not specified. - **clear_scan_reports** (bool) - Flag to clear out previous scan reports. ##### Returns `ScanFinishedWaitable` - A Waitable which will trigger once the scan finishes based on the timeout specified. Waitable returns a ScanReportCollection of the advertising packets found. #### stop ##### Description Stops scanning. ``` -------------------------------- ### GattcEvtMtuExchangeResponse.from_c Source: https://blatann.readthedocs.io/en/latest/api_reference.html Creates a GattcEvtMtuExchangeResponse object from C-style data. This method is part of the GattcEvtMtuExchangeResponse class. ```APIDOC ## GattcEvtMtuExchangeResponse.from_c ### Description Creates a GattcEvtMtuExchangeResponse object from C-style data. ### Method Not Applicable (Static Method) ### Endpoint Not Applicable (Static Method) ### Parameters None explicitly documented. ### Request Example None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### Uint32 Properties Source: https://blatann.readthedocs.io/en/latest/api_reference.html Documentation for the Uint32 data type. ```APIDOC ## Uint32 ### Description Represents a 32-bit unsigned integer. ### Properties * `byte_count`: The number of bytes, which is 4. ```