-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCH58xBLE_ROM.h
4717 lines (4326 loc) · 228 KB
/
CH58xBLE_ROM.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********************************** (C) COPYRIGHT ******************************
* File Name : CH58xBLE_ROM.H
* Author : WCH
* Version : V2.10
* Date : 2024/03/18
* Description : head file
* Address Space
* CODE: 00010000H - 0003FFFFH 192K
* : 00040000H - 0006FFFFH 192K
* : 0004E000H - 0006FFFFH 136K
* DATA: 20000000H - 20001FFFH 8K
*
* note:
* CH58xBLE_ROM.hex #define LIB_FLASH_BASE_ADDRESSS 0x00010000(default)
* CH58xBLE_ROMx.hex #define LIB_FLASH_BASE_ADDRESSS 0x00040000
* CH58xBLE_ROM_MESH.hex #define LIB_FLASH_BASE_ADDRESSS 0x0004E000
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/******************************************************************************/
#ifndef __CH58xBLE_ROM_H
#define __CH58xBLE_ROM_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "stdint.h"
#ifndef int8
typedef int8_t int8;
#endif
#ifndef int16
typedef int16_t int16;
#endif
#ifndef BOOL
typedef uint8_t BOOL;
#endif
#ifndef s8
typedef int8_t s8;
#endif
#ifndef s16
typedef int16_t s16;
#endif
#ifndef s32
typedef int32_t s32;
#endif
#ifndef u8
typedef uint8_t u8;
#endif
#ifndef u16
typedef uint16_t u16;
#endif
#ifndef u32
typedef uint32_t u32;
#endif
#ifndef u64
typedef uint64_t u64;
#endif
#ifndef u8C
typedef const uint8_t u8C;
#endif
#ifndef u8V
typedef uint8_t volatile u8V;
#endif
#ifndef u32V
typedef uint32_t volatile u32V;
#endif
#ifndef uint8
typedef uint8_t uint8;
#endif
#ifndef uint16
typedef uint16_t uint16;
#endif
#ifndef uint32
typedef uint32_t uint32;
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef SUCCESS
#define SUCCESS 0x00
#endif
#ifndef bStatus_t
typedef uint8_t bStatus_t;
#endif
#ifndef tmosTaskID
typedef uint8_t tmosTaskID;
#endif
#ifndef tmosEvents
typedef uint16_t tmosEvents;
#endif
#ifndef tmosTimer
typedef uint32_t tmosTimer;
#endif
#ifndef tmosSnvId_t
typedef uint8_t tmosSnvId_t;
#endif
#ifndef tmosSnvLen_t
typedef uint8_t tmosSnvLen_t;
#endif
// Define function type that generate a random seed callback
typedef uint32_t (*pfnSrandCB)( void );
// Define function type that switch to idle mode callback
typedef uint32_t (*pfnIdleCB)( uint32_t );
// Define function type that run LSI clock calibration callback
typedef void (*pfnLSICalibrationCB)( void );
// Define function type that get temperature callback
typedef uint16_t (*pfnTempSampleCB)( void );
// Define function type that connect/advertise event complete callback.
typedef void (*pfnEventCB)( uint32_t timeUs );
// Define function type that library status callback.
typedef void (*pfnLibStatusErrorCB)( uint8_t code, uint32_t status );
// Define function type that process event
typedef tmosEvents (*pTaskEventHandlerFn)( tmosTaskID taskID, tmosEvents event );
// Define function type that read flash
typedef uint32_t (*pfnFlashReadCB)( uint32_t addr, uint32_t num, uint32_t *pBuf );
// Define function type that write flash
typedef uint32_t (*pfnFlashWriteCB)( uint32_t addr, uint32_t num, uint32_t *pBuf );
// Define function type that get system clock count
typedef uint32_t (*pfnGetSysClock)( void );
/* BLE library config struct */
typedef struct tag_ble_config
{
uint32_t MEMAddr; // library memory start address
uint16_t MEMLen; // library memory size
uint32_t SNVAddr; // SNV flash start address( if NULL,bonding information will not be saved )
uint16_t SNVBlock; // SNV flash block size ( default 256 )
uint8_t SNVNum; // SNV flash block number ( default 1 )
uint8_t BufNumber; // Maximum number of sent and received packages cached by the controller( default 5 )
// Must be greater than the number of connections.
uint16_t BufMaxLen; // Maximum length (in octets) of the data portion of each HCI data packet( default 27 )
// SC enable,must be greater than 69
// ATT_MTU = BufMaxLen-4,Range[23,ATT_MAX_MTU_SIZE]
uint8_t TxNumEvent; // Maximum number of TX data in a connection event ( default 1 )
uint8_t RxNumEvent; // Maximum number of RX data in a connection event ( default equal to BufNumber )
uint8_t TxPower; // Transmit power level( default LL_TX_POWEER_0_DBM(0dBm) )
uint8_t WakeUpTime; // Wake up time value in one system count
uint8_t SelRTCClock; // system clock select
// bit0-1 00: LSE(32768Hz) 01:LSI(32000Hz) 10:LSI(32768Hz)
// bit7: 1: ble timer(HSE)(must disable sleep)
uint8_t ConnectNumber; // Connect number,lower two bits are peripheral number,followed by central number
uint8_t WindowWidening; // Wait rf start window(us)
uint8_t WaitWindow; // Wait event arrive window in one system clock
uint8_t MacAddr[6]; // MAC address,little-endian
pfnSrandCB srandCB; // Register a program that generate a random seed
pfnIdleCB sleepCB; // Register a program that set idle
pfnTempSampleCB tsCB; // Register a program that read the current temperature,determine whether calibration is need
pfnLSICalibrationCB rcCB; // Register a program that LSI clock calibration
pfnLibStatusErrorCB staCB; // Register a program that library status callback
pfnFlashReadCB readFlashCB; // Register a program that read flash
pfnFlashWriteCB writeFlashCB; // Register a program that write flash
} bleConfig_t; // Library initialization call BLE_LibInit function
/* BLE pa control config struct */
typedef struct tag_ble_clock_config
{
pfnGetSysClock getClockValue;
uint32_t ClockMaxCount; // The maximum count value
uint16_t ClockFrequency; // The timing clock frequency(Hz)
uint16_t ClockAccuracy; // The timing clock accuracy(ppm)
uint8_t irqEnable; // resv
}bleClockConfig_t;
/* BLE pa control config struct */
typedef struct tag_ble_pa_control_config
{
uint32_t txEnableGPIO; // tx enable gpio register
uint32_t txDisableGPIO; // tx disable gpio register
uint32_t tx_pin; // tx pin define
uint32_t rxEnableGPIO; // rx enable gpio register
uint32_t rxDisableGPIO; // rx disable gpio register
uint32_t rx_pin; // tx pin define
} blePaControlConfig_t;
// defined for all task
#define SYS_EVENT_MSG (0x8000) // A message is waiting event
#define INVALID_TASK_ID 0xFF // Task ID isn't setup properly
#define TASK_NO_TASK 0xFF
typedef struct
{
uint8_t event;
uint8_t status;
} tmos_event_hdr_t;
/*********************************************************************
* GLOBAL MACROS
*/
#define VER_FILE "CH58x_BLE_LIB_V2.1"
extern const uint8_t VER_LIB[]; // LIB version
#define SYSTEM_TIME_MICROSEN 625 // unit of process event timer is 625us
#define MS1_TO_SYSTEM_TIME(x) ((x)*1000/SYSTEM_TIME_MICROSEN) // transform unit in ms to unit in 625us ( attentional bias )
#define TMOS_TIME_VALID (30*1000*1000) // the maximum task time = RTC MAX clock - TMOS_TIME_VALID
/* takes a byte out of a uint32_t : var - uint32_t, ByteNum - byte to take out (0 - 3) */
#define BREAK_UINT32( var, ByteNum ) (uint8_t)((uint32_t)(((var) >>((ByteNum) * 8)) & 0x00FF))
#define HI_UINT16(a) (((a) >> 8) & 0xFF)
#define LO_UINT16(a) ((a) & 0xFF)
#define HI_UINT8(a) (((a) >> 4) & 0x0F)
#define LO_UINT8(a) ((a) & 0x0F)
#define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
((uint32_t)(((uint32_t)(Byte0) & 0x00FF) \
+ (((uint32_t)(Byte1) & 0x00FF) << 8) \
+ (((uint32_t)(Byte2) & 0x00FF) << 16) \
+ (((uint32_t)(Byte3) & 0x00FF) << 24)))
#define BUILD_UINT16(loByte, hiByte) ((uint16_t)(((loByte) & 0x00FF)|(((hiByte) & 0x00FF)<<8)))
#define ACTIVE_LOW !
#define ACTIVE_HIGH !! // double negation forces result to be '1'
#ifndef BV
#define BV(n) (1 << (n))
#endif
#ifndef BF
#define BF(x,b,s) (((x) & (b)) >> (s))
#endif
#ifndef MIN
#define MIN(n,m) (((n) < (m)) ? (n) : (m))
#endif
#ifndef MAX
#define MAX(n,m) (((n) < (m)) ? (m) : (n))
#endif
#ifndef ABS
#define ABS(n) (((n) < 0) ? -(n) : (n))
#endif
/* Tx_POWER define(Accuracy:¡À2dBm) */
#define LL_TX_POWEER_MINUS_16_DBM 0x01
#define LL_TX_POWEER_MINUS_12_DBM 0x02
#define LL_TX_POWEER_MINUS_8_DBM 0x04
#define LL_TX_POWEER_MINUS_5_DBM 0x07
#define LL_TX_POWEER_MINUS_3_DBM 0x09
#define LL_TX_POWEER_MINUS_1_DBM 0x0B
#define LL_TX_POWEER_0_DBM 0x0D
#define LL_TX_POWEER_1_DBM 0x0F
#define LL_TX_POWEER_2_DBM 0x13
#define LL_TX_POWEER_3_DBM 0x17
#define LL_TX_POWEER_4_DBM 0x1D
#define LL_TX_POWEER_5_DBM 0x29
#define LL_TX_POWEER_6_DBM 0x3D
/* ERR_LIB_INIT define */
#define ERR_LLE_IRQ_HANDLE 0x01
#define ERR_MEM_ALLOCATE_SIZE 0x02
#define ERR_SET_MAC_ADDR 0x03
#define ERR_GAP_ROLE_CONFIG 0x04
#define ERR_CONNECT_NUMBER_CONFIG 0x05
#define ERR_SNV_ADDR_CONFIG 0x06
#define ERR_CLOCK_SELECT_CONFIG 0x07
//! Default Public and Random Address Length
#define B_ADDR_LEN 6
//! Random Number Size
#define B_RANDOM_NUM_SIZE 8
//! Default key length
#define KEYLEN 16
#define PUBLIC_KEY_LEN 64
//! Maximum Advertising Packet Length
#define B_MAX_ADV_LEN 31 // maximum legacy advertising packet length
#define B_MAX_ADV_EXT_LEN 460 // maximum extended advertising packet length
#define B_MAX_ADV_PERIODIC_LEN 460 // maximum periodic advertising packet length
#define FAILURE 0x01 //!< Failure
#define INVALIDPARAMETER 0x02 //!< Invalid request field
#define INVALID_TASK 0x03 //!< Task ID isn't setup properly
#define MSG_BUFFER_NOT_AVAIL 0x04 //!< No buffer is available.
#define INVALID_MSG_POINTER 0x05 //!< No message pointer.
#define INVALID_EVENT_ID 0x06 //!< Invalid event id.
#define INVALID_TIMEOUT 0x07 //!< Invalid timeout.
#define NO_TIMER_AVAIL 0x08 //!< No event is available.
#define NV_OPER_FAILED 0x0A //!< read a data item to NV failed.
#define INVALID_MEM_SIZE 0x0B //!< The tokens take up too much space and don't fit into Advertisement data and Scan Response Data
/** BLE_STATUS_VALUES BLE Default BLE Status Values
* returned as bStatus_t
*/
#define bleInvalidTaskID INVALID_TASK //!< Task ID isn't setup properly
#define bleEecKeyRequestRejected 0x06 //!< key missing
#define bleNotReady 0x10 //!< Not ready to perform task
#define bleAlreadyInRequestedMode 0x11 //!< Already performing that task
#define bleIncorrectMode 0x12 //!< Not setup properly to perform that task
#define bleMemAllocError 0x13 //!< Memory allocation error occurred
#define bleNotConnected 0x14 //!< Can't perform function when not in a connection
#define bleNoResources 0x15 //!< There are no resource available
#define blePending 0x16 //!< Waiting
#define bleTimeout 0x17 //!< Timed out performing function
#define bleInvalidRange 0x18 //!< A parameter is out of range
#define bleLinkEncrypted 0x19 //!< The link is already encrypted
#define bleProcedureComplete 0x1A //!< The Procedure is completed
#define bleInvalidMtuSize 0x1B //!< SDU size is larger than peer MTU.
/********************************LinkDB****************************************/
// Special case connection handles
#define INVALID_CONNHANDLE 0xFFFF // Invalid connection handle, used for no connection handle
#define LOOPBACK_CONNHANDLE 0xFFFE // Loopback connection handle, used to loopback a message
// Link state flags
#define LINK_NOT_CONNECTED 0x00 // Link isn't connected
#define LINK_CONNECTED 0x01 // Link is connected
#define LINK_AUTHENTICATED 0x02 // Link is authenticated
#define LINK_BOUND 0x04 // Link is bonded
#define LINK_ENCRYPTED 0x10 // Link is encrypted
// Link Database Status callback changeTypes
#define LINKDB_STATUS_UPDATE_NEW 0 // New connection created
#define LINKDB_STATUS_UPDATE_REMOVED 1 // Connection was removed
#define LINKDB_STATUS_UPDATE_STATEFLAGS 2 // Connection state flag changed
/*******************************gattUUID***************************************/
/**
* GATT Services
*/
#define GAP_SERVICE_UUID 0x1800 // Generic Access Profile
#define GATT_SERVICE_UUID 0x1801 // Generic Attribute Profile
/**
* GATT Declarations
*/
#define GATT_PRIMARY_SERVICE_UUID 0x2800 // Primary Service
#define GATT_SECONDARY_SERVICE_UUID 0x2801 // Secondary Service
#define GATT_INCLUDE_UUID 0x2802 // Include
#define GATT_CHARACTER_UUID 0x2803 // Characteristic
/**
* GATT Descriptors
*/
#define GATT_CHAR_EXT_PROPS_UUID 0x2900 // Characteristic Extended Properties
#define GATT_CHAR_USER_DESC_UUID 0x2901 // Characteristic User Description
#define GATT_CLIENT_CHAR_CFG_UUID 0x2902 // Client Characteristic Configuration
#define GATT_SERV_CHAR_CFG_UUID 0x2903 // Server Characteristic Configuration
#define GATT_CHAR_FORMAT_UUID 0x2904 // Characteristic Presentation Format
#define GATT_CHAR_AGG_FORMAT_UUID 0x2905 // Characteristic Aggregate Format
#define GATT_VALID_RANGE_UUID 0x2906 // Valid Range
#define GATT_EXT_REPORT_REF_UUID 0x2907 // External Report Reference Descriptor
#define GATT_REPORT_REF_UUID 0x2908 // Report Reference Descriptor
/**
* GATT Characteristics
*/
#define DEVICE_NAME_UUID 0x2A00 // Device Name
#define APPEARANCE_UUID 0x2A01 // Appearance
#define PERI_PRIVACY_FLAG_UUID 0x2A02 // Peripheral Privacy Flag
#define RECONNECT_ADDR_UUID 0x2A03 // Reconnection Address
#define PERI_CONN_PARAM_UUID 0x2A04 // Peripheral Preferred Connection Parameters
#define SERVICE_CHANGED_UUID 0x2A05 // Service Changed
#define CENTRAL_ADDRESS_RESOLUTION_UUID 0x2AA6 // Central Address Resolution
#define RL_PRIVATE_ADDR_ONLY_UUID 0x2AC9 // Resolvable Private Address Only
#define ENC_DATA_KEY_MATERIAL_UUID 0x2B88 // Encrypted Data Key Material
#define LE_GATT_SEC_LEVELS_UUID 0x2BF5 // LE GATT Security Levels
/**
* GATT Service UUIDs
*/
#define IMMEDIATE_ALERT_SERV_UUID 0x1802 // Immediate Alert
#define LINK_LOSS_SERV_UUID 0x1803 // Link Loss
#define TX_PWR_LEVEL_SERV_UUID 0x1804 // Tx Power
#define CURRENT_TIME_SERV_UUID 0x1805 // Current Time Service
#define REF_TIME_UPDATE_SERV_UUID 0x1806 // Reference Time Update Service
#define NEXT_DST_CHANGE_SERV_UUID 0x1807 // Next DST Change Service
#define GLUCOSE_SERV_UUID 0x1808 // Glucose
#define THERMOMETER_SERV_UUID 0x1809 // Health Thermometer
#define DEVINFO_SERV_UUID 0x180A // Device Information
#define NWA_SERV_UUID 0x180B // Network Availability
#define HEARTRATE_SERV_UUID 0x180D // Heart Rate
#define PHONE_ALERT_STS_SERV_UUID 0x180E // Phone Alert Status Service
#define BATT_SERV_UUID 0x180F // Battery Service
#define BLOODPRESSURE_SERV_UUID 0x1810 // Blood Pressure
#define ALERT_NOTIF_SERV_UUID 0x1811 // Alert Notification Service
#define HID_SERV_UUID 0x1812 // Human Interface Device
#define SCAN_PARAM_SERV_UUID 0x1813 // Scan Parameters
#define RSC_SERV_UUID 0x1814 // Running Speed and Cadence
#define CSC_SERV_UUID 0x1816 // Cycling Speed and Cadence
#define CYCPWR_SERV_UUID 0x1818 // Cycling Power
#define LOC_NAV_SERV_UUID 0x1819 // Location and Navigation
/**
* GATT Characteristic UUIDs
*/
#define ALERT_LEVEL_UUID 0x2A06 // Alert Level
#define TX_PWR_LEVEL_UUID 0x2A07 // Tx Power Level
#define DATE_TIME_UUID 0x2A08 // Date Time
#define DAY_OF_WEEK_UUID 0x2A09 // Day of Week
#define DAY_DATE_TIME_UUID 0x2A0A // Day Date Time
#define EXACT_TIME_256_UUID 0x2A0C // Exact Time 256
#define DST_OFFSET_UUID 0x2A0D // DST Offset
#define TIME_ZONE_UUID 0x2A0E // Time Zone
#define LOCAL_TIME_INFO_UUID 0x2A0F // Local Time Information
#define TIME_WITH_DST_UUID 0x2A11 // Time with DST
#define TIME_ACCURACY_UUID 0x2A12 // Time Accuracy
#define TIME_SOURCE_UUID 0x2A13 // Time Source
#define REF_TIME_INFO_UUID 0x2A14 // Reference Time Information
#define TIME_UPDATE_CTRL_PT_UUID 0x2A16 // Time Update Control Point
#define TIME_UPDATE_STATE_UUID 0x2A17 // Time Update State
#define GLUCOSE_MEAS_UUID 0x2A18 // Glucose Measurement
#define BATT_LEVEL_UUID 0x2A19 // Battery Level
#define TEMP_MEAS_UUID 0x2A1C // Temperature Measurement
#define TEMP_TYPE_UUID 0x2A1D // Temperature Type
#define IMEDIATE_TEMP_UUID 0x2A1E // Intermediate Temperature
#define MEAS_INTERVAL_UUID 0x2A21 // Measurement Interval
#define BOOT_KEY_INPUT_UUID 0x2A22 // Boot Keyboard Input Report
#define SYSTEM_ID_UUID 0x2A23 // System ID
#define MODEL_NUMBER_UUID 0x2A24 // Model Number String
#define SERIAL_NUMBER_UUID 0x2A25 // Serial Number String
#define FIRMWARE_REV_UUID 0x2A26 // Firmware Revision String
#define HARDWARE_REV_UUID 0x2A27 // Hardware Revision String
#define SOFTWARE_REV_UUID 0x2A28 // Software Revision String
#define MANUFACTURER_NAME_UUID 0x2A29 // Manufacturer Name String
#define IEEE_11073_CERT_DATA_UUID 0x2A2A // IEEE 11073-20601 Regulatory Certification Data List
#define CURRENT_TIME_UUID 0x2A2B // Current Time
#define SCAN_REFRESH_UUID 0x2A31 // Scan Refresh
#define BOOT_KEY_OUTPUT_UUID 0x2A32 // Boot Keyboard Output Report
#define BOOT_MOUSE_INPUT_UUID 0x2A33 // Boot Mouse Input Report
#define GLUCOSE_CONTEXT_UUID 0x2A34 // Glucose Measurement Context
#define BLOODPRESSURE_MEAS_UUID 0x2A35 // Blood Pressure Measurement
#define IMEDIATE_CUFF_PRESSURE_UUID 0x2A36 // Intermediate Cuff Pressure
#define HEARTRATE_MEAS_UUID 0x2A37 // Heart Rate Measurement
#define BODY_SENSOR_LOC_UUID 0x2A38 // Body Sensor Location
#define HEARTRATE_CTRL_PT_UUID 0x2A39 // Heart Rate Control Point
#define NETWORK_AVAIL_UUID 0x2A3E // Network Availability
#define ALERT_STATUS_UUID 0x2A3F // Alert Status
#define RINGER_CTRL_PT_UUID 0x2A40 // Ringer Control Point
#define RINGER_SETTING_UUID 0x2A41 // Ringer Setting
#define ALERT_CAT_ID_BMASK_UUID 0x2A42 // Alert Category ID Bit Mask
#define ALERT_CAT_ID_UUID 0x2A43 // Alert Category ID
#define ALERT_NOTIF_CTRL_PT_UUID 0x2A44 // Alert Notification Control Point
#define UNREAD_ALERT_STATUS_UUID 0x2A45 // Unread Alert Status
#define NEW_ALERT_UUID 0x2A46 // New Alert
#define SUP_NEW_ALERT_CAT_UUID 0x2A47 // Supported New Alert Category
#define SUP_UNREAD_ALERT_CAT_UUID 0x2A48 // Supported Unread Alert Category
#define BLOODPRESSURE_FEATURE_UUID 0x2A49 // Blood Pressure Feature
#define HID_INFORMATION_UUID 0x2A4A // HID Information
#define REPORT_MAP_UUID 0x2A4B // Report Map
#define HID_CTRL_PT_UUID 0x2A4C // HID Control Point
#define REPORT_UUID 0x2A4D // Report
#define PROTOCOL_MODE_UUID 0x2A4E // Protocol Mode
#define SCAN_INTERVAL_WINDOW_UUID 0x2A4F // Scan Interval Window
#define PNP_ID_UUID 0x2A50 // PnP ID
#define GLUCOSE_FEATURE_UUID 0x2A51 // Glucose Feature
#define RECORD_CTRL_PT_UUID 0x2A52 // Record Access Control Point
#define RSC_MEAS_UUID 0x2A53 // RSC Measurement
#define RSC_FEATURE_UUID 0x2A54 // RSC Feature
#define SC_CTRL_PT_UUID 0x2A55 // SC Control Point
#define CSC_MEAS_UUID 0x2A5B // CSC Measurement
#define CSC_FEATURE_UUID 0x2A5C // CSC Feature
#define SENSOR_LOC_UUID 0x2A5D // Sensor Location
#define CYCPWR_MEAS_UUID 0x2A63 // Cycling Power Measurement
#define CYCPWR_VECTOR_UUID 0x2A64 // Cycling Power Vector
#define CYCPWR_FEATURE_UUID 0x2A65 // Cycling Power Feature
#define CYCPWR_CTRL_PT_UUID 0x2A66 // Cycling Power Control Point
#define LOC_SPEED_UUID 0x2A67 // Location and Speed
#define NAV_UUID 0x2A68 // Navigation
#define POS_QUALITY_UUID 0x2A69 // Position Quality
#define LN_FEATURE_UUID 0x2A6A // LN Feature
#define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
#define ELE_UUID 0x2A6C // Elevation
#define PRESSURE_UUID 0x2A6D // Pressure
#define TEMP_UUID 0x2A6E // Temperature
#define HUMI_UUID 0x2A6F // Humidity
#define TRUE_WIND_SPEED_UUID 0x2A70 // True Wind Speed
#define TRUE_WIND_DIRECTION_UUID 0x2A71 // True Wind Direction
#define URI_UUID 0x2AB6 // URI
#define MEDIA_STATE_UUID 0x2BA3 // Media State
#define MEDIA_CTRL_PT_UUID 0x2BA4 // Media Control Point
#define MEDIA_CTRL_PT_OS_UUID 0x2BA5 // Media Control Point Opcodes Supported
#define CALL_STATE_UUID 0x2BBD // Call State
#define CALL_CTRL_PT_UUID 0x2BBE // Call Control Point
#define CALL_CTRL_PT_OO_UUID 0x2BBF // Call Control Point Optional Opcodes
#define TERM_REASON_UUID 0x2BC0 // Termination Reason
#define INCOMING_CALL_UUID 0x2BC1 // Incoming Call
#define MUTE_UUID 0x2BC3 // Mute
#define ESL_ADDR_UUID 0x2BF6 // ESL Address
#define AP_SYNC_KEY_MATERIAL_UUID 0x2BF7 // AP Sync Key Material
#define ESL_RSP_KEY_MATERIAL_UUID 0x2BF8 // ESL Response Key Material
#define ESL_CURR_ABS_TIME_UUID 0x2BF9 // ESL Current Absolute Time
#define ESL_DISPLAY_INFO_UUID 0x2BFA // ESL Display Information
#define ESL_IMAGE_INFO_UUID 0x2BFB // ESL Image Information
#define ESL_SENSOR_INFO_UUID 0x2BFC // ESL Sensor Information
#define ESL_LED_INFO_UUID 0x2BFD // ESL LED Information
#define ESL_CTL_POINT_UUID 0x2BFE // ESL Control Point
/**
* GATT Unit UUIDs
*/
#define GATT_UNITLESS_UUID 0x2700 // unitless
#define GATT_UNIT_LENGTH_METER_UUID 0x2701 // m, m
#define GATT_UNIT_MASS_KGRAM_UUID 0x2702 // kg, kg
#define GATT_UNIT_TIME_SECOND_UUID 0x2703 // s, s
#define GATT_UNIT_ELECTRIC_CURRENT_A_UUID 0x2704 // A, A
#define GATT_UNIT_THERMODYN_TEMP_K_UUID 0x2705 // K, K
#define GATT_UNIT_AMOUNT_SUBSTANCE_M_UUID 0x2706 // mol, mol
#define GATT_UNIT_LUMINOUS_INTENSITY_C_UUID 0x2707 // cd, cd
#define GATT_UNIT_AREA_SQ_MTR_UUID 0x2710 // m^2, m^2
#define GATT_UNIT_VOLUME_CUBIC_MTR_UUID 0x2711 // m^3, m^3
#define GATT_UNIT_VELOCITY_MPS_UUID 0x2712 // m/s, m s^-1
#define GATT_UNIT_ACCELERATION_MPS_SQ_UUID 0x2713 // m/s^2, m s^-2
#define GATT_UNIT_WAVENUMBER_RM_UUID 0x2714 // ? m^-1
#define GATT_UNIT_DENSITY_KGPCM_UUID 0x2715 // p, kg m^-3
#define GATT_UNIT_SURFACE_DENSITY_KGPSM_UUID 0x2716 // pA, kg m^-2
#define GATT_UNIT_SPECIFIC_VOLUME_CMPKG_UUID 0x2717 // v, m^3 kg^-1
#define GATT_UNIT_CURRENT_DENSITY_APSM_UUID 0x2718 // j, A m^-2
#define GATT_UNIT_MAG_FIELD_STRENGTH_UUID 0x2719 // H, A m
#define GATT_UNIT_AMOUNT_CONC_MPCM_UUID 0x271A // c, mol m^-3
#define GATT_UNIT_MASS_CONC_KGPCM_UUID 0x271B // c, kg m^-3
#define GATT_UNIT_LUMINANCE_CPSM_UUID 0x271C // Lv, cd m^-2
#define GATT_UNIT_REFRACTIVE_INDEX_UUID 0x271D // n, 1
#define GATT_UNIT_RELATIVE_PERMEABLILTY_UUID 0x271E // u, 1
#define GATT_UNIT_PLANE_ANGLE_RAD_UUID 0x2720 // rad, m m-1
#define GATT_UNIT_SOLID_ANGLE_STERAD_UUID 0x2721 // sr, m2 m-2
#define GATT_UNIT_FREQUENCY_HTZ_UUID 0x2722 // Hz, s-1
#define GATT_UNIT_FORCE_NEWTON_UUID 0x2723 // N, m kg s-2
#define GATT_UNIT_PRESSURE_PASCAL_UUID 0x2724 // Pa, N/m2 = m2 kg s-2
#define GATT_UNIT_ENERGY_JOULE_UUID 0x2725 // J, N m = m2 kg s-2
#define GATT_UNIT_POWER_WATT_UUID 0x2726 // W, J/s = m2 kg s-3
#define GATT_UNIT_E_CHARGE_C_UUID 0x2727 // C, sA
#define GATT_UNIT_E_POTENTIAL_DIF_V_UUID 0x2728 // V, W/A = m2 kg s-3 A-1
#define GATT_UNIT_CELSIUS_TEMP_DC_UUID 0x272F // oC, t/oC = T/K - 273.15
#define GATT_UNIT_TIME_MINUTE_UUID 0x2760 // min, 60 s
#define GATT_UNIT_TIME_HOUR_UUID 0x2761 // h, 3600 s
#define GATT_UNIT_TIME_DAY_UUID 0x2762 // d, 86400 s
#define GATT_UNIT_PLANE_ANGLE_DEGREE_UUID 0x2763 // o, (pi/180) rad
#define GATT_UNIT_PLANE_ANGLE_MINUTE_UUID 0x2764 // ', (pi/10800) rad
#define GATT_UNIT_PLANE_ANGLE_SECOND_UUID 0x2765 // '', (pi/648000) rad
#define GATT_UNIT_AREA_HECTARE_UUID 0x2766 // ha, 10^4 m^2
#define GATT_UNIT_VOLUME_LITRE_UUID 0x2767 // l, 10^-3 m^3
#define GATT_UNIT_MASS_TONNE_UUID 0x2768 // t, 10^3 kg
#define GATT_UINT_LENGTH_YARD_UUID 0x27A0 // yd, 0.9144 m
#define GATT_UNIT_LENGTH_PARSEC_UUID 0x27A1 // pc, 3.085678 ?1016 m
#define GATT_UNIT_LENGTH_INCH_UUID 0x27A2 // in, 0.0254 m
#define GATT_UNIT_LENGTH_FOOT_UUID 0x27A3 // ft, 0.3048 m
#define GATT_UNIT_LENGTH_MILE_UUID 0x27A4 // mi, 1609.347 m
#define GATT_UNIT_PRESSURE_PFPSI_UUID 0x27A5 // psi, 6.894757 ?103 Pa
#define GATT_UNIT_VELOCITY_KMPH_UUID 0x27A6 // km/h, 0.2777778 m^s-1
#define GATT_UNIT_VELOCITY_MPH_UUID 0x27A7 // mi/h, 0.44704 m^ s-1
#define GATT_UNIT_ANGULAR_VELOCITY_RPM_UUID 0x27A8 // r/min, 0.1047198 rad s-1
#define GATT_UNIT_ENERGY_GCAL_UUID 0x27A9 // energy (gram calorie)
#define GATT_UNIT_ENERGY_KCAL_UUID 0x27AA // kcal, 4190.02 J
#define GATT_UNIT_ENERGY_KWH_UUID 0x27AB // kWh, 3600000 J
#define GATT_UNIT_THERMODYN_TEMP_DF_UUID 0x27AC // oF, t/oF = T/K ?1.8 - 459.67
#define GATT_UNIT_PERCENTAGE_UUID 0x27AD // percentage,%
#define GATT_UNIT_PER_MILE_UUID 0x27AE // per mille
#define GATT_UNIT_PERIOD_BPM_UUID 0x27AF // period (beats per minute),BPM
#define GATT_UNIT_E_CHARGE_AH_UUID 0x27B0 // electric charge (ampere hours)
#define GATT_UNIT_MASS_DENSITY_MGPD_UUID 0x27B1 // mass density (milligram per decilitre)
#define GATT_UNIT_MASS_DENSITY_MMPL_UUID 0x27B2 // mass density (millimole per litre)
#define GATT_UNIT_TIME_YEAR_UUID 0x27B3 // time (year)
#define GATT_UNIT_TIME_MONTH_UUID 0x27B4 // time (month)
/*********************************Messages IDs*********************************/
// GATT - Messages IDs
#define GATT_MSG_EVENT 0xB0 //!< Incoming GATT message
#define GATT_SERV_MSG_EVENT 0xB1 //!< Incoming GATT ServApp message
// GAP - Messages IDs
#define GAP_MSG_EVENT 0xD0 //!< Incoming GAP message
/************************************ATT***************************************/
#define ATT_MTU_SIZE 23 //!< Minimum ATT MTU size
#define ATT_MAX_MTU_SIZE 512 //!< Maximum ATT MTU size
// ATT Methods
#define ATT_ERROR_RSP 0x01 //!< ATT Error Response
#define ATT_EXCHANGE_MTU_REQ 0x02 //!< ATT Exchange MTU Request
#define ATT_EXCHANGE_MTU_RSP 0x03 //!< ATT Exchange MTU Response
#define ATT_FIND_INFO_REQ 0x04 //!< ATT Find Information Request
#define ATT_FIND_INFO_RSP 0x05 //!< ATT Find Information Response
#define ATT_FIND_BY_TYPE_VALUE_REQ 0x06 //!< ATT Find By Type Value Request
#define ATT_FIND_BY_TYPE_VALUE_RSP 0x07 //!< ATT Find By Type Value Response
#define ATT_READ_BY_TYPE_REQ 0x08 //!< ATT Read By Type Request
#define ATT_READ_BY_TYPE_RSP 0x09 //!< ATT Read By Type Response
#define ATT_READ_REQ 0x0a //!< ATT Read Request
#define ATT_READ_RSP 0x0b //!< ATT Read Response
#define ATT_READ_BLOB_REQ 0x0c //!< ATT Read Blob Request
#define ATT_READ_BLOB_RSP 0x0d //!< ATT Read Blob Response
#define ATT_READ_MULTI_REQ 0x0e //!< ATT Read Multiple Request
#define ATT_READ_MULTI_RSP 0x0f //!< ATT Read Multiple Response
#define ATT_READ_BY_GRP_TYPE_REQ 0x10 //!< ATT Read By Group Type Request
#define ATT_READ_BY_GRP_TYPE_RSP 0x11 //!< ATT Read By Group Type Response
#define ATT_WRITE_REQ 0x12 //!< ATT Write Request
#define ATT_WRITE_RSP 0x13 //!< ATT Write Response
#define ATT_PREPARE_WRITE_REQ 0x16 //!< ATT Prepare Write Request
#define ATT_PREPARE_WRITE_RSP 0x17 //!< ATT Prepare Write Response
#define ATT_EXECUTE_WRITE_REQ 0x18 //!< ATT Execute Write Request
#define ATT_EXECUTE_WRITE_RSP 0x19 //!< ATT Execute Write Response
#define ATT_HANDLE_VALUE_NOTI 0x1b //!< ATT Handle Value Notification
#define ATT_HANDLE_VALUE_IND 0x1d //!< ATT Handle Value Indication
#define ATT_HANDLE_VALUE_CFM 0x1e //!< ATT Handle Value Confirmation
#define ATT_WRITE_CMD 0x52 //!< ATT Write Command
#define ATT_SIGNED_WRITE_CMD 0xD2 //!< ATT Signed Write Command
// ATT Error Codes
#define ATT_ERR_INVALID_HANDLE 0x01 //!< The attribute handle given was not valid on this server
#define ATT_ERR_READ_NOT_PERMITTED 0x02 //!< The attribute cannot be read
#define ATT_ERR_WRITE_NOT_PERMITTED 0x03 //!< The attribute cannot be written
#define ATT_ERR_INVALID_PDU 0x04 //!< The attribute PDU was invalid
#define ATT_ERR_INSUFFICIENT_AUTHEN 0x05 //!< The attribute requires authentication before it can be read or written
#define ATT_ERR_UNSUPPORTED_REQ 0x06 //!< Attribute server does not support the request received from the client
#define ATT_ERR_INVALID_OFFSET 0x07 //!< Offset specified was past the end of the attribute
#define ATT_ERR_INSUFFICIENT_AUTHOR 0x08 //!< The attribute requires authorization before it can be read or written
#define ATT_ERR_PREPARE_QUEUE_FULL 0x09 //!< Too many prepare writes have been queued
#define ATT_ERR_ATTR_NOT_FOUND 0x0a //!< No attribute found within the given attribute handle range
#define ATT_ERR_ATTR_NOT_LONG 0x0b //!< The attribute cannot be read using the Read Blob Request
#define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c //!< The Encryption Key Size used for encrypting this link is insufficient
#define ATT_ERR_INVALID_VALUE_SIZE 0x0d //!< The attribute value length is invalid for the operation
#define ATT_ERR_UNLIKELY 0x0e //!< The attribute request that was requested has encountered an error that was very unlikely, and therefore could not be completed as requested
#define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f //!< The attribute requires encryption before it can be read or written
#define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10 //!< The attribute type is not a supported grouping attribute as defined by a higher layer specification
#define ATT_ERR_INSUFFICIENT_RESOURCES 0x11 //!< Insufficient Resources to complete the request
#define ATT_ERR_INVALID_VALUE 0x80 //!< The attribute value is invalid for the operation
/*********************************************************************
* ATT Find By Type Value Response macros
*/
// Attribute Handle and Group End Handle pair indexes
#define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
#define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
#define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
(info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
#define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
(info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
/** @defgroup ATT_MSG_EVENT_DEFINES ATT Message Event IDs
* @{
*/
#define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E //!< Sent when ATT flow control is violated on a connection. This event is sent as an TMOS message defined as attFlowCtrlViolatedEvt_t.
#define ATT_MTU_UPDATED_EVENT 0x7F //!< Sent when MTU is updated for a connection. This event is sent as an TMOS message defined as attMtuUpdatedEvt_t.
/** @} End ATT_MSG_EVENT_DEFINES */
/*** Opcode fields: bitmasks ***/
// Size of 16-bit Bluetooth UUID
#define ATT_BT_UUID_SIZE 2
// Size of 128-bit UUID
#define ATT_UUID_SIZE 16
/******************************** GATT ***********************************/
// GATT Attribute Access Permissions Bit Fields
#define GATT_PERMIT_READ 0x01 //!< Attribute is Readable
#define GATT_PERMIT_WRITE 0x02 //!< Attribute is Writable
#define GATT_PERMIT_AUTHEN_READ 0x04 //!< Read requires Authentication
#define GATT_PERMIT_AUTHEN_WRITE 0x08 //!< Write requires Authentication
#define GATT_PERMIT_AUTHOR_READ 0x10 //!< Read requires Authorization
#define GATT_PERMIT_AUTHOR_WRITE 0x20 //!< Write requires Authorization
#define GATT_PERMIT_ENCRYPT_READ 0x40 //!< Read requires Encryption
#define GATT_PERMIT_ENCRYPT_WRITE 0x80 //!< Write requires Encryption
// GATT Characteristic Properties Bit Fields
#define GATT_PROP_BCAST 0x01 //!< Permits broadcasts of the Characteristic Value
#define GATT_PROP_READ 0x02 //!< Permits reads of the Characteristic Value
#define GATT_PROP_WRITE_NO_RSP 0x04 //!< Permits writes of the Characteristic Value without response
#define GATT_PROP_WRITE 0x08 //!< Permits writes of the Characteristic Value with response
#define GATT_PROP_NOTIFY 0x10 //!< Permits notifications of a Characteristic Value without acknowledgement
#define GATT_PROP_INDICATE 0x20 //!< Permits indications of a Characteristic Value with acknowledgement
#define GATT_PROP_AUTHEN 0x40 //!< Permits signed writes to the Characteristic Value
#define GATT_PROP_EXTENDED 0x80 //!< Additional characteristic properties are defined in the Characteristic Extended Properties Descriptor
// GATT local read or write operation
#define GATT_LOCAL_READ 0xFF
#define GATT_LOCAL_WRITE 0xFE
// GATT Encryption Key Size Limits
#define GATT_MIN_ENCRYPT_KEY_SIZE 7 //!< GATT Minimum Encryption Key Size
#define GATT_MAX_ENCRYPT_KEY_SIZE 16 //!< GATT Maximum Encryption Key Size
// Attribute handle definitions
#define GATT_INVALID_HANDLE 0x0000 // Invalid attribute handle
#define GATT_MIN_HANDLE 0x0001 // Minimum attribute handle
#define GATT_MAX_HANDLE 0xFFFF // Maximum attribute handle
#define GATT_MAX_MTU 0xFFFF // Maximum MTU size
// Attribute Access Permissions
#define gattPermitRead( a ) ( (a) & GATT_PERMIT_READ )
#define gattPermitWrite( a ) ( (a) & GATT_PERMIT_WRITE )
#define gattPermitAuthenRead( a ) ( (a) & GATT_PERMIT_AUTHEN_READ )
#define gattPermitAuthenWrite( a ) ( (a) & GATT_PERMIT_AUTHEN_WRITE )
#define gattPermitAuthorRead( a ) ( (a) & GATT_PERMIT_AUTHOR_READ )
#define gattPermitAuthorWrite( a ) ( (a) & GATT_PERMIT_AUTHOR_WRITE )
#define gattPermitEncryptRead( a ) ( (a) & GATT_PERMIT_ENCRYPT_READ )
#define gattPermitEncryptWrite( a ) ( (a) & GATT_PERMIT_ENCRYPT_WRITE )
// Check for different UUID types
#define gattPrimaryServiceType( t ) ( ATT_CompareUUID( primaryServiceUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
#define gattSecondaryServiceType( t ) ( ATT_CompareUUID( secondaryServiceUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
#define gattCharacterType( t ) ( ATT_CompareUUID( characterUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
#define gattIncludeType( t ) ( ATT_CompareUUID( includeUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
#define gattServiceType( t ) ( gattPrimaryServiceType( (t) ) || gattSecondaryServiceType( (t) ) )
#define GATT_MAX_NUM_CONN (4)
// GATT Client Characteristic Configuration Bit Fields
#define GATT_CLIENT_CFG_NOTIFY 0x0001 //!< The Characteristic Value shall be notified
#define GATT_CLIENT_CFG_INDICATE 0x0002 //!< The Characteristic Value shall be indicated
#define GATT_CFG_NO_OPERATION 0x0000 // No operation
// All profile services bit fields
#define GATT_ALL_SERVICES 0xFFFFFFFF
// The number of attribute records in a given attribute table
#define GATT_NUM_ATTRS( attrs ) ( sizeof( attrs ) / sizeof( gattAttribute_t ) )
// The handle of a service is the handle of the first attribute
#define GATT_SERVICE_HANDLE( attrs ) ( (attrs)[0].handle )
// The handle of the first included service (i = 1) is the value of the second attribute
#define GATT_INCLUDED_HANDLE( attrs, i ) ( *((uint16_t *)((attrs)[(i)].pValue)) )
// Client Characteristic Configuration table (from CCC attribute value pointer)
#define GATT_CCC_TBL( pValue ) ( (gattCharCfg_t *)(*((PTR_TYPE)(&pValue))))
/************************************ GAP *************************************/
#define GAP_MSG_EVENT_DEFINES //!< GAP type of command
#define GAP_DEVICE_INIT_DONE_EVENT 0x00 //!< Sent when the Device Initialization is complete. This event is sent as an tmos message defined as gapDeviceInitDoneEvent_t.
#define GAP_DEVICE_DISCOVERY_EVENT 0x01 //!< Sent when the Device Discovery Process is complete. This event is sent as an tmos message defined as gapDevDiscEvent_t.
#define GAP_ADV_DATA_UPDATE_DONE_EVENT 0x02 //!< Sent when the Advertising Data or SCAN_RSP Data has been updated. This event is sent as an tmos message defined as gapAdvDataUpdateEvent_t.
#define GAP_MAKE_DISCOVERABLE_DONE_EVENT 0x03 //!< Sent when the Make Discoverable Request is complete. This event is sent as an tmos message defined as gapMakeDiscoverableRspEvent_t.
#define GAP_END_DISCOVERABLE_DONE_EVENT 0x04 //!< Sent when the Advertising has ended. This event is sent as an tmos message defined as gapEndDiscoverableRspEvent_t.
#define GAP_LINK_ESTABLISHED_EVENT 0x05 //!< Sent when the Establish Link Request is complete. This event is sent as an tmos message defined as gapEstLinkReqEvent_t.
#define GAP_LINK_TERMINATED_EVENT 0x06 //!< Sent when a connection was terminated. This event is sent as an tmos message defined as gapTerminateLinkEvent_t.
#define GAP_LINK_PARAM_UPDATE_EVENT 0x07 //!< Sent when an Update Parameters Event is received. This event is sent as an tmos message defined as gapLinkUpdateEvent_t.
#define GAP_RANDOM_ADDR_CHANGED_EVENT 0x08 //!< Sent when a random address was changed. This event is sent as an tmos message defined as gapRandomAddrEvent_t.
#define GAP_SIGNATURE_UPDATED_EVENT 0x09 //!< Sent when the device's signature counter is updated. This event is sent as an tmos message defined as gapSignUpdateEvent_t.
#define GAP_AUTHENTICATION_COMPLETE_EVENT 0x0A //!< Sent when the Authentication (pairing) process is complete. This event is sent as an tmos message defined as gapAuthCompleteEvent_t.
#define GAP_PASSKEY_NEEDED_EVENT 0x0B //!< Sent when a Passkey is needed. This is part of the pairing process. This event is sent as an tmos message defined as gapPasskeyNeededEvent_t.
#define GAP_SLAVE_REQUESTED_SECURITY_EVENT 0x0C //!< Sent when a Slave Security Request is received. This event is sent as an tmos message defined as gapSlaveSecurityReqEvent_t.
#define GAP_DEVICE_INFO_EVENT 0x0D //!< Sent during the Device Discovery Process when a device is discovered. This event is sent as an tmos message defined as gapDeviceInfoEvent_t.
#define GAP_BOND_COMPLETE_EVENT 0x0E //!< Sent when the bonding process is complete. This event is sent as an tmos message defined as gapBondCompleteEvent_t.
#define GAP_PAIRING_REQ_EVENT 0x0F //!< Sent when an unexpected Pairing Request is received. This event is sent as an tmos message defined as gapPairingReqEvent_t.
#define GAP_DIRECT_DEVICE_INFO_EVENT 0x10 //!< Sent when a direct Advertising Data is received. This event is sent as an tmos message defined as gapDirectDeviceInfoEvent_t.
#define GAP_PHY_UPDATE_EVENT 0x11 //!< Sent when a PHY Update Event is received. This event is sent as an tmos message defined as gapLinkUpdateEvent_t.
#define GAP_EXT_ADV_DEVICE_INFO_EVENT 0x12 //!< Sent when a Extended Advertising Data is received. This event is sent as an tmos message defined as gapExtAdvDeviceInfoEvent_t.
#define GAP_MAKE_PERIODIC_ADV_DONE_EVENT 0x13 //!< Sent when the Set Periodic Advertising enable is complete. This event is sent as an tmos message defined as gapMakePeriodicRspEvent_t.
#define GAP_END_PERIODIC_ADV_DONE_EVENT 0x14 //!< Sent when the Set Periodic Advertising disable is complete. This event is sent as an tmos message defined as gapEndPeriodicRspEvent_t.
#define GAP_SYNC_ESTABLISHED_EVENT 0x15 //!< Sent when a Periodic Advertising Sync Establish is complete. This event is sent as an tmos message defined as gapSyncEstablishedEvent_t.
#define GAP_PERIODIC_ADV_DEVICE_INFO_EVENT 0x16 //!< Sent when a Periodic Advertising Data is received. This event is sent as an tmos message defined as gapPeriodicAdvDeviceInfoEvent_t.
#define GAP_SYNC_LOST_EVENT 0x17 //!< Sent when a Periodic Advertising Sync was lost. This event is sent as an tmos message defined as gapSyncLostEvent_t.
#define GAP_SCAN_REQUEST_EVENT 0x19 //!< Sent when a SCAN_REQ PDU or an AUX_SCAN_REQ PDU has been received by the advertiser. This event is sent as an tmos message defined as gapScanReqReseiveEvent_t.
#define GAP_OOB_NEEDED_EVENT 0x1A //!< resv
#define GAP_MAKE_CONNECTIONESS_CTE_DONE_EVENT 0x1B //!< Sent when the Set Connectionless CTE Transmit enable is complete. This event is sent as an tmos message defined as gapMakeConnectionlessCTERspEvent_t.
#define GAP_END_CONNECTIONESS_CTE_DONE_EVENT 0x1C //!< Sent when the Set Connectionless CTE Transmit disable is complete. This event is sent as an tmos message defined as gapEndConnectionlessCTERspEvent_t.
#define GAP_PERI_ADV_SYNC_TRAN_RECEIVED_EVENT 0x1D //!< Sent when the periodic advertising sync transfer received. This event is sent as an tmos message defined as gapPeriTranReceivec_t.
// GAP_PROFILE_ROLE_DEFINES GAP Profile Roles
#define GAP_PROFILE_BROADCASTER 0x01 //!< A device that sends advertising events only.
#define GAP_PROFILE_OBSERVER 0x02 //!< A device that receives advertising events only.
#define GAP_PROFILE_PERIPHERAL 0x04 //!< A device that accepts the establishment of an LE physical link using the connection establishment procedure
#define GAP_PROFILE_CENTRAL 0x08 //!< A device that supports the Central role initiates the establishment of a physical connection
// GAP Status Return Values - returned as bStatus_t
#define bleGAPUserCanceled 0x30 //!< The user canceled the task
#define bleGAPConnNotAcceptable 0x31 //!< The connection was not accepted
#define bleGAPBondRejected 0x32 //!< The bond information was rejected.
#define bleGAPExpiredCanceled 0x33 //!< The duration has expired
#define GAP_DEVICE_NAME_LEN 21 //!< Excluding null-terminate char
#define GAP_DEVICE_NAME_MAX_LEN 248 //!< maximum length of device name
// option defined
#define LISTEN_PERIODIC_ADVERTISING_MODE (1<<0) //!< used to determine whether the Periodic Advertiser List is used
#define REPORTING_INITIALLY_DISABLED (1<<1) //!< 0: Reporting initially enabled 1: Reporting initially disabled
#define DUPLICATE_FILTERING_INITIALLY_ENABLED (1<<2) //!< 0: Duplicate filtering initially disabled 1: Duplicate filtering initially enabled
/*-------------------------------------------------------------------
* CONSTANTS
*/
/** @defgroup GAP_CONN_HANDLE_DEFINES GAP Special Connection Handles
* Used by GAP_TerminateLinkReq()
* @{
*/
#define GAP_CONNHANDLE_INIT 0xFFFE //!< terminates a link create
#define GAP_CONNHANDLE_ALL 0xFFFF //!< terminates all links for the matching task ID.
/** @} End GAP_CONN_HANDLE_DEFINES */
// Privacy Flag States
#define GAP_PRIVACY_DISABLED 0x00
#define GAP_PRIVACY_ENABLED 0x01
// GAP GATT Server Parameters used with GGS Get/Set Parameter and Application's Callback functions
#define GGS_DEVICE_NAME_ATT 0 //!< RW uint8_t[GAP_DEVICE_NAME_LEN]
#define GGS_APPEARANCE_ATT 1 //!< RW uint16_t
#define GGS_PERI_PRIVACY_FLAG_ATT 2 //!< RW uint8_t
#define GGS_RECONNCT_ADDR_ATT 3 //!< RW uint8_t[B_ADDR_LEN]
#define GGS_PERI_CONN_PARAM_ATT 4 //!< RW sizeof(gapPeriConnectParams_t)
#define GGS_PERI_PRIVACY_FLAG_PROPS 5 //!< RW uint8_t
#define GGS_W_PERMIT_DEVICE_NAME_ATT 6 //!< W uint8_t
#define GGS_W_PERMIT_APPEARANCE_ATT 7 //!< W uint8_t
#define GGS_W_PERMIT_PRIVACY_FLAG_ATT 8 //!< W uint8_t
#define GGS_CENT_ADDR_RES_ATT 9 //!< RW uint8_t
#define GGS_ENC_DATA_KEY_MATERIAL 11 //!< RW sizeof(gapEncDataKey_t)
#define GGS_LE_GATT_SEC_LEVELS 12 //!< RW uint8_t
// GAP Services bit fields
#define GAP_SERVICE 0x00000001
// GAP_PARAMETER_ID_DEFINES GAP Parameter IDs
// Timers
#define TGAP_GEN_DISC_ADV_MIN 0 //!< Minimum time to remain advertising, when in Discoverable mode.Default 0-turns off the timeout. (n * 0.625 mSec).
#define TGAP_LIM_ADV_TIMEOUT 1 //!< Maximum time to remain advertising, when in Limited Discoverable mode.Default 180 seconds. (n * 1 seconds)
#define TGAP_DISC_SCAN 2 //!< Minimum time to perform scanning,Setting this parameter to 0 turns off the timeout.Default 10.24seconds. (n * 0.625 mSec)
// when in General Discovery process
#define TGAP_DISC_ADV_INT_MIN 3 //!< Minimum advertising interval.Default 160. (n * 0.625 mSec)
#define TGAP_DISC_ADV_INT_MAX 4 //!< Maximum advertising interval.Default 160. (n * 0.625 mSec)
#define TGAP_DISC_SCAN_INT 5 //!< Scan interval used during Link Layer Scanning state.Default 16. (n * 0.625 mSec)
#define TGAP_DISC_SCAN_WIND 6 //!< Scan window used during Link Layer Scanning state.Default 16. (n * 0.625 mSec)
// when in Connection Establishment process(1M PHY)
#define TGAP_CONN_EST_INT_MIN 7 //!< Minimum Link Layer connection interval.Default 80. (n * 1.25 mSec)
#define TGAP_CONN_EST_INT_MAX 8 //!< Maximum Link Layer connection interval.Default 80. (n * 1.25 mSec)
#define TGAP_CONN_EST_SCAN_INT 9 //!< Scan interval used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
#define TGAP_CONN_EST_SCAN_WIND 10 //!< Scan window used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
#define TGAP_CONN_EST_HIGH_SCAN_INT 11 //!< Scan interval used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
#define TGAP_CONN_EST_HIGH_SCAN_WIND 12 //!< Scan window used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
#define TGAP_CONN_EST_SUPERV_TIMEOUT 13 //!< Link Layer connection supervision timeout.Default 2000. (n * 10 mSec)
#define TGAP_CONN_EST_LATENCY 14 //!< Link Layer connection slave latency.Default 0. (in number of connection events)
#define TGAP_CONN_EST_MIN_CE_LEN 15 //!< Local informational parameter about minimum length of connection needed.Default 0. (n * 0.625 mSec)
#define TGAP_CONN_EST_MAX_CE_LEN 16 //!< Local informational parameter about maximum length of connection needed.Default 0. (n * 0.625 mSec)
// Proprietary
#define TGAP_PRIVATE_ADDR_INT 17 //!< Minimum Time Interval between private (resolvable) address changes.Default 900. (n * 1 seconds)
#define TGAP_SM_TIMEOUT 18 //!< SM Message Timeout (milliseconds). Default 30 seconds.
#define TGAP_SM_MIN_KEY_LEN 19 //!< SM Minimum Key Length supported. Default 7.
#define TGAP_SM_MAX_KEY_LEN 20 //!< SM Maximum Key Length supported. Default 16.
#define TGAP_FILTER_ADV_REPORTS 21 //!< Filter duplicate advertising reports. Default TRUE.
#define TGAP_SCAN_RSSI_MIN 22 //!< Minimum RSSI required for scan advertising to be reported to the app. Default -127.
#define TGAP_REJECT_CONN_PARAMS 23 //!< Whether or not to reject Connection Parameter Update Request received on Central device. Default FALSE.
#define TGAP_AUTH_TASK_ID 24 //!< Task ID override for Task Authentication control (for stack internal use only)
// v5.x
#define TGAP_ADV_TX_POWER 25 //!< Indicates the maximum power level Range: -127 â?N â?+126 Units: dBm.Default 127(Host has no preference).
#define TGAP_ADV_PRIMARY_PHY 26 //!< Indicates the PHY on which the advertising packets are transmitted on the primary advertising channel.LE 1M/LE Coded.Default GAP_PHY_VAL_LE_1M.
#define TGAP_ADV_SECONDARY_PHY 27 //!< LE 1M/LE 2M/LE Coded. Default GAP_PHY_VAL_LE_1M.
#define TGAP_ADV_SECONDARY_MAX_SKIP 28 //!< Maximum advertising events the Controller can skip before sending the AUX_ADV_IND packets on the secondary advertising channel. Default 0.
#define TGAP_ADV_ADVERTISING_SID 29 //!< Value of the Advertising SID subfield in the ADI field of the PDU Range:0-15. Default 0.
#define TGAP_ADV_SCAN_REQ_NOTIFY 30 //!< bit0:Scan request notifications enabled.Default 0-disabled.
//!< bit1:After the SCAN_RSP PDU is sent the advertiser move to the next used primary advertising channel index.Default 0-close the advertising event.
#define TGAP_ADV_ADVERTISING_DURATION 31 //!< Advertising duration Range: 0x0001 - 0xFFFF Time = N * 10ms. Default 0-No advertising duration.
#define TGAP_ADV_MAX_EVENTS 32 //!< indicates the maximum number of extended advertising events.Range: 0x00 - 0xFF. Default 0(No maximum number of advertising events).
// when in General Discovery process
#define TGAP_DISC_SCAN_PHY 33 //!< LE 1M/LE Coded. Default GAP_PHY_BIT_LE_1M.
#define TGAP_DISC_SCAN_CODED_INT 34 //!< Scan interval used during Link Layer coded Scanning state, when in General Discovery process (n * 0.625 mSec)
#define TGAP_DISC_SCAN_CODED_WIND 35 //!< Scan window used during Link Layer coded Scanning state, when in General Discovery process (n * 0.625 mSec)
#define TGAP_DISC_SCAN_DURATION 36 //!< Scan duration Range: 0x0001 - 0xFFFF Time = N * 10 ms. Default 0-Scan continuously until explicitly disable.
#define TGAP_DISC_SCAN_PERIOD 37 //!< resv.
// when in Connection Establishment process(2M PHY)
#define TGAP_CONN_EST_INT_PHY 38 //!< LE 1M/LE Coded. Default GAP_PHY_BIT_LE_1M.
#define TGAP_CONN_EST_2M_INT_MIN 39 //!< Minimum Link Layer connection interval.Default 80. (n * 1.25 mSec)
#define TGAP_CONN_EST_2M_INT_MAX 40 //!< Maximum Link Layer connection interval.Default 80. (n * 1.25 mSec)
#define TGAP_CONN_EST_2M_SUPERV_TIMEOUT 41 //!< Link Layer connection supervision timeout.Default 2000. (n * 10 mSec)
#define TGAP_CONN_EST_2M_LATENCY 42 //!< Link Layer connection slave latency.Default 0. (in number of connection events)
#define TGAP_CONN_EST_2M_MIN_CE_LEN 43 //!< Local informational parameter about minimum length of connection needed.Default 0. (n * 0.625 mSec)
#define TGAP_CONN_EST_2M_MAX_CE_LEN 44 //!< Local informational parameter about maximum length of connection needed.Default 0. (n * 0.625 mSec)
// when in Connection Establishment process(Coded PHY)
#define TGAP_CONN_EST_CODED_INT_MIN 45 //!< Minimum Link Layer connection interval.Default 80. (n * 1.25 mSec)
#define TGAP_CONN_EST_CODED_INT_MAX 46 //!< Maximum Link Layer connection interval.Default 80. (n * 1.25 mSec)
#define TGAP_CONN_EST_CODED_SCAN_INT 47 //!< Scan interval used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
#define TGAP_CONN_EST_CODED_SCAN_WIND 48 //!< Scan window used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
#define TGAP_CONN_EST_CODED_HIGH_SCAN_INT 49 //!< Scan interval used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
#define TGAP_CONN_EST_CODED_HIGH_SCAN_WIND 50 //!< Scan window used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
#define TGAP_CONN_EST_CODED_SUPERV_TIMEOUT 51 //!< Link Layer connection supervision timeout.Default 2000. (n * 10 mSec)
#define TGAP_CONN_EST_CODED_LATENCY 52 //!< Link Layer connection slave latency.Default 0. (in number of connection events)
#define TGAP_CONN_EST_CODED_MIN_CE_LEN 53 //!< Local informational parameter about minimum length of connection needed.Default 0. (n * 0.625 mSec)
#define TGAP_CONN_EST_CODED_MAX_CE_LEN 54 //!< Local informational parameter about maximum length of connection needed.Default 0. (n * 0.625 mSec)
// periodic advertising
#define TGAP_PERIODIC_ADV_INT_MIN 55 //!< Minimum periodic advertising interval.Range: 0x0006 to 0xFFFF.Default 160. (n * 1.25 mSec)
#define TGAP_PERIODIC_ADV_INT_MAX 56 //!< Maximum periodic advertising interval.Range: 0x0006 to 0xFFFF.Default 160. (n * 1.25 mSec)
#define TGAP_PERIODIC_ADV_PROPERTIES 57 //!< Include TxPower in the periodic advertising PDU.
#define TGAP_SCAN_MAX_LENGTH 58 //!< Extended scan maximum data length.Default 460
#define TGAP_AFH_CHANNEL_MDOE 59 //!< whether t he Controller's channel assessment scheme is enabled or disabled.Default disabled.
// Constant Tone Extension Transmit
#define TGAP_CTE_TYPE 60 //!< The type of Constant Tone Extension.Default GAP_CTE_TYPE_AOA.
#define TGAP_CTE_LENGTH 61 //!< The type of Constant Tone Extension.Default 20.Range[2,20]
#define TGAP_CTE_COUNT 62 //!< resv
#define TGAP_LENGTH_OF_SWITCHING_PATTERN 63 //!< The number of Antenna IDs in the pattern,only used when transmitting an AoD Constant Tone Extension.Default 0.
// Advertising Coding Selection
#define TGAP_ADV_PRIMARY_PHY_OPTIONS 64 //!< Indicate the Host's preference or requirement concerning coding scheme.Default GAP_PHY_OPTIONS_NOPRE.
#define TGAP_ADV_SECONDARY_PHY_OPTIONS 65 //!< indicate the Host's preference or requirement concerning coding scheme (including for periodic advertising).Default GAP_PHY_OPTIONS_NOPRE.
#define TGAP_PARAMID_MAX 66 //!< ID MAX-valid Parameter ID
// GAP_DEVDISC_MODE_DEFINES GAP Device Discovery Modes
#define DEVDISC_MODE_NONDISCOVERABLE 0x00 //!< No discoverable setting
#define DEVDISC_MODE_GENERAL 0x01 //!< General Discoverable devices
#define DEVDISC_MODE_LIMITED 0x02 //!< Limited Discoverable devices
#define DEVDISC_MODE_ALL 0x03 //!< Not filtered
// GAP_ADDR_TYPE_DEFINES GAP Address Types
#define ADDRTYPE_PUBLIC 0x00 //!< Use the BD_ADDR
#define ADDRTYPE_STATIC 0x01 //!< Static address
#define ADDRTYPE_PRIVATE_NONRESOLVE 0x02 //!< Generate Non-Resolvable Private Address
#define ADDRTYPE_PRIVATE_RESOLVE 0x03 //!< Generate Resolvable Private Address
// GAP_ADVERTISEMENT_TYPE_DEFINES GAP Advertising Event Types
#define GAP_ADTYPE_ADV_IND 0x00 //!< Connectable undirected event typet
#define GAP_ADTYPE_ADV_HDC_DIRECT_IND 0x01 //!< Connectable high duty cycle directed event type
#define GAP_ADTYPE_ADV_SCAN_IND 0x02 //!< Scannable undirected event type
#define GAP_ADTYPE_ADV_NONCONN_IND 0x03 //!< Non-Connectable undirected event type
#define GAP_ADTYPE_ADV_LDC_DIRECT_IND 0x04 //!< Connectable low duty cycle directed event type
//v5.x
#define GAP_ADTYPE_EXT_CONN_DIRECT 0x05 //!< extend Connectable directed event type
#define GAP_ADTYPE_EXT_SCAN_UNDIRECT 0x06 //!< extend Scannable undirected event type
#define GAP_ADTYPE_EXT_NONCONN_NONSCAN_UNDIRECT 0x07 //!< extend Non-Connectable and Non-Scannable undirected event type
#define GAP_ADTYPE_EXT_CONN_UNDIRECT 0x08 //!< extend Connectable undirected event type
#define GAP_ADTYPE_EXT_SCAN_DIRECT 0x09 //!< extend Scannable directed event type
#define GAP_ADTYPE_EXT_NONCONN_NONSCAN_DIRECT 0x0A //!< extend Non-Connectable and Non-Scannable directed event type
// GAP_ADVERTISEMENT_TYPE_DEFINES GAP Advertising PHY VAL TYPE(GAP_PHY_VAL_TYPE)
#define GAP_PHY_VAL_TYPE
#define GAP_PHY_VAL_LE_1M 0x01
#define GAP_PHY_VAL_LE_2M 0x02
#define GAP_PHY_VAL_LE_CODED 0x03
// GAP_ADVERTISEMENT_TYPE_DEFINES GAP Scan PHY VAL TYPE(GAP_PHY_BIT_TYPE)
#define GAP_PHY_BIT_TYPE
#define GAP_PHY_BIT_LE_1M (1<<0)
#define GAP_PHY_BIT_LE_2M (1<<1)
#define GAP_PHY_BIT_LE_CODED (1<<2)
#define GAP_PHY_BIT_ALL (GAP_PHY_BIT_LE_1M|GAP_PHY_BIT_LE_2M|GAP_PHY_BIT_LE_CODED)
#define GAP_PHY_BIT_LE_CODED_S2 (1<<3)
// PHY_OPTIONS preferred coding when transmitting on the LE Coded PHY
#define GAP_PHY_OPTIONS_TYPE
#define GAP_PHY_OPTIONS_NOPRE 0x00 //!< 0:no preferred
#define GAP_PHY_OPTIONS_S2 0x01 //!< prefers that S=2 coding be used when transmitting on the LE Coded PHY
#define GAP_PHY_OPTIONS_S8 0x02 //!< prefers that S=8 coding be used when transmitting on the LE Coded PHY
#define GAP_PHY_OPTIONS_S2_REQUIRES 0x03 //!< requires that S=2 coding be used when transmitting on the LE Coded PHY
#define GAP_PHY_OPTIONS_S8_REQUIRES 0x04 //!< requires that S=8 coding be used when transmitting on the LE Coded PHY
// GAP_ADVERTISEMENT_TYPE_DEFINES GAP Periodic Advertising Properties
#define GAP_PERI_PROPERTIES_INCLUDE_TXPOWER (1<<6)
// GAP_ADVERTISEMENT_TYPE_DEFINES GAP Connectionless CTE Transmit CTE type
#define GAP_CTE_TYPE_AOA 0x00 //!< AoA Constant Tone Extension
#define GAP_CTE_TYPE_AOD_1US 0x01 //!< AoD Constant Tone Extension with 1us slots
#define GAP_CTE_TYPE_AOD_2US 0x02 //!< AoD Constant Tone Extension with 2us slots
// GAP Advertising Report Event Types
#define GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
// bit0 to 4 ADVERTISEMENT_TYPE:defined for gapExtAdvDeviceInfoEvent_t Advertisement data type
#define GAP_ADRPT_ADV_IND 0x00 //!< Connectable undirected advertisement
#define GAP_ADRPT_ADV_DIRECT_IND 0x01 //!< Connectable directed advertisement
#define GAP_ADRPT_ADV_SCAN_IND 0x02 //!< Scannable undirected advertisement
#define GAP_ADRPT_ADV_NONCONN_IND 0x03 //!< Non-Connectable undirected advertisement
#define GAP_ADRPT_SCAN_RSP 0x04 //!< Scan Response
#define GAP_ADRPT_EXT_CONN_DIRECT 0x05 //!< extend Connectable directed report type
#define GAP_ADRPT_EXT_SCAN_UNDIRECT 0x06 //!< extend Scannable undirected report type
#define GAP_ADRPT_EXT_NONCONN_NONSCAN_UNDIRECT 0x07 //!< extend Non-Connectable and Non-Scannable undirected report type
#define GAP_ADRPT_EXT_CONN_UNDIRECT 0x08 //!< extend Connectable undirected report type
#define GAP_ADRPT_EXT_SCAN_DIRECT 0x09 //!< extend Scannable directed report type
#define GAP_ADRPT_EXT_NONCONN_NONSCAN_DIRECT 0x0A //!< extend Non-Connectable and Non-Scannable directed report type
#define GAP_ADRPT_EXT_SCAN_RESPONSE 0x0B //!< extend Scan Response report type
// bit5 to 6 Data status:defined for gapExtAdvDeviceInfoEvent_t Advertisement data type
#define GAP_ADRPT_EXT_DATA_MASK (3<<5)
#define GAP_ADRPT_EXT_DATA_COMPLETE (0<<5) //!< Complete
#define GAP_ADRPT_EXT_DATA_INCOMPLETE (1<<5) //!< more data to come
#define GAP_ADRPT_EXT_DATA_LAST (2<<5) //!< Incomplete, data truncated, no more to come
// GAP_EXTEND_ADVERTISEMENT_REPORT_TYPE_DEFINES GAP Extend Advertising Report Event Types
#define GAP_ADRPT_ADV_CONNECTABLE (1<<0)
#define GAP_ADRPT_ADV_SCANNABLE (1<<1)
#define GAP_ADRPT_ADV_DITECTED (1<<2)
#define GAP_ADRPT_SCAN_RESPONSE (1<<3)
// GAP_FILTER_POLICY_DEFINES GAP Advertiser Filter Scan Parameters
#define GAP_FILTER_POLICY_ALL 0x00 //!< Allow Scan Request from Any, Allow Connect Request from Any (default).
#define GAP_FILTER_POLICY_WHITE_SCAN 0x01 //!< Allow Scan Request from White List Only, Allow Connect from Any
#define GAP_FILTER_POLICY_WHITE_CON 0x02 //!< Allow Scan Request from Any, Connect from White List Only
#define GAP_FILTER_POLICY_WHITE 0x03 //!< Allow Scan Request and Connect from White List Only
// Maximum Pairing Passcode/Passkey value. Range of a passkey can be 0 - 999,999.
#define GAP_PASSCODE_MAX 999999
/** Sign Counter Initialized - Sign counter hasn't been used yet. Used when setting up
* a connection's signing information.
*/
#define GAP_INIT_SIGN_COUNTER 0xFFFFFFFF