TI BLE5-Stack API Documentation  2.02.05.00
gap_scanner.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: TI_TEXT 2009 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
21 #ifndef GAP_SCANNER_H
22 #define GAP_SCANNER_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 /*-------------------------------------------------------------------
30  * INCLUDES
31  */
32 #include "bcomdef.h"
33 #include "osal.h"
34 #include "gap.h"
35 
36 /*-------------------------------------------------------------------
37  * MACROS
38  */
39 
40 /*******************************************************************************
41  * Gap Scanner Internal API
42  */
43 
44 /*-------------------------------------------------------------------
45  * CONSTANTS
46  */
47 
92  ADV_RPT_EVT_TYPE_CONNECTABLE = AE_EVT_TYPE_CONN_ADV,
94  ADV_RPT_EVT_TYPE_SCANNABLE = AE_EVT_TYPE_SCAN_ADV,
96  ADV_RPT_EVT_TYPE_DIRECTED = AE_EVT_TYPE_DIR_ADV,
98  ADV_RPT_EVT_TYPE_SCAN_RSP = AE_EVT_TYPE_SCAN_RSP,
100  ADV_RPT_EVT_TYPE_LEGACY = AE_EVT_TYPE_LEGACY,
102  ADV_RPT_EVT_STATUS_COMPLETE = AE_EVT_TYPE_COMPLETE,
104  ADV_RPT_EVT_STATUS_MORE_DATA = AE_EVT_TYPE_INCOMPLETE_MORE_TO_COME,
106  ADV_RPT_EVT_STATUS_TRUNCATED = AE_EVT_TYPE_INCOMPLETE_NO_MORE_TO_COME,
108  ADV_RPT_EVT_STATUS_RFU = AE_EVT_TYPE_RFU
109 };
110 
113  SCAN_PRIM_PHY_1M = LL_PHY_1_MBPS,
114  SCAN_PRIM_PHY_CODED = LL_PHY_CODED
115 };
116 
143 };
144 
159 };
160 
165 };
166 
171 #define SCAN_RSSI_MAX 127
172 #define SCAN_RSSI_MIN -128
173 
179 #define SCAN_FLT_RSSI_ALL SCAN_RSSI_MIN
180 #define SCAN_FLT_RSSI_NONE SCAN_RSSI_MAX
181 
187 #define SCAN_PARAM_DFLT_INTERVAL 800
189 #define SCAN_PARAM_DFLT_WINDOW 800
191 #define SCAN_PARAM_DFLT_TYPE SCAN_TYPE_PASSIVE
193 #define SCAN_PARAM_DFLT_RPT_FIELDS (SCAN_ADVRPT_FLD_EVENTTYPE|\
195  SCAN_ADVRPT_FLD_ADDRTYPE |\
196  SCAN_ADVRPT_FLD_ADDRESS |\
197  SCAN_ADVRPT_FLD_ADVSID |\
198  SCAN_ADVRPT_FLD_RSSI)
199 #define SCAN_PARAM_DFLT_PHYS SCAN_PRIM_PHY_1M
201 #define SCAN_PARAM_DFLT_FLT_POLICY SCAN_FLT_POLICY_ALL
203 #define SCAN_PARAM_DFLT_FLT_PDU SCAN_FLT_PDU_COMPLETE_ONLY
205 #define SCAN_PARAM_DFLT_FLT_RSSI SCAN_FLT_RSSI_ALL
207 #define SCAN_PARAM_DFLT_FLT_DISC SCAN_FLT_DISC_DISABLE
209 #define SCAN_PARAM_DFLT_FLT_DUP SCAN_FLT_DUP_ENABLE
211 #define SCAN_PARAM_DFLT_NUM_ADV_RPT 0
213 
219 #define SCAN_PERIODIC_SKIP_MAX 0x01F3
221 #define SCAN_PERIODIC_TIMEOUT_MIN 0x000A
223 #define SCAN_PERIODIC_TIMEOUT_MAX 0x4000
225 #define SCAN_PERIODIC_CTE_TYPE_ALL 0
227 #define SCAN_PERIODIC_DO_NOT_SYNC_AOA_CTE 1
229 #define SCAN_PERIODIC_DO_NOT_SYNC_AOD_CTE_1US 2
231 #define SCAN_PERIODIC_DO_NOT_SYNC_AOD_CTE_2US 4
233 #define SCAN_PERIODIC_SYNC_ONLY_WITH_CTE 16
235 #define SCAN_PERIODIC_MAX_ADV_SID 0x0F
237 #define SCAN_PERIODIC_SYNC_OPTIONS_MAX 0x03
239 #define SCAN_PERIODIC_DO_NOT_USE_PERIODIC_ADV_LIST (0 << 0)
241 #define SCAN_PERIODIC_USE_PERIODIC_ADV_LIST (1 << 0)
243 #define SCAN_PERIODIC_REPORTING_INITIALLY_ENABLED (0 << 1)
245 #define SCAN_PERIODIC_REPORTING_INITIALLY_DISABLED (1 << 1)
247 
265 typedef enum
266 {
283 
301 
318 
356 
370 
384 
402 
404  SCAN_NUM_RW_PARAM,
406 
418  SCAN_PARAM_NUM_ADV_RPT = SCAN_NUM_RW_PARAM,
419 
421  SCAN_NUM_PARAM
426 /*-------------------------------------------------------------------
427  * Structures
428  */
429 
436 typedef enum
438 {
440  SCANNED_PHY_1M = AE_PHY_1_MBPS,
441  SCANNED_PHY_2M = AE_PHY_2_MBPS,
442  SCANNED_PHY_CODED = AE_PHY_CODED
444 
446 typedef enum {
447  SCAN_TYPE_PASSIVE = LL_SCAN_PASSIVE,
448  SCAN_TYPE_ACTIVE = LL_SCAN_ACTIVE
450 
452 typedef enum {
480 
482 typedef enum {
489 
491 typedef enum {
497 
499 typedef struct {
500  uint8_t reason;
501  uint8_t numReport;
503 
505 typedef struct {
510  uint8_t evtType;
514  uint8_t addr[B_ADDR_LEN];
516  GapScan_ScannedPhy_t primPhy;
518  GapScan_ScannedPhy_t secPhy;
520  uint8_t advSid;
522  int8_t txPower;
524  int8_t rssi;
528  uint8_t directAddr[B_ADDR_LEN];
530  uint16_t periodicAdvInt;
532  uint16_t dataLen;
534  uint8_t *pData;
536 
538 typedef uint32_t GapScan_EventMask_t;
539 
541 typedef struct
542 {
551  uint8 options;
552  uint8 advAddrType;
553  uint8 advAddress[6];
554  uint16 skip;
555  uint16 syncTimeout;
556 
562  uint8 syncCteType;
564 
566 typedef struct
567 {
569  uint8_t opcode;
570  uint8_t status;
572 
574 typedef struct
575 {
577  uint8_t opcode;
578  uint8_t status;
579  uint8_t listSize;
581 
583 typedef struct
584 {
586  uint8_t opcode;
587  uint16_t syncHandle;
589 
591 typedef struct
592 {
594  uint8 opcode;
595  uint8 BLEEventCode;
596  uint16 syncHandle;
597  int8 txPower;
598  int8 rssi;
599  uint8 cteType;
600  uint8 dataStatus;
601  uint8 dataLen;
602  uint8 *pData;
604 
606 typedef struct
607 {
609  uint8 opcode;
610  uint8 BLEEventCode;
611  uint8 status;
612  uint16 syncHandle;
613  uint8 advSid;
614  uint8 advAddrType;
615  uint8 advAddress[6];
616  uint8 advPhy;
617  uint16 periodicAdvInt;
620 
623 /*-------------------------------------------------------------------
624  * API's
625  */
626 
637 status_t GapScan_registerCb(pfnGapCB_t cb, uintptr_t arg);
638 
659 status_t GapScan_setPhyParams(uint8_t primPhys, GapScan_ScanType_t type,
660  uint16_t interval, uint16_t window);
661 
677 status_t GapScan_getPhyParams(uint8_t primPhy, GapScan_ScanType_t* pType,
678  uint16_t* pInterval, uint16_t* pWindow);
679 
691 status_t GapScan_setParam(GapScan_ParamId_t paramId, void* pValue);
692 
706 status_t GapScan_getParam(GapScan_ParamId_t paramId, void* pValue, uint8_t *pLen);
707 
716 void GapScan_setEventMask(GapScan_EventMask_t eventMask);
717 
744 status_t GapScan_enable(uint16_t period, uint16_t duration,
745  uint8_t maxNumReport);
746 
754 status_t GapScan_disable(void);
755 
770 status_t GapScan_getAdvReport(uint8_t rptIdx, GapScan_Evt_AdvRpt_t* pAdvRpt);
771 
782 status_t GapScan_discardAdvReportList(void);
783 
800 uint8_t GapScan_PeriodicAdvCreateSync( uint8 advSID,
801  GapScan_PeriodicAdvCreateSyncParams_t *createSyncParams );
802 
814 
832 bStatus_t GapScan_PeriodicAdvTerminateSync( uint16 syncHandle);
833 
854  uint8 enable );
855 
875  uint8 advAddress[6],
876  uint8 advSID );
877 
898  uint8 advAddress[6],
899  uint8 advSID );
900 
911 hciStatus_t GapScan_ReadPeriodicAdvListSize( void );
912 
924 
925 /*-------------------------------------------------------------------
926 -------------------------------------------------------------------*/
927 
928 #ifdef __cplusplus
929 }
930 #endif
931 
932 #endif /* GAP_SCANNER_H */
933 
uint8 opcode
GAP type of command.
Definition: gap_scanner.h:609
Definition: gap_scanner.h:463
address field
Definition: gap_scanner.h:149
GAP_Addr_Types_t
Address types used for identifying peer address type.
Definition: gap.h:713
status_t GapScan_discardAdvReportList(void)
Definition: gap_scanner.h:355
uint8 advAddrType
Advertiser address type - 0x00 - public ; 0x01 - random.
Definition: gap_scanner.h:552
Limited discoverable mode.
Definition: gap_scanner.h:485
txPower field
Definition: gap_scanner.h:153
This API allows the software components in the Z-Stack to be written independently of the specifics o...
No PHY is used.
Definition: gap_scanner.h:439
Definition: gap_scanner.h:317
General discoverable mode.
Definition: gap_scanner.h:484
GapScan_FilterDiscMode_t
Choices for GAP Scanner Discoverable Mode Filter.
Definition: gap_scanner.h:482
Truncated.
Definition: gap_scanner.h:106
Read Advertisers list command complete structure.
Definition: gap_scanner.h:574
Scan Response only. Mutually exclusive with SCAN_FLT_PDU_ADV_ONLY.
Definition: gap_scanner.h:134
int8_t txPower
-127 dBm <= TX power <= 126 dBm
Definition: gap_scanner.h:522
Directed only. Mutually exclusive with SCAN_FLT_PDU_UNDIRECTED_ONLY.
Definition: gap_scanner.h:130
Disable discoverable mode filter.
Definition: gap_scanner.h:487
GapScan_EndReason_t
Reason for GapScan_Evt_End_t.
Definition: gap_scanner.h:162
uint16 periodicAdvInt
Periodic advertising interval Range: 0x0006 to 0xFFFF. Time = N * 1.25 ms (Time Range: 7...
Definition: gap_scanner.h:617
uint8 dataLen
Length of the Data field (Range: 0 to 247)
Definition: gap_scanner.h:601
Scannable.
Definition: gap_scanner.h:94
status_t GapScan_enable(uint16_t period, uint16_t duration, uint8_t maxNumReport)
Definition: gap_scanner.h:401
GapScan_ScannedPhy_t
Scanned PHY.
Definition: gap_scanner.h:437
uint8 status
Periodic advertising sync HCI status.
Definition: gap_scanner.h:611
GapScan_ScannedPhy_t secPhy
PHY of the secondary advertising channel.
Definition: gap_scanner.h:518
status_t GapScan_getAdvReport(uint8_t rptIdx, GapScan_Evt_AdvRpt_t *pAdvRpt)
bStatus_t GapScan_AddDeviceToPeriodicAdvList(uint8 advAddrType, uint8 advAddress[6], uint8 advSID)
status_t GapScan_registerCb(pfnGapCB_t cb, uintptr_t arg)
uint8_t * pData
Pointer to advertising or scan response data.
Definition: gap_scanner.h:534
GapScan_AdvRptField_t
Fields of Adv Report.
Definition: gap_scanner.h:146
uint8_t status
Event status.
Definition: gap_scanner.h:578
GapScan_ParamId_t
Definition: gap_scanner.h:265
uint16 syncHandle
Handle identifying the periodic advertising train.
Definition: gap_scanner.h:596
Undirected only. Mutually exclusive with SCAN_FLT_PDU_DIRECTIED_ONLY.
Definition: gap_scanner.h:128
Periodic advertising sync establish event structure.
Definition: gap_scanner.h:606
Definition: gap_scanner.h:470
Non-discoverable mode.
Definition: gap_scanner.h:483
uint8 dataStatus
0x00 - Data complete 0x01 - Data incomplete, more data to come 0x02 - Data incomplete, data truncated, no more to come
Definition: gap_scanner.h:600
dataLen field
Definition: gap_scanner.h:158
Directed.
Definition: gap_scanner.h:96
Periodic advertising create sync parameters structure.
Definition: gap_scanner.h:541
Truncated only. Mutually exclusive with SCAN_FLT_PDU_COMPLETE_ONLY.
Definition: gap_scanner.h:140
Legacy.
Definition: gap_scanner.h:100
uint8 advPhy
Advertiser PHY: 0x01 - LE 1M 0x02 - LE 2M 0x03 - LE Coded.
Definition: gap_scanner.h:616
uint8_t listSize
Periodic advertisers list size.
Definition: gap_scanner.h:579
GapScan_ScanType_t
GAP Scanner Scan Type.
Definition: gap_scanner.h:446
void GapScan_setEventMask(GapScan_EventMask_t eventMask)
Scanned on the 2M PHY.
Definition: gap_scanner.h:441
osal_event_hdr_t hdr
OSAL Event Header.
Definition: gap_scanner.h:568
Non-scannable only. Mutually exclusive with SCAN_FLT_PDU_SCANNABLE_ONLY.
Definition: gap_scanner.h:124
bStatus_t GapScan_SetPeriodicAdvReceiveEnable(uint16 syncHandle, uint8 enable)
bStatus_t GapScan_PeriodicAdvCreateSyncCancel(void)
bStatus_t GapScan_ClearPeriodicAdvList(void)
uint8_t reason
End reason - GapScan_EndReason_t.
Definition: gap_scanner.h:500
Definition: gap_scanner.h:493
Extended only. Mutually exclusive with SCAN_FLT_PDU_LEGACY_ONLY.
Definition: gap_scanner.h:136
GapScan_FilterPolicy_t
GAP Scanner Filter Policy.
Definition: gap_scanner.h:452
GapScan_AdvRptTypeNStatus_t
Advertising report event types.
Definition: gap_scanner.h:90
uint8_t advSid
SID (0x00-0x0f) of the advertising PDU. 0xFF means no ADI field in the PDU.
Definition: gap_scanner.h:520
Definition: gap_scanner.h:418
status_t GapScan_setPhyParams(uint8_t primPhys, GapScan_ScanType_t type, uint16_t interval, uint16_t window)
status_t GapScan_disable(void)
addrType field
Definition: gap_scanner.h:148
Scanned on the 1M PHY.
Definition: gap_scanner.h:440
uint8 BLEEventCode
BLE Event Code.
Definition: gap_scanner.h:610
void(* pfnGapCB_t)(uint32_t event, void *pBuf, uintptr_t arg)
Definition: gap.h:1343
status_t GapScan_setParam(GapScan_ParamId_t paramId, void *pValue)
uint8 advClockAccuracy
Accuracy of the periodic advertiser&#39;s clock: 0x00 - 500 ppm 0x01 - 250 ppm 0x02 - 150 ppm 0x03 - ...
Definition: gap_scanner.h:618
Complete.
Definition: gap_scanner.h:102
Definition: gap_scanner.h:383
More Data To Come.
Definition: gap_scanner.h:104
Scanned on the Coded PHY.
Definition: gap_scanner.h:442
advSid field
Definition: gap_scanner.h:152
status_t GapScan_getParam(GapScan_ParamId_t paramId, void *pValue, uint8_t *pLen)
uint8_t opcode
GAP type of command.
Definition: gap_scanner.h:569
GapScan_ScannedPhy_t primPhy
PHY of the primary advertising channel.
Definition: gap_scanner.h:516
Scan on the 1M PHY.
Definition: gap_scanner.h:113
Scanning ended by user request.
Definition: gap_scanner.h:163
uint8_t opcode
GAP type of command.
Definition: gap_scanner.h:586
Scan on the Coded PHY.
Definition: gap_scanner.h:114
General or Limited discoverable mode.
Definition: gap_scanner.h:486
Scannable only. Mutually exclusive with SCAN_FLT_PDU_NONSCANNABLE_ONLY.
Definition: gap_scanner.h:126
Event for advertising report.
Definition: gap_scanner.h:505
uint8 advSid
Value of the Advertising SID subfield in the ADI field of the PDU.
Definition: gap_scanner.h:613
uint8 syncCteType
Definition: gap_scanner.h:562
status_t GapScan_getPhyParams(uint8_t primPhy, GapScan_ScanType_t *pType, uint16_t *pInterval, uint16_t *pWindow)
uint8_t opcode
GAP type of command.
Definition: gap_scanner.h:577
prdAdvInterval field
Definition: gap_scanner.h:157
Type definitions and macros for BLE stack.
Periodic advertising report event structure.
Definition: gap_scanner.h:591
eventType field
Definition: gap_scanner.h:147
uint16 syncTimeout
Synchronization timeout for the periodic advertising train. Range: 0x000A to 0x4000 Time = N*10 ms Ti...
Definition: gap_scanner.h:555
Scan for scannable advertisements.
Definition: gap_scanner.h:448
GAP_Addr_Types_t directAddrType
Type of TargetA address in the directed advertising PDU.
Definition: gap_scanner.h:526
int8 txPower
Tx Power information (Range: -127 to +20 dBm)
Definition: gap_scanner.h:597
uint16_t syncHandle
Handle identifying the periodic advertising train.
Definition: gap_scanner.h:587
bStatus_t GapScan_RemoveDeviceFromPeriodicAdvList(uint8 advAddrType, uint8 advAddress[6], uint8 advSID)
GapScan_FilterDuplicate_t
Choices for GAP Scanner Duplicate Filter.
Definition: gap_scanner.h:491
uint8 * pData
Data received from a Periodic Advertising packet.
Definition: gap_scanner.h:602
GAP layer interface.
osal_event_hdr_t hdr
OSAL Event Header.
Definition: gap_scanner.h:576
Definition: gap_scanner.h:457
Definition: gap_scanner.h:282
OSAL Event Header.
Definition: osal.h:92
Event for scanning end.
Definition: gap_scanner.h:499
Connectable only. Mutually exclusive with SCAN_FLT_PDU_NONCONNECTABLE_ONLY.
Definition: gap_scanner.h:122
uint16_t periodicAdvInt
Periodic advertising interval. 0 means no periodic advertising.
Definition: gap_scanner.h:530
primPhy field
Definition: gap_scanner.h:150
Definition: gap_scanner.h:300
uint16 skip
The maximum number of periodic advertising events that can be skipped after a successful receive (Ran...
Definition: gap_scanner.h:554
uint32_t GapScan_EventMask_t
Event Mask.
Definition: gap_scanner.h:538
Legacy only. Mutually exclusive with SCAN_FLT_PDU_EXTENDED_ONLY.
Definition: gap_scanner.h:138
osal_event_hdr_t hdr
OSAL Event Header.
Definition: gap_scanner.h:585
uint8 cteType
0x00 AoA CTE 0x01 - AoD CTE with 1us slots 0x02 - AoD CTE with 2us slots 0xFF - No CTE ...
Definition: gap_scanner.h:599
hciStatus_t GapScan_ReadPeriodicAdvListSize(void)
Reserved for Future Use.
Definition: gap_scanner.h:108
uint8_t GapScan_PeriodicAdvCreateSync(uint8 advSID, GapScan_PeriodicAdvCreateSyncParams_t *createSyncParams)
Duplicate filtering enabled, reset for each scan period.
Definition: gap_scanner.h:495
#define B_ADDR_LEN
Default Public and Random Address Length.
Definition: bcomdef.h:108
osal_event_hdr_t hdr
OSAL Event Header.
Definition: gap_scanner.h:608
Complete only. Mutually exclusive with SCAN_FLT_PDU_TRUNCATED_ONLY.
Definition: gap_scanner.h:142
GapScan_PrimPhy_t
GAP Scanner Primary PHY.
Definition: gap_scanner.h:112
uint8_t evtType
Definition: gap_scanner.h:510
uint16 syncHandle
Handle identifying the periodic advertising train.
Definition: gap_scanner.h:612
Advertisement only. Mutually exclusive with SCAN_FLT_PDU_SCANRSP_ONLY.
Definition: gap_scanner.h:132
GapScan_FilterPduType_t
PDU Types for PDU Type Filter.
Definition: gap_scanner.h:118
secPhy field
Definition: gap_scanner.h:151
uint8 BLEEventCode
BLE Event Code.
Definition: gap_scanner.h:595
RSSI field.
Definition: gap_scanner.h:154
dirAddress field
Definition: gap_scanner.h:156
uint16_t dataLen
Length of the data.
Definition: gap_scanner.h:532
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:251
int8_t rssi
-127 dBm <= RSSI <= 20 dBm
Definition: gap_scanner.h:524
int8 rssi
RSSI value for the received packet (Range: -127 to +20 dBm); If the packet contains CTE...
Definition: gap_scanner.h:598
uint8 advAddrType
Advertiser address type: 0x00 - Public 0x01 - Random 0x02 - Public Identity Address 0x03 - Random...
Definition: gap_scanner.h:614
Definition: gap_scanner.h:478
uint8 options
Definition: gap_scanner.h:551
Non-connectable only. Mutually exclusive with SCAN_FLT_PDU_CONNECTABLE_ONLY.
Definition: gap_scanner.h:120
Connectable.
Definition: gap_scanner.h:92
dirAddrType field
Definition: gap_scanner.h:155
Duplicate filtering disabled.
Definition: gap_scanner.h:492
uint8_t status
Event status.
Definition: gap_scanner.h:570
bStatus_t GapScan_PeriodicAdvTerminateSync(uint16 syncHandle)
Sync Lost event struct.
Definition: gap_scanner.h:583
Scan Response.
Definition: gap_scanner.h:98
Scanning ended by duration expiration.
Definition: gap_scanner.h:164
GAP_Addr_Types_t addrType
Public, random, public ID, random ID, or anonymous.
Definition: gap_scanner.h:512
Definition: gap_scanner.h:369
osal_event_hdr_t hdr
OSAL Event Header.
Definition: gap_scanner.h:593
uint8 opcode
GAP type of command.
Definition: gap_scanner.h:594
uint8_t numReport
Number of recorded advertising reports.
Definition: gap_scanner.h:501
Scan for non-scannable advertisements.
Definition: gap_scanner.h:447
Command status and command complete event structure.
Definition: gap_scanner.h:566
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale