summaryrefslogtreecommitdiff
path: root/shared-bindings/bleio/Service.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-06-29 00:20:06 -0400
committerDan Halbert <halbert@halwitz.org>2019-06-29 00:20:06 -0400
commit6ea01ea9b0334a175419f9d449be25a5838627da (patch)
treeca91eaa919c301696f1543f336dcaa6c26505345 /shared-bindings/bleio/Service.c
parent140904ec84ad1900f280c1febaa89a499c42b8c5 (diff)
Central is connecting; characteristics can be read and written
Diffstat (limited to 'shared-bindings/bleio/Service.c')
-rw-r--r--shared-bindings/bleio/Service.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c
index e687019d1..e6bb7dcc3 100644
--- a/shared-bindings/bleio/Service.c
+++ b/shared-bindings/bleio/Service.c
@@ -140,11 +140,13 @@ const mp_obj_property_t bleio_service_secondary_obj = {
//| .. attribute:: uuid
//|
//| The UUID of this service. (read-only)
+//| Will be ``None`` if the 128-bit UUID for this service is not known.
//|
STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return MP_OBJ_FROM_PTR(common_hal_bleio_service_get_uuid(self));
+ bleio_uuid_obj_t *uuid = common_hal_bleio_service_get_uuid(self);
+ return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_uuid_obj, bleio_service_get_uuid);
@@ -160,12 +162,23 @@ STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_secondary), MP_ROM_PTR(&bleio_service_secondary_obj) },
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_service_uuid_obj) },
};
-
STATIC MP_DEFINE_CONST_DICT(bleio_service_locals_dict, bleio_service_locals_dict_table);
+STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ mp_printf(print, "Service(");
+ if (self->uuid) {
+ bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind);
+ } else {
+ mp_printf(print, "unregistered UUID");
+ }
+ mp_printf(print, ")");
+}
+
const mp_obj_type_t bleio_service_type = {
{ &mp_type_type },
.name = MP_QSTR_Service,
.make_new = bleio_service_make_new,
+ .print = bleio_service_print,
.locals_dict = (mp_obj_dict_t*)&bleio_service_locals_dict
};