nrf: Move the Descriptor class from ubluepy to the shared bleio module
This commit is contained in:
parent
f4940c9aec
commit
20b8d5169d
@ -134,7 +134,6 @@ DRIVERS_SRC_C += $(addprefix modules/,\
|
||||
ubluepy/ubluepy_characteristic.c \
|
||||
ubluepy/ubluepy_delegate.c \
|
||||
ubluepy/ubluepy_constants.c \
|
||||
ubluepy/ubluepy_descriptor.c \
|
||||
ubluepy/ubluepy_scanner.c \
|
||||
ubluepy/ubluepy_scan_entry.c \
|
||||
)
|
||||
@ -168,6 +167,7 @@ ifneq ($(SD), )
|
||||
SRC_COMMON_HAL += \
|
||||
bleio/__init__.c \
|
||||
bleio/Adapter.c \
|
||||
bleio/Descriptor.c \
|
||||
bleio/UUID.c
|
||||
endif
|
||||
|
||||
|
45
ports/nrf/common-hal/bleio/Descriptor.c
Normal file
45
ports/nrf/common-hal/bleio/Descriptor.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 "common-hal/bleio/Descriptor.h"
|
||||
|
||||
void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid) {
|
||||
self->uuid = uuid;
|
||||
}
|
||||
|
||||
void common_hal_bleio_descriptor_print(bleio_descriptor_obj_t *self, const mp_print_t *print) {
|
||||
mp_printf(print, "Descriptor(uuid: 0x" HEX2_FMT HEX2_FMT ")",
|
||||
self->uuid->value[1], self->uuid->value[0]);
|
||||
}
|
||||
|
||||
mp_int_t common_hal_bleio_descriptor_get_handle(bleio_descriptor_obj_t *self) {
|
||||
return self->handle;
|
||||
}
|
||||
|
||||
mp_int_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) {
|
||||
return self->uuid->value[0] | (self->uuid->value[1] << 8);
|
||||
}
|
40
ports/nrf/common-hal/bleio/Descriptor.h
Normal file
40
ports/nrf/common-hal/bleio/Descriptor.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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_DESCRIPTOR_H
|
||||
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_DESCRIPTOR_H
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "common-hal/bleio/UUID.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
uint16_t handle;
|
||||
bleio_uuid_obj_t *uuid;
|
||||
} bleio_descriptor_obj_t;
|
||||
|
||||
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_DESCRIPTOR_H
|
@ -52,9 +52,6 @@ STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = {
|
||||
{ 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_constants), MP_ROM_PTR(&ubluepy_constants_type) },
|
||||
#if MICROPY_PY_UBLUEPY_DESCRIPTOR
|
||||
{ MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&ubluepy_descriptor_type) },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -136,12 +136,6 @@ typedef struct _ubluepy_characteristic_obj_t {
|
||||
mp_obj_t value_data;
|
||||
} ubluepy_characteristic_obj_t;
|
||||
|
||||
typedef struct _ubluepy_descriptor_obj_t {
|
||||
mp_obj_base_t base;
|
||||
uint16_t handle;
|
||||
bleio_uuid_obj_t * p_uuid;
|
||||
} ubluepy_descriptor_obj_t;
|
||||
|
||||
typedef struct _ubluepy_delegate_obj_t {
|
||||
mp_obj_base_t base;
|
||||
} ubluepy_delegate_obj_t;
|
||||
|
@ -1,82 +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"
|
||||
|
||||
#if MICROPY_PY_UBLUEPY
|
||||
|
||||
#include "modubluepy.h"
|
||||
#include "ble_drv.h"
|
||||
|
||||
STATIC void ubluepy_descriptor_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
||||
ubluepy_descriptor_obj_t * self = (ubluepy_descriptor_obj_t *)o;
|
||||
|
||||
mp_printf(print, "Descriptor(uuid: 0x" HEX2_FMT HEX2_FMT ")",
|
||||
self->p_uuid->value[1], self->p_uuid->value[0]);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t ubluepy_descriptor_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_descriptor_obj_t * s = m_new_obj(ubluepy_descriptor_obj_t);
|
||||
s->base.type = type;
|
||||
|
||||
mp_obj_t uuid_obj = args[ARG_NEW_UUID].u_obj;
|
||||
|
||||
(void)uuid_obj;
|
||||
|
||||
return MP_OBJ_FROM_PTR(s);
|
||||
}
|
||||
|
||||
STATIC const mp_rom_map_elem_t ubluepy_descriptor_locals_dict_table[] = {
|
||||
#if 0
|
||||
{ MP_ROM_QSTR(MP_QSTR_binVal), MP_ROM_PTR(&ubluepy_descriptor_bin_val_obj) },
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_descriptor_locals_dict, ubluepy_descriptor_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_descriptor_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Descriptor,
|
||||
.print = ubluepy_descriptor_print,
|
||||
.make_new = ubluepy_descriptor_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_descriptor_locals_dict
|
||||
};
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY
|
171
shared-bindings/bleio/Descriptor.c
Normal file
171
shared-bindings/bleio/Descriptor.c
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* 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/Descriptor.h"
|
||||
#include "shared-bindings/bleio/UUID.h"
|
||||
|
||||
enum {
|
||||
DescriptorUuidCharacteristicExtendedProperties = 0x2900,
|
||||
DescriptorUuidCharacteristicUserDescription = 0x2901,
|
||||
DescriptorUuidClientCharacteristicConfiguration = 0x2902,
|
||||
DescriptorUuidServerCharacteristicConfiguration = 0x2903,
|
||||
DescriptorUuidCharacteristicPresentationFormat = 0x2904,
|
||||
DescriptorUuidCharacteristicAggregateFormat = 0x2905,
|
||||
DescriptorUuidValidRange = 0x2906,
|
||||
DescriptorUuidExternalReportReference = 0x2907,
|
||||
DescriptorUuidReportReference = 0x2908,
|
||||
DescriptorUuidNumberOfDigitals = 0x2909,
|
||||
DescriptorUuidValueTriggerSetting = 0x290A,
|
||||
DescriptorUuidEnvironmentalSensingConfiguration = 0x290B,
|
||||
DescriptorUuidEnvironmentalSensingMeasurement = 0x290C,
|
||||
DescriptorUuidEnvironmentalSensingTriggerSetting = 0x290D,
|
||||
DescriptorUuidTimeTriggerSetting = 0x290E,
|
||||
};
|
||||
|
||||
//| .. currentmodule:: bleio
|
||||
//|
|
||||
//| :class:`Descriptor` -- BLE descriptor
|
||||
//| =========================================================
|
||||
//|
|
||||
//| Stores information about a BLE descriptor.
|
||||
//| Descriptors are encapsulated by BLE characteristics and provide contextual
|
||||
//| information about the characteristic.
|
||||
//|
|
||||
|
||||
//| .. 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
|
||||
//|
|
||||
//| The descriptor handle. (read-only)
|
||||
//|
|
||||
|
||||
//| .. attribute:: uuid
|
||||
//|
|
||||
//| The descriptor uuid. (read-only)
|
||||
//|
|
||||
STATIC mp_obj_t bleio_descriptor_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, 0, 1, true);
|
||||
bleio_descriptor_obj_t *self = m_new_obj(bleio_descriptor_obj_t);
|
||||
self->base.type = 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_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));
|
||||
}
|
||||
|
||||
common_hal_bleio_descriptor_construct(self, uuid);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t bleio_descriptor_get_handle(mp_obj_t self_in) {
|
||||
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
return mp_obj_new_int(common_hal_bleio_descriptor_get_handle(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_handle_obj, bleio_descriptor_get_handle);
|
||||
|
||||
const mp_obj_property_t bleio_descriptor_handle_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&bleio_descriptor_get_handle_obj,
|
||||
(mp_obj_t)&mp_const_none_obj,
|
||||
(mp_obj_t)&mp_const_none_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);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_uuid_obj, bleio_descriptor_get_uuid);
|
||||
|
||||
const mp_obj_property_t bleio_descriptor_uuid_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&bleio_descriptor_get_uuid_obj,
|
||||
(mp_obj_t)&mp_const_none_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t bleio_descriptor_locals_dict_table[] = {
|
||||
// Properties
|
||||
{ MP_ROM_QSTR(MP_QSTR_handle), MP_ROM_PTR(&bleio_descriptor_handle_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_descriptor_uuid_obj) },
|
||||
|
||||
// Static variables
|
||||
{ MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_EXTENDED_PROPERTIES), MP_ROM_INT(DescriptorUuidCharacteristicExtendedProperties) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_USER_DESCRIPTION), MP_ROM_INT(DescriptorUuidCharacteristicUserDescription) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CLIENT_CHARACTERISTIC_CONFIGURATION), MP_ROM_INT(DescriptorUuidClientCharacteristicConfiguration) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SERVER_CHARACTERISTIC_CONFIGURATION), MP_ROM_INT(DescriptorUuidServerCharacteristicConfiguration) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_PRESENTATION_FORMAT), MP_ROM_INT(DescriptorUuidCharacteristicPresentationFormat) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_AGGREGATE_FORMAT), MP_ROM_INT(DescriptorUuidCharacteristicAggregateFormat) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_VALID_RANGE), MP_ROM_INT(DescriptorUuidValidRange) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_EXTERNAL_REPORT_REFERENCE), MP_ROM_INT(DescriptorUuidExternalReportReference) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_REPORT_REFERENCE), MP_ROM_INT(DescriptorUuidReportReference) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_NUMBER_OF_DIGITALS), MP_ROM_INT(DescriptorUuidNumberOfDigitals) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_VALUE_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidValueTriggerSetting) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_CONFIGURATION), MP_ROM_INT(DescriptorUuidEnvironmentalSensingConfiguration) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_MEASUREMENT ), MP_ROM_INT(DescriptorUuidEnvironmentalSensingMeasurement) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidEnvironmentalSensingTriggerSetting) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TIME_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidTimeTriggerSetting) }
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(bleio_descriptor_locals_dict, bleio_descriptor_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t bleio_descriptor_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Descriptor,
|
||||
.print = bleio_descriptor_print,
|
||||
.make_new = bleio_descriptor_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&bleio_descriptor_locals_dict
|
||||
};
|
40
shared-bindings/bleio/Descriptor.h
Normal file
40
shared-bindings/bleio/Descriptor.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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_DESCRIPTOR_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DESCRIPTOR_H
|
||||
|
||||
#include "common-hal/bleio/Descriptor.h"
|
||||
#include "common-hal/bleio/UUID.h"
|
||||
|
||||
extern const mp_obj_type_t bleio_descriptor_type;
|
||||
|
||||
extern void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid);
|
||||
extern void common_hal_bleio_descriptor_print(bleio_descriptor_obj_t *self, const mp_print_t *print);
|
||||
extern mp_int_t common_hal_bleio_descriptor_get_handle(bleio_descriptor_obj_t *self);
|
||||
extern mp_int_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DESCRIPTOR_H
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "shared-bindings/bleio/__init__.h"
|
||||
#include "shared-bindings/bleio/Descriptor.h"
|
||||
#include "shared-bindings/bleio/UUID.h"
|
||||
#include "shared-bindings/bleio/UUIDType.h"
|
||||
|
||||
@ -45,6 +46,7 @@
|
||||
//| :maxdepth: 3
|
||||
//|
|
||||
//| Adapter
|
||||
//| Descriptor
|
||||
//| UUID
|
||||
//| UUIDType
|
||||
//|
|
||||
@ -57,6 +59,7 @@
|
||||
|
||||
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_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) },
|
||||
|
||||
// Properties
|
||||
|
Loading…
Reference in New Issue
Block a user