Microchip® Advanced Software Framework

ble_sdk/ble_services/ble_mgr/ble_manager.c File Reference

BLE Manager.

Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <string.h>
#include "at_ble_api.h"
#include "at_ble_trace.h"
#include "ble_manager.h"
#include "ble_utils.h"
#include "platform.h"
#include "pds.h"

Functions

at_ble_status_t ble_advertisement_data_set (void)
 ble_advertisement_data_set set the BLE advertisement data based on the available available services and profiles which is present in the current application. More...
 
at_ble_status_t ble_characteristic_write_cmd_complete_handler (void *params)
 ble_characteristic_write_cmd_complete_handler handler for Char write command complete event More...
 
at_ble_status_t ble_check_device_state (at_ble_handle_t conn_handle, ble_device_state_t state)
 Check the device state. More...
 
bool ble_check_disconnected_iscentral (at_ble_handle_t handle)
 Check the passed connection handle of the device is disconnected and central device. More...
 
bool ble_check_disconnected_isperipheral (at_ble_handle_t handle)
 Check the passed connection handle of the device is disconnected and peripheral device. More...
 
bool ble_check_iscentral (at_ble_handle_t handle)
 Check the passed connection handle of the device is central device. More...
 
bool ble_check_ispheripheral (at_ble_handle_t handle)
 Check the passed connection handle of the device is peripheral or central device. More...
 
at_ble_status_t ble_conn_param_update (void *params)
 connection update parameter function More...
 
at_ble_status_t ble_conn_param_update_req (void *params)
 function triggered on receiving a connection parameter update request from the peer. More...
 
at_ble_status_t ble_connected_device_role (at_ble_handle_t conn_handle, at_ble_dev_role_t *dev_role)
 Get the passed connection handle device role. More...
 
at_ble_status_t ble_connected_state_handler (void *params)
 function to handle connected event received from stack More...
 
at_ble_status_t ble_device_dead_handler (void *params)
 ble_device_dead_handler handler for BLE device dead indication handler. More...
 
void ble_device_init (at_ble_addr_t *addr)
 BLE device initialization. More...
 
at_ble_status_t ble_device_out_of_sync_handler (void *params)
 ble_device_out_of_sync_handler handler for out of sync indication handler. More...
 
at_ble_status_t ble_disconnected_device_role (at_ble_handle_t conn_handle, at_ble_dev_role_t *dev_role)
 Get the device role of disconnected device. More...
 
at_ble_status_t ble_disconnected_state_handler (void *params)
 function handles disconnection event received from stack More...
 
at_ble_status_t ble_encryption_request_handler (void *params)
 function handles encryption requests More...
 
at_ble_status_t ble_encryption_status_change_handler (void *params)
 function handles encryption status change More...
 
void ble_event_manager (at_ble_events_t events, void *event_params)
 function handling all the events from the stack, responsible for calling the respective functions initialized for the events. More...
 
at_ble_status_t ble_event_task (void)
 function to get event from stack More...
 
static void ble_init (at_ble_init_config_t *args)
 initializes the platform More...
 
bool ble_mgr_events_callback_handler (ble_mgr_event_cb_t event_cb_type, ble_mgr_event_t event_type, const void *ble_event_handler)
 The structure of BLE Event callback pointer will be registered or unregistered dynamically. More...
 
at_ble_status_t ble_mtu_changed_cmd_complete_handler (void *params)
 ble_mtu_changed_indication_handler handler for Peer device MTU size change More...
 
at_ble_status_t ble_mtu_changed_indication_handler (void *params)
 ble_mtu_changed_indication_handler handler for Peer device MTU size change More...
 
at_ble_status_t ble_pair_done_handler (void *params)
 function handles pair done event More...
 
at_ble_status_t ble_pair_key_request_handler (void *params)
 function handles pair key request More...
 
at_ble_status_t ble_pair_request_handler (void *params)
 function handles pair request More...
 
at_ble_status_t ble_remove_bonding_info (void)
 Remove all bonding information from PDS. More...
 
at_ble_status_t ble_resolv_rand_addr_handler (void *params)
 ble_resolv_rand_addr_handler handles the resolved random address event More...
 
at_ble_status_t ble_restore_bonding_info (void)
 Restore the bonding information from PDS. More...
 
static bool ble_scan_duplication_check (at_ble_scan_info_t *info)
 filter function for avoiding duplicated scan data. More...
 
at_ble_status_t ble_scan_info_handler (void *params)
 function handling scaned information More...
 
at_ble_status_t ble_scan_report_handler (void *params)
 function handles scan report More...
 
uint32_t ble_sdk_version (void)
 ble_sdk_version gets the version of BluSDK and also checks the SDK and Library version compatibility More...
 
at_ble_status_t ble_send_slave_sec_request (at_ble_handle_t conn_handle)
 function to send slave security request More...
 
static void ble_set_dev_config (at_ble_addr_t *addr)
 Set BLE Address, If address is NULL then it will use BD public address. More...
 
at_ble_status_t ble_set_device_name (uint8_t *name, uint8_t name_len)
 set device name to BLE Device More...
 
at_ble_status_t ble_slave_security_request_handler (void *params)
 
at_ble_status_t ble_store_bonding_info (void *params)
 Store the bonding information. More...
 
at_ble_status_t ble_undefined_event_handler (void *params)
 ble_undefined_event_handler handler for undefined events which is not expected in Library More...
 
at_ble_status_t gap_dev_connect (at_ble_addr_t *dev_addr)
 request the peer device for connection More...
 
at_ble_status_t gap_dev_scan (void)
 instructs device to start scanning More...
 
at_ble_status_t pds_module_init (void)
 Initialize the PDS Module. More...
 
at_ble_status_t scan_info_parse (at_ble_scan_info_t *scan_info_data, at_ble_uuid_t *ble_service_uuid, uint8_t adv_type)
 function parses the received advertising data for service and local name. More...
 

Variables

uint32_t att_db_data [BLE_ATT_DB_MEMORY_SIZE/4] = {0}
 
ble_connected_dev_info_t ble_dev_info [BLE_MAX_DEVICE_CONNECTION]
 Initialize the service with its included service, characteristics, and descriptors. More...
 
volatile uint8_t ble_device_count
 
volatile ble_device_ll_state_t ble_device_current_state = BLE_DEVICE_IDLE_STATE
 
uint32_t ble_event_params [BLE_EVENT_PARAM_MAX_SIZE/sizeof(uint32_t)]
 
const ble_custom_event_cb_tble_mgr_custom_event_cb [MAX_CUSTOM_EVENT_SUBSCRIBERS] = {NULL, }
 
static const ble_custom_event_cb_t ble_mgr_custom_event_handle
 
const ble_dtm_event_cb_tble_mgr_dtm_event_cb [MAX_DTM_EVENT_SUBSCRIBERS] = {NULL, }
 
const ble_gap_event_cb_tble_mgr_gap_event_cb [MAX_GAP_EVENT_SUBSCRIBERS] = {NULL, }
 
static const ble_gap_event_cb_t ble_mgr_gap_handle
 
const ble_gatt_client_event_cb_tble_mgr_gatt_client_event_cb [MAX_GATT_CLIENT_SUBSCRIBERS] = {NULL, }
 
const ble_gatt_server_event_cb_tble_mgr_gatt_server_event_cb [MAX_GATT_SERVER_SUBSCRIBERS] = {NULL, }
 
static const
ble_gatt_server_event_cb_t 
ble_mgr_gatt_server_handle
 
const ble_htpt_event_cb_tble_mgr_htpt_event_cb [MAX_HTPT_EVENT_SUBSCRIBERS] = {NULL, }
 
const ble_l2cap_event_cb_tble_mgr_l2cap_event_cb [MAX_L2CAP_EVENT_SUBSCRIBERS] = {NULL, }
 
static at_ble_addr_t ble_peripheral_dev_address
 
at_ble_connected_t connected_state_info
 
at_ble_events_t event
 
uint32_t event_params_memory [1024] = {0}
 
uint32_t event_pool_memory [256] = {0}
 
pds_env_t pds_env_cfg
 
at_ble_init_config_t pf_cfg
 
bool volatile resolve_addr_flag = false
 
uint32_t rx_fifo_memory [256] = {0}
 
at_ble_scan_info_t scan_info [MAX_SCAN_DEVICE]
 
volatile uint32_t scan_response_count = 0
 
bool volatile send_slave_security_flag = true
 
at_ble_encryption_request_t temp_param [sizeof(at_ble_encryption_request_t)]
 

at_ble_status_t ble_advertisement_data_set ( void  )

ble_advertisement_data_set set the BLE advertisement data based on the available available services and profiles which is present in the current application.

Parameters
[in]None
Returns
AT_BLE_SUCCESS BLE advertisement data set successfully
AT_BLE_FAILURE Failed to set the advertisement data

References _CONF_PUBLIC_TARGET_ADDR, _CONF_PUBLIC_TARGET_ADDR_SCAN_RSP, _CONF_RANDOM_TARGET_ADDR, _CONF_RANDOM_TARGET_ADDR_SCAN_RSP, _CONF_SERVICE_128BIT_UUID, _CONF_SERVICE_128BIT_UUID_SCAN_RSP, _CONF_SERVICE_16BIT_UUID, _CONF_SERVICE_16BIT_UUID_SCAN_RSP, _CONF_SERVICE_32BIT_UUID, _CONF_SERVICE_32BIT_UUID_SCAN_RSP, _CONF_SERVICE_SOLTN_128BIT_UUID, _CONF_SERVICE_SOLTN_128BIT_UUID_SCAN_RSP, _CONF_SERVICE_SOLTN_16BIT_UUID, _CONF_SERVICE_SOLTN_16BIT_UUID_SCAN_RSP, _CONF_SERVICE_SOLTN_32BIT_UUID, _CONF_SERVICE_SOLTN_32BIT_UUID_SCAN_RSP, ADV_ELEMENT_SIZE, adv_element_container::adv_ptr, ADV_TYPE_FLAG_SIZE, ADV_TYPE_SIZE, ADVERTISING_INTERVAL, APPEARANCE, at_ble_adv_data_set(), AT_BLE_ADV_MAX_SIZE, AT_BLE_GAP_INVALID_PARAM, AT_BLE_SUCCESS, BLE_GAP_ADV_ADVERTISING_INTERVAL_LENGTH, BLE_GAP_ADV_DATA_SLAVE_CONN_INTERVAL_RANGE_LENGTH, BLE_GAP_ADV_PUBLIC_TARGET_ADDR_LENGTH, BLE_GAP_ADV_RANDOM_TARGET_ADDR_LENGTH, BLE_GAP_ADV_SERVICE_128BIT_UUID_LENGTH, BLE_GAP_ADV_SERVICE_16BIT_UUID_LENGTH, BLE_GAP_ADV_SERVICE_32BIT_UUID_LENGTH, COMPLETE_LIST_128BIT_SERV_UUIDS, COMPLETE_LIST_16BIT_SERV_UUIDS, COMPLETE_LIST_32BIT_SERV_UUIDS, COMPLETE_LOCAL_NAME, DBG_LOG, DBG_LOG_ADV, DBG_LOG_DEV, LE_BLUETOOTH_DEVICE_ADDRESS, LE_ROLE, adv_element_container::len, scan_resp_element::len, LIST_128BIT_SERV_SOLICITATION_UUIDS, LIST_16BIT_SERV_SOLICITATION_UUIDS, LIST_32BIT_SERV_SOLICITATION_UUIDS, MANUFACTURER_SPECIFIC_DATA, MREPEAT, NULL, PUBLIC_RANDOM_ADDR_MAX_NUM, PUBLIC_TARGET_ADDR_MAX_NUM, PUBLIC_TARGET_ADDRESS, RANDOM_TARGET_ADDRESS, scan_resp_element::scn_ptr, SERVICE_DATA, SERVICE_DATA_128BIT, SERVICE_DATA_32BIT, SERVICE_UUID128_MAX_NUM, SERVICE_UUID16_MAX_NUM, SERVICE_UUID32_MAX_NUM, SHORTENED_LOCAL_NAME, SLAVE_CONNECTION_INTERVAL_RANGE, and TX_POWER_LEVEL.

Referenced by anp_client_init(), battery_service_advertise(), battery_set_advertisement_data(), blp_sensor_init(), csc_prf_init(), device_information_advertise(), fmp_target_adv(), hid_prf_dev_adv(), hr_sensor_init(), htpt_set_advertisement_data(), pas_client_init(), pxp_reporter_adv(), sps_service_advertise(), and time_info_adv().

at_ble_status_t ble_characteristic_write_cmd_complete_handler ( void *  params)

ble_characteristic_write_cmd_complete_handler handler for Char write command complete event

Parameters
[in]paramsof at_ble_cmd_complete_event_t type, Refer to at_ble_cmd_complete_event_t
Returns
AT_BLE_SUCCESS event handled successfully
AT_BLE_FAILURE event with error status

References AT_BLE_FAILURE, AT_BLE_SUCCESS, at_ble_cmd_complete_event_t::conn_handle, DBG_LOG_DEV, at_ble_cmd_complete_event_t::operation, and at_ble_cmd_complete_event_t::status.

at_ble_status_t ble_check_device_state ( at_ble_handle_t  conn_handle,
ble_device_state_t  state 
)

Check the device state.

Parameters
[in]conn_handleat_ble_handle_t Device connection handle
[in]stateble_device_state_t device state
Returns
AT_BLE_SUCCESS if the passed handle of device states are matches
AT_BLE_FAILURE if the passed handle of device states are doesn't matches

References AT_BLE_FAILURE, AT_BLE_SUCCESS, and BLE_MAX_DEVICE_CONNECTION.

bool ble_check_disconnected_iscentral ( at_ble_handle_t  handle)

Check the passed connection handle of the device is disconnected and central device.

Parameters
[in]handleat_ble_handle_t Device connection handle
Returns
true if the passed handle of the device is disconnected and central
false if the passed handle of the device is not central or not disconnected.

References AT_BLE_ROLE_CENTRAL, AT_BLE_SUCCESS, and ble_disconnected_device_role().

Referenced by pxp_disconnect_event_handler().

bool ble_check_disconnected_isperipheral ( at_ble_handle_t  handle)

Check the passed connection handle of the device is disconnected and peripheral device.

Parameters
[in]handleat_ble_handle_t Device connection handle
Returns
true if the passed handle of the device is disconnected and peripheral
false if the passed handle of the device is not peripheral or not disconnected.

References AT_BLE_ROLE_PERIPHERAL, AT_BLE_SUCCESS, and ble_disconnected_device_role().

bool ble_check_ispheripheral ( at_ble_handle_t  handle)

Check the passed connection handle of the device is peripheral or central device.

Parameters
[in]handleat_ble_handle_t Device connection handle
Returns
true if the passed handle of the device is peripheral
false if the passed handle of the device is not peripheral.

References AT_BLE_ROLE_PERIPHERAL, AT_BLE_SUCCESS, and ble_connected_device_role().

Referenced by ble_connected_app_event(), ble_pair_done_handler(), pxp_monitor_encryption_change_handler(), and pxp_monitor_pair_done_handler().

at_ble_status_t ble_conn_param_update ( void *  params)

connection update parameter function

function used to update the connection parameter.

References ALL_UNUSED, AT_BLE_SUCCESS, and DBG_LOG_DEV.

at_ble_status_t ble_conn_param_update_req ( void *  params)

function triggered on receiving a connection parameter update request from the peer.

Parameters
[in]conn_param_reqat_ble_conn_param_update_request_t parameters received.
Returns
AT_BLE_SUCCESS operation completed successfully.
AT_BLE_FAILURE Generic error.

References at_ble_conn_update_reply(), AT_BLE_SUCCESS, and at_ble_conn_param_update_request_t::handle.

at_ble_status_t ble_connected_device_role ( at_ble_handle_t  conn_handle,
at_ble_dev_role_t dev_role 
)

Get the passed connection handle device role.

Parameters
[in]conn_handleat_ble_handle_t Device connection handle
[in]dev_roleat_ble_dev_role_t device role Central or Peripheral
Returns
AT_BLE_SUCCESS if the passed handle of the device gets the device role
AT_BLE_FAILURE if the passed handle doesn't match and failure of getting device role

References AT_BLE_FAILURE, AT_BLE_SUCCESS, BLE_DEVICE_DEFAULT_IDLE, BLE_DEVICE_DISCONNECTED, and BLE_MAX_DEVICE_CONNECTION.

Referenced by ble_check_iscentral(), and ble_check_ispheripheral().

at_ble_status_t ble_device_dead_handler ( void *  params)

ble_device_dead_handler handler for BLE device dead indication handler.

When the application receives this event that means BLE device is not responding. The application may start the BLE device from beginning by calling the at_ble_init, Refer to at_ble_init

Parameters
[in]paramsof void * type
Returns
AT_BLE_SUCCESS event handled successfully
AT_BLE_FAILURE event with error status

References ALL_UNUSED, AT_BLE_SUCCESS, and DBG_LOG.

void ble_device_init ( at_ble_addr_t addr)

BLE device initialization.

function sets both device address and device name which are exposed to all other devices.

Select BTLC1000 GPIO for host wakeup, for Wing board select BTLC1000_EXT_PIN9 only, for SoC use the enum values

UART baudrate value one of at_ble_uart_baudrate_tag values

References AT_BLE_GAP_INVALID_PARAM, platform_api_list_tag::at_ble_reconfigure_usart, AT_BLE_ROLE_NONE, AT_BLE_SUCCESS, AT_BLE_UART, AT_BTLC1000_MR, AT_BTLC1000_ZR, att_db_data, BLE_ATT_DB_MEMORY_SIZE, BLE_CUSTOM_EVENT_TYPE, ble_device_count, BLE_DEVICE_DEFAULT_IDLE, BLE_DEVICE_NAME, BLE_GAP_EVENT_TYPE, BLE_GATT_SERVER_EVENT_TYPE, ble_init(), BLE_INVALID_CONNECTION_HANDLE, BLE_MAX_DEVICE_CONNECTION, ble_mgr_events_callback_handler(), ble_restore_bonding_info(), ble_sdk_version(), ble_set_dev_config(), ble_set_device_name(), BTLC1000_EXT_PIN9, at_ble_init_config_t::btlc1000_module_version, at_ble_bus_info_t::btlc1000_uart_pinout_switch, at_ble_bus_info_t::bus_baudrate, at_ble_init_config_t::bus_info, at_ble_bus_info_t::bus_type, DBG_LOG, at_ble_init_config_t::event_mem_pool, at_ble_init_config_t::event_params_mem_pool, event_params_memory, event_pool_memory, at_ble_bus_info_t::host_external_wakeup_gpio, at_ble_init_config_t::memPool, at_ble_mempool_t::memSize, at_ble_mempool_t::memStartAdd, NULL, at_ble_init_config_t::platform_api_list, platform_configure_hw_fc_uart(), platform_configure_primary_uart(), platform_host_set_sleep(), platform_init(), REGISTER_CALL_BACK, at_ble_init_config_t::rx_fifo_mem_pool, rx_fifo_memory, TRACE_LVL_DISABLE, and trace_set_level().

Referenced by ble_disconnected_app_event(), ble_init(), and main().

at_ble_status_t ble_device_out_of_sync_handler ( void *  params)

ble_device_out_of_sync_handler handler for out of sync indication handler.

When device starts missing few events or UART BLE event data

Parameters
[in]paramsof void * type
Returns
AT_BLE_SUCCESS event handled successfully
AT_BLE_FAILURE event with error status

References ALL_UNUSED, AT_BLE_SUCCESS, and DBG_LOG.

at_ble_status_t ble_disconnected_device_role ( at_ble_handle_t  conn_handle,
at_ble_dev_role_t dev_role 
)

Get the device role of disconnected device.

Parameters
[in]conn_handleat_ble_handle_t Device connection handle
[in]dev_roleat_ble_dev_role_t device role Central or Peripheral
Returns
AT_BLE_SUCCESS if the passed handle of the device gets the device role
AT_BLE_FAILURE if the passed handle doesn't match and failure of getting device role

References AT_BLE_FAILURE, AT_BLE_ROLE_NONE, AT_BLE_SUCCESS, BLE_DEVICE_DEFAULT_IDLE, BLE_DEVICE_DISCONNECTED, and BLE_MAX_DEVICE_CONNECTION.

Referenced by ble_check_disconnected_iscentral(), and ble_check_disconnected_isperipheral().

at_ble_status_t ble_encryption_status_change_handler ( void *  params)
void ble_event_manager ( at_ble_events_t  events,
void *  event_params 
)

function handling all the events from the stack, responsible for calling the respective functions initialized for the events.

Parameters
[in]eventsevents received from the stack at_ble_events_t.
[in]event_paramsdata received from stack for the respective event received.
Returns
none.

References AT_BLE_ADV_REPORT, AT_BLE_CHARACTERISTIC_CHANGED, AT_BLE_CHARACTERISTIC_CONFIGURATION_CHANGED, AT_BLE_CHARACTERISTIC_FOUND, AT_BLE_CHARACTERISTIC_READ_BY_UUID_RESPONSE, AT_BLE_CHARACTERISTIC_READ_MULTIBLE_RESPONSE, AT_BLE_CHARACTERISTIC_WRITE_CMD_CMP, AT_BLE_CHARACTERISTIC_WRITE_RESPONSE, AT_BLE_CON_CHANNEL_MAP_IND, AT_BLE_CONN_PARAM_UPDATE_DONE, AT_BLE_CONN_PARAM_UPDATE_REQUEST, AT_BLE_CONNECTED, AT_BLE_CUSTOM_EVENT, AT_BLE_DESCRIPTOR_FOUND, AT_BLE_DEVICE_READY, AT_BLE_DISCONNECTED, AT_BLE_DISCOVERY_COMPLETE, AT_BLE_ENCRYPTION_REQUEST, AT_BLE_ENCRYPTION_STATUS_CHANGED, AT_BLE_EVENT_MAX, AT_BLE_HTPT_CFG_INDNTF_IND, AT_BLE_HTPT_CREATE_DB_CFM, AT_BLE_HTPT_DISABLE_IND, AT_BLE_HTPT_ENABLE_RSP, AT_BLE_HTPT_ERROR_IND, AT_BLE_HTPT_MEAS_INTV_CHG_IND, AT_BLE_HTPT_MEAS_INTV_CHG_REQ, AT_BLE_HTPT_MEAS_INTV_UPD_RSP, AT_BLE_HTPT_TEMP_SEND_CFM, AT_BLE_INCLUDED_SERVICE_FOUND, AT_BLE_INDICATION_CONFIRMED, AT_BLE_INDICATION_RECIEVED, AT_BLE_LE_PACKET_REPORT, AT_BLE_LE_TEST_STATUS, AT_BLE_LECB_ADD_CREDIT_IND, AT_BLE_LECB_CONN_REQ, AT_BLE_LECB_CONNECTED, AT_BLE_LECB_DATA_RECIEVED, AT_BLE_LECB_DISCONNECTED, AT_BLE_LECB_SEND_RESP, AT_BLE_MTU_CHANGED_CMD_COMPLETE, AT_BLE_MTU_CHANGED_INDICATION, AT_BLE_NOTIFICATION_CONFIRMED, AT_BLE_NOTIFICATION_RECIEVED, AT_BLE_PAIR_DONE, AT_BLE_PAIR_KEY_REQUEST, AT_BLE_PAIR_REQUEST, AT_BLE_PEER_ATT_INFO_IND, AT_BLE_PRIMARY_SERVICE_FOUND, AT_BLE_RAND_ADDR_CHANGED, AT_BLE_READ_AUTHORIZE_REQUEST, AT_BLE_RESOLV_RAND_ADDR_STATUS, AT_BLE_SCAN_INFO, AT_BLE_SCAN_REPORT, AT_BLE_SERVICE_CHANGED_INDICATION_SENT, AT_BLE_SIGN_COUNTERS_IND, AT_BLE_SLAVE_SEC_REQUEST, AT_BLE_UNDEFINED_EVENT, AT_BLE_WRITE_AUTHORIZE_REQUEST, ble_scan_duplication_check(), DBG_LOG, DBG_LOG_DEV, events, MAX_CUSTOM_EVENT_SUBSCRIBERS, MAX_DTM_EVENT_SUBSCRIBERS, MAX_GAP_EVENT_SUBSCRIBERS, MAX_GATT_CLIENT_SUBSCRIBERS, MAX_GATT_SERVER_SUBSCRIBERS, MAX_HTPT_EVENT_SUBSCRIBERS, MAX_L2CAP_EVENT_SUBSCRIBERS, and NULL.

Referenced by ble_event_task().

at_ble_status_t ble_event_task ( void  )

function to get event from stack

function to handle the BLE event task.

References at_ble_event_get(), AT_BLE_FAILURE, AT_BLE_SUCCESS, ble_event_manager(), ble_event_params, BLE_EVENT_TIMEOUT, and event.

Referenced by main(), and pxp_monitor_start_scan().

static void ble_init ( at_ble_init_config_t args)
static

initializes the platform

References at_ble_chip_id_get(), at_ble_init(), AT_BLE_SUCCESS, and DBG_LOG.

bool ble_mgr_events_callback_handler ( ble_mgr_event_cb_t  event_cb_type,
ble_mgr_event_t  event_type,
const void *  ble_event_handler 
)

The structure of BLE Event callback pointer will be registered or unregistered dynamically.

ble_mgr_events_callback_handler handler for Profile/Service/application to register the BLE events callbacks

The callback pointers are registered according to the group type of BLE Events request is received AT_BLE_LECB_CONN_REQ

Parameters
[in]event_cb_typeRegister/Unregister the callback functions
[in]event_typetype of BLE event
[in]ble_event_handlerstructure of function pointers for the event
Returns
Upon successful completion the function shall return true, Otherwise the function shall return false

References BLE_CUSTOM_EVENT_TYPE, BLE_DTM_EVENT_TYPE, BLE_GAP_EVENT_TYPE, BLE_GATT_CLIENT_EVENT_TYPE, BLE_GATT_HTPT_EVENT_TYPE, BLE_GATT_SERVER_EVENT_TYPE, BLE_L2CAP_EVENT_TYPE, MAX_CUSTOM_EVENT_SUBSCRIBERS, MAX_DTM_EVENT_SUBSCRIBERS, MAX_GAP_EVENT_SUBSCRIBERS, MAX_GATT_CLIENT_SUBSCRIBERS, MAX_GATT_SERVER_SUBSCRIBERS, MAX_HTPT_EVENT_SUBSCRIBERS, MAX_L2CAP_EVENT_SUBSCRIBERS, NULL, REGISTER_CALL_BACK, and UNREGISTER_CALL_BACK.

Referenced by anp_client_init(), ble_device_init(), blp_sensor_init(), csc_prf_init(), eddystone_app_init(), fmp_locator_init(), fmp_target_init(), hid_prf_init(), hr_sensor_init(), main(), pas_client_init(), pxp_monitor_init(), pxp_reporter_init(), sps_init_service(), and time_info_init().

at_ble_status_t ble_mtu_changed_cmd_complete_handler ( void *  params)

ble_mtu_changed_indication_handler handler for Peer device MTU size change

Parameters
[in]paramsof at_ble_mtu_changed_ind_t type, Refer to at_ble_mtu_changed_ind_t
Returns
AT_BLE_SUCCESS event handled successfully
AT_BLE_FAILURE event with error status

References AT_BLE_FAILURE, AT_BLE_SUCCESS, at_ble_cmd_complete_event_t::conn_handle, DBG_LOG, DBG_LOG_DEV, at_ble_cmd_complete_event_t::operation, and at_ble_cmd_complete_event_t::status.

at_ble_status_t ble_mtu_changed_indication_handler ( void *  params)

ble_mtu_changed_indication_handler handler for Peer device MTU size change

Parameters
[in]paramsof at_ble_mtu_changed_ind_t type, Refer to at_ble_mtu_changed_ind_t
Returns
AT_BLE_SUCCESS event handled successfully
AT_BLE_FAILURE event with error status

References AT_BLE_SUCCESS, at_ble_mtu_changed_ind_t::conhdl, DBG_LOG_DEV, and at_ble_mtu_changed_ind_t::mtu_value.

at_ble_status_t ble_remove_bonding_info ( void  )

Remove all bonding information from PDS.

Remove all the valid bonding informations from PDS

Parameters
[in]None
Returns
Status of the Remove bonding information procedure
Return values
AT_BLE_SUCCESSbonding information removed successfully from the PDS
AT_BLE_FAILUREFailed to remove the bonding information from PDS

References AT_BLE_FAILURE, AT_BLE_SUCCESS, BLE_BONDING_INFO, BLE_MAX_DEVICE_CONNECTION, count, DBG_LOG, pds_delete(), PDS_ID, pds_list_item(), and PDS_SUCCESS.

Referenced by main().

at_ble_status_t ble_restore_bonding_info ( void  )

Restore the bonding information from PDS.

Restore all the valid bonding information from PDS to device info table

Parameters
[in]None
Returns
Status of the Restore bonding information
Return values
AT_BLE_SUCCESSPDS Restore bonding information is completed.
AT_BLE_FAILURERestore bonding information failed

References AT_BLE_FAILURE, AT_BLE_SUCCESS, BLE_BONDING_INFO, BLE_DEVICE_DISCONNECTED, BLE_MAX_DEVICE_CONNECTION, count, DBG_LOG, PDS_ID, pds_list_item(), pds_read(), and PDS_SUCCESS.

Referenced by ble_device_init().

static bool ble_scan_duplication_check ( at_ble_scan_info_t info)
static

filter function for avoiding duplicated scan data.

References at_ble_addr_t::addr, at_ble_scan_info_t::dev_addr, i, scan_response_count, and at_ble_scan_info_t::type.

Referenced by ble_event_manager().

at_ble_status_t ble_scan_info_handler ( void *  params)

function handling scaned information

function to handle the scan information.

References at_ble_addr_t::addr, AT_BLE_FAILURE, at_ble_scan_stop(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, at_ble_scan_info_t::dev_addr, MAX_SCAN_DEVICE, and scan_response_count.

at_ble_status_t ble_scan_report_handler ( void *  params)

function handles scan report

function to handle the scan status.

References AT_BLE_FAILURE, AT_BLE_SUCCESS, ble_device_current_state, BLE_DEVICE_IDLE_STATE, DBG_LOG, and at_ble_scan_report_t::status.

uint32_t ble_sdk_version ( void  )

ble_sdk_version gets the version of BluSDK and also checks the SDK and Library version compatibility

Parameters
[in]None
Returns
BluSDK version

References at_ble_firmware_version_get(), at_ble_rf_version_get(), AT_BLE_SUCCESS, BLE_SDK_BUILD_NO, BLE_SDK_MAJOR_NO, BLE_SDK_MINOR_NO, BLE_SDK_MINOR_NO_INC, BLE_SDK_VERSION, DBG_LOG, and DBG_LOG_DEV.

Referenced by ble_device_init().

at_ble_status_t ble_send_slave_sec_request ( at_ble_handle_t  conn_handle)

function to send slave security request

function to send slave security request.

References ALL_UNUSED, AT_BLE_FAILURE, at_ble_send_slave_sec_request(), AT_BLE_SUCCESS, BLE_BOND_REQ, BLE_MITM_REQ, DBG_LOG, and DBG_LOG_DEV.

Referenced by ble_connected_state_handler(), ble_resolv_rand_addr_handler(), and time_info_connected_state_handler().

at_ble_status_t ble_set_device_name ( uint8_t *  name,
uint8_t  name_len 
)

set device name to BLE Device

function to set the device name.

References at_ble_device_name_set(), AT_BLE_INVALID_PARAM, and NULL.

at_ble_status_t ble_store_bonding_info ( void *  params)

Store the bonding information.

Parameters
[in]None
Returns
Status of the PDS bonding information store procedure
Return values
AT_BLE_SUCCESSStored the bonding information in PDS
AT_BLE_FAILUREFailed to store the bonding information in PDS

References AT_BLE_FAILURE, AT_BLE_SUCCESS, BLE_BONDING_INFO, BLE_MAX_DEVICE_CONNECTION, count, DBG_LOG, pds_compact_sector(), PDS_ID, pds_list_item(), PDS_NVM_NO_MEMORY, PDS_SECTOR_ITEM_ERROR, PDS_SUCCESS, and pds_write().

Referenced by ble_pair_done_handler().

at_ble_status_t ble_undefined_event_handler ( void *  params)

ble_undefined_event_handler handler for undefined events which is not expected in Library

Parameters
[in]paramsof void * type
Returns
AT_BLE_SUCCESS event handled successfully
AT_BLE_FAILURE event with error status

References ALL_UNUSED, AT_BLE_SUCCESS, and DBG_LOG_DEV.

at_ble_status_t pds_module_init ( void  )

Initialize the PDS Module.

IInitialize the PDS & NVM Memory

Parameters
[in]None
Returns
Status of the PDS Module Initialize procedure
Return values
AT_BLE_SUCCESSPDS Module Initialize is completed
AT_BLE_FAILUREPDS Module Initialization Failure

References AT_BLE_FAILURE, AT_BLE_SUCCESS, DBG_LOG, pds_init(), and PDS_SUCCESS.

Referenced by main().

at_ble_status_t scan_info_parse ( at_ble_scan_info_t scan_info_data,
at_ble_uuid_t ble_service_uuid,
uint8_t  adv_type 
)

function parses the received advertising data for service and local name.

Parameters
[in]scan_info_datathe received data.
[in]ble_service_uuiduuid to be searched in the received data.
[in]adv_typeadvertisement type
Returns
AT_BLE_SUCCESS operation completed successfully.
AT_BLE_FAILURE Generic error.

References at_ble_scan_info_t::adv_data, at_ble_scan_info_t::adv_data_len, AT_BLE_FAILURE, AT_BLE_SUCCESS, AT_BLE_UUID_128, AT_BLE_UUID_128_LEN, AT_BLE_UUID_16, AT_BLE_UUID_16_LEN, AT_BLE_UUID_32, AT_BLE_UUID_32_LEN, at_ble_uuid_t::type, and at_ble_uuid_t::uuid.

Referenced by ble_scan_report_app_event(), and pxp_monitor_scan_data_handler().

uint32_t att_db_data[BLE_ATT_DB_MEMORY_SIZE/4] = {0}

Referenced by ble_device_init().

Initialize the service with its included service, characteristics, and descriptors.

Peer Connected device info

Parameters
[in]scan_paramgatt service information
Returns
none
uint32_t ble_event_params[BLE_EVENT_PARAM_MAX_SIZE/sizeof(uint32_t)]

Referenced by ble_event_task().

const ble_custom_event_cb_t* ble_mgr_custom_event_cb[MAX_CUSTOM_EVENT_SUBSCRIBERS] = {NULL, }
const ble_custom_event_cb_t ble_mgr_custom_event_handle
static
Initial value:
= {
.custom_event = NULL,
.device_dead = ble_device_dead_handler,
.device_out_of_sync = ble_device_out_of_sync_handler,
.device_ready = NULL,
.event_max = NULL,
}
at_ble_status_t ble_device_out_of_sync_handler(void *params)
ble_device_out_of_sync_handler handler for out of sync indication handler.
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:2071
#define NULL
Definition: nm_bsp.h:64
at_ble_status_t ble_device_dead_handler(void *params)
ble_device_dead_handler handler for BLE device dead indication handler.
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:2064
const ble_dtm_event_cb_t* ble_mgr_dtm_event_cb[MAX_DTM_EVENT_SUBSCRIBERS] = {NULL, }
const ble_gap_event_cb_t* ble_mgr_gap_event_cb[MAX_GAP_EVENT_SUBSCRIBERS] = {NULL, }
const ble_gap_event_cb_t ble_mgr_gap_handle
static
Initial value:
= {
.scan_info = ble_scan_info_handler,
.scan_report = ble_scan_report_handler,
.advt_cmp = NULL,
.adv_report = NULL,
.rand_addr_changed = NULL,
.conn_parameter_update_done = ble_conn_param_update,
.conn_param_update_request = ble_conn_param_update_req,
.pair_done = ble_pair_done_handler,
.pair_request = ble_pair_request_handler,
.slave_sec_request = ble_slave_security_request_handler,
.pair_key_request = ble_pair_key_request_handler,
.encryption_request = ble_encryption_request_handler,
.encryption_status_changed = ble_encryption_status_change_handler,
.resolv_rand_addr_status = ble_resolv_rand_addr_handler,
.sign_counters_ind = NULL,
.peer_att_info_ind = NULL,
.con_channel_map_ind = NULL
}
at_ble_status_t ble_pair_request_handler(void *params)
function handles pair request
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1511
at_ble_status_t ble_scan_info_handler(void *params)
function handling scaned information
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:807
at_ble_status_t ble_undefined_event_handler(void *params)
ble_undefined_event_handler handler for undefined events which is not expected in Library ...
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:727
at_ble_status_t ble_conn_param_update(void *params)
connection update parameter function
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1383
at_ble_status_t ble_resolv_rand_addr_handler(void *params)
ble_resolv_rand_addr_handler handles the resolved random address event
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1183
at_ble_status_t ble_encryption_status_change_handler(void *params)
function handles encryption status change
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1952
at_ble_status_t ble_pair_done_handler(void *params)
function handles pair done event
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1664
at_ble_status_t ble_conn_param_update_req(void *params)
function triggered on receiving a connection parameter update request from the peer.
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1392
at_ble_status_t ble_connected_state_handler(void *params)
function to handle connected event received from stack
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1070
at_ble_status_t ble_encryption_request_handler(void *params)
function handles encryption requests
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:2001
at_ble_status_t ble_disconnected_state_handler(void *params)
function handles disconnection event received from stack
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1317
#define NULL
Definition: nm_bsp.h:64
at_ble_status_t ble_slave_security_request_handler(void *params)
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1400
at_ble_status_t ble_pair_key_request_handler(void *params)
function handles pair key request
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1590
at_ble_status_t ble_scan_report_handler(void *params)
function handles scan report
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:854
const ble_gatt_client_event_cb_t* ble_mgr_gatt_client_event_cb[MAX_GATT_CLIENT_SUBSCRIBERS] = {NULL, }
const ble_gatt_server_event_cb_t* ble_mgr_gatt_server_event_cb[MAX_GATT_SERVER_SUBSCRIBERS] = {NULL, }
const ble_gatt_server_event_cb_t ble_mgr_gatt_server_handle
static
Initial value:
= {
.notification_confirmed = NULL,
.indication_confirmed = NULL,
.characteristic_changed = NULL,
.characteristic_configuration_changed = NULL,
.service_changed_indication_sent = NULL,
.write_authorize_request = NULL,
.mtu_changed_indication = ble_mtu_changed_indication_handler,
.mtu_changed_cmd_complete = ble_mtu_changed_cmd_complete_handler,
.characteristic_write_cmd_cmp = ble_characteristic_write_cmd_complete_handler,
.read_authorize_request = NULL
}
at_ble_status_t ble_mtu_changed_indication_handler(void *params)
ble_mtu_changed_indication_handler handler for Peer device MTU size change
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1265
at_ble_status_t ble_characteristic_write_cmd_complete_handler(void *params)
ble_characteristic_write_cmd_complete_handler handler for Char write command complete event ...
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1296
at_ble_status_t ble_mtu_changed_cmd_complete_handler(void *params)
ble_mtu_changed_indication_handler handler for Peer device MTU size change
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.c:1275
#define NULL
Definition: nm_bsp.h:64
const ble_htpt_event_cb_t* ble_mgr_htpt_event_cb[MAX_HTPT_EVENT_SUBSCRIBERS] = {NULL, }
const ble_l2cap_event_cb_t* ble_mgr_l2cap_event_cb[MAX_L2CAP_EVENT_SUBSCRIBERS] = {NULL, }
at_ble_addr_t ble_peripheral_dev_address
static
at_ble_connected_t connected_state_info
uint32_t event_params_memory[1024] = {0}
uint32_t event_pool_memory[256] = {0}
pds_env_t pds_env_cfg
Initial value:
= {
.platform_api_list.at_ble_create_timer = platform_create_timer,
.platform_api_list.at_ble_delete_timer = platform_delete_timer,
.platform_api_list.at_ble_start_timer = platform_start_timer,
.platform_api_list.at_ble_stop_timer = platform_stop_timer,
.platform_api_list.at_ble_sleep = platform_sleep,
.platform_api_list.at_ble_gpio_set = platform_gpio_set,
.platform_api_list.at_ble_send_sync = platform_send_sync,
.platform_api_list.at_ble_recv_async = platform_recv_async,
.platform_api_list.at_ble_reconfigure_usart = platform_configure_hw_fc_uart,
.platform_api_list.at_ble_wait_for_signal = platform_wait_for_signal,
.platform_api_list.at_ble_create_signal = platform_create_signal,
.platform_api_list.at_ble_delete_signal = platform_delete_signal,
.platform_api_list.at_ble_trigger_signal = platform_trigger_signal,
.platform_api_list.at_ble_reset_signal = platform_reset_signal
}
void platform_delete_timer(void *timer_handle)
Definition: ble_host_sdk/src/platform.c:188
void platform_reset_signal(void *signal_handler)
Definition: ble_sdk/src/platform.c:345
void platform_stop_timer(void *timer_handle)
Definition: ble_host_sdk/src/platform.c:200
void * platform_create_timer(void(*timer_cb)(void *))
Definition: ble_host_sdk/src/platform.c:183
void platform_configure_hw_fc_uart(uint32_t baudrate)
Definition: ble_sdk/src/platform.c:177
void platform_send_sync(uint8_t *data, uint32_t length)
Definition: ble_host_sdk/src/platform.c:82
void platform_gpio_set(gpio_pin_t pin, gpio_status_t status)
Definition: ble_host_sdk/src/platform.c:133
void platform_wait_for_signal(uint32_t count, void **signal_handler_list)
Definition: ble_sdk/src/platform.c:273
void platform_recv_async(uart_recv_async_cb_t recv_async_callback)
Definition: ble_host_sdk/src/platform.c:90
void platform_trigger_signal(void *signal_handler)
Definition: ble_sdk/src/platform.c:335
void platform_start_timer(void *timer_handle, uint32_t ms)
Definition: ble_host_sdk/src/platform.c:193
void * platform_create_signal(void)
Definition: ble_sdk/src/platform.c:310
void platform_sleep(uint32_t ms)
Definition: ble_host_sdk/src/platform.c:207
void platform_delete_signal(void *signal_handler)
Definition: ble_sdk/src/platform.c:325
uint32_t rx_fifo_memory[256] = {0}