# Bluetooth Low Energy Stack Abstraction Function Documentation

## GAP_Initialize

void GAP_Initialize()

Initialize GAP environment.

Initialize GAP environment after each GAPM reset.

Location: ble_gap.h:167

## GAP_GetEnv

const GAP_Env_t * GAP_GetEnv()

Get GAP environment.

Initialize GAP environment after each GAPM reset.

Location: ble_gap.h:176

Return

Pointer to GAP environment structure

## GAP_GetProfileAddedTaskId

uint16_t * GAP_GetProfileAddedTaskId()

Get GAP environment added profiles task identifiers.

Location: ble_gap.h:183

Return

Pointer to an array of added profiles task identifiers

## GAP_IsAddrPrivateResolvable

bool GAP_IsAddrPrivateResolvable(const uint8_t * addr, uint8_t addrType)

Check address if its private resolvable.

Location: ble_gap.h:192

Parameters

Direction | Name | Description
--- | --- | ---
in | addr | Pointer to address
in | addrType | Type of address

Return

True if address is private resolvable false otherwise

## GAP_AddAdvData

bool GAP_AddAdvData(bool isExtendedAdv, uint8_t newDataLen, enum gap_ad_type newDataFlag, const uint8_t * newData, uint8_t * resultAdvData, uint8_t * resultAdvDataLen)

Add GAP advertise data.

Add BLE advertisement data and scan response data to buffer

Location: ble_gap.h:207

Parameters

Direction | Name | Description
--- | --- | ---
in | isExtendedAdv | If extended advertising is required
in | newDataLen | Advertisement data length to add
in | newDataFlag | Type of advertisement data
in | newData | Pointer to new advertisement data to add
in | resultAdvData | Pointer to resultant advertisement data buffer
in | resultAdvDataLen | Length of resultant advertisement data

Return

True if new advertisement data is added false otherwise

## GAPM_ResetCmd

void GAPM_ResetCmd(enum gapm_operation operation)

Perform GAPM reset with specified GAPM operation.

Location: ble_gap.h:216

Parameters

Direction | Name | Description
--- | --- | ---
in | operation | GAPM operation code

## GAPM_SoftwareReset

void GAPM_SoftwareReset()

Perform GAPM software reset.

Do software reset using GAPM_RESET operation.

Location: ble_gap.h:223

## GAPM_PlatformReset

void GAPM_PlatformReset()

Perform GAPM platform reset.

Do platform reset using GAPM_PLF_RESET operation.

Location: ble_gap.h:230

## GAPM_SetDevConfigCmd

void GAPM_SetDevConfigCmd(const struct gapm_set_dev_config_cmd * deviceConfig)

Prepare and send set the device configuration.

Set the device configuration such as device role, manage device address type, privacy configuration, GAP/GATT service start, configure data length extension, set specific write permissions in GAP database, enable or not audio features.

Location: ble_gap.h:244

Parameters

Direction | Name | Description
--- | --- | ---
in | deviceConfig | Pointer to constant GAPM set device configuration command

NOTE: : This command is allowed only when no link is established

## GAPM_GetDeviceConfig

const struct gapm_set_dev_config_cmd * GAPM_GetDeviceConfig()

get Device configuration

Get the device configuration such as device role, manage device address type, privacy configuration, GAP/GATT service start, configure data length extension, set specific write permissions in GAP database, enable or not audio features.

Location: ble_gap.h:256

Return

Pointer to constant constant GAPM set device configuration command

## GAPM_ProfileTaskAddCmd

void GAPM_ProfileTaskAddCmd(uint8_t sec_lvl, uint16_t prf_task_id, uint16_t app_task, uint16_t start_hdl, uint8_t * param, uint32_t paramSize)

Prepare and Send GAPM_PROFILE_TASK_ADD_CMD to the Bluetooth stack.

Prepare and send GAPM_PROFILE_TASK_ADD_CMD to the Bluetooth stack to allocate a task for a specific profile (service or client).

Location: ble_gap.h:271

Parameters

Direction | Name | Description
--- | --- | ---
in | sec_lvl | Security level
in | prf_task_id | Profile task identifier of profile to add
in | app_task | Application task number
in | start_hdl | Service start handle (0 for dynamically allocated in attribute database)
in | param | Pointer to parameter value to initialize profile
in | paramSize | Size of parameter

## GAPM_GetProfileAddedCount

uint16_t GAPM_GetProfileAddedCount()

Get number of profiles added by the Bluetooth stack.

Get the GAP environment variable that keeps track of number of added GAPM profiles.

Location: ble_gap.h:281

Return

Number of GAPM profile added successfully

## GAPM_LepsmRegisterCmd

void GAPM_LepsmRegisterCmd(uint16_t le_psm, uint16_t app_task, uint8_t sec_lvl)

Prepare and send GAPM_LEPSM_REGISTER_CMD to the Bluetooth stack.

Prepare and send GAPM_LEPSM_REGISTER_CMD to register an LE protocol/Service multiplexer ID in the device allowing a peer device to create LE credit based connection on it.

Location: ble_gap.h:293

Parameters

Direction | Name | Description
--- | --- | ---
in | le_psm | LE protocol/service multiplexer
in | app_task | Application task number
in | sec_lvl | Security level

## GAPM_GenRandAddrCmd

void GAPM_GenRandAddrCmd(enum random_addr_type rnd_type)

Prepare and send GAPM_GEN_RAND_ADDR_CMD to the Bluetooth stack.

Prepare and send GAPM_LEPSM_REGISTER_CMD to generate a random device address without starting any air operation.

Location: ble_gap.h:303

Parameters

Direction | Name | Description
--- | --- | ---
in | rnd_type | Random address type

## GAPM_ResolvAddrCmd

void GAPM_ResolvAddrCmd(uint8_t conidx, const uint8_t * peerAddr)

Prepare and send GAPM_RESOLV_ADDR_CMD to the Bluetooth stack.

Prepare and send GAPM_RESOLV_ADDR_CMD to resolve a random address using array of IRK exchanged and bonded with device during pairing operation.

Location: ble_gap.h:314

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | peerAddr | Resolvable random address to solve

## GAPM_ActivityCreateAdvCmd

bool GAPM_ActivityCreateAdvCmd(GAPM_ActivityStatus_t * actv_status, enum gapm_own_addr own_addr_type, const struct gapm_adv_create_param * adv_param)

Prepare and send GAPM_ACTIVITY_CREATE_CMD to create an advertising activity.

Prepare and send GAPM_ACTIVITY_CREATE_CMD with operation GAPM_CREATE_ADV_ACTIVITY to create an advertising activity.

Location: ble_gap.h:327

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_status | Pointer to GAPM activity status
in | own_addr_type | Bluetooth device`s own address type
in | adv_param | Pointer to constant advertising parameters structure

Return

False if no activity slot found, true otherwise

## GAPM_ActivityCreateScanCmd

bool GAPM_ActivityCreateScanCmd(GAPM_ActivityStatus_t * actv_status, enum gapm_own_addr own_addr_type)

Prepare and send GAPM_ACTIVITY_CREATE_CMD to create scan activity.

Prepare and send GAPM_ACTIVITY_CREATE_CMD with operation GAPM_CREATE_SCAN_ACTIVITY to create scan activity.

Location: ble_gap.h:341

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_status | Pointer to GAPM activity status
in | own_addr_type | Bluetooth device`s own address type

Return

False if no activity slot found, true otherwise

## GAPM_ActivityCreateInitCmd

bool GAPM_ActivityCreateInitCmd(GAPM_ActivityStatus_t * actv_status, enum gapm_own_addr own_addr_type)

Prepare and send GAPM_ACTIVITY_CREATE_CMD to create an initiating activity.

Prepare and send GAPM_ACTIVITY_CREATE_CMD with operation GAPM_CREATE_INIT_ACTIVITY to create an initiating activity.

Location: ble_gap.h:354

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_status | Pointer to GAPM activity status
in | own_addr_type | Bluetooth device`s own address type

Return

False if no activity slot found, true otherwise

## GAPM_ActivityCreatePeriodSyncCmd

bool GAPM_ActivityCreatePeriodSyncCmd(GAPM_ActivityStatus_t * actv_status, enum gapm_own_addr own_addr_type)

Prepare and send GAPM_ACTIVITY_CREATE_CMD to create a periodic sync activity.

Prepare and send GAPM_ACTIVITY_CREATE_CMD with operation GAPM_CREATE_PERIOD_SYNC_ACTIVITY to create a periodic synchronization activity.

Location: ble_gap.h:367

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_status | Pointer to GAPM activity status
in | own_addr_type | Bluetooth device`s own address type

Return

False if no activity slot found, true otherwise

## GAPM_AdvActivityStart

bool GAPM_AdvActivityStart(uint8_t actv_idx, uint16_t duration, uint8_t max_adv_evt)

Prepare and send GAPM_ACTIVITY_START_CMD to start an advertising activity.

Prepare and send GAPM_ACTIVITY_START_CMD to request the host to start a previously created advertising activity.

Location: ble_gap.h:383

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | duration | Advertising duration (in unit of 10ms). 0 means that advertising continues until the host disables it.
in | max_adv_evt | Maximum number of extended advertising events the controller shall attempt to send prior to terminating the extended advertising

Return

False if no activity slot found, true otherwise

## GAPM_InitActivityStart

bool GAPM_InitActivityStart(uint8_t actv_idx, struct gapm_init_param * initParam)

Prepare and send GAPM_ACTIVITY_START_CMD to start an initiating activity.

Prepare and send GAPM_ACTIVITY_START_CMD to request the host to start previously created initiating activity.

Location: ble_gap.h:395

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | initParam | Pointer to initiating parameters structure

Return

False if no activity slot found, true otherwise

## GAPM_ScanActivityStart

bool GAPM_ScanActivityStart(uint8_t actv_idx, struct gapm_scan_param * scanParam)

Prepare and send GAPM_ACTIVITY_START_CMD to start a scanning activity.

Prepare and send GAPM_ACTIVITY_START_CMD to request the host to start previously created scanning activity.

Location: ble_gap.h:407

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | scanParam | Pointer to scan parameters structure

Return

False if no activity slot found, true otherwise

## GAPM_PerSyncActivityStart

bool GAPM_PerSyncActivityStart(uint8_t actv_idx, struct gapm_per_sync_param * per_sync_param)

Prepare and send GAPM_ACTIVITY_START_CMD to start a periodic sync activity.

Prepare and send GAPM_ACTIVITY_START_CMD to request the host to start previously created periodic synchronization activity.

Location: ble_gap.h:419

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | per_sync_param | Pointer to periodic sync parameters structure

Return

False if no activity slot found, true otherwise

## GAPM_ActivityStartCmd

bool GAPM_ActivityStartCmd(uint8_t actv_idx, union gapm_u_param * u_param)

Prepare and send GAPM_ACTIVITY_START_CMD to start an activity.

Prepare and send GAPM_ACTIVITY_START_CMD to request the host to start previously created activity.

Location: ble_gap.h:431

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | u_param | Pointer to union to containing activity parameters

Return

False if no activity slot found, true otherwise

## GAPM_ActivityStop

bool GAPM_ActivityStop(uint8_t actv_idx)

Prepare and send GAPM_ACTIVITY_STOP_CMD to stop a specified activity.

Prepare and send GAPM_ACTIVITY_STOP_CMD with operation GAPM_STOP_ACTIVITY request the host to stop a specified activity.

Location: ble_gap.h:442

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier

Return

False if activity does not exist, true otherwise

## GAPM_ActivityStopAll

bool GAPM_ActivityStopAll()

Prepare and send GAPM_ACTIVITY_STOP_CMD to stop all existing activities.

Prepare and send GAPM_ACTIVITY_STOP_CMD with operation GAPM_STOP_ALL_ACTIVITIES request the host to stop all existing activities.

Location: ble_gap.h:452

Return

False if activity does not exist, true otherwise

## GAPM_DeleteActivity

bool GAPM_DeleteActivity(uint8_t actv_idx)

Prepare and send GAPM_ACTIVITY_DELETE_CMD to delete a specified activity.

Prepare and send GAPM_ACTIVITY_DELETE_CMD with operation GAPM_DELETE_ACTIVITY to request the host to delete an existing specified activity.

Location: ble_gap.h:463

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier (used only if operation is GAPM_DELETE_ACTIVITY)

Return

False if activity does not exist, true otherwise

## GAPM_DeleteAllActivities

bool GAPM_DeleteAllActivities()

Prepare and send GAPM_ACTIVITY_DELETE_CMD to delete all the activities.

Prepare and send GAPM_ACTIVITY_DELETE_CMD with operation GAPM_DELETE_ALL_ACTIVITIES to request the host to delete all existing activities.

Location: ble_gap.h:473

Return

False if activity does not exist, true otherwise

## GAPM_ActivityStopCmd

bool GAPM_ActivityStopCmd(uint8_t operation, uint8_t actv_idx)

Prepare and send GAPM_ACTIVITY_STOP_CMD to stop a specified activity.

Prepare and send GAPM_ACTIVITY_STOP_CMD with operation GAPM_STOP_ACTIVITY request the host to stop a specified activity.

Location: ble_gap.h:485

Parameters

Direction | Name | Description
--- | --- | ---
in | operation | GAPM operation code [GAPM_STOP_ACTIVITY or GAPM_STOP_ALL_ACTIVITIES]
in | actv_idx | Activity identifier (used only if operation is GAPM_STOP_ACTIVITY)

Return

False if activity does not exist, true otherwise

## GAPM_DeleteActivityCmd

bool GAPM_DeleteActivityCmd(uint8_t operation, uint8_t actv_idx)

Prepare and send GAPM_ACTIVITY_DELETE_CMD to delete activity/activities.

Prepare and send GAPM_ACTIVITY_DELETE_CMD to request the host to delete either an activity or all currently existing activities.

Location: ble_gap.h:497

Parameters

Direction | Name | Description
--- | --- | ---
in | operation | GAPM operation code [GAPM_DELETE_ACTIVITY or GAPM_DELETE_ALL_ACTIVITIES]
in | actv_idx | Activity identifier (used only if operation is GAPM_DELETE_ACTIVITY)

Return

False if activity does not exist, true otherwise

## GAPM_SetAdvDataCmd

bool GAPM_SetAdvDataCmd(uint8_t operation, uint8_t actv_idx, uint8_t length, uint8_t * data)

Prepare and send GAPM_SET_ADV_DATA_CMD to set an advertising data or scan response data or periodic advertising data.

Prepare and send GAPM_SET_ADV_DATA_CMD to either set an advertising data or the scan response data or the periodic advertising data for a given advertising activity identified by activity ID.

Location: ble_gap.h:514

Parameters

Direction | Name | Description
--- | --- | ---
in | operation | GAPM operation code (GAPM_SET_ADV_DATA or GAPM_SET_SCAN_RSP_DATA or GAPM_SET_PERIOD_ADV_DATA)
in | actv_idx | Activity identifier
in | length | Length of data
in | data | Pointer to data

Return

False if activity slot not found, true otherwise

## GAPM_MsgHandler

void GAPM_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Message handler for GAPM events.

This function receives GAPM events from he Bluetooth stack and perform actions accordingly. It initialize GAP and GATT at reset and also manages GAPM states and the GAP environment.

Location: ble_gap.h:527

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant parameter
in | dest_id | Constant destination kernel identifier
in | src_id | Constant source kernel identifier

## GAPC_ParamUpdateCmd

void GAPC_ParamUpdateCmd(uint8_t conidx, uint16_t intv_min, uint16_t intv_max, uint16_t latency, uint16_t time_out, uint16_t ce_len_min, uint16_t ce_len_max)

Prepare and send GAPC_PARAM_UPDATE_CMD to perform an update on parameters.

Prepare and send GAPC_PARAM_UPDATE_CMD to perform an update of connection parameters.

Location: ble_gap.h:543

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | intv_min | Minimum of connection interval (value = intv_max * 1.25 ms)
in | intv_max | Maximum of connection interval (value = intv_max * 1.25 ms)
in | latency | connection latency
in | time_out | Link supervision timeout (value = time_out * 10 ms)
in | ce_len_min | Minimum CE length (value = ce_len_min * 0.625 ms)
in | ce_len_max | Maximum CE length (value = ce_len_min * 0.625 ms)

## GAPC_ParamUpdateCfm

void GAPC_ParamUpdateCfm(uint8_t conidx, bool accept, uint16_t ce_len_min, uint16_t ce_len_max)

Prepare and send GAPC_PARAM_UPDATE_CFM to accept or reject connection parameters.

Prepare and send GAPC_PARAM_UPDATE_CFM to accept or reject connection parameters proposed by the peer device.

Location: ble_gap.h:557

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | accept | Accept(0x01) or reject(0x00) slave connection parameters
in | ce_len_min | Minimum CE length (value = ce_len_min * 0.625 ms)
in | ce_len_max | Maximum CE length (value = ce_len_min * 0.625 ms)

## GAPC_ConnectionCfm

void GAPC_ConnectionCfm(uint8_t conidx, struct gapc_connection_cfm * param)

Prepare and send GAPC_CONNECTION_CFM in a response to connection request.

Prepare and send GAPC_CONNECTION_CFM in a response to connection request from the peer to enable local attribute tasks and security manager for the connection.

Location: ble_gap.h:569

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | param | Pointer to GAPC connection confirmation structure

## GAPC_DisconnectCmd

void GAPC_DisconnectCmd(uint8_t conidx, uint8_t reason)

Prepare and send GAPC_DISCONNECT_CMD to disconnect link.

Prepare and send GAPC_DISCONNECT_CMD to request a disconnection of the link.

Location: ble_gap.h:580

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | reason | Reason for disconnection

## GAPC_IsConnectionActive

bool GAPC_IsConnectionActive(uint8_t conidx)

Check if the specified connection is active.

Check if specified connection ID is active or not.

Location: ble_gap.h:591

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier

Return

True if given connection id have valid GAP connection handle, false otherwise

## GAPC_DisconnectAll

void GAPC_DisconnectAll(uint8_t reason)

Prepare and send GAPC_DISCONNECT_CMD to disconnect all the links.

Prepare and send GAPC_DISCONNECT_CMD to request disconnection for each active connections.

Location: ble_gap.h:601

Parameters

Direction | Name | Description
--- | --- | ---
in | reason | Reason for disconnection

## GAPC_ConnectionCount

uint8_t GAPC_ConnectionCount()

Get the number of active connection count.

Location: ble_gap.h:608

Return

Number of active connection count

## GAPC_MasterConnectionCount

uint8_t GAPC_MasterConnectionCount()

Get the master connection count.

Location: ble_gap.h:615

Return

Number of master connection count

## GAPC_SlaveConnectionCount

uint8_t GAPC_SlaveConnectionCount()

Get the slave connection count.

Location: ble_gap.h:622

Return

Number of slave connection count

## GAPC_GetConnectionInfo

const struct gapc_connection_req_ind * GAPC_GetConnectionInfo(uint8_t conidx)

Get the connection information of a specified connection ID.

Get GAPC connection information of a specified connection ID.

Location: ble_gap.h:632

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier

Return

Pointer to constant structure gapc_connection_req_ind

## GAPC_GetDevInfoCfm_Name

void GAPC_GetDevInfoCfm_Name(uint8_t conidx, const char * devName)

Prepare and send GAPC_GET_DEV_INFO_CFM to send the device name.

Prepare and send GAPC_GET_DEV_INFO_CFM to send the device name information to the peer device.

Location: ble_gap.h:643

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | devName | Pointer to device name

## GAPC_GetDevInfoCfm_Appearance

void GAPC_GetDevInfoCfm_Appearance(uint8_t conidx, uint16_t appearance)

Prepare and send GAPC_GET_DEV_INFO_CFM to send the device appearance.

Prepare and send GAPC_GET_DEV_INFO_CFM to send the device appearance icon to the peer device.

Location: ble_gap.h:654

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | appearance | Appearance icon

## GAPC_GetDevInfoCfm_SlvPrefParams

void GAPC_GetDevInfoCfm_SlvPrefParams(uint8_t conidx, uint16_t con_intv_min, uint16_t con_intv_max, uint16_t slave_latency, uint16_t conn_timeout)

Prepare and send GAPC_GET_DEV_INFO_CFM to send device slave preferred parameters.

Prepare and send GAPC_GET_DEV_INFO_CFM to to send device slave preferred parameters to peer device.

Location: ble_gap.h:668

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | con_intv_min | Minimum connection interval (value = con_intv_min * 1.25 ms)
in | con_intv_max | Maximum connection interval (value = con_intv_max * 1.25 ms)
in | slave_latency | Slave latency
in | conn_timeout | Connection supervision timeout (value = conn_timeout * 10 ms)

## GAPC_GetDevInfoCfm

void GAPC_GetDevInfoCfm(uint8_t conidx, uint8_t req, const union gapc_dev_info_val * dat)

Prepare and send GAPC_GET_DEV_INFO_CFM to send requested information.

Prepare and send GAPC_GET_DEV_INFO_CFM to send requested information to the peer device.

Location: ble_gap.h:682

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | req | Requested information
in | dat | Pointer to constant union GAPC device information value

## GAPC_SetDevInfoCfm

bool GAPC_SetDevInfoCfm(uint8_t conidx, uint8_t req, bool accept)

Prepare and send GAPC_SET_DEV_INFO_CFM to confirm if the requested device information was written.

Prepare and send GAPC_SET_DEV_INFO_CFM to provide confirmation to the Bluetooth stack if the requested device information was written.

Location: ble_gap.h:697

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | req | Requested information (GAPC_DEV_NAME or GAPC_DEV_APPEARANCE)
in | accept | True if the write request has been approved, false otherwise

Return

False if req is not GAPC_DEV_NAME or GAPC_DEV_APPEARANCE, true otherwise

## GAPC_BondCfm

void GAPC_BondCfm(uint8_t conidx, enum gapc_bond request, bool accept, const union gapc_bond_cfm_data * data)

GAPC bond and encryption operations.

Prepare and send GAPC_BOND_CFM to send confirmation to a bond request Prepare and send GAPC_BOND_CFM to provide confirmation of the receipt of a GAPC_BOND_REQ_IND message.

Location: ble_gap.h:714

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | request | Bond request type
in | accept | Accept(0x01) or reject(0x00) request
in | data | Pointer to constant GAPC bond confirmation data union

## GAPC_EncryptCmd

void GAPC_EncryptCmd(uint8_t conidx, uint16_t ediv, const uint8_t * randnb, const uint8_t * ltk, uint8_t key_size)

Prepare and send GAPC_ENCRYPT_CMD to request encrypting the connection link.

Prepare and send GAPC_ENCRYPT_CMD as the master to request initiation of the link encryption procedure.

Location: ble_gap.h:729

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | ediv | Encryption diversifier
in | randnb | Pointer to constant random number
in | ltk | Pointer to constant long term key
in | key_size | Size of LTK key

## GAPC_EncryptCfm

void GAPC_EncryptCfm(uint8_t conidx, bool found, const uint8_t * ltk, uint8_t key_size)

Prepare and send GAPC_ENCRYPT_CFM to confirm an encryption request.

Prepare and send GAPC_ENCRYPT_CFM to provide confirmation of the receipt of a GAPC_ENCRYPY_REQ_IND message.

Location: ble_gap.h:743

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | found | Nonzero if LTK is found for peer device, zero otherwise
in | ltk | Pointer to constant long term key
in | key_size | Size of LTK key

## GAPC_IsBonded

bool GAPC_IsBonded(uint8_t conidx)

Check if the connection is bonded.

Check if the specified connection ID is active and if it has a valid bond state.

Location: ble_gap.h:753

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier

Return

True if connection is active and it has valid bond state, false otherwise

## GAPC_GetBondInfo

const BondInfo_t * GAPC_GetBondInfo(uint8_t conidx)

Get bond information for the connection.

Get bond information for a specified connection ID.

Location: ble_gap.h:764

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier

Return

Pointer to constant bond information structure if connection is active and its bonded, NULL otherwise

## GAPC_BondCmd

void GAPC_BondCmd(uint8_t conidx, const struct gapc_pairing * pairing)

Prepare and send GAPC_BOND_CMD to initiate a bond procedure.

Prepare and send GAPC_BOND_CMD to the master of the link in order to initiate the bond procedure.

Location: ble_gap.h:775

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | pairing | Pointer to constant structure pairing information

## GAPC_AddRecordToBondList

uint16_t GAPC_AddRecordToBondList(uint8_t conidx)

Add record to bond list.

Add device with a specified connection ID to bond list.

Location: ble_gap.h:785

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier

Return

Non-zero if successful, zero otherwise

## GAPC_MsgHandler

void GAPC_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

GAPC message handler.

Receives GAPC events from the Bluetooth stack and perform actions accordingly.

Location: ble_gap.h:797

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant parameter
in | dest_id | Constant destination kernel identifier
in | src_id | Constant source kernel identifier

## GAPM_ListSetWlCmd

void GAPM_ListSetWlCmd(uint8_t operation, uint8_t nb, struct gap_bdaddr * devices_wl)

Prepare and send GAPM_LIST_SET_CMD to set the white list content.

Prepare and send GAPM_LIST_SET_CMD to set the content of the white list.

Location: ble_gap.h:810

Parameters

Direction | Name | Description
--- | --- | ---
in | operation | GAPM operation code to set the content of white list
in | nb | Number of entries to be added in the list
in | devices_wl | Pointer to structure containing list of addresses to be added in the white list

## GAPM_ListSetRalCmd

void GAPM_ListSetRalCmd(uint8_t operation, uint8_t nb, struct gap_ral_dev_info * rl_devinfo)

Prepare and send GAPM_LIST_SET_CMD to set the resolving list content.

Prepare and send GAPM_LIST_SET_CMD to set the content of the resolving list.

Location: ble_gap.h:823

Parameters

Direction | Name | Description
--- | --- | ---
in | operation | GAPM operation code to set the content of white list
in | nb | Number of entries to be added in the list
in | rl_devinfo | Pointer to structure containing list of addresses to be added in the resolving list

## GAPM_IsIRKValid

bool GAPM_IsIRKValid(const BondInfo_t * bond_info)

Check if IRK is valid.

Function checks if a valid IRK has been previously exchanged or not.

Location: ble_gap.h:834

Parameters

Direction | Name | Description
--- | --- | ---
in | bond_info | Pointer to constant bond information

Return

True if irk_exchanged in the specified bond_info is nonzero, false otherwise

## WhiteList_ResolvableList_Update

bool WhiteList_ResolvableList_Update()

Update the white list and the resolve List.

Copies the addresses of the devices in the bond list and updates them in the Bluetooth stack's white list and the resolvable list (if applicable).

Location: ble_gap.h:842

## GAPM_GetWhitelistNumDev

uint16_t GAPM_GetWhitelistNumDev()

Get number of devices in whitelist.

Get the variable that keeps track of number of devices added to whitelist.

Location: ble_gap.h:851

Return

Number of devices in whitelist

## GAPM_SetWhitelistNumDev

void GAPM_SetWhitelistNumDev()

Set the number of devices in whitelist.

Set the GAPM variable that keeps track of number of devices added to whitelist to value.

Location: ble_gap.h:860

Return

None

## GAPC_SetPhyCmd

void GAPC_SetPhyCmd(uint8_t conidx, uint8_t rx_rate, uint8_t tx_rate, uint8_t preferredRate)

GAPC PHY management operations.

Prepare and send GAPC_SET_PHY_CMD to set the preferred PHY Prepare and send GAPC_SET_PHY_CMD to set the preferred PHY for current active link.

Location: ble_gap.h:877

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | rx_rate | Preferred LE PHYs for reception
in | tx_rate | Preferred LE PHYs for transmission
in | preferredRate | Preferred coding scheme for LE coded

## GAPC_CteTxCfgCmd

void GAPC_CteTxCfgCmd(uint8_t conidx, uint8_t cte_type, uint8_t ant_pattern_len, uint8_t * ant_id)

GAPC constant Tone extension operations.

Prepare and send GAPC_CTE_TX_CFG_CMD to configure CTE TX Prepare and send GAPC_CTE_TX_CFG_CMD to configure constant tone extension transmission.

Location: ble_gap.h:895

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | cte_type | CTE types
in | ant_pattern_len | Length of switching pattern
in | ant_id | Pointer to antenna IDs

## GAPC_CteRxCfgCmd

void GAPC_CteRxCfgCmd(uint8_t conidx, uint8_t slot_dur, uint8_t ant_pattern_len, uint8_t * ant_id, bool sample_en)

Prepare and send GAPC_CTE_RX_CFG_CMD to configure CTE RX.

Prepare and send GAPC_CTE_RX_CFG_CMD to configure constant tone extension reception.

Location: ble_gap.h:910

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | slot_dur | Slot durations (1: 1us, 2: 2us)
in | ant_pattern_len | Length of switching pattern
in | ant_id | Pointer to antenna IDs
in | sample_en | Enable or disable sampling

## GAPC_CteReqCtrlCmd

void GAPC_CteReqCtrlCmd(uint8_t conidx, uint8_t cte_type, uint8_t cte_len, uint8_t cte_interval, bool enable)

Prepare and send GAPC_CTE_REQ_CTRL_CMD to control CTE requests.

Prepare and send GAPC_CTE_REQ_CTRL_CMD to control constant tone extension requests.

Location: ble_gap.h:925

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | cte_type | CTE types
in | cte_len | Request CTE length (in 8us unit)
in | cte_interval | CTE request interval (in no of connection events)
in | enable | Enable or disable TX/RX CTE

## GAPC_CteRspCtrlCmd

void GAPC_CteRspCtrlCmd(uint8_t conidx, bool enable)

Prepare and send GAPC_CTE_RSP_CTRL_CMD to control CTE reception.

Prepare and send GAPC_CTE_RSP_CTRL_CMD to control constant tone extension reception.

Location: ble_gap.h:937

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | enable | Enable or disable TX/RX CTE

## GAPC_GetInfoCmd

void GAPC_GetInfoCmd(uint8_t conidx, uint8_t operation)

GAPC local and peer device information operations.

Prepare and send GAPC_GET_INFO_CMD to get the peer information Prepare and send GAPC_GET_INFO_CMD to get information about the peer device or about the current active link.

Location: ble_gap.h:952

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection identifier
in | operation | GAPC requested operation

## GAPM_PerAdvCteTxCmd

bool GAPM_PerAdvCteTxCmd(uint8_t actv_idx, bool enable)

Prepare and send GAPM_PER_ADV_CTE_TX_CTL_CMD to control CTE transmission in a periodic advertising activity.

Location: ble_gap.h:962

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | enable | Enable or disable CTE transmission

Return

False if activity slot is equal to max number of activity, true otherwise

## GAPM_PerAdvReportCtrlCmd

bool GAPM_PerAdvReportCtrlCmd(uint8_t actv_idx, bool enable)

Prepare and send GAPM_PER_ADV_REPORT_CTRL_CMD to control reception of periodic advertising report in a periodic advertising sync activity.

Location: ble_gap.h:972

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | enable | Enable or disable reception of periodic advertising report

Return

False if activity slot is equal to max number of activity, true otherwise

## GAPM_PerSyncIQSamplingCtrlCmd

bool GAPM_PerSyncIQSamplingCtrlCmd(uint8_t actv_idx, uint8_t slot_dur, uint8_t max_sample_cte, uint8_t ant_pattern_len, uint8_t * ant_id, bool enable)

Prepare and send GAPM_PER_SYNC_IQ_SAMPLING_CTRL_CMD to control capturing IQ samples from the constant tone extension of periodic advertising packets.

Location: ble_gap.h:987

Parameters

Direction | Name | Description
--- | --- | ---
in | actv_idx | Activity identifier
in | slot_dur | Slot durations (1: 1us | 2: 2us)
in | max_sample_cte | Maximum sampled CTEs
in | ant_pattern_len | Length of switching pattern
in | ant_id | Pointer to antenna IDs
in | enable | Enable IQ sampling

Return

False if activity slot is equal to max number of activity, true otherwise

## GATT_Initialize

void GATT_Initialize()

GATT initialization.

Initialize the GATT environment.

Location: ble_gatt.h:189

## GATT_GetEnv

const GATT_Env_t * GATT_GetEnv()

Get GATT environment.

Function gets a reference to the internal GATT environment structure.

Location: ble_gatt.h:198

Return

A constant pointer to GATT_Env_t

## GATT_SetEnvData

void GATT_SetEnvData(uint16_t * disc_svc_count, cust_svc_desc * custom_service_db, uint8_t max_cust_svc_num)

Set GATT environment data.

Set the GATT environment discovery service counter (array), custom service database and maximum number of custom services.

Location: ble_gatt.h:210

Parameters

Direction | Name | Description
--- | --- | ---
in | disc_svc_count | Pointer to discovered services count
in | custom_service_db | Pointer to custom service database
in | max_cust_svc_num | Maximum number of custom services

## GATT_GetMaxCustomServiceNumber

uint16_t GATT_GetMaxCustomServiceNumber()

Get the maximum number of custom services in GATT.

Function gets the maximum number of custom services in GATT environment.

Location: ble_gatt.h:220

Return

max_cust_svc_num maximum number of custom services

## GATTM_GetServiceAddedCount

uint16_t GATTM_GetServiceAddedCount()

Get GATT added services count.

Function gets number of GATT services that have been added.

Location: ble_gatt.h:229

Return

the number of GATT services that have been added

## GATTM_ResetServiceAttributeDatabaseID

void GATTM_ResetServiceAttributeDatabaseID()

Resets GATT services attribute database ID.

Function resets GATT services attribute database ID. This should be called before re-adding the attribute databases via

Location: ble_gatt.h:238

GATTM_AddAttributeDatabase() without complete system reset.

## GATTM_AddAttributeDatabase

void GATTM_AddAttributeDatabase(const struct att_db_desc * att_db, uint16_t att_db_len)

Add service and attributes to the Bluetooth stack.

Prepare and send GATTM_ADD_SVC_REQ to add services/characteristics into the Bluetooth stack database.

Location: ble_gatt.h:250

Parameters

Direction | Name | Description
--- | --- | ---
in | att_db | Pointer to constant custom service attribute database
in | att_db_len | Number of elements in the att_db array

NOTE: Triggers a GATTM_ADD_SVC_RSP for every service added.

## GATTM_GetHandle

uint16_t GATTM_GetHandle(uint8_t cs_svc_number, uint16_t attidx)

Get the handle for an attribute.

Returns the stack database handle for a certain attribute index.

Location: ble_gatt.h:265

Parameters

Direction | Name | Description
--- | --- | ---
in | cs_svc_number | Custom service number related to attribute
in | attidx | Attribute index

Return

Handle value, in case of success or 0, in case the attidx or the start handle is invalid

NOTE: The user has used GATT_AddAttributeDatabase() to construct the database and the stack has already finished adding services to the database.

## GATTM_MsgHandler

void GATTM_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Handle GATTM messages.

Message handler for the GATT manager

Location: ble_gatt.h:277

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameter (unused)
in | dest_id | Destination task identifier
in | src_id | Source task identifier

## GATTC_Initialize

void GATTC_Initialize()

GATTC initialization.

Initialize GATTC

Location: ble_gatt.h:285

## GATTC_DiscByUUIDSvc

void GATTC_DiscByUUIDSvc(uint8_t conidx, uint8_t uuid, uint8_t uuid_len, uint16_t start_hdl, uint16_t end_hdl)

GATTC services discovery by UUID.

Start a discovery by UUID(GATTC_DISC_BY_UUID_SVC) in a specified handle range.

Location: ble_gatt.h:299

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
| uuid |
in | uuid_len | UUID length (ATT_UUID_16_LEN or ATT_UUID_32_LEN or ATT_UUID_128_LEN)
in | start_hdl | Start handle of a discovery range
in | end_hdl | End handle of a discovery range

## GATTC_DiscAllSvc

void GATTC_DiscAllSvc(uint8_t conidx, uint16_t start_hdl, uint16_t end_hdl)

GATTC all services discovery.

Start a discovery for all services in a specified handle range.

Location: ble_gatt.h:311

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | start_hdl | Start handle of discovery range
in | end_hdl | End handle of discovery range

## GATTC_DiscAllChar

void GATTC_DiscAllChar(uint8_t conidx, uint16_t start_hdl, uint16_t end_hdl)

GATTC all characteristics discovery.

Start a characteristic discovery for all characteristics in a specified handle range.

Location: ble_gatt.h:323

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | start_hdl | Start handle of discovery range
in | end_hdl | End handle of discovery range

## GATTC_SendEvtCmd

void GATTC_SendEvtCmd(uint8_t conidx, uint8_t operation, uint16_t seq_num, uint16_t handle, uint16_t length, uint8_t * value)

GATTC send event.

Send GATTC characteristic notification or indication event.

Location: ble_gatt.h:337

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | operation | GATTC_NOTIFY or GATTC_INDICATE
in | seq_num | Operation sequence number
in | handle | Characteristic handle
in | length | Attribute length
in | value | Pointer to attribute data value

## GATTC_SendEvtCfm

void GATTC_SendEvtCfm(uint8_t conidx, uint16_t handle)

GATTC send event confirmation.

Send a GATTC indication event confirmation.

Location: ble_gatt.h:348

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | handle | Characteristic handle

## GATTC_MtuExchange

void GATTC_MtuExchange(uint8_t conidx)

Prepare and send GATTC_EXC_MTU_CMD to start MTU exchange procedure.

Prepare and send GATTC_EXC_MTU_CMD to start MTU exchange procedure.

Location: ble_gatt.h:357

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index

## GATTC_ReadReqInd

void GATTC_ReadReqInd(ke_msg_id_t const msg_id, struct gattc_read_req_ind const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

GATTC handle read request indication.

Handle a received read request indication from GATT controller.

Location: ble_gatt.h:371

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameters (in format of structure gattc_read_req_ind)
in | dest_id | Destination task identifier
in | src_id | Source task identifier

NOTE: Indicate if the message was consumed, compare with KE_MSG_CONSUMED

## GATTC_WriteReqInd

void GATTC_WriteReqInd(ke_msg_id_t const msg_id, struct gattc_write_req_ind const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

GATTC handle write request indication.

Handle a received write request indication from GATT controller.

Location: ble_gatt.h:387

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameters (in format of structure gattc_write_req_ind)
in | dest_id | Destination task identifier
in | src_id | Source task identifier

NOTE: Indicate if the message was consumed, compare with KE_MSG_CONSUMED

## GATTC_AttInfoReqInd

void GATTC_AttInfoReqInd(ke_msg_id_t const msg_id, struct gattc_read_req_ind const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

GATTC request attribute information.

Request an attribute info indication to be passed to the upper layers of the Bluetooth stack. Could also be triggered during prepare write to check if attribute modification is authorized by profile/application or not and to get current attribute length.

Location: ble_gatt.h:406

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameters (in format of structure gattc_read_req_ind)
in | dest_id | Destination task identifier
in | src_id | Source task identifier

NOTE: Indicate if the message was consumed, compare with KE_MSG_CONSUMED

## GATTC_MsgHandler

void GATTC_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Handle GATTM messages.

Message handler for GATT manager messages received from kernel

Location: ble_gatt.h:421

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameter (unused)
in | dest_id | Destination task identifier
in | src_id | Source task identifier

NOTE: Indicate if the message was consumed, compare with KE_MSG_CONSUMED

## Device_BLE_Public_Address_Read

void Device_BLE_Public_Address_Read(uint32_t ble_addr_location)

Read the Bluetooth public address to ble_public_addr.

Read the Bluetooth public address from a given location and save it to ble_public_addr (array).

Location: ble_protocol_support.h:77

Parameters

Direction | Name | Description
--- | --- | ---
in | ble_addr_location | Location to read value from

## Device_BLE_Param_Get

uint8_t Device_BLE_Param_Get(uint8_t param_id, uint8_t * lengthPtr, uint8_t * buf)

Read BLE device parameters.

Read bluetooth low energy parameters, security keys, and channel assessment parameters that are provided by the application or NVR3.

Location: ble_protocol_support.h:90

Parameters

Direction | Name | Description
--- | --- | ---
in | param_id | Parameter identifier
in | lengthPtr | Pointer to the length of parameter
in | buf | Pointer to returned value

Return

Indicate if the requested parameter is provided by application

## rand_func

int rand_func()

Generate a pseudo-random number.

Location: ble_protocol_support.h:97

Return

A pseudo-random number

## set_app_rand_func

void set_app_rand_func(int(*)(void) func)

Sets random number generator function to be used by the BLE stack when calling rand_func()

Location: ble_protocol_support.h:105

Parameters

Direction | Name | Description
--- | --- | ---
in | func | Function containing random number generator

## srand_func

void srand_func(uint32_t seed)

Seeds pseudo-random number generator used by function rand()

Location: ble_protocol_support.h:112

Parameters

Direction | Name | Description
--- | --- | ---
in | seed | Seed value

## set_app_rand_seed_val

void set_app_rand_seed_val(uint32_t seed)

Sets seed value to be used by the BLE stack when calling srand_func()

Location: ble_protocol_support.h:119

Parameters

Direction | Name | Description
--- | --- | ---
in | seed | Seed value

## default_rf_rssi_func

int8_t default_rf_rssi_func(uint8_t rssi_reg)

Default RF to RSSI conversion function to be used by the BLE stack when calling Device_RF_RSSI_Convert().

This is in the event that APP_BLE_RSSI_CONVERSION_DEFINED is set to 1, but the user has not called

Location: ble_protocol_support.h:129

Parameters

Direction | Name | Description
--- | --- | ---
in | rssi_reg | RF data value

set_app_rf_rssi_func().

## set_app_rf_rssi_func

void set_app_rf_rssi_func(int8_t(*)(uint8_t) func)

Sets RF to RSSI conversion function to be used by the BLE stack when calling Device_RF_RSSI_Convert()

Location: ble_protocol_support.h:137

Parameters

Direction | Name | Description
--- | --- | ---
in | func | Function containing RF to RSSI calculations

## MsgHandler_GetTaskAppDesc

const struct ke_task_desc * MsgHandler_GetTaskAppDesc()

Provide an application task descriptor with default handler set to the MsgHandler_Notify function.

Location: msg_handler.h:42

Return

A TASK_APP descriptor to be used in the ke_create_task function

## MsgHandler_Add

bool MsgHandler_Add(ke_msg_id_t const msg_id, MsgHandlerCallback_t callback)

Add/subscribe a message handler callback function.

If the msg_id argument is a message identifier (such as GAPM_CMP_EVT), the callback function is called only when the specific event is triggered

Location: msg_handler.h:58

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | A message identifier (such as GAPM_CMP_EVT) or a task identifier (such as TASK_ID_GAPM)
in | callback | A pointer to the callback function that should be called when an event matching msg_id happens

Return

True if it was able to add/register the handler, false otherwise

If the msg_id argument is a task identifier (such as TASK_ID_GAPM), the callback function is for for any event triggered from that task

## MsgHandler_Notify

int MsgHandler_Notify(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Notify the callback functions associated with the msg_id.

This function searches the list of handlers added using MsgHandler_Add and notify each one with matching msg_id.

Location: msg_handler.h:80

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | A message identifier (such as GAPM_CMP_EVT) or a task identifier (such as TASK_ID_GAPM)
in | param | Message parameter
in | dest_id | Destination task identifier
in | src_id | Source task identifier

Return

KE_MSG_CONSUMED back to the kernel

It also makes sure to call the BLE abstraction message handlers prior to any application message handler

NOTE: This function was designed to be used as the default handler of the kernel and shall NOT be called directly by the application. To notify an event, the application should instead enqueue a message in the kernel, in order to avoid chaining the context of function calls and causing a stack overflow

## BASC_Initialize

void BASC_Initialize()

Initialize BASC environment.

Initialize battery service client environment and configure message handlers.

Location: ble_basc.h:81

## BASC_EnableReq

void BASC_EnableReq(uint8_t conidx)

Enable the client role of the BAS.

Prepare and send BASC_ENABLE_REQ to enable the client role of the battery service.

Location: ble_basc.h:92

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index

NOTE: conidx is valid (between 0 and GAP_MAX_CONNECTIONS-1)

## BASC_ReadInfoReq

void BASC_ReadInfoReq(uint8_t conidx, uint8_t bas_nb, uint8_t info)

Prepare and send BASC_READ_INFO_REQ to read value from peer.

Prepare and send BASC_READ_INFO_REQ to read the value of characteristic or descriptor in the peer device database.

Location: ble_basc.h:104

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | bas_nb | Battery instance number
in | info | Peer battery info type

## BASC_BattLevelNtfCfgReq

void BASC_BattLevelNtfCfgReq(uint8_t conidx, uint8_t bas_nb, uint8_t ntf_cfg)

Send a request to change notification configuration.

Prepare and send BASC_BATT_LEVEL_NTF_CFG_REQ to request to change battery level notification configuration in the peer device.

Location: ble_basc.h:116

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | bas_nb | Battery instance number
in | ntf_cfg | The value of notification configuration

## BASC_RequestBattLevelOnTimeout

void BASC_RequestBattLevelOnTimeout(uint32_t timeout_ms)

Send a request for periodic battery level update.

Configure a kernel timer to periodically send battery level requests.

Location: ble_basc.h:126

Parameters

Direction | Name | Description
--- | --- | ---
in | timeout_ms | Delay between requests in units of 10ms. If timeout == 0, disable periodic requests.

## BASC_GetLastBatteryLevel

uint8_t BASC_GetLastBatteryLevel(uint8_t conidx, uint8_t bas_nb)

Read the most recent battery level.

Read the most recent value of battery level from the BASC environment.

Location: ble_basc.h:137

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index
in | bas_nb | Battery instance number

Return

Value of battery level

## BASC_GetEnv

const BASC_Env_t * BASC_GetEnv()

Get the BASC environment.

Return a reference to the internal BASC environment structure.

Location: ble_basc.h:146

Return

Constant pointer to BASC_Env_t

## BASC_MsgHandler

void BASC_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Handle the BASC events.

Handle all the events related to battery service client.

Location: ble_basc.h:158

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameter
in | dest_id | Destination task identifier
in | src_id | Source task identifier

## BASS_Initialize

void BASS_Initialize(uint8_t bas_nb, uint8_t(*)(uint8_t bas_nb) readBattLevelCallback)

Initialize BASS environment.

Initialize a battery service server environment and configure message handlers.

Location: ble_bass.h:82

Parameters

Direction | Name | Description
--- | --- | ---
in | bas_nb | Number of battery instances [1,2].
in | readBattLevelCallback | Pointer to user application callback function that returns the battery value.

## BASS_NotifyOnTimeout

void BASS_NotifyOnTimeout(uint32_t timeout)

BASS configure periodic notification.

Configure a battery service to send periodic notifications.

Location: ble_bass.h:93

Parameters

Direction | Name | Description
--- | --- | ---
in | timeout | Timeout period in units of 10ms. disabled if timeout == 0

## BASS_NotifyOnBattLevelChange

void BASS_NotifyOnBattLevelChange(uint32_t timeout)

BASS notify peers on battery level change.

Configure battery service to periodically monitor the battery level according to the timeout. The battery level is queried read through the callback function passed as argument to

Location: ble_bass.h:107

Parameters

Direction | Name | Description
--- | --- | ---
in | timeout | Timeout period in units of 10ms. disabled if timeout == 0

BASS_Initialize(). Connected peers are only notified if the battery level changes. It triggers a BASS_BATT_LEVEL_CHANGED event, which the user application may subscribe to.

## BASS_ProfileTaskAddCmd

void BASS_ProfileTaskAddCmd()

Add a battery profile in kernel.

Send request to add a battery profile in kernel and database.

Location: ble_bass.h:114

## BASS_EnableReq

void BASS_EnableReq(uint8_t conidx)

Enable the server role in BAS.

Prepare and send BASS_ENABLE_REQ to enable the server role of the battery service.

Location: ble_bass.h:124

Parameters

Direction | Name | Description
--- | --- | ---
in | conidx | Connection index

## BASS_BattLevelUpdReq

void BASS_BattLevelUpdReq(uint8_t batt_lvl, uint8_t bas_nb)

Prepare and send BASS_BATT_LEVEL_UPD_REQ for battery level notification.

Prepare and send BASS_BATT_LEVEL_UPD_REQ to update the battery level characteristic value for the BAS instance. This value will be stored in the database so that it can be read by the peer device.

Location: ble_bass.h:137

Parameters

Direction | Name | Description
--- | --- | ---
in | batt_lvl | Battery level [0, 100]
in | bas_nb | Battery server instance number

## BASS_GetEnv

const BASS_Env_t * BASS_GetEnv()

Get the BASS environment.

Return a reference to the internal BASS environment structure.

Location: ble_bass.h:146

Return

Constant pointer to BASS_Env_t

## BASS_IsAdded

bool BASS_IsAdded()

Check if the BASS is added successfully.

Returns a boolean indication if the BAS server has been successfully added to the services database.

Location: ble_bass.h:156

Return

True if the service has been successfully added, false otherwise

## BASS_MsgHandler

void BASS_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Handle BASS messages.

Handle all events related to the battery service server

Location: ble_bass.h:168

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Pointer to constant message parameters
in | dest_id | Destination task identifier
in | src_id | Source task identifier

## DISS_Initialize

int DISS_Initialize(uint16_t features, const struct DISS_DeviceInfo_t * deviceInfo)

Initialize the device information server service environment and configure message handlers.

Location: ble_diss.h:81

Parameters

Direction | Name | Description
--- | --- | ---
in | features | The enabled features for the device information service. Values define as enum diss_features in diss_task.h.
in | deviceInfo | Constant pointer to DISS_DeviceInfo_t

Return

0 if the initialization was successful, < 0 otherwise

## DISS_ProfileTaskAddCmd

void DISS_ProfileTaskAddCmd()

Send a request to add the device information service in kernel and database.

Location: ble_diss.h:87

## DISS_EnvGet

const DISS_Env_t * DISS_EnvGet()

Return a reference to the internal DISS environment structure.

Location: ble_diss.h:94

Return

A constant pointer to DISS_Env_t

## DISS_IsAdded

bool DISS_IsAdded()

Return a boolean indication if the DISS server has been successfully added to the services database.

Location: ble_diss.h:102

Return

True if the service is added successful, false otherwise

## DISS_MsgHandler

void DISS_MsgHandler(ke_msg_id_t const msg_id, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Handle all the events related to the device information service server.

Location: ble_diss.h:112

Parameters

Direction | Name | Description
--- | --- | ---
in | msg_id | Kernel message identifier
in | param | Message parameter
in | dest_id | Destination task identifier
in | src_id | Source task identifier

## DISS_DeviceInfoValueReqInd

void DISS_DeviceInfoValueReqInd(ke_msg_id_t const msgid, void const * param, ke_task_id_t const dest_id, ke_task_id_t const src_id)

Handle the indication when the peer device requests a value.

Location: ble_diss.h:123

Parameters

Direction | Name | Description
--- | --- | ---
in | msgid | Kernel message identifier
in | param | Message parameters in format of struct diss_value_req_ind
in | dest_id | Destination task identifier
in | src_id | Source task identifier