Microchip® Advanced Software Framework

gapm_task.h File Reference
#include "cmn_defs.h"
#include "ll_if.h"

Data Structures

struct  peers_info
 

Macros

#define AD_TYPE_NAME   (0x09)
 
#define ADV_DATA_MAX_SIZE   (31-3) /*32 including the size in 1st byte*/
 Advertising data maximal length. More...
 
#define APP_ADV_DEV_NAME   "\x4e\x4d\x49\x2D\x42\x4C\x45"
 
#define APP_ADV_DEV_NAME_LEN   (7)
 
#define APP_ZERO_PAD_DATA   "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0"
 
#define ATTC_1ST_REQ_END_HDL   0xFFFF
 
#define ATTC_1ST_REQ_START_HDL   0x0001
 
#define EVENT_TYPE_ADVERTISING   0
 
#define EVENT_TYPE_SCAN_RESP   4
 
#define GAP_CONN_LATENCY   0x0000
 Connection latency default value: 0x0000. More...
 
#define GAP_CONN_MAX_CE   0x0140
 Maximum connection event default value: 0xFFFF. More...
 
#define GAP_CONN_MIN_CE   0x0000
 Minimum connection event default value: 0x0000. More...
 
#define GAP_CONN_SUPERV_TIMEOUT   0x01f4
 Connection supervision timeout recommended value: 20s. More...
 
#define GAP_INIT_CONN_MAX_INTV   0x00a0
 
#define GAP_INIT_CONN_MIN_INTV   0x00a0
 Minimum to maximum connection interval upon any connection establishment: TGAP(initial_conn_interval) recommended value: 30 to 50 ms ; N * 1.25 ms. More...
 
#define GAP_INQ_SCAN_INTV   0x0140
 RW Defines. More...
 
#define GAP_INQ_SCAN_WIND   0x00a0
 
#define GAP_TMR_PRIV_ADDR_INT   0xEA60
 
#define SCAN_RESP_DATA_MAX_SIZE   (31) /*32 including the size in 1st byte*/
 Scan Response data maximal length. More...
 

Enumerations

enum  {
  GAP_GEN_INQ_TYPE = 0x00,
  GAP_LIM_INQ_TYPE,
  GAP_KNOWN_DEV_INQ_TYPE
}
 Device discovery search type. More...
 
enum  {
  GAP_BOND_ACCEPT = 0,
  GAP_BOND_REJECT = 1
}
 
enum  {
  SCAN_FILT_DUPLIC_DIS = 0x00,
  SCAN_FILT_DUPLIC_EN,
  SCAN_FILT_DUPLIC_END
}
 Filter duplicates. More...
 
enum  {
  GAPM_CMP_EVT = 0x3400,
  GAPM_DEVICE_READY_IND,
  GAPM_RESET_CMD,
  GAPM_CANCEL_CMD,
  GAPM_SET_DEV_CONFIG_CMD,
  GAPM_SET_DEV_NAME_CMD,
  GAPM_SET_CHANNEL_MAP_CMD,
  GAPM_GET_DEV_INFO_CMD,
  GAPM_DEV_NAME_IND,
  GAPM_APPEARANCE_IND,
  GAPM_DEV_VERSION_IND,
  GAPM_DEV_BDADDR_IND,
  GAPM_WHITE_LIST_MGT_CMD,
  GAPM_WHITE_LIST_SIZE_IND,
  GAPM_START_ADVERTISE_CMD,
  GAPM_START_SCAN_CMD,
  GAPM_ADV_REPORT_IND,
  GAPM_START_CONNECTION_CMD,
  GAPM_PEER_NAME_IND,
  GAPM_CONNECTION_CFM,
  GAPM_UPDATED_PRIVACY_IND,
  GAPM_UPDATED_RECON_ADDR_IND,
  GAPM_RESOLV_ADDR_CMD,
  GAPM_ADDR_SOLVED_IND,
  GAPM_GEN_RAND_ADDR_CMD,
  GAPM_USE_ENC_BLOCK_CMD,
  GAPM_USE_ENC_BLOCK_IND,
  GAPM_GEN_RAND_NB_CMD,
  GAPM_GEN_RAND_NB_IND,
  GAPM_DBG_MEM_INFO_IND,
  GAPM_DEV_ADV_TX_POWER_IND,
  GAPM_LIM_DISC_TO_IND,
  GAPM_SCAN_TO_IND,
  GAPM_ADDR_RENEW_TO_IND
}
 GAP Interface. More...
 
enum  gap_adv_mode {
  GAP_NON_DISCOVERABLE,
  GAP_GEN_DISCOVERABLE,
  GAP_LIM_DISCOVERABLE,
  GAP_BROADCASTER_MODE
}
 Advertising mode. More...
 
enum  gap_err_code {
  GAP_ERR_NO_ERROR = 0x00,
  GAP_ERR_INVALID_PARAM = 0x40,
  GAP_ERR_PROTOCOL_PROBLEM,
  GAP_ERR_NOT_SUPPORTED,
  GAP_ERR_COMMAND_DISALLOWED,
  GAP_ERR_CANCELED,
  GAP_ERR_TIMEOUT,
  GAP_ERR_DISCONNECTED,
  GAP_ERR_NOT_FOUND,
  GAP_ERR_REJECTED,
  GAP_ERR_PRIVACY_CFG_PB,
  GAP_ERR_ADV_DATA_INVALID
}
 GAP Specific Error. More...
 
enum  gap_role {
  GAP_NO_ROLE = 0x00,
  GAP_OBSERVER_SCA = 0x01,
  GAP_BROADCASTER_ADV = 0x02,
  GAP_CENTRAL_MST = (0x04 | GAP_OBSERVER_SCA),
  GAP_PERIPHERAL_SLV = (0x08 | GAP_BROADCASTER_ADV)
}
 
enum  gap_scan_mode {
  GAP_GEN_DISCOVERY,
  GAP_LIM_DISCOVERY,
  GAP_OBSERVER_MODE,
  GAP_INVALID_MODE
}
 Scan mode. More...
 
enum  gapm_operation {
  GAPM_NO_OP = 0x00,
  GAPM_RESET,
  GAPM_CANCEL,
  GAPM_SET_DEV_CONFIG,
  GAPM_SET_DEV_NAME,
  GAPM_SET_CHANNEL_MAP,
  GAPM_GET_DEV_NAME,
  GAPM_GET_DEV_VERSION,
  GAPM_GET_DEV_BDADDR,
  GAPM_GET_WLIST_SIZE,
  GAPM_ADD_DEV_IN_WLIST,
  GAPM_RMV_DEV_FRM_WLIST,
  GAPM_CLEAR_WLIST,
  GAPM_ADV_NON_CONN,
  GAPM_ADV_UNDIRECT,
  GAPM_ADV_DIRECT,
  GAPM_SCAN_ACTIVE,
  GAPM_SCAN_PASSIVE,
  GAPM_CONNECTION_DIRECT,
  GAPM_CONNECTION_AUTO,
  GAPM_CONNECTION_SELECTIVE,
  GAPM_CONNECTION_NAME_REQUEST,
  GAPM_RESOLV_ADDR,
  GAPM_GEN_RAND_ADDR,
  GAPM_USE_ENC_BLOCK,
  GAPM_GEN_RAND_NB,
  GAPM_DBG_GET_MEM_INFO,
  GAPM_PLF_RESET,
  GAPM_GET_DEV_ADV_TX_POWER,
  GAPM_LAST
}
 GAP Manager operation type - application interface. More...
 
enum  gapm_own_addr_src {
  GAPM_PUBLIC_ADDR,
  GAPM_PROVIDED_RND_ADDR,
  GAPM_GEN_STATIC_RND_ADDR,
  GAPM_GEN_RSLV_ADDR,
  GAPM_GEN_NON_RSLV_ADDR,
  GAPM_PROVIDED_RECON_ADDR,
  GAPM_INVALID_ADDR
}
 Own BD address source of the device. More...
 
enum  gapm_write_att_perm {
  GAPM_WRITE_DISABLE = PERM(WR, DISABLE),
  GAPM_WRITE_ENABLE = PERM(WR, ENABLE),
  GAPM_WRITE_UNAUTH = PERM(WR, UNAUTH),
  GAPM_WRITE_AUTH = PERM(WR, AUTH)
}
 Device Attribute write permission requirement. More...
 

Functions

at_ble_status_t gapm_addr_solved_ind_handler (uint8_t *data, at_ble_resolv_rand_addr_status_t *params)
 
at_ble_status_t gapm_adv_report_evt_handler (uint8_t *data, at_ble_scan_info_t *param)
 
at_ble_status_t gapm_cancel_cmd_handler (void)
 
at_ble_events_t gapm_cmp_evt (uint8_t *data, void *params)
 
at_ble_status_t gapm_connection_cfm_handler (uint8_t *pu8PeerBdAddr, uint8_t u8PeerAddrType, uint16_t u16ConIntvMin, uint16_t u16ConIntvMax, uint16_t u16ConLatency, uint16_t u16SupervTO, uint16_t u16CeMin, uint16_t u16CeMAx)
 
at_ble_status_t gapm_dev_bdaddr_ind_handler (uint8_t *data, at_ble_rand_addr_changed_t *param)
 
at_ble_status_t gapm_reset_req_handler (void)
 
at_ble_status_t gapm_resolv_addr_cmd_handler (uint8_t nb_key, uint8_t *rand_addr, uint8_t *irk)
 
at_ble_status_t gapm_set_dev_config_cmd_handler (uint8_t u8Role, uint8_t *pu8Key, uint16_t u16Appearance, uint8_t u8AppWrPerm, uint8_t u8NameWrPerm, uint16_t u16MaxMTU, uint16_t u16ConIntMin, uint16_t u16ConIntMax, uint16_t u16ConLatency, uint16_t u16SupervTo, uint8_t u8Flags)
 
at_ble_status_t gapm_set_dev_name_handler (uint8_t len, uint8_t *name)
 
at_ble_status_t gapm_start_adv_cmd_handler (uint8_t u8OpCode, uint8_t u8AddrSrc, uint16_t u16RenewDur, uint8_t *pu8BdAddr, uint8_t peer_addr_type, uint8_t *peerBdAddr, uint16_t u16MinIntv, uint16_t u16MaxIntv, uint8_t u8ChnlMap, uint8_t u8Mode, uint8_t u8AdvFiltPolicy, uint8_t u8AdvDataLen, uint8_t *pu8AdvData, uint8_t u8ScnRespLen, uint8_t *pu8ScnRespData)
 
at_ble_status_t gapm_start_connection_cmd_handler (uint8_t u8OpCode, uint8_t u8AddrType, uint16_t u16RenewDur, uint8_t *pu8BdAddr, uint16_t u16ScanInterval, uint16_t u16ScanWin, uint16_t u16ConIntvMin, uint16_t u16ConIntvMax, uint16_t u16ConLatency, uint16_t u16SupervTO, uint16_t u16CeMin, uint16_t u16CeMAx, uint8_t u8NbOfPeers, at_ble_addr_t *peers)
 
at_ble_status_t gapm_start_scan_cmd_handler (uint8_t u8OpCode, uint8_t u8AddrType, uint16_t u16RenewDur, uint8_t *pu8BdAddr, uint16_t u16ScanInterval, uint16_t u16ScanWin, uint8_t u8ScanMode, uint8_t u8FiltPolicy, uint8_t u8FilterDuplic)
 
at_ble_status_t gapm_white_list_mgm_cmd (uint8_t operation, uint8_t addr_type, uint8_t *address)
 

#define AD_TYPE_NAME   (0x09)
#define ADV_DATA_MAX_SIZE   (31-3) /*32 including the size in 1st byte*/

Advertising data maximal length.

Referenced by gapm_start_adv_cmd_handler().

#define APP_ADV_DEV_NAME   "\x4e\x4d\x49\x2D\x42\x4C\x45"
#define APP_ADV_DEV_NAME_LEN   (7)
#define APP_ZERO_PAD_DATA   "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0"
#define ATTC_1ST_REQ_END_HDL   0xFFFF
#define ATTC_1ST_REQ_START_HDL   0x0001
#define EVENT_TYPE_ADVERTISING   0
#define EVENT_TYPE_SCAN_RESP   4
#define GAP_CONN_LATENCY   0x0000

Connection latency default value: 0x0000.

#define GAP_CONN_MAX_CE   0x0140

Maximum connection event default value: 0xFFFF.

#define GAP_CONN_MIN_CE   0x0000

Minimum connection event default value: 0x0000.

#define GAP_CONN_SUPERV_TIMEOUT   0x01f4

Connection supervision timeout recommended value: 20s.

#define GAP_INIT_CONN_MAX_INTV   0x00a0
#define GAP_INIT_CONN_MIN_INTV   0x00a0

Minimum to maximum connection interval upon any connection establishment: TGAP(initial_conn_interval) recommended value: 30 to 50 ms ; N * 1.25 ms.

#define GAP_INQ_SCAN_INTV   0x0140

RW Defines.

#define GAP_INQ_SCAN_WIND   0x00a0
#define GAP_TMR_PRIV_ADDR_INT   0xEA60

Referenced by at_ble_init().

#define SCAN_RESP_DATA_MAX_SIZE   (31) /*32 including the size in 1st byte*/

Scan Response data maximal length.

Referenced by gapm_start_adv_cmd_handler().

anonymous enum

Device discovery search type.

Enumerator
GAP_GEN_INQ_TYPE 

General Inquiry.

GAP_LIM_INQ_TYPE 

Limited Inquiry.

GAP_KNOWN_DEV_INQ_TYPE 

Known device Inquiry.

anonymous enum
Enumerator
GAP_BOND_ACCEPT 
GAP_BOND_REJECT 
anonymous enum

Filter duplicates.

Enumerator
SCAN_FILT_DUPLIC_DIS 

Disable filtering of duplicate packets.

SCAN_FILT_DUPLIC_EN 

Enable filtering of duplicate packets.

SCAN_FILT_DUPLIC_END 

Enumeration end value for scan duplicate filtering value check.

anonymous enum

GAP Interface.

Enumerator
GAPM_CMP_EVT 

Command Complete event.

GAPM_DEVICE_READY_IND 

Event triggered to inform that lower layers are ready.

GAPM_RESET_CMD 

Reset link layer and the host command.

GAPM_CANCEL_CMD 

Cancel ongoing operation.

GAPM_SET_DEV_CONFIG_CMD 

Set device configuration command.

GAPM_SET_DEV_NAME_CMD 

Set device name command.

GAPM_SET_CHANNEL_MAP_CMD 

Set device channel map.

GAPM_GET_DEV_INFO_CMD 

Get local device info command.

GAPM_DEV_NAME_IND 

Local device name indication event.

GAPM_APPEARANCE_IND 

Local device appearance indication event.

GAPM_DEV_VERSION_IND 

Local device version indication event.

GAPM_DEV_BDADDR_IND 

Local device BD Address indication event.

GAPM_WHITE_LIST_MGT_CMD 

White List Management Command.

GAPM_WHITE_LIST_SIZE_IND 

White List Size indication event.

GAPM_START_ADVERTISE_CMD 

Set advertising mode Command.

GAPM_START_SCAN_CMD 

Set Scan mode Command.

GAPM_ADV_REPORT_IND 

Advertising or scanning report information event.

GAPM_START_CONNECTION_CMD 

Set connection initialization Command.

GAPM_PEER_NAME_IND 

Name of peer device indication.

GAPM_CONNECTION_CFM 

Confirm connection to a specific device (Connection Operation in Selective mode)

GAPM_UPDATED_PRIVACY_IND 

Privacy flag value has been updated.

GAPM_UPDATED_RECON_ADDR_IND 

Reconnection address has been updated.

GAPM_RESOLV_ADDR_CMD 

Resolve address command.

GAPM_ADDR_SOLVED_IND 

Indicate that resolvable random address has been solved.

GAPM_GEN_RAND_ADDR_CMD 

Generate a random address.

GAPM_USE_ENC_BLOCK_CMD 

Use the AES-128 block in the controller.

GAPM_USE_ENC_BLOCK_IND 

AES-128 block result indication.

GAPM_GEN_RAND_NB_CMD 

Generate a 8-byte random number.

GAPM_GEN_RAND_NB_IND 

Random Number Indication.

GAPM_DBG_MEM_INFO_IND 

Indication containing information about memory usage.

GAPM_DEV_ADV_TX_POWER_IND 

Advertising channel Tx power level.

GAPM_LIM_DISC_TO_IND 

Limited discoverable timeout indication.

GAPM_SCAN_TO_IND 

Scan timeout indication.

GAPM_ADDR_RENEW_TO_IND 

Address renewal timeout indication.

Advertising mode.

Enumerator
GAP_NON_DISCOVERABLE 

Mode in non-discoverable.

GAP_GEN_DISCOVERABLE 

Mode in general discoverable.

GAP_LIM_DISCOVERABLE 

Mode in limited discoverable.

GAP_BROADCASTER_MODE 

Broadcaster mode which is a non discoverable and non connectable mode.

GAP Specific Error.

Enumerator
GAP_ERR_NO_ERROR 

No error.

GAP_ERR_INVALID_PARAM 

Invalid parameters set.

GAP_ERR_PROTOCOL_PROBLEM 

Problem with protocol exchange, get unexpected response.

GAP_ERR_NOT_SUPPORTED 

Request not supported by software configuration.

GAP_ERR_COMMAND_DISALLOWED 

Request not allowed in current state.

GAP_ERR_CANCELED 

Requested operation canceled.

GAP_ERR_TIMEOUT 

Requested operation timeout.

GAP_ERR_DISCONNECTED 

Link connection lost during operation.

GAP_ERR_NOT_FOUND 

Search algorithm finished, but no result found.

GAP_ERR_REJECTED 

Request rejected by peer device.

GAP_ERR_PRIVACY_CFG_PB 

Problem with privacy configuration.

GAP_ERR_ADV_DATA_INVALID 

Duplicate or invalid advertising data.

enum gap_role
Enumerator
GAP_NO_ROLE 

No role set yet.

GAP_OBSERVER_SCA 

Observer role.

GAP_BROADCASTER_ADV 

Broadcaster role.

GAP_CENTRAL_MST 

Master/Central role.

GAP_PERIPHERAL_SLV 

Peripheral/Slave role.

Scan mode.

Enumerator
GAP_GEN_DISCOVERY 

Mode in general discovery.

GAP_LIM_DISCOVERY 

Mode in limited discovery.

GAP_OBSERVER_MODE 

Observer mode.

GAP_INVALID_MODE 

Invalid mode.

GAP Manager operation type - application interface.

Enumerator
GAPM_NO_OP 

No operation.

GAPM_RESET 

Reset BLE subsystem: LL and HL.

GAPM_CANCEL 

Cancel currently executed operation.

GAPM_SET_DEV_CONFIG 

Set device configuration.

GAPM_SET_DEV_NAME 

Set device name.

GAPM_SET_CHANNEL_MAP 

Set device channel map.

GAPM_GET_DEV_NAME 

Get Local device name.

GAPM_GET_DEV_VERSION 

Get Local device version.

GAPM_GET_DEV_BDADDR 

Get Local device BD Address.

GAPM_GET_WLIST_SIZE 

Get White List Size.

GAPM_ADD_DEV_IN_WLIST 

Add devices in white list.

GAPM_RMV_DEV_FRM_WLIST 

Remove devices form white list.

GAPM_CLEAR_WLIST 

Clear all devices from white list.

GAPM_ADV_NON_CONN 

Start non connectable advertising.

GAPM_ADV_UNDIRECT 

Start undirected connectable advertising.

GAPM_ADV_DIRECT 

Start directed connectable advertising.

GAPM_SCAN_ACTIVE 

Start active scan operation.

GAPM_SCAN_PASSIVE 

Start passive scan operation.

GAPM_CONNECTION_DIRECT 

Direct connection operation.

GAPM_CONNECTION_AUTO 

Automatic connection operation.

GAPM_CONNECTION_SELECTIVE 

Selective connection operation.

GAPM_CONNECTION_NAME_REQUEST 

Name Request operation (requires to start a direct connection)

GAPM_RESOLV_ADDR 

Resolve device address.

GAPM_GEN_RAND_ADDR 

Generate a random address.

GAPM_USE_ENC_BLOCK 

Use the controller's AES-128 block.

GAPM_GEN_RAND_NB 

Generate a 8-byte random number.

GAPM_DBG_GET_MEM_INFO 

Get memory usage.

GAPM_PLF_RESET 

Perform a platform reset.

GAPM_GET_DEV_ADV_TX_POWER 

Get device advertising power level.

GAPM_LAST 

Last GAPM operation flag.

Own BD address source of the device.

Enumerator
GAPM_PUBLIC_ADDR 

Public Address.

GAPM_PROVIDED_RND_ADDR 

Provided random address.

GAPM_GEN_STATIC_RND_ADDR 

Provided static random address.

GAPM_GEN_RSLV_ADDR 

Generated resolvable private random address.

GAPM_GEN_NON_RSLV_ADDR 

Generated non-resolvable private random address.

GAPM_PROVIDED_RECON_ADDR 

Provided Reconnection address.

GAPM_INVALID_ADDR 

Invalid address.

Device Attribute write permission requirement.

Enumerator
GAPM_WRITE_DISABLE 

Disable write access.

GAPM_WRITE_ENABLE 

Enable write access.

GAPM_WRITE_UNAUTH 

Write access requires unauthenticated link.

GAPM_WRITE_AUTH 

Write access requires authenticated link.

at_ble_status_t gapm_connection_cfm_handler ( uint8_t *  pu8PeerBdAddr,
uint8_t  u8PeerAddrType,
uint16_t  u16ConIntvMin,
uint16_t  u16ConIntvMax,
uint16_t  u16ConLatency,
uint16_t  u16SupervTO,
uint16_t  u16CeMin,
uint16_t  u16CeMAx 
)
at_ble_status_t gapm_set_dev_config_cmd_handler ( uint8_t  u8Role,
uint8_t *  pu8Key,
uint16_t  u16Appearance,
uint8_t  u8AppWrPerm,
uint8_t  u8NameWrPerm,
uint16_t  u16MaxMTU,
uint16_t  u16ConIntMin,
uint16_t  u16ConIntMax,
uint16_t  u16ConLatency,
uint16_t  u16SupervTo,
uint8_t  u8Flags 
)
at_ble_status_t gapm_start_adv_cmd_handler ( uint8_t  u8OpCode,
uint8_t  u8AddrSrc,
uint16_t  u16RenewDur,
uint8_t *  pu8BdAddr,
uint8_t  peer_addr_type,
uint8_t *  peerBdAddr,
uint16_t  u16MinIntv,
uint16_t  u16MaxIntv,
uint8_t  u8ChnlMap,
uint8_t  u8Mode,
uint8_t  u8AdvFiltPolicy,
uint8_t  u8AdvDataLen,
uint8_t *  pu8AdvData,
uint8_t  u8ScnRespLen,
uint8_t *  pu8ScnRespData 
)
at_ble_status_t gapm_start_connection_cmd_handler ( uint8_t  u8OpCode,
uint8_t  u8AddrType,
uint16_t  u16RenewDur,
uint8_t *  pu8BdAddr,
uint16_t  u16ScanInterval,
uint16_t  u16ScanWin,
uint16_t  u16ConIntvMin,
uint16_t  u16ConIntvMax,
uint16_t  u16ConLatency,
uint16_t  u16SupervTO,
uint16_t  u16CeMin,
uint16_t  u16CeMAx,
uint8_t  u8NbOfPeers,
at_ble_addr_t peers 
)
at_ble_status_t gapm_start_scan_cmd_handler ( uint8_t  u8OpCode,
uint8_t  u8AddrType,
uint16_t  u16RenewDur,
uint8_t *  pu8BdAddr,
uint16_t  u16ScanInterval,
uint16_t  u16ScanWin,
uint8_t  u8ScanMode,
uint8_t  u8FiltPolicy,
uint8_t  u8FilterDuplic 
)
at_ble_status_t gapm_white_list_mgm_cmd ( uint8_t  operation,
uint8_t  addr_type,
uint8_t *  address 
)