summaryrefslogtreecommitdiff
path: root/shared-bindings/bleio/Descriptor.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-11-20 23:04:58 -0500
committerDan Halbert <halbert@halwitz.org>2018-11-20 23:04:58 -0500
commit1763ffe2450fa07c74db225cc5ef3a6e2feb669b (patch)
tree0c6bf99479b1c135928aea9a9d475f01c84ce9d4 /shared-bindings/bleio/Descriptor.c
parentc424ad844b0241483d5968b7c4f158f61d498752 (diff)
More UUID work; use mp_raise for exceptions
Diffstat (limited to 'shared-bindings/bleio/Descriptor.c')
-rw-r--r--shared-bindings/bleio/Descriptor.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c
index df32a00e7..d58bbd275 100644
--- a/shared-bindings/bleio/Descriptor.c
+++ b/shared-bindings/bleio/Descriptor.c
@@ -61,7 +61,6 @@ enum {
//| .. class:: Descriptor(uuid)
//|
//| Create a new descriptor object with the UUID uuid.
-//| The value can be either of type `bleio.UUID` or any value allowed by the `bleio.UUID` constructor.
//| .. attribute:: handle
//|
@@ -90,13 +89,11 @@ STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_ar
const mp_obj_t uuid_arg = args[ARG_uuid].u_obj;
- bleio_uuid_obj_t *uuid;
- if (MP_OBJ_IS_TYPE(uuid_arg, &bleio_uuid_type)) {
- uuid = MP_OBJ_TO_PTR(uuid_arg);
- } else {
- uuid = MP_OBJ_TO_PTR(bleio_uuid_type.make_new(&bleio_uuid_type, 1, 0, &uuid_arg));
+ if (!MP_OBJ_IS_TYPE(uuid_arg, &bleio_uuid_type)) {
+ mp_raise_ValueError(translate("Expected a UUID"));
}
+ bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_arg);
common_hal_bleio_descriptor_construct(self, uuid);
return MP_OBJ_FROM_PTR(self);
@@ -104,7 +101,6 @@ STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_ar
STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
common_hal_bleio_descriptor_print(self, print);
}
@@ -124,9 +120,7 @@ const mp_obj_property_t bleio_descriptor_handle_obj = {
STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) {
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
- const mp_obj_t uuid = mp_obj_new_int(common_hal_bleio_descriptor_get_uuid(self));
-
- return bleio_uuid_type.make_new(&bleio_uuid_type, 1, 0, &uuid);
+ return common_hal_bleio_descriptor_get_uuid(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_uuid_obj, bleio_descriptor_get_uuid);