Skip to content

Commit 630c923

Browse files
committed
address review comments; avoid calling common_hal_bleio_device... routines from shared-bindings
1 parent af29fc3 commit 630c923

File tree

14 files changed

+74
-111
lines changed

14 files changed

+74
-111
lines changed

ports/nrf/common-hal/bleio/Attribute.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,31 @@
2929
// Convert a bleio security mode to a ble_gap_conn_sec_mode_t setting.
3030
void bleio_attribute_gatts_set_security_mode(ble_gap_conn_sec_mode_t *perm, bleio_attribute_security_mode_t security_mode) {
3131
switch (security_mode) {
32-
case SEC_MODE_NO_ACCESS:
32+
case SECURITY_MODE_NO_ACCESS:
3333
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(perm);
3434
break;
3535

36-
case SEC_MODE_OPEN:
36+
case SECURITY_MODE_OPEN:
3737
BLE_GAP_CONN_SEC_MODE_SET_OPEN(perm);
3838
break;
3939

40-
case SEC_MODE_ENC_NO_MITM:
40+
case SECURITY_MODE_ENC_NO_MITM:
4141
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(perm);
4242
break;
4343

44-
case SEC_MODE_ENC_WITH_MITM:
44+
case SECURITY_MODE_ENC_WITH_MITM:
4545
BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(perm);
4646
break;
4747

48-
case SEC_MODE_LESC_ENC_WITH_MITM:
48+
case SECURITY_MODE_LESC_ENC_WITH_MITM:
4949
BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(perm);
5050
break;
5151

52-
case SEC_MODE_SIGNED_NO_MITM:
52+
case SECURITY_MODE_SIGNED_NO_MITM:
5353
BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(perm);
5454
break;
5555

56-
case SEC_MODE_SIGNED_WITH_MITM:
56+
case SECURITY_MODE_SIGNED_WITH_MITM:
5757
BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(perm);
5858
break;
5959
}

ports/nrf/common-hal/bleio/Central.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#include "nrf_soc.h"
3535
#include "py/objstr.h"
3636
#include "py/runtime.h"
37+
#include "shared-bindings/bleio/__init__.h"
3738
#include "shared-bindings/bleio/Adapter.h"
3839
#include "shared-bindings/bleio/Central.h"
39-
#include "common-hal/bleio/__init__.h"
4040

4141
STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) {
4242
bleio_central_obj_t *central = (bleio_central_obj_t*)central_in;
@@ -131,6 +131,15 @@ bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self) {
131131
return self->conn_handle != BLE_CONN_HANDLE_INVALID;
132132
}
133133

134+
mp_obj_tuple_t *common_hal_bleio_central_discover_remote_services(bleio_central_obj_t *self, mp_obj_t service_uuids_whitelist) {
135+
common_hal_bleio_device_discover_remote_services(MP_OBJ_FROM_PTR(self), service_uuids_whitelist);
136+
// Convert to a tuple and then clear the list so the callee will take ownership.
137+
mp_obj_tuple_t *services_tuple = mp_obj_new_tuple(self->remote_services_list->len,
138+
self->remote_services_list->items);
139+
mp_obj_list_clear(self->remote_services_list);
140+
return services_tuple;
141+
}
142+
134143
mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) {
135144
return self->remote_services_list;
136145
}

ports/nrf/common-hal/bleio/Peripheral.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
#include "py/objlist.h"
3737
#include "py/objstr.h"
3838
#include "py/runtime.h"
39+
#include "shared-bindings/bleio/__init__.h"
3940
#include "shared-bindings/bleio/Adapter.h"
4041
#include "shared-bindings/bleio/Characteristic.h"
4142
#include "shared-bindings/bleio/Peripheral.h"
4243
#include "shared-bindings/bleio/Service.h"
4344
#include "shared-bindings/bleio/UUID.h"
44-
#include "common-hal/bleio/Service.h"
4545

4646
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
4747
#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(300, UNIT_0_625_MS)
@@ -303,8 +303,13 @@ void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *self) {
303303
sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
304304
}
305305

306-
mp_obj_list_t *common_hal_bleio_peripheral_get_remote_services(bleio_peripheral_obj_t *self) {
307-
return self->remote_services_list;
306+
mp_obj_tuple_t *common_hal_bleio_peripheral_discover_remote_services(bleio_peripheral_obj_t *self, mp_obj_t service_uuids_whitelist) {
307+
common_hal_bleio_device_discover_remote_services(MP_OBJ_FROM_PTR(self), service_uuids_whitelist);
308+
// Convert to a tuple and then clear the list so the callee will take ownership.
309+
mp_obj_tuple_t *services_tuple = mp_obj_new_tuple(self->remote_services_list->len,
310+
self->remote_services_list->items);
311+
mp_obj_list_clear(self->remote_services_list);
312+
return services_tuple;
308313
}
309314

310315
void common_hal_bleio_peripheral_pair(bleio_peripheral_obj_t *self) {

ports/nrf/common-hal/bleio/__init__.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, mp_ob
218218

219219
// Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler.
220220
common_hal_bleio_characteristic_construct(
221-
characteristic, uuid, props, SEC_MODE_OPEN, SEC_MODE_OPEN,
221+
characteristic, uuid, props, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN,
222222
GATT_MAX_DATA_LENGTH, false, // max_length, fixed_length: values may not matter for gattc
223223
mp_obj_new_list(0, NULL));
224224
characteristic->handle = gattc_char->handle_value;
@@ -274,7 +274,7 @@ STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, mp_ob
274274
// For now, just leave the UUID as NULL.
275275
}
276276

277-
common_hal_bleio_descriptor_construct(descriptor, uuid, SEC_MODE_OPEN, SEC_MODE_OPEN,
277+
common_hal_bleio_descriptor_construct(descriptor, uuid, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN,
278278
GATT_MAX_DATA_LENGTH, false);
279279
descriptor->handle = gattc_desc->handle;
280280
descriptor->characteristic = m_desc_discovery_characteristic;

shared-bindings/bleio/Attribute.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ STATIC const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = {
7676
//|
7777
//| security_mode: authenticated data signing, without man-in-the-middle protection
7878
//|
79-
{ MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SEC_MODE_NO_ACCESS) },
80-
{ MP_ROM_QSTR(MP_QSTR_OPEN), MP_ROM_INT(SEC_MODE_OPEN) },
81-
{ MP_ROM_QSTR(MP_QSTR_ENCRYPT_NO_MITM), MP_ROM_INT(SEC_MODE_ENC_NO_MITM) },
82-
{ MP_ROM_QSTR(MP_QSTR_ENCRYPT_WITH_MITM), MP_ROM_INT(SEC_MODE_ENC_WITH_MITM) },
83-
{ MP_ROM_QSTR(MP_QSTR_LESC_ENCRYPT_WITH_MITM), MP_ROM_INT(SEC_MODE_LESC_ENC_WITH_MITM) },
84-
{ MP_ROM_QSTR(MP_QSTR_SIGNED_NO_MITM), MP_ROM_INT(SEC_MODE_SIGNED_NO_MITM) },
85-
{ MP_ROM_QSTR(MP_QSTR_SIGNED_WITH_MITM), MP_ROM_INT(SEC_MODE_SIGNED_WITH_MITM) },
79+
{ MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SECURITY_MODE_NO_ACCESS) },
80+
{ MP_ROM_QSTR(MP_QSTR_OPEN), MP_ROM_INT(SECURITY_MODE_OPEN) },
81+
{ MP_ROM_QSTR(MP_QSTR_ENCRYPT_NO_MITM), MP_ROM_INT(SECURITY_MODE_ENC_NO_MITM) },
82+
{ MP_ROM_QSTR(MP_QSTR_ENCRYPT_WITH_MITM), MP_ROM_INT(SECURITY_MODE_ENC_WITH_MITM) },
83+
{ MP_ROM_QSTR(MP_QSTR_LESC_ENCRYPT_WITH_MITM), MP_ROM_INT(SECURITY_MODE_LESC_ENC_WITH_MITM) },
84+
{ MP_ROM_QSTR(MP_QSTR_SIGNED_NO_MITM), MP_ROM_INT(SECURITY_MODE_SIGNED_NO_MITM) },
85+
{ MP_ROM_QSTR(MP_QSTR_SIGNED_WITH_MITM), MP_ROM_INT(SECURITY_MODE_SIGNED_WITH_MITM) },
8686

8787
};
8888
STATIC MP_DEFINE_CONST_DICT(bleio_attribute_locals_dict, bleio_attribute_locals_dict_table);

shared-bindings/bleio/Central.c

+10-35
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "py/objproperty.h"
3535
#include "py/objstr.h"
3636
#include "py/runtime.h"
37-
#include "shared-bindings/bleio/__init__.h"
3837
#include "shared-bindings/bleio/Adapter.h"
3938
#include "shared-bindings/bleio/Address.h"
4039
#include "shared-bindings/bleio/Characteristic.h"
@@ -66,7 +65,7 @@
6665
//|
6766
//| central = bleio.Central()
6867
//| central.connect(my_entry.address, 10) # timeout after 10 seconds
69-
//| central.discover_remote_services()
68+
//| remote_services = central.discover_remote_services()
7069
//|
7170

7271
//| .. class:: Central()
@@ -132,15 +131,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_dis
132131

133132
//| .. method:: discover_remote_services(service_uuids_whitelist=None)
134133
//| Do BLE discovery for all services or for the given service UUIDS,
135-
//| to find their handles and characteristics.
136-
//| The attribute `remote_services` will contain a list of all discovered services.
137-
//| `Central.connected` must be True.
134+
//| to find their handles and characteristics, and return the discovered services.
135+
//| `Peripheral.connected` must be True.
138136
//|
139137
//| :param iterable service_uuids_whitelist: an iterable of :py:class:~`UUID` objects for the services
140138
//| provided by the peripheral that you want to use.
141-
//| The peripheral may provide more services, but services not listed are ignored.
142-
//| If a service in service_uuids_whitelist is not found during discovery, it will not
143-
//| appear in `remote_services`.
139+
//| The peripheral may provide more services, but services not listed are ignored
140+
//| and will not be returned.
144141
//|
145142
//| If service_uuids_whitelist is None, then all services will undergo discovery, which can be slow.
146143
//|
@@ -149,6 +146,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_dis
149146
//| service or characteristic to be discovered. Creating the UUID causes the UUID to be registered
150147
//| for use. (This restriction may be lifted in the future.)
151148
//|
149+
//| :return: A tuple of services provided by the remote peripheral.
150+
//|
152151
STATIC mp_obj_t bleio_central_discover_remote_services(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
153152
bleio_central_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
154153

@@ -164,10 +163,9 @@ STATIC mp_obj_t bleio_central_discover_remote_services(mp_uint_t n_args, const m
164163
mp_raise_ValueError(translate("Not connected"));
165164
}
166165

167-
common_hal_bleio_device_discover_remote_services(MP_OBJ_FROM_PTR(self),
168-
args[ARG_service_uuids_whitelist].u_obj);
169-
170-
return mp_const_none;
166+
return MP_OBJ_FROM_PTR(common_hal_bleio_central_discover_remote_services(
167+
MP_OBJ_FROM_PTR(self),
168+
args[ARG_service_uuids_whitelist].u_obj));
171169
}
172170
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_central_discover_remote_services_obj, 1, bleio_central_discover_remote_services);
173171

@@ -189,28 +187,6 @@ const mp_obj_property_t bleio_central_connected_obj = {
189187
(mp_obj_t)&mp_const_none_obj },
190188
};
191189

192-
193-
//| .. attribute:: remote_services (read-only)
194-
//|
195-
//| A tuple of services provided by the remote peripheral.
196-
//| If the Central is not connected, an empty tuple will be returned.
197-
//|
198-
STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) {
199-
bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
200-
201-
// Return list as a tuple so user won't be able to change it.
202-
mp_obj_list_t *service_list = common_hal_bleio_central_get_remote_services(self);
203-
return mp_obj_new_tuple(service_list->len, service_list->items);
204-
}
205-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services);
206-
207-
const mp_obj_property_t bleio_central_remote_services_obj = {
208-
.base.type = &mp_type_property,
209-
.proxy = { (mp_obj_t)&bleio_central_get_remote_services_obj,
210-
(mp_obj_t)&mp_const_none_obj,
211-
(mp_obj_t)&mp_const_none_obj },
212-
};
213-
214190
STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = {
215191
// Methods
216192
{ MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_central_connect_obj) },
@@ -219,7 +195,6 @@ STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = {
219195

220196
// Properties
221197
{ MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_central_connected_obj) },
222-
{ MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) },
223198
};
224199

225200
STATIC MP_DEFINE_CONST_DICT(bleio_central_locals_dict, bleio_central_locals_dict_table);

shared-bindings/bleio/Central.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H
2929
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H
3030

31+
#include "py/objtuple.h"
3132
#include "common-hal/bleio/Central.h"
3233
#include "common-hal/bleio/Service.h"
3334

@@ -37,6 +38,6 @@ extern void common_hal_bleio_central_construct(bleio_central_obj_t *self);
3738
extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout);
3839
extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self);
3940
extern bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self);
40-
extern mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self);
41+
extern mp_obj_tuple_t *common_hal_bleio_central_discover_remote_services(bleio_central_obj_t *self, mp_obj_t service_uuids_whitelist);
4142

4243
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H

shared-bindings/bleio/Characteristic.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
6767
static const mp_arg_t allowed_args[] = {
6868
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
6969
{ MP_QSTR_properties, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 0} },
70-
{ MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SEC_MODE_OPEN} },
71-
{ MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SEC_MODE_OPEN} },
70+
{ MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} },
71+
{ MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} },
7272
{ MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} },
7373
{ MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
7474
{ MP_QSTR_descriptors, MP_ARG_KW_ONLY| MP_ARG_OBJ, {.u_obj = mp_const_none} },

shared-bindings/bleio/Descriptor.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_ar
6262
enum { ARG_uuid, ARG_read_perm, ARG_write_perm, ARG_max_length, ARG_fixed_length };
6363
static const mp_arg_t allowed_args[] = {
6464
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ },
65-
{ MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SEC_MODE_OPEN } },
66-
{ MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SEC_MODE_OPEN } },
65+
{ MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN } },
66+
{ MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN } },
6767
{ MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} },
6868
{ MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
6969
};

shared-bindings/bleio/Peripheral.c

+8-33
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "py/objstr.h"
3636
#include "py/runtime.h"
3737

38-
#include "shared-bindings/bleio/__init__.h"
3938
#include "shared-bindings/bleio/Adapter.h"
4039
#include "shared-bindings/bleio/Characteristic.h"
4140
#include "shared-bindings/bleio/Peripheral.h"
@@ -263,15 +262,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_disconnect_obj, bleio_peripher
263262

264263
//| .. method:: discover_remote_services(service_uuids_whitelist=None)
265264
//| Do BLE discovery for all services or for the given service UUIDS,
266-
//| to find their handles and characteristics.
267-
//| The attribute `remote_services` will contain a list of all discovered services.
265+
//| to find their handles and characteristics, and return the discovered services.
268266
//| `Peripheral.connected` must be True.
269267
//|
270268
//| :param iterable service_uuids_whitelist: an iterable of :py:class:~`UUID` objects for the services
271269
//| provided by the peripheral that you want to use.
272-
//| The peripheral may provide more services, but services not listed are ignored.
273-
//| If a service in service_uuids_whitelist is not found during discovery, it will not
274-
//| appear in `remote_services`.
270+
//| The peripheral may provide more services, but services not listed are ignored
271+
//| and will not be returned.
275272
//|
276273
//| If service_uuids_whitelist is None, then all services will undergo discovery, which can be slow.
277274
//|
@@ -285,6 +282,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_disconnect_obj, bleio_peripher
285282
//| Examples include a peripheral accessing a central that provides Current Time Service,
286283
//| Apple Notification Center Service, or Battery Service.
287284
//|
285+
//| :return: A tuple of services provided by the remote central.
286+
//|
288287
STATIC mp_obj_t bleio_peripheral_discover_remote_services(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
289288
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
290289

@@ -300,27 +299,12 @@ STATIC mp_obj_t bleio_peripheral_discover_remote_services(mp_uint_t n_args, cons
300299
mp_raise_ValueError(translate("Not connected"));
301300
}
302301

303-
common_hal_bleio_device_discover_remote_services(MP_OBJ_FROM_PTR(self),
304-
args[ARG_service_uuids_whitelist].u_obj);
305-
306-
return mp_const_none;
302+
return MP_OBJ_FROM_PTR(common_hal_bleio_peripheral_discover_remote_services(
303+
MP_OBJ_FROM_PTR(self),
304+
args[ARG_service_uuids_whitelist].u_obj));
307305
}
308306
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_discover_remote_services_obj, 1, bleio_peripheral_discover_remote_services);
309307

310-
//| .. attribute:: remote_services (read-only)
311-
//|
312-
//| A tuple of services provided by the remote central.
313-
//| If discovery did not occur, an empty tuple will be returned.
314-
//|
315-
STATIC mp_obj_t bleio_peripheral_get_remote_services(mp_obj_t self_in) {
316-
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
317-
318-
// Return list as a tuple so user won't be able to change it.
319-
mp_obj_list_t *service_list = common_hal_bleio_peripheral_get_remote_services(self);
320-
return mp_obj_new_tuple(service_list->len, service_list->items);
321-
}
322-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_remote_services_obj, bleio_peripheral_get_remote_services);
323-
324308
//| .. method:: pair()
325309
//|
326310
//| Request pairing with connected central.
@@ -333,14 +317,6 @@ STATIC mp_obj_t bleio_peripheral_pair(mp_obj_t self_in) {
333317
}
334318
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_pair_obj, bleio_peripheral_pair);
335319

336-
const mp_obj_property_t bleio_peripheral_remote_services_obj = {
337-
.base.type = &mp_type_property,
338-
.proxy = { (mp_obj_t)&bleio_peripheral_get_remote_services_obj,
339-
(mp_obj_t)&mp_const_none_obj,
340-
(mp_obj_t)&mp_const_none_obj },
341-
};
342-
343-
344320
STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = {
345321
// Methods
346322
{ MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_peripheral_start_advertising_obj) },
@@ -352,7 +328,6 @@ STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = {
352328
// Properties
353329
{ MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_peripheral_connected_obj) },
354330
{ MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_peripheral_name_obj) },
355-
{ MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_peripheral_remote_services_obj) },
356331
{ MP_ROM_QSTR(MP_QSTR_services), MP_ROM_PTR(&bleio_peripheral_services_obj) },
357332
};
358333

shared-bindings/bleio/Peripheral.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H
2929
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H
3030

31+
#include "py/objtuple.h"
3132
#include "common-hal/bleio/Peripheral.h"
3233

3334
extern const mp_obj_type_t bleio_peripheral_type;
@@ -39,7 +40,7 @@ extern mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *sel
3940
extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, float interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo);
4041
extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device);
4142
extern void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *device);
42-
extern mp_obj_list_t *common_hal_bleio_peripheral_get_remote_services(bleio_peripheral_obj_t *self);
43+
extern mp_obj_tuple_t *common_hal_bleio_peripheral_discover_remote_services(bleio_peripheral_obj_t *self, mp_obj_t service_uuids_whitelist);
4344
extern void common_hal_bleio_peripheral_pair(bleio_peripheral_obj_t *device);
4445

4546
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H

shared-bindings/bleio/__init__.c

-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
9494

9595
// Properties
9696
{ MP_ROM_QSTR(MP_QSTR_adapter), MP_ROM_PTR(&common_hal_bleio_adapter_obj) },
97-
98-
// constants
99-
{ MP_ROM_QSTR(MP_QSTR_SEC), MP_ROM_PTR(&bleio_uuid_type) },
10097
};
10198

10299
STATIC MP_DEFINE_CONST_DICT(bleio_module_globals, bleio_module_globals_table);

0 commit comments

Comments
 (0)