Skip to content

Commit ba7a956

Browse files
Deomid Ryabkovcesantabot
authored andcommitted
More BT-related work
PUBLISHED_FROM=ab9fe8ca10e8bbaed6ec95e8acda17b90d0f8a0a
1 parent 2091051 commit ba7a956

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

include/esp32/esp32_bt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ void mgos_bt_ble_set_scan_rsp_data(const struct mg_str scan_rsp_data);
7676
bool mgos_bt_gap_get_adv_enable(void);
7777
bool mgos_bt_gap_set_adv_enable(bool adv_enable);
7878

79+
int mgos_bt_ble_get_num_paired_devices(void);
80+
7981
#ifdef __cplusplus
8082
}
8183
#endif

include/esp32/esp32_bt_gatts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ bool mgos_bt_gatts_register_service(const esp_gatts_attr_db_t *svc_descr,
3434
size_t num_attrs,
3535
mgos_bt_gatts_handler_t cb);
3636

37+
int mgos_bt_gatts_get_num_connections(void);
38+
3739
#ifdef __cplusplus
3840
}
3941
#endif

src/esp32/esp32_bt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ static void mgos_bt_net_ev(enum mgos_net_event ev,
163163
(void) arg;
164164
}
165165

166+
int mgos_bt_ble_get_num_paired_devices(void) {
167+
return esp_ble_get_bond_device_num();
168+
}
169+
166170
bool mgos_bt_common_init(void) {
167171
bool ret = false;
168172
if (!mgos_sys_config_get_bt_enable()) {
@@ -219,7 +223,8 @@ bool mgos_bt_common_init(void) {
219223
mgos_net_add_event_handler(mgos_bt_net_ev, NULL);
220224
}
221225

222-
LOG(LL_INFO, ("Bluetooth init ok"));
226+
LOG(LL_INFO, ("Bluetooth init ok, %d paired devices",
227+
mgos_bt_ble_get_num_paired_devices()));
223228
ret = true;
224229

225230
out:

src/esp32/esp32_bt_gatts.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,13 @@ bool mgos_bt_gatts_register_service(const esp_gatts_attr_db_t *svc_descr,
625625
return true;
626626
}
627627

628+
int mgos_bt_gatts_get_num_connections(void) {
629+
int num = 0;
630+
struct esp32_gatts_connection_entry *ce;
631+
SLIST_FOREACH(ce, &s_conns, next) num++;
632+
return num;
633+
}
634+
628635
bool esp32_bt_gatts_init(void) {
629636
return (esp_ble_gatts_register_callback(esp32_bt_gatts_ev) == ESP_OK &&
630637
esp_ble_gatts_app_register(0) == ESP_OK);

0 commit comments

Comments
 (0)