WIP: Central compiles; now will test

This commit is contained in:
Dan Halbert 2019-06-21 18:04:04 -04:00
parent 24ac1fdcab
commit 4881e1ff55
12 changed files with 78 additions and 162 deletions

View File

@ -41,34 +41,22 @@
#include "shared-bindings/bleio/UUID.h"
static bleio_service_obj_t *m_char_discovery_service;
static volatile bool m_discovery_in_process;
static volatile bool m_discovery_successful;
STATIC bool discover_next_services(bleio_central_obj_t *self, uint16_t start_handle) {
m_discovery_successful = false;
m_discovery_in_process = true;
uint32_t err_code = sd_ble_gattc_primary_services_discover(self->conn_handle, start_handle, NULL);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to discover services"));
}
// Serialize discovery.
err_code = sd_mutex_acquire(&m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to acquire mutex"));
// Wait for a discovery event.
while (m_discovery_in_process) {
MICROPY_VM_HOOK_LOOP;
}
// Wait for someone else to release m_discovery_mutex.
while (sd_mutex_acquire(&m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
}
err_code = sd_mutex_release(&m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
return m_discovery_successful;
}
@ -80,26 +68,17 @@ STATIC bool discover_next_characteristics(bleio_central_obj_t *self, bleio_servi
handle_range.end_handle = service->end_handle;
m_discovery_successful = false;
m_discovery_in_process = true;
uint32_t err_code = sd_ble_gattc_characteristics_discover(self->conn_handle, &handle_range);
if (err_code != NRF_SUCCESS) {
return false;
}
err_code = sd_mutex_acquire(&m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to acquire mutex"));
}
while (sd_mutex_acquire(&m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
// Wait for a discovery event.
while (m_discovery_in_process) {
MICROPY_VM_HOOK_LOOP;
}
err_code = sd_mutex_release(&m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
return m_discovery_successful;
}
@ -109,7 +88,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res
bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
service->base.type = &bleio_service_type;
service->device = central;
service->device = MP_OBJ_FROM_PTR(central);
service->characteristic_list = mp_obj_new_list(0, NULL);
service->start_handle = gattc_service->handle_range.start_handle;
service->end_handle = gattc_service->handle_range.end_handle;
@ -125,11 +104,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res
if (response->count > 0) {
m_discovery_successful = true;
}
const uint32_t err_code = sd_mutex_release(&m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
m_discovery_in_process = false;
}
STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_central_obj_t *central) {
@ -159,11 +134,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio
if (response->count > 0) {
m_discovery_successful = true;
}
const uint32_t err_code = sd_mutex_release(&m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
m_discovery_in_process = false;
}
STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) {
@ -189,6 +160,8 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) {
case BLE_GAP_EVT_DISCONNECTED:
central->conn_handle = BLE_CONN_HANDLE_INVALID;
m_discovery_successful = false;
m_discovery_in_process = false;
break;
case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
@ -220,10 +193,22 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) {
}
}
void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address_obj_t *address) {
common_hal_bleio_adapter_set_enabled(true);
self->service_list = mp_obj_new_list(0, NULL);
self->gatt_role = GATT_ROLE_CLIENT;
self->conn_handle = BLE_CONN_HANDLE_INVALID;
}
void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout) {
common_hal_bleio_adapter_set_enabled(true);
ble_drv_add_event_handler(on_ble_evt, self);
ble_gap_addr_t addr;
addr.addr_type = self->address.type;
memcpy(addr.addr, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES);
ble_gap_scan_params_t scan_params = {
.interval = MSEC_TO_UNITS(100, UNIT_0_625_MS),
.window = MSEC_TO_UNITS(100, UNIT_0_625_MS),
@ -241,7 +226,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time
self->attempting_to_connect = true;
uint32_t err_code = sd_ble_gap_connect(&scan_params, &m_scan_buffer);
uint32_t err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to start connecting, error 0x%04x"), err_code);
@ -266,7 +251,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time
next_start_handle = BLE_GATT_HANDLE_START;
while (1) {
if(!discover_next_services(self, discovery_start_handle)) {
if(!discover_next_services(self, next_start_handle)) {
break;
}
@ -310,3 +295,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time
void common_hal_bleio_central_disconnect(bleio_central_obj_t *self) {
sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
}
mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) {
return self->service_list;
}

View File

@ -30,16 +30,16 @@
#include <stdbool.h>
#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
typedef struct {
mp_obj_base_t base;
mp_obj_t remote_name;
gatt_role_t gatt_role;
bleio_address_obj_t address;
volatile bool attempting_to_connect;
volatile uint16_t conn_handle;
mp_obj_t service_list;
mp_obj_t conn_handler;
} bleio_central_obj_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H

View File

@ -152,7 +152,6 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) {
STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) {
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
uint32_t err_code;
ble_gattc_write_params_t write_params = {
.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL,
@ -163,7 +162,7 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in
};
while (1) {
uint32 err_code = sd_ble_gattc_write(conn_handle, &write_params);
uint32_t err_code = sd_ble_gattc_write(conn_handle, &write_params);
if (err_code == NRF_SUCCESS) {
break;
}

View File

@ -37,7 +37,7 @@ typedef struct {
bool is_secondary;
bleio_uuid_obj_t *uuid;
// May be a Peripheral, Central, etc.
mp_obj_t *device;
mp_obj_t device;
mp_obj_t characteristic_list;
// Range of attribute handles of this service.
uint16_t start_handle;

View File

@ -28,6 +28,7 @@
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/Central.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "common-hal/bleio/__init__.h"

View File

@ -35,11 +35,10 @@
#include "py/objstr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/AddressType.h"
#include "shared-bindings/bleio/Address.h"
#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Central.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
//| .. currentmodule:: bleio
//|
@ -62,44 +61,28 @@
//| break
//|
//| central = bleio.Central(my_entry.address)
//| central.connect()
//| central.connect(10.0) # timeout after 10 seconds
//|
//| .. class:: Central(address=None, scan_entry=None)
//|
//| Create a new Central object. If the `address` or :py:data:`scan_entry` parameters are not `None`,
//| the role is set to Central, otherwise it's set to Peripheral.
//| .. class:: Central(address)
//|
//| Create a new Central object.
//| :param bleio.Address address: The address of the central to connect to
//| :param bleio.ScanEntry scan_entry: The scan entry returned from `bleio.Scanner`
//|
STATIC mp_obj_t bleio_central_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);
STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 1, 1, false);
bleio_central_obj_t *self = m_new_obj(bleio_central_obj_t);
self->base.type = &bleio_central_type;
self->service_list = mp_obj_new_list(0, NULL);
self->conn_handler = mp_const_none;
self->conn_handle = 0xFFFF;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_address, ARG_scan_entry };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_address, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_scan_entry, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
};
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 address_obj = args[ARG_address].u_obj;
const mp_obj_t scan_entry_obj = args[ARG_scan_entry].u_obj;
const mp_obj_t address_obj = pos_args[0];
if (!MP_OBJ_IS_TYPE(address_obj, &bleio_address_type)) {
mp_raise_ValueError("Expected an Address");
mp_raise_ValueError(translate("Expected an Address"));
}
bleio_address_obj_t *address = MP_OBJ_TO_PTR(address_obj);
common_hal_bleio_central_construct(self, address);
return MP_OBJ_FROM_PTR(self);
}
@ -109,19 +92,15 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args,
//|
//| Attempts a connection to the remote peripheral. If the connection is successful,
//|
STATIC mp_obj_t bleio_central_connect(mp_obj_t self_in) {
STATIC mp_obj_t bleio_central_connect(mp_obj_t self_in, mp_obj_t timeout_in) {
bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (self->is_peripheral) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
translate("Can't connect in Peripheral mode")));
}
common_hal_bleio_central_connect(self);
mp_float_t timeout = mp_obj_float_get(timeout_in);
common_hal_bleio_central_connect(self, timeout);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_connect_obj, bleio_central_connect);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_central_connect_obj, bleio_central_connect);
//| .. method:: disconnect()
@ -137,17 +116,6 @@ STATIC mp_obj_t bleio_central_disconnect(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_disconnect);
//| .. attribute:: remote_name (read-only)
//|
//| The name of the remote peripheral, if connected. May be None if no name was advertised.
//|
STATIC mp_obj_t bleio_central_get_remote_name(mp_obj_t self_in) {
bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
return self->remote_name;
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_name_obj, bleio_central_get_remote_name);
//| .. attribute:: remote_services (read-only)
//|
//| Empty until connected, then a list of services provided by the remote peripheral.
@ -155,7 +123,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_name_obj, bleio_central_get_r
STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) {
bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
return self->service_list;
return common_hal_bleio_central_get_remote_services(self);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services);
@ -172,7 +140,6 @@ STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_central_disconnect_obj) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_remote_name), MP_ROM_PTR(&bleio_central_remote_name_obj) },
{ MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) },
};

View File

@ -31,9 +31,11 @@
#include "common-hal/bleio/Central.h"
#include "common-hal/bleio/Service.h"
extern const mp_obj_type_t bleio_device_type;
extern const mp_obj_type_t bleio_central_type;
extern void common_hal_bleio_device_connect(bleio_device_obj_t *device);
extern void common_hal_bleio_device_disconnect(bleio_device_obj_t *device);
extern void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address_obj_t *address);
extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout);
extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self);
extern mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H

View File

@ -69,12 +69,12 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
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;
const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
bleio_uuid_obj_t *uuid_obj = MP_OBJ_TO_PTR(uuid);
bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t);
self->base.type = &bleio_characteristic_type;
@ -88,7 +88,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
properties.write = args[ARG_write].u_bool;
properties.write_no_response = args[ARG_write_no_response].u_bool;
common_hal_bleio_characteristic_construct(self, uuid_obj, properties);
common_hal_bleio_characteristic_construct(self, uuid, properties);
return MP_OBJ_FROM_PTR(self);
}

View File

@ -86,7 +86,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t);
self->base.type = &bleio_characteristic_buffer_type;
common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer_size);
common_hal_bleio_characteristic_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), timeout, buffer_size);
return MP_OBJ_FROM_PTR(self);
}

View File

@ -1,42 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
* 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_DEVICE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H
#include "shared-module/bleio/Device.h"
#include "common-hal/bleio/Service.h"
extern const mp_obj_type_t bleio_device_type;
extern void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_service_obj_t *service);
extern void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data);
extern void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device);
extern void common_hal_bleio_device_connect(bleio_device_obj_t *device);
extern void common_hal_bleio_device_disconnect(bleio_device_obj_t *device);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H

View File

@ -107,8 +107,8 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar
self->base.type = &bleio_peripheral_type;
// Copy the services list and validate its items.
mp_obj_t service_list = mp_obj_new_list(0, NULL);
mp_obj_list_t *service_list_obj = MP_OBJ_FROM_PTR(service_list);
mp_obj_t service_list_obj = mp_obj_new_list(0, NULL);
mp_obj_list_t *service_list = MP_OBJ_FROM_PTR(service_list_obj);
mp_obj_t service;
while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
@ -128,7 +128,7 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar
mp_raise_ValueError(translate("name must be a string"));
}
common_hal_bleio_peripheral_construct(self, service_list_obj, name_str);
common_hal_bleio_peripheral_construct(self, service_list, name_str);
return MP_OBJ_FROM_PTR(self);
}

View File

@ -61,9 +61,9 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
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;
const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
@ -71,31 +71,31 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
self->base.type = &bleio_service_type;
const bool is_secondary = args[ARG_secondary].u_bool;
bleio_uuid_obj_t *uuid_obj = MP_OBJ_TO_PTR(uuid);
bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
// If characteristics is not an iterable, an exception will be thrown.
mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_characteristics].u_obj, &iter_buf);
mp_obj_t characteristic;
mp_obj_t characteristic_obj;
// Copy the characteristics list and validate its items.
mp_obj_t char_list = mp_obj_new_list(0, NULL);
mp_obj_list_t *char_list_obj = MP_OBJ_FROM_PTR(char_list);
mp_obj_t char_list_obj = mp_obj_new_list(0, NULL);
mp_obj_list_t *char_list = MP_OBJ_FROM_PTR(char_list);
while ((characteristic = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) {
while ((characteristic_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (!MP_OBJ_IS_TYPE(characteristic_obj, &bleio_characteristic_type)) {
mp_raise_ValueError(translate("characteristics includes an object that is not a Characteristic"));
}
bleio_characteristic_obj_t *characteristic_ptr = MP_OBJ_TO_PTR(characteristic);
bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_obj);
if (common_hal_bleio_uuid_get_uuid128_reference(uuid) !=
common_hal_bleio_uuid_get_uuid128_reference(characteristic_ptr->uuid)) {
common_hal_bleio_uuid_get_uuid128_reference(characteristic->uuid)) {
// The descriptor base UUID doesn't match the characteristic base UUID.
mp_raise_ValueError(translate("Characteristic UUID doesn't match Service UUID"));
}
mp_obj_list_append(char_list, characteristic);
mp_obj_list_append(char_list_obj, characteristic_obj);
}
common_hal_bleio_service_construct(self, uuid_obj, char_list_obj, is_secondary);
common_hal_bleio_service_construct(self, uuid, char_list, is_secondary);
return MP_OBJ_FROM_PTR(self);
}