pub struct GattServerFacade { /* private fields */ }
Expand description
Perform Gatt Server operations.
Note this object is shared among all threads created by server.
Implementations§
Source§impl GattServerFacade
impl GattServerFacade
pub fn new() -> GattServerFacade
Sourcepub async fn publish_server(&self, args: Value) -> Result<(), Error>
pub async fn publish_server(&self, args: Value) -> Result<(), Error>
Publish a GATT Server.
The input is a JSON object representing the attributes of the GATT server Database to setup. This function will also start listening for incoming requests to Characteristics and Descriptors in each Service.
This is primarially using the same input syntax as in the Android AOSP ACTS test framework at: <aosp_root>/tools/test/connectivity/acts/framework/acts/test_utils/bt/gatt_test_database.py
A “database” key wraps the database at:
Example python dictionary that’s turned into JSON (sub dic values can be found in <aosp_root>/tools/test/connectivity/acts/framework/acts/test_utils/bt/bt_constants.py:
SMALL_DATABASE = { ‘services’: [{ ‘uuid’: ‘00001800-0000-1000-8000-00805f9b34fb’, ‘type’: gatt_service_types[‘primary’], ‘characteristics’: [{ ‘uuid’: gatt_char_types[‘device_name’], ‘properties’: gatt_characteristic[‘property_read’], ‘permissions’: gatt_characteristic[‘permission_read’], ‘handle’: 0x0003, ‘value_type’: gatt_characteristic_value_format[‘string’], ‘value’: ‘Test Database’ }, { ‘uuid’: gatt_char_types[‘appearance’], ‘properties’: gatt_characteristic[‘property_read’], ‘permissions’: gatt_characteristic[‘permission_read’], ‘handle’: 0x0005, ‘value_type’: gatt_characteristic_value_format[‘sint32’], ‘offset’: 0, ‘value’: 17 }, { ‘uuid’: gatt_char_types[‘peripheral_pref_conn’], ‘properties’: gatt_characteristic[‘property_read’], ‘permissions’: gatt_characteristic[‘permission_read’], ‘handle’: 0x0007 }] }, { ‘uuid’: ‘00001801-0000-1000-8000-00805f9b34fb’, ‘type’: gatt_service_types[‘primary’], ‘characteristics’: [{ ‘uuid’: gatt_char_types[‘service_changed’], ‘properties’: gatt_characteristic[‘property_indicate’], ‘permissions’: gatt_characteristic[‘permission_read’] | gatt_characteristic[‘permission_write’], ‘handle’: 0x0012, ‘value_type’: gatt_characteristic_value_format[‘byte’], ‘value’: [0x0000], ‘descriptors’: [{ ‘uuid’: gatt_char_desc_uuids[‘client_char_cfg’], ‘permissions’: gatt_descriptor[‘permission_read’] | gatt_descriptor[‘permission_write’], ‘value’: [0x0000] }] }, { ‘uuid’: ‘0000b004-0000-1000-8000-00805f9b34fb’, ‘properties’: gatt_characteristic[‘property_read’], ‘permissions’: gatt_characteristic[‘permission_read’], ‘handle’: 0x0015, ‘value_type’: gatt_characteristic_value_format[‘byte’], ‘value’: [0x04] }] }] }