NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_gap.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_GAP_
21#define H_BLE_GAP_
22
30#include <inttypes.h>
31#include "ble_hs.h"
32#include "ble_hs_adv.h"
33#include "nimble/porting/nimble/include/syscfg/syscfg.h"
34#include "ble_esp_gap.h"
35
36#if MYNEWT_VAL(ENC_ADV_DATA)
37#include "../../src/ble_hs_hci_priv.h"
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44struct hci_le_conn_complete;
45struct hci_conn_update;
46
47#define BLE_GAP_ADV_ITVL_MS(t) ((t) * 1000 / BLE_HCI_ADV_ITVL)
48#define BLE_GAP_SCAN_ITVL_MS(t) ((t) * 1000 / BLE_HCI_SCAN_ITVL)
49#define BLE_GAP_SCAN_WIN_MS(t) ((t) * 1000 / BLE_HCI_SCAN_ITVL)
50#define BLE_GAP_CONN_ITVL_MS(t) ((t) * 1000 / BLE_HCI_CONN_ITVL)
51#define BLE_GAP_SUPERVISION_TIMEOUT_MS(t) ((t) / 10)
52#define BLE_GAP_PERIODIC_ITVL_MS(t) ((t) * 1000 / BLE_HCI_PERIODIC_ADV_ITVL)
53
54#if MYNEWT_VAL(BLE_HIGH_DUTY_ADV_ITVL)
56#define BLE_GAP_ADV_FAST_INTERVAL1_MIN BLE_GAP_ADV_ITVL_MS(5)
57#else
59#define BLE_GAP_ADV_FAST_INTERVAL1_MIN BLE_GAP_ADV_ITVL_MS(30)
60#endif
61
63#define BLE_GAP_ADV_FAST_INTERVAL1_MAX BLE_GAP_ADV_ITVL_MS(60)
64
65#if MYNEWT_VAL(BLE_HIGH_DUTY_ADV_ITVL)
67#define BLE_GAP_ADV_FAST_INTERVAL2_MIN BLE_GAP_ADV_ITVL_MS(5)
68#else
70#define BLE_GAP_ADV_FAST_INTERVAL2_MIN BLE_GAP_ADV_ITVL_MS(100)
71#endif
72
74#define BLE_GAP_ADV_FAST_INTERVAL2_MAX BLE_GAP_ADV_ITVL_MS(150)
75
77#define BLE_GAP_SCAN_FAST_INTERVAL_MIN BLE_GAP_SCAN_ITVL_MS(30)
78
80#define BLE_GAP_SCAN_FAST_INTERVAL_MAX BLE_GAP_SCAN_ITVL_MS(60)
81
83#define BLE_GAP_LIM_DISC_SCAN_INT BLE_GAP_SCAN_ITVL_MS(11.25)
84
86#define BLE_GAP_LIM_DISC_SCAN_WINDOW BLE_GAP_SCAN_WIN_MS(11.25)
87
89#define BLE_GAP_SCAN_FAST_WINDOW BLE_GAP_SCAN_WIN_MS(30)
90
91/* 30.72 seconds; active scanning. */
92#define BLE_GAP_SCAN_FAST_PERIOD BLE_GAP_SCAN_ITVL_MS(30.72)
93
95#define BLE_GAP_SCAN_SLOW_INTERVAL1 BLE_GAP_SCAN_ITVL_MS(1280)
96
98#define BLE_GAP_SCAN_SLOW_WINDOW1 BLE_GAP_SCAN_WIN_MS(11.25)
99
101#define BLE_GAP_DISC_DUR_DFLT (10.24 * 1000)
102
104#define BLE_GAP_CONN_DUR_DFLT (30 * 1000)
105
107#define BLE_GAP_CONN_PAUSE_CENTRAL (1 * 1000)
108
110#define BLE_GAP_CONN_PAUSE_PERIPHERAL (5 * 1000)
111
112/* 30 ms. */
113#define BLE_GAP_INITIAL_CONN_ITVL_MIN BLE_GAP_CONN_ITVL_MS(30)
114
115/* 50 ms. */
116#define BLE_GAP_INITIAL_CONN_ITVL_MAX BLE_GAP_CONN_ITVL_MS(50)
117
119#define BLE_GAP_ADV_DFLT_CHANNEL_MAP 0x07
120
121#define BLE_GAP_INITIAL_CONN_LATENCY 0
122#define BLE_GAP_INITIAL_SUPERVISION_TIMEOUT 0x0100
123#define BLE_GAP_INITIAL_CONN_MIN_CE_LEN 0x0000
124#define BLE_GAP_INITIAL_CONN_MAX_CE_LEN 0x0000
125
126#define BLE_GAP_ROLE_MASTER 0
127#define BLE_GAP_ROLE_SLAVE 1
128
129#define BLE_GAP_EVENT_CONNECT 0
130#define BLE_GAP_EVENT_DISCONNECT 1
131/* Reserved 2 */
132#define BLE_GAP_EVENT_CONN_UPDATE 3
133#define BLE_GAP_EVENT_CONN_UPDATE_REQ 4
134#define BLE_GAP_EVENT_L2CAP_UPDATE_REQ 5
135#define BLE_GAP_EVENT_TERM_FAILURE 6
136#define BLE_GAP_EVENT_DISC 7
137#define BLE_GAP_EVENT_DISC_COMPLETE 8
138#define BLE_GAP_EVENT_ADV_COMPLETE 9
139#define BLE_GAP_EVENT_ENC_CHANGE 10
140#define BLE_GAP_EVENT_PASSKEY_ACTION 11
141#define BLE_GAP_EVENT_NOTIFY_RX 12
142#define BLE_GAP_EVENT_NOTIFY_TX 13
143#define BLE_GAP_EVENT_SUBSCRIBE 14
144#define BLE_GAP_EVENT_MTU 15
145#define BLE_GAP_EVENT_IDENTITY_RESOLVED 16
146#define BLE_GAP_EVENT_REPEAT_PAIRING 17
147#define BLE_GAP_EVENT_PHY_UPDATE_COMPLETE 18
148#define BLE_GAP_EVENT_EXT_DISC 19
149#define BLE_GAP_EVENT_PERIODIC_SYNC 20
150#define BLE_GAP_EVENT_PERIODIC_REPORT 21
151#define BLE_GAP_EVENT_PERIODIC_SYNC_LOST 22
152#define BLE_GAP_EVENT_SCAN_REQ_RCVD 23
153#define BLE_GAP_EVENT_PERIODIC_TRANSFER 24
154#define BLE_GAP_EVENT_PATHLOSS_THRESHOLD 25
155#define BLE_GAP_EVENT_TRANSMIT_POWER 26
156#define BLE_GAP_EVENT_SUBRATE_CHANGE 27
157#define BLE_GAP_EVENT_VS_HCI 28
158#define BLE_GAP_EVENT_REATTEMPT_COUNT 29
159#define BLE_GAP_EVENT_AUTHORIZE 30
160#define BLE_GAP_EVENT_TEST_UPDATE 31
161#define BLE_GAP_EVENT_DATA_LEN_CHG 32
162
163/* DTM events */
164#define BLE_GAP_DTM_TX_START_EVT 0
165#define BLE_GAP_DTM_RX_START_EVT 1
166#define BLE_GAP_DTM_END_EVT 2
167
168/*** Reason codes for the subscribe GAP event. */
169
171#define BLE_GAP_SUBSCRIBE_REASON_WRITE 1
172
174#define BLE_GAP_SUBSCRIBE_REASON_TERM 2
175
180#define BLE_GAP_SUBSCRIBE_REASON_RESTORE 3
181
182#define BLE_GAP_REPEAT_PAIRING_RETRY 1
183#define BLE_GAP_REPEAT_PAIRING_IGNORE 2
184
190#define BLE_STATIC_RAND_ADDR_MASK 0xC0
191
193#define BLE_NON_RPA_MASK 0x3F
194
197/* Response values for gatt read/write authorization event */
198#define BLE_GAP_AUTHORIZE_ACCEPT 1
199#define BLE_GAP_AUTHORIZE_REJECT 2
200
204 unsigned encrypted:1;
205
207 unsigned authenticated:1;
208
210 unsigned bonded:1;
211
213 unsigned key_size:5;
214
216 unsigned authorize:1;
217};
218
226 uint8_t conn_mode;
232 uint8_t disc_mode;
233
235 uint16_t itvl_min;
237 uint16_t itvl_max;
239 uint8_t channel_map;
240
243
246};
247
252
254 ble_addr_t our_id_addr;
255
257 ble_addr_t peer_id_addr;
258
260 ble_addr_t our_ota_addr;
261
263 ble_addr_t peer_ota_addr;
264
266 uint16_t conn_handle;
267
269 uint16_t conn_itvl;
270
272 uint16_t conn_latency;
273
276
280 uint8_t role;
281
284};
285
289 uint16_t scan_itvl;
290
292 uint16_t scan_window;
293
295 uint16_t itvl_min;
296
298 uint16_t itvl_max;
299
301 uint16_t latency;
302
305
307 uint16_t min_ce_len;
308
310 uint16_t max_ce_len;
311};
312
316 uint16_t itvl;
317
319 uint16_t window;
320
322 uint8_t passive:1;
323};
324
328 uint16_t itvl;
329
331 uint16_t window;
332
335
337 uint8_t limited:1;
338
340 uint8_t passive:1;
341
344};
345
349 uint16_t itvl_min;
350
352 uint16_t itvl_max;
353
355 uint16_t latency;
356
359
361 uint16_t min_ce_len;
362
364 uint16_t max_ce_len;
365};
366
376 uint8_t action;
377
379 uint32_t numcmp;
380};
381
382#if MYNEWT_VAL(BLE_EXT_ADV)
383
384#define BLE_GAP_EXT_ADV_DATA_STATUS_COMPLETE 0x00
385#define BLE_GAP_EXT_ADV_DATA_STATUS_INCOMPLETE 0x01
386#define BLE_GAP_EXT_ADV_DATA_STATUS_TRUNCATED 0x02
387
389struct ble_gap_ext_disc_desc {
397 uint8_t props;
398
404 uint8_t data_status;
405
414 uint8_t legacy_event_type;
415
417 ble_addr_t addr;
418
420 int8_t rssi;
421
423 int8_t tx_power;
424
426 uint8_t sid;
427
432 uint8_t prim_phy;
433
439 uint8_t sec_phy;
440
442 uint16_t periodic_adv_itvl;
443
445 uint8_t length_data;
446
448 const uint8_t *data;
449
453 ble_addr_t direct_addr;
454};
455#endif
456
466 uint8_t event_type;
467
469 uint8_t length_data;
470
472 ble_addr_t addr;
473
475 int8_t rssi;
476
478 const uint8_t *data;
479
483 ble_addr_t direct_addr;
484};
485
486struct ble_gap_repeat_pairing {
488 uint16_t conn_handle;
489
491 uint8_t cur_key_size;
492 uint8_t cur_authenticated:1;
493 uint8_t cur_sc:1;
494
499 uint8_t new_key_size;
500 uint8_t new_authenticated:1;
501 uint8_t new_sc:1;
502 uint8_t new_bonding:1;
503};
504
515 uint8_t type;
516
521 union {
527 struct {
535
537 uint16_t conn_handle;
539
545 struct {
551
555
562
563#if MYNEWT_VAL(BLE_EXT_ADV)
569 struct ble_gap_ext_disc_desc ext_disc;
570#endif
571
577 struct {
585 int reason;
587
593 struct {
602 int reason;
603
604#if MYNEWT_VAL(BLE_EXT_ADV)
606 uint8_t instance;
608 uint16_t conn_handle;
616 uint8_t num_ext_adv_events;
617#endif
619
628 struct {
635 int status;
636
638 uint16_t conn_handle;
640
655 struct {
661
669
671 uint16_t conn_handle;
673
679 struct {
683 int status;
684
686 uint16_t conn_handle;
688
697 struct {
704 int status;
705
707 uint16_t conn_handle;
709
716 struct {
719
721 uint16_t conn_handle;
723
730 struct {
736 struct os_mbuf *om;
737
739 uint16_t attr_handle;
740
742 uint16_t conn_handle;
743
750 uint8_t indication:1;
752
760 struct {
769 int status;
770
772 uint16_t conn_handle;
773
775 uint16_t attr_handle;
776
783 uint8_t indication:1;
785
800 struct {
802 uint16_t conn_handle;
803
805 uint16_t attr_handle;
806
808 uint8_t reason;
809
811 uint8_t prev_notify:1;
812
814 uint8_t cur_notify:1;
815
817 uint8_t prev_indicate:1;
818
820 uint8_t cur_indicate:1;
822
829 struct {
831 uint16_t conn_handle;
832
837 uint16_t channel_id;
838
839 /* The channel's new MTU. */
840 uint16_t value;
842
850 struct {
852 uint16_t conn_handle;
854
869 struct ble_gap_repeat_pairing repeat_pairing;
870
875 struct {
876 int status;
877 uint16_t conn_handle;
878
885 uint8_t tx_phy;
886 uint8_t rx_phy;
888#if MYNEWT_VAL(BLE_PERIODIC_ADV)
894 struct {
898 uint8_t status;
900 uint16_t sync_handle;
901
903 uint8_t sid;
904
906 ble_addr_t adv_addr;
907
913 uint8_t adv_phy;
914
916 uint16_t per_adv_ival;
917
919 uint8_t adv_clk_accuracy;
920 } periodic_sync;
921
927 struct {
929 uint16_t sync_handle;
930
932 int8_t tx_power;
933
935 int8_t rssi;
936
942 uint8_t data_status;
943
945 uint8_t data_length;
946
948 const uint8_t *data;
949 } periodic_report;
950
958 struct {
960 uint16_t sync_handle;
961
965 int reason;
966 } periodic_sync_lost;
967#endif
968
969#if MYNEWT_VAL(BLE_EXT_ADV)
976 struct {
978 uint8_t instance;
980 ble_addr_t scan_addr;
981 } scan_req_rcvd;
982#endif
983#if MYNEWT_VAL(BLE_PERIODIC_ADV_SYNC_TRANSFER)
989 struct {
993 uint8_t status;
994
996 uint16_t sync_handle;
997
999 uint16_t conn_handle;
1000
1002 uint16_t service_data;
1003
1005 uint8_t sid;
1006
1008 ble_addr_t adv_addr;
1009
1015 uint8_t adv_phy;
1016
1018 uint16_t per_adv_itvl;
1019
1021 uint8_t adv_clk_accuracy;
1022 } periodic_transfer;
1023#endif
1024
1025#if MYNEWT_VAL(BLE_POWER_CONTROL)
1032 struct {
1034 uint16_t conn_handle;
1035
1037 uint8_t current_path_loss;
1038
1040 uint8_t zone_entered;
1041 } pathloss_threshold;
1042
1049 struct {
1051 uint8_t status;
1052
1054 uint16_t conn_handle;
1055
1057 uint8_t reason;
1058
1060 uint8_t phy;
1061
1063 int8_t transmit_power_level;
1064
1066 uint8_t transmit_power_level_flag;
1067
1069 int8_t delta;
1070 } transmit_power;
1071#endif
1072
1073#if MYNEWT_VAL(BLE_CONN_SUBRATING)
1080 struct {
1082 uint8_t status;
1083
1085 uint16_t conn_handle;
1086
1088 uint16_t subrate_factor;
1089
1091 uint16_t periph_latency;
1092
1094 uint16_t cont_num;
1095
1097 uint16_t supervision_tmo;
1098 } subrate_change;
1099#endif
1100
1101#if MYNEWT_VAL(BLE_HCI_VS)
1108 struct {
1109 const void *ev;
1110 uint8_t length;
1111 } vs_hci;
1112#endif
1113
1125 struct {
1126 /* Connection Handle */
1127 uint16_t conn_handle;
1128
1129 /* Attribute handle of the attribute being accessed. */
1130 uint16_t attr_handle;
1131
1132 /* Weather the operation is a read or write operation. */
1133 int is_read;
1134
1135 /* User's response */
1136 int out_response;
1138
1139#if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT)
1147 struct {
1148 /* Connection handle */
1149 uint16_t conn_handle;
1150
1151 /* Reattempt connection attempt count */
1152 uint8_t count;
1153 } reattempt_cnt;
1154#endif
1161 struct {
1162 /* Indicate DTM operation status */
1163 uint8_t status;
1164
1165 /* DTM state change event. Can be following constants:
1166 * o BLE_GAP_DTM_TX_START_EVT
1167 * o BLE_GAP_DTM_RX_START_EVT
1168 * o BLE_GAP_DTM_END_EVT
1169 */
1170 uint8_t update_evt;
1171
1172 /* Number of packets received.
1173 *
1174 * Valid only for BLE_GAP_DTM_END_EVT
1175 * shall be 0 for a transmitter.
1176 */
1177 uint16_t num_pkt;
1179
1186 struct {
1187 /* Connection handle */
1188 uint16_t conn_handle;
1189
1190 /* Max Tx Payload octotes */
1191 uint16_t max_tx_octets;
1192
1193 /* Max Tx Time */
1194 uint16_t max_tx_time;
1195
1196 /* Max Rx payload octet */
1197 uint16_t max_rx_octets;
1198
1199 /* Max Rx Time */
1200 uint16_t max_rx_time;
1202 };
1203};
1204
1205#if MYNEWT_VAL(OPTIMIZE_MULTI_CONN)
1207struct ble_gap_multi_conn_params {
1209 uint8_t own_addr_type;
1210
1211#if MYNEWT_VAL(BLE_EXT_ADV)
1213 uint8_t phy_mask;
1214#endif // MYNEWT_VAL(BLE_EXT_ADV)
1215
1217 const ble_addr_t *peer_addr;
1218
1220 int32_t duration_ms;
1221
1227 const struct ble_gap_conn_params *phy_1m_conn_params;
1228
1229#if MYNEWT_VAL(BLE_EXT_ADV)
1234 const struct ble_gap_conn_params *phy_2m_conn_params;
1235
1240 const struct ble_gap_conn_params *phy_coded_conn_params;
1241#endif // MYNEWT_VAL(BLE_EXT_ADV)
1242
1247 uint32_t scheduling_len_us;
1248};
1249#endif // MYNEWT_VAL(OPTIMIZE_MULTI_CONN)
1250
1251typedef int ble_gap_event_fn(struct ble_gap_event *event, void *arg);
1252
1253#define BLE_GAP_CONN_MODE_NON 0
1254#define BLE_GAP_CONN_MODE_DIR 1
1255#define BLE_GAP_CONN_MODE_UND 2
1256
1257#define BLE_GAP_DISC_MODE_NON 0
1258#define BLE_GAP_DISC_MODE_LTD 1
1259#define BLE_GAP_DISC_MODE_GEN 2
1260
1274int ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc);
1275
1289int ble_gap_conn_find_by_addr(const ble_addr_t *addr,
1290 struct ble_gap_conn_desc *out_desc);
1291
1305int ble_gap_set_event_cb(uint16_t conn_handle,
1306 ble_gap_event_fn *cb, void *cb_arg);
1307
1336int ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr,
1337 int32_t duration_ms,
1338 const struct ble_gap_adv_params *adv_params,
1339 ble_gap_event_fn *cb, void *cb_arg);
1340
1361int ble_gap_adv_stop(void);
1362
1368int ble_gap_adv_active(void);
1369
1379int ble_gap_adv_set_data(const uint8_t *data, int data_len);
1380
1390int ble_gap_adv_rsp_set_data(const uint8_t *data, int data_len);
1391
1404int ble_gap_adv_set_fields(const struct ble_hs_adv_fields *rsp_fields);
1405
1418int ble_gap_adv_rsp_set_fields(const struct ble_hs_adv_fields *rsp_fields);
1419
1420#if MYNEWT_VAL(ENC_ADV_DATA)
1432#define BLE_GAP_DATA_SERIALIZED_SIZE(data_len) ((data_len) + 2)
1433#define BLE_GAP_ENC_ADV_DATA 0x31
1434struct enc_adv_data {
1435 uint8_t len;
1436 uint8_t type;
1437 uint8_t *data;
1438};
1439
1450#define ENC_ADV_DATA(_type, _data, _data_len) \
1451 { \
1452 .type = (_type), \
1453 .len = (_data_len), \
1454 .data = (uint8_t *)(_data), \
1455 }
1456#endif
1457
1458#if MYNEWT_VAL(BLE_EXT_ADV)
1460struct ble_gap_ext_adv_params {
1462 unsigned int connectable:1;
1463
1465 unsigned int scannable:1;
1466
1468 unsigned int directed:1;
1469
1471 unsigned int high_duty_directed:1;
1472
1486 unsigned int legacy_pdu:1;
1487
1489 unsigned int anonymous:1;
1490
1492 unsigned int include_tx_power:1;
1493
1495 unsigned int scan_req_notif:1;
1496
1500 uint32_t itvl_min;
1501
1505 uint32_t itvl_max;
1506
1508 uint8_t channel_map;
1509
1511 uint8_t own_addr_type;
1512
1514 ble_addr_t peer;
1515
1517 uint8_t filter_policy;
1518
1523 uint8_t primary_phy;
1524
1530 uint8_t secondary_phy;
1531
1533 int8_t tx_power;
1534
1536 uint8_t sid;
1537};
1538
1555int ble_gap_ext_adv_configure(uint8_t instance,
1556 const struct ble_gap_ext_adv_params *params,
1557 int8_t *selected_tx_power,
1558 ble_gap_event_fn *cb, void *cb_arg);
1559
1568int ble_gap_ext_adv_set_addr(uint8_t instance, const ble_addr_t *addr);
1569
1586int ble_gap_ext_adv_start(uint8_t instance, int duration, int max_events);
1587
1596int ble_gap_ext_adv_stop(uint8_t instance);
1597
1607int ble_gap_ext_adv_set_data(uint8_t instance, struct os_mbuf *data);
1608
1619int ble_gap_ext_adv_rsp_set_data(uint8_t instance, struct os_mbuf *data);
1620
1630int ble_gap_ext_adv_remove(uint8_t instance);
1631
1638int ble_gap_ext_adv_clear(void);
1639
1650int ble_gap_ext_adv_active(uint8_t instance);
1651#endif
1652
1653/* Periodic Advertising */
1654#if MYNEWT_VAL(BLE_PERIODIC_ADV)
1655
1657struct ble_gap_periodic_adv_params {
1659 unsigned int include_tx_power:1;
1660
1664 uint16_t itvl_min;
1665
1669 uint16_t itvl_max;
1670};
1671
1672#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
1674struct ble_gap_periodic_adv_start_params {
1676 unsigned int include_adi:1;
1677};
1678
1680struct ble_gap_periodic_adv_sync_reporting_params {
1682 unsigned int filter_duplicates:1;
1683};
1684
1686struct ble_gap_periodic_adv_set_data_params {
1688 unsigned int update_did:1;
1689};
1690#endif
1691
1693struct ble_gap_periodic_sync_params {
1697 uint16_t skip;
1698
1701 uint16_t sync_timeout;
1702
1704 unsigned int reports_disabled:1;
1705
1706#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
1709 unsigned int filter_duplicates:1;
1710#endif
1711};
1712
1725int ble_gap_periodic_adv_configure(uint8_t instance,
1726 const struct ble_gap_periodic_adv_params *params);
1727
1728#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
1738int
1739ble_gap_periodic_adv_start(uint8_t instance,
1740 const struct ble_gap_periodic_adv_start_params *params);
1741
1742#else
1750int ble_gap_periodic_adv_start(uint8_t instance);
1751#endif
1752
1760int ble_gap_periodic_adv_stop(uint8_t instance);
1761
1762#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
1774int ble_gap_periodic_adv_set_data(uint8_t instance,
1775 struct os_mbuf *data,
1776 struct ble_gap_periodic_adv_set_data_params *params);
1777#else
1787int ble_gap_periodic_adv_set_data(uint8_t instance, struct os_mbuf *data);
1788#endif
1789
1806int ble_gap_periodic_adv_sync_create(const ble_addr_t *addr, uint8_t adv_sid,
1807 const struct ble_gap_periodic_sync_params *params,
1808 ble_gap_event_fn *cb, void *cb_arg);
1809
1815int ble_gap_periodic_adv_sync_create_cancel(void);
1816
1824int ble_gap_periodic_adv_sync_terminate(uint16_t sync_handle);
1825
1826#if MYNEWT_VAL(BLE_PERIODIC_ADV_SYNC_TRANSFER)
1827#if MYNEWT_VAL(BLE_PERIODIC_ADV_ENH)
1838int ble_gap_periodic_adv_sync_reporting(uint16_t sync_handle,
1839 bool enable,
1840 const struct ble_gap_periodic_adv_sync_reporting_params *params);
1841#else
1850int ble_gap_periodic_adv_sync_reporting(uint16_t sync_handle, bool enable);
1851#endif
1863int ble_gap_periodic_adv_sync_transfer(uint16_t sync_handle,
1864 uint16_t conn_handle,
1865 uint16_t service_data);
1866
1878int ble_gap_periodic_adv_sync_set_info(uint8_t instance,
1879 uint16_t conn_handle,
1880 uint16_t service_data);
1881
1890int periodic_adv_set_default_sync_params(const struct ble_gap_periodic_sync_params *params);
1891
1913int ble_gap_periodic_adv_sync_receive(uint16_t conn_handle,
1914 const struct ble_gap_periodic_sync_params *params,
1915 ble_gap_event_fn *cb, void *cb_arg);
1916#endif
1917
1926int ble_gap_add_dev_to_periodic_adv_list(const ble_addr_t *peer_addr,
1927 uint8_t adv_sid);
1928
1937int ble_gap_rem_dev_from_periodic_adv_list(const ble_addr_t *peer_addr,
1938 uint8_t adv_sid);
1939
1945int ble_gap_clear_periodic_adv_list(void);
1946
1954int ble_gap_read_periodic_adv_list_size(uint8_t *per_adv_list_size);
1955#endif
1956
1957
1987int ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
1988 const struct ble_gap_disc_params *disc_params,
1989 ble_gap_event_fn *cb, void *cb_arg);
1990
2041int ble_gap_ext_disc(uint8_t own_addr_type, uint16_t duration, uint16_t period,
2042 uint8_t filter_duplicates, uint8_t filter_policy,
2043 uint8_t limited,
2044 const struct ble_gap_ext_disc_params *uncoded_params,
2045 const struct ble_gap_ext_disc_params *coded_params,
2046 ble_gap_event_fn *cb, void *cb_arg);
2047
2058int ble_gap_disc_cancel(void);
2059
2066int ble_gap_disc_active(void);
2067
2105int ble_gap_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
2106 int32_t duration_ms,
2107 const struct ble_gap_conn_params *params,
2108 ble_gap_event_fn *cb, void *cb_arg);
2109
2161int ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
2162 int32_t duration_ms, uint8_t phy_mask,
2163 const struct ble_gap_conn_params *phy_1m_conn_params,
2164 const struct ble_gap_conn_params *phy_2m_conn_params,
2165 const struct ble_gap_conn_params *phy_coded_conn_params,
2166 ble_gap_event_fn *cb, void *cb_arg);
2167
2168#if MYNEWT_VAL(OPTIMIZE_MULTI_CONN)
2177int ble_gap_common_factor_set(bool enable, uint32_t common_factor);
2178
2202int ble_gap_multi_connect(struct ble_gap_multi_conn_params *multi_conn_params,
2203 ble_gap_event_fn *cb, void *cb_arg);
2204#endif
2205
2214int ble_gap_conn_cancel(void);
2215
2222int ble_gap_conn_active(void);
2223
2237int ble_gap_terminate(uint16_t conn_handle, uint8_t hci_reason);
2238
2247int ble_gap_wl_set(const ble_addr_t *addrs, uint8_t white_list_count);
2248
2267int ble_gap_update_params(uint16_t conn_handle,
2268 const struct ble_gap_upd_params *params);
2269
2284int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time);
2285
2299int ble_gap_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
2300 uint16_t *out_sugg_max_tx_time);
2301
2315int ble_gap_write_sugg_def_data_len(uint16_t sugg_max_tx_octets, uint16_t sugg_max_tx_time);
2316
2333int ble_gap_security_initiate(uint16_t conn_handle);
2334
2349int ble_gap_pair_initiate(uint16_t conn_handle);
2350
2371int ble_gap_encryption_initiate(uint16_t conn_handle, uint8_t key_size,
2372 const uint8_t *ltk, uint16_t ediv,
2373 uint64_t rand_val, int auth);
2374
2388int ble_gap_conn_rssi(uint16_t conn_handle, int8_t *out_rssi);
2389
2403int ble_gap_unpair(const ble_addr_t *peer_addr);
2404
2417
2430int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr);
2431
2432#define BLE_GAP_PRIVATE_MODE_NETWORK 0
2433#define BLE_GAP_PRIVATE_MODE_DEVICE 1
2434
2446int ble_gap_set_priv_mode(const ble_addr_t *peer_addr, uint8_t priv_mode);
2447
2448#define BLE_GAP_LE_PHY_1M 1
2449#define BLE_GAP_LE_PHY_2M 2
2450#define BLE_GAP_LE_PHY_CODED 3
2468int ble_gap_read_le_phy(uint16_t conn_handle, uint8_t *tx_phy, uint8_t *rx_phy);
2469
2470#define BLE_GAP_LE_PHY_1M_MASK 0x01
2471#define BLE_GAP_LE_PHY_2M_MASK 0x02
2472#define BLE_GAP_LE_PHY_CODED_MASK 0x04
2473#define BLE_GAP_LE_PHY_ANY_MASK 0x0F
2492int ble_gap_set_prefered_default_le_phy(uint8_t tx_phys_mask,
2493 uint8_t rx_phys_mask);
2494
2495#define BLE_GAP_LE_PHY_CODED_ANY 0
2496#define BLE_GAP_LE_PHY_CODED_S2 1
2497#define BLE_GAP_LE_PHY_CODED_S8 2
2521int ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
2522 uint8_t rx_phys_mask, uint16_t phy_opts);
2523
2524#if MYNEWT_VAL(BLE_CONN_SUBRATING)
2539int ble_gap_set_default_subrate(uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency,
2540 uint16_t cont_num, uint16_t supervision_timeout);
2541
2558int
2559ble_gap_subrate_req(uint16_t conn_handle, uint16_t subrate_min, uint16_t subrate_max,
2560 uint16_t max_latency, uint16_t cont_num,
2561 uint16_t supervision_timeout);
2562#endif
2569 ble_gap_event_fn *fn;
2570 void *arg;
2571 SLIST_ENTRY(ble_gap_event_listener) link;
2572};
2573
2590 ble_gap_event_fn *fn, void *arg);
2591
2601
2602#if MYNEWT_VAL(BLE_POWER_CONTROL)
2613int ble_gap_set_path_loss_reporting_enable(uint16_t conn_handle, uint8_t enable);
2614
2627int ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle,
2628 uint8_t local_enable,
2629 uint8_t remote_enable);
2630
2647int ble_gap_enh_read_transmit_power_level(uint16_t conn_handle, uint8_t phy,
2648 uint8_t *out_status, uint8_t *out_phy,
2649 uint8_t *out_curr_tx_power_level,
2650 uint8_t *out_max_tx_power_level);
2651
2660int ble_gap_read_remote_transmit_power_level(uint16_t conn_handle, uint8_t phy);
2661
2674int ble_gap_set_path_loss_reporting_param(uint16_t conn_handle, uint8_t high_threshold,
2675 uint8_t high_hysteresis, uint8_t low_threshold,
2676 uint8_t low_hysteresis, uint16_t min_time_spent);
2677#endif
2678
2687int ble_gap_set_data_related_addr_change_param(uint8_t adv_handle, uint8_t change_reason);
2688
2702int ble_gap_dtm_tx_start(uint8_t tx_chan, uint8_t test_data_len, uint8_t payload);
2703
2714int ble_gap_dtm_rx_start(uint8_t rx_chan);
2715
2722int ble_gap_dtm_stop(void);
2723
2737int ble_gap_dtm_enh_tx_start(uint8_t tx_chan, uint8_t test_data_len, uint8_t payload,
2738 uint8_t phy);
2739
2752int ble_gap_dtm_enh_rx_start(uint8_t rx_chan, uint8_t index, uint8_t phy);
2753
2754#ifdef __cplusplus
2755}
2756#endif
2757
2762#endif
int ble_gap_wl_set(const ble_addr_t *addrs, uint8_t white_list_count)
Definition ble_gap.c:2609
int ble_gap_write_sugg_def_data_len(uint16_t sugg_max_tx_octets, uint16_t sugg_max_tx_time)
Definition ble_gap.c:6693
int ble_gap_conn_find_by_addr(const ble_addr_t *addr, struct ble_gap_conn_desc *out_desc)
Definition ble_gap.c:565
int ble_gap_unpair_oldest_peer(void)
Definition ble_gap.c:6935
int ble_gap_conn_rssi(uint16_t conn_handle, int8_t *out_rssi)
Definition ble_gap.c:7107
int ble_gap_set_event_cb(uint16_t conn_handle, ble_gap_event_fn *cb, void *cb_arg)
Definition ble_gap.c:2475
int ble_gap_adv_rsp_set_data(const uint8_t *data, int data_len)
Definition ble_gap.c:3069
int ble_gap_set_prefered_default_le_phy(uint8_t tx_phys_mask, uint8_t rx_phys_mask)
Definition ble_gap.c:682
int ble_gap_disc_active(void)
Definition ble_gap.c:5403
int ble_gap_set_data_related_addr_change_param(uint8_t adv_handle, uint8_t change_reason)
Definition ble_gap.c:7833
int ble_gap_read_le_phy(uint16_t conn_handle, uint8_t *tx_phy, uint8_t *rx_phy)
Definition ble_gap.c:639
int ble_gap_adv_stop(void)
Definition ble_gap.c:2726
int ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms, const struct ble_gap_disc_params *disc_params, ble_gap_event_fn *cb, void *cb_arg)
Definition ble_gap.c:5287
int ble_gap_conn_active(void)
Definition ble_gap.c:6201
int ble_gap_adv_set_fields(const struct ble_hs_adv_fields *rsp_fields)
Definition ble_gap.c:3097
int ble_gap_dtm_enh_tx_start(uint8_t tx_chan, uint8_t test_data_len, uint8_t payload, uint8_t phy)
Definition ble_gap.c:7857
int ble_gap_disc_cancel(void)
Definition ble_gap.c:5057
int ble_gap_conn_cancel(void)
Definition ble_gap.c:6334
int ble_gap_dtm_stop(void)
Definition ble_gap.c:7851
int ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc)
int ble_gap_dtm_tx_start(uint8_t tx_chan, uint8_t test_data_len, uint8_t payload)
Definition ble_gap.c:7839
int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time)
Definition ble_gap.c:6683
int ble_gap_dtm_enh_rx_start(uint8_t rx_chan, uint8_t index, uint8_t phy)
Definition ble_gap.c:7864
int ble_gap_ext_disc(uint8_t own_addr_type, uint16_t duration, uint16_t period, uint8_t filter_duplicates, uint8_t filter_policy, uint8_t limited, const struct ble_gap_ext_disc_params *uncoded_params, const struct ble_gap_ext_disc_params *coded_params, ble_gap_event_fn *cb, void *cb_arg)
Definition ble_gap.c:5149
int ble_gap_adv_active(void)
Definition ble_gap.c:3152
int ble_gap_security_initiate(uint16_t conn_handle)
Definition ble_gap.c:6702
int ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr, int32_t duration_ms, uint8_t phy_mask, const struct ble_gap_conn_params *phy_1m_conn_params, const struct ble_gap_conn_params *phy_2m_conn_params, const struct ble_gap_conn_params *phy_coded_conn_params, ble_gap_event_fn *cb, void *cb_arg)
int ble_gap_encryption_initiate(uint16_t conn_handle, uint8_t key_size, const uint8_t *ltk, uint16_t ediv, uint64_t rand_val, int auth)
Definition ble_gap.c:6818
int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr)
Definition ble_gap.c:6968
int ble_gap_dtm_rx_start(uint8_t rx_chan)
Definition ble_gap.c:7845
int ble_gap_adv_rsp_set_fields(const struct ble_hs_adv_fields *rsp_fields)
Definition ble_gap.c:3128
int ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t tx_phys_mask, uint8_t rx_phys_mask, uint16_t phy_opts)
Definition ble_gap.c:726
int ble_gap_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr, int32_t duration_ms, const struct ble_gap_conn_params *params, ble_gap_event_fn *cb, void *cb_arg)
Definition ble_gap.c:5878
int ble_gap_unpair(const ble_addr_t *peer_addr)
Definition ble_gap.c:6851
int ble_gap_terminate(uint16_t conn_handle, uint8_t hci_reason)
Definition ble_gap.c:6248
int ble_gap_event_listener_unregister(struct ble_gap_event_listener *listener)
Definition ble_gap.c:7495
int ble_gap_pair_initiate(uint16_t conn_handle)
Definition ble_gap.c:6804
int ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr, int32_t duration_ms, const struct ble_gap_adv_params *adv_params, ble_gap_event_fn *cb, void *cb_arg)
Start advertising.
Definition ble_gap.c:2935
int ble_gap_adv_set_data(const uint8_t *data, int data_len)
Definition ble_gap.c:3039
int ble_gap_update_params(uint16_t conn_handle, const struct ble_gap_upd_params *params)
Definition ble_gap.c:6587
int ble_gap_set_priv_mode(const ble_addr_t *peer_addr, uint8_t priv_mode)
Definition ble_gap.c:625
int ble_gap_event_listener_register(struct ble_gap_event_listener *listener, ble_gap_event_fn *fn, void *arg)
Definition ble_gap.c:7465
int ble_gap_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets, uint16_t *out_sugg_max_tx_time)
Definition ble_gap.c:6688
Definition ble_gap.h:220
uint8_t channel_map
Definition ble_gap.h:239
uint8_t high_duty_cycle
Definition ble_gap.h:245
uint16_t itvl_min
Definition ble_gap.h:235
uint8_t disc_mode
Definition ble_gap.h:232
uint16_t itvl_max
Definition ble_gap.h:237
uint8_t conn_mode
Definition ble_gap.h:226
uint8_t filter_policy
Definition ble_gap.h:242
Connection descriptor.
Definition ble_gap.h:249
ble_addr_t peer_ota_addr
Definition ble_gap.h:263
uint8_t role
Definition ble_gap.h:280
struct ble_gap_sec_state sec_state
Definition ble_gap.h:251
uint16_t supervision_timeout
Definition ble_gap.h:275
uint16_t conn_latency
Definition ble_gap.h:272
ble_addr_t our_id_addr
Definition ble_gap.h:254
uint8_t master_clock_accuracy
Definition ble_gap.h:283
uint16_t conn_handle
Definition ble_gap.h:266
ble_addr_t our_ota_addr
Definition ble_gap.h:260
ble_addr_t peer_id_addr
Definition ble_gap.h:257
uint16_t conn_itvl
Definition ble_gap.h:269
Connection parameters
Definition ble_gap.h:287
uint16_t min_ce_len
Definition ble_gap.h:307
uint16_t latency
Definition ble_gap.h:301
uint16_t itvl_max
Definition ble_gap.h:298
uint16_t supervision_timeout
Definition ble_gap.h:304
uint16_t max_ce_len
Definition ble_gap.h:310
uint16_t itvl_min
Definition ble_gap.h:295
uint16_t scan_window
Definition ble_gap.h:292
uint16_t scan_itvl
Definition ble_gap.h:289
Advertising report.
Definition ble_gap.h:458
ble_addr_t direct_addr
Definition ble_gap.h:483
uint8_t event_type
Definition ble_gap.h:466
int8_t rssi
Definition ble_gap.h:475
ble_addr_t addr
Definition ble_gap.h:472
const uint8_t * data
Definition ble_gap.h:478
uint8_t length_data
Definition ble_gap.h:469
Discovery parameters.
Definition ble_gap.h:326
uint16_t itvl
Definition ble_gap.h:328
uint8_t filter_policy
Definition ble_gap.h:334
uint8_t limited
Definition ble_gap.h:337
uint16_t window
Definition ble_gap.h:331
uint8_t filter_duplicates
Definition ble_gap.h:343
uint8_t passive
Definition ble_gap.h:340
Definition ble_gap.h:2568
Definition ble_gap.h:510
struct ble_gap_event::@7::@17 passkey
struct os_mbuf * om
Definition ble_gap.h:736
const struct ble_gap_upd_params * peer_params
Definition ble_gap.h:660
struct ble_gap_event::@7::@26 data_len_chg
uint8_t cur_indicate
Definition ble_gap.h:820
uint16_t conn_handle
Definition ble_gap.h:537
struct ble_gap_event::@7::@15 term_failure
struct ble_gap_passkey_params params
Definition ble_gap.h:718
struct ble_gap_upd_params * self_params
Definition ble_gap.h:668
struct ble_gap_event::@7::@14 conn_update_req
uint8_t prev_notify
Definition ble_gap.h:811
struct ble_gap_event::@7::@18 notify_rx
struct ble_gap_conn_desc conn
Definition ble_gap.h:553
struct ble_gap_event::@7::@11 disc_complete
uint8_t cur_notify
Definition ble_gap.h:814
struct ble_gap_event::@7::@16 enc_change
struct ble_gap_event::@7::@21 mtu
struct ble_gap_disc_desc disc
Definition ble_gap.h:561
struct ble_gap_event::@7::@23 phy_updated
struct ble_gap_repeat_pairing repeat_pairing
Definition ble_gap.h:869
uint8_t prev_indicate
Definition ble_gap.h:817
uint16_t channel_id
Definition ble_gap.h:837
uint8_t tx_phy
Definition ble_gap.h:885
struct ble_gap_event::@7::@25 dtm_state
struct ble_gap_event::@7::@24 authorize
struct ble_gap_event::@7::@12 adv_complete
uint16_t attr_handle
Definition ble_gap.h:739
struct ble_gap_event::@7::@19 notify_tx
int reason
Definition ble_gap.h:550
struct ble_gap_event::@7::@13 conn_update
struct ble_gap_event::@7::@22 identity_resolved
uint8_t indication
Definition ble_gap.h:750
struct ble_gap_event::@7::@10 disconnect
uint8_t reason
Definition ble_gap.h:808
int status
Definition ble_gap.h:534
struct ble_gap_event::@7::@9 connect
uint8_t type
Definition ble_gap.h:515
struct ble_gap_event::@7::@20 subscribe
Extended discovery parameters.
Definition ble_gap.h:314
uint8_t passive
Definition ble_gap.h:322
uint16_t window
Definition ble_gap.h:319
uint16_t itvl
Definition ble_gap.h:316
Passkey query.
Definition ble_gap.h:368
uint32_t numcmp
Definition ble_gap.h:379
uint8_t action
Definition ble_gap.h:376
Definition ble_gap.h:202
unsigned bonded
Definition ble_gap.h:210
unsigned key_size
Definition ble_gap.h:213
unsigned authenticated
Definition ble_gap.h:207
unsigned encrypted
Definition ble_gap.h:204
unsigned authorize
Definition ble_gap.h:216
Connection parameters update parameters.
Definition ble_gap.h:347
uint16_t itvl_max
Definition ble_gap.h:352
uint16_t max_ce_len
Definition ble_gap.h:364
uint16_t min_ce_len
Definition ble_gap.h:361
uint16_t latency
Definition ble_gap.h:355
uint16_t itvl_min
Definition ble_gap.h:349
uint16_t supervision_timeout
Definition ble_gap.h:358
Definition os_mbuf.h:86