TI BLE Stack API Documentation  2.03.06
peripheral.h
1 /******************************************************************************
2 
3  @file peripheral.h
4 
5  @brief TI BLE GAP Peripheral Role for for RTOS Applications
6 
7  This GAP profile advertises and allows connections.
8 
9  Group: WCS, BTS
10  $Target Device: DEVICES $
11 
12  ******************************************************************************
13  $License: BSD3 2009 $
14  ******************************************************************************
15  $Release Name: PACKAGE NAME $
16  $Release Date: PACKAGE RELEASE DATE $
17  *****************************************************************************/
18 
19 #ifndef PERIPHERAL_H
20 #define PERIPHERAL_H
21 
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif
26 
27 /*-------------------------------------------------------------------
28  * INCLUDES
29  */
30 
31 /*-------------------------------------------------------------------
32  * CONSTANTS
33  */
34 
38 #define GAPROLE_PROFILEROLE 0x300
39 #define GAPROLE_IRK 0x301
40 #define GAPROLE_SRK 0x302
41 #define GAPROLE_SIGNCOUNTER 0x303
42 #define GAPROLE_BD_ADDR 0x304
43 #define GAPROLE_ADVERT_ENABLED 0x305
44 #define GAPROLE_ADVERT_OFF_TIME 0x306
45 #define GAPROLE_ADVERT_DATA 0x307
46 #define GAPROLE_SCAN_RSP_DATA 0x308
47 #define GAPROLE_ADV_EVENT_TYPE 0x309
48 #define GAPROLE_ADV_DIRECT_TYPE 0x30A
49 #define GAPROLE_ADV_DIRECT_ADDR 0x30B
50 #define GAPROLE_ADV_CHANNEL_MAP 0x30C
51 #define GAPROLE_ADV_FILTER_POLICY 0x30D
52 #define GAPROLE_CONNHANDLE 0x30E
53 #define GAPROLE_RSSI_READ_RATE 0x30F
54 #define GAPROLE_PARAM_UPDATE_ENABLE 0x310
55 #define GAPROLE_MIN_CONN_INTERVAL 0x311
56 #define GAPROLE_MAX_CONN_INTERVAL 0x312
57 #define GAPROLE_SLAVE_LATENCY 0x313
58 #define GAPROLE_TIMEOUT_MULTIPLIER 0x314
59 #define GAPROLE_CONN_BD_ADDR 0x315
60 #define GAPROLE_CONN_INTERVAL 0x316
61 #define GAPROLE_CONN_LATENCY 0x317
62 #define GAPROLE_CONN_TIMEOUT 0x318
63 #define GAPROLE_PARAM_UPDATE_REQ 0x319
64 #define GAPROLE_STATE 0x31A
65 #define GAPROLE_ADV_NONCONN_ENABLED 0x31B
66 #define GAPROLE_BD_ADDR_TYPE 0x31C
67 #define GAPROLE_CONN_TERM_REASON 0x31D
68 
69 
71 /*-------------------------------------------------------------------
72  * TYPEDEFS
73  */
74 
78 typedef enum
80 {
81  GAPROLE_INIT = 0,
82  GAPROLE_STARTED,
83  GAPROLE_ADVERTISING,
84  GAPROLE_ADVERTISING_NONCONN,
85  GAPROLE_WAITING,
86  GAPROLE_WAITING_AFTER_TIMEOUT,
87  GAPROLE_CONNECTED,
88  GAPROLE_CONNECTED_ADV,
89  GAPROLE_ERROR
90 } gaprole_States_t;
92 
100 #define GAPROLE_NO_ACTION 0 // Take no action upon unsuccessful parameter updates
101 #define GAPROLE_RESEND_PARAM_UPDATE 1 // Continue to resend request until successful update
102 #define GAPROLE_TERMINATE_LINK 2 // Terminate link upon unsuccessful parameter updates
103 
108 #define GAPROLE_LINK_PARAM_UPDATE_WAIT_REMOTE_PARAMS 0 // Wait for parameter update request, respond with remote's requested parameters.
109 #define GAPROLE_LINK_PARAM_UPDATE_INITIATE_BOTH_PARAMS 1 // Initiate parameter update request, respond with best combination of local and remote parameters.
110 #define GAPROLE_LINK_PARAM_UPDATE_INITIATE_APP_PARAMS 2 // Initiate parameter update request, respond with local requested parameters only.
111 #define GAPROLE_LINK_PARAM_UPDATE_WAIT_APP_PARAMS 3 // Wait for parameter update request, respond with local requested parameters only.
112 #define GAPROLE_LINK_PARAM_UPDATE_WAIT_BOTH_PARAMS 4 // Wait for parameter update request, respond with best combination of local and remote parameters.
113 #define GAPROLE_LINK_PARAM_UPDATE_REJECT_REQUEST 5 // Reject all parameter update requests.
114 #define GAPROLE_LINK_PARAM_UPDATE_NUM_OPTIONS 6 // Used for parameter checking.
115 /*-------------------------------------------------------------------
116  * MACROS
117  */
118 
119 /*-------------------------------------------------------------------
120  * Profile Callbacks
121  */
122 
126 typedef void (*gapRolesParamUpdateCB_t)(uint16_t connInterval,
127  uint16_t connSlaveLatency,
128  uint16_t connTimeout);
129 
134 typedef void (*gapRolesStateNotify_t)(gaprole_States_t newState);
135 
140 typedef struct
141 {
142  gapRolesStateNotify_t pfnStateChange;
143 } gapRolesCBs_t;
144 
145 /*-------------------------------------------------------------------
146  * API FUNCTIONS
147  */
148 
172 extern bStatus_t GAPRole_SetParameter(uint16_t param, uint8_t len, void *pValue);
173 
189 extern bStatus_t GAPRole_GetParameter(uint16_t param, void *pValue);
190 
198 extern bStatus_t GAPRole_StartDevice(gapRolesCBs_t *pAppCallbacks);
199 
206 
226 extern bStatus_t GAPRole_SendUpdateParam(uint16_t minConnInterval,
227  uint16_t maxConnInterval,
228  uint16_t latency, uint16_t connTimeout,
229  uint8_t handleFailure);
230 
238 extern void GAPRole_RegisterAppCBs(gapRolesParamUpdateCB_t *pParamUpdateCB);
239 
245 /*-------------------------------------------------------------------
246  * TASK FUNCTIONS - Don't call these. These are system functions.
247  */
248 
256 extern void GAPRole_createTask(void);
257 
258 /*-------------------------------------------------------------------
259 -------------------------------------------------------------------*/
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif /* PERIPHERAL_H */
bStatus_t GAPRole_SendUpdateParam(uint16_t minConnInterval, uint16_t maxConnInterval, uint16_t latency, uint16_t connTimeout, uint8_t handleFailure)
Update the parameters of an existing connection.
Definition: peripheral.h:140
bStatus_t GAPRole_GetParameter(uint16_t param, void *pValue)
Get a GAP Role parameter.
void GAPRole_RegisterAppCBs(gapRolesParamUpdateCB_t *pParamUpdateCB)
Register application's callbacks.
Status_t bStatus_t
BLE Generic Status return: BLE Default BLE Status Values.
Definition: bcomdef.h:244
bStatus_t GAPRole_SetParameter(uint16_t param, uint8_t len, void *pValue)
Set a GAP Role parameter.
gapRolesStateNotify_t pfnStateChange
Whenever the device changes state.
Definition: peripheral.h:142
bStatus_t GAPRole_StartDevice(gapRolesCBs_t *pAppCallbacks)
Does the device initialization. Only call this function once.
bStatus_t GAPRole_TerminateConnection(void)
Terminates the existing connection.