IOT-ESP32
ble.h File Reference

Interfaces for BLE communication. More...

Data Structures

struct  ble_config_t
 Configuration of BLE operation. More...
 
struct  queue_entry_t
 
class  SecureClient
 

Enumerations

enum  authstate_t
 States associated with BLE authorization of a connection. More...
 
enum  ble_char_len_t
 Possible GATT characteristic value types. More...
 
enum  ble_device_config_t
 The mode for managing devices. More...
 
enum  ble_state_t
 Flags representing the current/desired state of our BLE tasks. More...
 
enum  scan_filter_t
 Setting to specify HCI scan type. More...
 

Functions

void ble_add_static_device (device_id_t)
 Used to pre-define a device in STATIC config. More...
 
void ble_enable_bas ()
 configure device GATT service to use as BAS More...
 
void ble_init (ble_device_config_t config_mode=DEFAULT_BLE_SCAN_MODE)
 Initialize BLE services. More...
 
void ble_parse_sensor_payload (sensor_data_entry_t *, uint8_t *)
 Parse value from GATT and populate a payload entry. More...
 
uint8_t ble_request_attr_update (device_t *, uint8_t)
 Request the BLE device to provide update immediately. More...
 
void ble_sensor_network_queue (BLEAddress *, uint32_t *)
 Callback handler (bt_queue_handler_t) More...
 
void ble_set_notify_cb (ble_notify_cb_t)
 Set a callback handler for BLE notifications. More...
 
void ble_set_svc_uuid (ble_svc_uuid_t, NimBLEUUID)
 Update the BLE UUID's we expect from a device. More...
 
void bt_scan_enable ()
 Unlock BLE scanning task. More...
 
void bt_set_auth_handler (bt_conn_handler_t)
 Register callback for GAP 'on_auth' event. More...
 
void bt_set_connect_handler (bt_conn_handler_t)
 Register callback for GAP 'on_connect' event. More...
 
void bt_set_device_config_cb (bt_device_config_cb_t)
 Register callback for using external service for device information. More...
 
void bt_set_device_init_cb (bt_device_init_cb_t)
 Register callback for creating devices in another service. More...
 
void bt_set_device_mgmt_init (bt_device_mgmt_init_t)
 Register callback on BLE device mgmt task init. More...
 
void bt_set_disconnect_handler (bt_conn_handler_t)
 Register callback for GAP 'on_disconnect' event. More...
 
void bt_set_queue_handler (bt_queue_handler_t)
 Register the task to process the GATT payload queue. More...
 
void bt_set_scan_mgr_init (bt_device_mgmt_init_t)
 Register callback on BLE scan mgr task init. More...
 

Detailed Description

Interfaces for BLE communication.

Enumeration Type Documentation

◆ ble_char_len_t

Possible GATT characteristic value types.

◆ authstate_t

States associated with BLE authorization of a connection.

◆ ble_state_t

Flags representing the current/desired state of our BLE tasks.

◆ scan_filter_t

Setting to specify HCI scan type.

Type of BLE scanning to use, which generally will correspond to DEVICE_DYNAMIC vs DEVICE_STATIC operation

◆ ble_device_config_t

The mode for managing devices.

Function Documentation

◆ ble_parse_sensor_payload()

void ble_parse_sensor_payload ( sensor_data_entry_t *  ,
uint8_t *   
)

Parse value from GATT and populate a payload entry.

Parameters
entryptr to payload entry to populate
ble_dataptr to GATT value

◆ bt_set_queue_handler()

void bt_set_queue_handler ( bt_queue_handler_t  )

Register the task to process the GATT payload queue.

If there's a BLE service to accept incoming GATT payloads, there must be a consumer of the queue to process them

Parameters
handlerbt_queue_handler_t

◆ bt_set_connect_handler()

void bt_set_connect_handler ( bt_conn_handler_t  )

Register callback for GAP 'on_connect' event.

Parameters
handlerbt_conn_handler_t

◆ bt_set_disconnect_handler()

void bt_set_disconnect_handler ( bt_conn_handler_t  )

Register callback for GAP 'on_disconnect' event.

Parameters
handlerbt_connt_handler_t

◆ bt_set_auth_handler()

void bt_set_auth_handler ( bt_conn_handler_t  )

Register callback for GAP 'on_auth' event.

Parameters
handlerbt_connt_handler_t

◆ bt_set_device_config_cb()

void bt_set_device_config_cb ( bt_device_config_cb_t  )

Register callback for using external service for device information.

Parameters
handlerbt_device_config_cb_t

◆ bt_set_device_init_cb()

void bt_set_device_init_cb ( bt_device_init_cb_t  )

Register callback for creating devices in another service.

Parameters
handlerbt_device_init_cb_t

◆ bt_set_scan_mgr_init()

void bt_set_scan_mgr_init ( bt_device_mgmt_init_t  )

Register callback on BLE scan mgr task init.

Parameters
handler(bt_device_mgmt_init_t)

◆ bt_set_device_mgmt_init()

void bt_set_device_mgmt_init ( bt_device_mgmt_init_t  )

Register callback on BLE device mgmt task init.

Parameters
handler(bt_device_mgmt_init_t)

◆ bt_scan_enable()

void bt_scan_enable ( )

Unlock BLE scanning task.

Used for task synchronization across peripherals

◆ ble_init()

void ble_init ( ble_device_config_t  config_mode = DEFAULT_BLE_SCAN_MODE)

Initialize BLE services.

Parameters
device_modble_device_config_t Either SCAN_FILTER_NO_FILTER or SCAN_FILTER_WHITELIST to control scanning behavior of new advertisements. If not specified, the default is determined by the value of NO_DYNAMIC_DEVICES and will most likely be what you want.

◆ ble_add_static_device()

void ble_add_static_device ( device_id_t  )

Used to pre-define a device in STATIC config.

Chances are you'll only use this via device_load_static_lic()

Parameters
device_idThe device to create

◆ ble_request_attr_update()

uint8_t ble_request_attr_update ( device_t ,
uint8_t   
)

Request the BLE device to provide update immediately.

Parameters
device
sensor_indexThe devices index of the requested sensor type
Returns
uint8_t

◆ ble_sensor_network_queue()

void ble_sensor_network_queue ( BLEAddress *  ,
uint32_t *   
)

Callback handler (bt_queue_handler_t)

Handles incoming BLE payloads in their native format and delivers them to the outgoing network after construct the appropriate device_data_t structure

Parameters
*addrBLEAddress from GATT payload
*datauint32_t value from GATT

◆ ble_set_svc_uuid()

void ble_set_svc_uuid ( ble_svc_uuid_t  ,
NimBLEUUID   
)

Update the BLE UUID's we expect from a device.

Parameters
svc_uuidThe type of UUID
uuidThe new value

◆ ble_set_notify_cb()

void ble_set_notify_cb ( ble_notify_cb_t  )

Set a callback handler for BLE notifications.

This is the handler that gets registered when we subscribe() to characteristic updates.

Parameters
handler(ble_notify_cb_t)

◆ ble_enable_bas()

void ble_enable_bas ( )

configure device GATT service to use as BAS

Configure a subscription to devices BLE BAS service with network handler