Microchip® Advanced Software Framework

common/components/wifi/winc3400/ble/ble_services/ble_mgr/ble_manager.h File Reference

BLE Manager declarations.

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

#include <asf.h>
#include <string.h>
#include <stddef.h>
#include "at_ble_api.h"
#include "ble_utils.h"
#include "wifi_provisioning.h"
#include "pxp_reporter.h"
#include "pxp_monitor.h"
#include "ble_observer.h"
#include "ancs_profile.h"
#include "time_info.h"
#include "cscp.h"

Data Structures

struct  adv_element
 advertisement data element More...
 
struct  ble_custom_event_cb
 
struct  gatt_service_handler
 GATT service handles. More...
 

Macros

#define ADV_INTERVAL_SIZE   2
 
#define ALERT_LEVEL_CHAR_UUID   (0x2A06)
 
#define APPEARANCE_SIZE   2
 Length of Adv data types. More...
 
#define BAT_CHAR_BAT_LEVEL_UUID   (0x2A19)
 battery level characteristic uuid More...
 
#define BAT_SERVICE_UUID   (0x180F)
 battery service uuid More...
 
#define BLE_ADDITIONAL_CONNECTED_STATE_HANDLER   csc_prf_connected_state_handler
 
#define BLE_ADDITIONAL_CONNECTED_STATE_HANDLER   pxp_reporter_connected_state_handler
 
#define BLE_ADDITIONAL_CONNECTED_STATE_HANDLER   pxp_monitor_connected_state_handler
 
#define BLE_ADDITIONAL_CONNECTED_STATE_HANDLER(param)   anp_client_connected_state_handler(param);
 
#define BLE_ADDITIONAL_CONNECTED_STATE_HANDLER(param)   time_info_service_discover(param);
 
#define BLE_ADDITIONAL_DISCONNECTED_STATE_HANDLER(param)   csc_prf_disconnect_event_handler(param);
 
#define BLE_ADDITIONAL_DISCONNECTED_STATE_HANDLER   pxp_disconnect_event_handler
 
#define BLE_ADDITIONAL_DISCONNECTED_STATE_HANDLER   pxp_disconnect_event_handler
 
#define BLE_ADDITIONAL_DISCONNECTED_STATE_HANDLER(param)   anp_client_disconnected_event_handler(param);
 
#define BLE_ADDITIONAL_DISCONNECTED_STATE_HANDLER(param)   time_info_disconnected_event_handler(param);
 
#define BLE_ADDITIONAL_ENCRYPTION_CHANGED_HANDLER(param)   csc_prf_write_notification_handler(param);
 
#define BLE_ADDITIONAL_ENCRYPTION_CHANGED_HANDLER(param)   anp_client_write_notification_handler(param)
 
#define BLE_ADDITIONAL_PAIR_DONE_HANDLER   csc_prf_write_notification_handler
 
#define BLE_ADDITIONAL_PAIR_DONE_HANDLER(param)   anp_client_write_notification_handler(param)
 
#define BLE_AUTHENTICATION_LEVEL   (AT_BLE_MODE1_L2_AUTH_PAIR_ENC)
 
#define BLE_BOND_REQ   (true)
 
#define BLE_CHARACTERISTIC_CHANGED   csc_prf_char_changed_handler
 
#define BLE_CHARACTERISTIC_CHANGED   wifi_provision_char_changed_handler
 
#define BLE_CHARACTERISTIC_CHANGED   pxp_reporter_char_changed_handler
 
#define BLE_CHARACTERISTIC_CHANGED   anp_client_char_changed_handler
 
#define BLE_CHARACTERISTIC_CHANGED   time_info_char_changed_handler
 
#define BLE_CHARACTERISTIC_FOUND_HANDLER   csc_prf_characteristic_found_handler
 
#define BLE_CHARACTERISTIC_FOUND_HANDLER   pxp_monitor_characteristic_found_handler
 
#define BLE_CHARACTERISTIC_FOUND_HANDLER   anp_client_characteristic_found_handler
 
#define BLE_CHARACTERISTIC_FOUND_HANDLER   time_info_characteristic_found_handler
 
#define BLE_CHARACTERISTIC_READ_RESPONSE   pxp_monitor_characteristic_read_response
 
#define BLE_CHARACTERISTIC_READ_RESPONSE   time_info_characteristic_read_response
 
#define BLE_CHARACTERISTIC_WRITE_RESPONSE   anp_client_write_response_handler
 
#define BLE_CONN_PARAM_UPDATE_DONE   ble_conn_param_update
 
#define BLE_CONNECTED_STATE_HANDLER(param)
 
#define BLE_DESCRIPTOR_FOUND_HANDLER   csc_prf_descriptor_found_handler
 
#define BLE_DESCRIPTOR_FOUND_HANDLER   anp_client_descriptor_found_handler
 
#define BLE_DEVICE_NAME   "MCHP_BLE"
 
#define BLE_DEVICE_NAME   "MCHP-PXP"
 
#define BLE_DEVICE_NAME   "MCHP-MON"
 
#define BLE_DEVICE_NAME   "MCHP-OBS"
 
#define BLE_DEVICE_NAME   "MCHP-ANCS"
 
#define BLE_DEVICE_NAME   "MCHP-TIP"
 
#define BLE_DEVICE_NAME   "MCHP-TRANS"
 
#define BLE_DEVICE_NAME   "MCHP-CSC"
 
#define BLE_DISCONNECTED_STATE_HANDLER(param)
 
#define BLE_DISCOVERY_COMPLETE_HANDLER   csc_prf_discovery_complete_handler
 
#define BLE_DISCOVERY_COMPLETE_HANDLER   pxp_monitor_discovery_complete_handler
 
#define BLE_DISCOVERY_COMPLETE_HANDLER   anp_client_discovery_complete_handler
 
#define BLE_DISCOVERY_COMPLETE_HANDLER   time_info_discovery_complete_handler
 
#define BLE_ENCRYPTION_REQUEST   ble_encryption_request_handler
 
#define BLE_ENCRYPTION_STATUS_CHANGED(param)
 
#define BLE_EVENT_TIMEOUT   (0)
 default device name More...
 
#define BLE_MITM_REQ   (true)
 
#define BLE_NOTIFICATION_RECEIVED_HANDLER   csc_prf_notification_handler
 
#define BLE_NOTIFICATION_RECEIVED_HANDLER   anp_client_notification_handler
 
#define BLE_PAIR_DONE(param)
 
#define BLE_PAIR_DONE   pxp_monitor_pair_done_handler
 
#define BLE_PAIR_KEY_REQUEST   ble_pair_key_request_handler
 
#define BLE_PAIR_KEY_REQUEST   ble_pair_key_request_handler
 
#define BLE_PAIR_REQUEST   ble_pair_request_handler
 
#define BLE_PRIMARY_SERVICE_FOUND_HANDLER   csc_prf_service_found_handler
 
#define BLE_PRIMARY_SERVICE_FOUND_HANDLER   pxp_monitor_service_found_handler
 
#define BLE_PRIMARY_SERVICE_FOUND_HANDLER   anp_client_service_found_handler
 
#define BLE_PRIMARY_SERVICE_FOUND_HANDLER   time_info_service_found_handler
 
#define BLE_PROFILE_INIT(param)
 Function handlers for proximity monitor. More...
 
#define BLE_PROFILE_INIT   wifi_provision_init
 Function handlers for proximity monitor. More...
 
#define BLE_PROFILE_INIT   pxp_reporter_init
 Function handlers for proximity monitor. More...
 
#define BLE_PROFILE_INIT   pxp_monitor_init
 Function handlers for proximity monitor. More...
 
#define BLE_PROFILE_INIT   anp_client_init
 Function handlers for proximity monitor. More...
 
#define BLE_PROFILE_INIT   time_info_init
 Function handlers for proximity monitor. More...
 
#define BLE_SCAN_DATA_HANDLER   ble_observer_scan_data_handler
 
#define BLE_SCAN_DATA_HANDLER   pxp_monitor_scan_data_handler
 
#define BLE_SCAN_INFO_HANDLER(param)
 
#define BLE_SCAN_INFO_HANDLER   ble_scan_info_handler
 
#define BLE_SCAN_REPORT_HANDLER   ble_scan_report_handler
 
#define BLE_SCAN_REPORT_HANDLER   ble_scan_report_handler
 
#define BLE_SERVICE_CHANGED   wifi_provision_svc_changed_handler
 
#define BLE_SLAVE_SEC_REQUEST   ble_slave_security_handler
 
#define BLE_SLAVE_SEC_REQUEST   ble_slave_security_handler
 
#define BODY_SENSOR_LOCATION_CHAR_UUID   (0x2A38)
 Body Sensor location characteristic uuid. More...
 
#define BREDR_NOT_SUPPORTED   ((uint8_t) 1 << 2)
 
#define CSC_ENDPOINT_CHAR_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\xa6\x85\xe5\x11\x35\x39\xa1\xbb\x5a\xfd")
 CSC Endpoint Characteristic UUID. More...
 
#define CSC_SERVICE_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\xa6\x85\xe5\x11\x35\x39\xa0\xbb\x5a\xfd")
 CSC Service UUID. More...
 
#define CURRENT_TIME_CHAR_UUID   (0x2A2B)
 
#define CURRENT_TIME_SERVICE_UUID   (0x1805)
 
#define DIS_CHAR_FIRMWARE_REVISION_UUID   (0x2A26)
 
#define DIS_CHAR_HARDWARE_REVISION_UUID   (0x2A27)
 
#define DIS_CHAR_IEEE_REG_CERT_DATA_LIST_UUID   (0x2A2A)
 
#define DIS_CHAR_MANUFACTURER_NAME_UUID   (0x2A29)
 
#define DIS_CHAR_MODEL_NUMBER_UUID   (0x2A24)
 
#define DIS_CHAR_PNP_ID_UUID   (0x2A50)
 
#define DIS_CHAR_SERIAL_NUMBER_UUID   (0x2A25)
 
#define DIS_CHAR_SOFTWARE_REVISION_UUID   (0x2A28)
 
#define DIS_CHAR_SYSTEM_ID_UUID   (0x2A23)
 
#define DIS_SERVICE_UUID   (0x180A)
 
#define GAP_CE_LEN_MAX   (0)
 maximum length of local info parameters when using connection establishment proc More...
 
#define GAP_CE_LEN_MIN   (0)
 minimum length of local info parameters when using connection establishment proc More...
 
#define GAP_CONN_INTERVAL_MAX   (40)
 maximum connection interval More...
 
#define GAP_CONN_INTERVAL_MIN   (20)
 minimum connection interval More...
 
#define GAP_CONN_SLAVE_LATENCY   (0)
 connection slave latency More...
 
#define GAP_CONNECT_PEER_COUNT   (1)
 number of connections More...
 
#define GAP_SUPERVISION_TIMEOUT   (0x1f4)
 supervision time-out More...
 
#define GATT_DISCOVERY_ENDING_HANDLE   (0xFFFF)
 gatt discover end handle More...
 
#define GATT_DISCOVERY_STARTING_HANDLE   (0x0001)
 gatt discover start handle More...
 
#define HEART_RATE_CONTROL_POINT_CHAR_UUID   (0x2A39)
 Heart Rate Control Point characteristic uuid. More...
 
#define HEART_RATE_MEASUREMENT_CHAR_UUID   (0x2A37)
 heart rate measurement characteristic uuid More...
 
#define HEART_RATE_SERVICE_UUID   (0x180D)
 
#define IMMEDIATE_ALERT_SERVICE_UUID   (0x1802)
 
#define LE_BREDR_CAPABLE_CONTROLLER   ((uint8_t) 1 << 3)
 
#define LE_BREDR_CAPABLE_HOST   ((uint8_t) 1 << 4)
 
#define LE_GENERAL_DISCOVERABLE_MODE   ((uint8_t) 1 << 1)
 
#define LE_LIMITED_DISCOVERABLE_MODE   ((uint8_t) 1 << 0)
 Observer related declarations. More...
 
#define LINK_LOSS_SERVICE_UUID   (0x1803)
 
#define MAX_DEVICE_CONNECTED   (1)
 maximum number of devices connected More...
 
#define MAX_SCAN_DEVICE   (10)
 
#define SCAN_INTERVAL   (0x140)
 
#define SCAN_TIMEOUT   (0x0000)
 
#define SCAN_TYPE   (AT_BLE_SCAN_ACTIVE)
 
#define SCAN_WINDOW   (0x60)
 
#define SPS_CHAR_SCAN_INT_VALUE_UUID   (0x2A4F)
 scan interval characteristic uuid More...
 
#define SPS_CHAR_SCAN_REFRESH_UUID   (0x2A31)
 scan refresh characteristic uuid More...
 
#define SPS_SERVICE_UUID   (0x1813)
 Scan param service uuid. More...
 
#define TOTAL_CHARACTERISTIC_NUM   3
 
#define TX_POWER_LEVEL_CHAR_UUID   (0x2A07)
 
#define TX_POWER_LEVEL_SIZE   1
 
#define TX_POWER_SERVICE_UUID   (0x1804)
 
#define UUID_MCHP_PROPRIETARY_SERVICE_16   0x55,0xE4,0x05,0xD2,0xAF,0x9F,0xA9,0x8F,0xE5,0x4A,0x7D,0xFE,0x43,0x53,0x53,0x49
 
#define UUID_MCHP_TRANS_CTRL_16   0x7e,0x3b,0x07,0xff,0x1c,0x51,0x49,0x2f,0xb3,0x39,0x8a,0x4c,0x43,0x53,0x53,0x49
 
#define UUID_MCHP_TRANS_RX_16   0xB3,0x9B,0x72,0x34,0xBE,0xEC,0xD4,0xA8,0xF4,0x43,0x41,0x88,0x43,0x53,0x53,0x49
 
#define UUID_MCHP_TRANS_TX_16   0x16,0x96,0x24,0x47,0xC6,0x23,0x61,0xBA,0xD9,0x4B,0x4D,0x1E,0x43,0x53,0x53,0x49
 
#define WIFI_CON_APPARAM_CHAR_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\x89\x86\xe4\x11\x29\xd2\x03\x00\x88\x77")
 
#define WIFI_CON_SERVICE_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\x89\x86\xe4\x11\x29\xd2\x01\x00\x88\x77")
 Service UUID's. More...
 
#define WIFI_CON_STATE_CHAR_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\x89\x86\xe4\x11\x29\xd2\x02\x00\x88\x77")
 
#define WIFI_SCAN_APCOUNT_CHAR_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\xa1\x85\xe4\x11\x24\xd2\x03\x00\x8c\xfb")
 
#define WIFI_SCAN_APDETAILS_CHAR_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\xa1\x85\xe4\x11\x24\xd2\x00\x01\x8c\xfb")
 
#define WIFI_SCAN_MODE_CHAR_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\xa1\x85\xe4\x11\x24\xd2\x02\x00\x8c\xfb")
 
#define WIFI_SCAN_SERVICE_UUID   ("\x1b\xc5\xd5\xa5\x02\x00\xa1\x85\xe4\x11\x24\xd2\x01\x00\x8c\xfb")
 

Typedefs

typedef struct adv_element adv_element_t
 advertisement data element More...
 
typedef at_ble_status_t(* ble_characteristic_changed_callback_t )(at_ble_characteristic_changed_t *)
 
typedef struct ble_custom_event_cb ble_custom_event_cb_t
 
typedef enum ble_device_ll_state ble_device_ll_state_t
 
typedef at_ble_status_t(* ble_event_callback_t )(void *params)
 
typedef void(* ble_gap_event_callback_t )(at_ble_handle_t)
 
typedef struct gatt_service_handler gatt_service_handler_t
 GATT service handles. More...
 

Enumerations

enum  ble_device_ll_state {
  BLE_DEVICE_IDLE_STATE,
  PERIPHERAL_ADVERTISING_STATE,
  CENTRAL_SCANNING_STATE,
  PERIPHERAL_CONNECTED_STATE,
  PERIPHERAL_PAIRED_STATE,
  PERIPHERAL_ENCRYPTION_STATE,
  PERIPHERAL_DISCONNECTED_STATE,
  BLE_DEVICE_IDLE_STATE,
  PERIPHERAL_ADVERTISING_STATE,
  CENTRAL_SCANNING_STATE,
  PERIPHERAL_CONNECTED_STATE,
  PERIPHERAL_PAIRED_STATE,
  PERIPHERAL_ENCRYPTION_STATE,
  PERIPHERAL_DISCONNECTED_STATE
}
 
enum  gap_ad_type {
  FLAGS = 0x01,
  INCOMPLETE_LIST_16BIT_SERV_UUIDS,
  COMPLETE_LIST_16BIT_SERV_UUIDS,
  INCOMPLETE_LIST_32BIT_SERV_UUIDS,
  COMPLETE_LIST_32BIT_SERV_UUIDS,
  INCOMPLETE_LIST_128BIT_SERV_UUIDS,
  COMPLETE_LIST_128BIT_SERV_UUIDS,
  SHORTENED_LOCAL_NAME,
  COMPLETE_LOCAL_NAME,
  TX_POWER_LEVEL,
  CLASS_OF_DEVICE = 0x0D,
  SIMPLE_PAIRING_HASHING,
  SIMPLE_PAIRING_RANDOMIZER,
  DEVICE_ID,
  SECURITY_MANAGER_OOB_FLAGS,
  SLAVE_CONNECTION_INTERVAL_RANGE,
  LIST_16BIT_SERV_SOLICITATION_UUIDS = 0x14,
  LIST_128BIT_SERV_SOLICITATION_UUIDS,
  SERVICE_DATA,
  PUBLIC_TARGET_ADDRESS,
  RANDOM_TARGET_ADDRESS,
  APPEARANCE,
  ADVERTISING_INTERVAL,
  LE_BLUETOOTH_DEVICE_ADDRESS,
  LE_ROLE,
  SIMPLE_PAIRING_HASHING_C256,
  SIMPLE_PAIRING_RANDOMIZER_R256,
  SERVICE_DATA_32BIT = 0x20,
  SERVICE_DATA_128BIT,
  LE_SECURE_CONNECTIONS_CONFIRMATION_VALUE,
  LE_SECURE_CONNECTIONS_RANDOM_VALUE,
  THREED_INFORMATION_DATA = 0x3D,
  MANUFACTURER_SPECIFIC_DATA = 0xFF,
  FLAGS = 0x01,
  INCOMPLETE_LIST_16BIT_SERV_UUIDS,
  COMPLETE_LIST_16BIT_SERV_UUIDS,
  INCOMPLETE_LIST_32BIT_SERV_UUIDS,
  COMPLETE_LIST_32BIT_SERV_UUIDS,
  INCOMPLETE_LIST_128BIT_SERV_UUIDS,
  COMPLETE_LIST_128BIT_SERV_UUIDS,
  SHORTENED_LOCAL_NAME,
  COMPLETE_LOCAL_NAME,
  TX_POWER_LEVEL,
  CLASS_OF_DEVICE = 0x0D,
  SIMPLE_PAIRING_HASHING,
  SIMPLE_PAIRING_RANDOMIZER,
  DEVICE_ID,
  SECURITY_MANAGER_OOB_FLAGS,
  SLAVE_CONNECTION_INTERVAL_RANGE,
  LIST_16BIT_SERV_SOLICITATION_UUIDS = 0x14,
  LIST_128BIT_SERV_SOLICITATION_UUIDS,
  SERVICE_DATA,
  PUBLIC_TARGET_ADDRESS,
  RANDOM_TARGET_ADDRESS,
  APPEARANCE,
  ADVERTISING_INTERVAL,
  LE_BLUETOOTH_DEVICE_ADDRESS,
  LE_ROLE,
  SIMPLE_PAIRING_HASHING_C256,
  SIMPLE_PAIRING_RANDOMIZER_R256,
  LIST_32BIT_SERV_SOLICITATION_UUIDS,
  SERVICE_DATA_32BIT = 0x20,
  SERVICE_DATA_128BIT,
  LE_SECURE_CONNECTIONS_CONFIRMATION_VALUE,
  LE_SECURE_CONNECTIONS_RANDOM_VALUE,
  THREED_INFORMATION_DATA = 0x3D,
  MANUFACTURER_SPECIFIC_DATA = 0xFF
}
 Gap Advertisement Types. More...
 

Functions

void ble_characteristic_found_handler (at_ble_characteristic_found_t *characteristic_found)
 function called when the AT_BLE_CHARACTERISTIC_FOUND event is received from stack. More...
 
void ble_conn_param_update (at_ble_conn_param_update_done_t *conn_param_update)
 function used to update the connection parameter. More...
 
void ble_connected_state_handler (at_ble_connected_t *conn_params)
 function called when the AT_BLE_CONNECTED event is received from the stack. More...
 
void ble_device_init (at_ble_addr_t *addr)
 function sets both device address and device name which are exposed to all other devices. More...
 
void ble_disconnected_state_handler (at_ble_disconnected_t *disconnect)
 function called when the AT_BLE_DISCONNECTED event is received from the stack. More...
 
void ble_discovery_complete_handler (at_ble_discovery_complete_t *discover_status)
 function called when the AT_BLE_DISCOVERY_COMPLETE event is received from the stack. More...
 
static void ble_dummy_handler (void *param)
 
void ble_encryption_request_handler (at_ble_encryption_request_t *encry_req)
 function called when the AT_BLE_ENCRYPTION_REQUEST event is received from stack. More...
 
void ble_encryption_status_change_handler (at_ble_encryption_status_changed_t *encry_status)
 function called when the AT_BLE_ENCRYPTION_STATUS_CHANGED event is received from stack. 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 handle the BLE event task. More...
 
at_ble_status_t ble_pair_done_handler (at_ble_pair_done_t *pairing_params)
 function called when the AT_BLE_PAIR_DONE event is received from stack. More...
 
void ble_pair_key_request_handler (at_ble_pair_key_request_t *pair_key)
 function called when the AT_BLE_PAIR_KEY_REQUEST event is received from stack. More...
 
void ble_pair_request_handler (at_ble_pair_request_t *at_ble_pair_req)
 function called when the AT_BLE_PAIR_REQUEST event is received from stack. More...
 
at_ble_status_t ble_scan_info_handler (at_ble_scan_info_t *scan_param)
 function to handle the scan information. More...
 
at_ble_status_t ble_scan_report_handler (at_ble_scan_report_t *scan_report)
 function to handle the scan status. More...
 
at_ble_status_t ble_send_slave_sec_request (at_ble_handle_t conn_handle)
 function to send slave security request. More...
 
at_ble_status_t ble_set_device_name (uint8_t *name, uint8_t name_len)
 function to set the device name. More...
 
void ble_slave_security_handler (at_ble_slave_sec_request_t *slave_sec_req)
 slave security handler More...
 
static at_ble_status_t BLE_UNUSED2_VAR (void *param1_var, void *param2_var)
 
at_ble_status_t gap_dev_connect (at_ble_addr_t dev_addr[])
 function requesting the device for the connection. More...
 
at_ble_status_t gap_dev_scan (void)
 function to start scan. More...
 
void register_ble_characteristic_changed_cb (ble_characteristic_changed_callback_t char_changed_cb_fn)
 Register callback function, to be triggered when characteristic value is changed. More...
 
void register_ble_connected_event_cb (ble_gap_event_callback_t connected_cb_fn)
 Register callback function, to be triggered when connected to the device. More...
 
void register_ble_disconnected_event_cb (ble_gap_event_callback_t disconnected_cb_fn)
 Register callback function, to be triggered when disconnected from the peer device. More...
 
void register_ble_paired_event_cb (ble_gap_event_callback_t paired_cb_fn)
 Register callback function, to be triggered when pairing procedure is completed. More...
 
uint8_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...