nrf: Move the UUID class from ubluepy to the shared bleio module
Also added a UUIDType enum-like class for determining UUID type.
This commit is contained in:
parent
b436666e85
commit
f4940c9aec
@ -132,7 +132,6 @@ DRIVERS_SRC_C += $(addprefix modules/,\
|
|||||||
ubluepy/ubluepy_peripheral.c \
|
ubluepy/ubluepy_peripheral.c \
|
||||||
ubluepy/ubluepy_service.c \
|
ubluepy/ubluepy_service.c \
|
||||||
ubluepy/ubluepy_characteristic.c \
|
ubluepy/ubluepy_characteristic.c \
|
||||||
ubluepy/ubluepy_uuid.c \
|
|
||||||
ubluepy/ubluepy_delegate.c \
|
ubluepy/ubluepy_delegate.c \
|
||||||
ubluepy/ubluepy_constants.c \
|
ubluepy/ubluepy_constants.c \
|
||||||
ubluepy/ubluepy_descriptor.c \
|
ubluepy/ubluepy_descriptor.c \
|
||||||
@ -168,7 +167,8 @@ SRC_COMMON_HAL += \
|
|||||||
ifneq ($(SD), )
|
ifneq ($(SD), )
|
||||||
SRC_COMMON_HAL += \
|
SRC_COMMON_HAL += \
|
||||||
bleio/__init__.c \
|
bleio/__init__.c \
|
||||||
bleio/Adapter.c
|
bleio/Adapter.c \
|
||||||
|
bleio/UUID.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# These don't have corresponding files in each port but are still located in
|
# These don't have corresponding files in each port but are still located in
|
||||||
@ -183,6 +183,11 @@ SRC_BINDINGS_ENUMS = \
|
|||||||
math/__init__.c \
|
math/__init__.c \
|
||||||
util.c
|
util.c
|
||||||
|
|
||||||
|
ifneq ($(SD), )
|
||||||
|
SRC_BINDINGS_ENUMS += \
|
||||||
|
bleio/UUIDType.c
|
||||||
|
endif
|
||||||
|
|
||||||
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
||||||
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
|
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
|
||||||
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
||||||
|
125
ports/nrf/common-hal/bleio/UUID.c
Normal file
125
ports/nrf/common-hal/bleio/UUID.c
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 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 "ble_drv.h"
|
||||||
|
#include "common-hal/bleio/UUID.h"
|
||||||
|
#include "py/objstr.h"
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "shared-bindings/bleio/UUID.h"
|
||||||
|
|
||||||
|
#define UUID_STR_16BIT_LEN 6
|
||||||
|
#define UUID_STR_128BIT_LEN 36
|
||||||
|
|
||||||
|
static uint8_t xdigit_8b_value(byte nibble1, byte nibble2) {
|
||||||
|
return unichar_xdigit_value(nibble1) |
|
||||||
|
(unichar_xdigit_value(nibble2) << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, const mp_obj_t *uuid) {
|
||||||
|
if (MP_OBJ_IS_INT(*uuid)) {
|
||||||
|
self->type = UUID_TYPE_16BIT;
|
||||||
|
|
||||||
|
self->value[1] = (mp_obj_get_int(*uuid) >> 8) & 0xFF;
|
||||||
|
self->value[0] = (mp_obj_get_int(*uuid) >> 0) & 0xFF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MP_OBJ_IS_STR(*uuid)) {
|
||||||
|
GET_STR_DATA_LEN(*uuid, str_data, str_len);
|
||||||
|
|
||||||
|
if (str_len == UUID_STR_16BIT_LEN) {
|
||||||
|
self->type = UUID_TYPE_16BIT;
|
||||||
|
|
||||||
|
self->value[0] = xdigit_8b_value(str_data[5], str_data[4]);
|
||||||
|
self->value[1] = xdigit_8b_value(str_data[3], str_data[2]);
|
||||||
|
} else if (str_len == UUID_STR_128BIT_LEN) {
|
||||||
|
self->type = UUID_TYPE_128BIT;
|
||||||
|
|
||||||
|
uint8_t buffer[16];
|
||||||
|
buffer[0] = xdigit_8b_value(str_data[35], str_data[34]);
|
||||||
|
buffer[1] = xdigit_8b_value(str_data[33], str_data[32]);
|
||||||
|
buffer[2] = xdigit_8b_value(str_data[31], str_data[30]);
|
||||||
|
buffer[3] = xdigit_8b_value(str_data[29], str_data[28]);
|
||||||
|
buffer[4] = xdigit_8b_value(str_data[27], str_data[26]);
|
||||||
|
buffer[5] = xdigit_8b_value(str_data[25], str_data[24]);
|
||||||
|
|
||||||
|
// 23 '-'
|
||||||
|
buffer[6] = xdigit_8b_value(str_data[22], str_data[21]);
|
||||||
|
buffer[7] = xdigit_8b_value(str_data[20], str_data[19]);
|
||||||
|
|
||||||
|
// 18 '-'
|
||||||
|
buffer[8] = xdigit_8b_value(str_data[17], str_data[16]);
|
||||||
|
buffer[9] = xdigit_8b_value(str_data[15], str_data[14]);
|
||||||
|
|
||||||
|
// 13 '-'
|
||||||
|
buffer[10] = xdigit_8b_value(str_data[12], str_data[11]);
|
||||||
|
buffer[11] = xdigit_8b_value(str_data[10], str_data[9]);
|
||||||
|
|
||||||
|
// 8 '-'
|
||||||
|
self->value[0] = xdigit_8b_value(str_data[7], str_data[6]);
|
||||||
|
self->value[1] = xdigit_8b_value(str_data[5], str_data[4]);
|
||||||
|
|
||||||
|
buffer[14] = xdigit_8b_value(str_data[3], str_data[2]);
|
||||||
|
buffer[15] = xdigit_8b_value(str_data[1], str_data[0]);
|
||||||
|
|
||||||
|
ble_drv_uuid_add_vs(buffer, &self->uuid_vs_idx);
|
||||||
|
} else {
|
||||||
|
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
||||||
|
"Invalid UUID string length"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// deep copy
|
||||||
|
if (MP_OBJ_IS_TYPE(*uuid, &bleio_uuid_type)) {
|
||||||
|
bleio_uuid_obj_t *other = MP_OBJ_TO_PTR(*uuid);
|
||||||
|
self->type = other->type;
|
||||||
|
self->uuid_vs_idx = other->uuid_vs_idx;
|
||||||
|
self->value[0] = other->value[0];
|
||||||
|
self->value[1] = other->value[1];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
||||||
|
"Invalid UUID parameter"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void common_hal_bleio_uuid_print(bleio_uuid_obj_t *self, const mp_print_t *print) {
|
||||||
|
if (self->type == UUID_TYPE_16BIT) {
|
||||||
|
mp_printf(print, "UUID(uuid: 0x" HEX2_FMT HEX2_FMT ")",
|
||||||
|
self->value[1], self->value[0]);
|
||||||
|
} else {
|
||||||
|
mp_printf(print, "UUID(uuid: 0x" HEX2_FMT HEX2_FMT ", VS idx: " HEX2_FMT ")",
|
||||||
|
self->value[1], self->value[0], self->uuid_vs_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bleio_uuid_type_t common_hal_bleio_uuid_get_type(bleio_uuid_obj_t *self) {
|
||||||
|
return self->type;
|
||||||
|
}
|
41
ports/nrf/common-hal/bleio/UUID.h
Normal file
41
ports/nrf/common-hal/bleio/UUID.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the MicroPython project, http://micropython.org/
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_UUID_H
|
||||||
|
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_UUID_H
|
||||||
|
|
||||||
|
#include "py/obj.h"
|
||||||
|
#include "shared-bindings/bleio/UUIDType.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
mp_obj_base_t base;
|
||||||
|
bleio_uuid_type_t type;
|
||||||
|
uint8_t uuid_vs_idx;
|
||||||
|
uint8_t value[2];
|
||||||
|
} bleio_uuid_obj_t;
|
||||||
|
|
||||||
|
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_UUID_H
|
@ -430,11 +430,11 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
|
|||||||
|
|
||||||
for (uint8_t i = 0; i < p_adv_params->num_of_services; i++) {
|
for (uint8_t i = 0; i < p_adv_params->num_of_services; i++) {
|
||||||
ubluepy_service_obj_t * p_service = (ubluepy_service_obj_t *)p_adv_params->p_services[i];
|
ubluepy_service_obj_t * p_service = (ubluepy_service_obj_t *)p_adv_params->p_services[i];
|
||||||
if (p_service->p_uuid->type == UBLUEPY_UUID_16_BIT) {
|
if (p_service->p_uuid->type == UUID_TYPE_16BIT) {
|
||||||
type_16bit_present = true;
|
type_16bit_present = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_service->p_uuid->type == UBLUEPY_UUID_128_BIT) {
|
if (p_service->p_uuid->type == UUID_TYPE_128BIT) {
|
||||||
type_128bit_present = true;
|
type_128bit_present = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,21 +34,21 @@
|
|||||||
|
|
||||||
#if MICROPY_PY_BLE_NUS
|
#if MICROPY_PY_BLE_NUS
|
||||||
|
|
||||||
static ubluepy_uuid_obj_t uuid_obj_service = {
|
static bleio_uuid_obj_t uuid_obj_service = {
|
||||||
.base.type = &ubluepy_uuid_type,
|
.base.type = &bleio_uuid_type,
|
||||||
.type = UBLUEPY_UUID_128_BIT,
|
.type = UUID_128_BIT,
|
||||||
.value = {0x01, 0x00}
|
.value = {0x01, 0x00}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ubluepy_uuid_obj_t uuid_obj_char_tx = {
|
static bleio_uuid_obj_t uuid_obj_char_tx = {
|
||||||
.base.type = &ubluepy_uuid_type,
|
.base.type = &bleio_uuid_type,
|
||||||
.type = UBLUEPY_UUID_128_BIT,
|
.type = UUID_128_BIT,
|
||||||
.value = {0x03, 0x00}
|
.value = {0x03, 0x00}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ubluepy_uuid_obj_t uuid_obj_char_rx = {
|
static bleio_uuid_obj_t uuid_obj_char_rx = {
|
||||||
.base.type = &ubluepy_uuid_type,
|
.base.type = &bleio_uuid_type,
|
||||||
.type = UBLUEPY_UUID_128_BIT,
|
.type = UUID_128_BIT,
|
||||||
.value = {0x02, 0x00}
|
.value = {0x02, 0x00}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
extern const mp_obj_type_t ubluepy_peripheral_type;
|
extern const mp_obj_type_t ubluepy_peripheral_type;
|
||||||
extern const mp_obj_type_t ubluepy_service_type;
|
extern const mp_obj_type_t ubluepy_service_type;
|
||||||
extern const mp_obj_type_t ubluepy_uuid_type;
|
|
||||||
extern const mp_obj_type_t ubluepy_characteristic_type;
|
extern const mp_obj_type_t ubluepy_characteristic_type;
|
||||||
extern const mp_obj_type_t ubluepy_delegate_type;
|
extern const mp_obj_type_t ubluepy_delegate_type;
|
||||||
extern const mp_obj_type_t ubluepy_constants_type;
|
extern const mp_obj_type_t ubluepy_constants_type;
|
||||||
@ -50,7 +49,6 @@ STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = {
|
|||||||
{ MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&ubluepy_scan_entry_type) },
|
{ MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&ubluepy_scan_entry_type) },
|
||||||
#endif
|
#endif
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DefaultDelegate), MP_ROM_PTR(&ubluepy_delegate_type) },
|
{ MP_ROM_QSTR(MP_QSTR_DefaultDelegate), MP_ROM_PTR(&ubluepy_delegate_type) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&ubluepy_uuid_type) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&ubluepy_service_type) },
|
{ MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&ubluepy_service_type) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&ubluepy_characteristic_type) },
|
{ MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&ubluepy_characteristic_type) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_constants), MP_ROM_PTR(&ubluepy_constants_type) },
|
{ MP_ROM_QSTR(MP_QSTR_constants), MP_ROM_PTR(&ubluepy_constants_type) },
|
||||||
|
@ -71,9 +71,9 @@ p.advertise(device_name="micr", services=[s])
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "common-hal/bleio/UUID.h"
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
extern const mp_obj_type_t ubluepy_uuid_type;
|
|
||||||
extern const mp_obj_type_t ubluepy_service_type;
|
extern const mp_obj_type_t ubluepy_service_type;
|
||||||
extern const mp_obj_type_t ubluepy_characteristic_type;
|
extern const mp_obj_type_t ubluepy_characteristic_type;
|
||||||
extern const mp_obj_type_t ubluepy_peripheral_type;
|
extern const mp_obj_type_t ubluepy_peripheral_type;
|
||||||
@ -82,11 +82,6 @@ extern const mp_obj_type_t ubluepy_scan_entry_type;
|
|||||||
extern const mp_obj_type_t ubluepy_constants_type;
|
extern const mp_obj_type_t ubluepy_constants_type;
|
||||||
extern const mp_obj_type_t ubluepy_constants_ad_types_type;
|
extern const mp_obj_type_t ubluepy_constants_ad_types_type;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
UBLUEPY_UUID_16_BIT = 1,
|
|
||||||
UBLUEPY_UUID_128_BIT
|
|
||||||
} ubluepy_uuid_type_t;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UBLUEPY_SERVICE_PRIMARY = 1,
|
UBLUEPY_SERVICE_PRIMARY = 1,
|
||||||
UBLUEPY_SERVICE_SECONDARY = 2
|
UBLUEPY_SERVICE_SECONDARY = 2
|
||||||
@ -106,13 +101,6 @@ typedef enum {
|
|||||||
UBLUEPY_ROLE_CENTRAL
|
UBLUEPY_ROLE_CENTRAL
|
||||||
} ubluepy_role_type_t;
|
} ubluepy_role_type_t;
|
||||||
|
|
||||||
typedef struct _ubluepy_uuid_obj_t {
|
|
||||||
mp_obj_base_t base;
|
|
||||||
ubluepy_uuid_type_t type;
|
|
||||||
uint8_t value[2];
|
|
||||||
uint8_t uuid_vs_idx;
|
|
||||||
} ubluepy_uuid_obj_t;
|
|
||||||
|
|
||||||
typedef struct _ubluepy_peripheral_obj_t {
|
typedef struct _ubluepy_peripheral_obj_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
ubluepy_role_type_t role;
|
ubluepy_role_type_t role;
|
||||||
@ -127,7 +115,7 @@ typedef struct _ubluepy_service_obj_t {
|
|||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
ubluepy_uuid_obj_t * p_uuid;
|
bleio_uuid_obj_t * p_uuid;
|
||||||
ubluepy_peripheral_obj_t * p_periph;
|
ubluepy_peripheral_obj_t * p_periph;
|
||||||
mp_obj_t char_list;
|
mp_obj_t char_list;
|
||||||
uint16_t start_handle;
|
uint16_t start_handle;
|
||||||
@ -137,7 +125,7 @@ typedef struct _ubluepy_service_obj_t {
|
|||||||
typedef struct _ubluepy_characteristic_obj_t {
|
typedef struct _ubluepy_characteristic_obj_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
ubluepy_uuid_obj_t * p_uuid;
|
bleio_uuid_obj_t * p_uuid;
|
||||||
uint16_t service_handle;
|
uint16_t service_handle;
|
||||||
uint16_t user_desc_handle;
|
uint16_t user_desc_handle;
|
||||||
uint16_t cccd_handle;
|
uint16_t cccd_handle;
|
||||||
@ -151,7 +139,7 @@ typedef struct _ubluepy_characteristic_obj_t {
|
|||||||
typedef struct _ubluepy_descriptor_obj_t {
|
typedef struct _ubluepy_descriptor_obj_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
ubluepy_uuid_obj_t * p_uuid;
|
bleio_uuid_obj_t * p_uuid;
|
||||||
} ubluepy_descriptor_obj_t;
|
} ubluepy_descriptor_obj_t;
|
||||||
|
|
||||||
typedef struct _ubluepy_delegate_obj_t {
|
typedef struct _ubluepy_delegate_obj_t {
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "modubluepy.h"
|
#include "modubluepy.h"
|
||||||
#include "ble_drv.h"
|
#include "ble_drv.h"
|
||||||
|
#include "shared-bindings/bleio/UUID.h"
|
||||||
|
|
||||||
STATIC void ubluepy_characteristic_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
STATIC void ubluepy_characteristic_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
||||||
ubluepy_characteristic_obj_t * self = (ubluepy_characteristic_obj_t *)o;
|
ubluepy_characteristic_obj_t * self = (ubluepy_characteristic_obj_t *)o;
|
||||||
@ -60,7 +61,7 @@ STATIC mp_obj_t ubluepy_characteristic_make_new(const mp_obj_type_t *type, size_
|
|||||||
return MP_OBJ_FROM_PTR(s);
|
return MP_OBJ_FROM_PTR(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) {
|
if (MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
|
||||||
s->p_uuid = MP_OBJ_TO_PTR(uuid_obj);
|
s->p_uuid = MP_OBJ_TO_PTR(uuid_obj);
|
||||||
// (void)sd_characterstic_add(s);
|
// (void)sd_characterstic_add(s);
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#if MICROPY_PY_UBLUEPY
|
#if MICROPY_PY_UBLUEPY
|
||||||
|
|
||||||
#include "ble_drv.h"
|
#include "ble_drv.h"
|
||||||
|
#include "common-hal/bleio/UUID.h"
|
||||||
|
#include "shared-bindings/bleio/UUID.h"
|
||||||
|
|
||||||
STATIC void ubluepy_peripheral_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
STATIC void ubluepy_peripheral_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
||||||
ubluepy_peripheral_obj_t * self = (ubluepy_peripheral_obj_t *)o;
|
ubluepy_peripheral_obj_t * self = (ubluepy_peripheral_obj_t *)o;
|
||||||
@ -294,8 +296,8 @@ void static disc_add_service(mp_obj_t self, ble_drv_service_data_t * p_service_d
|
|||||||
ubluepy_service_obj_t * p_service = m_new_obj(ubluepy_service_obj_t);
|
ubluepy_service_obj_t * p_service = m_new_obj(ubluepy_service_obj_t);
|
||||||
p_service->base.type = &ubluepy_service_type;
|
p_service->base.type = &ubluepy_service_type;
|
||||||
|
|
||||||
ubluepy_uuid_obj_t * p_uuid = m_new_obj(ubluepy_uuid_obj_t);
|
bleio_uuid_obj_t * p_uuid = m_new_obj(bleio_uuid_obj_t);
|
||||||
p_uuid->base.type = &ubluepy_uuid_type;
|
p_uuid->base.type = &bleio_uuid_type;
|
||||||
|
|
||||||
p_service->p_uuid = p_uuid;
|
p_service->p_uuid = p_uuid;
|
||||||
|
|
||||||
@ -317,8 +319,8 @@ void static disc_add_char(mp_obj_t service_in, ble_drv_char_data_t * p_desc_data
|
|||||||
ubluepy_characteristic_obj_t * p_char = m_new_obj(ubluepy_characteristic_obj_t);
|
ubluepy_characteristic_obj_t * p_char = m_new_obj(ubluepy_characteristic_obj_t);
|
||||||
p_char->base.type = &ubluepy_characteristic_type;
|
p_char->base.type = &ubluepy_characteristic_type;
|
||||||
|
|
||||||
ubluepy_uuid_obj_t * p_uuid = m_new_obj(ubluepy_uuid_obj_t);
|
bleio_uuid_obj_t * p_uuid = m_new_obj(bleio_uuid_obj_t);
|
||||||
p_uuid->base.type = &ubluepy_uuid_type;
|
p_uuid->base.type = &bleio_uuid_type;
|
||||||
|
|
||||||
p_char->p_uuid = p_uuid;
|
p_char->p_uuid = p_uuid;
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "modubluepy.h"
|
#include "modubluepy.h"
|
||||||
#include "ble_drv.h"
|
#include "ble_drv.h"
|
||||||
|
#include "common-hal/bleio/UUID.h"
|
||||||
|
#include "shared-bindings/bleio/UUID.h"
|
||||||
|
|
||||||
STATIC void ubluepy_service_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
STATIC void ubluepy_service_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
||||||
ubluepy_service_obj_t * self = (ubluepy_service_obj_t *)o;
|
ubluepy_service_obj_t * self = (ubluepy_service_obj_t *)o;
|
||||||
@ -62,7 +64,7 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||||||
return MP_OBJ_FROM_PTR(s);
|
return MP_OBJ_FROM_PTR(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) {
|
if (MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
|
||||||
s->p_uuid = MP_OBJ_TO_PTR(uuid_obj);
|
s->p_uuid = MP_OBJ_TO_PTR(uuid_obj);
|
||||||
|
|
||||||
uint8_t type = args[ARG_NEW_TYPE].u_int;
|
uint8_t type = args[ARG_NEW_TYPE].u_int;
|
||||||
@ -124,10 +126,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(ubluepy_service_get_chars_obj, service_get_char
|
|||||||
///
|
///
|
||||||
STATIC mp_obj_t service_get_characteristic(mp_obj_t self_in, mp_obj_t uuid) {
|
STATIC mp_obj_t service_get_characteristic(mp_obj_t self_in, mp_obj_t uuid) {
|
||||||
ubluepy_service_obj_t * self = MP_OBJ_TO_PTR(self_in);
|
ubluepy_service_obj_t * self = MP_OBJ_TO_PTR(self_in);
|
||||||
ubluepy_uuid_obj_t * p_uuid = MP_OBJ_TO_PTR(uuid);
|
bleio_uuid_obj_t * p_uuid = MP_OBJ_TO_PTR(uuid);
|
||||||
|
|
||||||
// validate that there is an UUID object passed in as parameter
|
// validate that there is an UUID object passed in as parameter
|
||||||
if (!(MP_OBJ_IS_TYPE(uuid, &ubluepy_uuid_type))) {
|
if (!(MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type))) {
|
||||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
||||||
translate("Invalid UUID parameter")));
|
translate("Invalid UUID parameter")));
|
||||||
}
|
}
|
||||||
|
@ -1,174 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the MicroPython project, http://micropython.org/
|
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Glenn Ruben Bakke
|
|
||||||
*
|
|
||||||
* 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/obj.h"
|
|
||||||
#include "py/runtime.h"
|
|
||||||
#include "py/objstr.h"
|
|
||||||
#include "py/misc.h"
|
|
||||||
#include "supervisor/shared/translate.h"
|
|
||||||
|
|
||||||
#if MICROPY_PY_UBLUEPY
|
|
||||||
|
|
||||||
#include "modubluepy.h"
|
|
||||||
#include "ble_drv.h"
|
|
||||||
|
|
||||||
STATIC void ubluepy_uuid_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
|
||||||
ubluepy_uuid_obj_t * self = (ubluepy_uuid_obj_t *)o;
|
|
||||||
if (self->type == UBLUEPY_UUID_16_BIT) {
|
|
||||||
mp_printf(print, "UUID(uuid: 0x" HEX2_FMT HEX2_FMT ")",
|
|
||||||
self->value[1], self->value[0]);
|
|
||||||
} else {
|
|
||||||
mp_printf(print, "UUID(uuid: 0x" HEX2_FMT HEX2_FMT ", VS idx: " HEX2_FMT ")",
|
|
||||||
self->value[1], self->value[0], self->uuid_vs_idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
|
||||||
|
|
||||||
enum { ARG_NEW_UUID };
|
|
||||||
|
|
||||||
static const mp_arg_t allowed_args[] = {
|
|
||||||
{ ARG_NEW_UUID, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
|
||||||
};
|
|
||||||
|
|
||||||
// parse args
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
|
||||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
|
|
||||||
ubluepy_uuid_obj_t *s = m_new_obj(ubluepy_uuid_obj_t);
|
|
||||||
s->base.type = type;
|
|
||||||
|
|
||||||
mp_obj_t uuid_obj = args[ARG_NEW_UUID].u_obj;
|
|
||||||
|
|
||||||
if (uuid_obj == MP_OBJ_NULL) {
|
|
||||||
return MP_OBJ_FROM_PTR(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MP_OBJ_IS_INT(uuid_obj)) {
|
|
||||||
s->type = UBLUEPY_UUID_16_BIT;
|
|
||||||
s->value[1] = (((uint16_t)mp_obj_get_int(uuid_obj)) >> 8) & 0xFF;
|
|
||||||
s->value[0] = ((uint8_t)mp_obj_get_int(uuid_obj)) & 0xFF;
|
|
||||||
} else if (MP_OBJ_IS_STR(uuid_obj)) {
|
|
||||||
GET_STR_DATA_LEN(uuid_obj, str_data, str_len);
|
|
||||||
if (str_len == 6) { // Assume hex digit prefixed with 0x
|
|
||||||
s->type = UBLUEPY_UUID_16_BIT;
|
|
||||||
s->value[0] = unichar_xdigit_value(str_data[5]);
|
|
||||||
s->value[0] += unichar_xdigit_value(str_data[4]) << 4;
|
|
||||||
s->value[1] = unichar_xdigit_value(str_data[3]);
|
|
||||||
s->value[1] += unichar_xdigit_value(str_data[2]) << 4;
|
|
||||||
} else if (str_len == 36) {
|
|
||||||
s->type = UBLUEPY_UUID_128_BIT;
|
|
||||||
uint8_t buffer[16];
|
|
||||||
buffer[0] = unichar_xdigit_value(str_data[35]);
|
|
||||||
buffer[0] += unichar_xdigit_value(str_data[34]) << 4;
|
|
||||||
buffer[1] = unichar_xdigit_value(str_data[33]);
|
|
||||||
buffer[1] += unichar_xdigit_value(str_data[32]) << 4;
|
|
||||||
buffer[2] = unichar_xdigit_value(str_data[31]);
|
|
||||||
buffer[2] += unichar_xdigit_value(str_data[30]) << 4;
|
|
||||||
buffer[3] = unichar_xdigit_value(str_data[29]);
|
|
||||||
buffer[3] += unichar_xdigit_value(str_data[28]) << 4;
|
|
||||||
buffer[4] = unichar_xdigit_value(str_data[27]);
|
|
||||||
buffer[4] += unichar_xdigit_value(str_data[26]) << 4;
|
|
||||||
buffer[5] = unichar_xdigit_value(str_data[25]);
|
|
||||||
buffer[5] += unichar_xdigit_value(str_data[24]) << 4;
|
|
||||||
// 23 '-'
|
|
||||||
buffer[6] = unichar_xdigit_value(str_data[22]);
|
|
||||||
buffer[6] += unichar_xdigit_value(str_data[21]) << 4;
|
|
||||||
buffer[7] = unichar_xdigit_value(str_data[20]);
|
|
||||||
buffer[7] += unichar_xdigit_value(str_data[19]) << 4;
|
|
||||||
// 18 '-'
|
|
||||||
buffer[8] = unichar_xdigit_value(str_data[17]);
|
|
||||||
buffer[8] += unichar_xdigit_value(str_data[16]) << 4;
|
|
||||||
buffer[9] = unichar_xdigit_value(str_data[15]);
|
|
||||||
buffer[9] += unichar_xdigit_value(str_data[14]) << 4;
|
|
||||||
// 13 '-'
|
|
||||||
buffer[10] = unichar_xdigit_value(str_data[12]);
|
|
||||||
buffer[10] += unichar_xdigit_value(str_data[11]) << 4;
|
|
||||||
buffer[11] = unichar_xdigit_value(str_data[10]);
|
|
||||||
buffer[11] += unichar_xdigit_value(str_data[9]) << 4;
|
|
||||||
// 8 '-'
|
|
||||||
// 16-bit field
|
|
||||||
s->value[0] = unichar_xdigit_value(str_data[7]);
|
|
||||||
s->value[0] += unichar_xdigit_value(str_data[6]) << 4;
|
|
||||||
s->value[1] = unichar_xdigit_value(str_data[5]);
|
|
||||||
s->value[1] += unichar_xdigit_value(str_data[4]) << 4;
|
|
||||||
|
|
||||||
buffer[14] = unichar_xdigit_value(str_data[3]);
|
|
||||||
buffer[14] += unichar_xdigit_value(str_data[2]) << 4;
|
|
||||||
buffer[15] = unichar_xdigit_value(str_data[1]);
|
|
||||||
buffer[15] += unichar_xdigit_value(str_data[0]) << 4;
|
|
||||||
|
|
||||||
ble_drv_uuid_add_vs(buffer, &s->uuid_vs_idx);
|
|
||||||
} else {
|
|
||||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
|
||||||
translate("Invalid UUID string length")));
|
|
||||||
}
|
|
||||||
} else if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) {
|
|
||||||
// deep copy instance
|
|
||||||
ubluepy_uuid_obj_t * p_old = MP_OBJ_TO_PTR(uuid_obj);
|
|
||||||
s->type = p_old->type;
|
|
||||||
s->value[0] = p_old->value[0];
|
|
||||||
s->value[1] = p_old->value[1];
|
|
||||||
} else {
|
|
||||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
|
||||||
translate("Invalid UUID parameter")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return MP_OBJ_FROM_PTR(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \method binVal()
|
|
||||||
/// Get binary value of the 16 or 128 bit UUID. Returned as bytearray type.
|
|
||||||
///
|
|
||||||
STATIC mp_obj_t uuid_bin_val(mp_obj_t self_in) {
|
|
||||||
ubluepy_uuid_obj_t * self = MP_OBJ_TO_PTR(self_in);
|
|
||||||
|
|
||||||
// TODO: Extend the uint16 byte value to 16 byte if 128-bit,
|
|
||||||
// also encapsulate it in a bytearray. For now, return
|
|
||||||
// the uint16_t field of the UUID.
|
|
||||||
return MP_OBJ_NEW_SMALL_INT(self->value[0] | self->value[1] << 8);
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(ubluepy_uuid_bin_val_obj, uuid_bin_val);
|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t ubluepy_uuid_locals_dict_table[] = {
|
|
||||||
#if 0
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_getCommonName), MP_ROM_PTR(&ubluepy_uuid_get_common_name_obj) },
|
|
||||||
#endif
|
|
||||||
// Properties
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_binVal), MP_ROM_PTR(&ubluepy_uuid_bin_val_obj) },
|
|
||||||
};
|
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_uuid_locals_dict, ubluepy_uuid_locals_dict_table);
|
|
||||||
|
|
||||||
const mp_obj_type_t ubluepy_uuid_type = {
|
|
||||||
{ &mp_type_type },
|
|
||||||
.name = MP_QSTR_UUID,
|
|
||||||
.print = ubluepy_uuid_print,
|
|
||||||
.make_new = ubluepy_uuid_make_new,
|
|
||||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_uuid_locals_dict
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MICROPY_PY_UBLUEPY
|
|
208
shared-bindings/bleio/UUID.c
Normal file
208
shared-bindings/bleio/UUID.c
Normal file
@ -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
|
||||||
|
};
|
39
shared-bindings/bleio/UUID.h
Normal file
39
shared-bindings/bleio/UUID.h
Normal file
@ -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
|
75
shared-bindings/bleio/UUIDType.c
Normal file
75
shared-bindings/bleio/UUIDType.c
Normal file
@ -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,
|
||||||
|
};
|
46
shared-bindings/bleio/UUIDType.h
Normal file
46
shared-bindings/bleio/UUIDType.h
Normal file
@ -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
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "shared-bindings/bleio/__init__.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
|
//| :mod:`bleio` --- Bluetooth Low Energy functionality
|
||||||
//| ================================================================
|
//| ================================================================
|
||||||
@ -43,6 +45,8 @@
|
|||||||
//| :maxdepth: 3
|
//| :maxdepth: 3
|
||||||
//|
|
//|
|
||||||
//| Adapter
|
//| Adapter
|
||||||
|
//| UUID
|
||||||
|
//| UUIDType
|
||||||
//|
|
//|
|
||||||
//| .. attribute:: adapter
|
//| .. attribute:: adapter
|
||||||
//|
|
//|
|
||||||
@ -52,8 +56,14 @@
|
|||||||
//|
|
//|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
|
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___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_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);
|
STATIC MP_DEFINE_CONST_DICT(bleio_module_globals, bleio_module_globals_table);
|
||||||
|
Loading…
Reference in New Issue
Block a user