Skip to content

Commit d047b73

Browse files
committed
fix newly-introduced bugs; UART client/server working again
1 parent d74c8b9 commit d047b73

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

ports/nrf/common-hal/bleio/Service.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self)
7373
MP_OBJ_TO_PTR(self->characteristic_list->items[characteristic_idx]);
7474

7575
ble_gatts_char_md_t char_md = {
76-
.char_props.broadcast = (bool) characteristic->props & CHAR_PROP_BROADCAST,
77-
.char_props.read = (bool) characteristic->props & CHAR_PROP_READ,
78-
.char_props.write_wo_resp = (bool) characteristic->props & CHAR_PROP_WRITE_NO_RESPONSE,
79-
.char_props.write = (bool) characteristic->props & CHAR_PROP_WRITE,
80-
.char_props.notify = (bool) characteristic->props & CHAR_PROP_NOTIFY,
81-
.char_props.indicate = (bool) characteristic->props & CHAR_PROP_INDICATE,
76+
.char_props.broadcast = (characteristic->props & CHAR_PROP_BROADCAST) ? 1 : 0,
77+
.char_props.read = (characteristic->props & CHAR_PROP_READ) ? 1 : 0,
78+
.char_props.write_wo_resp = (characteristic->props & CHAR_PROP_WRITE_NO_RESPONSE) ? 1 : 0,
79+
.char_props.write = (characteristic->props & CHAR_PROP_WRITE) ? 1 : 0,
80+
.char_props.notify = (characteristic->props & CHAR_PROP_NOTIFY) ? 1 : 0,
81+
.char_props.indicate = (characteristic->props & CHAR_PROP_INDICATE) ? 1 : 0,
8282
};
8383

8484
ble_gatts_attr_md_t cccd_md = {

ports/nrf/common-hal/bleio/__init__.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, mp_ob
195195
bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
196196
characteristic->base.type = &bleio_characteristic_type;
197197

198-
characteristic->descriptor_list = mp_obj_new_list(0, NULL);
199-
200198
bleio_uuid_obj_t *uuid = NULL;
201199

202200
if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
@@ -219,7 +217,8 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, mp_ob
219217
(gattc_char->char_props.write_wo_resp ? CHAR_PROP_WRITE_NO_RESPONSE : 0);
220218

221219
// Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler.
222-
common_hal_bleio_characteristic_construct(characteristic, uuid, props, SEC_MODE_OPEN, SEC_MODE_OPEN, mp_const_empty_tuple);
220+
common_hal_bleio_characteristic_construct(
221+
characteristic, uuid, props, SEC_MODE_OPEN, SEC_MODE_OPEN, mp_obj_new_list(0, NULL));
223222
characteristic->handle = gattc_char->handle_value;
224223
characteristic->service = m_char_discovery_service;
225224

shared-bindings/bleio/Characteristic.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
9696
bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t);
9797
self->base.type = &bleio_characteristic_type;
9898

99-
// If descriptors is not an iterable, an exception will be thrown.
100-
mp_obj_iter_buf_t iter_buf;
101-
mp_obj_t iterable = mp_getiter(args[ARG_descriptors].u_obj, &iter_buf);
102-
103-
// Copy the descriptors list and validate its items.
99+
// Copy the descriptors list and validate its items.
104100
mp_obj_t desc_list_obj = mp_obj_new_list(0, NULL);
105101
mp_obj_list_t *desc_list = MP_OBJ_TO_PTR(desc_list_obj);
106102

103+
// If descriptors is not an iterable, an exception will be thrown.
104+
mp_obj_iter_buf_t iter_buf;
105+
mp_obj_t descriptors_iter = mp_getiter(descriptors, &iter_buf);
106+
107107
mp_obj_t descriptor_obj;
108-
while ((descriptor_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
108+
while ((descriptor_obj = mp_iternext(descriptors_iter)) != MP_OBJ_STOP_ITERATION) {
109109
if (!MP_OBJ_IS_TYPE(descriptor_obj, &bleio_descriptor_type)) {
110110
mp_raise_ValueError(translate("descriptors includes an object that is not a Descriptors"));
111111
}

shared-bindings/bleio/__init__.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "shared-bindings/bleio/__init__.h"
3030
#include "shared-bindings/bleio/Address.h"
31+
#include "shared-bindings/bleio/Attribute.h"
3132
#include "shared-bindings/bleio/Central.h"
3233
#include "shared-bindings/bleio/Characteristic.h"
3334
#include "shared-bindings/bleio/CharacteristicBuffer.h"
@@ -80,6 +81,7 @@
8081
STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
8182
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) },
8283
{ MP_ROM_QSTR(MP_QSTR_Address), MP_ROM_PTR(&bleio_address_type) },
84+
{ MP_ROM_QSTR(MP_QSTR_Attribute), MP_ROM_PTR(&bleio_attribute_type) },
8385
{ MP_ROM_QSTR(MP_QSTR_Central), MP_ROM_PTR(&bleio_central_type) },
8486
{ MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) },
8587
{ MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) },

0 commit comments

Comments
 (0)