TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
ugap.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: TISD 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
24 #ifndef UGAP_H
25 #define UGAP_H
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 /*-------------------------------------------------------------------
33  * INCLUDES
34  */
35 
36 /*-------------------------------------------------------------------
37  * CONSTANTS
38  */
39 
44 #define UGAP_DUTY_TIME_UNIT 100L
46 
47 #if defined(FEATURE_BROADCASTER)
48 
52 #define UGAP_BCAST_STATE_INVALID 0
53 #define UGAP_BCAST_STATE_INITIALIZED 1
54 #define UGAP_BCAST_STATE_IDLE 2
55 #define UGAP_BCAST_STATE_ADVERTISING 3
56 #define UGAP_BCAST_STATE_WAITING 4
57 #define UGAP_BCAST_STATE_SUSPENDED 5
58 
63 #define UGB_EVT_STATE_CHANGE 1
64 #define UGB_EVT_ADV_PREPARE 2
65 #define UGB_EVT_ADV_POSTPROCESS 3
66 
67 #endif /* FEATURE_BROADCASTER */
68 
69 #if defined(FEATURE_OBSERVER)
70 
74 #define UGAP_SCAN_STATE_INVALID 0
75 #define UGAP_SCAN_STATE_INITIALIZED 1
76 #define UGAP_SCAN_STATE_IDLE 2
77 #define UGAP_SCAN_STATE_SCANNING 3
78 #define UGAP_SCAN_STATE_WAITING 4
79 #define UGAP_SCAN_STATE_SUSPENDED 5
80 
85 #define UGAP_OBSERVER_EVT_STATE_CHANGE 4
86 #define UGAP_OBSERVER_EVT_SCAN_INDICATION 5
87 #define UGAP_OBSERVER_EVT_SCAN_WINDOW_COMPLETE 6
88 
89 #endif /* FEATURE_OBSERVER */
90 
91 #if defined(FEATURE_MONITOR)
92 
96 #define UGAP_MONITOR_STATE_INVALID 0
97 #define UGAP_MONITOR_STATE_INITIALIZED 1
98 #define UGAP_MONITOR_STATE_IDLE 2
99 #define UGAP_MONITOR_STATE_MONITORING 3
100 
105 #define UGAP_MONITOR_EVT_STATE_CHANGE 7
106 #define UGAP_MONITOR_EVT_MONITOR_INDICATION 8
107 #define UGAP_MONITOR_EVT_MONITOR_COMPLETE 9
108 
109 #endif /* FEATURE_MONITOR */
110 
113 /*-------------------------------------------------------------------
114  * TYPEDEFS
115  */
116 
117 #if defined(FEATURE_BROADCASTER)
118 
122 typedef uint8 ugapBcastState_t;
123 
135 typedef void (*ugapBcastStateChangeCb_t)(ugapBcastState_t state);
136 
142 typedef void (*ugapBcastAdvPrepareCb_t)(void);
143 
149 typedef void (*ugapBcastAdvDoneCb_t)(bStatus_t status);
150 
154 typedef struct
155 {
160 
161 PACKED_TYPEDEF_STRUCT {
162  ugapBcastState_t state;
163 } ugapBcastMsgStateChange_t;
164 
165 PACKED_TYPEDEF_STRUCT {
166  bStatus_t status;
167 } ugapBcastMsgAdvPostprocess_t;
168 
171 #endif /* FEATURE_BROADCASTER */
172 
173 #if defined(FEATURE_OBSERVER)
174 
178 typedef uint8 ugapObserverScan_State_t;
179 
191 typedef void (*ugapObserverStateChangeCb_t)(ugapObserverScan_State_t state);
192 
200 typedef void (*ugapObserverScanIndicationCb_t)(bStatus_t status, uint8_t len, uint8_t *pPayload);
201 
207 typedef void (*ugapObserverScanWindowCompleteCb_t)(bStatus_t status);
208 
212 typedef struct
213 {
214  ugapObserverStateChangeCb_t pfnStateChangeCB;
215  ugapObserverScanIndicationCb_t pfnScanIndicationCB;
216  ugapObserverScanWindowCompleteCb_t pfnScanWindowCompleteCB;
217 } ugapObserverScanCBs_t;
218 
219 PACKED_TYPEDEF_STRUCT {
220  ugapObserverScan_State_t state;
221 } ugapObserverMsgStateChange_t;
222 
223 PACKED_TYPEDEF_STRUCT {
224  bStatus_t status;
225  uint8_t len;
226  uint8_t *pPayload;
227 } ugapObserverMsgScanIndication_t;
228 
229 PACKED_TYPEDEF_STRUCT {
230  bStatus_t status;
231 } ugapObserverMsgScanWindowComplete_t;
232 
235 #endif /* FEATURE_OBSERVER */
236 
237 #if defined(FEATURE_MONITOR)
238 
242 typedef uint8 ugapMonitorState_t;
243 
255 typedef void (*ugapMonitorStateChangeCb_t)(ugapMonitorState_t state);
256 
265 typedef void (*ugapMonitorIndicationCb_t)(bStatus_t status, uint8_t sessionId, uint8_t len, uint8_t *pPayload);
266 
273 typedef void (*ugapMonitorCompleteCb_t)(bStatus_t status, uint8_t sessionId);
274 
278 typedef struct
279 {
284 
285 PACKED_TYPEDEF_STRUCT {
286  ugapMonitorState_t state;
287 } ugapMsgStateChange_t;
288 
289 PACKED_TYPEDEF_STRUCT {
290  bStatus_t status;
291  uint8_t sessionId;
292  uint8_t len;
293  uint8_t *pPayload;
294 } ugapMsgMonitorIndication_t;
295 
296 PACKED_TYPEDEF_STRUCT {
297  bStatus_t status;
298  uint8_t sessionId;
299 } ugapMsgMonitorComplete_t;
300 
303 #endif /* FEATURE_MONITOR */
304 
305 /*-------------------------------------------------------------------
306  * MACROS
307  */
308 
309 /*-------------------------------------------------------------------
310  * API FUNCTIONS
311  */
312 
313 #if defined(FEATURE_BROADCASTER)
314 
324 
338 bStatus_t ugap_bcastSetDuty(uint16 dutyOnTime, uint16 dutyOffTime);
339 
354 bStatus_t ugap_bcastStart(uint16 numAdvEvent);
355 
365 #endif /* FEATURE_BROADCASTER */
366 
367 #if defined(FEATURE_OBSERVER)
368 
377 bStatus_t ugap_scanInit(ugapObserverScanCBs_t* pCBs);
378 
386 bStatus_t ugap_scanStart(void);
387 
394 bStatus_t ugap_scanStop(void);
395 
404 bStatus_t ugap_scanSuspend(void);
405 
413 bStatus_t ugap_scanResume(void);
414 
432 bStatus_t ugap_scanRequest(uint8_t scanChanMap, uint16_t scanWindow, uint16_t scanInterval);
433 
434 #endif /* FEATURE_OBSERVER */
435 
436 #if defined(FEATURE_MONITOR)
437 
447 
456 
465 
484 bStatus_t ugap_monitorRequest(uint8_t channel,
485  uint32_t accessAddr,
486  uint32_t startTime,
487  uint16_t duration);
488 
489 #endif /* FEATURE_MONITOR */
490 
491 /*-------------------------------------------------------------------
492 -------------------------------------------------------------------*/
493 
494 #ifdef __cplusplus
495 }
496 #endif
497 
498 #endif /* UGAP_H */
499  // end of Micro_BLE_Stack
ugapMonitorCompleteCb_t pfnMonitorCompleteCB
Notification of monitoring scan complete.
Definition: ugap.h:282
bStatus_t ugap_bcastInit(ugapBcastCBs_t *pCBs)
Initialize Micro Broadcaster.
bStatus_t ugap_bcastStop(void)
Stop Broadcaster. Proceed the state from either Advertising or Waiting to IDLE.
void(* ugapBcastAdvPrepareCb_t)(void)
Callback of when the next Advertising Event is about to start.
Definition: ugap.h:142
ugapMonitorStateChangeCb_t pfnStateChangeCB
State change notification.
Definition: ugap.h:280
ugapBcastAdvPrepareCb_t pfnAdvPrepareCB
Notification for Adv preperation.
Definition: ugap.h:157
uint8 ugapMonitorState_t
Monitor state.
Definition: ugap.h:242
bStatus_t ugap_bcastSetDuty(uint16 dutyOnTime, uint16 dutyOffTime)
Set Broadcaster Duty On/Off time.
bStatus_t ugap_monitorRequest(uint8_t channel, uint32_t accessAddr, uint32_t startTime, uint16_t duration)
uGAP monitor request
Set of Observer callbacks - must be setup by the application.
Definition: ugap.h:278
uint8 ugapBcastState_t
Broadcaster state.
Definition: ugap.h:122
bStatus_t ugap_monitorInit(ugapMonitorCBs_t *pCBs)
Initialize Micro Monitor.
void(* ugapMonitorCompleteCb_t)(bStatus_t status, uint8_t sessionId)
Callback of when a scan monitoring has just been done.
Definition: ugap.h:273
ugapMonitorIndicationCb_t pfnMonitorIndicationCB
Scan monitor indication with payload.
Definition: ugap.h:281
bStatus_t ugap_monitorStop(void)
Stop Monitor scanning. Proceed the state from Monitoring to Idle.
void(* ugapMonitorIndicationCb_t)(bStatus_t status, uint8_t sessionId, uint8_t len, uint8_t *pPayload)
Callback of when a packet is received.
Definition: ugap.h:265
Set of Broadcaster callbacks - must be setup by the application.
Definition: ugap.h:154
void(* ugapBcastAdvDoneCb_t)(bStatus_t status)
Callback of when an Advertising Event has just been done.
Definition: ugap.h:149
void(* ugapBcastStateChangeCb_t)(ugapBcastState_t state)
Callback of when the Broadcaster's state changes.
Definition: ugap.h:135
void(* ugapMonitorStateChangeCb_t)(ugapMonitorState_t state)
Callback of when the Monitor's state changes.
Definition: ugap.h:255
bStatus_t ugap_monitorStart(void)
Start Monitor scanning. Proceed the state from either Initialized or Idle to Monitoring.
ugapBcastStateChangeCb_t pfnStateChangeCB
State change notification.
Definition: ugap.h:156
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:227
ugapBcastAdvDoneCb_t pfnAdvDoneCB
Notification of Adv event done.
Definition: ugap.h:158
bStatus_t ugap_bcastStart(uint16 numAdvEvent)
Start Broadcaster. Proceed the state from either Initialized or IDLE to Advertising.
Copyright 2017, Texas Instruments Incorporated