SmartSnippets DA1459x SDK
Data Structures | Macros | Typedefs | Enumerations | Functions
ble_gap.h File Reference

BLE GAP API. More...

#include <stddef.h>
#include <stdint.h>
#include "co_version.h"
#include "co_bt.h"
#include "ble_att.h"
#include "ble_common.h"
#include "ble_config.h"

Go to the source code of this file.

Data Structures

struct  gap_adv_ad_struct_t
 
struct  gap_device_t
 
union  gap_device_filter_data_t
 
struct  gap_sec_key_t
 
struct  gap_chnl_map
 
struct  gap_conn_params_t
 
struct  gap_scan_params_t
 
struct  ble_evt_gap_connected_t
 
struct  ble_evt_gap_disconnected_t
 
struct  ble_evt_gap_disconnect_failed_t
 
struct  ble_evt_gap_conn_param_update_req_t
 
struct  ble_evt_gap_conn_param_update_completed_t
 
struct  ble_evt_gap_conn_param_updated_t
 
struct  ble_evt_gap_adv_completed_t
 
struct  ble_evt_gap_adv_report_t
 
struct  ble_evt_gap_scan_completed_t
 
struct  ble_evt_gap_pair_req_t
 
struct  ble_evt_gap_pair_completed_t
 
struct  ble_evt_gap_security_request_t
 
struct  ble_evt_gap_passkey_notify_t
 
struct  ble_evt_gap_passkey_request_t
 
struct  ble_evt_gap_address_resolved_t
 
struct  ble_evt_gap_address_resolution_failed_t
 
struct  ble_evt_gap_sec_level_changed_t
 
struct  ble_evt_gap_set_sec_level_failed_t
 
struct  ble_evt_gap_data_length_changed_t
 
struct  ble_evt_gap_data_length_set_failed_t
 
struct  ble_evt_gap_connection_completed_t
 
struct  ble_evt_gap_ltk_missing_t
 
struct  ble_evt_gap_air_op_bdaddr_t
 
struct  ble_evt_gap_peer_version_t
 
struct  ble_evt_gap_peer_features_t
 

Macros

#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)
 

Typedefs

typedef struct gap_chnl_map gap_chnl_map_t
 

Enumerations

enum  gap_appearance_t
 
enum  gap_data_type_t {
  GAP_DATA_TYPE_FLAGS = 0x01, GAP_DATA_TYPE_UUID16_LIST_INC = 0x02, GAP_DATA_TYPE_UUID16_LIST = 0x03, GAP_DATA_TYPE_UUID32_LIST_INC = 0x04,
  GAP_DATA_TYPE_UUID32_LIST = 0x05, GAP_DATA_TYPE_UUID128_LIST_INC = 0x06, GAP_DATA_TYPE_UUID128_LIST = 0x07, GAP_DATA_TYPE_SHORT_LOCAL_NAME = 0x08,
  GAP_DATA_TYPE_LOCAL_NAME = 0x09, GAP_DATA_TYPE_TX_POWER_LEVEL = 0x0A, GAP_DATA_TYPE_CLASS_OF_DEVICE = 0x0D, GAP_DATA_TYPE_SP_HASH_C = 0x0E,
  GAP_DATA_TYPE_SP_RANDOMIZER_R = 0x0F, GAP_DATA_TYPE_TK_VALUE = 0x10, GAP_DATA_TYPE_OOB_FLAGS = 0x11, GAP_DATA_TYPE_SLAVE_CONN_INTV = 0x12,
  GAP_DATA_TYPE_UUID16_SOLIC = 0x14, GAP_DATA_TYPE_UUID128_SOLIC = 0x15, GAP_DATA_TYPE_UUID16_SVC_DATA = 0x16, GAP_DATA_TYPE_PUBLIC_ADDRESS = 0x17,
  GAP_DATA_TYPE_RANDOM_ADDRESS = 0x18, GAP_DATA_TYPE_APPEARANCE = 0x19, GAP_DATA_TYPE_ADV_INTERVAL = 0x1A, GAP_DATA_TYPE_LE_BT_ADDR = 0x1B,
  GAP_DATA_TYPE_LE_ROLE = 0x1C, GAP_DATA_TYPE_SPAIR_HASH = 0x1D, GAP_DATA_TYPE_SPAIR_RAND = 0x1E, GAP_DATA_TYPE_UUID32_SOLIC = 0x1F,
  GAP_DATA_TYPE_UUID32_SVC_DATA = 0x20, GAP_DATA_TYPE_UUID128_SVC_DATA = 0x21, GAP_DATA_TYPE_LE_SEC_CONN_CFM_VAL = 0x22, GAP_DATA_TYPE_LE_SEC_CONN_RAND_VAL = 0x23,
  GAP_DATA_TYPE_URI = 0x24, GAP_DATA_TYPE_INDOOR_POSITIONING = 0x25, GAP_DATA_TYPE_TRANSPORT_DISC_DATA = 0x26, GAP_DATA_TYPE_LE_SUPP_FEATURES = 0x27,
  GAP_DATA_TYPE_CHNL_MAP_UPD_IND = 0x28, GAP_DATA_TYPE_PB_ADV = 0x29, GAP_DATA_TYPE_MESH_MESSAGE = 0x2A, GAP_DATA_TYPE_MESH_BEACON = 0x2B,
  GAP_DATA_TYPE_INFO_DATA_3D = 0x3D, GAP_DATA_TYPE_MANUFACTURER_SPEC = 0xFF
}
 
enum  gap_tx_power_t
 
enum  ble_evt_gap {
  BLE_EVT_GAP_CONNECTED = BLE_EVT_CAT_FIRST(BLE_EVT_CAT_GAP), BLE_EVT_GAP_ADV_REPORT, BLE_EVT_GAP_DISCONNECTED, BLE_EVT_GAP_DISCONNECT_FAILED,
  BLE_EVT_GAP_ADV_COMPLETED, BLE_EVT_GAP_SCAN_COMPLETED, BLE_EVT_GAP_CONN_PARAM_UPDATE_REQ, BLE_EVT_GAP_CONN_PARAM_UPDATED,
  BLE_EVT_GAP_PAIR_REQ, BLE_EVT_GAP_PAIR_COMPLETED, BLE_EVT_GAP_SECURITY_REQUEST, BLE_EVT_GAP_PASSKEY_NOTIFY,
  BLE_EVT_GAP_PASSKEY_REQUEST, BLE_EVT_GAP_SEC_LEVEL_CHANGED, BLE_EVT_GAP_ADDRESS_RESOLVED, BLE_EVT_GAP_SET_SEC_LEVEL_FAILED,
  BLE_EVT_GAP_CONN_PARAM_UPDATE_COMPLETED, BLE_EVT_GAP_DATA_LENGTH_CHANGED, BLE_EVT_GAP_DATA_LENGTH_SET_FAILED, BLE_EVT_GAP_CONNECTION_COMPLETED,
  BLE_EVT_GAP_NUMERIC_REQUEST, BLE_EVT_GAP_ADDRESS_RESOLUTION_FAILED, BLE_EVT_GAP_LTK_MISSING, BLE_EVT_GAP_AIR_OP_BDADDR,
  BLE_EVT_GAP_PEER_VERSION, BLE_EVT_GAP_PEER_FEATURES
}
 GAP events. More...
 
enum  gap_device_filter_t {
  GAP_DEVICE_FILTER_ALL, GAP_DEVICE_FILTER_CONNECTED, GAP_DEVICE_FILTER_BONDED, GAP_DEVICE_FILTER_ADDRESS,
  GAP_DEVICE_FILTER_CONN_IDX
}
 
enum  gap_role_t {
  GAP_NO_ROLE = 0x00, GAP_OBSERVER_ROLE = 0x01, GAP_BROADCASTER_ROLE = 0x02, GAP_CENTRAL_ROLE = 0x04,
  GAP_PERIPHERAL_ROLE = 0x08, GAP_ALL_ROLES = (GAP_OBSERVER_ROLE|GAP_BROADCASTER_ROLE|GAP_CENTRAL_ROLE|GAP_PERIPHERAL_ROLE)
}
 
enum  gap_air_op_t { GAP_AIR_OP_ADV = 0x01, GAP_AIR_OP_SCAN = 0x02, GAP_AIR_OP_INITIATE = 0x04 }
 
enum  gap_conn_mode_t { GAP_CONN_MODE_NON_CONN, GAP_CONN_MODE_UNDIRECTED, GAP_CONN_MODE_DIRECTED, GAP_CONN_MODE_DIRECTED_LDC }
 
enum  gap_disc_mode_t { GAP_DISC_MODE_NON_DISCOVERABLE, GAP_DISC_MODE_GEN_DISCOVERABLE, GAP_DISC_MODE_LIM_DISCOVERABLE, GAP_DISC_MODE_BROADCASTER }
 
enum  gap_adv_chnl_t { GAP_ADV_CHANNEL_37 = 0x01, GAP_ADV_CHANNEL_38 = 0x02, GAP_ADV_CHANNEL_39 = 0x04 }
 
enum  adv_filt_pol_t { ADV_ALLOW_SCAN_ANY_CONN_ANY, ADV_ALLOW_SCAN_WLIST_CONN_ANY, ADV_ALLOW_SCAN_ANY_CONN_WLIST, ADV_ALLOW_SCAN_WLIST_CONN_WLIST }
 
enum  {
  GAP_ADV_IND, GAP_ADV_DIRECT_IND, GAP_ADV_SCAN_IND, GAP_ADV_NONCONN_IND,
  GAP_SCAN_RSP
}
 
enum  gap_scan_type_t { GAP_SCAN_ACTIVE, GAP_SCAN_PASSIVE }
 
enum  gap_scan_mode_t { GAP_SCAN_GEN_DISC_MODE, GAP_SCAN_LIM_DISC_MODE, GAP_SCAN_OBSERVER_MODE }
 
enum  gap_auth_t { GAP_AUTH_NO_MITM_NO_BOND = 0x00, GAP_AUTH_NO_MITM_BOND = 0x01, GAP_AUTH_MITM_NO_BOND = 0x04, GAP_AUTH_MITM_BOND = 0x05 }
 
enum  gap_sec_level_t { GAP_SEC_LEVEL_1 = 0x00, GAP_SEC_LEVEL_2 = 0x01, GAP_SEC_LEVEL_3 = 0x02, GAP_SEC_LEVEL_4 = 0x03 }
 
enum  gap_io_cap_t {
  GAP_IO_CAP_DISP_ONLY = 0x00, GAP_IO_CAP_DISP_YES_NO = 0x01, GAP_IO_CAP_KEYBOARD_ONLY = 0x02, GAP_IO_CAP_NO_INPUT_OUTPUT = 0x03,
  GAP_IO_CAP_KEYBOARD_DISP = 0x04
}
 
enum  ble_gap_phy_t { BLE_GAP_PHY_1M = 0x01, BLE_GAP_PHY_2M = 0x02, BLE_GAP_PHY_CODED = 0x03 }
 
enum  ble_gap_phy_pref_t { BLE_GAP_PHY_PREF_AUTO = 0x00, BLE_GAP_PHY_PREF_1M = 0x01, BLE_GAP_PHY_PREF_2M = 0x02, BLE_GAP_PHY_PREF_CODED = 0x04 }
 

Functions

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...
 

Detailed Description

BLE GAP API.

Copyright (C) 2015-2023 Renesas Electronics Corporation and/or its affiliates. All rights reserved. Confidential Information.

This software ("Software") is supplied by Renesas Electronics Corporation and/or its affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable, revocable, non-sub-licensable right and license to use the Software, solely if used in or together with Renesas products. You may make copies of this Software, provided this copyright notice and disclaimer ("Notice") is included in all such copies. Renesas reserves the right to change or discontinue the Software at any time without notice.

THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS SOFTWARE.