|
SmartSnippets DA1459x SDK
|
API. More...
Files | |
| file | ble_att.h |
| Attribute protocol API. | |
| file | ble_attribdb.h |
| Helper to manage complex attributes database. | |
| file | ble_bufops.h |
| Helpers to put and get data from BLE buffers. | |
| file | ble_common.h |
| Common definitions for BLE API. | |
| file | ble_gap.h |
| BLE GAP API. | |
| file | ble_gatt.h |
| Common definitions for GATT API. | |
| file | ble_gattc.h |
| BLE GATT Client API. | |
| file | ble_gattc_util.h |
| BLE GATT Client Utilities API. | |
| file | ble_gatts.h |
| BLE GATT Server API. | |
| file | ble_l2cap.h |
| LE L2CAP connection oriented channels API. | |
| file | ble_storage.h |
| BLE persistent storage API. | |
| file | ble_uuid.h |
| BLE UUID declarations. | |
Macros | |
| #define | BLE_APP_NOTIFY_MASK (1 << 0) |
| #define | BLE_EVT_CAT_FIRST(CAT) (CAT << 8) |
| #define | LOW_POWER_ALL_PHYS ( 0x01 ) |
| #define | HIGH_PERFORMANCE_ALL_PHYS ( 0x02 ) |
| #define | BLE_ADV_DATA_LEN_MAX (ADV_DATA_LEN - 3) |
| #define | BLE_NON_CONN_ADV_DATA_LEN_MAX (ADV_DATA_LEN) |
| #define | BLE_SCAN_RSP_LEN_MAX (SCAN_RSP_DATA_LEN) |
| #define | BLE_GAP_CHANNEL_MAP_LEN (LE_CHNL_MAP_LEN) |
| #define | BLE_GAP_MAX_CONNECTED (dg_configBLE_CONNECTIONS_MAX) |
| #define | BLE_GAP_MAX_BONDED (defaultBLE_MAX_BONDED) |
| #define | BLE_ADV_INTERVAL_FROM_MS(MS) ((MS) * 1000 / 625) |
| #define | BLE_ADV_INTERVAL_TO_MS(VAL) ((VAL) * 625 / 1000) |
| #define | BLE_SCAN_INTERVAL_FROM_MS(MS) ((MS) * 1000 / 625) |
| #define | BLE_SCAN_INTERVAL_TO_MS(VAL) ((VAL) * 625 / 1000) |
| #define | BLE_SCAN_WINDOW_FROM_MS(MS) ((MS) * 1000 / 625) |
| #define | BLE_SCAN_WINDOW_TO_MS(VAL) ((VAL) * 625 / 1000) |
| #define | BLE_CONN_EVENT_LENGTH_FROM_MS(MS) ((MS) * 1000 / 625) |
| #define | BLE_CONN_EVENT_LENGTH_TO_MS(VAL) ((VAL) * 625 / 1000) |
| #define | BLE_CONN_INTERVAL_FROM_MS(MS) ((MS) * 100 / 125) |
| #define | BLE_CONN_INTERVAL_TO_MS(VAL) ((VAL) * 125 / 100) |
| #define | BLE_SUPERVISION_TMO_FROM_MS(MS) ((MS) / 10) |
| #define | BLE_SUPERVISION_TMO_TO_MS(VAL) ((VAL) * 10) |
| #define | BLE_CONN_IDX_INVALID (0xFFFF) |
| #define | BLE_RSSI_NOT_AVAILABLE (127) |
| #define | BLE_ENC_KEY_SIZE_MAX (16) |
| #define | GAP_ADV_AD_STRUCT(_ad_data_type, _ad_data_len, _ad_data) |
| #define | GAP_ADV_AD_STRUCT_BYTES(_ad_data_type, _ad_data_bytes...) |
| #define | GAP_ADV_AD_STRUCT_DECLARE(_ad_data_type, _ad_data_len, _ad_data) |
| #define | BLE_STORAGE_KEY_SRV(handle) (BLE_STORAGE_KEYCAT_SRV | (handle & 0xFFFF)) |
| #define | BLE_STORAGE_KEY_CLI(handle) (BLE_STORAGE_KEYCAT_CLI | (handle & 0xFFFF)) |
| #define | BLE_STORAGE_KEY_APP(app_id, val_id) (BLE_STORAGE_KEYCAT_APP | ((app_id & 0xFF) << 16) | (val_id & 0xFFFF)) |
Typedefs | |
| typedef enum addr_types | addr_type_t |
| typedef enum own_addr_types | own_addr_type_t |
| typedef struct bd_address | bd_address_t |
| typedef struct own_address | own_address_t |
| typedef struct gap_chnl_map | gap_chnl_map_t |
| typedef void(* | ble_storage_free_cb_t) (void *ptr) |
| Callback to free buffer stored in storage. More... | |
| typedef uint32_t | ble_storage_key_t |
| Storage key (for indexing values in storage) More... | |
Functions | |
| __STATIC_INLINE uint8_t | get_u8 (const uint8_t *buffer) |
| Get uint8 from buffer. More... | |
| __STATIC_INLINE uint16_t | get_u16 (const uint8_t *buffer) |
| Get uint16 from buffer. More... | |
| __STATIC_INLINE uint32_t | get_u32 (const uint8_t *buffer) |
| Get uint32 from buffer. More... | |
| __STATIC_INLINE uint8_t | get_u8_inc (const uint8_t **buffer) |
| Get uint8 from buffer and increase pointer. More... | |
| __STATIC_INLINE uint16_t | get_u16_inc (const uint8_t **buffer) |
| Get uint16 from buffer and increase pointer. More... | |
| __STATIC_INLINE uint32_t | get_u32_inc (const uint8_t **buffer) |
| Get uint32 from buffer and increase pointer. More... | |
| __STATIC_INLINE void | put_u8 (uint8_t *buffer, uint8_t value) |
| Put uint8 to buffer. More... | |
| __STATIC_INLINE void | put_u16 (uint8_t *buffer, uint16_t value) |
| Put uint16 to buffer. More... | |
| __STATIC_INLINE void | put_u32 (uint8_t *buffer, uint32_t value) |
| Put uint32 to buffer. More... | |
| __STATIC_INLINE void | put_u8_inc (uint8_t **buffer, uint8_t value) |
| Put uint8 to buffer and increase pointer. More... | |
| __STATIC_INLINE void | put_u16_inc (uint8_t **buffer, uint16_t value) |
| Put uint16 to buffer and increase pointer. More... | |
| __STATIC_INLINE void | put_u32_inc (uint8_t **buffer, uint32_t value) |
| Put uint32 to buffer and increase pointer. More... | |
| __STATIC_INLINE void | put_data_inc (uint8_t **buffer, uint16_t length, const void *data) |
| Put data to buffer and increase pointer. More... | |
| __STATIC_INLINE void | put_str_inc (uint8_t **buffer, const char *str) |
| Put string to buffer and increase pointer. More... | |
| ble_error_t | ble_register_app (void) |
| Register application in BLE framework. More... | |
| ble_error_t | ble_enable (void) |
| Enable BLE module. More... | |
| ble_error_t | ble_reset (void) |
| Reset BLE module. More... | |
| ble_error_t | ble_central_start (void) |
| Start the BLE module as a central device. More... | |
| ble_error_t | ble_peripheral_start (void) |
| Start the BLE module as a peripheral device. More... | |
| ble_evt_hdr_t * | ble_get_event (bool wait) |
| Get event from BLE event queue. More... | |
| bool | ble_has_event (void) |
| Checks if there's event pending in event queue. More... | |
| void | ble_handle_event_default (ble_evt_hdr_t *hdr) |
| Execute default event handler. More... | |
| ble_error_t | ble_read_tx_power (uint16_t conn_idx, tx_power_level_type_t type, uint8_t *tx_power) |
| Read controller TX power. More... | |
| __STATIC_INLINE bool | ble_address_cmp (const bd_address_t *addr1, const bd_address_t *addr2) |
| Compare two BD Addresses. More... | |
| const char * | ble_address_to_string (const bd_address_t *address) |
| Convert bd_address to string. More... | |
| bool | ble_address_from_string (const char *str, addr_type_t addr_type, bd_address_t *address) |
| Convert string to bd_address. More... | |
| ble_error_t | ble_set_fem_voltage_trim (uint8_t channel, uint8_t value) |
| Set FEM Voltage GPIO values for a specific channel. More... | |
| ble_error_t | ble_gap_address_get (own_address_t *address) |
| Retrieve the currently set BD address. More... | |
| ble_error_t | ble_gap_address_set (const own_address_t *address, uint16_t renew_dur) |
| Set the address of the device. More... | |
| ble_error_t | ble_gap_device_name_set (const char *name, att_perm_t perm) |
| Set the device name used for GAP service. More... | |
| ble_error_t | ble_gap_device_name_get (char *name, uint8_t *length) |
| Get the device name used for GAP service. More... | |
| ble_error_t | ble_gap_appearance_set (gap_appearance_t appearance, att_perm_t perm) |
| Set the appearance used for GAP service. More... | |
| ble_error_t | ble_gap_appearance_get (gap_appearance_t *appearance) |
| Get the appearance used for GAP service. More... | |
| ble_error_t | ble_gap_per_pref_conn_params_set (const gap_conn_params_t *conn_params) |
| Set the peripheral preferred connection parameters used for GAP service. More... | |
| ble_error_t | ble_gap_per_pref_conn_params_get (gap_conn_params_t *conn_params) |
| Get the peripheral preferred connection parameters currently set for GAP service. More... | |
| ble_error_t | ble_gap_adv_start (gap_conn_mode_t adv_type) |
| Start advertising. More... | |
| ble_error_t | ble_gap_adv_stop (void) |
| Stop advertising. More... | |
| ble_error_t | ble_gap_adv_data_set (uint8_t adv_data_len, const uint8_t *adv_data, uint8_t scan_rsp_data_len, const uint8_t *scan_rsp_data) |
| Set advertising Data and scan response data. More... | |
| ble_error_t | ble_gap_adv_ad_struct_set (size_t ad_len, const gap_adv_ad_struct_t *ad, size_t sd_len, const gap_adv_ad_struct_t *sd) |
| Set Advertising Data and Scan Response Data using gap_adv_ad_struct_t type. More... | |
| ble_error_t | ble_gap_adv_data_get (uint8_t *adv_data_len, uint8_t *adv_data, uint8_t *scan_rsp_data_len, uint8_t *scan_rsp_data) |
| Get currently used Advertising Data and Scan Response Data. More... | |
| ble_error_t | ble_gap_adv_intv_get (uint16_t *adv_intv_min, uint16_t *adv_intv_max) |
| Get the currently set advertising interval. More... | |
| ble_error_t | ble_gap_adv_intv_set (uint16_t adv_intv_min, uint16_t adv_intv_max) |
| Set the advertising interval. More... | |
| ble_error_t | ble_gap_adv_chnl_map_get (uint8_t *chnl_map) |
| Get the advertising channel map currently set. More... | |
| ble_error_t | ble_gap_adv_chnl_map_set (uint8_t chnl_map) |
| Set the advertising channel map. More... | |
| ble_error_t | ble_gap_adv_mode_get (gap_disc_mode_t *adv_mode) |
| Get the discoverability mode used for advertising. More... | |
| ble_error_t | ble_gap_adv_mode_set (gap_disc_mode_t adv_mode) |
| Set the discoverability mode used for advertising. More... | |
| ble_error_t | ble_gap_adv_filt_policy_get (adv_filt_pol_t *filt_policy) |
| Get the filtering policy used for advertising. More... | |
| ble_error_t | ble_gap_adv_filt_policy_set (adv_filt_pol_t filt_policy) |
| Set the filtering policy used for advertising. More... | |
| ble_error_t | ble_gap_adv_direct_address_get (bd_address_t *address) |
| Get the peer address used for directed advertising. More... | |
| ble_error_t | ble_gap_adv_direct_address_set (const bd_address_t *address) |
| Set peer address used for directed advertising. More... | |
| ble_error_t | ble_gap_adv_set_permutation (uint8_t permutation_index) |
| Set the permutation order of the primary advertising channels. More... | |
| ble_error_t | ble_gap_scan_start (gap_scan_type_t type, gap_scan_mode_t mode, uint16_t interval, uint16_t window, bool filt_wlist, bool filt_dupl) |
| Start scanning for devices. More... | |
| ble_error_t | ble_gap_scan_stop (void) |
| Stop scanning for devices. More... | |
| ble_error_t | ble_gap_scan_params_get (gap_scan_params_t *scan_params) |
| Get the scan parameters used for connections. More... | |
| ble_error_t | ble_gap_scan_params_set (const gap_scan_params_t *scan_params) |
| Set the scan parameters used for connections. More... | |
| ble_error_t | ble_gap_connect (const bd_address_t *peer_addr, const gap_conn_params_t *conn_params) |
| Connect to a device. More... | |
| ble_error_t | ble_gap_connect_ce (const bd_address_t *peer_addr, const gap_conn_params_t *conn_params, uint16_t ce_len_min, uint16_t ce_len_max) |
| Connect to a device with a defined connection event length. More... | |
| ble_error_t | ble_gap_connect_cancel (void) |
| Cancel an initiated connection. More... | |
| ble_error_t | ble_gap_disconnect (uint16_t conn_idx, ble_hci_error_t reason) |
| Terminate a connection. More... | |
| ble_error_t | ble_gap_peer_version_get (uint16_t conn_idx) |
| Get peer's version. More... | |
| ble_error_t | ble_gap_peer_features_get (uint16_t conn_idx) |
| Get peer's features. More... | |
| ble_error_t | ble_gap_conn_rssi_get (uint16_t conn_idx, int8_t *conn_rssi) |
| Retrieve the RSSI of a connection. More... | |
| ble_error_t | ble_gap_role_get (gap_role_t *role) |
| Get the GAP role currently set. More... | |
| ble_error_t | ble_gap_role_set (const gap_role_t role) |
| Set GAP role. More... | |
| ble_error_t | ble_gap_mtu_size_get (uint16_t *mtu_size) |
| Get MTU size. More... | |
| ble_error_t | ble_gap_mtu_size_set (uint16_t mtu_size) |
| Set MTU size. More... | |
| ble_error_t | ble_gap_channel_map_get (uint64_t *chnl_map) |
| Get the currently set channel map of the device (device has to be configured as central) More... | |
| ble_error_t | ble_gap_channel_map_set (const uint64_t chnl_map) |
| Set the channel map of the device (device has to be configured as central) More... | |
| ble_error_t | ble_gap_conn_param_update (uint16_t conn_idx, const gap_conn_params_t *conn_params) |
| Initiate a connection parameter update. More... | |
| ble_error_t | ble_gap_conn_param_update_reply (uint16_t conn_idx, bool accept) |
| Reply to a connection parameter update request. More... | |
| ble_error_t | ble_gap_pair (uint16_t conn_idx, bool bond) |
| Start pairing. More... | |
| ble_error_t | ble_gap_pair_reply (uint16_t conn_idx, bool accept, bool bond) |
| Respond to a pairing request. More... | |
| ble_error_t | ble_gap_get_connected (uint8_t *length, uint16_t **conn_idx) |
| Get connected devices list. More... | |
| ble_error_t | ble_gap_get_bonded (uint8_t *length, bd_address_t **addr) |
| Get bonded devices list. More... | |
| ble_error_t | ble_gap_get_io_cap (gap_io_cap_t *io_cap) |
| Get the I/O capabilities of the device. More... | |
| ble_error_t | ble_gap_set_io_cap (gap_io_cap_t io_cap) |
| Set the I/O capabilities of the device. More... | |
| ble_error_t | ble_gap_passkey_reply (uint16_t conn_idx, bool accept, uint32_t passkey) |
| Respond to a passkey request. More... | |
| ble_error_t | ble_gap_get_sec_level (uint16_t conn_idx, gap_sec_level_t *level) |
| Get connection security level. More... | |
| ble_error_t | ble_gap_unpair (const bd_address_t *addr) |
| Unpair command. More... | |
| ble_error_t | ble_gap_set_sec_level (uint16_t conn_idx, gap_sec_level_t level) |
| Set connection security level. More... | |
| ble_error_t | ble_gap_get_devices (gap_device_filter_t filter, gap_device_filter_data_t *filter_data, size_t *length, gap_device_t *gap_devices) |
| Return list of known devices. More... | |
| ble_error_t | ble_gap_get_device_by_addr (const bd_address_t *addr, gap_device_t *gap_device) |
| Get device object by device address. More... | |
| ble_error_t | ble_gap_get_device_by_conn_idx (uint16_t conn_idx, gap_device_t *gap_device) |
| Get device object by connection index. More... | |
| ble_error_t | ble_gap_is_bonded (uint16_t conn_idx, bool *bonded) |
| Get bond state of device (by connection index) More... | |
| ble_error_t | ble_gap_is_addr_bonded (const bd_address_t *addr, bool *bonded) |
| Get bond state of device (by address) More... | |
| ble_error_t | ble_gap_data_length_set (uint16_t conn_idx, uint16_t tx_length, uint16_t tx_time) |
| Set the data length used for TX. More... | |
| ble_error_t | ble_gap_address_resolve (bd_address_t address) |
| Resolve a BD address. More... | |
| ble_error_t | ble_gap_tx_power_set (uint8_t air_operation, gap_tx_power_t tx_power) |
| Set TX power for air operations. More... | |
| ble_error_t | ble_gap_conn_tx_power_set (uint16_t conn_idx, gap_tx_power_t tx_power) |
| Set TX power for given connection. More... | |
| ble_error_t | ble_gattc_browse (uint16_t conn_idx, const att_uuid_t *uuid) |
| Browse services on remote GATT server. More... | |
| ble_error_t | ble_gattc_browse_range (uint16_t conn_idx, uint16_t start_h, uint16_t end_h, const att_uuid_t *uuid) |
| Browse services on remote GATT server in a given range. More... | |
| ble_error_t | ble_gattc_discover_svc (uint16_t conn_idx, const att_uuid_t *uuid) |
| Discover services on remote GATT server. More... | |
| ble_error_t | ble_gattc_discover_include (uint16_t conn_idx, uint16_t start_h, uint16_t end_h) |
| Discover included services on remote GATT server. More... | |
| ble_error_t | ble_gattc_discover_char (uint16_t conn_idx, uint16_t start_h, uint16_t end_h, const att_uuid_t *uuid) |
| Discover characteristics on remote GATT server. More... | |
| ble_error_t | ble_gattc_discover_desc (uint16_t conn_idx, uint16_t start_h, uint16_t end_h) |
| Discover descriptors on remote GATT server. More... | |
| ble_error_t | ble_gattc_read (uint16_t conn_idx, uint16_t handle, uint16_t offset) |
| Read attribute from remote GATT server. More... | |
| ble_error_t | ble_gattc_write (uint16_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *value) |
| Write attribute to remote GATT server. More... | |
| ble_error_t | ble_gattc_write_no_resp (uint16_t conn_idx, uint16_t handle, bool signed_write, uint16_t length, const uint8_t *value) |
| Write attribute to remote GATT server (without response) More... | |
| ble_error_t | ble_gattc_write_prepare (uint16_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *value) |
| Prepare long/reliable write to remote GATT server. More... | |
| ble_error_t | ble_gattc_write_execute (uint16_t conn_idx, bool commit) |
| Execute reliable/long write to remote GATT server. More... | |
| ble_error_t | ble_gattc_indication_cfm (uint16_t conn_idx, uint16_t handle) __attribute__((deprecated)) |
| Send confirmation for received indication. More... | |
| ble_error_t | ble_gattc_get_mtu (uint16_t conn_idx, uint16_t *mtu) |
| Get current TX MTU for peer. More... | |
| ble_error_t | ble_gattc_exchange_mtu (uint16_t conn_idx) |
| Exchange MTU. More... | |
| void | ble_gattc_util_find_init (const ble_evt_gattc_browse_svc_t *evt) |
| Initialize browse event iterators. More... | |
| const gattc_item_t * | ble_gattc_util_find_characteristic (const att_uuid_t *uuid) |
| Find characteristic in browse event. More... | |
| const gattc_item_t * | ble_gattc_util_find_descriptor (const att_uuid_t *uuid) |
| Find descriptor in browse event. More... | |
| __STATIC_INLINE ble_error_t | ble_gattc_util_write_ccc (uint16_t conn_idx, uint16_t handle, gatt_ccc_t ccc) |
| Write value to CCC descriptor. More... | |
| ble_error_t | ble_gatts_add_service (const att_uuid_t *uuid, const gatt_service_t type, uint16_t num_attrs) |
| Add new GATT service. More... | |
| ble_error_t | ble_gatts_add_include (uint16_t handle, uint16_t *h_offset) |
| Add included service to GATT service. More... | |
| ble_error_t | ble_gatts_add_characteristic (const att_uuid_t *uuid, gatt_prop_t prop, att_perm_t perm, uint16_t max_len, gatts_flag_t flags, uint16_t *h_offset, uint16_t *h_val_offset) |
| Add characteristic to GATT service. More... | |
| ble_error_t | ble_gatts_add_descriptor (const att_uuid_t *uuid, att_perm_t perm, uint16_t max_len, gatts_flag_t flags, uint16_t *h_offset) |
| Add descriptor to GATT service. More... | |
| ble_error_t | ble_gatts_register_service (uint16_t *handle,...) |
| Register service in database. More... | |
| ble_error_t | ble_gatts_enable_service (uint16_t handle) |
| Enable service in database. More... | |
| ble_error_t | ble_gatts_disable_service (uint16_t handle) |
| Disable service in database. More... | |
| ble_error_t | ble_gatts_get_characteristic_prop (uint16_t handle, gatt_prop_t *prop, att_perm_t *perm) |
| Read current characteristic properties and permissions. More... | |
| ble_error_t | ble_gatts_set_characteristic_prop (uint16_t handle, gatt_prop_t prop, att_perm_t perm) |
| Set characteristic properties and permissions. More... | |
| ble_error_t | ble_gatts_get_value (uint16_t handle, uint16_t *length, void *value) |
| Get attribute value. More... | |
| ble_error_t | ble_gatts_set_value (uint16_t handle, uint16_t length, const void *value) |
| Set attribute value. More... | |
| ble_error_t | ble_gatts_read_cfm (uint16_t conn_idx, uint16_t handle, att_error_t status, uint16_t length, const void *value) |
| Respond to an attribute read request. More... | |
| ble_error_t | ble_gatts_write_cfm (uint16_t conn_idx, uint16_t handle, att_error_t status) |
| Respond to an attribute write request. More... | |
| ble_error_t | ble_gatts_prepare_write_cfm (uint16_t conn_idx, uint16_t handle, uint16_t length, att_error_t status) |
| Respond to an attribute prepare write request. More... | |
| ble_error_t | ble_gatts_send_event (uint16_t conn_idx, uint16_t handle, gatt_event_t type, uint16_t length, const void *value) |
| Send a characteristic value notification or indication. More... | |
| ble_error_t | ble_gatts_service_changed_ind (uint16_t conn_idx, uint16_t start_handle, uint16_t end_handle) |
| Send indication of the Service Changed Characteristic. More... | |
| __STATIC_INLINE uint16_t | ble_gatts_get_num_attr (uint16_t include, uint16_t characteristic, uint16_t descriptor) |
| Calculate number of attributes required for service. More... | |
| ble_error_t | ble_l2cap_listen (uint16_t conn_idx, uint16_t psm, gap_sec_level_t sec_level, uint16_t initial_credits, uint16_t *scid) |
| Create a connection oriented channel listening for incoming connections. More... | |
| ble_error_t | ble_l2cap_listen_defer_setup (uint16_t conn_idx, uint16_t psm, gap_sec_level_t sec_level, uint16_t initial_credits, uint16_t *scid) |
| Create a connection oriented channel listening for incoming connections. More... | |
| ble_error_t | ble_l2cap_connection_cfm (uint16_t conn_idx, uint16_t scid, enum ble_l2cap_connection_status status) |
| Accept or reject incoming connection. More... | |
| ble_error_t | ble_l2cap_stop_listen (uint16_t conn_idx, uint16_t scid) |
| Stop listening for incoming connections. More... | |
| ble_error_t | ble_l2cap_connect (uint16_t conn_idx, uint16_t psm, uint16_t initial_credits, uint16_t *scid) |
| Connect a connection oriented channel to remote peer. More... | |
| ble_error_t | ble_l2cap_disconnect (uint16_t conn_idx, uint16_t scid) |
| Disconnect channel. More... | |
| ble_error_t | ble_l2cap_add_credits (uint16_t conn_idx, uint16_t scid, uint16_t credits) |
| Add local credits on channel. More... | |
| ble_error_t | ble_l2cap_send (uint16_t conn_idx, uint16_t scid, uint16_t length, const void *data) |
| Send data on channel. More... | |
| ble_error_t | ble_l2cap_conn_param_update (uint16_t conn_idx, const gap_conn_params_t *conn_params) |
| Initiate a connection parameter update over L2CAP. More... | |
| ble_error_t | ble_storage_put_i32 (uint16_t conn_idx, ble_storage_key_t key, int32_t value, bool persistent) |
| Store signed integer value in storage. More... | |
| ble_error_t | ble_storage_put_u32 (uint16_t conn_idx, ble_storage_key_t key, uint32_t value, bool persistent) |
| Store unsigned integer value in storage. More... | |
| ble_error_t | ble_storage_put_buffer (uint16_t conn_idx, ble_storage_key_t key, uint16_t length, void *ptr, ble_storage_free_cb_t free_cb, bool persistent) |
| Store data buffer in storage. More... | |
| ble_error_t | ble_storage_put_buffer_copy (uint16_t conn_idx, ble_storage_key_t key, uint16_t length, void *ptr, ble_storage_free_cb_t free_cb, bool persistent) |
| Store copy of data buffer in storage. More... | |
| ble_error_t | ble_storage_get_i8 (uint16_t conn_idx, ble_storage_key_t key, int8_t *value) |
| Get int8 value from storage. More... | |
| ble_error_t | ble_storage_get_u8 (uint16_t conn_idx, ble_storage_key_t key, uint8_t *value) |
| Get uint8 value from storage. More... | |
| ble_error_t | ble_storage_get_i16 (uint16_t conn_idx, ble_storage_key_t key, int16_t *value) |
| Get int16 value from storage. More... | |
| ble_error_t | ble_storage_get_u16 (uint16_t conn_idx, ble_storage_key_t key, uint16_t *value) |
| Get uint16 value from storage. More... | |
| ble_error_t | ble_storage_get_i32 (uint16_t conn_idx, ble_storage_key_t key, int32_t *value) |
| Get int32 value from storage. More... | |
| ble_error_t | ble_storage_get_u32 (uint16_t conn_idx, ble_storage_key_t key, uint32_t *value) |
| Get uint32 value from storage. More... | |
| ble_error_t | ble_storage_get_buffer (uint16_t conn_idx, ble_storage_key_t key, uint16_t *length, void **ptr) |
| Get buffer value from storage. More... | |
| ble_error_t | ble_storage_remove (uint16_t conn_idx, ble_storage_key_t key) |
| Remove value from storage. More... | |
| ble_error_t | ble_storage_remove_all (ble_storage_key_t key) |
| Remove value from storage. More... | |
| void | ble_uuid_create16 (uint16_t uuid16, att_uuid_t *uuid) |
| Create 16-bit UUID from integer value. More... | |
| void | ble_uuid_from_buf (const uint8_t *buf, att_uuid_t *uuid) |
| Create UUID from buffer. More... | |
| bool | ble_uuid_from_string (const char *str, att_uuid_t *uuid) |
| Create UUID from string. More... | |
| const char * | ble_uuid_to_string (const att_uuid_t *uuid) |
| Convert UUID to string. More... | |
| bool | ble_uuid_equal (const att_uuid_t *uuid1, const att_uuid_t *uuid2) |
| Check if two UUIDs are equal. More... | |
API.
| #define BLE_ADV_DATA_LEN_MAX (ADV_DATA_LEN - 3) |
Maximum length of advertising data for connectable advertising packets in bytes (3 bytes reserved for AD flags)
| #define BLE_ADV_INTERVAL_FROM_MS | ( | MS | ) | ((MS) * 1000 / 625) |
Convert time in milliseconds to advertising interval value
| #define BLE_ADV_INTERVAL_TO_MS | ( | VAL | ) | ((VAL) * 625 / 1000) |
Convert advertising interval value to time in milliseconds
| #define BLE_APP_NOTIFY_MASK (1 << 0) |
Notification bitmask for event queue
| #define BLE_CONN_EVENT_LENGTH_FROM_MS | ( | MS | ) | ((MS) * 1000 / 625) |
Convert time in milliseconds to connection event length value
| #define BLE_CONN_EVENT_LENGTH_TO_MS | ( | VAL | ) | ((VAL) * 625 / 1000) |
Convert connection event length value to time in milliseconds
| #define BLE_CONN_IDX_INVALID (0xFFFF) |
Value for invalid connection index
Portable code should use this value wherever it's required to mark connection index as invalid.
| #define BLE_CONN_INTERVAL_FROM_MS | ( | MS | ) | ((MS) * 100 / 125) |
Convert time in milliseconds to connection interval value
| #define BLE_CONN_INTERVAL_TO_MS | ( | VAL | ) | ((VAL) * 125 / 100) |
Convert connection interval value to time in milliseconds
| #define BLE_ENC_KEY_SIZE_MAX (16) |
Maximum Encryption Key Size
| #define BLE_EVT_CAT_FIRST | ( | CAT | ) | (CAT << 8) |
Defines first event id in category
| #define BLE_GAP_CHANNEL_MAP_LEN (LE_CHNL_MAP_LEN) |
Channel map size in bytes
| #define BLE_GAP_MAX_BONDED (defaultBLE_MAX_BONDED) |
Maximum number of bonded devices
| #define BLE_GAP_MAX_CONNECTED (dg_configBLE_CONNECTIONS_MAX) |
Maximum number of connected devices
| #define BLE_NON_CONN_ADV_DATA_LEN_MAX (ADV_DATA_LEN) |
Maximum length of advertising data for non-connectable advertising packets
| #define BLE_RSSI_NOT_AVAILABLE (127) |
RSSI value not available
| #define BLE_SCAN_INTERVAL_FROM_MS | ( | MS | ) | ((MS) * 1000 / 625) |
Convert time in milliseconds to scan interval value
| #define BLE_SCAN_INTERVAL_TO_MS | ( | VAL | ) | ((VAL) * 625 / 1000) |
Convert scan interval value to time in milliseconds
| #define BLE_SCAN_RSP_LEN_MAX (SCAN_RSP_DATA_LEN) |
Maximum length of scan response data in bytes
| #define BLE_SCAN_WINDOW_FROM_MS | ( | MS | ) | ((MS) * 1000 / 625) |
Convert time in milliseconds to scan window value
| #define BLE_SCAN_WINDOW_TO_MS | ( | VAL | ) | ((VAL) * 625 / 1000) |
Convert scan window value to time in milliseconds
| #define BLE_STORAGE_KEY_APP | ( | app_id, | |
| val_id | |||
| ) | (BLE_STORAGE_KEYCAT_APP | ((app_id & 0xFF) << 16) | (val_id & 0xFFFF)) |
Storage key for application-defined values
| #define BLE_STORAGE_KEY_CLI | ( | handle | ) | (BLE_STORAGE_KEYCAT_CLI | (handle & 0xFFFF)) |
Storage key for attribute on GATT client (by handle)
| #define BLE_STORAGE_KEY_SRV | ( | handle | ) | (BLE_STORAGE_KEYCAT_SRV | (handle & 0xFFFF)) |
Storage key for attribute on GATT server (by handle)
| #define BLE_SUPERVISION_TMO_FROM_MS | ( | MS | ) | ((MS) / 10) |
Convert time in milliseconds to supervision timeout value
| #define BLE_SUPERVISION_TMO_TO_MS | ( | VAL | ) | ((VAL) * 10) |
Convert supervision timeout value to time in milliseconds
| #define GAP_ADV_AD_STRUCT | ( | _ad_data_type, | |
| _ad_data_len, | |||
| _ad_data | |||
| ) |
Helper macro to initialize single gap_adv_ad_struct_t object with fixed AD data like in this call example GAP_ADV_AD_STRUCT(GAP_DATA_TYPE_LOCAL_NAME, DEVICE_ADV_NAME_LEN, DEVICE_ADV_NAME)
| #define GAP_ADV_AD_STRUCT_BYTES | ( | _ad_data_type, | |
| _ad_data_bytes... | |||
| ) |
Helper macro to initialize single gap_adv_ad_struct_t object by specifying set of individual octets of AD data like this one GAP_ADV_AD_STRUCT_BYTES(GAP_DATA_TYPE_UUID16_LIST, 0x12, 0x18)
| #define GAP_ADV_AD_STRUCT_DECLARE | ( | _ad_data_type, | |
| _ad_data_len, | |||
| _ad_data | |||
| ) |
Helper macro to instantiate & initialize single gap_adv_ad_struct_t object on stack with AD data returning address of the object.
| #define HIGH_PERFORMANCE_ALL_PHYS ( 0x02 ) |
High Performance (HP) mode
| #define LOW_POWER_ALL_PHYS ( 0x01 ) |
Radio Power Modes Low Power (LP) mode
| typedef enum addr_types addr_type_t |
Bluetooth Address type
| typedef struct bd_address bd_address_t |
Bluetooth Device address
| typedef void(* ble_storage_free_cb_t) (void *ptr) |
Callback to free buffer stored in storage.
| [in] | ptr | buffer |
| typedef uint32_t ble_storage_key_t |
Storage key (for indexing values in storage)
Storage keys namespace is divided into different category thus should not be hard-coded as raw number, but appropriate macros should be used to ensure no collision between different users of storage, see STORAGE_KEY_SRV(), STORAGE_KEY_CLI() and STORAGE_KEY_APP().
| typedef struct gap_chnl_map gap_chnl_map_t |
Link Layer channel map
| typedef enum own_addr_types own_addr_type_t |
Own Device Address type
| typedef struct own_address own_address_t |
Own Bluetooth Device address
| anonymous enum |
| enum addr_types |
| enum adv_filt_pol_t |
Advertising filter policy
| enum att_error_t |
Error code for ATT operation (as defined by Core 4.2 specification)
| enum att_perm_t |
ATT attribute permission
| enum ble_error_t |
BLE error code
| enum ble_evt_cat |
BLE event categories
| enum ble_evt_common |
| enum ble_evt_gap |
GAP events.
| enum ble_evt_gattc |
GATT Client events
| enum ble_evt_gatts |
| enum ble_evt_l2cap |
LE L2CAP connection oriented channels events
| enum ble_gap_phy_pref_t |
| enum ble_gap_phy_t |
| enum ble_hci_error_t |
BLE HCI error code
Connection confirm status
| enum ble_status_t |
BLE stack status
| enum gap_adv_chnl_t |
| enum gap_air_op_t |
| enum gap_appearance_t |
GAP device external appearance
| enum gap_auth_t |
| enum gap_conn_mode_t |
| enum gap_data_type_t |
GAP Advertising Data Types, as defined by Bluetooth Core 4.2 specification
| enum gap_device_filter_t |
Device filter type
| enum gap_disc_mode_t |
| enum gap_io_cap_t |
| enum gap_role_t |
| enum gap_scan_mode_t |
| enum gap_scan_type_t |
| enum gap_sec_level_t |
| enum gap_tx_power_t |
GAP TX power levels
| enum gatt_ccc_t |
GATT Client Characteristic Configuration bitmask values
| enum gatt_event_t |
GATT event type
| enum gatt_prop_t |
GATT characteristic properties
| enum gatt_service_t |
GATT service type
| enum gattc_item_type_t |
| enum gatts_flag_t |
GATT Server flags
| Enumerator | |
|---|---|
| GATTS_FLAG_CHAR_READ_REQ | enable BLE_EVT_GATTS_READ_REQ for attribute |
| enum own_addr_types |
TX Power Level
| __STATIC_INLINE bool ble_address_cmp | ( | const bd_address_t * | addr1, |
| const bd_address_t * | addr2 | ||
| ) |
Compare two BD Addresses.
| [in] | addr1 | 1st address |
| [in] | addr2 | 2nd address |
addr1 and addr2 are the same, false otherwise | bool ble_address_from_string | ( | const char * | str, |
| addr_type_t | addr_type, | ||
| bd_address_t * | address | ||
| ) |
Convert string to bd_address.
| [in] | str | address as a string |
| [in] | addr_type | address type |
| [out] | address | converted address |
| const char* ble_address_to_string | ( | const bd_address_t * | address | ) |
Convert bd_address to string.
| [in] | address | address to convert |
| ble_error_t ble_central_start | ( | void | ) |
Start the BLE module as a central device.
| ble_error_t ble_enable | ( | void | ) |
Enable BLE module.
| ble_error_t ble_gap_address_get | ( | own_address_t * | address | ) |
Retrieve the currently set BD address.
This API call is used to retrieve the currently set BD address of the device.
| [out] | address | Buffer to store the BD address |
| ble_error_t ble_gap_address_resolve | ( | bd_address_t | address | ) |
Resolve a BD address.
Resolve a BD address using the set of IRKs stored in BLE storage.
| [in] | address | BD address to resolve (has to be resolvable private address) |
| ble_error_t ble_gap_address_set | ( | const own_address_t * | address, |
| uint16_t | renew_dur | ||
| ) |
Set the address of the device.
This API call is used to set the BD address of the device. If the address type is not PRIVATE_STATIC_ADDRESS the address passed is ignored (public static is set either in NVPARAM or using defaultBLE_STATIC_ADDRESS and private random addresses are automatically generated by the BLE stack every renew_dur seconds).
| [in] | address | Pointer to the address to be set |
| [in] | renew_dur | Random address renew duration in seconds (valid range is 1 to 3600 seconds) |
| ble_error_t ble_gap_adv_ad_struct_set | ( | size_t | ad_len, |
| const gap_adv_ad_struct_t * | ad, | ||
| size_t | sd_len, | ||
| const gap_adv_ad_struct_t * | sd | ||
| ) |
Set Advertising Data and Scan Response Data using gap_adv_ad_struct_t type.
This API call sets advertising and scan response data. The function is to be a wrapper to ble_gap_adv_data_set() API. Internally it makes validation and then transforms inputs advertising data before it reuses call to ble_gap_adv_data_set(). The API uses as input gap_adv_ad_struct_t data type that logically expressing AD Data format that conforms to Bluetooth Core Specification [Core 5.0, Vol 3, Part C, 11] Such individual input objects can be easily instantiated by making call to helper macros GAP_ADV_AD_STRUCT(), GAP_ADV_AD_STRUCT_BYTES() and GAP_ADV_AD_STRUCT_DECLARE(). Such objects can be used separately or can be aggregated into an array to feed the API input.
| [in] | ad_len | Number of Advertising Data objects |
| [in] | ad | Pointer to Advertising Data object(s) |
| [in] | sd_len | Number of Scan Response Data objects |
| [in] | sd | Pointer to Scan Response Data object(s) |
| ble_error_t ble_gap_adv_chnl_map_get | ( | uint8_t * | chnl_map | ) |
Get the advertising channel map currently set.
chnl_map will be constructed using the members of gap_adv_chnl_t: GAP_ADV_CHANNEL_37, GAP_ADV_CHANNEL_38, GAP_ADV_CHANNEL_39.| [out] | chnl_map | Channel map currently used for advertising |
| ble_error_t ble_gap_adv_chnl_map_set | ( | uint8_t | chnl_map | ) |
Set the advertising channel map.
chnl_map must be constructed using the members of gap_adv_chnl_t: GAP_ADV_CHANNEL_37, GAP_ADV_CHANNEL_38, GAP_ADV_CHANNEL_39.| [in] | chnl_map | Channel map used for advertising |
| ble_error_t ble_gap_adv_data_get | ( | uint8_t * | adv_data_len, |
| uint8_t * | adv_data, | ||
| uint8_t * | scan_rsp_data_len, | ||
| uint8_t * | scan_rsp_data | ||
| ) |
Get currently used Advertising Data and Scan Response Data.
Get the Advertising Data and Scan Response Data currently used. This can be used while an advertising operation is in progress. adv_data_len and scan_rsp_data_len can be set to 0 to get the length of the currently set advertising data and scan response data before allocating any buffers.
| [in,out] | adv_data_len | Empty buffer size on input, length of advertising data set on output |
| [in] | adv_data | Pointer to the empty buffer the advertising aata should be copied into |
| [in,out] | scan_rsp_data_len | Empty buffer size on input, length of scan response data set on output |
| [in] | scan_rsp_data | Pointer to the empty buffer the scan response data should be copied into |
| ble_error_t ble_gap_adv_data_set | ( | uint8_t | adv_data_len, |
| const uint8_t * | adv_data, | ||
| uint8_t | scan_rsp_data_len, | ||
| const uint8_t * | scan_rsp_data | ||
| ) |
Set advertising Data and scan response data.
This API call is used to modify the advertising data and scan response Data used. It can be used while an advertising operation is in progress. If an advertising operation is not in progress, the new Advertising Data and/or new Scan Response Data will be used the next time function ble_gap_adv_start() is called. The maximum Advertising Data length for undirected connectable advertising is BLE_ADV_DATA_LEN_MAX bytes (31 minus 3 that are reserved to set the Advertising Data type flags - which shall not be set in Advertising Data using this function). The equivalent max length for non-connectable advertising is BLE_NON_CONN_ADV_DATA_LEN_MAX bytes.
| [in] | adv_data_len | Length of the Advertising Data |
| [in] | adv_data | Pointer to the Advertising Data |
| [in] | scan_rsp_data_len | Length of the Scan Response Data |
| [in] | scan_rsp_data | Pointer to the Scan Response Data |
| ble_error_t ble_gap_adv_direct_address_get | ( | bd_address_t * | address | ) |
Get the peer address used for directed advertising.
| [out] | address | Peer address used for directed advertising |
| ble_error_t ble_gap_adv_direct_address_set | ( | const bd_address_t * | address | ) |
Set peer address used for directed advertising.
| [in] | address | Peer address used for directed advertising |
| ble_error_t ble_gap_adv_filt_policy_get | ( | adv_filt_pol_t * | filt_policy | ) |
Get the filtering policy used for advertising.
| [out] | filt_policy | Filtering policy used for advertising |
| ble_error_t ble_gap_adv_filt_policy_set | ( | adv_filt_pol_t | filt_policy | ) |
Set the filtering policy used for advertising.
| [in] | filt_policy | Filtering policy used for advertising |
| ble_error_t ble_gap_adv_intv_get | ( | uint16_t * | adv_intv_min, |
| uint16_t * | adv_intv_max | ||
| ) |
Get the currently set advertising interval.
Get the minimum and maximum advertising intervals currently set.
| [out] | adv_intv_min | Minimum interval in steps of 0.625ms |
| [out] | adv_intv_max | Maximum interval in steps of 0.625ms |
| ble_error_t ble_gap_adv_intv_set | ( | uint16_t | adv_intv_min, |
| uint16_t | adv_intv_max | ||
| ) |
Set the advertising interval.
Set the minimum and maximum interval to be used for advertising. Intervals are set in steps of 0.625ms. Allowed values for intervals span from 0x20 (20ms) to 0x4000 (10.24s), while for non-connectable advertising the range is 0xA0 (100ms) to 0x4000 (10.24s).
| [in] | adv_intv_min | Minimum interval in steps of 0.625ms |
| [in] | adv_intv_max | Maximum interval in steps of 0.625ms |
| ble_error_t ble_gap_adv_mode_get | ( | gap_disc_mode_t * | adv_mode | ) |
Get the discoverability mode used for advertising.
| [out] | adv_mode | Discoverability mode |
| ble_error_t ble_gap_adv_mode_set | ( | gap_disc_mode_t | adv_mode | ) |
Set the discoverability mode used for advertising.
| [in] | adv_mode | Discoverability mode used for advertising |
| ble_error_t ble_gap_adv_set_permutation | ( | uint8_t | permutation_index | ) |
Set the permutation order of the primary advertising channels.
This function sets the order of the primary advertising channels to be used in subsequent advertising events. There are 6 (3!) possible permutations for the arrangement of the channels. The permutations are indexed by their position in lexicographical increasing order.
| [in] | permutation_index | A valid permutation index (0 <= index <= 5), as defined in the following table: permutation_index | channel order -----------------—+------------— 0 | 37, 38, 39 1 | 37, 39, 38 2 | 38, 37, 39 3 | 38, 39, 37 4 | 39, 37, 38 5 | 39, 38, 37 |
| ble_error_t ble_gap_adv_start | ( | gap_conn_mode_t | adv_type | ) |
Start advertising.
This API call is used to start an advertising air operation. If adv_type is set to be GAP_CONN_MODE_NON_CONN or GAP_CONN_MODE_UNDIRECTED, the air operation will go on until it is stopped using ble_gap_adv_stop(). If adv_type is set to be GAP_CONN_MODE_DIRECTED or GAP_CONN_MODE_DIRECTED_LDC (low duty cycle advertising), the air operation will automatically stop after 1.28s. In both cases, upon advertising completion, a BLE_EVT_GAP_ADV_COMPLETED event will be sent to the application.
| [in] | adv_type | Type of advertising |
| ble_error_t ble_gap_adv_stop | ( | void | ) |
Stop advertising.
This API call is used to stop a previously started advertising air operation. If advertising is successfully stopped, the application will receive a BLE_EVT_GAP_ADV_COMPLETED with status set to BLE_ERROR_CANCELED.
| ble_error_t ble_gap_appearance_get | ( | gap_appearance_t * | appearance | ) |
Get the appearance used for GAP service.
| [in] | appearance | Pointer to where the appearance value should be stored |
| ble_error_t ble_gap_appearance_set | ( | gap_appearance_t | appearance, |
| att_perm_t | perm | ||
| ) |
Set the appearance used for GAP service.
| [in] | appearance | Appearance value |
| [in] | perm | Appearance attribute write permission |
| ble_error_t ble_gap_channel_map_get | ( | uint64_t * | chnl_map | ) |
Get the currently set channel map of the device (device has to be configured as central)
This API call is used to retrieve the channel map currently set for the device. The channel map consists of 37 bits. The n-th bit (in the range 0 to 36) contains the value for the link layer channel index n. A bit equal to 0 indicates that the corresponding channel is unused, and a bit equal to 1 indicates that the corresponding channel is used. The most significant bits are reserved and shall be set to 0.
| [out] | chnl_map | Channel map (only the 37 least significant bits are used) |
| ble_error_t ble_gap_channel_map_set | ( | const uint64_t | chnl_map | ) |
Set the channel map of the device (device has to be configured as central)
This API call is used to modify the channel map of the device. The device has to be central to have the ability to change the channel map. The channel map consists of 37 bits. The n-th bit (in the range 0 to 36) contains the value for the link layer channel index n. A bit equal to 0 indicates that the corresponding channel is unused, and a bit equal to 1 indicates that the corresponding channel is used. The most significant bits are reserved and shall be set to 0.
| [in] | chnl_map | Channel map (only the 37 least significant bits are used) |
| ble_error_t ble_gap_conn_param_update | ( | uint16_t | conn_idx, |
| const gap_conn_params_t * | conn_params | ||
| ) |
Initiate a connection parameter update.
This call can be used by both the master and the slave of the connection to initiate a connection parameter update. For the master of the connection, the new connection parameters will be applied immediately. For the slave of the connection, a connection parameter update request will be send to the master. If the master accepts the connection parameters, it will be in charge of applying them (which will result in a BLE_EVT_GAP_CONN_PARAM_UPDATED event message to the slave that initiated the connection parameter update process). If 40s elapse without a response from the master, the connection will be terminated.
| [in] | conn_idx | Connection index |
| [in] | conn_params | Connection parameters |
| ble_error_t ble_gap_conn_param_update_reply | ( | uint16_t | conn_idx, |
| bool | accept | ||
| ) |
Reply to a connection parameter update request.
This call should be used to reply to a connection parameter update request event (BLE_EVT_GAP_CONN_PARAM_UPDATE_REQ) message.
| [in] | conn_idx | Connection index |
| [in] | accept | Accept flag (1 to accept, 0 to reject) |
| ble_error_t ble_gap_conn_rssi_get | ( | uint16_t | conn_idx, |
| int8_t * | conn_rssi | ||
| ) |
Retrieve the RSSI of a connection.
This call retrieves the RSSI of an established connection. Value BLE_RSSI_NOT_AVAILABLE of parameter conn_rssi informs that RSSI is not available.
| [in] | conn_idx | Connection index |
| [out] | conn_rssi | Connection RSSI |
| ble_error_t ble_gap_conn_tx_power_set | ( | uint16_t | conn_idx, |
| gap_tx_power_t | tx_power | ||
| ) |
Set TX power for given connection.
Set the TX power level to be used for a given connection.
| [in] | conn_idx | Connection index |
| [in] | tx_power | TX power level (see gap_tx_power_t for available options) |
| ble_error_t ble_gap_connect | ( | const bd_address_t * | peer_addr, |
| const gap_conn_params_t * | conn_params | ||
| ) |
Connect to a device.
This call initiates a direct connection procedure to a specified device. The application will get a BLE_EVT_GAP_CONNECTED event when the connection is established and a BLE_EVT_GAP_CONNECTION_COMPLETED event when the connection procedure is completed either successfully or with error (in the second case, BLE_EVT_GAP_CONNECTED will not be received).
| [in] | peer_addr | Pointer to the BD address of the peer device. |
| [in] | conn_params | Pointer to the connection parameters to be used. |
| ble_error_t ble_gap_connect_cancel | ( | void | ) |
Cancel an initiated connection.
This call cancels a previously started connection procedure using ble_gap_connect(). The application will receive a BLE_EVT_GAP_CONNECTION_COMPLETED event with status set to BLE_ERROR_CANCELED if the connection procedure is successfully canceled.
| ble_error_t ble_gap_connect_ce | ( | const bd_address_t * | peer_addr, |
| const gap_conn_params_t * | conn_params, | ||
| uint16_t | ce_len_min, | ||
| uint16_t | ce_len_max | ||
| ) |
Connect to a device with a defined connection event length.
This is an extension to ble_gap_connect(). It initiates a direct connection procedure to a specified device. The application will get a BLE_EVT_GAP_CONNECTED event when the connection is established and a BLE_EVT_GAP_CONNECTION_COMPLETED event when the connection procedure is completed either successfully or with error (in the second case, BLE_EVT_GAP_CONNECTED will not be received). Compared to ble_gap_connect(), this allows setting the minimum and maximum lengths for the connection event when used by the master of the connection (ce_len_min and ce_len_max will be ignored when used by the slave of the connection).
| [in] | peer_addr | Pointer to the BD address of the peer device. |
| [in] | conn_params | Pointer to the connection parameters to be used. |
| [in] | ce_len_min | Minimum connection event length (in steps of 0.625us) |
| [in] | ce_len_max | Maximum connection event length (in steps of 0.625us) |
| ble_error_t ble_gap_data_length_set | ( | uint16_t | conn_idx, |
| uint16_t | tx_length, | ||
| uint16_t | tx_time | ||
| ) |
Set the data length used for TX.
This function will set the maximum transmit data channel PDU payload length and time depending on the conn_idx provided. If conn_idx is set to BLE_CONN_IDX_INVALID then this API sets the preferred TX data length and time for subsequent connections. If conn_idx corresponds to an existing connection, it will set the TX data length and time for the specific connection (and possibly will initiate a Data Length Update procedure as defined in Bluetooth Core v_4.2).
| [in] | conn_idx | Connection index (if set to BLE_CONN_IDX_INVALID then the API will set the preferred data length for new connections) |
| [in] | tx_length | Length for TX data channel PDU payload in octets |
| [in] | tx_time | Time for TX data channel PDU payload (if set to 0 it will be calculated based on the tx_length (with regard to Bluetooth Core v_4.2) |
| ble_error_t ble_gap_device_name_get | ( | char * | name, |
| uint8_t * | length | ||
| ) |
Get the device name used for GAP service.
| [in] | name | Pointer to empty buffer where the device name (NULL-terminated) shall be placed. |
| [in,out] | length | Empty buffer size on input, set length of the ble parameter device name on output. |
| ble_error_t ble_gap_device_name_set | ( | const char * | name, |
| att_perm_t | perm | ||
| ) |
Set the device name used for GAP service.
| [in] | name | Pointer to the device name |
| [in] | perm | Device name attribute write permission |
| ble_error_t ble_gap_disconnect | ( | uint16_t | conn_idx, |
| ble_hci_error_t | reason | ||
| ) |
Terminate a connection.
This call initiates a disconnection procedure on an established link.
| [in] | conn_idx | Connection index |
| [in] | reason | Reason for disconnection. |
| ble_error_t ble_gap_get_bonded | ( | uint8_t * | length, |
| bd_address_t ** | addr | ||
| ) |
Get bonded devices list.
Addresses for currently bonded devices are returned in addr buffer which is allocated internally and should be freed by called when not needed.
| [out] | length | Length of returned array |
| [out] | addr | Array of bonded addresses |
| ble_error_t ble_gap_get_connected | ( | uint8_t * | length, |
| uint16_t ** | conn_idx | ||
| ) |
Get connected devices list.
Connection indexes for currently connected devices are returned in conn_idx buffer which is allocated internally and should be freed by called when not needed.
| [out] | length | Length of returned array |
| [out] | conn_idx | Array of connections indexes |
| ble_error_t ble_gap_get_device_by_addr | ( | const bd_address_t * | addr, |
| gap_device_t * | gap_device | ||
| ) |
Get device object by device address.
| [in] | addr | Device address |
| [out] | gap_device | Device object |
| ble_error_t ble_gap_get_device_by_conn_idx | ( | uint16_t | conn_idx, |
| gap_device_t * | gap_device | ||
| ) |
Get device object by connection index.
| [in] | conn_idx | Connection index |
| [out] | gap_device | Device object |
| ble_error_t ble_gap_get_devices | ( | gap_device_filter_t | filter, |
| gap_device_filter_data_t * | filter_data, | ||
| size_t * | length, | ||
| gap_device_t * | gap_devices | ||
| ) |
Return list of known devices.
| [in] | filter | device list filter to be applied |
| [in] | filter_data | additional data for filtering (depends on filter) |
| [in,out] | length | length of devices list (maximum allowed as input, number of returned as output) |
| [out] | gap_devices | returned devices |
| ble_error_t ble_gap_get_io_cap | ( | gap_io_cap_t * | io_cap | ) |
Get the I/O capabilities of the device.
Get the currently set Input/Output Capabilities of the device (combined with the peer's I/O capabilities, this will determine which pairing algorithm will be used).
| [out] | io_cap | IO capabilities |
| ble_error_t ble_gap_get_sec_level | ( | uint16_t | conn_idx, |
| gap_sec_level_t * | level | ||
| ) |
Get connection security level.
Get the currently established security level on a connection.
| [in] | conn_idx | Connection index |
| [out] | level | Connection security level |
| ble_error_t ble_gap_is_addr_bonded | ( | const bd_address_t * | addr, |
| bool * | bonded | ||
| ) |
Get bond state of device (by address)
| [in] | addr | Device address |
| [out] | bonded | Flag specifying if the device is bonded |
| ble_error_t ble_gap_is_bonded | ( | uint16_t | conn_idx, |
| bool * | bonded | ||
| ) |
Get bond state of device (by connection index)
| [in] | conn_idx | Connection index |
| [out] | bonded | Flag specifying if the device is bonded |
| ble_error_t ble_gap_mtu_size_get | ( | uint16_t * | mtu_size | ) |
Get MTU size.
This call retrieves the Maximum Protocol Unit size that is used in exchange MTU transactions with peers.
| [out] | mtu_size | MTU size |
| ble_error_t ble_gap_mtu_size_set | ( | uint16_t | mtu_size | ) |
Set MTU size.
This call sets the Maximum Protocol Unit size that will be used in exchange MTU transactions with peers.
| [in] | mtu_size | MTU size |
| ble_error_t ble_gap_pair | ( | uint16_t | conn_idx, |
| bool | bond | ||
| ) |
Start pairing.
This call starts a pairing or bonding procedure. Depending on whether the device is master or slave on the connection, it will send a pairing or a security request respectively.
| [in] | conn_idx | Connection index |
| [in] | bond | Whether it starts pairing or bonding procedure |
| ble_error_t ble_gap_pair_reply | ( | uint16_t | conn_idx, |
| bool | accept, | ||
| bool | bond | ||
| ) |
Respond to a pairing request.
The application should use this function to respond to a BLE_EVT_GAP_PAIR_REQ event.
| [in] | conn_idx | Connection index |
| [in] | accept | Accept flag |
| [in] | bond | Bonding flag |
| ble_error_t ble_gap_passkey_reply | ( | uint16_t | conn_idx, |
| bool | accept, | ||
| uint32_t | passkey | ||
| ) |
Respond to a passkey request.
Respond to a BLE_EVT_GAP_PASSKEY_REQUEST event.
| [in] | conn_idx | Connection index |
| [in] | accept | Accept flag |
| [in] | passkey | Passkey entered by user |
| ble_error_t ble_gap_peer_features_get | ( | uint16_t | conn_idx | ) |
Get peer's features.
This call initiates a Feature Exchange procedure or retrieves the already exchanged peer's features on an established connection. Peer's features will be delivered to the application via BLE_EVT_GAP_PEER_FEATURES event.
| [in] | conn_idx | Connection index |
| ble_error_t ble_gap_peer_version_get | ( | uint16_t | conn_idx | ) |
Get peer's version.
This call initiates a Version Exchange procedure or retrieves the already exchanged peer's version on an established connection. Peer's version will be delivered to the application via BLE_EVT_GAP_PEER_VERSION event.
| [in] | conn_idx | Connection index |
| ble_error_t ble_gap_per_pref_conn_params_get | ( | gap_conn_params_t * | conn_params | ) |
Get the peripheral preferred connection parameters currently set for GAP service.
| [in] | conn_params | Pointer to where the preferred connection parameters shall be stored. |
| ble_error_t ble_gap_per_pref_conn_params_set | ( | const gap_conn_params_t * | conn_params | ) |
Set the peripheral preferred connection parameters used for GAP service.
| [in] | conn_params | Preferred connection parameters. |
| ble_error_t ble_gap_role_get | ( | gap_role_t * | role | ) |
Get the GAP role currently set.
This call gets the currently set GAP role of the device.
| [out] | role | GAP role |
| ble_error_t ble_gap_role_set | ( | const gap_role_t | role | ) |
Set GAP role.
This call sets the GAP role of the device.
| [in] | role | GAP role |
| ble_error_t ble_gap_scan_params_get | ( | gap_scan_params_t * | scan_params | ) |
Get the scan parameters used for connections.
This call retrieves the scan parameters used when a connection is initiated.
| [out] | scan_params | Pointer to the structure where the scan parameters will be stored. |
| ble_error_t ble_gap_scan_params_set | ( | const gap_scan_params_t * | scan_params | ) |
Set the scan parameters used for connections.
This call sets the scan parameters used for initiated connections. This call won't change the scan parameters of a connection attempt which is in progress (the scan parameters will be set for the next connection attempt).
| [in] | scan_params | Pointer to the scan parameters structure |
| ble_error_t ble_gap_scan_start | ( | gap_scan_type_t | type, |
| gap_scan_mode_t | mode, | ||
| uint16_t | interval, | ||
| uint16_t | window, | ||
| bool | filt_wlist, | ||
| bool | filt_dupl | ||
| ) |
Start scanning for devices.
This call initiates a scan procedure. The scan duration depends on the scan mode selected. In General-discoverable and Limited-discoverable modes, the scan will stop after 10s of activity. In Observer mode, the scan operation will continue until it is stopped using ble_gap_scan_stop(). The scan interval and window can be set in steps of 0.625ms. Allowed values for interval span in the range of 0x4 (2.5ms) to 0x4000 (10.24s).
| [in] | type | Active or passive scanning |
| [in] | mode | Scan for General-discoverable, Limited-discoverable or for all devices |
| [in] | interval | Scan interval in steps of 0.625ms |
| [in] | window | Scan window in steps of 0.625ms |
| [in] | filt_wlist | Enable or disable white list filtering |
| [in] | filt_dupl | Enable or disable filtering of duplicates |
| ble_error_t ble_gap_scan_stop | ( | void | ) |
Stop scanning for devices.
This call stops a scan procedure previously started using ble_gap_scan_start().
| ble_error_t ble_gap_set_io_cap | ( | gap_io_cap_t | io_cap | ) |
Set the I/O capabilities of the device.
Set the Input/Output Capabilities of the device (combined with the peer's I/O capabilities, this will determine which pairing algorithm will be used).
| [in] | io_cap | new IO capabilities |
| ble_error_t ble_gap_set_sec_level | ( | uint16_t | conn_idx, |
| gap_sec_level_t | level | ||
| ) |
Set connection security level.
Use this function to set the security level for a connection. If the device is already bonded, it will use the existing LTK or request a new bonding. If the device is not bonded, it will create a pairing or a security request (depending on whether the device is master or slave on the connection) with the bond flag set to false.
| [in] | conn_idx | Connection index |
| [in] | level | New security level |
| ble_error_t ble_gap_tx_power_set | ( | uint8_t | air_operation, |
| gap_tx_power_t | tx_power | ||
| ) |
Set TX power for air operations.
Set the TX power level to be used for advertising, scanning and/or initiating a connection. This TX power level setting will be also used for the connection that may be established as a result of the air operation.
| [in] | air_operation | Air operation(s) (combine gap_air_op_t available options) |
| [in] | tx_power | TX power level (see gap_tx_power_t for available options) |
| ble_error_t ble_gap_unpair | ( | const bd_address_t * | addr | ) |
Unpair command.
Use this function to unpair a device. This will also remove the device bond data from BLE storage.
| [in] | addr | Remote device address |
| ble_error_t ble_gattc_browse | ( | uint16_t | conn_idx, |
| const att_uuid_t * | uuid | ||
| ) |
Browse services on remote GATT server.
This will automatically discover all characteristics and descriptors of a service. To discover services only, use ble_gattc_discover_svc() instead.
BLE_EVT_GATTC_BROWSE_SVC will be sent for each service found. Once completed BLE_EVT_GATTC_BROWSE_COMPLETED will be sent.
If uuid is NULL, all services are returned.
| [in] | conn_idx | connection index |
| [in] | uuid | optional service UUID |
| ble_error_t ble_gattc_browse_range | ( | uint16_t | conn_idx, |
| uint16_t | start_h, | ||
| uint16_t | end_h, | ||
| const att_uuid_t * | uuid | ||
| ) |
Browse services on remote GATT server in a given range.
This will automatically discover all characteristics and descriptors of a service in the range between start_h and end_h.
BLE_EVT_GATTC_BROWSE_SVC will be sent for each service found. Once completed BLE_EVT_GATTC_BROWSE_COMPLETED will be sent.
If uuid is NULL, all services in range are returned.
| [in] | conn_idx | connection index |
| [in] | start_h | beginning of browse range |
| [in] | end_h | end of browse range |
| [in] | uuid | optional service UUID |
| ble_error_t ble_gattc_discover_char | ( | uint16_t | conn_idx, |
| uint16_t | start_h, | ||
| uint16_t | end_h, | ||
| const att_uuid_t * | uuid | ||
| ) |
Discover characteristics on remote GATT server.
BLE_EVT_GATTC_DISCOVER_CHAR will be sent for each characteristic found. Once completed BLE_EVT_GATTC_DISCOVER_COMPLETED will be sent.
If uuid is NULL, all characteristics are returned.
| [in] | conn_idx | connection index |
| [in] | start_h | start handle of service to discover |
| [in] | end_h | end handle of service to discover |
| [in] | uuid | optional characteristic UUID |
| ble_error_t ble_gattc_discover_desc | ( | uint16_t | conn_idx, |
| uint16_t | start_h, | ||
| uint16_t | end_h | ||
| ) |
Discover descriptors on remote GATT server.
BLE_EVT_GATTC_DISCOVER_DESC will be sent for each descriptor found. Once completed BLE_EVT_GATTC_DISCOVER_COMPLETED will be sent.
| [in] | conn_idx | connection index |
| [in] | start_h | start handle of characteristic to discover |
| [in] | end_h | end handle of characteristic to discover |
| ble_error_t ble_gattc_discover_include | ( | uint16_t | conn_idx, |
| uint16_t | start_h, | ||
| uint16_t | end_h | ||
| ) |
Discover included services on remote GATT server.
BLE_EVT_GATTC_DISCOVER_INCLUDE will be sent for each included service found. Once completed BLE_EVT_GATTC_DISCOVER_COMPLETED will be sent.
| [in] | conn_idx | connection index |
| [in] | start_h | start handle of service to discover |
| [in] | end_h | end handle of service to discover |
| ble_error_t ble_gattc_discover_svc | ( | uint16_t | conn_idx, |
| const att_uuid_t * | uuid | ||
| ) |
Discover services on remote GATT server.
BLE_EVT_GATTC_DISCOVER_SVC will be sent for each service found. Once completed BLE_EVT_GATTC_DISCOVER_COMPLETED will be sent.
If uuid is NULL, all services are returned.
| [in] | conn_idx | connection index |
| [in] | uuid | optional service UUID |
| ble_error_t ble_gattc_exchange_mtu | ( | uint16_t | conn_idx | ) |
Exchange MTU.
This call will start an MTU exchange procedure with the MTU previously set using ble_gap_mtu_size_set(). If the MTU has been changed during the negotiation, a BLE_EVT_GATTC_MTU_CHANGED event will be sent to the application.
| [in] | conn_idx | connection index |
| ble_error_t ble_gattc_get_mtu | ( | uint16_t | conn_idx, |
| uint16_t * | mtu | ||
| ) |
Get current TX MTU for peer.
| [in] | conn_idx | connection index |
| [out] | mtu | current MTU |
| ble_error_t ble_gattc_indication_cfm | ( | uint16_t | conn_idx, |
| uint16_t | handle | ||
| ) |
Send confirmation for received indication.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| ble_error_t ble_gattc_read | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| uint16_t | offset | ||
| ) |
Read attribute from remote GATT server.
This uses either the "Read Characteristic Value" procedure or the "Read Characteristic Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero or the attribute length is larger than the MTU, the "Read Long Characteristic Value" procedure or the "Read Long Characteristic Descriptor" procedure will be used respectively. The complete attribute value will be returned in the BLE_EVT_GATTC_READ_COMPLETED event.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | offset | value offset to start with |
| const gattc_item_t* ble_gattc_util_find_characteristic | ( | const att_uuid_t * | uuid | ) |
Find characteristic in browse event.
This call will return the first characteristic from the event which matches the given UUID (in case uuid is NULL, the first characteristic will be returned). Subsequent calls with the same given uuid will return subsequent characteristics matching the same criteria or NULL if no more matching characteristics are found.
ble_gattc_util_find_init() must be called prior to calling this function.
Subsequent calls with different uuid will restart searching from the first characteristic.
The returned item will always have the GATTC_ITEM_TYPE_CHARACTERISTIC type.
| [in] | uuid | optional UUID of characteristic |
| const gattc_item_t* ble_gattc_util_find_descriptor | ( | const att_uuid_t * | uuid | ) |
Find descriptor in browse event.
This call will return the first descriptor from the event which matches the given UUID (if uuid is NULL, the first descriptor will be returned). Subsequent calls with the same given uuid will return subsequent descriptors matching the same criteria or NULL if no more matching descriptors are found.
ble_gattc_util_find_characteristic() must be called and the specified characteristic must be found prior to calling this function.
Subsequent calls with different uuid will restart searching from the first descriptor.
Returned item will always have the GATTC_ITEM_TYPE_DESCRIPTOR type.
| [in] | uuid | optional UUID of descriptor |
| void ble_gattc_util_find_init | ( | const ble_evt_gattc_browse_svc_t * | evt | ) |
Initialize browse event iterators.
This call will initialize internal structures to iterate over BLE_EVT_GATTC_BROWSE_SVC. After this call the application can use ble_gattc_util_find_characteristic() to get a characteristic from the event. evt instance should be valid as long as the iterator is used since only weak reference is stored internally.
| [in] | evt | instance of event |
| __STATIC_INLINE ble_error_t ble_gattc_util_write_ccc | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| gatt_ccc_t | ccc | ||
| ) |
Write value to CCC descriptor.
This function writes a Client Characteristic Configuration Descriptor value to a given handle.
| [in] | conn_idx | connection index |
| [in] | handle | CCC descriptor handle |
| [in] | ccc | value to be written |
| ble_error_t ble_gattc_write | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| uint16_t | offset, | ||
| uint16_t | length, | ||
| const uint8_t * | value | ||
| ) |
Write attribute to remote GATT server.
This uses either the "Write Characteristic Value" procedure or the "Write Characteristic
Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero or the attribute length is larger than the MTU, the "Write Long Characteristic Value" procedure or the "Write Long Characteristic Descriptor" procedure will be used respectively.
The application will receive a BLE_EVT_GATTC_WRITE_COMPLETED event when the write operation is completed.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | offset | value offset to start with |
| [in] | length | value length |
| [in] | value | value data |
| ble_error_t ble_gattc_write_execute | ( | uint16_t | conn_idx, |
| bool | commit | ||
| ) |
Execute reliable/long write to remote GATT server.
In order to cancel prepared requests, commit shall be set to false.
The application will receive a BLE_EVT_GATTC_WRITE_COMPLETED event when write queue is executed. The handle parameter of this event will be set to 0.
| [in] | conn_idx | connection index |
| [in] | commit | true if data shall be written, false otherwise |
| ble_error_t ble_gattc_write_no_resp | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| bool | signed_write, | ||
| uint16_t | length, | ||
| const uint8_t * | value | ||
| ) |
Write attribute to remote GATT server (without response)
If signed_write is set to false, the "Write Without Response" procedure will be used. If signed_write is set to true, the "Signed Write Without Response" procedure will be used on a link which is not encrypted or will fall back to the "Write Without Response" procedure on a link that is already encrypted.
The application will receive a BLE_EVT_GATTC_WRITE_COMPLETED event when the write operation is performed.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | signed_write | true if signed write should be used if possible/applicable |
| [in] | length | value length |
| [in] | value | value data |
| ble_error_t ble_gattc_write_prepare | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| uint16_t | offset, | ||
| uint16_t | length, | ||
| const uint8_t * | value | ||
| ) |
Prepare long/reliable write to remote GATT server.
The application will receive a BLE_EVT_GATTC_WRITE_COMPLETED event when the write operation is queued.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | offset | value offset |
| [in] | length | value length |
| [in] | value | value data |
| ble_error_t ble_gatts_add_characteristic | ( | const att_uuid_t * | uuid, |
| gatt_prop_t | prop, | ||
| att_perm_t | perm, | ||
| uint16_t | max_len, | ||
| gatts_flag_t | flags, | ||
| uint16_t * | h_offset, | ||
| uint16_t * | h_val_offset | ||
| ) |
Add characteristic to GATT service.
This adds a characteristic declaration to the service added by ble_gatts_add_service().
The application will receive a BLE_EVT_GATTS_WRITE_REQ event every time a value is written by the peer to the attribute. In order for application to receive also a BLE_EVT_GATTS_READ_REQ event every time the attribute's value is read by peer, flags shall be set to GATTS_FLAG_CHAR_READ_REQ.
prop. It will be used later to set the correct descriptor's value.| [in] | uuid | characteristic UUID |
| [in] | prop | characteristic properties |
| [in] | perm | characteristic value attribute permissions |
| [in] | max_len | maximum length of characteristic value |
| [in] | flags | additional settings for characteristic |
| [out] | h_offset | attribute offset (relative to service handle) |
| [out] | h_val_offset | value attribute offset (relative to service handle) |
| ble_error_t ble_gatts_add_descriptor | ( | const att_uuid_t * | uuid, |
| att_perm_t | perm, | ||
| uint16_t | max_len, | ||
| gatts_flag_t | flags, | ||
| uint16_t * | h_offset | ||
| ) |
Add descriptor to GATT service.
This adds a characteristic declaration to the service added by ble_gatts_add_service().
The application will receive a BLE_EVT_GATTS_WRITE_REQ event every time the attribute is written by the peer. In order for application to receive also a BLE_EVT_GATTS_READ_REQ event every time the attribute is read by the peer, flags shall be set to GATTS_FLAG_CHAR_READ_REQ.
flags value. This applies e.g. to the Client Characteristic Configuration descriptor.| [in] | uuid | descriptor UUID |
| [in] | perm | descriptor attribute permissions |
| [in] | max_len | maximum length of descriptor value |
| [in] | flags | additional settings for descriptor |
| [out] | h_offset | attribute offset (relative to service handle) |
| ble_error_t ble_gatts_add_include | ( | uint16_t | handle, |
| uint16_t * | h_offset | ||
| ) |
Add included service to GATT service.
This adds an included service declaration to the service added by ble_gatts_add_service().
| [in] | handle | included service handle |
| [out] | h_offset | attribute offset (relative to service handle) |
| ble_error_t ble_gatts_add_service | ( | const att_uuid_t * | uuid, |
| const gatt_service_t | type, | ||
| uint16_t | num_attrs | ||
| ) |
Add new GATT service.
This initiates the addition of a new service to ATT database. Subsequent calls to ble_gatts_add_include(), ble_gatts_add_characteristic() and ble_gatts_add_descriptor() will add attributes to the service added by this call. All of these calls should be in the same order as attributes should be added to the database.
The Service is added to the database and enabled once ble_gatts_register_service() is called after all attributes have been added.
| [in] | uuid | service UUID |
| [in] | type | service type |
| [in] | num_attrs | number of attributes to be added |
| ble_error_t ble_gatts_disable_service | ( | uint16_t | handle | ) |
Disable service in database.
This makes a service invisible to clients. Once registered, services are always enabled by default. Since this function may change the database structure, application shall ensure that the Service Changed characteristic is enabled in the database (bit 0x20 is set in defaultBLE_ATT_DB_CONFIGURATION) and indicated if necessary.
| [in] | handle | service start handle |
| ble_error_t ble_gatts_enable_service | ( | uint16_t | handle | ) |
Enable service in database.
This makes a service visible to clients. Once registered, services are always enabled by default. Since this function may change the database structure, the application shall ensure that the Service Changed characteristic is enabled in the database (bit 0x20 is set in defaultBLE_ATT_DB_CONFIGURATION) and indicated if necessary.
| [in] | handle | service start handle |
| ble_error_t ble_gatts_get_characteristic_prop | ( | uint16_t | handle, |
| gatt_prop_t * | prop, | ||
| att_perm_t * | perm | ||
| ) |
Read current characteristic properties and permissions.
| [in] | handle | characteristic value handle |
| [out] | prop | characteristic properties |
| [out] | perm | characteristic permissions |
| __STATIC_INLINE uint16_t ble_gatts_get_num_attr | ( | uint16_t | include, |
| uint16_t | characteristic, | ||
| uint16_t | descriptor | ||
| ) |
Calculate number of attributes required for service.
| [in] | include | number of included services |
| [in] | characteristic | number of characteristics |
| [in] | descriptor | number of descriptors |
| ble_error_t ble_gatts_get_value | ( | uint16_t | handle, |
| uint16_t * | length, | ||
| void * | value | ||
| ) |
Get attribute value.
This retrieves an attribute's value from the database. Up to size bytes are copied to val buffer. The value returned in size is the total attribute value length and may be larger than the supplied size. This information can be used by the application to allocate a larger buffer that fits the complete attribute value.
| [in] | handle | attribute handle |
| [in,out] | length | input buffer size or attribute value length |
| [out] | value | buffer to store attribute value |
| ble_error_t ble_gatts_prepare_write_cfm | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| uint16_t | length, | ||
| att_error_t | status | ||
| ) |
Respond to an attribute prepare write request.
The application should use this function to respond to a BLE_EVT_GATTS_PREPARE_WRITE_REQ event.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | length | attribute value length |
| [in] | status | operation status |
| ble_error_t ble_gatts_read_cfm | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| att_error_t | status, | ||
| uint16_t | length, | ||
| const void * | value | ||
| ) |
Respond to an attribute read request.
The application should use this function to respond to a BLE_EVT_GATTS_READ_REQ event.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | status | operation status |
| [in] | length | attribute value length |
| [in] | value | attribute value |
| ble_error_t ble_gatts_register_service | ( | uint16_t * | handle, |
| ... | |||
| ) |
Register service in database.
This adds all attributes previously added to the service to the attribute database.
handle can be used to calculate the actual handle values for offset values returned in h_offset and h_val_offset parameters. A series of pointers to offset values can be specified as arguments in order for this function to update them automatically.
| [out] | handle | service handle |
| [out] | ... | attributes offsets to be translated (shall end with 0) |
| ble_error_t ble_gatts_send_event | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| gatt_event_t | type, | ||
| uint16_t | length, | ||
| const void * | value | ||
| ) |
Send a characteristic value notification or indication.
Send an indication or a notification of an attribute's value to a connected peer.
The application will receive a BLE_EVT_GATTS_EVENT_SENT event when the notification is successfully sent over the air.
| [in] | conn_idx | connection index |
| [in] | handle | characteristic value handle |
| [in] | type | indication or notification |
| [in] | length | characteristic value length |
| [in] | value | characteristic value |
| ble_error_t ble_gatts_service_changed_ind | ( | uint16_t | conn_idx, |
| uint16_t | start_handle, | ||
| uint16_t | end_handle | ||
| ) |
Send indication of the Service Changed Characteristic.
This should be called only if the Service Changed Characteristic is enabled in the attribute database configuration (bit 0x20 is set in defaultBLE_ATT_DB_CONFIGURATION).
| [in] | conn_idx | connection index |
| [in] | start_handle | start handle of affected database region |
| [in] | end_handle | end handle of affected database region |
| ble_error_t ble_gatts_set_characteristic_prop | ( | uint16_t | handle, |
| gatt_prop_t | prop, | ||
| att_perm_t | perm | ||
| ) |
Set characteristic properties and permissions.
As mandated by Core Specification version 4.1, characteristic declarations shall not change while a bond with any device exists on the server. THe application shall ensure it does not use this API to change the characteristic properties while such bond exists.
| [in] | handle | characteristic value handle |
| [in] | prop | characteristic properties |
| [in] | perm | characteristic permissions |
| ble_error_t ble_gatts_set_value | ( | uint16_t | handle, |
| uint16_t | length, | ||
| const void * | value | ||
| ) |
Set attribute value.
This sets an attribute's value in the internal database. Any read request from any peer will have this value returned. In order for an attribute to have different values for each peer, the application should store them locally and use BLE_EVT_GATTS_READ_REQ to handle read requests for a given attribute.
| [in] | handle | attribute handle |
| [in] | length | attribute value length |
| [in] | value | attribute value |
| ble_error_t ble_gatts_write_cfm | ( | uint16_t | conn_idx, |
| uint16_t | handle, | ||
| att_error_t | status | ||
| ) |
Respond to an attribute write request.
The application should use this function to respond to a BLE_EVT_GATTS_WRITE_REQ event.
| [in] | conn_idx | connection index |
| [in] | handle | attribute handle |
| [in] | status | operation status |
| ble_evt_hdr_t* ble_get_event | ( | bool | wait | ) |
Get event from BLE event queue.
| [in] | wait | if true, function will block until there is event in queue |
| void ble_handle_event_default | ( | ble_evt_hdr_t * | hdr | ) |
Execute default event handler.
It's recommended for application to call this for any event it does not handle. This avoids situation when BLE stack is waiting for response on event which application does not handle.
| [in] | hdr | event buffer |
| bool ble_has_event | ( | void | ) |
Checks if there's event pending in event queue.
| ble_error_t ble_l2cap_add_credits | ( | uint16_t | conn_idx, |
| uint16_t | scid, | ||
| uint16_t | credits | ||
| ) |
Add local credits on channel.
Application should monitor contents of local_credits_consumed member of BLE_EVT_L2CAP_DATA_IND event and give back appropriate number of local credits when processing of incoming data is completed.
| [in] | conn_idx | Connection index |
| [in] | scid | Source CID |
| [in] | credits | Number of credits to be added |
| ble_error_t ble_l2cap_conn_param_update | ( | uint16_t | conn_idx, |
| const gap_conn_params_t * | conn_params | ||
| ) |
Initiate a connection parameter update over L2CAP.
This call can be used only by the slave of a connection to initiate a connection parameter request to the master over L2CAP, instead of using ble_gap_conn_param_update() which triggers the connection parameter request procedure. Successful connection parameters update will result in a BLE_EVT_GAP_CONN_PARAM_UPDATED event message. Unsuccessful connection parameters update (connection parameters rejected by the master) will not result in any event message to the application.
| [in] | conn_idx | Connection index |
| [in] | conn_params | Pointer to the connection parameters |
| ble_error_t ble_l2cap_connect | ( | uint16_t | conn_idx, |
| uint16_t | psm, | ||
| uint16_t | initial_credits, | ||
| uint16_t * | scid | ||
| ) |
Connect a connection oriented channel to remote peer.
| [in] | conn_idx | Connection index |
| [in] | psm | LE Protocol/Service Multiplexer |
| [in] | initial_credits | Initial credits on channel |
| [out] | scid | Source CID for created channel |
| ble_error_t ble_l2cap_connection_cfm | ( | uint16_t | conn_idx, |
| uint16_t | scid, | ||
| enum ble_l2cap_connection_status | status | ||
| ) |
Accept or reject incoming connection.
Accepted connection will be signaled using BLE_EVT_L2CAP_CONNECTED event.
| [in] | conn_idx | Connection index |
| [in] | scid | Source CID for created channel |
| [in] | status | Status of operation |
| ble_error_t ble_l2cap_disconnect | ( | uint16_t | conn_idx, |
| uint16_t | scid | ||
| ) |
Disconnect channel.
scid should identify channel which was received in BLE_EVT_L2CAP_CONNECTED event.
| [in] | conn_idx | Connection index |
| [in] | scid | Source CID for channel to be disconnected |
| ble_error_t ble_l2cap_listen | ( | uint16_t | conn_idx, |
| uint16_t | psm, | ||
| gap_sec_level_t | sec_level, | ||
| uint16_t | initial_credits, | ||
| uint16_t * | scid | ||
| ) |
Create a connection oriented channel listening for incoming connections.
Incoming connection will be signaled using BLE_EVT_L2CAP_CONNECTED event.
| [in] | conn_idx | Connection index |
| [in] | psm | LE Protocol/Service Multiplexer |
| [in] | sec_level | Channel security |
| [in] | initial_credits | Initial credits on channel |
| [out] | scid | Source CID for created channel |
| ble_error_t ble_l2cap_listen_defer_setup | ( | uint16_t | conn_idx, |
| uint16_t | psm, | ||
| gap_sec_level_t | sec_level, | ||
| uint16_t | initial_credits, | ||
| uint16_t * | scid | ||
| ) |
Create a connection oriented channel listening for incoming connections.
Incoming connection will be signaled using BLE_EVT_L2CAP_CONNECTION_REQ event.
| [in] | conn_idx | Connection index |
| [in] | psm | LE Protocol/Service Multiplexer |
| [in] | sec_level | Channel security |
| [in] | initial_credits | Initial credits on channel |
| [out] | scid | Source CID for created channel |
| ble_error_t ble_l2cap_send | ( | uint16_t | conn_idx, |
| uint16_t | scid, | ||
| uint16_t | length, | ||
| const void * | data | ||
| ) |
Send data on channel.
| [in] | conn_idx | Connection index |
| [in] | scid | Source CID |
| [in] | length | Length of data to be sent |
| [in] | data | Data to be sent |
| ble_error_t ble_l2cap_stop_listen | ( | uint16_t | conn_idx, |
| uint16_t | scid | ||
| ) |
Stop listening for incoming connections.
scid should identify channel previously created with ble_l2cap_listen().
| [in] | conn_idx | Connection index |
| [in] | scid | Source CID for channel to stop listening on |
| ble_error_t ble_peripheral_start | ( | void | ) |
Start the BLE module as a peripheral device.
| ble_error_t ble_read_tx_power | ( | uint16_t | conn_idx, |
| tx_power_level_type_t | type, | ||
| uint8_t * | tx_power | ||
| ) |
Read controller TX power.
| [in] | conn_idx | connection index |
| [in] | type | type of TX power |
| [out] | tx_power | returned tx_power in case of success |
| ble_error_t ble_register_app | ( | void | ) |
Register application in BLE framework.
| ble_error_t ble_reset | ( | void | ) |
Reset BLE module.
| ble_error_t ble_set_fem_voltage_trim | ( | uint8_t | channel, |
| uint8_t | value | ||
| ) |
Set FEM Voltage GPIO values for a specific channel.
This sets the values of the 3 FEM voltage trim GPIOs. Bit X, X in[0, 2] of this value corresponds to the desired state for the respective GPIO.
| [in] | channel | The BLE physical channel to configure the GPIOs for, as defined by channel = (freq - 2402)/2, where freq is the channel frequency. |
| [in] | value | The 3-bit value to be configured |
| ble_error_t ble_storage_get_buffer | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint16_t * | length, | ||
| void ** | ptr | ||
| ) |
Get buffer value from storage.
This has unpredictable result when used with key which stores signed or unsigned value, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | length | length of returned buffer |
| [out] | ptr | pointer to buffer |
| ble_error_t ble_storage_get_i16 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| int16_t * | value | ||
| ) |
Get int16 value from storage.
This has unpredictable result when used with key which stores unsigned value or buffer, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | value | value |
| ble_error_t ble_storage_get_i32 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| int32_t * | value | ||
| ) |
Get int32 value from storage.
This has unpredictable result when used with key which stores unsigned value or buffer, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | value | value |
| ble_error_t ble_storage_get_i8 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| int8_t * | value | ||
| ) |
Get int8 value from storage.
This has unpredictable result when used with key which stores unsigned value or buffer, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | value | value |
| ble_error_t ble_storage_get_u16 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint16_t * | value | ||
| ) |
Get uint16 value from storage.
This has unpredictable result when used with key which stores signed value or buffer, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | value | value |
| ble_error_t ble_storage_get_u32 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint32_t * | value | ||
| ) |
Get uint32 value from storage.
This has unpredictable result when used with key which stores signed value or buffer, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | value | value |
| ble_error_t ble_storage_get_u8 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint8_t * | value | ||
| ) |
Get uint8 value from storage.
This has unpredictable result when used with key which stores signed value or buffer, no sanity checks are performed. Value of value is not changed if key is not found in storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [out] | value | value |
| ble_error_t ble_storage_put_buffer | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint16_t | length, | ||
| void * | ptr, | ||
| ble_storage_free_cb_t | free_cb, | ||
| bool | persistent | ||
| ) |
Store data buffer in storage.
length shall be non-zero. Buffer pointed by ptr is owned by storage after calling this function and shall not be freed by application. It will be freed automatically when value is removed from storage. Optional free_cb callback can be provided if buffer stores data which shall be handled in a special way, i.e. pointers to other buffers.
key can be an arbitrary value, it's recommended to use values within service attribute handles range to avoid collision with other services or applications.| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [in] | length | length of buffer |
| [in] | ptr | buffer pointer |
| [in] | free_cb | callback to free buffer |
| [in] | persistent | if true, value will be persistent for bonded devices |
| ble_error_t ble_storage_put_buffer_copy | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint16_t | length, | ||
| void * | ptr, | ||
| ble_storage_free_cb_t | free_cb, | ||
| bool | persistent | ||
| ) |
Store copy of data buffer in storage.
This is identical to ble_storage_put_buffer() except it makes copy of buffer pointed by ptr.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [in] | length | length of buffer |
| [in] | ptr | buffer pointer |
| [in] | free_cb | callback to free buffer |
| [in] | persistent | if true, value will be persistent for bonded devices |
| ble_error_t ble_storage_put_i32 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| int32_t | value, | ||
| bool | persistent | ||
| ) |
Store signed integer value in storage.
key can be an arbitrary value, it's recommended to use values within service attribute handles range to avoid collision with other services or applications.| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [in] | value | value to be stored |
| [in] | persistent | if true, value will be persistent for bonded devices |
| ble_error_t ble_storage_put_u32 | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key, | ||
| uint32_t | value, | ||
| bool | persistent | ||
| ) |
Store unsigned integer value in storage.
key can be an arbitrary value, it's recommended to use values within service attribute handles range to avoid collision with other services or applications.| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| [in] | value | value to be stored |
| [in] | persistent | if true, value will be persistent for bonded devices |
| ble_error_t ble_storage_remove | ( | uint16_t | conn_idx, |
| ble_storage_key_t | key | ||
| ) |
Remove value from storage.
| [in] | conn_idx | connection index |
| [in] | key | storage key (attribute handle) |
| ble_error_t ble_storage_remove_all | ( | ble_storage_key_t | key | ) |
Remove value from storage.
This function removes value in all devices where it is stored.
| [in] | key | storage key (attribute handle) |
| void ble_uuid_create16 | ( | uint16_t | uuid16, |
| att_uuid_t * | uuid | ||
| ) |
Create 16-bit UUID from integer value.
| [in] | uuid16 | value |
| [out] | uuid | UUID |
| bool ble_uuid_equal | ( | const att_uuid_t * | uuid1, |
| const att_uuid_t * | uuid2 | ||
| ) |
Check if two UUIDs are equal.
| [in] | uuid1 | 1st uuid |
| [in] | uuid2 | 2nd uuid |
| void ble_uuid_from_buf | ( | const uint8_t * | buf, |
| att_uuid_t * | uuid | ||
| ) |
Create UUID from buffer.
buf shall have proper length (16 bytes) and endianess (little-endian) Created UUID is 16-bit in case it's Bluetooth UUID or 128-bit otherwise.
| [in] | buf | buffer |
| [out] | uuid | UUID |
| bool ble_uuid_from_string | ( | const char * | str, |
| att_uuid_t * | uuid | ||
| ) |
Create UUID from string.
str shall be UUID in canonical form (aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee) or 16-bit Bluetooth UUID. Created UUID is 16-bit in case it is Bluetooth UUID, otherwise it's 128-bit.
| [in] | str | string |
| [out] | uuid | UUID |
| const char* ble_uuid_to_string | ( | const att_uuid_t * | uuid | ) |
Convert UUID to string.
Convert UUID (16-bit or 128-bit case) to UUID string - (0xaaaa) or canonical form (aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee). The result is pointer to static buffer.
| [in] | uuid | UUID |
| __STATIC_INLINE uint16_t get_u16 | ( | const uint8_t * | buffer | ) |
Get uint16 from buffer.
| [in] | buffer | data buffer |
| __STATIC_INLINE uint16_t get_u16_inc | ( | const uint8_t ** | buffer | ) |
Get uint16 from buffer and increase pointer.
| [in,out] | buffer | data buffer |
| __STATIC_INLINE uint32_t get_u32 | ( | const uint8_t * | buffer | ) |
Get uint32 from buffer.
| [in] | buffer | data buffer |
| __STATIC_INLINE uint32_t get_u32_inc | ( | const uint8_t ** | buffer | ) |
Get uint32 from buffer and increase pointer.
| [in,out] | buffer | data buffer |
| __STATIC_INLINE uint8_t get_u8 | ( | const uint8_t * | buffer | ) |
Get uint8 from buffer.
| [in] | buffer | data buffer |
| __STATIC_INLINE uint8_t get_u8_inc | ( | const uint8_t ** | buffer | ) |
Get uint8 from buffer and increase pointer.
| [in,out] | buffer | data buffer |
| __STATIC_INLINE void put_data_inc | ( | uint8_t ** | buffer, |
| uint16_t | length, | ||
| const void * | data | ||
| ) |
Put data to buffer and increase pointer.
| [in,out] | buffer | data buffer |
| [in] | length | length of data to put |
| [in] | data | data to put |
| __STATIC_INLINE void put_str_inc | ( | uint8_t ** | buffer, |
| const char * | str | ||
| ) |
Put string to buffer and increase pointer.
| [in,out] | buffer | data buffer |
| [in] | str | string to put |
| __STATIC_INLINE void put_u16 | ( | uint8_t * | buffer, |
| uint16_t | value | ||
| ) |
Put uint16 to buffer.
| [in,out] | buffer | data buffer |
| [in] | value | value to put |
| __STATIC_INLINE void put_u16_inc | ( | uint8_t ** | buffer, |
| uint16_t | value | ||
| ) |
Put uint16 to buffer and increase pointer.
| [in,out] | buffer | data buffer |
| [in] | value | value to put |
| __STATIC_INLINE void put_u32 | ( | uint8_t * | buffer, |
| uint32_t | value | ||
| ) |
Put uint32 to buffer.
| [in,out] | buffer | data buffer |
| [in] | value | value to put |
| __STATIC_INLINE void put_u32_inc | ( | uint8_t ** | buffer, |
| uint32_t | value | ||
| ) |
Put uint32 to buffer and increase pointer.
| [in,out] | buffer | data buffer |
| [in] | value | value to put |
| __STATIC_INLINE void put_u8 | ( | uint8_t * | buffer, |
| uint8_t | value | ||
| ) |
Put uint8 to buffer.
| [in,out] | buffer | data buffer |
| [in] | value | value to put |
| __STATIC_INLINE void put_u8_inc | ( | uint8_t ** | buffer, |
| uint8_t | value | ||
| ) |
Put uint8 to buffer and increase pointer.
| [in,out] | buffer | data buffer |
| [in] | value | value to put |
1.8.16