summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-07-07 00:07:47 -0400
committerDan Halbert <halbert@halwitz.org>2019-07-07 00:07:47 -0400
commit09ddff8df1349c590e6c0533b6f5085fbcb92483 (patch)
tree0d7e167b231f892937eaead1390a2fcaee65b6ce /shared-bindings
parentbf8a35b2f835fbc97d54867f8e21b486a46c245b (diff)
WIP: Need descriptors for Central CCCD discovery; not done yet
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/bleio/Central.c4
-rw-r--r--shared-bindings/bleio/Central.h2
-rw-r--r--shared-bindings/bleio/Descriptor.c3
-rw-r--r--shared-bindings/bleio/Peripheral.c16
-rw-r--r--shared-bindings/bleio/Peripheral.h1
5 files changed, 19 insertions, 7 deletions
diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c
index efadcbb2a..95ba19dd0 100644
--- a/shared-bindings/bleio/Central.c
+++ b/shared-bindings/bleio/Central.c
@@ -79,8 +79,6 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(self);
}
-
-
//| .. method:: connect(address, timeout, *, service_uuids=None)
//| Attempts a connection to the remote peripheral. If the connection is successful,
//| Do BLE discovery for the listed services, to find their handles and characteristics.
@@ -167,7 +165,7 @@ const mp_obj_property_t bleio_central_connected_obj = {
STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) {
bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return common_hal_bleio_central_get_remote_services(self);
+ return MP_OBJ_FROM_PTR(common_hal_bleio_central_get_remote_services(self));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services);
diff --git a/shared-bindings/bleio/Central.h b/shared-bindings/bleio/Central.h
index 2ca423945..0e84037f9 100644
--- a/shared-bindings/bleio/Central.h
+++ b/shared-bindings/bleio/Central.h
@@ -37,6 +37,6 @@ extern void common_hal_bleio_central_construct(bleio_central_obj_t *self);
extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids);
extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self);
extern bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self);
-extern mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self);
+extern mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H
diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c
index 9e051c89e..723352ea1 100644
--- a/shared-bindings/bleio/Descriptor.c
+++ b/shared-bindings/bleio/Descriptor.c
@@ -49,9 +49,6 @@ enum {
DescriptorUuidTimeTriggerSetting = 0x290E,
};
-// Work-in-progress: orphaned for now.
-//| :orphan:
-//|
//| .. currentmodule:: bleio
//|
//| :class:`Descriptor` -- BLE descriptor
diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c
index 665f5baaf..320d83471 100644
--- a/shared-bindings/bleio/Peripheral.c
+++ b/shared-bindings/bleio/Peripheral.c
@@ -250,10 +250,26 @@ STATIC mp_obj_t bleio_peripheral_stop_advertising(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_stop_advertising_obj, bleio_peripheral_stop_advertising);
+//| .. method:: disconnect()
+//|
+//| Disconnects from the remote central.
+//| Normally the central initiates a disconnection. Use this only
+//| if necessary for your application.
+//|
+STATIC mp_obj_t bleio_peripheral_disconnect(mp_obj_t self_in) {
+ bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ common_hal_bleio_peripheral_disconnect(self);
+
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_disconnect_obj, bleio_peripheral_disconnect);
+
STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_peripheral_start_advertising_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_peripheral_stop_advertising_obj) },
+ { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_peripheral_disconnect_obj) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_peripheral_connected_obj) },
diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h
index 16438bba6..846250a5f 100644
--- a/shared-bindings/bleio/Peripheral.h
+++ b/shared-bindings/bleio/Peripheral.h
@@ -38,5 +38,6 @@ extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *se
extern mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self);
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);
extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device);
+extern void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *device);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H