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... | |
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.
[in] | None |
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
[in] | params | of at_ble_cmd_complete_event_t type, Refer to at_ble_cmd_complete_event_t |
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.
[in] | conn_handle | at_ble_handle_t Device connection handle |
[in] | state | ble_device_state_t device state |
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.
[in] | handle | at_ble_handle_t Device connection handle |
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.
[in] | handle | at_ble_handle_t Device connection handle |
References AT_BLE_ROLE_PERIPHERAL, AT_BLE_SUCCESS, and ble_disconnected_device_role().
bool ble_check_iscentral | ( | at_ble_handle_t | handle | ) |
Check the passed connection handle of the device is central device.
[in] | handle | at_ble_handle_t Device connection handle |
References AT_BLE_ROLE_CENTRAL, AT_BLE_ROLE_NONE, AT_BLE_SUCCESS, and ble_connected_device_role().
Referenced by bas_encryption_status_changed_app_event(), bas_paired_app_event(), ble_connected_app_event(), fmp_locator_characteristic_found_handler(), fmp_locator_connected_state_handler(), fmp_locator_discovery_complete_handler(), fmp_locator_pair_done_handler(), pxp_monitor_characteristic_found_handler(), pxp_monitor_characteristic_read_response(), pxp_monitor_connected_state_handler(), pxp_monitor_discovery_complete_handler(), pxp_monitor_encryption_change_handler(), pxp_monitor_pair_done_handler(), and pxp_monitor_service_found_handler().
bool ble_check_ispheripheral | ( | at_ble_handle_t | handle | ) |
Check the passed connection handle of the device is peripheral or central device.
[in] | handle | at_ble_handle_t Device connection handle |
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.
[in] | conn_param_req | at_ble_conn_param_update_request_t parameters received. |
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.
[in] | conn_handle | at_ble_handle_t Device connection handle |
[in] | dev_role | at_ble_dev_role_t device role Central or Peripheral |
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_connected_state_handler | ( | void * | params | ) |
function to handle connected event received from stack
ble_connected_state_handler handles the connected event.
References at_ble_addr_t::addr, ALL_UNUSED, AT_BLE_ADDRESS_PUBLIC, AT_BLE_ADDRESS_RANDOM_PRIVATE_RESOLVABLE, at_ble_disconnect(), AT_BLE_FAILURE, AT_BLE_MAX_KEY_LEN, at_ble_random_address_resolve(), AT_BLE_ROLE_CENTRAL, AT_BLE_ROLE_PERIPHERAL, AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, BLE_DEVICE_CONNECTED, ble_device_count, ble_device_current_state, BLE_DEVICE_DEFAULT_IDLE, BLE_MAX_DEVICE_CONNECTION, ble_send_slave_sec_request(), at_ble_connected_t::conn_status, DBG_LOG, DBG_LOG_DEV, at_ble_connected_t::handle, at_ble_connected_t::peer_addr, PERIPHERAL_CONNECTED_STATE, resolve_addr_flag, and at_ble_addr_t::type.
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
[in] | params | of void * type |
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
[in] | params | of void * type |
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.
[in] | conn_handle | at_ble_handle_t Device connection handle |
[in] | dev_role | at_ble_dev_role_t device role Central or Peripheral |
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_disconnected_state_handler | ( | void * | params | ) |
function handles disconnection event received from stack
function called when the AT_BLE_DISCONNECTED event is received from the stack.
References AT_BLE_ATT_INSUFF_AUTHEN, AT_BLE_AUTH_NO_MITM_NO_BOND, AT_BLE_GAP_INVALID_PARAM, AT_BLE_ROLE_NONE, AT_BLE_SUCCESS, BLE_DEVICE_CONNECTED, ble_device_count, BLE_DEVICE_DEFAULT_IDLE, BLE_DEVICE_DISCONNECTED, BLE_DEVICE_ENCRYPTION_COMPLETED, BLE_DEVICE_ENCRYPTION_FAILED, BLE_DEVICE_ENCRYPTION_STATE, BLE_DEVICE_PAIRED, BLE_DEVICE_PAIRING, BLE_DEVICE_PAIRING_FAILED, BLE_MAX_DEVICE_CONNECTION, DBG_LOG, DBG_LOG_DEV, at_ble_disconnected_t::handle, at_ble_disconnected_t::reason, and send_slave_security_flag.
at_ble_status_t ble_encryption_request_handler | ( | void * | params | ) |
function handles encryption requests
function called when the AT_BLE_ENCRYPTION_REQUEST event is received from stack.
References AT_BLE_AUTH_FAILURE, at_ble_disconnect(), at_ble_encryption_request_reply(), AT_BLE_FAILURE, AT_BLE_SUCCESS, BLE_DEVICE_DEFAULT_IDLE, BLE_DEVICE_DISCONNECTED, BLE_DEVICE_ENCRYPTION_STATE, BLE_MAX_DEVICE_CONNECTION, DBG_LOG, DBG_LOG_DEV, at_ble_encryption_request_t::ediv, at_ble_encryption_request_t::handle, at_ble_encryption_request_t::nb, resolve_addr_flag, and temp_param.
Referenced by ble_resolv_rand_addr_handler().
at_ble_status_t ble_encryption_status_change_handler | ( | void * | params | ) |
function handles encryption status change
function called when the AT_BLE_ENCRYPTION_STATUS_CHANGED event is received from stack.
References AT_BLE_FAILURE, AT_BLE_SUCCESS, at_ble_encryption_status_changed_t::authen, BLE_DEVICE_ENCRYPTION_COMPLETED, BLE_DEVICE_ENCRYPTION_FAILED, BLE_DEVICE_ENCRYPTION_STATE, BLE_MAX_DEVICE_CONNECTION, DBG_LOG, at_ble_encryption_status_changed_t::handle, send_slave_security_flag, and at_ble_encryption_status_changed_t::status.
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.
[in] | events | events received from the stack at_ble_events_t. |
[in] | event_params | data received from stack for the respective event received. |
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 |
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
[in] | event_cb_type | Register/Unregister the callback functions |
[in] | event_type | type of BLE event |
[in] | ble_event_handler | structure of function pointers for the event |
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
[in] | params | of at_ble_mtu_changed_ind_t type, Refer to at_ble_mtu_changed_ind_t |
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
[in] | params | of at_ble_mtu_changed_ind_t type, Refer to at_ble_mtu_changed_ind_t |
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_pair_done_handler | ( | void * | params | ) |
function handles pair done event
function called when the AT_BLE_PAIR_DONE event is received from stack.
References at_ble_disconnect(), AT_BLE_FAILURE, AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, at_ble_pair_done_t::auth, ble_check_ispheripheral(), BLE_DEVICE_PAIRED, BLE_DEVICE_PAIRING, BLE_DEVICE_PAIRING_FAILED, BLE_MAX_DEVICE_CONNECTION, ble_store_bonding_info(), DBG_LOG, DBG_LOG_CONT_DEV, DBG_LOG_DEV, at_ble_pair_done_t::handle, at_ble_LTK_t::key, at_ble_CSRK_t::key, at_ble_IRK_t::key, at_ble_pair_done_t::peer_csrk, at_ble_pair_done_t::peer_irk, at_ble_pair_done_t::peer_ltk, and at_ble_pair_done_t::status.
at_ble_status_t ble_pair_key_request_handler | ( | void * | params | ) |
function handles pair key request
function called when the AT_BLE_PAIR_KEY_REQUEST event is received from stack.
References at_ble_disconnect(), AT_BLE_FAILURE, at_ble_pair_key_reply(), AT_BLE_PAIR_OOB, AT_BLE_PAIR_PASSKEY, AT_BLE_PAIR_PASSKEY_DISPLAY, AT_BLE_PAIR_PASSKEY_ENTRY, AT_BLE_PASSKEY_LEN, AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, DBG_LOG, DBG_LOG_CONT, getchar_timeout(), at_ble_pair_key_request_t::handle, at_ble_pair_key_request_t::passkey_type, PIN_TIMEOUT, and at_ble_pair_key_request_t::type.
at_ble_status_t ble_pair_request_handler | ( | void * | params | ) |
function handles pair request
function called when the AT_BLE_PAIR_REQUEST event is received from stack.
References AT_BLE_ADDRESS_RANDOM_PRIVATE_RESOLVABLE, at_ble_authenticate(), AT_BLE_FAILURE, AT_BLE_GAP_INVALID_PARAM, AT_BLE_KEY_DIST_ENC, AT_BLE_KEY_DIST_ID, AT_BLE_SUCCESS, BLE_AUTHENTICATION_LEVEL, BLE_BOND_REQ, BLE_DEVICE_CONNECTED, BLE_DEVICE_PAIRING, BLE_IO_CAPABALITIES, BLE_MAX_DEVICE_CONNECTION, BLE_MITM_REQ, BLE_OOB_REQ, at_ble_pair_features_t::bond, DBG_LOG, DBG_LOG_CONT_DEV, DBG_LOG_DEV, at_ble_pair_features_t::desired_auth, at_ble_pair_request_t::handle, i, at_ble_pair_features_t::initiator_keys, at_ble_pair_features_t::io_cababilities, at_ble_pair_features_t::max_key_size, at_ble_pair_features_t::min_key_size, at_ble_pair_features_t::mitm_protection, NULL, at_ble_pair_features_t::oob_avaiable, and at_ble_pair_features_t::responder_keys.
at_ble_status_t ble_remove_bonding_info | ( | void | ) |
Remove all bonding information from PDS.
Remove all the valid bonding informations from PDS
[in] | None |
AT_BLE_SUCCESS | bonding information removed successfully from the PDS |
AT_BLE_FAILURE | Failed 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_resolv_rand_addr_handler | ( | void * | params | ) |
ble_resolv_rand_addr_handler handles the resolved random address event
[in] | params | of at_ble_resolv_rand_addr_status_t type, Refer to at_ble_resolv_rand_addr_status_t |
References ALL_UNUSED, at_ble_disconnect(), AT_BLE_FAILURE, AT_BLE_MAX_KEY_LEN, AT_BLE_ROLE_PERIPHERAL, AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, BLE_DEVICE_CONNECTED, ble_device_count, BLE_DEVICE_DEFAULT_IDLE, BLE_DEVICE_DISCONNECTED, ble_encryption_request_handler(), BLE_MAX_DEVICE_CONNECTION, ble_send_slave_sec_request(), DBG_LOG, DBG_LOG_DEV, at_ble_connected_t::handle, at_ble_resolv_rand_addr_status_t::irk, resolve_addr_flag, send_slave_security_flag, at_ble_resolv_rand_addr_status_t::status, and temp_param.
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
[in] | None |
AT_BLE_SUCCESS | PDS Restore bonding information is completed. |
AT_BLE_FAILURE | Restore 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 |
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
[in] | None |
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().
|
static |
Set BLE Address, If address is NULL then it will use BD public address.
References at_ble_addr_t::addr, at_ble_dev_config_t::address, at_ble_addr_get(), at_ble_addr_set(), AT_BLE_ADDRESS_PUBLIC, AT_BLE_AUTO_ALLOC_HANDLE, at_ble_set_dev_config(), AT_BLE_SUCCESS, AT_BLE_WRITE_DISABLE, AT_MTU_VAL_RECOMMENDED, AT_RENEW_DUR_VAL_MIN, at_ble_dev_config_t::att_cfg, at_ble_att_cfg_t::b1EnableServiceChanged, at_ble_att_cfg_t::b1EnableSpcs, at_ble_att_cfg_t::b2AppearancePerm, at_ble_att_cfg_t::b2NamePerm, at_ble_att_cfg_t::b2Rfu, DBG_LOG, at_ble_dev_config_t::gap_start_hdl, at_ble_dev_config_t::gatt_start_hdl, at_ble_dev_config_t::max_mtu, NULL, at_ble_dev_config_t::renew_dur, at_ble_dev_config_t::role, and at_ble_addr_t::type.
Referenced by ble_device_init().
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_slave_security_request_handler | ( | void * | params | ) |
References AT_BLE_ADDRESS_RANDOM_PRIVATE_RESOLVABLE, AT_BLE_AUTH_NO_MITM_BOND, at_ble_authenticate(), at_ble_encryption_start(), AT_BLE_FAILURE, AT_BLE_GAP_INVALID_PARAM, AT_BLE_IO_CAP_KB_DISPLAY, AT_BLE_KEY_DIST_ENC, AT_BLE_KEY_DIST_ID, AT_BLE_SUCCESS, BLE_AUTHENTICATION_LEVEL, BLE_DEVICE_CONNECTED, BLE_DEVICE_ENCRYPTION_STATE, BLE_DEVICE_PAIRING, BLE_MAX_DEVICE_CONNECTION, at_ble_pair_features_t::bond, at_ble_slave_sec_request_t::bond, DBG_LOG, at_ble_pair_features_t::desired_auth, at_ble_slave_sec_request_t::handle, i, at_ble_pair_features_t::initiator_keys, at_ble_pair_features_t::io_cababilities, at_ble_pair_features_t::max_key_size, at_ble_pair_features_t::min_key_size, at_ble_pair_features_t::mitm_protection, NULL, at_ble_pair_features_t::oob_avaiable, and at_ble_pair_features_t::responder_keys.
at_ble_status_t ble_store_bonding_info | ( | void * | params | ) |
Store the bonding information.
[in] | None |
AT_BLE_SUCCESS | Stored the bonding information in PDS |
AT_BLE_FAILURE | Failed 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
[in] | params | of void * type |
References ALL_UNUSED, AT_BLE_SUCCESS, and DBG_LOG_DEV.
at_ble_status_t gap_dev_connect | ( | at_ble_addr_t * | dev_addr | ) |
request the peer device for connection
References at_ble_connect(), at_ble_connection_params_t::ce_len_max, at_ble_connection_params_t::ce_len_min, at_ble_connection_params_t::con_intv_max, at_ble_connection_params_t::con_intv_min, at_ble_connection_params_t::con_latency, GAP_CE_LEN_MAX, GAP_CE_LEN_MIN, GAP_CONN_INTERVAL_MAX, GAP_CONN_INTERVAL_MIN, GAP_CONN_SLAVE_LATENCY, GAP_CONNECT_PEER_COUNT, GAP_SUPERVISION_TIMOUT, SCAN_INTERVAL, SCAN_WINDOW, and at_ble_connection_params_t::superv_to.
Referenced by app_connect_request(), pxp_monitor_connect_request(), and pxp_monitor_start_scan().
at_ble_status_t gap_dev_scan | ( | void | ) |
instructs device to start scanning
function to start scan.
References AT_BLE_SCAN_GEN_DISCOVERY, AT_BLE_SCAN_OBSERVER_MODE, at_ble_scan_start(), AT_BLE_SUCCESS, ble_device_current_state, CENTRAL_SCANNING_STATE, DBG_LOG, SCAN_INTERVAL, scan_response_count, SCAN_TIMEOUT, SCAN_TYPE, and SCAN_WINDOW.
Referenced by app_no_device_found_handler(), battery_start_advertisement(), ble_adv_report_app_event(), ble_connected_app_event(), ble_disconnected_app_event(), ble_observer_custom_event(), ble_scan_report_app_event(), pxp_app_init(), pxp_monitor_scan_data_handler(), and pxp_monitor_start_scan().
at_ble_status_t pds_module_init | ( | void | ) |
Initialize the PDS Module.
IInitialize the PDS & NVM Memory
[in] | None |
AT_BLE_SUCCESS | PDS Module Initialize is completed |
AT_BLE_FAILURE | PDS 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.
[in] | scan_info_data | the received data. |
[in] | ble_service_uuid | uuid to be searched in the received data. |
[in] | adv_type | advertisement type |
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().
ble_connected_dev_info_t ble_dev_info[BLE_MAX_DEVICE_CONNECTION] |
Initialize the service with its included service, characteristics, and descriptors.
Peer Connected device info
[in] | scan_param | gatt service information |
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)] |
Referenced by ble_event_task().
const ble_custom_event_cb_t* ble_mgr_custom_event_cb[MAX_CUSTOM_EVENT_SUBSCRIBERS] = {NULL, } |
|
static |
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, } |
|
static |
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, } |
|
static |
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, } |
|
static |
at_ble_connected_t connected_state_info |
at_ble_events_t event |
Referenced by ble_event_get(), ble_event_task(), dispatch_event(), mac_task(), and wpan_task().
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 |
Referenced by ble_connected_state_handler(), ble_encryption_request_handler(), and ble_resolv_rand_addr_handler().
uint32_t rx_fifo_memory[256] = {0} |
at_ble_scan_info_t scan_info[MAX_SCAN_DEVICE] |
volatile uint32_t scan_response_count = 0 |
at_ble_encryption_request_t temp_param[sizeof(at_ble_encryption_request_t)] |
Referenced by ble_encryption_request_handler(), and ble_resolv_rand_addr_handler().