diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-05-31 18:03:05 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2019-05-31 18:03:05 -0400 |
| commit | 12f1d9d30cf6e8c73db2eac5512c332cfde3031f (patch) | |
| tree | ce56ab85a45ca1868db75c5f9abf5f60f1f847a5 | |
| parent | 6cec81bcb54fe69d179f6596d8dae96b6f3beea2 (diff) | |
fix advertisement length check; add Service.secondary attribute
| -rw-r--r-- | ports/nrf/common-hal/bleio/Peripheral.c | 2 | ||||
| -rw-r--r-- | shared-bindings/bleio/Service.c | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 83191d487..4aff75c9b 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -52,7 +52,7 @@ static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; STATIC void check_data_fit(size_t pos, size_t data_len) { - if (pos + data_len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) { + if (pos + data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { mp_raise_ValueError(translate("Data too large for advertisement packet")); } } diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index c3be26260..d9bc4021f 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -118,6 +118,24 @@ const mp_obj_property_t bleio_service_characteristics_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. attribute:: secondary +//| +//| True if this is a secondary service. (read-only) +//| +STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) { + bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_bool(self->is_secondary); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_secondary_obj, bleio_service_get_secondary); + +const mp_obj_property_t bleio_service_secondary_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_service_get_secondary_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + //| .. attribute:: uuid //| //| The UUID of this service. (read-only) @@ -138,6 +156,7 @@ const mp_obj_property_t bleio_service_uuid_obj = { STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_characteristics), MP_ROM_PTR(&bleio_service_characteristics_obj) }, + { MP_ROM_QSTR(MP_QSTR_secondary), MP_ROM_PTR(&bleio_service_secondary_obj) }, { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_service_uuid_obj) }, }; |
