Microchip® Advanced Software Framework

common/components/wifi/winc3400/ble/ble_profiles/pxp_monitor/pxp_monitor.h File Reference

Proximity Monitor Profile declarations.

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

#include "ble_manager.h"

Macros

#define DBG_LOG_PTS   ALL_UNUSED
 
#define DISCOVER_SUCCESS   (10)
 
#define PXP_ASCII_TO_DECIMAL_VALUE   ('0')
 
#define PXP_CONNECT_REQ_INTERVAL   (20)
 
#define PXP_HIGH_ALERT_RANGE   (-90)
 
#define PXP_LOW_ALERT_RANGE   (-70)
 
#define PXP_RSSI_UPDATE_INTERVAL   (0x01)
 

Enumerations

enum  AD_TYPE {
  AD_TYPE_FLAGS = 01,
  AD_TYPE_COMPLETE_LIST_UUID = 0x03,
  AD_TYPE_COMPLETE_LOCAL_NAME = 0x09,
  AD_TYPE_FLAGS = 01,
  AD_TYPE_COMPLETE_LIST_UUID = 0x03,
  AD_TYPE_COMPLETE_LOCAL_NAME = 0x09
}
 
enum  PXP_DEV {
  PXP_DEV_UNCONNECTED,
  PXP_DEV_CONNECTING,
  PXP_DEV_CONNECTED,
  PXP_DEV_UNCONNECTED,
  PXP_DEV_CONNECTING,
  PXP_DEV_CONNECTED
}
 

Functions

at_ble_status_t pxp_disconnect_event_handler (void *params)
 peer device connection terminated More...
 
at_ble_status_t pxp_monitor_characteristic_found_handler (void *params)
 Handles all Discovered characteristics of a given handler in a connected device. More...
 
at_ble_status_t pxp_monitor_characteristic_read_response (void *params)
 Handles the read response from the peer/connected device. More...
 
at_ble_status_t pxp_monitor_connect_request (at_ble_scan_info_t *scan_buffer, uint8_t index)
 Connect to a peer device. More...
 
at_ble_status_t pxp_monitor_connected_state_handler (void *params)
 Connected event state handle after connection request to peer device. More...
 
at_ble_status_t pxp_monitor_discovery_complete_handler (void *params)
 Discover all Characteristics supported for Proximity Service of a connected device and handles discovery complete Search will go from start_handle to end_handle, whenever a characteristic is found After search and discovery completes will initialize the alert level and read the tx power value as defined AT_BLE_CHARACTERISTIC_FOUND event is sent and AT_BLE_DISCOVERY_COMPLETE is sent at end of discover operation. More...
 
at_ble_status_t pxp_monitor_encryption_change_handler (void *params)
 
void pxp_monitor_init (void *param)
 
at_ble_status_t pxp_monitor_pair_done_handler (void *params)
 
at_ble_status_t pxp_monitor_scan_data_handler (at_ble_scan_info_t *scan_info, uint8_t scan_count)
 Search for a given AD type in a buffer, received from advertising packets. More...
 
at_ble_status_t pxp_monitor_service_discover (at_ble_handle_t)
 Discover all services. More...
 
at_ble_status_t pxp_monitor_service_found_handler (void *params)
 Discover the Proximity services. More...
 
at_ble_status_t pxp_monitor_start_scan (void)
 

#define PXP_ASCII_TO_DECIMAL_VALUE   ('0')
#define PXP_CONNECT_REQ_INTERVAL   (20)
#define PXP_HIGH_ALERT_RANGE   (-90)

Referenced by pxp_monitor_init(), and rssi_update().

#define PXP_LOW_ALERT_RANGE   (-70)

Referenced by pxp_monitor_init(), and rssi_update().

#define PXP_RSSI_UPDATE_INTERVAL   (0x01)

enum AD_TYPE
Enumerator
AD_TYPE_FLAGS 
AD_TYPE_COMPLETE_LIST_UUID 
AD_TYPE_COMPLETE_LOCAL_NAME 
AD_TYPE_FLAGS 
AD_TYPE_COMPLETE_LIST_UUID 
AD_TYPE_COMPLETE_LOCAL_NAME 
enum PXP_DEV
Enumerator
PXP_DEV_UNCONNECTED 
PXP_DEV_CONNECTING 
PXP_DEV_CONNECTED 
PXP_DEV_UNCONNECTED 
PXP_DEV_CONNECTING 
PXP_DEV_CONNECTED 

at_ble_status_t pxp_disconnect_event_handler ( void *  params)

peer device connection terminated

handler for disconnect notification try to send connect request for previously connect device.

Parameters
[in]availabledisconnect handler of peer and reason for disconnection
Returns
AT_BLE_SUCCESS Reconnect request sent to previously connected device
AT_BLE_FAILURE Reconnection fails.
at_ble_status_t pxp_monitor_characteristic_found_handler ( void *  params)

Handles all Discovered characteristics of a given handler in a connected device.

Compare the characteristics UUID with proximity services whenever a characteristics is found if compare stores the characteristics handler of respective service

Parameters
[in]characteristic_foundDiscovered characteristics params of a connected device
at_ble_status_t pxp_monitor_characteristic_read_response ( void *  params)

Handles the read response from the peer/connected device.

if any read request send, response back event is handle. compare the read response characteristics with available service. and data is handle to the respective service.

at_ble_status_t pxp_monitor_connect_request ( at_ble_scan_info_t scan_buffer,
uint8_t  index 
)

Connect to a peer device.

Connecting to a peer device, implicitly starting the necessary scan operation then connecting if a device in the peers list is found.

Parameters
[in]scan_buffera list of peers that the device will connect to one of them
[in]indexindex of elements in peers, to initiate the connection
Returns
AT_BLE_SUCCESS operation programmed successfully
AT_BLE_INVALID_PARAM incorrect parameter.
AT_BLE_FAILURE Generic error.
at_ble_status_t pxp_monitor_connected_state_handler ( void *  params)

Connected event state handle after connection request to peer device.

After connecting to the peer device start the GATT primary discovery

Parameters
[in]at_ble_connected_tparameters of the established connection
Returns
AT_BLE_SUCCESS operation programmed successfully.
AT_BLE_INVALID_PARAM if GATT discovery parameter are incorrect parameter.
AT_BLE_FAILURE Generic error.

After connecting to the peer device start the GATT primary discovery

Parameters
[in]conn_paramsparameters of the established connection
Returns
AT_BLE_SUCCESS operation successfully.
AT_BLE_INVALID_PARAM if GATT discovery parameter are incorrect parameter.
AT_BLE_FAILURE Generic error.
at_ble_status_t pxp_monitor_discovery_complete_handler ( void *  params)

Discover all Characteristics supported for Proximity Service of a connected device and handles discovery complete Search will go from start_handle to end_handle, whenever a characteristic is found After search and discovery completes will initialize the alert level and read the tx power value as defined AT_BLE_CHARACTERISTIC_FOUND event is sent and AT_BLE_DISCOVERY_COMPLETE is sent at end of discover operation.

Parameters
[in]discover_statusdiscovery status on each
[in]start_handlestart of the searched range
[in]end_handleend of the searched range
[in]discover_statusdiscovery status of each handle
at_ble_status_t pxp_monitor_encryption_change_handler ( void *  params)
void pxp_monitor_init ( void *  param)
at_ble_status_t pxp_monitor_pair_done_handler ( void *  params)
at_ble_status_t pxp_monitor_scan_data_handler ( at_ble_scan_info_t scan_info,
uint8_t  scan_count 
)

Search for a given AD type in a buffer, received from advertising packets.

starts search form the buffer, need to provide required search params

Parameters
[in]scan_bufferwhere all received advertising packet are stored
[in]scanned_dev_countelements in scan_buffer
Returns
AT_BLE_SUCCESS operation programmed successfully
AT_BLE_INVALID_PARAM incorrect parameter.
AT_BLE_FAILURE Generic error.

Search for a given AD type in a buffer, received from advertising packets.

Parameters
[in]scan_bufferwhere all received advertising packet are stored
[in]scanned_dev_countelements in scan_buffer
Returns
AT_BLE_SUCCESS operation programmed successfully
AT_BLE_INVALID_PARAM incorrect parameter.
AT_BLE_FAILURE Generic error.

References AD_TYPE_COMPLETE_LIST_UUID, at_ble_addr_t::addr, AT_BLE_ADV_TYPE_DIRECTED, AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_FAILURE, at_ble_scan_stop(), AT_BLE_SUCCESS, AT_BLE_UUID_16, DBG_LOG, DBG_LOG_CONT, at_ble_scan_info_t::dev_addr, gap_dev_scan(), LINK_LOSS_SERVICE_UUID, MAX_SCAN_DEVICE, PXP_ASCII_TO_DECIMAL_VALUE, pxp_monitor_connect_request(), pxp_supp_scan_index, scan_index, scan_info, scan_info_parse(), at_ble_uuid_t::type, and at_ble_uuid_t::uuid.

at_ble_status_t pxp_monitor_service_discover ( at_ble_handle_t  handle)

Discover all services.

Parameters
[in]connectionhandle.
Returns
AT_BLE_SUCCESS operation programmed successfully
AT_BLE_INVALID_PARAM incorrect parameter.
AT_BLE_FAILURE Generic error.
Parameters
[in]connectionhandle.
Returns
AT_BLE_SUCCESS operation programmed successfully.
AT_BLE_INVALID_PARAM incorrect parameter.
AT_BLE_FAILURE Generic error.
at_ble_status_t pxp_monitor_service_found_handler ( void *  params)

Discover the Proximity services.

Search will go from start_handle to end_handle, whenever a service is found and compare with proximity services and stores the respective handlers PXP_MONITOR_CONNECTED_STATE_HANDLER event i.

Parameters
[in]at_ble_primary_service_found_tPrimary service parameter
Returns
AT_BLE_SUCCESS operation programmed successfully
AT_BLE_INVALID_PARAM incorrect parameter.
AT_BLE_FAILURE Generic error.

Search will go from start_handle to end_handle, whenever a service is found and compare with proximity services and stores the respective handlers PXP_MONITOR_CONNECTED_STATE_HANDLER event i.

Parameters
[in]at_ble_primary_service_found_tPrimary service parameter
at_ble_status_t pxp_monitor_start_scan ( void  )