summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorarturo182 <arturo182@tlen.pl>2018-07-16 14:44:20 +0200
committerarturo182 <arturo182@tlen.pl>2018-10-21 15:43:08 +0200
commitf4940c9aec2ac73086efe18fbc57151f55c85981 (patch)
tree633bbd5f1c054760b409e6638a9c8c0296ab9a49 /shared-bindings
parentb436666e852b0d75a970052997ea019af7411b45 (diff)
nrf: Move the UUID class from ubluepy to the shared bleio module
Also added a UUIDType enum-like class for determining UUID type.
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/bleio/UUID.c208
-rw-r--r--shared-bindings/bleio/UUID.h39
-rw-r--r--shared-bindings/bleio/UUIDType.c75
-rw-r--r--shared-bindings/bleio/UUIDType.h46
-rw-r--r--shared-bindings/bleio/__init__.c14
5 files changed, 380 insertions, 2 deletions
diff --git a/shared-bindings/bleio/UUID.c b/shared-bindings/bleio/UUID.c
new file mode 100644
index 000000000..0523e918f
--- /dev/null
+++ b/shared-bindings/bleio/UUID.c
@@ -0,0 +1,208 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "shared-bindings/bleio/UUID.h"
+
+enum {
+ ServiceUuidGenericAccess = 0x1800,
+ ServiceUuidGenericAttribute = 0x1801,
+ ServiceUuidImmediateAlert = 0x1802,
+ ServiceUuidLinkLoss = 0x1803,
+ ServiceUuidTxPower = 0x1804,
+ ServiceUuidCurrentTimeServiceService = 0x1805,
+ ServiceUuidReferenceTimeUpdateService = 0x1806,
+ ServiceUuidNextDSTChangeService = 0x1807,
+ ServiceUuidGlucose = 0x1808,
+ ServiceUuidHealthThermometer = 0x1809,
+ ServiceUuidDeviceInformation = 0x180A,
+ ServiceUuidHeartRate = 0x180D,
+ ServiceUuidPhoneAlertStatusService = 0x180E,
+ ServiceUuidBatteryService = 0x180F,
+ ServiceUuidBloodPressure = 0x1810,
+ ServiceUuidAlertNotificationService = 0x1811,
+ ServiceUuidHumanInterfaceDevice = 0x1812,
+ ServiceUuidScanParameters = 0x1813,
+ ServiceUuidRunningSpeedAndCadence = 0x1814,
+ ServiceUuidAutomationIO = 0x1815,
+ ServiceUuidCyclingSpeedAndCadence = 0x1816,
+ ServiceUuidCyclingPower = 0x1818,
+ ServiceUuidLocationAndNavigation = 0x1819,
+ ServiceUuidEnvironmentalSensing = 0x181A,
+ ServiceUuidBodyComposition = 0x181B,
+ ServiceUuidUserData = 0x181C,
+ ServiceUuidWeightScale = 0x181D,
+ ServiceUuidBondManagementService = 0x181E,
+ ServiceUuidContinuousGlucoseMonitoring = 0x181F,
+ ServiceUuidInternetProtocolSupportService = 0x1820,
+ ServiceUuidIndoorPositioning = 0x1821,
+ ServiceUuidPulseOximeterService = 0x1822,
+ ServiceUuidHTTPProxy = 0x1823,
+ ServiceUuidTransportDiscovery = 0x1824,
+ ServiceUuidObjectTransferService = 0x1825,
+ ServiceUuidFitnessMachine = 0x1826,
+ ServiceUuidMeshProvisioningService = 0x1827,
+ ServiceUuidMeshProxyService = 0x1828,
+ ServiceUuidReconnectionConfiguration = 0x1829,
+};
+
+//| .. currentmodule:: bleio
+//|
+//| :class:`UUID` -- BLE UUID
+//| =========================================================
+//|
+//| Encapsulates both 16-bit and 128-bit UUIDs. Can be used for services,
+//| characteristics, descriptors and more.
+//|
+
+//| .. class:: UUID(uuid)
+//|
+//| Create a new UUID object encapsulating the uuid value.
+//| The value itself can be one of:
+//|
+//| - a `int` value in range of 0 to 0xFFFF
+//| - a `str` value in the format of '0xXXXX' for 16-bit or 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' for 128-bit
+//| - another UUID object
+//|
+//| :param uuid: The uuid to encapsulate
+//|
+
+//| .. attribute:: type
+//|
+//| The UUID type. One of:
+//|
+//| - `bleio.UUIDType.TYPE_16BIT`
+//| - `bleio.UUIDType.TYPE_128BIT`
+//|
+STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
+ mp_arg_check_num(n_args, n_kw, 1, 1, true);
+ bleio_uuid_obj_t *self = m_new_obj(bleio_uuid_obj_t);
+ self->base.type = &bleio_uuid_type;
+
+ mp_map_t kw_args;
+ mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
+
+ enum { ARG_uuid };
+ static const mp_arg_t allowed_args[] = {
+ { ARG_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
+ };
+
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ const mp_obj_t uuid = args[ARG_uuid].u_obj;
+
+ common_hal_bleio_uuid_construct(self, &uuid);
+
+ return MP_OBJ_FROM_PTR(self);
+}
+
+STATIC void bleio_uuid_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ common_hal_bleio_uuid_print(self, print);
+}
+
+STATIC mp_obj_t bleio_uuid_get_type(mp_obj_t self_in) {
+ bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ const bleio_uuid_type_t type = common_hal_bleio_uuid_get_type(self);
+ if (type == UUID_TYPE_16BIT) {
+ return (mp_obj_t)&bleio_uuidtype_16bit_obj;
+ }
+
+ if (type == UUID_TYPE_128BIT) {
+ return (mp_obj_t)&bleio_uuidtype_128bit_obj;
+ }
+
+ return (mp_obj_t)&mp_const_none_obj;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(bleio_uuid_get_type_obj, bleio_uuid_get_type);
+
+const mp_obj_property_t bleio_uuid_type_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&bleio_uuid_get_type_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+STATIC const mp_rom_map_elem_t bleio_uuid_locals_dict_table[] = {
+ // Properties
+ { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_uuid_type_obj) },
+
+ // Static variables
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_GENERIC_ACCESS), MP_ROM_INT(ServiceUuidGenericAccess) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_GENERIC_ATTRIBUTE), MP_ROM_INT(ServiceUuidGenericAttribute) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_IMMEDIATE_ALERT), MP_ROM_INT(ServiceUuidImmediateAlert) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_LINK_LOSS), MP_ROM_INT(ServiceUuidLinkLoss) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_TX_POWER), MP_ROM_INT(ServiceUuidTxPower) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_CURRENT_TIME_SERVICE), MP_ROM_INT(ServiceUuidCurrentTimeServiceService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_REFERENCE_TIME_UPDATE_SERVICE), MP_ROM_INT(ServiceUuidReferenceTimeUpdateService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_NEXT_DST_CHANGE_SERVICE), MP_ROM_INT(ServiceUuidNextDSTChangeService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_GLUCOSE), MP_ROM_INT(ServiceUuidGlucose) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_HEALTH_THERMOMETER), MP_ROM_INT(ServiceUuidHealthThermometer) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_DEVICE_INFORMATION), MP_ROM_INT(ServiceUuidDeviceInformation) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_HEART_RATE), MP_ROM_INT(ServiceUuidHeartRate) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_PHONE_ALERT_STATUS_SERVICE), MP_ROM_INT(ServiceUuidPhoneAlertStatusService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_BATTERY_SERVICE), MP_ROM_INT(ServiceUuidBatteryService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_BLOOD_PRESSURE), MP_ROM_INT(ServiceUuidBloodPressure) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_ALERT_NOTIFICATION_SERVICE), MP_ROM_INT(ServiceUuidAlertNotificationService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_HUMAN_INTERFACE_DEVICE), MP_ROM_INT(ServiceUuidHumanInterfaceDevice) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_SCAN_PARAMETERS), MP_ROM_INT(ServiceUuidScanParameters) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_RUNNING_SPEED_AND_CADENCE), MP_ROM_INT(ServiceUuidRunningSpeedAndCadence) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_AUTOMATION_IO), MP_ROM_INT(ServiceUuidAutomationIO) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_CYCLING_SPEED_AND_CADENCE), MP_ROM_INT(ServiceUuidCyclingSpeedAndCadence) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_CYCLING_POWER), MP_ROM_INT(ServiceUuidCyclingPower) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_LOCATION_AND_NAVIGATION), MP_ROM_INT(ServiceUuidLocationAndNavigation) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_ENVIRONMENTAL_SENSING), MP_ROM_INT(ServiceUuidEnvironmentalSensing) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_BODY_COMPOSITION), MP_ROM_INT(ServiceUuidBodyComposition) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_USER_DATA), MP_ROM_INT(ServiceUuidUserData) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_WEIGHT_SCALE), MP_ROM_INT(ServiceUuidWeightScale) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_BOND_MANAGEMENT_SERVICE), MP_ROM_INT(ServiceUuidBondManagementService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_CONTINUOUS_GLUCOSE_MONITORING), MP_ROM_INT(ServiceUuidContinuousGlucoseMonitoring) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_INTERNET_PROTOCOL_SUPPORT_SERVICE), MP_ROM_INT(ServiceUuidInternetProtocolSupportService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_INDOOR_POSITIONING), MP_ROM_INT(ServiceUuidIndoorPositioning) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_PULSE_OXIMETER_SERVICE), MP_ROM_INT(ServiceUuidPulseOximeterService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_HTTP_PROXY), MP_ROM_INT(ServiceUuidHTTPProxy) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_TRANSPORT_DISCOVERY), MP_ROM_INT(ServiceUuidTransportDiscovery) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_OBJECT_TRANSFER_SERVICE), MP_ROM_INT(ServiceUuidObjectTransferService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_FITNESS_MACHINE), MP_ROM_INT(ServiceUuidFitnessMachine) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_MESH_PROVISIONING_SERVICE), MP_ROM_INT(ServiceUuidMeshProvisioningService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_MESH_PROXY_SERVICE), MP_ROM_INT(ServiceUuidMeshProxyService) },
+ { MP_ROM_QSTR(MP_QSTR_SERVICE_RECONNECTION_CONFIGURATION), MP_ROM_INT(ServiceUuidReconnectionConfiguration) }
+};
+
+STATIC MP_DEFINE_CONST_DICT(bleio_uuid_locals_dict, bleio_uuid_locals_dict_table);
+
+const mp_obj_type_t bleio_uuid_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_UUID,
+ .print = bleio_uuid_print,
+ .make_new = bleio_uuid_make_new,
+ .locals_dict = (mp_obj_dict_t*)&bleio_uuid_locals_dict
+};
diff --git a/shared-bindings/bleio/UUID.h b/shared-bindings/bleio/UUID.h
new file mode 100644
index 000000000..d6fcbac1b
--- /dev/null
+++ b/shared-bindings/bleio/UUID.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUID_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUID_H
+
+#include "common-hal/bleio/UUID.h"
+#include "shared-bindings/bleio/UUIDType.h"
+
+extern const mp_obj_type_t bleio_uuid_type;
+
+extern void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, const mp_obj_t *uuid);
+extern void common_hal_bleio_uuid_print(bleio_uuid_obj_t *self, const mp_print_t *print);
+extern bleio_uuid_type_t common_hal_bleio_uuid_get_type(bleio_uuid_obj_t *self);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUID_H
diff --git a/shared-bindings/bleio/UUIDType.c b/shared-bindings/bleio/UUIDType.c
new file mode 100644
index 000000000..e36d1f06d
--- /dev/null
+++ b/shared-bindings/bleio/UUIDType.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/bleio/UUIDType.h"
+
+//| .. currentmodule:: bleio
+//|
+//| :class:`UUIDType` -- defines the type of a BLE UUID
+//| =============================================================
+//|
+//| .. class:: bleio.UUIDType
+//|
+//| Enum-like class to define the type of a BLE UUID.
+//|
+//| .. data:: TYPE_16BIT
+//|
+//| The UUID is 16-bit
+//|
+//| .. data:: TYPE_128BIT
+//|
+//| The UUID is 128-bit
+//|
+const mp_obj_type_t bleio_uuidtype_type;
+
+const bleio_uuidtype_obj_t bleio_uuidtype_16bit_obj = {
+ { &bleio_uuidtype_type },
+};
+
+const bleio_uuidtype_obj_t bleio_uuidtype_128bit_obj = {
+ { &bleio_uuidtype_type },
+};
+
+STATIC const mp_rom_map_elem_t bleio_uuidtype_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_TYPE_16BIT), MP_ROM_PTR(&bleio_uuidtype_16bit_obj) },
+ { MP_ROM_QSTR(MP_QSTR_TYPE_128BIT), MP_ROM_PTR(&bleio_uuidtype_128bit_obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(bleio_uuidtype_locals_dict, bleio_uuidtype_locals_dict_table);
+
+STATIC void bleio_uuidtype_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ qstr type = MP_QSTR_TYPE_128BIT;
+ if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&bleio_uuidtype_16bit_obj)) {
+ type = MP_QSTR_TYPE_16BIT;
+ }
+ mp_printf(print, "%q.%q.%q", MP_QSTR_bleio, MP_QSTR_UUIDType, type);
+}
+
+const mp_obj_type_t bleio_uuidtype_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_UUIDType,
+ .print = bleio_uuidtype_print,
+ .locals_dict = (mp_obj_t)&bleio_uuidtype_locals_dict,
+};
diff --git a/shared-bindings/bleio/UUIDType.h b/shared-bindings/bleio/UUIDType.h
new file mode 100644
index 000000000..87bbf9b53
--- /dev/null
+++ b/shared-bindings/bleio/UUIDType.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUIDTYPE_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUIDTYPE_H
+
+#include "py/obj.h"
+
+typedef enum {
+ UUID_TYPE_16BIT,
+ UUID_TYPE_128BIT
+} bleio_uuid_type_t;
+
+extern const mp_obj_type_t bleio_uuidtype_type;
+
+typedef struct {
+ mp_obj_base_t base;
+} bleio_uuidtype_obj_t;
+
+extern const bleio_uuidtype_obj_t bleio_uuidtype_16bit_obj;
+extern const bleio_uuidtype_obj_t bleio_uuidtype_128bit_obj;
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUIDTYPE_H
diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c
index 475fb395a..f59f1654b 100644
--- a/shared-bindings/bleio/__init__.c
+++ b/shared-bindings/bleio/__init__.c
@@ -27,6 +27,8 @@
#include "py/obj.h"
#include "shared-bindings/bleio/__init__.h"
+#include "shared-bindings/bleio/UUID.h"
+#include "shared-bindings/bleio/UUIDType.h"
//| :mod:`bleio` --- Bluetooth Low Energy functionality
//| ================================================================
@@ -43,6 +45,8 @@
//| :maxdepth: 3
//|
//| Adapter
+//| UUID
+//| UUIDType
//|
//| .. attribute:: adapter
//|
@@ -52,8 +56,14 @@
//|
STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) },
- { MP_ROM_QSTR(MP_QSTR_adapter), MP_ROM_PTR(&common_hal_bleio_adapter_obj) },
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) },
+ { MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) },
+
+ // Properties
+ { MP_ROM_QSTR(MP_QSTR_adapter), MP_ROM_PTR(&common_hal_bleio_adapter_obj) },
+
+ // Enum-like Classes.
+ { MP_ROM_QSTR(MP_QSTR_UUIDType), MP_ROM_PTR(&bleio_uuidtype_type) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_module_globals, bleio_module_globals_table);