From 7390dc7dab2c5ccd34a1fa5a33e1e5241b8f9bd7 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Tue, 17 Jul 2018 17:00:37 +0200 Subject: bleio: Move ScanEntry to shared module and add a new AdvertisementData class --- shared-bindings/bleio/ScanEntry.c | 307 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 shared-bindings/bleio/ScanEntry.c (limited to 'shared-bindings/bleio/ScanEntry.c') diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c new file mode 100644 index 000000000..f41665581 --- /dev/null +++ b/shared-bindings/bleio/ScanEntry.c @@ -0,0 +1,307 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Artur Pacholec + * 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 + +#include "py/objarray.h" +#include "py/objproperty.h" +#include "py/objstr.h" +#include "py/objtuple.h" +#include "shared-bindings/bleio/Address.h" +#include "shared-module/bleio/AdvertisementData.h" +#include "shared-bindings/bleio/UUID.h" +#include "shared-bindings/bleio/ScanEntry.h" + +//| .. currentmodule:: bleio +//| +//| :class:`ScanEntry` -- BLE scan response entry +//| ========================================================= +//| +//| Encapsulates information about a device that was received as a +//| response to a BLE scan request. +//| + +//| .. attribute:: address +//| +//| The address of the device. (read-only) +//| This attribute is of type `bleio:Address`. +//| + +//| .. attribute:: manufacturer_specific_data +//| +//| The manufacturer-specific data present in the advertisement packet. (read-only) +//| + +//| .. attribute:: name +//| +//| The name of the device. (read-only) +//| This attribute might be `None` if the data was missing from the advertisement packet. +//| + +//| .. attribute:: raw_data +//| +//| All the advertisement data present in the packet. (read-only) +//| + +//| .. attribute:: rssi +//| +//| The signal strength of the device at the time of the scan. (read-only) +//| + +//| .. attribute:: service_uuids +//| +//| The address of the device. (read-only) +//| This attribute is a list of `bleio:UUID`. +//| This attribute might be empty or incomplete, depending on the advertisement packet. +//| Currently only 16-bit UUIDS are listed. +//| + +//| .. attribute:: tx_power_level +//| +//| The transmit power level of the device. (read-only) +//| This attribute might be `None` if the data was missing from the advertisement packet. +//| +static uint8_t find_data_item(mp_obj_array_t *data_in, uint8_t type, uint8_t **data_out) { + uint16_t i = 0; + while (i < data_in->len) { + const uint8_t item_len = ((uint8_t*)data_in->items)[i]; + const uint8_t item_type = ((uint8_t*)data_in->items)[i + 1]; + if (item_type != type) { + i += (item_len + 1); + continue; + } + + *data_out = &((uint8_t*)data_in->items)[i + 2]; + + return item_len; + } + + return 0; +} + +STATIC mp_obj_t scanentry_get_name(mp_obj_t self_in); + +STATIC void bleio_scanentry_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_scanentry_obj_t *self = (bleio_scanentry_obj_t *)self_in; + mp_printf(print, "ScanEntry(address: "HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT"", + self->address.value[5], self->address.value[4], self->address.value[3], + self->address.value[1], self->address.value[1], self->address.value[0]); + + const mp_obj_t name_obj = scanentry_get_name(self_in); + if (name_obj != mp_const_none) { + mp_obj_str_t *str = MP_OBJ_TO_PTR(name_obj); + mp_printf(print, " name: %s", str->data); + } + + mp_print_str(print, ")"); +} + +STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_t obj = bleio_address_type.make_new(&bleio_address_type, 1, 0, (mp_obj_t)&mp_const_none_obj); + bleio_address_obj_t *address = MP_OBJ_TO_PTR(obj); + + address->type = self->address.type; + memcpy(address->value, self->address.value, BLEIO_ADDRESS_BYTES); + + return obj; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_address_obj, bleio_scanentry_get_address); + +const mp_obj_property_t bleio_scanentry_address_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bluepy_scanentry_get_address_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanentry_get_manufacturer_specific_data(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data); + uint8_t *manuf_data; + + const uint8_t manuf_data_len = find_data_item(data, AdManufacturerSpecificData, &manuf_data); + if (manuf_data_len == 0) { + return mp_const_none; + } + + return mp_obj_new_bytearray_by_ref(manuf_data_len, manuf_data); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(scanentry_get_manufacturer_specific_data_obj, scanentry_get_manufacturer_specific_data); + +const mp_obj_property_t bleio_scanentry_manufacturer_specific_data_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&scanentry_get_manufacturer_specific_data_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanentry_get_name(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data); + uint8_t *name; + + // Try for Complete but settle for Shortened + uint8_t name_len = find_data_item(data, AdCompleteLocalName, &name); + if (name_len == 0) { + name_len = find_data_item(data, AdShortenedLocalName, &name); + } + + if (name_len == 0) { + return mp_const_none; + } + + return mp_obj_new_str((const char*)name, name_len - 1, false); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_name_obj, scanentry_get_name); + +const mp_obj_property_t bleio_scanentry_name_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bluepy_scanentry_get_name_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanentry_get_raw_data(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_obj_t entries = mp_obj_new_list(0, NULL); + + mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data); + + uint16_t i = 0; + while (i < data->len) { + mp_obj_tuple_t *entry = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL)); + + const uint8_t item_len = ((uint8_t*)data->items)[i]; + const uint8_t item_type = ((uint8_t*)data->items)[i + 1]; + + entry->items[0] = MP_OBJ_NEW_SMALL_INT(item_type); + entry->items[1] = mp_obj_new_bytearray(item_len - 1, &((uint8_t*)data->items)[i + 2]); + mp_obj_list_append(entries, MP_OBJ_FROM_PTR(entry)); + + i += (item_len + 1); + } + + return entries; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_raw_data_obj, scanentry_get_raw_data); + +const mp_obj_property_t bleio_scanentry_raw_data_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_scanentry_get_raw_data_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanentry_get_rssi(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_int(self->rssi); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_rssi_obj, scanentry_get_rssi); + +const mp_obj_property_t bleio_scanentry_rssi_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bluepy_scanentry_get_rssi_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanentry_get_service_uuids(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data); + uint8_t *uuids; + + // Try for Complete but settle for Incomplete + uint8_t uuids_len = find_data_item(data, AdCompleteListOf16BitServiceClassUUIDs, &uuids); + if (uuids_len == 0) { + uuids_len = find_data_item(data, AdIncompleteListOf16BitServiceClassUUIDs, &uuids); + } + + mp_obj_t entries = mp_obj_new_list(0, NULL); + for (size_t i = 0; i < uuids_len / sizeof(uint16_t); ++i) { + const mp_obj_t uuid_int = mp_obj_new_int(uuids[sizeof(uint16_t) * i] | (uuids[sizeof(uint16_t) * i + 1] << 8)); + const mp_obj_t uuid_obj = bleio_uuid_type.make_new(&bleio_uuid_type, 1, 0, &uuid_int); + + mp_obj_list_append(entries, uuid_obj); + } + + // TODO: 32-bit UUIDs + // TODO: 128-bit UUIDs + + return entries; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(scanentry_get_service_uuids_obj, scanentry_get_service_uuids); + +const mp_obj_property_t bleio_scanentry_service_uuids_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&scanentry_get_service_uuids_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanentry_get_tx_power_level(mp_obj_t self_in) { + bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data); + uint8_t *tx_power; + + const uint8_t tx_power_len = find_data_item(data, AdTxPowerLevel, &tx_power); + if (tx_power_len == 0) { + return mp_const_none; + } + + return mp_obj_new_int((int8_t)(*tx_power)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(scanentry_get_tx_power_level_obj, scanentry_get_tx_power_level); + +const mp_obj_property_t bleio_scanentry_tx_power_level_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&scanentry_get_tx_power_level_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC const mp_rom_map_elem_t bleio_scanentry_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_address), MP_ROM_PTR(&bleio_scanentry_address_obj) }, + { MP_ROM_QSTR(MP_QSTR_manufacturer_specific_data), MP_ROM_PTR(&bleio_scanentry_manufacturer_specific_data_obj) }, + { MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_scanentry_name_obj) }, + { MP_ROM_QSTR(MP_QSTR_raw_data), MP_ROM_PTR(&bleio_scanentry_raw_data_obj) }, + { MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&bleio_scanentry_rssi_obj) }, + { MP_ROM_QSTR(MP_QSTR_service_uuids), MP_ROM_PTR(&bleio_scanentry_service_uuids_obj) }, + { MP_ROM_QSTR(MP_QSTR_tx_power_level), MP_ROM_PTR(&bleio_scanentry_tx_power_level_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_dict_table); + +const mp_obj_type_t bleio_scanentry_type = { + { &mp_type_type }, + .name = MP_QSTR_ScanEntry, + .print = bleio_scanentry_print, + .locals_dict = (mp_obj_dict_t*)&bleio_scanentry_locals_dict +}; -- cgit v1.2.3 From 1c6bf9a15061d64ea097a024d73ad0a6da8f8e2b Mon Sep 17 00:00:00 2001 From: arturo182 Date: Wed, 18 Jul 2018 10:22:11 +0200 Subject: bleio: Move the Scanner class to a shared module --- ports/nrf/Makefile | 2 +- ports/nrf/common-hal/bleio/Scanner.c | 59 ++++++++++ ports/nrf/drivers/bluetooth/ble_drv.c | 19 ++-- ports/nrf/drivers/bluetooth/ble_drv.h | 8 +- ports/nrf/modules/ubluepy/modubluepy.c | 4 - ports/nrf/modules/ubluepy/modubluepy.h | 6 -- ports/nrf/modules/ubluepy/ubluepy_scanner.c | 118 -------------------- shared-bindings/bleio/ScanEntry.c | 4 +- shared-bindings/bleio/Scanner.c | 161 ++++++++++++++++++++++++++++ shared-bindings/bleio/Scanner.h | 38 +++++++ shared-bindings/bleio/__init__.c | 3 + shared-module/bleio/Scanner.h | 39 +++++++ 12 files changed, 317 insertions(+), 144 deletions(-) create mode 100644 ports/nrf/common-hal/bleio/Scanner.c delete mode 100644 ports/nrf/modules/ubluepy/ubluepy_scanner.c create mode 100644 shared-bindings/bleio/Scanner.c create mode 100644 shared-bindings/bleio/Scanner.h create mode 100644 shared-module/bleio/Scanner.h (limited to 'shared-bindings/bleio/ScanEntry.c') diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index c5e0df02f..3873f2cbc 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -134,7 +134,6 @@ DRIVERS_SRC_C += $(addprefix modules/,\ ubluepy/ubluepy_characteristic.c \ ubluepy/ubluepy_delegate.c \ ubluepy/ubluepy_constants.c \ - ubluepy/ubluepy_scanner.c \ ) SRC_COMMON_HAL += \ @@ -167,6 +166,7 @@ SRC_COMMON_HAL += \ bleio/__init__.c \ bleio/Adapter.c \ bleio/Descriptor.c \ + bleio/Scanner.c \ bleio/UUID.c endif diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c new file mode 100644 index 000000000..ed1987144 --- /dev/null +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -0,0 +1,59 @@ +/* + * 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 + +#include "ble_drv.h" +#include "py/mphal.h" +#include "shared-bindings/bleio/Scanner.h" +#include "shared-bindings/bleio/ScanEntry.h" + +STATIC void adv_event_handler(bleio_scanner_obj_t *self, ble_drv_adv_data_t *data) { + // TODO: Don't add new entry for each item, group by address and update + bleio_scanentry_obj_t *item = m_new_obj(bleio_scanentry_obj_t); + item->base.type = &bleio_scanentry_type; + + item->rssi = data->rssi; + item->data = mp_obj_new_bytearray(data->data_len, data->p_data); + + item->address.type = data->addr_type; + memcpy(item->address.value, data->p_peer_addr, BLEIO_ADDRESS_BYTES); + + mp_obj_list_append(self->adv_reports, item); + + ble_drv_scan_continue(); +} + +void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout) { + ble_drv_adv_report_handler_set(self, adv_event_handler); + + ble_drv_scan_start(self->interval, self->window); + + mp_hal_delay_ms(timeout); + + ble_drv_scan_stop(); +} diff --git a/ports/nrf/drivers/bluetooth/ble_drv.c b/ports/nrf/drivers/bluetooth/ble_drv.c index 766660828..1d67842ef 100644 --- a/ports/nrf/drivers/bluetooth/ble_drv.c +++ b/ports/nrf/drivers/bluetooth/ble_drv.c @@ -94,7 +94,7 @@ static volatile ble_drv_disc_add_service_callback_t disc_add_service_handler; static volatile ble_drv_disc_add_char_callback_t disc_add_char_handler; static volatile ble_drv_gattc_char_data_callback_t gattc_char_data_handle; -static mp_obj_t mp_adv_observer; +static bleio_scanner_obj_t *mp_adv_observer; static mp_obj_t mp_gattc_observer; static mp_obj_t mp_gattc_disc_service_observer; static mp_obj_t mp_gattc_disc_char_observer; @@ -707,8 +707,8 @@ void ble_drv_gattc_event_handler_set(mp_obj_t obj, ble_drv_gattc_evt_callback_t gattc_event_handler = evt_handler; } -void ble_drv_adv_report_handler_set(mp_obj_t obj, ble_drv_adv_evt_callback_t evt_handler) { - mp_adv_observer = obj; +void ble_drv_adv_report_handler_set(bleio_scanner_obj_t *self, ble_drv_adv_evt_callback_t evt_handler) { + mp_adv_observer = self; adv_event_handler = evt_handler; } @@ -760,15 +760,15 @@ void ble_drv_attr_c_write(uint16_t conn_handle, uint16_t handle, uint16_t len, u ; } } -void ble_drv_scan_start(void) { +void ble_drv_scan_start(uint16_t interval, uint16_t window) { SD_TEST_OR_ENABLE(); ble_gap_scan_params_t scan_params; memset(&scan_params, 0, sizeof(ble_gap_scan_params_t)); scan_params.active = 1; - scan_params.interval = MSEC_TO_UNITS(100, UNIT_0_625_MS); - scan_params.window = MSEC_TO_UNITS(100, UNIT_0_625_MS); + scan_params.interval = MSEC_TO_UNITS(interval, UNIT_0_625_MS); + scan_params.window = MSEC_TO_UNITS(window, UNIT_0_625_MS); #if (BLUETOOTH_SD == 140) scan_params.scan_phys = BLE_GAP_PHY_1MBPS; #endif @@ -1003,10 +1003,9 @@ static void ble_evt_handler(ble_evt_t * p_ble_evt) { #endif }; - // TODO: Fix unsafe callback to possible undefined callback... - adv_event_handler(mp_adv_observer, - p_ble_evt->header.evt_id, - &adv_data); + if (adv_event_handler != NULL) { + adv_event_handler(mp_adv_observer, &adv_data); + } break; case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: diff --git a/ports/nrf/drivers/bluetooth/ble_drv.h b/ports/nrf/drivers/bluetooth/ble_drv.h index ca9a38fdd..d344e2690 100644 --- a/ports/nrf/drivers/bluetooth/ble_drv.h +++ b/ports/nrf/drivers/bluetooth/ble_drv.h @@ -32,6 +32,8 @@ #include #include +#include "shared-module/bleio/Scanner.h" + #include "modubluepy.h" typedef struct { @@ -67,7 +69,7 @@ typedef struct { typedef void (*ble_drv_gap_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data); typedef void (*ble_drv_gatts_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data); typedef void (*ble_drv_gattc_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data); -typedef void (*ble_drv_adv_evt_callback_t)(mp_obj_t self, uint16_t event_id, ble_drv_adv_data_t * data); +typedef void (*ble_drv_adv_evt_callback_t)(bleio_scanner_obj_t *self, ble_drv_adv_data_t *data); typedef void (*ble_drv_disc_add_service_callback_t)(mp_obj_t self, ble_drv_service_data_t * p_service_data); typedef void (*ble_drv_disc_add_char_callback_t)(mp_obj_t self, ble_drv_char_data_t * p_desc_data); typedef void (*ble_drv_gattc_char_data_callback_t)(mp_obj_t self, uint16_t length, uint8_t * p_data); @@ -106,13 +108,13 @@ void ble_drv_attr_s_notify(uint16_t conn_handle, uint16_t handle, uint16_t len, void ble_drv_attr_c_write(uint16_t conn_handle, uint16_t handle, uint16_t len, uint8_t * p_data, bool w_response); -void ble_drv_scan_start(void); +void ble_drv_scan_start(uint16_t interval, uint16_t window); void ble_drv_scan_continue(void); void ble_drv_scan_stop(void); -void ble_drv_adv_report_handler_set(mp_obj_t obj, ble_drv_adv_evt_callback_t evt_handler); +void ble_drv_adv_report_handler_set(bleio_scanner_obj_t *self, ble_drv_adv_evt_callback_t evt_handler); void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type); diff --git a/ports/nrf/modules/ubluepy/modubluepy.c b/ports/nrf/modules/ubluepy/modubluepy.c index 034cc806c..e817983fa 100644 --- a/ports/nrf/modules/ubluepy/modubluepy.c +++ b/ports/nrf/modules/ubluepy/modubluepy.c @@ -33,7 +33,6 @@ 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_delegate_type; extern const mp_obj_type_t ubluepy_constants_type; -extern const mp_obj_type_t ubluepy_scanner_type; STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubluepy) }, @@ -42,9 +41,6 @@ STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = { #endif #if 0 // MICROPY_PY_UBLUEPY_CENTRAL { MP_ROM_QSTR(MP_QSTR_Central), MP_ROM_PTR(&ubluepy_central_type) }, -#endif -#if MICROPY_PY_UBLUEPY_CENTRAL - { MP_ROM_QSTR(MP_QSTR_Scanner), MP_ROM_PTR(&ubluepy_scanner_type) }, #endif { MP_ROM_QSTR(MP_QSTR_DefaultDelegate), MP_ROM_PTR(&ubluepy_delegate_type) }, { MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&ubluepy_service_type) }, diff --git a/ports/nrf/modules/ubluepy/modubluepy.h b/ports/nrf/modules/ubluepy/modubluepy.h index 8fb9fadd0..f51cc9e87 100644 --- a/ports/nrf/modules/ubluepy/modubluepy.h +++ b/ports/nrf/modules/ubluepy/modubluepy.h @@ -77,7 +77,6 @@ p.advertise(device_name="micr", services=[s]) 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_peripheral_type; -extern const mp_obj_type_t ubluepy_scanner_type; extern const mp_obj_type_t ubluepy_constants_type; extern const mp_obj_type_t ubluepy_constants_ad_types_type; @@ -147,11 +146,6 @@ typedef struct _ubluepy_advertise_data_t { bool connectable; } ubluepy_advertise_data_t; -typedef struct _ubluepy_scanner_obj_t { - mp_obj_base_t base; - mp_obj_t adv_reports; -} ubluepy_scanner_obj_t; - typedef enum _ubluepy_prop_t { UBLUEPY_PROP_BROADCAST = 0x01, UBLUEPY_PROP_READ = 0x02, diff --git a/ports/nrf/modules/ubluepy/ubluepy_scanner.c b/ports/nrf/modules/ubluepy/ubluepy_scanner.c deleted file mode 100644 index 9d15037a5..000000000 --- a/ports/nrf/modules/ubluepy/ubluepy_scanner.c +++ /dev/null @@ -1,118 +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 -#include "py/obj.h" -#include "py/runtime.h" -#include "py/objstr.h" -#include "py/objlist.h" -#include "py/mphal.h" - -#if MICROPY_PY_UBLUEPY_CENTRAL - -#include "shared-bindings/bleio/ScanEntry.h" -#include "ble_drv.h" - -STATIC void adv_event_handler(mp_obj_t self_in, uint16_t event_id, ble_drv_adv_data_t * data) { - ubluepy_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); - - // TODO: Don't add new entry for each item, group by address and update - bleio_scanentry_obj_t *item = m_new_obj(bleio_scanentry_obj_t); - item->base.type = &bleio_scanentry_type; - - item->rssi = data->rssi; - item->data = mp_obj_new_bytearray(data->data_len, data->p_data); - - item->address.type = data->addr_type; - memcpy(item->address.value, data->p_peer_addr, BLEIO_ADDRESS_BYTES); - - mp_obj_list_append(self->adv_reports, item); - - ble_drv_scan_continue(); -} - -STATIC void ubluepy_scanner_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) { - ubluepy_scanner_obj_t * self = (ubluepy_scanner_obj_t *)o; - (void)self; - mp_printf(print, "Scanner"); -} - -STATIC mp_obj_t ubluepy_scanner_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - static const mp_arg_t allowed_args[] = { - - }; - - // 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_scanner_obj_t * s = m_new_obj(ubluepy_scanner_obj_t); - s->base.type = type; - - return MP_OBJ_FROM_PTR(s); -} - -/// \method scan(timeout) -/// Scan for devices. Timeout is in milliseconds and will set the duration -/// of the scanning. -/// -STATIC mp_obj_t scanner_scan(mp_obj_t self_in, mp_obj_t timeout_in) { - ubluepy_scanner_obj_t * self = MP_OBJ_TO_PTR(self_in); - mp_int_t timeout = mp_obj_get_int(timeout_in); - - self->adv_reports = mp_obj_new_list(0, NULL); - - ble_drv_adv_report_handler_set(MP_OBJ_FROM_PTR(self), adv_event_handler); - - // start - ble_drv_scan_start(); - - // sleep - mp_hal_delay_ms(timeout); - - // stop - ble_drv_scan_stop(); - - return self->adv_reports; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_scanner_scan_obj, scanner_scan); - -STATIC const mp_rom_map_elem_t ubluepy_scanner_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&ubluepy_scanner_scan_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(ubluepy_scanner_locals_dict, ubluepy_scanner_locals_dict_table); - - -const mp_obj_type_t ubluepy_scanner_type = { - { &mp_type_type }, - .name = MP_QSTR_Scanner, - .print = ubluepy_scanner_print, - .make_new = ubluepy_scanner_make_new, - .locals_dict = (mp_obj_dict_t*)&ubluepy_scanner_locals_dict -}; - -#endif // MICROPY_PY_UBLUEPY_CENTRAL diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index f41665581..e38a08909 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -48,7 +48,7 @@ //| .. attribute:: address //| //| The address of the device. (read-only) -//| This attribute is of type `bleio:Address`. +//| This attribute is of type `bleio.Address`. //| //| .. attribute:: manufacturer_specific_data @@ -75,7 +75,7 @@ //| .. attribute:: service_uuids //| //| The address of the device. (read-only) -//| This attribute is a list of `bleio:UUID`. +//| This attribute is a list of `bleio.UUID`. //| This attribute might be empty or incomplete, depending on the advertisement packet. //| Currently only 16-bit UUIDS are listed. //| diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c new file mode 100644 index 000000000..00e29d9d5 --- /dev/null +++ b/shared-bindings/bleio/Scanner.c @@ -0,0 +1,161 @@ +/* + * 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. + */ + +#include "py/objproperty.h" +#include "shared-bindings/bleio/ScanEntry.h" +#include "shared-bindings/bleio/Scanner.h" + +#define DEFAULT_INTERVAL 100 +#define DEFAULT_WINDOW 100 + +//| .. currentmodule:: bleio +//| +//| :class:`Scanner` -- scan for nearby BLE devices +//| ========================================================= +//| +//| Allows scanning for nearby BLE devices. +//| +//| Usage:: +//| +//| import bleio +//| scanner = bleio.Scanner() +//| entries = scanner.scan(2500) +//| print(entries) +//| + +//| .. class:: Scanner() +//| +//| Create a new Scanner object. +//| + +//| .. attribute:: interval +//| +//| The interval (in ms) between the start of two consecutive scan windows. +//| Allowed values are between 10ms and 10.24 sec. +//| + +//| .. attribute:: window +//| +//| The duration (in ms) in which a single BLE channel is scanned. +//| Allowed values are between 10ms and 10.24 sec. +//| + +//| .. method:: scan(timeout) +//| +//| Performs a BLE scan lasting :py:data:`timeout` ms. +//| +//| :returns: advertising packets found +//| :rtype: list of :py:class:`bleio.ScanEntry` +//| +STATIC void bleio_scanner_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_printf(print, "Scanner(interval: %d window: %d)", self->interval, self->window); +} + +STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + bleio_scanner_obj_t *self = m_new_obj(bleio_scanner_obj_t); + self->base.type = type; + + self->interval = DEFAULT_INTERVAL; + self->window = DEFAULT_WINDOW; + + return MP_OBJ_FROM_PTR(self); +} + +STATIC mp_obj_t bleio_scanner_get_interval(mp_obj_t self_in) { + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_int(self->interval); +} +MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanner_get_interval_obj, bleio_scanner_get_interval); + +static mp_obj_t bleio_scanner_set_interval(mp_obj_t self_in, mp_obj_t value) { + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); + + self->interval = mp_obj_get_int(value); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_set_interval_obj, bleio_scanner_set_interval); + +const mp_obj_property_t bleio_scanner_interval_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_scanner_get_interval_obj, + (mp_obj_t)&bleio_scanner_set_interval_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t scanner_scan(mp_obj_t self_in, mp_obj_t timeout_in) { + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); + const mp_int_t timeout = mp_obj_get_int(timeout_in); + + self->adv_reports = mp_obj_new_list(0, NULL); + + common_hal_bleio_scanner_scan(self, timeout); + + return self->adv_reports; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_scan_obj, scanner_scan); + +STATIC mp_obj_t bleio_scanner_get_window(mp_obj_t self_in) { + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_int(self->window); +} +MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanner_get_window_obj, bleio_scanner_get_window); + +static mp_obj_t bleio_scanner_set_window(mp_obj_t self_in, mp_obj_t value) { + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); + + self->window = mp_obj_get_int(value); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_set_window_obj, bleio_scanner_set_window); + +const mp_obj_property_t bleio_scanner_window_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_scanner_get_window_obj, + (mp_obj_t)&bleio_scanner_set_window_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC const mp_rom_map_elem_t bleio_scanner_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_interval), MP_ROM_PTR(&bleio_scanner_interval_obj) }, + { MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&bleio_scanner_scan_obj) }, + { MP_ROM_QSTR(MP_QSTR_window), MP_ROM_PTR(&bleio_scanner_window_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(bleio_scanner_locals_dict, bleio_scanner_locals_dict_table); + +const mp_obj_type_t bleio_scanner_type = { + { &mp_type_type }, + .name = MP_QSTR_Scanner, + .print = bleio_scanner_print, + .make_new = bleio_scanner_make_new, + .locals_dict = (mp_obj_dict_t*)&bleio_scanner_locals_dict +}; diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h new file mode 100644 index 000000000..03db5cd8b --- /dev/null +++ b/shared-bindings/bleio/Scanner.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H + +#include "py/objtype.h" +#include "shared-module/bleio/Scanner.h" + +extern const mp_obj_type_t bleio_scanner_type; + +extern void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 315b2c32c..4ad858ac9 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -32,6 +32,7 @@ #include "shared-bindings/bleio/AdvertisementData.h" #include "shared-bindings/bleio/Descriptor.h" #include "shared-bindings/bleio/ScanEntry.h" +#include "shared-bindings/bleio/Scanner.h" #include "shared-bindings/bleio/UUID.h" #include "shared-bindings/bleio/UUIDType.h" @@ -55,6 +56,7 @@ //| Adapter //| Descriptor //| ScanEntry +//| Scanner //| UUID //| UUIDType //| @@ -71,6 +73,7 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AdvertisementData), MP_ROM_PTR(&bleio_advertisementdata_type) }, { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, { MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) }, + { MP_ROM_QSTR(MP_QSTR_Scanner), MP_ROM_PTR(&bleio_scanner_type) }, { MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) }, // Properties diff --git a/shared-module/bleio/Scanner.h b/shared-module/bleio/Scanner.h new file mode 100644 index 000000000..f1159adfe --- /dev/null +++ b/shared-module/bleio/Scanner.h @@ -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_ATMEL_SAMD_SHARED_MODULE_BLEIO_SCANNER_H +#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BLEIO_SCANNER_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + mp_obj_t adv_reports; + uint16_t interval; + uint16_t window; +} bleio_scanner_obj_t; + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BLEIO_SCANNER_H -- cgit v1.2.3 From 3bd65fbae5d0150139c0ffd4cf02f8c9f547bbf5 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Thu, 19 Jul 2018 20:33:24 +0200 Subject: nrf: Move the Peripheral class to bleio as Device This was the last class from ubluepy and so that module is now gone. The Device class offers both Peripheral and Central functionality. See the inline docs for more info. --- ports/nrf/Makefile | 5 +- ports/nrf/common-hal/bleio/Characteristic.c | 6 +- ports/nrf/common-hal/bleio/Device.c | 166 ++++++++ ports/nrf/common-hal/bleio/Scanner.c | 3 +- ports/nrf/drivers/bluetooth/ble_drv.c | 396 +++++++++---------- ports/nrf/drivers/bluetooth/ble_drv.h | 36 +- ports/nrf/drivers/bluetooth/ble_uart.h | 1 - ports/nrf/modules/ubluepy/modubluepy.c | 48 --- ports/nrf/modules/ubluepy/modubluepy.h | 126 ------ ports/nrf/modules/ubluepy/ubluepy_peripheral.c | 507 ------------------------- ports/nrf/mpconfigport.h | 33 +- shared-bindings/bleio/Device.c | 348 +++++++++++++++++ shared-bindings/bleio/Device.h | 40 ++ shared-bindings/bleio/ScanEntry.c | 5 +- shared-bindings/bleio/ScanEntry.h | 11 +- shared-bindings/bleio/Service.c | 6 +- shared-bindings/bleio/__init__.c | 3 + shared-module/bleio/AdvertisementData.h | 9 + shared-module/bleio/Device.h | 45 +++ shared-module/bleio/ScanEntry.h | 40 ++ shared-module/bleio/Service.h | 3 +- 21 files changed, 860 insertions(+), 977 deletions(-) create mode 100644 ports/nrf/common-hal/bleio/Device.c delete mode 100644 ports/nrf/modules/ubluepy/modubluepy.c delete mode 100644 ports/nrf/modules/ubluepy/modubluepy.h delete mode 100644 ports/nrf/modules/ubluepy/ubluepy_peripheral.c create mode 100644 shared-bindings/bleio/Device.c create mode 100644 shared-bindings/bleio/Device.h create mode 100644 shared-module/bleio/Device.h create mode 100644 shared-module/bleio/ScanEntry.h (limited to 'shared-bindings/bleio/ScanEntry.c') diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 6112678f5..b059569ab 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -127,10 +127,6 @@ SRC_C += \ peripherals/nrf/timers.c \ supervisor/shared/memory.c -DRIVERS_SRC_C += $(addprefix modules/,\ - ubluepy/modubluepy.c \ - ubluepy/ubluepy_peripheral.c \ - ) SRC_COMMON_HAL += \ analogio/AnalogIn.c \ @@ -163,6 +159,7 @@ SRC_COMMON_HAL += \ bleio/Adapter.c \ bleio/Characteristic.c \ bleio/Descriptor.c \ + bleio/Device.c \ bleio/Scanner.c \ bleio/Service.c \ bleio/UUID.c diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 56afc52c5..938289f2d 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -26,6 +26,7 @@ #include "ble_drv.h" #include "shared-module/bleio/Characteristic.h" +#include "shared-module/bleio/Device.h" void data_callback(bleio_characteristic_obj_t *self, uint16_t length, uint8_t *data) { self->value_data = mp_obj_new_bytearray(length, data); @@ -36,10 +37,9 @@ void common_hal_bleio_characteristic_read_value(bleio_characteristic_obj_t *self } void common_hal_bleio_characteristic_write_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { - ubluepy_peripheral_obj_t *peripheral = MP_OBJ_TO_PTR(self->service->periph); - ubluepy_role_type_t role = peripheral->role; + const bleio_device_obj_t *device = MP_OBJ_TO_PTR(self->service->device); - if (role == UBLUEPY_ROLE_PERIPHERAL) { + if (device->is_peripheral) { // TODO: Add indications if (self->props.notify) { ble_drv_attr_s_notify(self, bufinfo); diff --git a/ports/nrf/common-hal/bleio/Device.c b/ports/nrf/common-hal/bleio/Device.c new file mode 100644 index 000000000..ab2898e72 --- /dev/null +++ b/ports/nrf/common-hal/bleio/Device.c @@ -0,0 +1,166 @@ +/* + * 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. + */ + +#include + +#include "ble_drv.h" +#include "ble_gap.h" +#include "ble_gatt.h" +#include "ble_types.h" +#include "py/runtime.h" +#include "shared-bindings/bleio/Characteristic.h" +#include "shared-bindings/bleio/Device.h" +#include "shared-bindings/bleio/Service.h" +#include "shared-bindings/bleio/UUID.h" + +static volatile bool m_disc_evt_received; + +STATIC void gap_event_handler(bleio_device_obj_t *device, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data) { + if (event_id == BLE_GAP_EVT_CONNECTED) { + device->conn_handle = conn_handle; + } else if (event_id == BLE_GAP_EVT_DISCONNECTED) { + device->conn_handle = BLE_CONN_HANDLE_INVALID; + } +} + +STATIC void gatts_event_handler(bleio_device_obj_t *device, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data) { + +} + +STATIC void gattc_event_handler(bleio_device_obj_t *device, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data) { + m_disc_evt_received = true; +} + +STATIC void disc_add_service(bleio_device_obj_t *device, ble_drv_service_data_t * service_data) { + bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); + service->base.type = &bleio_service_type; + + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + uuid->base.type = &bleio_uuid_type; + uuid->type = (service_data->uuid_type == BLE_UUID_TYPE_BLE) ? UUID_TYPE_16BIT : UUID_TYPE_128BIT; + uuid->value[0] = service_data->uuid & 0xFF; + uuid->value[1] = service_data->uuid >> 8; + + service->char_list = mp_obj_new_list(0, NULL); + service->uuid = uuid; + service->device = device; + service->handle = service_data->start_handle; + service->start_handle = service_data->start_handle; + service->end_handle = service_data->end_handle; + + mp_obj_list_append(device->service_list, service); +} + +STATIC void disc_add_char(bleio_service_obj_t *service, ble_drv_char_data_t *chara_data) { + bleio_characteristic_obj_t *chara = m_new_obj(bleio_characteristic_obj_t); + chara->base.type = &bleio_characteristic_type; + + bleio_uuid_obj_t * p_uuid = m_new_obj(bleio_uuid_obj_t); + p_uuid->base.type = &bleio_uuid_type; + + chara->uuid = p_uuid; + + p_uuid->type = chara_data->uuid_type; + p_uuid->value[0] = chara_data->uuid & 0xFF; + p_uuid->value[1] = chara_data->uuid >> 8; + + // add characteristic specific data from discovery + chara->props.broadcast = chara_data->props.broadcast; + chara->props.indicate = chara_data->props.indicate; + chara->props.notify = chara_data->props.notify; + chara->props.read = chara_data->props.read; + chara->props.write = chara_data->props.write; + chara->props.write_wo_resp = chara_data->props.write_wo_resp; + chara->handle = chara_data->value_handle; + + chara->service_handle = service->handle; + chara->service = service; + + mp_obj_list_append(service->char_list, MP_OBJ_FROM_PTR(chara)); +} + + +void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bleio_advertisement_data_t *adv_data) { + if (adv_data->connectable) { + ble_drv_gap_event_handler_set(device, gap_event_handler); + ble_drv_gatts_event_handler_set(device, gatts_event_handler); + } + + ble_drv_advertise_data(adv_data); +} + +void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device) { + (void)device; + + ble_drv_advertise_stop(); +} + +void common_hal_bleio_device_connect(bleio_device_obj_t *device) { + ble_drv_gap_event_handler_set(device, gap_event_handler); + + ble_drv_connect(device); + + while (device->conn_handle == BLE_CONN_HANDLE_INVALID) { + run_background_tasks(); +// __asm volatile ("wfi"); + } + + ble_drv_gattc_event_handler_set(device, gattc_event_handler); + + // TODO: read name + + // find services + bool found_service = ble_drv_discover_services(device, BLE_GATT_HANDLE_START, disc_add_service); + while (found_service) { + const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(device->service_list); + const bleio_service_obj_t *service = service_list->items[service_list->len - 1]; + + found_service = ble_drv_discover_services(device, service->end_handle + 1, disc_add_service); + } + + // find characteristics in each service + const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(device->service_list); + for (size_t i = 0; i < service_list->len; ++i) { + bleio_service_obj_t *service = service_list->items[i]; + + bool found_char = ble_drv_discover_characteristic(device, service, service->start_handle, disc_add_char); + while (found_char) { + const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list); + const bleio_characteristic_obj_t *characteristic = char_list->items[char_list->len - 1]; + + const uint16_t next_handle = characteristic->handle + 1; + if (next_handle >= service->end_handle) { + break; + } + + found_char = ble_drv_discover_characteristic(device, service, next_handle, disc_add_char); + } + } +} + +void common_hal_bleio_device_disconnect(bleio_device_obj_t *device) { + ble_drv_disconnect(device); +} diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index ed1987144..0eb50a1f6 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -29,8 +29,9 @@ #include "ble_drv.h" #include "py/mphal.h" -#include "shared-bindings/bleio/Scanner.h" #include "shared-bindings/bleio/ScanEntry.h" +#include "shared-bindings/bleio/Scanner.h" +#include "shared-module/bleio/ScanEntry.h" STATIC void adv_event_handler(bleio_scanner_obj_t *self, ble_drv_adv_data_t *data) { // TODO: Don't add new entry for each item, group by address and update diff --git a/ports/nrf/drivers/bluetooth/ble_drv.c b/ports/nrf/drivers/bluetooth/ble_drv.c index e421036ae..1ab1d9337 100644 --- a/ports/nrf/drivers/bluetooth/ble_drv.c +++ b/ports/nrf/drivers/bluetooth/ble_drv.c @@ -4,6 +4,7 @@ * 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 @@ -34,6 +35,8 @@ #define NRF52 // Needed for SD132 v2 #endif +#include "shared-module/bleio/Device.h" +#include "py/objstr.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" #include "ble_drv.h" @@ -41,15 +44,10 @@ #include "nrf_sdm.h" #include "nrfx_power.h" #include "ble_gap.h" +#include "ble_hci.h" #include "ble.h" // sd_ble_uuid_encode - -#define BLE_DRIVER_VERBOSE 0 -#if BLE_DRIVER_VERBOSE #define BLE_DRIVER_LOG printf -#else -#define BLE_DRIVER_LOG(...) -#endif #define BLE_ADV_LENGTH_FIELD_SIZE 1 #define BLE_ADV_AD_TYPE_FIELD_SIZE 1 @@ -61,8 +59,8 @@ #define APP_CFG_NON_CONN_ADV_TIMEOUT 0 // Disable timeout. #define NON_CONNECTABLE_ADV_INTERVAL MSEC_TO_UNITS(100, UNIT_0_625_MS) -#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(12, UNIT_0_625_MS) -#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(12, UNIT_0_625_MS) +#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS) +#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(300, UNIT_0_625_MS) #define BLE_SLAVE_LATENCY 0 #define BLE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) @@ -81,8 +79,8 @@ static volatile bool m_tx_in_progress; static ble_drv_gap_evt_callback_t gap_event_handler; static ble_drv_gatts_evt_callback_t gatts_event_handler; -static mp_obj_t mp_gap_observer; -static mp_obj_t mp_gatts_observer; +static bleio_device_obj_t *mp_gap_observer; +static bleio_device_obj_t *mp_gatts_observer; static volatile bool m_primary_service_found; static volatile bool m_characteristic_found; @@ -95,10 +93,11 @@ static volatile ble_drv_disc_add_char_callback_t disc_add_char_handler; static volatile ble_drv_gattc_char_data_callback_t gattc_char_data_handle; static bleio_scanner_obj_t *mp_adv_observer; -static mp_obj_t mp_gattc_observer; -static mp_obj_t mp_gattc_disc_service_observer; -static mp_obj_t mp_gattc_disc_char_observer; +static bleio_device_obj_t *mp_gattc_observer; +static bleio_device_obj_t *mp_gattc_disc_service_observer; +static bleio_service_obj_t *mp_gattc_disc_char_observer; static bleio_characteristic_obj_t *mp_gattc_char_data_observer; +static bleio_address_obj_t *mp_connect_address; #if (BLUETOOTH_SD == 140) static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; @@ -123,18 +122,6 @@ uint32_t ble_drv_stack_enable(void) { m_adv_in_progress = false; m_tx_in_progress = false; -#if BLUETOOTH_LFCLK_RC - nrf_clock_lf_cfg_t clock_config = { - .source = NRF_CLOCK_LF_SRC_RC, - .rc_ctiv = 16, - .rc_temp_ctiv = 2, -#if (BLE_API_VERSION == 4) - .accuracy = 0 -#else - .xtal_accuracy = 0 -#endif - }; -#else nrf_clock_lf_cfg_t clock_config = { .source = NRF_CLOCK_LF_SRC_XTAL, .rc_ctiv = 0, @@ -145,23 +132,22 @@ uint32_t ble_drv_stack_enable(void) { .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM #endif }; -#endif #if (BLUETOOTH_SD == 140) // The SD takes over the POWER IRQ and will fail if the IRQ is already in use nrfx_power_uninit(); #endif - uint32_t err_code = sd_softdevice_enable(&clock_config, - softdevice_assert_handler); - - BLE_DRIVER_LOG("SoftDevice enable status: " UINT_FMT "\n", (uint16_t)err_code); + uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler); + if (err_code != NRF_SUCCESS) + BLE_DRIVER_LOG("SoftDevice enable status: " UINT_FMT "\n", (uint16_t)err_code); - err_code = sd_nvic_EnableIRQ(SWI2_EGU2_IRQn); - - BLE_DRIVER_LOG("IRQ enable status: " UINT_FMT "\n", (uint16_t)err_code); + err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); + if (err_code != NRF_SUCCESS) + BLE_DRIVER_LOG("IRQ enable status: " UINT_FMT "\n", (uint16_t)err_code); // Enable BLE stack. + uint32_t app_ram_start; #if (BLE_API_VERSION == 2) ble_enable_params_t ble_enable_params; memset(&ble_enable_params, 0x00, sizeof(ble_enable_params)); @@ -169,48 +155,17 @@ uint32_t ble_drv_stack_enable(void) { ble_enable_params.gatts_enable_params.service_changed = 0; ble_enable_params.gap_enable_params.periph_conn_count = 1; ble_enable_params.gap_enable_params.central_conn_count = 1; -#endif -#if (BLE_API_VERSION == 2) - uint32_t app_ram_start = 0x200039c0; + app_ram_start = 0x200039c0; err_code = sd_ble_enable(&ble_enable_params, &app_ram_start); // 8K SD headroom from linker script. - BLE_DRIVER_LOG("BLE ram size: " UINT_FMT "\n", (uint16_t)app_ram_start); #else - uint32_t app_ram_start = 0x20004000; + app_ram_start = 0x20004000; err_code = sd_ble_enable(&app_ram_start); - BLE_DRIVER_LOG("BLE ram size: " UINT_FMT "\n", (uint16_t)app_ram_start); #endif - - BLE_DRIVER_LOG("BLE enable status: " UINT_FMT "\n", (uint16_t)err_code); - - // set up security mode - ble_gap_conn_params_t gap_conn_params; - ble_gap_conn_sec_mode_t sec_mode; - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); - - const char device_name[] = "micr"; - - if ((err_code = sd_ble_gap_device_name_set(&sec_mode, - (const uint8_t *)device_name, - strlen(device_name))) != 0) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - translate("Cannot apply GAP parameters."))); - } - - // set connection parameters - memset(&gap_conn_params, 0, sizeof(gap_conn_params)); - - gap_conn_params.min_conn_interval = BLE_MIN_CONN_INTERVAL; - gap_conn_params.max_conn_interval = BLE_MAX_CONN_INTERVAL; - gap_conn_params.slave_latency = BLE_SLAVE_LATENCY; - gap_conn_params.conn_sup_timeout = BLE_CONN_SUP_TIMEOUT; - - if (sd_ble_gap_ppcp_set(&gap_conn_params) != 0) { - - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - translate("Cannot set PPCP parameters."))); + if (err_code != NRF_SUCCESS) { + BLE_DRIVER_LOG("BLE ram size: " UINT_FMT "\n", (uint16_t)app_ram_start); + BLE_DRIVER_LOG("BLE enable status: " UINT_FMT "\n", (uint16_t)err_code); } return err_code; @@ -223,9 +178,10 @@ void ble_drv_stack_disable(void) { uint8_t ble_drv_stack_enabled(void) { uint8_t is_enabled; uint32_t err_code = sd_softdevice_is_enabled(&is_enabled); - (void)err_code; - BLE_DRIVER_LOG("Is enabled status: " UINT_FMT "\n", (uint16_t)err_code); + if (err_code != NRF_SUCCESS) { + BLE_DRIVER_LOG("Is enabled status: " UINT_FMT "\n", (uint16_t)err_code); + } return is_enabled; } @@ -256,10 +212,10 @@ void ble_drv_address_get(ble_drv_addr_t * p_addr) { memcpy(p_addr->addr, local_ble_addr.addr, 6); } -bool ble_drv_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx) { +bool ble_drv_uuid_add_vs(uint8_t *uuid, uint8_t *idx) { SD_TEST_OR_ENABLE(); - if (sd_ble_uuid_vs_add((ble_uuid128_t const *)p_uuid, idx) != 0) { + if (sd_ble_uuid_vs_add((ble_uuid128_t const *)uuid, idx) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("Can not add Vendor Specific 128-bit UUID."))); } @@ -284,9 +240,7 @@ void ble_drv_service_add(bleio_service_obj_t *service) { service_type = BLE_GATTS_SRVC_TYPE_SECONDARY; } - if (sd_ble_gatts_service_add(service_type, - &uuid, - &service->handle) != 0) { + if (sd_ble_gatts_service_add(service_type, &uuid, &service->handle) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("Can not add Service."))); } @@ -372,59 +326,66 @@ bool ble_drv_characteristic_add(bleio_characteristic_obj_t *characteristic) { return true; } -bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { +// TODO: Replace with just bleio_device_obj_t + data +bool ble_drv_advertise_data(bleio_advertisement_data_t *adv_params) { SD_TEST_OR_ENABLE(); uint8_t byte_pos = 0; uint8_t adv_data[BLE_GAP_ADV_MAX_SIZE]; - if (p_adv_params->device_name_len > 0) { - ble_gap_conn_sec_mode_t sec_mode; + GET_STR_DATA_LEN(adv_params->device_name, name_data, name_len); + if (name_len > 0) { + ble_gap_conn_sec_mode_t sec_mode; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); if (sd_ble_gap_device_name_set(&sec_mode, - p_adv_params->p_device_name, - p_adv_params->device_name_len) != 0) { + name_data, + name_len) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("Can not apply device name in the stack."))); } - BLE_DRIVER_LOG("Device name applied\n"); - - adv_data[byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + p_adv_params->device_name_len); + adv_data[byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + name_len); byte_pos += BLE_ADV_LENGTH_FIELD_SIZE; + + // TODO: Shorten if too long adv_data[byte_pos] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME; byte_pos += BLE_ADV_AD_TYPE_FIELD_SIZE; - memcpy(&adv_data[byte_pos], p_adv_params->p_device_name, p_adv_params->device_name_len); - // increment position counter to see if it fits, and in case more content should - // follow in this adv packet. - byte_pos += p_adv_params->device_name_len; + + memcpy(&adv_data[byte_pos], name_data, name_len); + + byte_pos += name_len; } - // Add FLAGS only if manually controlled data has not been used. - if (p_adv_params->data_len == 0) { - // set flags, default to disc mode + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(adv_params->data, &bufinfo, MP_BUFFER_WRITE); + + // set flags, default to disc mode + if (bufinfo.len == 0) { adv_data[byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + BLE_AD_TYPE_FLAGS_DATA_SIZE); byte_pos += BLE_ADV_LENGTH_FIELD_SIZE; + adv_data[byte_pos] = BLE_GAP_AD_TYPE_FLAGS; byte_pos += BLE_AD_TYPE_FLAGS_DATA_SIZE; + adv_data[byte_pos] = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; byte_pos += 1; } - if (p_adv_params->num_of_services > 0) { - + const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(adv_params->services); + if (service_list->len > 0) { bool type_16bit_present = false; bool type_128bit_present = false; - for (uint8_t i = 0; i < p_adv_params->num_of_services; i++) { - bleio_service_obj_t * p_service = (bleio_service_obj_t *)p_adv_params->p_services[i]; - if (p_service->uuid->type == UUID_TYPE_16BIT) { + for (size_t i = 0; i < service_list->len; ++i) { + const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); + + if (service->uuid->type == UUID_TYPE_16BIT) { type_16bit_present = true; } - if (p_service->uuid->type == UUID_TYPE_128BIT) { + if (service->uuid->type == UUID_TYPE_128BIT) { type_128bit_present = true; } } @@ -441,13 +402,17 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { uint8_t uuid_total_size = 0; uint8_t encoded_size = 0; - for (uint8_t i = 0; i < p_adv_params->num_of_services; i++) { - bleio_service_obj_t * p_service = (bleio_service_obj_t *)p_adv_params->p_services[i]; + for (size_t i = 0; i < service_list->len; ++i) { + const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); + + if (service->uuid->type != UUID_TYPE_16BIT) { + continue; + } ble_uuid_t uuid; - uuid.type = p_service->uuid->type; - uuid.uuid = p_service->uuid->value[0]; - uuid.uuid += p_service->uuid->value[1] << 8; + uuid.type = BLE_UUID_TYPE_BLE; + uuid.uuid = service->uuid->value[0] | (service->uuid->value[1] << 8); + // calculate total size of uuids if (sd_ble_uuid_encode(&uuid, &encoded_size, NULL) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, @@ -460,19 +425,8 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { translate("Can encode UUID into the advertisement packet."))); } - BLE_DRIVER_LOG("encoded uuid for service %u: ", 0); - for (uint8_t j = 0; j < encoded_size; j++) { - BLE_DRIVER_LOG(HEX2_FMT " ", adv_data[byte_pos + j]); - } - BLE_DRIVER_LOG("\n"); - uuid_total_size += encoded_size; // size of entry byte_pos += encoded_size; // relative to adv data packet - BLE_DRIVER_LOG("ADV: uuid size: %u, type: %u, uuid: %x%x, vs_idx: %u\n", - encoded_size, p_service->p_uuid->type, - p_service->p_uuid->value[1], - p_service->p_uuid->value[0], - p_service->p_uuid->uuid_vs_idx); } adv_data[size_byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + uuid_total_size); @@ -490,13 +444,16 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { uint8_t uuid_total_size = 0; uint8_t encoded_size = 0; - for (uint8_t i = 0; i < p_adv_params->num_of_services; i++) { - bleio_service_obj_t * p_service = (bleio_service_obj_t *)p_adv_params->p_services[i]; + for (size_t i = 0; i < service_list->len; ++i) { + const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); + + if (service->uuid->type != UUID_TYPE_128BIT) { + continue; + } ble_uuid_t uuid; - uuid.type = p_service->uuid->uuid_vs_idx; - uuid.uuid = p_service->uuid->value[0]; - uuid.uuid += p_service->uuid->value[1] << 8; + uuid.type = service->uuid->uuid_vs_idx; + uuid.uuid = service->uuid->value[0] | (service->uuid->value[1] << 8); // calculate total size of uuids if (sd_ble_uuid_encode(&uuid, &encoded_size, NULL) != 0) { @@ -510,51 +467,37 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { translate("Can encode UUID into the advertisement packet."))); } - BLE_DRIVER_LOG("encoded uuid for service %u: ", 0); - for (uint8_t j = 0; j < encoded_size; j++) { - BLE_DRIVER_LOG(HEX2_FMT " ", adv_data[byte_pos + j]); - } - BLE_DRIVER_LOG("\n"); - uuid_total_size += encoded_size; // size of entry byte_pos += encoded_size; // relative to adv data packet - BLE_DRIVER_LOG("ADV: uuid size: %u, type: %x%x, uuid: %u, vs_idx: %u\n", - encoded_size, p_service->p_uuid->type, - p_service->p_uuid->value[1], - p_service->p_uuid->value[0], - p_service->p_uuid->uuid_vs_idx); } adv_data[size_byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + uuid_total_size); } } - if ((p_adv_params->data_len > 0) && (p_adv_params->p_data != NULL)) { - if (p_adv_params->data_len + byte_pos > BLE_GAP_ADV_MAX_SIZE) { + if (bufinfo.len > 0) { + if (byte_pos + bufinfo.len > BLE_GAP_ADV_MAX_SIZE) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("Can not fit data into the advertisement packet."))); } - memcpy(adv_data, p_adv_params->p_data, p_adv_params->data_len); - byte_pos += p_adv_params->data_len; + memcpy(adv_data, bufinfo.buf, bufinfo.len); + byte_pos += bufinfo.len; } - // scan response data not set uint32_t err_code; #if (BLUETOOTH_SD == 132) if ((err_code = sd_ble_gap_adv_data_set(adv_data, byte_pos, NULL, 0)) != 0) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("Can not apply advertisement data. status: 0x%02x"), (uint16_t)err_code)); } - BLE_DRIVER_LOG("Set Adv data size: " UINT_FMT "\n", byte_pos); #endif static ble_gap_adv_params_t m_adv_params; // initialize advertising params memset(&m_adv_params, 0, sizeof(m_adv_params)); - if (p_adv_params->connectable) { + if (adv_params->connectable) { #if (BLUETOOTH_SD == 140) m_adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; #else @@ -643,8 +586,8 @@ void ble_drv_attr_s_read(uint16_t conn_handle, uint16_t handle, uint16_t len, ui } void ble_drv_attr_s_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) { - ubluepy_peripheral_obj_t *peripheral = MP_OBJ_TO_PTR(characteristic->service->periph); - uint16_t conn_handle = peripheral->conn_handle; + bleio_device_obj_t *device = MP_OBJ_TO_PTR(characteristic->service->device); + uint16_t conn_handle = device->conn_handle; ble_gatts_value_t gatts_value; memset(&gatts_value, 0, sizeof(gatts_value)); @@ -662,8 +605,8 @@ void ble_drv_attr_s_write(bleio_characteristic_obj_t *characteristic, mp_buffer_ } void ble_drv_attr_s_notify(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) { - ubluepy_peripheral_obj_t *peripheral = MP_OBJ_TO_PTR(characteristic->service->periph); - uint16_t conn_handle = peripheral->conn_handle; + bleio_device_obj_t *device = MP_OBJ_TO_PTR(characteristic->service->device); + uint16_t conn_handle = device->conn_handle; ble_gatts_hvx_params_t hvx_params; uint16_t hvx_len = bufinfo->len; @@ -676,7 +619,9 @@ void ble_drv_attr_s_notify(bleio_characteristic_obj_t *characteristic, mp_buffer hvx_params.p_data = bufinfo->buf; while (m_tx_in_progress) { - ; +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif } m_tx_in_progress = true; @@ -687,50 +632,49 @@ void ble_drv_attr_s_notify(bleio_characteristic_obj_t *characteristic, mp_buffer } } -void ble_drv_gap_event_handler_set(mp_obj_t obj, ble_drv_gap_evt_callback_t evt_handler) { - mp_gap_observer = obj; +void ble_drv_gap_event_handler_set(bleio_device_obj_t *device, ble_drv_gap_evt_callback_t evt_handler) { + mp_gap_observer = device; gap_event_handler = evt_handler; } -void ble_drv_gatts_event_handler_set(mp_obj_t obj, ble_drv_gatts_evt_callback_t evt_handler) { - mp_gatts_observer = obj; +void ble_drv_gatts_event_handler_set(bleio_device_obj_t *device, ble_drv_gatts_evt_callback_t evt_handler) { + mp_gatts_observer = device; gatts_event_handler = evt_handler; } -void ble_drv_gattc_event_handler_set(mp_obj_t obj, ble_drv_gattc_evt_callback_t evt_handler) { - mp_gattc_observer = obj; +void ble_drv_gattc_event_handler_set(bleio_device_obj_t *device, ble_drv_gattc_evt_callback_t evt_handler) { + mp_gattc_observer = device; gattc_event_handler = evt_handler; } -void ble_drv_adv_report_handler_set(bleio_scanner_obj_t *self, ble_drv_adv_evt_callback_t evt_handler) { - mp_adv_observer = self; +void ble_drv_adv_report_handler_set(bleio_scanner_obj_t *device, ble_drv_adv_evt_callback_t evt_handler) { + mp_adv_observer = device; adv_event_handler = evt_handler; } - void ble_drv_attr_c_read(bleio_characteristic_obj_t *characteristic, ble_drv_gattc_char_data_callback_t cb) { bleio_service_obj_t *service = characteristic->service; - ubluepy_peripheral_obj_t *peripheral = MP_OBJ_TO_PTR(service->periph); + bleio_device_obj_t *device = MP_OBJ_TO_PTR(service->device); mp_gattc_char_data_observer = characteristic; gattc_char_data_handle = cb; - const uint32_t err_code = sd_ble_gattc_read(peripheral->conn_handle, - characteristic->handle, - 0); + const uint32_t err_code = sd_ble_gattc_read(device->conn_handle, characteristic->handle, 0); if (err_code != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, translate("Can not read attribute value. status: 0x%02x"), (uint16_t)err_code)); } while (gattc_char_data_handle != NULL) { - ; +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif } } void ble_drv_attr_c_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) { - ubluepy_peripheral_obj_t *peripheral = MP_OBJ_TO_PTR(characteristic->service->periph); - uint16_t conn_handle = peripheral->conn_handle; + bleio_device_obj_t *device = MP_OBJ_TO_PTR(characteristic->service->device); + uint16_t conn_handle = device->conn_handle; ble_gattc_write_params_t write_params; write_params.write_op = BLE_GATT_OP_WRITE_REQ; @@ -753,10 +697,13 @@ void ble_drv_attr_c_write(bleio_characteristic_obj_t *characteristic, mp_buffer_ translate("Can not write attribute value. status: 0x%02x"), (uint16_t)err_code)); } - while (m_write_done != true) { - ; + while (m_write_done != true) { +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif } } + void ble_drv_scan_start(uint16_t interval, uint16_t window) { SD_TEST_OR_ENABLE(); @@ -798,109 +745,108 @@ void ble_drv_scan_stop(void) { sd_ble_gap_scan_stop(); } -void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type) { - SD_TEST_OR_ENABLE(); +STATIC void ble_drv_connect_scan_callback(bleio_scanner_obj_t *scanner, ble_drv_adv_data_t *data) { + if (memcmp(data->p_peer_addr, mp_connect_address->value, BLEIO_ADDRESS_BYTES) == 0) { + ble_drv_adv_report_handler_set(NULL, NULL); - ble_gap_scan_params_t scan_params; - scan_params.active = 1; - scan_params.interval = MSEC_TO_UNITS(100, UNIT_0_625_MS); - scan_params.window = MSEC_TO_UNITS(100, UNIT_0_625_MS); - scan_params.timeout = 0; // Infinite + ble_gap_scan_params_t scan_params; + memset(&scan_params, 0, sizeof(scan_params)); - ble_gap_addr_t addr; - memset(&addr, 0, sizeof(addr)); + scan_params.active = 1; + scan_params.interval = MSEC_TO_UNITS(100, UNIT_0_625_MS); + scan_params.window = MSEC_TO_UNITS(100, UNIT_0_625_MS); + scan_params.timeout = 0; - addr.addr_type = addr_type; - memcpy(addr.addr, p_addr, 6); + ble_gap_addr_t addr; + memset(&addr, 0, sizeof(addr)); - BLE_DRIVER_LOG("GAP CONNECTING: "HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT", type: %d\n", - addr.addr[0], addr.addr[1], addr.addr[2], addr.addr[3], addr.addr[4], addr.addr[5], addr.addr_type); + addr.addr_type = data->addr_type; + memcpy(addr.addr, data->p_peer_addr, BLEIO_ADDRESS_BYTES); - ble_gap_conn_params_t conn_params; + BLE_DRIVER_LOG("GAP CONNECTING: "HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT":"HEX2_FMT", type: %d\n", + addr.addr[5], addr.addr[4], addr.addr[3], addr.addr[2], addr.addr[1], addr.addr[0], addr.addr_type); + + ble_gap_conn_params_t conn_params = { + .min_conn_interval = BLE_MIN_CONN_INTERVAL, + .max_conn_interval = BLE_MAX_CONN_INTERVAL, + .conn_sup_timeout = BLE_CONN_SUP_TIMEOUT, + .slave_latency = BLE_SLAVE_LATENCY, + }; + + uint32_t err_code; + #if (BLE_API_VERSION == 2) + if ((err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params)) != 0) { + #else + if ((err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_DEFAULT)) != 0) { + #endif + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, + "Can not connect. status: 0x" HEX2_FMT, (uint16_t)err_code)); + } + } +} -// (void)sd_ble_gap_ppcp_get(&conn_params); +void ble_drv_connect(bleio_device_obj_t *device) { + SD_TEST_OR_ENABLE(); - // set connection parameters - memset(&conn_params, 0, sizeof(conn_params)); + mp_connect_address = &device->address; + ble_drv_adv_report_handler_set(NULL, ble_drv_connect_scan_callback); - conn_params.min_conn_interval = BLE_MIN_CONN_INTERVAL; - conn_params.max_conn_interval = BLE_MAX_CONN_INTERVAL; - conn_params.slave_latency = BLE_SLAVE_LATENCY; - conn_params.conn_sup_timeout = BLE_CONN_SUP_TIMEOUT; + ble_drv_scan_start(100, 100); +} - uint32_t err_code; -#if (BLE_API_VERSION == 2) - if ((err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params)) != 0) { -#else - if ((err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_DEFAULT)) != 0) { -#endif - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - translate("Can not connect. status: 0x%02x"), (uint16_t)err_code)); - } +void ble_drv_disconnect(bleio_device_obj_t *device) { + sd_ble_gap_disconnect(device->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); } -bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, uint16_t start_handle, ble_drv_disc_add_service_callback_t cb) { - BLE_DRIVER_LOG("Discover primary services. Conn handle: 0x" HEX2_FMT "\n", - conn_handle); +bool ble_drv_discover_services(bleio_device_obj_t *device, uint16_t start_handle, ble_drv_disc_add_service_callback_t cb) { + BLE_DRIVER_LOG("Discover primary services. Conn handle: 0x" HEX2_FMT "\n", device->conn_handle); - mp_gattc_disc_service_observer = obj; + mp_gattc_disc_service_observer = device; disc_add_service_handler = cb; m_primary_service_found = false; uint32_t err_code; - err_code = sd_ble_gattc_primary_services_discover(conn_handle, - start_handle, - NULL); + err_code = sd_ble_gattc_primary_services_discover(device->conn_handle, start_handle, NULL); if (err_code != 0) { return false; } // busy loop until last service has been iterated while (disc_add_service_handler != NULL) { - ; +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif } - if (m_primary_service_found) { - return true; - } else { - return false; - } + return m_primary_service_found; } -bool ble_drv_discover_characteristic(mp_obj_t obj, - uint16_t conn_handle, - uint16_t start_handle, - uint16_t end_handle, - ble_drv_disc_add_char_callback_t cb) { - BLE_DRIVER_LOG("Discover characteristicts. Conn handle: 0x" HEX2_FMT "\n", - conn_handle); +bool ble_drv_discover_characteristic(bleio_device_obj_t *device, bleio_service_obj_t *service, uint16_t start_handle, ble_drv_disc_add_char_callback_t cb) { + BLE_DRIVER_LOG("Discover characteristicts. Conn handle: 0x" HEX2_FMT "\n", device->conn_handle); - mp_gattc_disc_char_observer = obj; + mp_gattc_disc_char_observer = service; disc_add_char_handler = cb; ble_gattc_handle_range_t handle_range; handle_range.start_handle = start_handle; - handle_range.end_handle = end_handle; + handle_range.end_handle = service->end_handle; m_characteristic_found = false; - uint32_t err_code; - err_code = sd_ble_gattc_characteristics_discover(conn_handle, &handle_range); + uint32_t err_code = sd_ble_gattc_characteristics_discover(device->conn_handle, &handle_range); if (err_code != 0) { return false; } // busy loop until last service has been iterated while (disc_add_char_handler != NULL) { - ; +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif } - if (m_characteristic_found) { - return true; - } else { - return false; - } + return m_characteristic_found; } void ble_drv_discover_descriptors(void) { @@ -908,12 +854,8 @@ void ble_drv_discover_descriptors(void) { } static void ble_evt_handler(ble_evt_t * p_ble_evt) { -// S132 event ranges. -// Common 0x01 -> 0x0F -// GAP 0x10 -> 0x2F -// GATTC 0x30 -> 0x4F -// GATTS 0x50 -> 0x6F -// L2CAP 0x70 -> 0x8F + printf("%s - 0x%02X\r\n", __func__, p_ble_evt->header.evt_id); + switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: BLE_DRIVER_LOG("GAP CONNECT\n"); @@ -1104,7 +1046,7 @@ static uint8_t m_ble_evt_buf[sizeof(ble_evt_t) + (GATT_MTU_SIZE_DEFAULT)] __attr static uint8_t m_ble_evt_buf[sizeof(ble_evt_t) + (BLE_GATT_ATT_MTU_DEFAULT)] __attribute__ ((aligned (4))); #endif -void SWI2_EGU2_IRQHandler(void) { +void SD_EVT_IRQHandler(void) { uint32_t evt_id; uint32_t err_code; do { diff --git a/ports/nrf/drivers/bluetooth/ble_drv.h b/ports/nrf/drivers/bluetooth/ble_drv.h index 8c6bd6ce3..e5282db73 100644 --- a/ports/nrf/drivers/bluetooth/ble_drv.h +++ b/ports/nrf/drivers/bluetooth/ble_drv.h @@ -32,12 +32,12 @@ #include #include +#include "shared-module/bleio/AdvertisementData.h" #include "shared-module/bleio/Characteristic.h" +#include "shared-module/bleio/Device.h" #include "shared-module/bleio/Scanner.h" #include "shared-module/bleio/Service.h" -#include "modubluepy.h" - typedef struct { uint8_t addr[6]; uint8_t addr_type; @@ -75,12 +75,12 @@ typedef struct { uint16_t value_handle; } ble_drv_char_data_t; -typedef void (*ble_drv_gap_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data); -typedef void (*ble_drv_gatts_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data); -typedef void (*ble_drv_gattc_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data); -typedef void (*ble_drv_adv_evt_callback_t)(bleio_scanner_obj_t *self, ble_drv_adv_data_t *data); -typedef void (*ble_drv_disc_add_service_callback_t)(mp_obj_t self, ble_drv_service_data_t * p_service_data); -typedef void (*ble_drv_disc_add_char_callback_t)(mp_obj_t self, ble_drv_char_data_t * p_desc_data); +typedef void (*ble_drv_gap_evt_callback_t)(bleio_device_obj_t *device, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data); +typedef void (*ble_drv_gatts_evt_callback_t)(bleio_device_obj_t *device, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data); +typedef void (*ble_drv_gattc_evt_callback_t)(bleio_device_obj_t *device, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data); +typedef void (*ble_drv_adv_evt_callback_t)(bleio_scanner_obj_t *scanner, ble_drv_adv_data_t *data); +typedef void (*ble_drv_disc_add_service_callback_t)(bleio_device_obj_t *device, ble_drv_service_data_t * p_service_data); +typedef void (*ble_drv_disc_add_char_callback_t)(bleio_service_obj_t *service, ble_drv_char_data_t * p_desc_data); typedef void (*ble_drv_gattc_char_data_callback_t)(bleio_characteristic_obj_t *self, uint16_t length, uint8_t * p_data); uint32_t ble_drv_stack_enable(void); @@ -97,15 +97,15 @@ void ble_drv_service_add(bleio_service_obj_t *service); bool ble_drv_characteristic_add(bleio_characteristic_obj_t *characteristic); -bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params); +bool ble_drv_advertise_data(bleio_advertisement_data_t *p_adv_params); void ble_drv_advertise_stop(void); -void ble_drv_gap_event_handler_set(mp_obj_t obs, ble_drv_gap_evt_callback_t evt_handler); +void ble_drv_gap_event_handler_set(bleio_device_obj_t *device, ble_drv_gap_evt_callback_t evt_handler); -void ble_drv_gatts_event_handler_set(mp_obj_t obj, ble_drv_gatts_evt_callback_t evt_handler); +void ble_drv_gatts_event_handler_set(bleio_device_obj_t *device, ble_drv_gatts_evt_callback_t evt_handler); -void ble_drv_gattc_event_handler_set(mp_obj_t obj, ble_drv_gattc_evt_callback_t evt_handler); +void ble_drv_gattc_event_handler_set(bleio_device_obj_t *device, ble_drv_gattc_evt_callback_t evt_handler); void ble_drv_attr_s_read(uint16_t conn_handle, uint16_t handle, uint16_t len, uint8_t * p_data); @@ -125,15 +125,13 @@ void ble_drv_scan_stop(void); void ble_drv_adv_report_handler_set(bleio_scanner_obj_t *self, ble_drv_adv_evt_callback_t evt_handler); -void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type); +void ble_drv_connect(bleio_device_obj_t *device); + +void ble_drv_disconnect(bleio_device_obj_t *device); -bool ble_drv_discover_services(mp_obj_t obj, uint16_t conn_handle, uint16_t start_handle, ble_drv_disc_add_service_callback_t cb); +bool ble_drv_discover_services(bleio_device_obj_t *device, uint16_t start_handle, ble_drv_disc_add_service_callback_t cb); -bool ble_drv_discover_characteristic(mp_obj_t obj, - uint16_t conn_handle, - uint16_t start_handle, - uint16_t end_handle, - ble_drv_disc_add_char_callback_t cb); +bool ble_drv_discover_characteristic(bleio_device_obj_t *device, bleio_service_obj_t *service, uint16_t start_handle, ble_drv_disc_add_char_callback_t cb); void ble_drv_discover_descriptors(void); diff --git a/ports/nrf/drivers/bluetooth/ble_uart.h b/ports/nrf/drivers/bluetooth/ble_uart.h index e67176a26..336624cd3 100644 --- a/ports/nrf/drivers/bluetooth/ble_uart.h +++ b/ports/nrf/drivers/bluetooth/ble_uart.h @@ -29,7 +29,6 @@ #if BLUETOOTH_SD -#include "modubluepy.h" #include "ble_drv.h" void ble_uart_init0(void); diff --git a/ports/nrf/modules/ubluepy/modubluepy.c b/ports/nrf/modules/ubluepy/modubluepy.c deleted file mode 100644 index f8266a82d..000000000 --- a/ports/nrf/modules/ubluepy/modubluepy.c +++ /dev/null @@ -1,48 +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" - -#if MICROPY_PY_UBLUEPY - -extern const mp_obj_type_t ubluepy_peripheral_type; -extern const mp_obj_type_t ubluepy_service_type; - -STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubluepy) }, -#if MICROPY_PY_UBLUEPY_PERIPHERAL - { MP_ROM_QSTR(MP_QSTR_Peripheral), MP_ROM_PTR(&ubluepy_peripheral_type) }, -#endif -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_ubluepy_globals, mp_module_ubluepy_globals_table); - -const mp_obj_module_t mp_module_ubluepy = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_ubluepy_globals, -}; - -#endif // MICROPY_PY_UBLUEPY diff --git a/ports/nrf/modules/ubluepy/modubluepy.h b/ports/nrf/modules/ubluepy/modubluepy.h deleted file mode 100644 index e301f0476..000000000 --- a/ports/nrf/modules/ubluepy/modubluepy.h +++ /dev/null @@ -1,126 +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. - */ - -#ifndef UBLUEPY_H__ -#define UBLUEPY_H__ - -/* Examples: - -Advertisment: - -from ubluepy import Peripheral -p = Peripheral() -p.advertise(device_name="MicroPython") - -DB setup: - -from ubluepy import Service, Characteristic, UUID, Peripheral, constants -from pyb import LED - -def event_handler(id, handle, data): - print("BLE event:", id, "handle:", handle) - print(data) - - if id == constants.EVT_GAP_CONNECTED: - # connected - LED(2).on() - elif id == constants.EVT_GAP_DISCONNECTED: - # disconnect - LED(2).off() - elif id == 80: - print("id 80, data:", data) - -# u0 = UUID("0x180D") # HRM service -# u1 = UUID("0x2A37") # HRM measurement - -u0 = UUID("6e400001-b5a3-f393-e0a9-e50e24dcca9e") -u1 = UUID("6e400002-b5a3-f393-e0a9-e50e24dcca9e") -u2 = UUID("6e400003-b5a3-f393-e0a9-e50e24dcca9e") -s = Service(u0) -c0 = Characteristic(u1, props = Characteristic.PROP_WRITE | Characteristic.PROP_WRITE_WO_RESP) -c1 = Characteristic(u2, props = Characteristic.PROP_NOTIFY, attrs = Characteristic.ATTR_CCCD) -s.addCharacteristic(c0) -s.addCharacteristic(c1) -p = Peripheral() -p.addService(s) -p.setConnectionHandler(event_handler) -p.advertise(device_name="micr", services=[s]) - -*/ - -#include "common-hal/bleio/UUID.h" -#include "py/obj.h" - -extern const mp_obj_type_t ubluepy_peripheral_type; - -typedef enum { - UBLUEPY_ADDR_TYPE_PUBLIC = 0, - UBLUEPY_ADDR_TYPE_RANDOM_STATIC = 1, - UBLUEPY_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = 2, - UBLUEPY_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE = 3, -} ubluepy_addr_type_t; - -typedef enum { - UBLUEPY_ROLE_PERIPHERAL, - UBLUEPY_ROLE_CENTRAL -} ubluepy_role_type_t; - -typedef struct _ubluepy_peripheral_obj_t { - mp_obj_base_t base; - ubluepy_role_type_t role; - volatile uint16_t conn_handle; - mp_obj_t delegate; - mp_obj_t notif_handler; - mp_obj_t conn_handler; - mp_obj_t service_list; -} ubluepy_peripheral_obj_t; - -typedef struct _ubluepy_advertise_data_t { - uint8_t * p_device_name; - uint8_t device_name_len; - mp_obj_t * p_services; - uint8_t num_of_services; - uint8_t * p_data; - uint8_t data_len; - bool connectable; -} ubluepy_advertise_data_t; - -typedef enum _ubluepy_prop_t { - UBLUEPY_PROP_BROADCAST = 0x01, - UBLUEPY_PROP_READ = 0x02, - UBLUEPY_PROP_WRITE_WO_RESP = 0x04, - UBLUEPY_PROP_WRITE = 0x08, - UBLUEPY_PROP_NOTIFY = 0x10, - UBLUEPY_PROP_INDICATE = 0x20, - UBLUEPY_PROP_AUTH_SIGNED_WR = 0x40, -} ubluepy_prop_t; - -typedef enum _ubluepy_attr_t { - UBLUEPY_ATTR_CCCD = 0x01, - UBLUEPY_ATTR_SCCD = 0x02, -} ubluepy_attr_t; - -#endif // UBLUEPY_H__ diff --git a/ports/nrf/modules/ubluepy/ubluepy_peripheral.c b/ports/nrf/modules/ubluepy/ubluepy_peripheral.c deleted file mode 100644 index 3b1a0d279..000000000 --- a/ports/nrf/modules/ubluepy/ubluepy_peripheral.c +++ /dev/null @@ -1,507 +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 -#include "py/obj.h" -#include "py/runtime.h" -#include "py/objstr.h" -#include "py/objlist.h" - -#if MICROPY_PY_UBLUEPY - -#include "ble_drv.h" -#include "common-hal/bleio/UUID.h" -#include "shared-bindings/bleio/Characteristic.h" -#include "shared-bindings/bleio/Service.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) { - ubluepy_peripheral_obj_t * self = (ubluepy_peripheral_obj_t *)o; - (void)self; - mp_printf(print, "Peripheral(conn_handle: " HEX2_FMT ")", - self->conn_handle); -} - -STATIC void gap_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - if (event_id == 16) { // connect event - self->conn_handle = conn_handle; - } else if (event_id == 17) { // disconnect event - self->conn_handle = 0xFFFF; // invalid connection handle - } - - if (self->conn_handler != mp_const_none) { - mp_obj_t args[3]; - mp_uint_t num_of_args = 3; - args[0] = MP_OBJ_NEW_SMALL_INT(event_id); - args[1] = MP_OBJ_NEW_SMALL_INT(conn_handle); - if (data != NULL) { - args[2] = mp_obj_new_bytearray_by_ref(length, data); - } else { - args[2] = mp_const_none; - } - - // for now hard-code all events to conn_handler - mp_call_function_n_kw(self->conn_handler, num_of_args, 0, args); - } - - (void)self; -} - -STATIC void gatts_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - if (self->conn_handler != mp_const_none) { - mp_obj_t args[3]; - mp_uint_t num_of_args = 3; - args[0] = MP_OBJ_NEW_SMALL_INT(event_id); - args[1] = MP_OBJ_NEW_SMALL_INT(attr_handle); - if (data != NULL) { - args[2] = mp_obj_new_bytearray_by_ref(length, data); - } else { - args[2] = mp_const_none; - } - - // for now hard-code all events to conn_handler - mp_call_function_n_kw(self->conn_handler, num_of_args, 0, args); - } - -} - -#if MICROPY_PY_UBLUEPY_CENTRAL - -static volatile bool m_disc_evt_received; - -STATIC void gattc_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t attr_handle, uint16_t length, uint8_t * data) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - (void)self; - m_disc_evt_received = true; -} -#endif - -STATIC mp_obj_t ubluepy_peripheral_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_DEVICE_ADDR, - ARG_NEW_ADDR_TYPE - }; - - static const mp_arg_t allowed_args[] = { - { ARG_NEW_DEVICE_ADDR, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { ARG_NEW_ADDR_TYPE, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - }; - - // 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_peripheral_obj_t *s = m_new_obj(ubluepy_peripheral_obj_t); - s->base.type = type; - - s->delegate = mp_const_none; - s->conn_handler = mp_const_none; - s->notif_handler = mp_const_none; - s->conn_handle = 0xFFFF; - - s->service_list = mp_obj_new_list(0, NULL); - - return MP_OBJ_FROM_PTR(s); -} - -/// \method withDelegate(DefaultDelegate) -/// Set delegate instance for handling Bluetooth LE events. -/// -STATIC mp_obj_t peripheral_with_delegate(mp_obj_t self_in, mp_obj_t delegate) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - self->delegate = delegate; - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_peripheral_with_delegate_obj, peripheral_with_delegate); - -/// \method setNotificationHandler(func) -/// Set handler for Bluetooth LE notification events. -/// -STATIC mp_obj_t peripheral_set_notif_handler(mp_obj_t self_in, mp_obj_t func) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - self->notif_handler = func; - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_peripheral_set_notif_handler_obj, peripheral_set_notif_handler); - -/// \method setConnectionHandler(func) -/// Set handler for Bluetooth LE connection events. -/// -STATIC mp_obj_t peripheral_set_conn_handler(mp_obj_t self_in, mp_obj_t func) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - self->conn_handler = func; - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_peripheral_set_conn_handler_obj, peripheral_set_conn_handler); - -#if MICROPY_PY_UBLUEPY_PERIPHERAL - -/// \method advertise(device_name, [service=[service1, service2, ...]], [data=bytearray], [connectable=True]) -/// Start advertising. Connectable advertisement type by default. -/// -STATIC mp_obj_t peripheral_advertise(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - static const mp_arg_t allowed_args[] = { - { MP_QSTR_device_name, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_services, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - }; - - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - - self->role = UBLUEPY_ROLE_PERIPHERAL; - - // parse args - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - // ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - mp_obj_t device_name_obj = args[0].u_obj; - mp_obj_t service_obj = args[1].u_obj; - mp_obj_t data_obj = args[2].u_obj; - mp_obj_t connectable_obj = args[3].u_obj; - - ubluepy_advertise_data_t adv_data; - memset(&adv_data, 0, sizeof(ubluepy_advertise_data_t)); - - if (device_name_obj != mp_const_none && MP_OBJ_IS_STR(device_name_obj)) { - GET_STR_DATA_LEN(device_name_obj, str_data, str_len); - - adv_data.p_device_name = (uint8_t *)str_data; - adv_data.device_name_len = str_len; - } - - if (service_obj != mp_const_none) { - mp_obj_t * services = NULL; - mp_uint_t num_services; - mp_obj_get_array(service_obj, &num_services, &services); - - if (num_services > 0) { - adv_data.p_services = services; - adv_data.num_of_services = num_services; - } - } - - if (data_obj != mp_const_none) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ); - - if (bufinfo.len > 0) { - adv_data.p_data = bufinfo.buf; - adv_data.data_len = bufinfo.len; - } - } - - adv_data.connectable = true; - if (connectable_obj != mp_const_none && !(mp_obj_is_true(connectable_obj))) { - adv_data.connectable = false; - } else { - ble_drv_gap_event_handler_set(MP_OBJ_FROM_PTR(self), gap_event_handler); - ble_drv_gatts_event_handler_set(MP_OBJ_FROM_PTR(self), gatts_event_handler); - } - - (void)ble_drv_advertise_data(&adv_data); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ubluepy_peripheral_advertise_obj, 0, peripheral_advertise); - -/// \method advertise_stop() -/// Stop advertisement if any onging advertisement. -/// -STATIC mp_obj_t peripheral_advertise_stop(mp_obj_t self_in) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - (void)self; - - ble_drv_advertise_stop(); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(ubluepy_peripheral_advertise_stop_obj, peripheral_advertise_stop); - -#endif // MICROPY_PY_UBLUEPY_PERIPHERAL - -/// \method disconnect() -/// disconnect connection. -/// -STATIC mp_obj_t peripheral_disconnect(mp_obj_t self_in) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - - (void)self; - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(ubluepy_peripheral_disconnect_obj, peripheral_disconnect); - -/// \method addService(Service) -/// Add service to the Peripheral. -/// -STATIC mp_obj_t peripheral_add_service(mp_obj_t self_in, mp_obj_t service) { - ubluepy_peripheral_obj_t * self = MP_OBJ_TO_PTR(self_in); - bleio_service_obj_t * p_service = MP_OBJ_TO_PTR(service); - - p_service->periph = self_in; - - mp_obj_list_append(self->service_list, service); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_peripheral_add_service_obj, peripheral_add_service); - -/// \method getServices() -/// Return list with all service registered in the Peripheral. -/// -STATIC mp_obj_t peripheral_get_services(mp_obj_t self_in) { - ubluepy_peripheral_obj_t * self = MP_OBJ_TO_PTR(self_in); - - return self->service_list; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(ubluepy_peripheral_get_services_obj, peripheral_get_services); - -#if MICROPY_PY_UBLUEPY_CENTRAL - -void static disc_add_service(mp_obj_t self, ble_drv_service_data_t * p_service_data) { - bleio_service_obj_t * p_service = m_new_obj(bleio_service_obj_t); - p_service->base.type = &bleio_service_type; - - bleio_uuid_obj_t * p_uuid = m_new_obj(bleio_uuid_obj_t); - p_uuid->base.type = &bleio_uuid_type; - - p_service->uuid = p_uuid; - - p_uuid->type = p_service_data->uuid_type; - p_uuid->value[0] = p_service_data->uuid & 0xFF; - p_uuid->value[1] = p_service_data->uuid >> 8; - - p_service->handle = p_service_data->start_handle; - p_service->start_handle = p_service_data->start_handle; - p_service->end_handle = p_service_data->end_handle; - - p_service->char_list = mp_obj_new_list(0, NULL); - - peripheral_add_service(self, MP_OBJ_FROM_PTR(p_service)); -} - -void static disc_add_char(mp_obj_t service_in, ble_drv_char_data_t * p_desc_data) { - bleio_service_obj_t * p_service = MP_OBJ_TO_PTR(service_in); - bleio_characteristic_obj_t * p_char = m_new_obj(bleio_characteristic_obj_t); - p_char->base.type = &bleio_characteristic_type; - - bleio_uuid_obj_t * p_uuid = m_new_obj(bleio_uuid_obj_t); - p_uuid->base.type = &bleio_uuid_type; - - p_char->uuid = p_uuid; - - p_uuid->type = p_desc_data->uuid_type; - p_uuid->value[0] = p_desc_data->uuid & 0xFF; - p_uuid->value[1] = p_desc_data->uuid >> 8; - - // add characteristic specific data from discovery - p_char->props.broadcast = p_desc_data->props.broadcast; - p_char->props.indicate = p_desc_data->props.indicate; - p_char->props.notify = p_desc_data->props.notify; - p_char->props.read = p_desc_data->props.read; - p_char->props.write = p_desc_data->props.write; - p_char->props.write_wo_resp = p_desc_data->props.write_wo_resp; - p_char->handle = p_desc_data->value_handle; - - // equivalent to ubluepy_service.c - service_add_characteristic() - // except the registration of the characteristic towards the bluetooth stack - p_char->service_handle = p_service->handle; - p_char->service = p_service; - - mp_obj_list_append(p_service->char_list, MP_OBJ_FROM_PTR(p_char)); -} - -/// \method connect(device_address [, addr_type=ADDR_TYPE_PUBLIC]) -/// Connect to device peripheral with the given device address. -/// addr_type can be either ADDR_TYPE_PUBLIC (default) or -/// ADDR_TYPE_RANDOM_STATIC. -/// -STATIC mp_obj_t peripheral_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - ubluepy_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - mp_obj_t dev_addr = pos_args[1]; - - self->role = UBLUEPY_ROLE_CENTRAL; - - static const mp_arg_t allowed_args[] = { - { MP_QSTR_addr_type, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = UBLUEPY_ADDR_TYPE_PUBLIC } }, - }; - - // parse args - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - uint8_t addr_type = args[0].u_int; - - ble_drv_gap_event_handler_set(MP_OBJ_FROM_PTR(self), gap_event_handler); - - if (MP_OBJ_IS_STR(dev_addr)) { - GET_STR_DATA_LEN(dev_addr, str_data, str_len); - if (str_len == 17) { // Example "11:22:33:aa:bb:cc" - - uint8_t * p_addr = m_new(uint8_t, 6); - - p_addr[0] = unichar_xdigit_value(str_data[16]); - p_addr[0] += unichar_xdigit_value(str_data[15]) << 4; - p_addr[1] = unichar_xdigit_value(str_data[13]); - p_addr[1] += unichar_xdigit_value(str_data[12]) << 4; - p_addr[2] = unichar_xdigit_value(str_data[10]); - p_addr[2] += unichar_xdigit_value(str_data[9]) << 4; - p_addr[3] = unichar_xdigit_value(str_data[7]); - p_addr[3] += unichar_xdigit_value(str_data[6]) << 4; - p_addr[4] = unichar_xdigit_value(str_data[4]); - p_addr[4] += unichar_xdigit_value(str_data[3]) << 4; - p_addr[5] = unichar_xdigit_value(str_data[1]); - p_addr[5] += unichar_xdigit_value(str_data[0]) << 4; - - ble_drv_connect(p_addr, addr_type); - - m_del(uint8_t, p_addr, 6); - } - } - - // block until connected - while (self->conn_handle == 0xFFFF) { - ; - } - - ble_drv_gattc_event_handler_set(MP_OBJ_FROM_PTR(self), gattc_event_handler); - - bool service_disc_retval = ble_drv_discover_services(self, self->conn_handle, 0x0001, disc_add_service); - - // continue discovery of primary services ... - while (service_disc_retval) { - // locate the last added service - mp_obj_t * services = NULL; - mp_uint_t num_services; - mp_obj_get_array(self->service_list, &num_services, &services); - - bleio_service_obj_t * p_service = (bleio_service_obj_t *)services[num_services - 1]; - - service_disc_retval = ble_drv_discover_services(self, - self->conn_handle, - p_service->end_handle + 1, - disc_add_service); - } - - // For each service perform a characteristic discovery - mp_obj_t * services = NULL; - mp_uint_t num_services; - mp_obj_get_array(self->service_list, &num_services, &services); - - for (uint16_t s = 0; s < num_services; s++) { - bleio_service_obj_t * p_service = (bleio_service_obj_t *)services[s]; - bool char_disc_retval = ble_drv_discover_characteristic(p_service, - self->conn_handle, - p_service->start_handle, - p_service->end_handle, - disc_add_char); - // continue discovery of characteristics ... - while (char_disc_retval) { - mp_obj_t * characteristics = NULL; - mp_uint_t num_chars; - mp_obj_get_array(p_service->char_list, &num_chars, &characteristics); - - bleio_characteristic_obj_t * p_char = (bleio_characteristic_obj_t *)characteristics[num_chars - 1]; - uint16_t next_handle = p_char->handle + 1; - if ((next_handle) < p_service->end_handle) { - char_disc_retval = ble_drv_discover_characteristic(p_service, - self->conn_handle, - next_handle, - p_service->end_handle, - disc_add_char); - } else { - break; - } - } - } - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ubluepy_peripheral_connect_obj, 2, peripheral_connect); - -#endif - -STATIC const mp_rom_map_elem_t ubluepy_peripheral_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_withDelegate), MP_ROM_PTR(&ubluepy_peripheral_with_delegate_obj) }, - { MP_ROM_QSTR(MP_QSTR_setNotificationHandler), MP_ROM_PTR(&ubluepy_peripheral_set_notif_handler_obj) }, - { MP_ROM_QSTR(MP_QSTR_setConnectionHandler), MP_ROM_PTR(&ubluepy_peripheral_set_conn_handler_obj) }, - { MP_ROM_QSTR(MP_QSTR_getServices), MP_ROM_PTR(&ubluepy_peripheral_get_services_obj) }, -#if MICROPY_PY_UBLUEPY_CENTRAL - { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&ubluepy_peripheral_connect_obj) }, -#if 0 - { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&ubluepy_peripheral_disconnect_obj) }, - { MP_ROM_QSTR(MP_QSTR_getServiceByUUID), MP_ROM_PTR(&ubluepy_peripheral_get_service_by_uuid_obj) }, - { MP_ROM_QSTR(MP_QSTR_getCharacteristics), MP_ROM_PTR(&ubluepy_peripheral_get_chars_obj) }, - { MP_ROM_QSTR(MP_QSTR_getDescriptors), MP_ROM_PTR(&ubluepy_peripheral_get_descs_obj) }, - { MP_ROM_QSTR(MP_QSTR_waitForNotifications), MP_ROM_PTR(&ubluepy_peripheral_wait_for_notif_obj) }, - { MP_ROM_QSTR(MP_QSTR_writeCharacteristic), MP_ROM_PTR(&ubluepy_peripheral_write_char_obj) }, - { MP_ROM_QSTR(MP_QSTR_readCharacteristic), MP_ROM_PTR(&ubluepy_peripheral_read_char_obj) }, -#endif // 0 -#endif // MICROPY_PY_UBLUEPY_CENTRAL -#if MICROPY_PY_UBLUEPY_PERIPHERAL - { MP_ROM_QSTR(MP_QSTR_advertise), MP_ROM_PTR(&ubluepy_peripheral_advertise_obj) }, - { MP_ROM_QSTR(MP_QSTR_advertise_stop), MP_ROM_PTR(&ubluepy_peripheral_advertise_stop_obj) }, - { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&ubluepy_peripheral_disconnect_obj) }, - { MP_ROM_QSTR(MP_QSTR_addService), MP_ROM_PTR(&ubluepy_peripheral_add_service_obj) }, -#if 0 - { MP_ROM_QSTR(MP_QSTR_addCharacteristic), MP_ROM_PTR(&ubluepy_peripheral_add_char_obj) }, - { MP_ROM_QSTR(MP_QSTR_addDescriptor), MP_ROM_PTR(&ubluepy_peripheral_add_desc_obj) }, - { MP_ROM_QSTR(MP_QSTR_writeCharacteristic), MP_ROM_PTR(&ubluepy_peripheral_write_char_obj) }, - { MP_ROM_QSTR(MP_QSTR_readCharacteristic), MP_ROM_PTR(&ubluepy_peripheral_read_char_obj) }, -#endif -#endif -#if MICROPY_PY_UBLUEPY_BROADCASTER - { MP_ROM_QSTR(MP_QSTR_advertise), MP_ROM_PTR(&ubluepy_peripheral_advertise_obj) }, -#endif -#if MICROPY_PY_UBLUEPY_OBSERVER - // Nothing yet. -#endif -}; - -STATIC MP_DEFINE_CONST_DICT(ubluepy_peripheral_locals_dict, ubluepy_peripheral_locals_dict_table); - -const mp_obj_type_t ubluepy_peripheral_type = { - { &mp_type_type }, - .name = MP_QSTR_Peripheral, - .print = ubluepy_peripheral_print, - .make_new = ubluepy_peripheral_make_new, - .locals_dict = (mp_obj_dict_t*)&ubluepy_peripheral_locals_dict -}; - -#endif // MICROPY_PY_UBLUEPY diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index b710808b9..62a041ae9 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -129,21 +129,15 @@ #define CIRCUITPY_GAMEPAD_TICKS 0x1f #if BLUETOOTH_SD -#define MICROPY_PY_BLEIO (1) -#define MICROPY_PY_BLE_NUS (0) -#define MICROPY_PY_UBLUEPY (1) -#define MICROPY_PY_UBLUEPY_PERIPHERAL (1) -#define MICROPY_PY_UBLUEPY_CENTRAL (1) -#define BLUETOOTH_WEBBLUETOOTH_REPL (0) -#endif - -#ifndef MICROPY_PY_BLEIO -#define MICROPY_PY_BLEIO (0) + #define MICROPY_PY_BLEIO (1) + #define MICROPY_PY_BLE_NUS (0) + #define BLUETOOTH_WEBBLUETOOTH_REPL (0) +#else + #ifndef MICROPY_PY_BLEIO + #define MICROPY_PY_BLEIO (0) + #endif #endif -#ifndef MICROPY_PY_UBLUEPY -#define MICROPY_PY_UBLUEPY (0) -#endif // type definitions for the specific machine @@ -184,16 +178,8 @@ extern const struct _mp_obj_module_t neopixel_write_module; extern const struct _mp_obj_module_t usb_hid_module; extern const struct _mp_obj_module_t bleio_module; -extern const struct _mp_obj_module_t mp_module_ubluepy; - -#if MICROPY_PY_UBLUEPY -#define UBLUEPY_MODULE { MP_ROM_QSTR(MP_QSTR_ubluepy), MP_ROM_PTR(&mp_module_ubluepy) }, -#else -#define UBLUEPY_MODULE -#endif - #if MICROPY_PY_BLEIO -#define BLEIO_MODULE { MP_ROM_QSTR(MP_QSTR_bleio), MP_ROM_PTR(&bleio_module) }, +#define BLEIO_MODULE { MP_ROM_QSTR(MP_QSTR_bleio), MP_ROM_PTR(&bleio_module) }, #else #define BLEIO_MODULE #endif @@ -221,8 +207,7 @@ extern const struct _mp_obj_module_t mp_module_ubluepy; { MP_OBJ_NEW_QSTR (MP_QSTR_gamepad ), (mp_obj_t)&gamepad_module }, \ { MP_OBJ_NEW_QSTR (MP_QSTR_time ), (mp_obj_t)&time_module }, \ USBHID_MODULE \ - BLEIO_MODULE \ - UBLUEPY_MODULE \ + BLEIO_MODULE // extra built in names to add to the global namespace #define MICROPY_PORT_BUILTINS \ diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c new file mode 100644 index 000000000..15ebd51ed --- /dev/null +++ b/shared-bindings/bleio/Device.c @@ -0,0 +1,348 @@ +/* + * 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 +#include + +#include "ble_drv.h" +#include "py/objarray.h" +#include "py/objproperty.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "shared-bindings/bleio/Adapter.h" +#include "shared-bindings/bleio/AddressType.h" +#include "shared-bindings/bleio/Characteristic.h" +#include "shared-bindings/bleio/Device.h" +#include "shared-bindings/bleio/Service.h" +#include "shared-bindings/bleio/UUID.h" +#include "shared-module/bleio/AdvertisementData.h" +#include "shared-module/bleio/Device.h" + +//| .. currentmodule:: bleio +//| +//| :class:`Device` -- BLE device +//| ========================================================= +//| +//| Provides access a to BLE device, either in a Peripheral or Central role. +//| When a device is created without any parameter passed to the constructor, +//| it will be set to the Peripheral role. If a address is passed, the device +//| will be a Central. For a Peripheral you can set the `name`, add services +//| via `add_service` and then start and stop advertising via `start_advertising` +//| and `stop_advertising`. For the Central, you can `bleio.Device.connect` and `bleio.Device.disconnect` +//| to the device, once a connection is established, the device's services can +//| be accessed using `services`. +//| +//| Usage:: +//| +//| import bleio +//| +//| # Peripheral +//| periph = bleio.Device() +//| +//| serv = bleio.Service(bleio.UUID(0x180f)) +//| p.add_service(serv) +//| +//| chara = bleio.Characteristic(bleio.UUID(0x2919)) +//| chara.read = True +//| chara.notify = True +//| serv.add_characteristic(chara) +//| +//| periph.start_advertising() +//| +//| # Central +//| scanner = bleio.Scanner() +//| entries = scanner.scan(2500) +//| +//| my_entry = None +//| for entry in entries: +//| if entry.name is not None and entry.name == 'MyDevice': +//| my_entry = entry +//| break +//| +//| central = bleio.Device(my_entry.address) +//| central.connect() +//| + +//| .. class:: Device(address=None) +//| +//| Create a new Device object. If the `address` parameter is not `None`, +//| the role is set to Central, otherwise it's set to Peripheral. +//| +//| :param bleio.Address address: The address of the device to connect to +//| + +//| .. attribute:: name +//| +//| For the Peripheral role, this property can be used to read and write the device's name. +//| For the Central role, this property will equal the name of the remote device, if one was +//| advertised by the device. In the Central role this property is read-only. +//| + +//| .. attribute:: services +//| +//| A `list` of `bleio.Service` that are offered by this device. (read-only) +//| For a Peripheral device, this list will contain services added using `add_service`, +//| for a Central, this list will be empty until a connection is established, at which point +//| it will be filled with the remote device's services. +//| + +//| .. method:: add_service(service) +//| +//| Appends the :py:data:`service` to the list of this devices's services. +//| This method can only be called for Peripheral devices. +//| +//| :param bleio.Service service: the service to append +//| + +//| .. method:: connect() +//| +//| Attempts a connection to the remote device. If the connection is successful, +//| the device's services are available via `services`. +//| This method can only be called for Central devices. +//| + +//| .. method:: disconnect() +//| +//| Disconnects from the remote device. +//| This method can only be called for Central devices. +//| + +//| .. method:: start_advertising(connectable=True) +//| +//| Starts advertising the device. The device's name and +//| services are put into the advertisement packets. +//| If :py:data:`connectable` is `True` then other devices are allowed to conncet to this device. +//| This method can only be called for Peripheral devices. +//| + +//| .. method:: stop_advertising() +//| +//| Disconnects from the remote device. +//| This method can only be called for Peripheral devices. +//| +static const char default_name[] = "CIRCUITPY"; + +STATIC void bleio_device_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + mp_printf(print, "Device(role: %s)", self->is_peripheral ? "Peripheral" : "Central"); +} + +STATIC mp_obj_t bleio_device_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_device_obj_t *self = m_new_obj(bleio_device_obj_t); + self->base.type = &bleio_device_type; + self->service_list = mp_obj_new_list(0, NULL); + self->notif_handler = mp_const_none; + self->conn_handler = mp_const_none; + self->conn_handle = 0xFFFF; + self->is_peripheral = true; + + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); + + //TODO: Add ScanEntry + enum { ARG_address }; + static const mp_arg_t allowed_args[] = { + { ARG_address, MP_ARG_OBJ, {.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; + + if (address_obj != mp_const_none) { + bleio_address_obj_t *address = MP_OBJ_TO_PTR(address_obj); + + self->is_peripheral = false; + self->address.type = address->type; + memcpy(self->address.value, address->value, BLEIO_ADDRESS_BYTES); + } else { + self->name = mp_obj_new_str(default_name, strlen(default_name), false); + common_hal_bleio_adapter_get_address(&self->address); + } + + return MP_OBJ_FROM_PTR(self); +} + +STATIC mp_obj_t bleio_device_add_service(mp_obj_t self_in, mp_obj_t service_in) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_in); + + if (!self->is_peripheral) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "Can't add services in Central mode")); + } + + service->device = self_in; + + mp_obj_list_append(self->service_list, service); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_device_add_service_obj, bleio_device_add_service); + +STATIC mp_obj_t bleio_device_connect(mp_obj_t self_in) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->is_peripheral) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "Can't connect in Peripheral mode")); + } + + common_hal_bleio_device_connect(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_connect_obj, bleio_device_connect); + +STATIC mp_obj_t bleio_device_disconnect(mp_obj_t self_in) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + common_hal_bleio_device_disconnect(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_disconnect_obj, bleio_device_disconnect); + +STATIC mp_obj_t bleio_device_get_name(mp_obj_t self_in) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return self->name; +} +MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_get_name_obj, bleio_device_get_name); + +static mp_obj_t bleio_device_set_name(mp_obj_t self_in, mp_obj_t value) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + if (!self->is_peripheral) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "Can't change the name in Central mode")); + } + + self->name = value; + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_device_set_name_obj, bleio_device_set_name); + +const mp_obj_property_t bleio_device_name_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_device_get_name_obj, + (mp_obj_t)&bleio_device_set_name_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC mp_obj_t bleio_device_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + if (!self->is_peripheral) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "Can't advertise in Central mode")); + } + + enum { ARG_connectable }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + // TODO: data + bleio_advertisement_data_t adv_data = { + .device_name = self->name, + .services = mp_obj_new_list(0, NULL), + .data = mp_obj_new_bytearray(0, NULL), + .connectable = args[ARG_connectable].u_bool + }; + + mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); + for (size_t i = 0; i < service_list->len; ++i) { + bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); + if (!service->is_secondary) { + mp_obj_list_append(adv_data.services, service_list->items[i]); + } + } + + common_hal_bleio_device_start_advertising(self, &adv_data); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_device_start_advertising_obj, 0, bleio_device_start_advertising); + +STATIC mp_obj_t bleio_device_stop_advertising(mp_obj_t self_in) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->is_peripheral) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + "Can't advertise in Central mode")); + } + + common_hal_bleio_device_stop_advertising(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_stop_advertising_obj, bleio_device_stop_advertising); + +STATIC mp_obj_t bleio_device_get_services(mp_obj_t self_in) { + bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return self->service_list; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_get_services_obj, bleio_device_get_services); + +const mp_obj_property_t bleio_device_services_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_device_get_services_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC const mp_rom_map_elem_t bleio_device_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_add_service), MP_ROM_PTR(&bleio_device_add_service_obj) }, + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_device_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_device_disconnect_obj) }, + { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_device_start_advertising_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_device_stop_advertising_obj) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_device_name_obj) }, + { MP_ROM_QSTR(MP_QSTR_services), MP_ROM_PTR(&bleio_device_services_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(bleio_device_locals_dict, bleio_device_locals_dict_table); + +const mp_obj_type_t bleio_device_type = { + { &mp_type_type }, + .name = MP_QSTR_Device, + .print = bleio_device_print, + .make_new = bleio_device_make_new, + .locals_dict = (mp_obj_dict_t*)&bleio_device_locals_dict +}; diff --git a/shared-bindings/bleio/Device.h b/shared-bindings/bleio/Device.h new file mode 100644 index 000000000..d099e5c43 --- /dev/null +++ b/shared-bindings/bleio/Device.h @@ -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_DEVICE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H + +#include "shared-module/bleio/AdvertisementData.h" +#include "shared-module/bleio/Device.h" + +extern const mp_obj_type_t bleio_device_type; + +extern void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bleio_advertisement_data_t *adv_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 diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index e38a08909..2eed24cd8 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -32,9 +32,10 @@ #include "py/objstr.h" #include "py/objtuple.h" #include "shared-bindings/bleio/Address.h" -#include "shared-module/bleio/AdvertisementData.h" -#include "shared-bindings/bleio/UUID.h" #include "shared-bindings/bleio/ScanEntry.h" +#include "shared-bindings/bleio/UUID.h" +#include "shared-module/bleio/AdvertisementData.h" +#include "shared-module/bleio/ScanEntry.h" //| .. currentmodule:: bleio //| diff --git a/shared-bindings/bleio/ScanEntry.h b/shared-bindings/bleio/ScanEntry.h index 4a201124e..2b44ba3f4 100644 --- a/shared-bindings/bleio/ScanEntry.h +++ b/shared-bindings/bleio/ScanEntry.h @@ -28,16 +28,7 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H -#include "shared-module/bleio/Address.h" -#include "py/objtype.h" - -typedef struct { - mp_obj_base_t base; - bleio_address_obj_t address; - bool connectable; - int8_t rssi; - mp_obj_t data; -} bleio_scanentry_obj_t; +#include "py/obj.h" extern const mp_obj_type_t bleio_scanentry_type; diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index 6451991e9..5b61a2966 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -73,7 +73,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_check_num(n_args, n_kw, 1, 1, true); bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t); self->base.type = &bleio_service_type; - self->periph = mp_const_none; + self->device = mp_const_none; self->char_list = mp_obj_new_list(0, NULL); mp_map_t kw_args; @@ -81,7 +81,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, enum { ARG_uuid, ARG_secondary }; static const mp_arg_t allowed_args[] = { - { ARG_uuid, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { ARG_uuid, MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_secondary, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; @@ -92,7 +92,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t uuid = args[ARG_uuid].u_obj; - if (uuid == MP_OBJ_NULL) { + if (uuid == mp_const_none) { return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 9f5a8f8f2..98099422c 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -31,6 +31,7 @@ #include "shared-bindings/bleio/AdvertisementData.h" #include "shared-bindings/bleio/Characteristic.h" #include "shared-bindings/bleio/Descriptor.h" +#include "shared-bindings/bleio/Device.h" #include "shared-bindings/bleio/ScanEntry.h" #include "shared-bindings/bleio/Scanner.h" #include "shared-bindings/bleio/Service.h" @@ -57,6 +58,7 @@ //| Adapter //| Characteristic //| Descriptor +//| Device //| ScanEntry //| Scanner //| Service @@ -76,6 +78,7 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AdvertisementData), MP_ROM_PTR(&bleio_advertisementdata_type) }, { MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) }, { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, + { MP_ROM_QSTR(MP_QSTR_Device), MP_ROM_PTR(&bleio_device_type) }, { MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) }, { MP_ROM_QSTR(MP_QSTR_Scanner), MP_ROM_PTR(&bleio_scanner_type) }, { MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&bleio_service_type) }, diff --git a/shared-module/bleio/AdvertisementData.h b/shared-module/bleio/AdvertisementData.h index 2a9addf57..738d53b23 100644 --- a/shared-module/bleio/AdvertisementData.h +++ b/shared-module/bleio/AdvertisementData.h @@ -27,6 +27,8 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H #define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H +#include "py/obj.h" + // Taken from https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile enum { AdFlags = 0x01, @@ -73,4 +75,11 @@ enum { AdManufacturerSpecificData = 0xFF, }; +typedef struct { + mp_obj_t device_name; + mp_obj_t services; + mp_obj_t data; + bool connectable; +} bleio_advertisement_data_t; + #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H diff --git a/shared-module/bleio/Device.h b/shared-module/bleio/Device.h new file mode 100644 index 000000000..afbd8f063 --- /dev/null +++ b/shared-module/bleio/Device.h @@ -0,0 +1,45 @@ +/* + * 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_MODULE_BLEIO_DEVICE_H +#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_DEVICE_H + +#include + +#include "shared-module/bleio/Address.h" + +typedef struct { + mp_obj_base_t base; + bool is_peripheral; + mp_obj_t name; + bleio_address_obj_t address; + uint16_t conn_handle; + mp_obj_t service_list; + mp_obj_t notif_handler; + mp_obj_t conn_handler; +} bleio_device_obj_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_DEVICE_H diff --git a/shared-module/bleio/ScanEntry.h b/shared-module/bleio/ScanEntry.h new file mode 100644 index 000000000..2f01669e2 --- /dev/null +++ b/shared-module/bleio/ScanEntry.h @@ -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_MODULE_BLEIO_SCANENTRY_H +#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANENTRY_H + +#include "shared-module/bleio/Address.h" + +typedef struct { + mp_obj_base_t base; + bleio_address_obj_t address; + bool connectable; + int8_t rssi; + mp_obj_t data; +} bleio_scanentry_obj_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANENTRY_H diff --git a/shared-module/bleio/Service.h b/shared-module/bleio/Service.h index bd359a41d..1e3f09119 100644 --- a/shared-module/bleio/Service.h +++ b/shared-module/bleio/Service.h @@ -27,7 +27,6 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H #define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H -#include "modubluepy.h" #include "common-hal/bleio/UUID.h" typedef struct { @@ -35,7 +34,7 @@ typedef struct { uint16_t handle; bool is_secondary; bleio_uuid_obj_t *uuid; - mp_obj_t periph; + mp_obj_t device; mp_obj_t char_list; uint16_t start_handle; uint16_t end_handle; -- cgit v1.2.3 From 4bc24c4f6084e414f0fb00299aae7d7cfdb76aba Mon Sep 17 00:00:00 2001 From: arturo182 Date: Fri, 31 Aug 2018 21:34:01 +0200 Subject: bleio: Fix errors after rebase --- .travis.yml | 2 +- conf.py | 2 +- locale/circuitpython.pot | 233 ++++++++++++-------- locale/de_DE.po | 253 +++++++++++++--------- locale/en_US.po | 233 ++++++++++++-------- locale/es.po | 324 +++++++++++++++++----------- locale/fil.po | 321 ++++++++++++++++----------- locale/fr.po | 320 ++++++++++++++++----------- locale/it_IT.po | 321 ++++++++++++++++----------- locale/pt_BR.po | 317 ++++++++++++++++----------- ports/nrf/Makefile | 7 +- ports/nrf/common-hal/bleio/Adapter.c | 8 +- ports/nrf/common-hal/bleio/Characteristic.c | 12 +- ports/nrf/common-hal/bleio/Device.c | 32 +-- ports/nrf/common-hal/bleio/Scanner.c | 4 +- ports/nrf/common-hal/bleio/Service.c | 2 +- ports/nrf/common-hal/bleio/UUID.c | 6 +- shared-bindings/bleio/Address.c | 4 +- shared-bindings/bleio/Characteristic.c | 2 +- shared-bindings/bleio/Device.c | 12 +- shared-bindings/bleio/ScanEntry.c | 2 +- shared-bindings/bleio/Service.c | 2 +- 22 files changed, 1472 insertions(+), 947 deletions(-) (limited to 'shared-bindings/bleio/ScanEntry.c') diff --git a/.travis.yml b/.travis.yml index 6cfa869b0..821165cce 100755 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ before_script: - (! var_search "${TRAVIS_SDK-}" arm || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~trusty1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb)) # For nrf builds - - (! var_search "${TRAVIS_SDK-}" nrf || sudo ports/nrf/drivers/bluetooth/download_ble_stack.sh) + - (! var_search "${TRAVIS_SDK-}" nrf || sudo ports/nrf/bluetooth/download_ble_stack.sh) # For huzzah builds - (! var_search "${TRAVIS_SDK-}" esp8266 || (wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz && tar -C .. -xavf xtensa-lx106-elf-standalone.tar.gz)) diff --git a/conf.py b/conf.py index 0f363923f..d4b7c7234 100644 --- a/conf.py +++ b/conf.py @@ -114,7 +114,7 @@ exclude_patterns = ["**/build*", "ports/esp8266/modules", "ports/minimal", "ports/nrf/device", - "ports/nrf/drivers", + "ports/nrf/bluetooth", "ports/nrf/modules", "ports/nrf/nrfx", "ports/nrf/peripherals", diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 83662734a..9f2e29430 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -291,12 +291,12 @@ msgid "Too many channels in sample." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "" @@ -312,43 +312,44 @@ msgstr "" msgid "sampling rate out of range" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -361,7 +362,7 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "" @@ -413,8 +414,8 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "" @@ -695,143 +696,165 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:95 -msgid "All I2C peripherals are in use" +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:115 -msgid "All SPI peripherals are in use" +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:48 +#: ports/nrf/common-hal/bleio/Adapter.c:135 #, c-format -msgid "error = 0x%08lX" +msgid "Failed to get softdevice state, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:86 -msgid "Invalid buffer size" +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:90 -msgid "Odd parity is not supported" +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, c-format +msgid "Failed to write gatts value, status: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 -#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 -#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 -#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 -#: ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not available" +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/microcontroller/Processor.c:49 +#: ports/nrf/common-hal/bleio/Characteristic.c:91 #, c-format -msgid "Can not get temperature. status: 0x%02x" +msgid "Failed to read attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 -msgid "All PWM peripherals are in use" +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, c-format +msgid "Failed to write attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +msgid "Can not fit data into the advertisment packet" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." +#: ports/nrf/common-hal/bleio/Device.c:436 +#, c-format +msgid "Failed to connect, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." +#: ports/nrf/common-hal/bleio/Device.c:513 +#, c-format +msgid "Failed to add service, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." +#: ports/nrf/common-hal/bleio/Device.c:531 +#, c-format +msgid "Failed to start advertisment, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." +#: ports/nrf/common-hal/bleio/Device.c:549 +#, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, c-format +msgid "Failed to start scanning, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 +#: ports/nrf/common-hal/bleio/Device.c:592 #, c-format -msgid "Can not apply advertisement data. status: 0x%02x" +msgid "Failed to create mutex, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 +#: ports/nrf/common-hal/bleio/Service.c:83 #, c-format -msgid "Can not start advertisement. status: 0x%02x" +msgid "Failed to add characteristic, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 +#: ports/nrf/common-hal/bleio/UUID.c:97 #, c-format -msgid "Can not stop advertisement. status: 0x%02x" +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" +#: ports/nrf/common-hal/busio/I2C.c:96 +msgid "All I2C peripherals are in use" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" +#: ports/nrf/common-hal/busio/SPI.c:115 +msgid "All SPI peripherals are in use" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 +#: ports/nrf/common-hal/busio/UART.c:48 #, c-format -msgid "Can not connect. status: 0x%02x" +msgid "error = 0x%08lX" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" +#: ports/nrf/common-hal/busio/UART.c:86 +msgid "Invalid buffer size" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" +#: ports/nrf/common-hal/busio/UART.c:90 +msgid "Odd parity is not supported" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 +msgid "busio.UART not available" +msgstr "" + +#: ports/nrf/common-hal/microcontroller/Processor.c:49 +#, c-format +msgid "Can not get temperature. status: 0x%02x" +msgstr "" + +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 +msgid "All PWM peripherals are in use" msgstr "" #: ports/unix/modffi.c:138 @@ -1994,7 +2017,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "" #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "" @@ -2087,6 +2110,30 @@ msgstr "" msgid "buffer slices must be of equal length" msgstr "" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +msgid "Wrong number of bytes provided" +msgstr "" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "" @@ -2201,7 +2248,7 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "" @@ -2263,7 +2310,7 @@ msgstr "" msgid "Read-only" msgstr "" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index de9a21e96..4f62ba4f9 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -300,12 +300,12 @@ msgid "Too many channels in sample." msgstr "Zu viele Kanäle im sample" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "Kein DMA Kanal gefunden" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren" @@ -321,43 +321,44 @@ msgstr "Nur 8 oder 16 bit mono mit " msgid "sampling rate out of range" msgstr "Abtastrate außerhalb der Reichweite" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "DAC wird schon benutzt" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "Rechter Kanal wird nicht unterstützt" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "Ungültiger Pin" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "Ungültiger Pin für linken Kanal" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "Ungültiger Pin für rechten Kanal" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "Kann nicht beite Kanäle auf dem gleichen Pin ausgeben" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "Alle timer werden benutzt" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "Alle event Kanälre werden benutzt" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -370,7 +371,7 @@ msgstr "Nicht genug Pins vorhanden" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "Ungültige Pins" @@ -422,8 +423,8 @@ msgstr "Reset zum bootloader nicht möglich da bootloader nicht vorhanden" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "Ungültige PWM Frequenz" @@ -704,150 +705,172 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:95 -#, fuzzy -msgid "All I2C peripherals are in use" -msgstr "Alle timer werden benutzt" - -#: ports/nrf/common-hal/busio/SPI.c:115 -#, fuzzy -msgid "All SPI peripherals are in use" -msgstr "Alle timer werden benutzt" - -#: ports/nrf/common-hal/busio/UART.c:48 +#: ports/nrf/common-hal/bleio/Adapter.c:41 #, c-format -msgid "error = 0x%08lX" +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:86 -#, fuzzy -msgid "Invalid buffer size" -msgstr "ungültiger dupterm index" - -#: ports/nrf/common-hal/busio/UART.c:90 -#, fuzzy -msgid "Odd parity is not supported" -msgstr "bytes mit merh als 8 bits werden nicht unterstützt" - -#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 -#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 -#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 -#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 -#: ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not available" +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/microcontroller/Processor.c:49 +#: ports/nrf/common-hal/bleio/Adapter.c:135 #, c-format -msgid "Can not get temperature. status: 0x%02x" +msgid "Failed to get softdevice state, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 -#, fuzzy -msgid "All PWM peripherals are in use" -msgstr "Alle timer werden benutzt" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, c-format +msgid "Failed to write gatts value, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." +#: ports/nrf/common-hal/bleio/Characteristic.c:91 +#, c-format +msgid "Failed to read attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, c-format +msgid "Failed to write attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +msgid "Can not fit data into the advertisment packet" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 +#: ports/nrf/common-hal/bleio/Device.c:436 #, c-format -msgid "Can not apply advertisement data. status: 0x%02x" +msgid "Failed to connect, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 +#: ports/nrf/common-hal/bleio/Device.c:513 #, c-format -msgid "Can not start advertisement. status: 0x%02x" +msgid "Failed to add service, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 +#: ports/nrf/common-hal/bleio/Device.c:531 #, c-format -msgid "Can not stop advertisement. status: 0x%02x" +msgid "Failed to start advertisment, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 +#: ports/nrf/common-hal/bleio/Device.c:549 #, c-format -msgid "Can not read attribute value. status: 0x%02x" +msgid "Failed to stop advertisment, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 #, c-format -msgid "Can not write attribute value. status: 0x%02x" +msgid "Failed to start scanning, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 +#: ports/nrf/common-hal/bleio/Device.c:592 #, c-format -msgid "Can not notify attribute value. status: 0x%02x" +msgid "Failed to create mutex, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 +#: ports/nrf/common-hal/bleio/Service.c:83 #, c-format -msgid "Can not start scanning. status: 0x%02x" +msgid "Failed to add characteristic, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 +#: ports/nrf/common-hal/bleio/UUID.c:97 #, c-format -msgid "Can not connect. status: 0x%02x" +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 msgid "Invalid UUID parameter" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" +#: ports/nrf/common-hal/busio/I2C.c:96 +#, fuzzy +msgid "All I2C peripherals are in use" +msgstr "Alle timer werden benutzt" + +#: ports/nrf/common-hal/busio/SPI.c:115 +#, fuzzy +msgid "All SPI peripherals are in use" +msgstr "Alle timer werden benutzt" + +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +#, fuzzy +msgid "Invalid buffer size" +msgstr "ungültiger dupterm index" + +#: ports/nrf/common-hal/busio/UART.c:90 +#, fuzzy +msgid "Odd parity is not supported" +msgstr "bytes mit merh als 8 bits werden nicht unterstützt" + +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 +msgid "busio.UART not available" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" +#: ports/nrf/common-hal/microcontroller/Processor.c:49 +#, c-format +msgid "Can not get temperature. status: 0x%02x" msgstr "" +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 +#, fuzzy +msgid "All PWM peripherals are in use" +msgstr "Alle timer werden benutzt" + #: ports/unix/modffi.c:138 msgid "Unknown type" msgstr "" @@ -2009,7 +2032,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "" #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "" @@ -2105,6 +2128,30 @@ msgstr "" msgid "buffer slices must be of equal length" msgstr "" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +msgid "Wrong number of bytes provided" +msgstr "" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "" @@ -2220,7 +2267,7 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "" @@ -2282,7 +2329,7 @@ msgstr "" msgid "Read-only" msgstr "" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index 15c97e329..1963390e2 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -291,12 +291,12 @@ msgid "Too many channels in sample." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "" @@ -312,43 +312,44 @@ msgstr "" msgid "sampling rate out of range" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -361,7 +362,7 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "" @@ -413,8 +414,8 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "" @@ -695,143 +696,165 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:95 -msgid "All I2C peripherals are in use" +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:115 -msgid "All SPI peripherals are in use" +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:48 +#: ports/nrf/common-hal/bleio/Adapter.c:135 #, c-format -msgid "error = 0x%08lX" +msgid "Failed to get softdevice state, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:86 -msgid "Invalid buffer size" +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:90 -msgid "Odd parity is not supported" +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, c-format +msgid "Failed to write gatts value, status: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 -#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 -#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 -#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 -#: ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not available" +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/microcontroller/Processor.c:49 +#: ports/nrf/common-hal/bleio/Characteristic.c:91 #, c-format -msgid "Can not get temperature. status: 0x%02x" +msgid "Failed to read attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 -msgid "All PWM peripherals are in use" +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, c-format +msgid "Failed to write attribute value, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +msgid "Can not fit data into the advertisment packet" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." +#: ports/nrf/common-hal/bleio/Device.c:436 +#, c-format +msgid "Failed to connect, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." +#: ports/nrf/common-hal/bleio/Device.c:513 +#, c-format +msgid "Failed to add service, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." +#: ports/nrf/common-hal/bleio/Device.c:531 +#, c-format +msgid "Failed to start advertisment, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." +#: ports/nrf/common-hal/bleio/Device.c:549 +#, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, c-format +msgid "Failed to start scanning, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 +#: ports/nrf/common-hal/bleio/Device.c:592 #, c-format -msgid "Can not apply advertisement data. status: 0x%02x" +msgid "Failed to create mutex, status: 0x%0xlX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 +#: ports/nrf/common-hal/bleio/Service.c:83 #, c-format -msgid "Can not start advertisement. status: 0x%02x" +msgid "Failed to add characteristic, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 +#: ports/nrf/common-hal/bleio/UUID.c:97 #, c-format -msgid "Can not stop advertisement. status: 0x%02x" +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" +#: ports/nrf/common-hal/busio/I2C.c:96 +msgid "All I2C peripherals are in use" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" +#: ports/nrf/common-hal/busio/SPI.c:115 +msgid "All SPI peripherals are in use" msgstr "" -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 +#: ports/nrf/common-hal/busio/UART.c:48 #, c-format -msgid "Can not connect. status: 0x%02x" +msgid "error = 0x%08lX" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" +#: ports/nrf/common-hal/busio/UART.c:86 +msgid "Invalid buffer size" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" +#: ports/nrf/common-hal/busio/UART.c:90 +msgid "Odd parity is not supported" msgstr "" -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 +msgid "busio.UART not available" +msgstr "" + +#: ports/nrf/common-hal/microcontroller/Processor.c:49 +#, c-format +msgid "Can not get temperature. status: 0x%02x" +msgstr "" + +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 +msgid "All PWM peripherals are in use" msgstr "" #: ports/unix/modffi.c:138 @@ -1994,7 +2017,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "" #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "" @@ -2087,6 +2110,30 @@ msgstr "" msgid "buffer slices must be of equal length" msgstr "" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +msgid "Wrong number of bytes provided" +msgstr "" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "" @@ -2201,7 +2248,7 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "" @@ -2263,7 +2310,7 @@ msgstr "" msgid "Read-only" msgstr "" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "" diff --git a/locale/es.po b/locale/es.po index 60452ae34..71e2089f5 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -306,12 +306,12 @@ msgid "Too many channels in sample." msgstr "Demasiados canales en sample" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "No se encontró el canal DMA" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "No se pudieron asignar buffers para la conversión con signo" @@ -327,43 +327,44 @@ msgstr "Solo mono de 8 o 16 bit con" msgid "sampling rate out of range" msgstr "velocidad de muestreo fuera de rango" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "DAC ya está siendo utilizado" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "El canal derecho no tiene soporte" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "pin inválido" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "Pin inválido para canal izquierdo" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "Pin inválido para canal derecho" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "No es posible utilizar el mismo pin para ambos canales" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "Todos los timers están siendo utilizados" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "Todos los canales de eventos están siendo utilizados" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor que %d" @@ -376,7 +377,7 @@ msgstr "No hay suficientes pines disponibles" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "pines inválidos" @@ -428,8 +429,8 @@ msgstr "No se puede reiniciar en bootloader porque no hay bootloader presente." #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "Frecuencia PWM inválida" @@ -712,7 +713,131 @@ msgstr "parámetro config desconocido" msgid "AnalogOut functionality not supported" msgstr "Funcionalidad AnalogOut no soportada" -#: ports/nrf/common-hal/busio/I2C.c:95 +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:135 +#, c-format +msgid "Failed to get softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, fuzzy, c-format +msgid "Failed to write gatts value, status: 0x%08lX" +msgstr "No se puede escribir el valor del atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, fuzzy, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" +msgstr "No se puede notificar el valor del anuncio. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:91 +#, fuzzy, c-format +msgid "Failed to read attribute value, status: 0x%08lX" +msgstr "No se puede leer el valor del atributo. status 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, fuzzy, c-format +msgid "Failed to write attribute value, status: 0x%08lX" +msgstr "No se puede escribir el valor del atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +#, fuzzy +msgid "Can not fit data into the advertisment packet" +msgstr "Los datos no caben en el paquete de anuncio." + +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, fuzzy, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" +msgstr "No se puede iniciar el escaneo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:436 +#, fuzzy, c-format +msgid "Failed to connect, status: 0x%08lX" +msgstr "No se puede conectar. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:513 +#, fuzzy, c-format +msgid "Failed to add service, status: 0x%08lX" +msgstr "No se puede detener el anuncio. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:531 +#, fuzzy, c-format +msgid "Failed to start advertisment, status: 0x%08lX" +msgstr "No se puede inicar el anuncio. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:549 +#, fuzzy, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" +msgstr "No se puede detener el anuncio. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, fuzzy, c-format +msgid "Failed to start scanning, status: 0x%0xlX" +msgstr "No se puede iniciar el escaneo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:592 +#, fuzzy, c-format +msgid "Failed to create mutex, status: 0x%0xlX" +msgstr "No se puede leer el valor del atributo. status 0x%02x" + +#: ports/nrf/common-hal/bleio/Service.c:83 +#, c-format +msgid "Failed to add characteristic, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:97 +#, fuzzy, c-format +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" +msgstr "No se puede agregar el UUID de 128-bits Especifico del Vendedor." + +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" +msgstr "Longitud de string UUID inválida" + +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" +msgstr "Parámetro UUID inválido" + +#: ports/nrf/common-hal/busio/I2C.c:96 msgid "All I2C peripherals are in use" msgstr "Todos los timers están siendo utilizados" @@ -746,112 +871,11 @@ msgstr "busio.UART no disponible" msgid "Can not get temperature. status: 0x%02x" msgstr "No se puede obtener la temperatura. status: 0x%02x" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 #, fuzzy msgid "All PWM peripherals are in use" msgstr "Todos los timers están siendo utilizados" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." -msgstr "No se pueden aplicar los parámetros GAP." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." -msgstr "No se pueden establecer los parámetros PPCP." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." -msgstr "No se puede consultar la dirección del dispositivo." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." -msgstr "No se puede agregar el UUID de 128-bits Especifico del Vendedor." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." -msgstr "No se puede agregar el Servicio" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." -msgstr "No se puede agregar la Característica" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." -msgstr "No se puede aplicar el nombre del dispositivo en el stack." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." -msgstr "No se puede codificar el UUID, para revisar la longitud." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." -msgstr "Se puede codificar el UUID en el paquete de anuncio." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." -msgstr "Los datos no caben en el paquete de anuncio." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 -#, c-format -msgid "Can not apply advertisement data. status: 0x%02x" -msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 -#, c-format -msgid "Can not start advertisement. status: 0x%02x" -msgstr "No se puede inicar el anuncio. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 -#, c-format -msgid "Can not stop advertisement. status: 0x%02x" -msgstr "No se puede detener el anuncio. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" -msgstr "No se puede leer el valor del atributo. status 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" -msgstr "No se puede escribir el valor del atributo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" -msgstr "No se puede notificar el valor del anuncio. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" -msgstr "No se puede iniciar el escaneo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 -#, c-format -msgid "Can not connect. status: 0x%02x" -msgstr "No se puede conectar. status: 0x%02x" - -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" -msgstr "Parámetro UUID inválido" - -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" -msgstr "Tipo de Servicio inválido" - -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" -msgstr "Longitud de string UUID inválida" - #: ports/unix/modffi.c:138 msgid "Unknown type" msgstr "" @@ -2036,7 +2060,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "" #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "" @@ -2094,8 +2118,8 @@ msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" msgstr "" -"sample_source buffer debe ser un bytearray o un array de tipo 'h', 'H', 'b' o" -"'B'" +"sample_source buffer debe ser un bytearray o un array de tipo 'h', 'H', 'b' " +"o'B'" #: shared-bindings/audioio/RawSample.c:104 msgid "buffer must be a bytes-like object" @@ -2131,6 +2155,30 @@ msgstr "" msgid "buffer slices must be of equal length" msgstr "" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +msgid "Wrong number of bytes provided" +msgstr "" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "" @@ -2246,7 +2294,7 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "" @@ -2309,7 +2357,7 @@ msgstr "" msgid "Read-only" msgstr "Solo lectura" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "" @@ -2501,3 +2549,33 @@ msgstr "" #~ msgid "Baud rate too high for this SPI peripheral" #~ msgstr "Baud rate demasiado alto para este periférico SPI" + +#~ msgid "Invalid Service type" +#~ msgstr "Tipo de Servicio inválido" + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x" + +#~ msgid "Can encode UUID into the advertisement packet." +#~ msgstr "Se puede codificar el UUID en el paquete de anuncio." + +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "No se puede codificar el UUID, para revisar la longitud." + +#~ msgid "Can not apply device name in the stack." +#~ msgstr "No se puede aplicar el nombre del dispositivo en el stack." + +#~ msgid "Can not add Characteristic." +#~ msgstr "No se puede agregar la Característica" + +#~ msgid "Can not add Service." +#~ msgstr "No se puede agregar el Servicio" + +#~ msgid "Can not query for the device address." +#~ msgstr "No se puede consultar la dirección del dispositivo." + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "No se pueden establecer los parámetros PPCP." + +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "No se pueden aplicar los parámetros GAP." diff --git a/locale/fil.po b/locale/fil.po index e4f3105c9..f6df8fa20 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -303,12 +303,12 @@ msgid "Too many channels in sample." msgstr "Sobra ang channels sa sample." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "Walang DMA channel na mahanap" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "Hindi ma-allocate ang buffers para sa naka-sign na conversion" @@ -324,43 +324,44 @@ msgstr "Tanging 8 o 16 na bit mono na may " msgid "sampling rate out of range" msgstr "pagpili ng rate wala sa sakop" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "Ginagamit na ang DAC" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "Hindi supportado ang kanang channel" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "Mali ang pin" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "Mali ang pin para sa kaliwang channel" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "Mali ang pin para sa kanang channel" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "Hindi maaaring output ang mga parehong channel sa parehong pin" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "Lahat ng timer ginagamit" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "Lahat ng event channels ginagamit" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -373,7 +374,7 @@ msgstr "Hindi sapat ang magagamit na pins" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "Mali ang pins" @@ -425,8 +426,8 @@ msgstr "Hindi ma-reset sa bootloader dahil walang bootloader." #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "Mali ang PWM frequency" @@ -710,7 +711,131 @@ msgstr "hindi alam na config param" msgid "AnalogOut functionality not supported" msgstr "Hindi supportado ang AnalogOut" -#: ports/nrf/common-hal/busio/I2C.c:95 +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:135 +#, c-format +msgid "Failed to get softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, fuzzy, c-format +msgid "Failed to write gatts value, status: 0x%08lX" +msgstr "Hindi maisulat ang attribute value. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, fuzzy, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" +msgstr "Hindi mabalitaan ang attribute value. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:91 +#, fuzzy, c-format +msgid "Failed to read attribute value, status: 0x%08lX" +msgstr "Hindi mabasa ang value ng attribute. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, fuzzy, c-format +msgid "Failed to write attribute value, status: 0x%08lX" +msgstr "Hindi maisulat ang attribute value. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +#, fuzzy +msgid "Can not fit data into the advertisment packet" +msgstr "Hindi makasya ang data sa loob ng advertisement packet." + +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, fuzzy, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" +msgstr "Hindi masimulaan mag i-scan. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:436 +#, fuzzy, c-format +msgid "Failed to connect, status: 0x%08lX" +msgstr "Hindi makaconnect. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:513 +#, fuzzy, c-format +msgid "Failed to add service, status: 0x%08lX" +msgstr "Hindi mahinto ang advertisement. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:531 +#, fuzzy, c-format +msgid "Failed to start advertisment, status: 0x%08lX" +msgstr "Hindi masimulaan ang advertisement. status 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:549 +#, fuzzy, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" +msgstr "Hindi mahinto ang advertisement. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, fuzzy, c-format +msgid "Failed to start scanning, status: 0x%0xlX" +msgstr "Hindi masimulaan mag i-scan. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:592 +#, fuzzy, c-format +msgid "Failed to create mutex, status: 0x%0xlX" +msgstr "Hindi mabasa ang value ng attribute. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Service.c:83 +#, c-format +msgid "Failed to add characteristic, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:97 +#, fuzzy, c-format +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" +msgstr "Hindi maaaring magdagdag ng Vendor Specific na 128-bit UUID." + +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" +msgstr "Mali ang UUID string length" + +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" +msgstr "Mali ang UUID parameter" + +#: ports/nrf/common-hal/busio/I2C.c:96 #, fuzzy msgid "All I2C peripherals are in use" msgstr "Lahat ng timer ginagamit" @@ -748,112 +873,11 @@ msgstr "" msgid "Can not get temperature. status: 0x%02x" msgstr "Hindi makuha ang temperatura. status 0x%02x" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 #, fuzzy msgid "All PWM peripherals are in use" msgstr "Lahat ng timer ginagamit" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." -msgstr "Hindi ma-apply ang GAP parameters." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." -msgstr "Hindi ma-set ang PPCP parameters." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." -msgstr "Hindi maaaring mag-query para sa address ng device." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." -msgstr "Hindi maaaring magdagdag ng Vendor Specific na 128-bit UUID." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." -msgstr "Hindi maidaragdag ang serbisyo." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." -msgstr "Hindi mabasa and Characteristic." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." -msgstr "Hindi maaaring ma-aplay ang device name sa stack." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." -msgstr "Hindi ma-encode UUID, para suriin ang haba." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." -msgstr "Maaring i-encode ang UUID sa advertisement packet." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." -msgstr "Hindi makasya ang data sa loob ng advertisement packet." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 -#, c-format -msgid "Can not apply advertisement data. status: 0x%02x" -msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 -#, c-format -msgid "Can not start advertisement. status: 0x%02x" -msgstr "Hindi masimulaan ang advertisement. status 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 -#, c-format -msgid "Can not stop advertisement. status: 0x%02x" -msgstr "Hindi mahinto ang advertisement. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" -msgstr "Hindi mabasa ang value ng attribute. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" -msgstr "Hindi maisulat ang attribute value. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" -msgstr "Hindi mabalitaan ang attribute value. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" -msgstr "Hindi masimulaan mag i-scan. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 -#, c-format -msgid "Can not connect. status: 0x%02x" -msgstr "Hindi makaconnect. status: 0x%02x" - -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" -msgstr "Mali ang UUID parameter" - -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" -msgstr "Mali ang tipo ng serbisyo" - -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" -msgstr "Mali ang UUID string length" - #: ports/unix/modffi.c:138 msgid "Unknown type" msgstr "Hindi alam ang type" @@ -2033,7 +2057,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "AnalogOut ay 16 bits. Value ay dapat hindi hihigit pa sa 65536." #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "Hindi playing" @@ -2137,6 +2161,31 @@ msgstr "Mali ang bilang ng bits" msgid "buffer slices must be of equal length" msgstr "aarehas na haba dapat ang buffer slices" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +#, fuzzy +msgid "Wrong number of bytes provided" +msgstr "mali ang bilang ng argumento" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "Kailangan ng lock ang function." @@ -2265,7 +2314,7 @@ msgstr "walang laman ang address" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "Umasa ng %q" @@ -2329,7 +2378,7 @@ msgstr "index ay dapat int" msgid "Read-only" msgstr "Basahin-lamang" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "May halfwords (type 'H') dapat ang array" @@ -2524,3 +2573,33 @@ msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format" #, fuzzy #~ msgid "palette must be displayio.Palette" #~ msgstr "ang palette ay dapat 32 bytes ang haba" + +#~ msgid "Invalid Service type" +#~ msgstr "Mali ang tipo ng serbisyo" + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x" + +#~ msgid "Can encode UUID into the advertisement packet." +#~ msgstr "Maaring i-encode ang UUID sa advertisement packet." + +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "Hindi ma-encode UUID, para suriin ang haba." + +#~ msgid "Can not apply device name in the stack." +#~ msgstr "Hindi maaaring ma-aplay ang device name sa stack." + +#~ msgid "Can not add Characteristic." +#~ msgstr "Hindi mabasa and Characteristic." + +#~ msgid "Can not add Service." +#~ msgstr "Hindi maidaragdag ang serbisyo." + +#~ msgid "Can not query for the device address." +#~ msgstr "Hindi maaaring mag-query para sa address ng device." + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Hindi ma-set ang PPCP parameters." + +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Hindi ma-apply ang GAP parameters." diff --git a/locale/fr.po b/locale/fr.po index 02beae6d0..8949a6899 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -298,12 +298,12 @@ msgid "Too many channels in sample." msgstr "Trop de canaux dans l'échantillon." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "Aucun canal DMA trouvé" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "Impossible d'allouer des tampons pour une conversion signée" @@ -319,43 +319,44 @@ msgstr "Uniquement 8 ou 16 bit mono avec " msgid "sampling rate out of range" msgstr "taux d'échantillonage hors gamme" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "DAC déjà utilisé" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "Canal droit non supporté" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "Broche invalide" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "Broche invalide pour le canal gauche" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "Broche invalide pour le canal droit" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "On ne peut mettre les deux canaux sur la même broche" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "Tous les timers sont utilisés" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "Tous les canaux d'événements sont utilisés" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -368,7 +369,7 @@ msgstr "Pas assez de broches disponibles" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "Broche invalide" @@ -421,8 +422,8 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "Fréquence de PWM invalide" @@ -706,7 +707,130 @@ msgstr "paramètre de config. inconnu" msgid "AnalogOut functionality not supported" msgstr "AnalogOut non supporté" -#: ports/nrf/common-hal/busio/I2C.c:95 +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:135 +#, c-format +msgid "Failed to get softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, fuzzy, c-format +msgid "Failed to write gatts value, status: 0x%08lX" +msgstr "Impossible d'écrire la valeur de l'attribut. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, fuzzy, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" +msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:91 +#, fuzzy, c-format +msgid "Failed to read attribute value, status: 0x%08lX" +msgstr "Impossible de lire la valeur de l'attribut. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, fuzzy, c-format +msgid "Failed to write attribute value, status: 0x%08lX" +msgstr "Impossible d'écrire la valeur de l'attribut. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +msgid "Can not fit data into the advertisment packet" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, fuzzy, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" +msgstr "Impossible de commencer à scanner. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:436 +#, fuzzy, c-format +msgid "Failed to connect, status: 0x%08lX" +msgstr "Connection impossible. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:513 +#, c-format +msgid "Failed to add service, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:531 +#, fuzzy, c-format +msgid "Failed to start advertisment, status: 0x%08lX" +msgstr "Impossible de commencer à scanner. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:549 +#, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, fuzzy, c-format +msgid "Failed to start scanning, status: 0x%0xlX" +msgstr "Impossible de commencer à scanner. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:592 +#, fuzzy, c-format +msgid "Failed to create mutex, status: 0x%0xlX" +msgstr "Impossible de lire la valeur de l'attribut. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Service.c:83 +#, c-format +msgid "Failed to add characteristic, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:97 +#, fuzzy, c-format +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" +msgstr "Impossible d'ajouter l'UUID 128bits Vendor Specific" + +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" +msgstr "Longeur de chaîne UUID invalide" + +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" +msgstr "Paramètre UUID invalide" + +#: ports/nrf/common-hal/busio/I2C.c:96 #, fuzzy msgid "All I2C peripherals are in use" msgstr "Tous les timers sont utilisés" @@ -745,112 +869,11 @@ msgstr "busio.UART n'est pas disponible" msgid "Can not get temperature. status: 0x%02x" msgstr "Impossible de lire la température. status: 0x%02x" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 #, fuzzy msgid "All PWM peripherals are in use" msgstr "Tous les timers sont utilisés" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." -msgstr "Impossible d'appliquer les paramètres GAP" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." -msgstr "Impossible d'appliquer les paramètres PPCP" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." -msgstr "Impossible d'obtenir l'adresse du périphérique" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." -msgstr "Impossible d'ajouter l'UUID 128bits Vendor Specific" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." -msgstr "Impossible d'ajouter le Service" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." -msgstr "Impossible d'ajouter la Characteristic." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." -msgstr "Impossible d'appliquer le nom de périphérique dans la pile" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." -msgstr "Impossible d'encoder l'UUID pour vérifier la longueur." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 -#, c-format -msgid "Can not apply advertisement data. status: 0x%02x" -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 -#, c-format -msgid "Can not start advertisement. status: 0x%02x" -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 -#, c-format -msgid "Can not stop advertisement. status: 0x%02x" -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" -msgstr "Impossible de lire la valeur de l'attribut. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" -msgstr "Impossible d'écrire la valeur de l'attribut. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" -msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" -msgstr "Impossible de commencer à scanner. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 -#, c-format -msgid "Can not connect. status: 0x%02x" -msgstr "Connection impossible. status: 0x%02x" - -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" -msgstr "Paramètre UUID invalide" - -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" -msgstr "Type de service invalide" - -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" -msgstr "Longeur de chaîne UUID invalide" - #: ports/unix/modffi.c:138 msgid "Unknown type" msgstr "Type inconnu" @@ -2027,7 +2050,7 @@ msgstr "" "65536." #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "En pause" @@ -2128,6 +2151,31 @@ msgstr "Nombre de bits invalide" msgid "buffer slices must be of equal length" msgstr "les slices de tampon doivent être de longueurs égales" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +#, fuzzy +msgid "Wrong number of bytes provided" +msgstr "mauvais nombres d'arguments" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "La fonction nécessite un verrou." @@ -2258,7 +2306,7 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "Attendu : %q" @@ -2325,7 +2373,7 @@ msgstr "l'index doit être un entier" msgid "Read-only" msgstr "Lecture seule" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "Le tableau doit contenir des halfwords (type 'H')" @@ -2517,10 +2565,34 @@ msgstr "'S' et 'O' ne sont pas des types de format supportés" msgid "too many arguments provided with the given format" msgstr "trop d'arguments fournis avec ce format" +#, fuzzy +#~ msgid "palette must be displayio.Palette" +#~ msgstr "la palette doit être longue de 32 octets" + #, fuzzy #~ msgid "value_size must be power of two" #~ msgstr "'len' doit être un multiple de 4" -#, fuzzy -#~ msgid "palette must be displayio.Palette" -#~ msgstr "la palette doit être longue de 32 octets" +#~ msgid "Invalid Service type" +#~ msgstr "Type de service invalide" + +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur." + +#~ msgid "Can not apply device name in the stack." +#~ msgstr "Impossible d'appliquer le nom de périphérique dans la pile" + +#~ msgid "Can not add Characteristic." +#~ msgstr "Impossible d'ajouter la Characteristic." + +#~ msgid "Can not add Service." +#~ msgstr "Impossible d'ajouter le Service" + +#~ msgid "Can not query for the device address." +#~ msgstr "Impossible d'obtenir l'adresse du périphérique" + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Impossible d'appliquer les paramètres PPCP" + +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Impossible d'appliquer les paramètres GAP" diff --git a/locale/it_IT.po b/locale/it_IT.po index 5490c699c..b3346e956 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -305,12 +305,12 @@ msgid "Too many channels in sample." msgstr "" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "Nessun canale DMA trovato" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "Ipossibilitato ad allocare buffer per la conversione con segno" @@ -326,43 +326,44 @@ msgstr "" msgid "sampling rate out of range" msgstr "frequenza di campionamento fuori intervallo" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "DAC già in uso" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "Canale destro non supportato" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "Pin non valido" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "Pin non valido per il canale sinistro" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "Pin non valido per il canale destro" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "Impossibile dare in output entrambi i canal sullo stesso pin" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "Tutti i timer utilizzati" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "Tutti i canali eventi utilizati" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -376,7 +377,7 @@ msgstr "Non sono presenti abbastanza pin" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "Pin non validi" @@ -429,8 +430,8 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "Frequenza PWM non valida" @@ -712,7 +713,131 @@ msgstr "parametro di configurazione sconosciuto" msgid "AnalogOut functionality not supported" msgstr "funzionalità AnalogOut non supportata" -#: ports/nrf/common-hal/busio/I2C.c:95 +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:135 +#, c-format +msgid "Failed to get softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, fuzzy, c-format +msgid "Failed to write gatts value, status: 0x%08lX" +msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, fuzzy, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" +msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:91 +#, fuzzy, c-format +msgid "Failed to read attribute value, status: 0x%08lX" +msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, fuzzy, c-format +msgid "Failed to write attribute value, status: 0x%08lX" +msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +#, fuzzy +msgid "Can not fit data into the advertisment packet" +msgstr "Impossibile inserire dati nel pacchetto di advertisement." + +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, fuzzy, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" +msgstr "Impossible iniziare la scansione. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:436 +#, fuzzy, c-format +msgid "Failed to connect, status: 0x%08lX" +msgstr "Impossibile connettersi. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:513 +#, fuzzy, c-format +msgid "Failed to add service, status: 0x%08lX" +msgstr "Impossibile fermare advertisement. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:531 +#, fuzzy, c-format +msgid "Failed to start advertisment, status: 0x%08lX" +msgstr "Impossibile avviare advertisement. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:549 +#, fuzzy, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" +msgstr "Impossibile fermare advertisement. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, fuzzy, c-format +msgid "Failed to start scanning, status: 0x%0xlX" +msgstr "Impossible iniziare la scansione. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:592 +#, fuzzy, c-format +msgid "Failed to create mutex, status: 0x%0xlX" +msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Service.c:83 +#, c-format +msgid "Failed to add characteristic, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:97 +#, fuzzy, c-format +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" +msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit" + +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" +msgstr "Lunghezza della stringa UUID non valida" + +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" +msgstr "Parametro UUID non valido" + +#: ports/nrf/common-hal/busio/I2C.c:96 msgid "All I2C peripherals are in use" msgstr "Tutte le periferiche I2C sono in uso" @@ -749,112 +874,11 @@ msgstr "busio.UART non ancora implementato" msgid "Can not get temperature. status: 0x%02x" msgstr "Impossibile leggere la temperatura. status: 0x%02x" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 #, fuzzy msgid "All PWM peripherals are in use" msgstr "Tutte le periferiche SPI sono in uso" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." -msgstr "Impossibile applicare i parametri GAP." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." -msgstr "Impossibile impostare i parametri PPCP." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." -msgstr "Non è possibile trovare l'indirizzo del dispositivo." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." -msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." -msgstr "Non è possibile aggiungere Service." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." -msgstr "Non è possibile aggiungere Characteristic." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." -msgstr "Non è possibile inserire il nome del dipositivo nella lista." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." -msgstr "Non è possibile codificare l'UUID, lunghezza da controllare." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." -msgstr "È possibile codificare l'UUID nel pacchetto di advertisement." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." -msgstr "Impossibile inserire dati nel pacchetto di advertisement." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 -#, c-format -msgid "Can not apply advertisement data. status: 0x%02x" -msgstr "Impossible inserire dati advertisement. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 -#, c-format -msgid "Can not start advertisement. status: 0x%02x" -msgstr "Impossibile avviare advertisement. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 -#, c-format -msgid "Can not stop advertisement. status: 0x%02x" -msgstr "Impossibile fermare advertisement. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" -msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" -msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" -msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" -msgstr "Impossible iniziare la scansione. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 -#, c-format -msgid "Can not connect. status: 0x%02x" -msgstr "Impossibile connettersi. status: 0x%02x" - -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" -msgstr "Parametro UUID non valido" - -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" -msgstr "Tipo di servizio non valido" - -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" -msgstr "Lunghezza della stringa UUID non valida" - #: ports/unix/modffi.c:138 msgid "Unknown type" msgstr "Tipo sconosciuto" @@ -2029,7 +2053,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "AnalogOut ha solo 16 bit. Il valore deve essere meno di 65536." #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "In pausa" @@ -2132,6 +2156,31 @@ msgstr "Numero di bit non valido" msgid "buffer slices must be of equal length" msgstr "slice del buffer devono essere della stessa lunghezza" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +#, fuzzy +msgid "Wrong number of bytes provided" +msgstr "numero di argomenti errato" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "" @@ -2248,7 +2297,7 @@ msgstr "gli indirizzi sono vuoti" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "Atteso un %q" @@ -2315,7 +2364,7 @@ msgstr "l'indice deve essere int" msgid "Read-only" msgstr "Sola lettura" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "" @@ -2504,3 +2553,33 @@ msgstr "'S' e 'O' non sono formati supportati" #: shared-module/struct/__init__.c:83 msgid "too many arguments provided with the given format" msgstr "troppi argomenti forniti con il formato specificato" + +#~ msgid "Invalid Service type" +#~ msgstr "Tipo di servizio non valido" + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "Impossible inserire dati advertisement. status: 0x%02x" + +#~ msgid "Can encode UUID into the advertisement packet." +#~ msgstr "È possibile codificare l'UUID nel pacchetto di advertisement." + +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare." + +#~ msgid "Can not apply device name in the stack." +#~ msgstr "Non è possibile inserire il nome del dipositivo nella lista." + +#~ msgid "Can not add Characteristic." +#~ msgstr "Non è possibile aggiungere Characteristic." + +#~ msgid "Can not add Service." +#~ msgstr "Non è possibile aggiungere Service." + +#~ msgid "Can not query for the device address." +#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo." + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Impossibile impostare i parametri PPCP." + +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Impossibile applicare i parametri GAP." diff --git a/locale/pt_BR.po b/locale/pt_BR.po index f3d055c08..25c645106 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-09 20:51-0400\n" +"POT-Creation-Date: 2018-10-21 17:15+0200\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -291,12 +291,12 @@ msgid "Too many channels in sample." msgstr "Muitos canais na amostra." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:417 msgid "No DMA channel found" msgstr "Nenhum canal DMA encontrado" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:419 msgid "Unable to allocate buffers for signed conversion" msgstr "Não é possível alocar buffers para conversão assinada" @@ -312,43 +312,44 @@ msgstr "" msgid "sampling rate out of range" msgstr "Taxa de amostragem fora do intervalo" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:132 msgid "DAC already in use" msgstr "DAC em uso" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:136 msgid "Right channel unsupported" msgstr "Canal direito não suportado" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:139 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" msgstr "Pino inválido" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:147 msgid "Invalid pin for left channel" msgstr "Pino inválido para canal esquerdo" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:151 msgid "Invalid pin for right channel" msgstr "Pino inválido para canal direito" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:154 msgid "Cannot output both channels on the same pin" msgstr "" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:243 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +#: ports/nrf/common-hal/pulseio/PulseOut.c:107 msgid "All timers in use" msgstr "Todos os temporizadores em uso" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:285 msgid "All event channels in use" msgstr "Todos os canais de eventos em uso" -#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:375 #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" @@ -361,7 +362,7 @@ msgstr "Não há pinos suficientes disponíveis" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:81 +#: ports/nrf/common-hal/busio/I2C.c:82 msgid "Invalid pins" msgstr "Pinos inválidos" @@ -413,8 +414,8 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 -#: ports/nrf/common-hal/pulseio/PWMOut.c:120 -#: ports/nrf/common-hal/pulseio/PWMOut.c:232 +#: ports/nrf/common-hal/pulseio/PWMOut.c:119 +#: ports/nrf/common-hal/pulseio/PWMOut.c:233 msgid "Invalid PWM frequency" msgstr "Frequência PWM inválida" @@ -695,7 +696,131 @@ msgstr "parâmetro configuração desconhecido" msgid "AnalogOut functionality not supported" msgstr "Funcionalidade AnalogOut não suportada" -#: ports/nrf/common-hal/busio/I2C.c:95 +#: ports/nrf/common-hal/bleio/Adapter.c:41 +#, c-format +msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:125 +#, c-format +msgid "Failed to change softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:135 +#, c-format +msgid "Failed to get softdevice state, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Adapter.c:155 +#, c-format +msgid "Failed to get local address, error: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:52 +#, fuzzy, c-format +msgid "Failed to write gatts value, status: 0x%08lX" +msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:76 +#, fuzzy, c-format +msgid "Failed to notify attribute value, status: 0x%08lX" +msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:91 +#, fuzzy, c-format +msgid "Failed to read attribute value, status: 0x%08lX" +msgstr "Não é possível ler o valor do atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:119 +#: ports/nrf/common-hal/bleio/Device.c:272 +#: ports/nrf/common-hal/bleio/Device.c:307 +#, c-format +msgid "Failed to acquire mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Characteristic.c:126 +#, fuzzy, c-format +msgid "Failed to write attribute value, status: 0x%08lX" +msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Characteristic.c:138 +#: ports/nrf/common-hal/bleio/Device.c:284 +#: ports/nrf/common-hal/bleio/Device.c:319 +#: ports/nrf/common-hal/bleio/Device.c:354 +#: ports/nrf/common-hal/bleio/Device.c:391 +#, c-format +msgid "Failed to release mutex, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:81 +#: ports/nrf/common-hal/bleio/Device.c:114 +#, fuzzy +msgid "Can not fit data into the advertisment packet" +msgstr "Não é possível ajustar dados no pacote de anúncios." + +#: ports/nrf/common-hal/bleio/Device.c:266 +#, c-format +msgid "Failed to discover serivices, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:403 +#: ports/nrf/common-hal/bleio/Scanner.c:76 +#, c-format +msgid "Failed to continue scanning, status: 0x%0xlX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:436 +#, c-format +msgid "Failed to connect, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/Device.c:513 +#, fuzzy, c-format +msgid "Failed to add service, status: 0x%08lX" +msgstr "Não pode parar propaganda. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:531 +#, fuzzy, c-format +msgid "Failed to start advertisment, status: 0x%08lX" +msgstr "Não é possível iniciar o anúncio. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:549 +#, fuzzy, c-format +msgid "Failed to stop advertisment, status: 0x%08lX" +msgstr "Não pode parar propaganda. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:575 +#: ports/nrf/common-hal/bleio/Scanner.c:103 +#, fuzzy, c-format +msgid "Failed to start scanning, status: 0x%0xlX" +msgstr "Não é possível iniciar o anúncio. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Device.c:592 +#, fuzzy, c-format +msgid "Failed to create mutex, status: 0x%0xlX" +msgstr "Não é possível ler o valor do atributo. status: 0x%02x" + +#: ports/nrf/common-hal/bleio/Service.c:83 +#, c-format +msgid "Failed to add characteristic, status: 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:97 +#, fuzzy, c-format +msgid "Failed to add Vendor Specific UUID, status: 0x%08lX" +msgstr "Não é possível adicionar o UUID de 128 bits específico do fornecedor." + +#: ports/nrf/common-hal/bleio/UUID.c:102 +msgid "Invalid UUID string length" +msgstr "" + +#: ports/nrf/common-hal/bleio/UUID.c:109 +#: shared-bindings/bleio/Characteristic.c:125 +#: shared-bindings/bleio/Service.c:105 +msgid "Invalid UUID parameter" +msgstr "Parâmetro UUID inválido" + +#: ports/nrf/common-hal/busio/I2C.c:96 msgid "All I2C peripherals are in use" msgstr "Todos os periféricos I2C estão em uso" @@ -731,112 +856,11 @@ msgstr "busio.UART não disponível" msgid "Can not get temperature. status: 0x%02x" msgstr "Não pode obter a temperatura. status: 0x%02x" -#: ports/nrf/common-hal/pulseio/PWMOut.c:162 +#: ports/nrf/common-hal/pulseio/PWMOut.c:161 #, fuzzy msgid "All PWM peripherals are in use" msgstr "Todos os temporizadores em uso" -#: ports/nrf/drivers/bluetooth/ble_drv.c:199 -msgid "Cannot apply GAP parameters." -msgstr "Não é possível aplicar parâmetros GAP." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:213 -msgid "Cannot set PPCP parameters." -msgstr "Não é possível definir parâmetros PPCP." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:245 -msgid "Can not query for the device address." -msgstr "Não é possível consultar o endereço do dispositivo." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:264 -msgid "Can not add Vendor Specific 128-bit UUID." -msgstr "Não é possível adicionar o UUID de 128 bits específico do fornecedor." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:284 -#: ports/nrf/drivers/bluetooth/ble_drv.c:298 -msgid "Can not add Service." -msgstr "Não é possível adicionar o serviço." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:373 -msgid "Can not add Characteristic." -msgstr "Não é possível adicionar Característica." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:400 -msgid "Can not apply device name in the stack." -msgstr "Não é possível aplicar o nome do dispositivo na pilha." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:464 -#: ports/nrf/drivers/bluetooth/ble_drv.c:514 -msgid "Can not encode UUID, to check length." -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:470 -#: ports/nrf/drivers/bluetooth/ble_drv.c:520 -msgid "Can encode UUID into the advertisement packet." -msgstr "Pode codificar o UUID no pacote de anúncios." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:545 -msgid "Can not fit data into the advertisement packet." -msgstr "Não é possível ajustar dados no pacote de anúncios." - -#: ports/nrf/drivers/bluetooth/ble_drv.c:558 -#: ports/nrf/drivers/bluetooth/ble_drv.c:604 -#, c-format -msgid "Can not apply advertisement data. status: 0x%02x" -msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:614 -#, c-format -msgid "Can not start advertisement. status: 0x%02x" -msgstr "Não é possível iniciar o anúncio. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:631 -#, c-format -msgid "Can not stop advertisement. status: 0x%02x" -msgstr "Não pode parar propaganda. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:650 -#: ports/nrf/drivers/bluetooth/ble_drv.c:726 -#, c-format -msgid "Can not read attribute value. status: 0x%02x" -msgstr "Não é possível ler o valor do atributo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:667 -#: ports/nrf/drivers/bluetooth/ble_drv.c:756 -#, c-format -msgid "Can not write attribute value. status: 0x%02x" -msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:691 -#, c-format -msgid "Can not notify attribute value. status: 0x%02x" -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:784 -#, c-format -msgid "Can not start scanning. status: 0x%02x" -msgstr "" - -#: ports/nrf/drivers/bluetooth/ble_drv.c:829 -#, c-format -msgid "Can not connect. status: 0x%02x" -msgstr "" - -#: ports/nrf/modules/ubluepy/ubluepy_characteristic.c:68 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:80 -#: ports/nrf/modules/ubluepy/ubluepy_service.c:132 -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:137 -msgid "Invalid UUID parameter" -msgstr "Parâmetro UUID inválido" - -#: ports/nrf/modules/ubluepy/ubluepy_service.c:73 -msgid "Invalid Service type" -msgstr "Tipo de serviço inválido" - -#: ports/nrf/modules/ubluepy/ubluepy_uuid.c:127 -msgid "Invalid UUID string length" -msgstr "" - #: ports/unix/modffi.c:138 msgid "Unknown type" msgstr "Tipo desconhecido" @@ -1998,7 +2022,7 @@ msgid "AnalogOut is only 16 bits. Value must be less than 65536." msgstr "" #: shared-bindings/audiobusio/I2SOut.c:225 -#: shared-bindings/audioio/AudioOut.c:223 +#: shared-bindings/audioio/AudioOut.c:226 msgid "Not playing" msgstr "" @@ -2094,6 +2118,30 @@ msgstr "Número inválido de bits" msgid "buffer slices must be of equal length" msgstr "" +#: shared-bindings/bleio/Address.c:101 +msgid "Wrong address length" +msgstr "" + +#: shared-bindings/bleio/Address.c:107 +msgid "Wrong number of bytes provided" +msgstr "" + +#: shared-bindings/bleio/Device.c:210 +msgid "Can't add services in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:226 +msgid "Can't connect in Peripheral mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:256 +msgid "Can't change the name in Central mode" +msgstr "" + +#: shared-bindings/bleio/Device.c:277 shared-bindings/bleio/Device.c:313 +msgid "Can't advertise in Central mode" +msgstr "" + #: shared-bindings/busio/I2C.c:120 msgid "Function requires lock." msgstr "" @@ -2208,7 +2256,7 @@ msgstr "" #: shared-bindings/microcontroller/Pin.c:89 #: shared-bindings/neopixel_write/__init__.c:67 -#: shared-bindings/pulseio/PulseOut.c:75 +#: shared-bindings/pulseio/PulseOut.c:76 msgid "Expected a %q" msgstr "Esperado um" @@ -2270,7 +2318,7 @@ msgstr "index deve ser int" msgid "Read-only" msgstr "Somente leitura" -#: shared-bindings/pulseio/PulseOut.c:134 +#: shared-bindings/pulseio/PulseOut.c:135 msgid "Array must contain halfwords (type 'H')" msgstr "Array deve conter meias palavras (tipo 'H')" @@ -2461,3 +2509,30 @@ msgstr "Muitos argumentos fornecidos com o formato dado" #~ msgid "Baud rate too high for this SPI peripheral" #~ msgstr "Taxa de transmissão muito alta para esse periférico SPI" + +#~ msgid "Invalid Service type" +#~ msgstr "Tipo de serviço inválido" + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x" + +#~ msgid "Can encode UUID into the advertisement packet." +#~ msgstr "Pode codificar o UUID no pacote de anúncios." + +#~ msgid "Can not apply device name in the stack." +#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha." + +#~ msgid "Can not add Characteristic." +#~ msgstr "Não é possível adicionar Característica." + +#~ msgid "Can not add Service." +#~ msgstr "Não é possível adicionar o serviço." + +#~ msgid "Can not query for the device address." +#~ msgstr "Não é possível consultar o endereço do dispositivo." + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Não é possível definir parâmetros PPCP." + +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Não é possível aplicar parâmetros GAP." diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 9f8993977..6b03d112d 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -41,13 +41,14 @@ INC += -I$(BUILD) INC += -I$(BUILD)/genhdr INC += -I./../../lib/cmsis/inc INC += -I./boards/$(BOARD) -INC += -I./bluetooth INC += -I./modules/ubluepy INC += -I./modules/ble INC += -I./nrfx INC += -I./nrfx/hal INC += -I./nrfx/mdk INC += -I./nrfx/drivers/include +INC += -I./bluetooth +INC += -I./peripherals INC += -I../../lib/mp-readline INC += -I../../lib/tinyusb/src INC += -I./usb @@ -103,8 +104,8 @@ SRC_C += \ boards/$(BOARD)/board.c \ boards/$(BOARD)/pins.c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \ - drivers/bluetooth/ble_drv.c \ - drivers/bluetooth/ble_uart.c \ + bluetooth/ble_drv.c \ + bluetooth/ble_uart.c \ lib/libc/string0.c \ lib/mp-readline/readline.c \ lib/oofatfs/ff.c \ diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index dd2fd00dd..985e262e4 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -38,7 +38,7 @@ STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AssertionError, - "Soft device assert, id: 0x%08lX, pc: 0x%08lX", id, pc)); + translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc)); } STATIC uint32_t ble_stack_enable(void) { @@ -122,7 +122,7 @@ void common_hal_bleio_adapter_set_enabled(bool enabled) { if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to change softdevice state, error: 0x%08lX", err_code)); + translate("Failed to change softdevice state, error: 0x%08lX"), err_code)); } } @@ -132,7 +132,7 @@ bool common_hal_bleio_adapter_get_enabled(void) { const uint32_t err_code = sd_softdevice_is_enabled(&is_enabled); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to get softdevice state, error: 0x%08lX", err_code)); + translate("Failed to get softdevice state, error: 0x%08lX"), err_code)); } return is_enabled; @@ -152,7 +152,7 @@ void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address) { if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to get local address, error: 0x%08lX", err_code)); + translate("Failed to get local address, error: 0x%08lX"), err_code)); } address->type = local_address.addr_type; diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index a370d29a7..246c35005 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -49,7 +49,7 @@ STATIC void gatts_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in const uint32_t err_code = sd_ble_gatts_value_set(conn_handle, characteristic->handle, &gatts_value); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to write gatts value, status: 0x%08lX", err_code)); + translate("Failed to write gatts value, status: 0x%08lX"), err_code)); } } @@ -73,7 +73,7 @@ STATIC void gatts_notify(bleio_characteristic_obj_t *characteristic, mp_buffer_i const uint32_t err_code = sd_ble_gatts_hvx(device->conn_handle, &hvx_params); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to notify attribute value, status: 0x%08lX", err_code)); + translate("Failed to notify attribute value, status: 0x%08lX"), err_code)); } m_tx_in_progress += 1; @@ -88,7 +88,7 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) { const uint32_t err_code = sd_ble_gattc_read(device->conn_handle, characteristic->handle, 0); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to read attribute value, status: 0x%08lX", err_code)); + translate("Failed to read attribute value, status: 0x%08lX"), err_code)); } while (m_read_characteristic != NULL) { @@ -116,14 +116,14 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in err_code = sd_mutex_acquire(m_write_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to acquire mutex, status: 0x%08lX", err_code)); + translate("Failed to acquire mutex, status: 0x%08lX"), err_code)); } } err_code = sd_ble_gattc_write(device->conn_handle, &write_params); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to write attribute value, status: 0x%08lX", err_code)); + translate("Failed to write attribute value, status: 0x%08lX"), err_code)); } while (sd_mutex_acquire(m_write_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { @@ -135,7 +135,7 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in err_code = sd_mutex_release(m_write_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to release mutex, status: 0x%08lX", err_code)); + translate("Failed to release mutex, status: 0x%08lX"), err_code)); } } diff --git a/ports/nrf/common-hal/bleio/Device.c b/ports/nrf/common-hal/bleio/Device.c index c03db0ab9..2c000ae2e 100644 --- a/ports/nrf/common-hal/bleio/Device.c +++ b/ports/nrf/common-hal/bleio/Device.c @@ -78,7 +78,7 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta do { \ if (byte_pos + (len) > BLE_GAP_ADV_MAX_SIZE) { \ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, \ - "Can not fit data into the advertisment packet")); \ + translate("Can not fit data into the advertisment packet"))); \ } \ adv_data[byte_pos] = (field); \ byte_pos += (len); \ @@ -111,7 +111,7 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta } else { if (byte_pos + raw_data->len > BLE_GAP_ADV_MAX_SIZE) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not fit data into the advertisment packet")); + translate("Can not fit data into the advertisment packet"))); } memcpy(&adv_data[byte_pos], raw_data->buf, raw_data->len); @@ -263,13 +263,13 @@ STATIC bool discover_services(bleio_device_obj_t *device, uint16_t start_handle) uint32_t err_code = sd_ble_gattc_primary_services_discover(device->conn_handle, start_handle, NULL); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to discover serivices, status: 0x%08lX", err_code)); + translate("Failed to discover serivices, status: 0x%08lX"), err_code)); } err_code = sd_mutex_acquire(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to acquire mutex, status: 0x%08lX", err_code)); + translate("Failed to acquire mutex, status: 0x%08lX"), err_code)); } while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { @@ -281,7 +281,7 @@ STATIC bool discover_services(bleio_device_obj_t *device, uint16_t start_handle) err_code = sd_mutex_release(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to release mutex, status: 0x%08lX", err_code)); + translate("Failed to release mutex, status: 0x%08lX"), err_code)); } return m_discovery_successful; @@ -304,7 +304,7 @@ STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_o err_code = sd_mutex_acquire(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to acquire mutex, status: 0x%08lX", err_code)); + translate("Failed to acquire mutex, status: 0x%08lX"), err_code)); } while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { @@ -316,7 +316,7 @@ STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_o err_code = sd_mutex_release(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to release mutex, status: 0x%08lX", err_code)); + translate("Failed to release mutex, status: 0x%08lX"), err_code)); } return m_discovery_successful; @@ -351,7 +351,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res const uint32_t err_code = sd_mutex_release(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to release mutex, status: 0x%08lX", err_code)); + translate("Failed to release mutex, status: 0x%08lX"), err_code)); } } @@ -388,7 +388,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio const uint32_t err_code = sd_mutex_release(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to release mutex, status: 0x%08lX", err_code)); + translate("Failed to release mutex, status: 0x%08lX"), err_code)); } } @@ -400,7 +400,7 @@ STATIC void on_adv_report(ble_gap_evt_adv_report_t *report, bleio_device_obj_t * err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to continue scanning, status: 0x%0xlX", err_code)); + translate("Failed to continue scanning, status: 0x%0xlX"), err_code)); } #endif return; @@ -433,7 +433,7 @@ STATIC void on_adv_report(ble_gap_evt_adv_report_t *report, bleio_device_obj_t * if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to connect, status: 0x%08lX", err_code)); + translate("Failed to connect, status: 0x%08lX"), err_code)); } } @@ -510,7 +510,7 @@ void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_servi const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to add service, status: 0x%08lX", err_code)); + translate("Failed to add service, status: 0x%08lX"), err_code)); } const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list); @@ -528,7 +528,7 @@ void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool const uint32_t err_code = set_advertisement_data(device, connectable, raw_data); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to start advertisment, status: 0x%08lX", err_code)); + translate("Failed to start advertisment, status: 0x%08lX"), err_code)); } } @@ -546,7 +546,7 @@ void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device) { if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to stop advertisment, status: 0x%08lX", err_code)); + translate("Failed to stop advertisment, status: 0x%08lX"), err_code)); } } @@ -572,7 +572,7 @@ void common_hal_bleio_device_connect(bleio_device_obj_t *device) { if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to start scanning, status: 0x%0xlX", err_code)); + translate("Failed to start scanning, status: 0x%0xlX"), err_code)); } while (device->conn_handle == BLE_CONN_HANDLE_INVALID) { @@ -589,7 +589,7 @@ void common_hal_bleio_device_connect(bleio_device_obj_t *device) { err_code = sd_mutex_new(m_discovery_mutex); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to create mutex, status: 0x%0xlX", err_code)); + translate("Failed to create mutex, status: 0x%0xlX"), err_code)); } } diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index 17af49621..e56c1860c 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -73,7 +73,7 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { const uint32_t err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to continue scanning, status: 0x%0xlX", err_code)); + translate("Failed to continue scanning, status: 0x%0xlX"), err_code)); } #endif } @@ -100,7 +100,7 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout) if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to start scanning, status: 0x%0xlX", err_code)); + translate("Failed to start scanning, status: 0x%0xlX"), err_code)); } if (timeout > 0) { diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c index ee2624073..c17c16904 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -80,7 +80,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, blei err_code = sd_ble_gatts_characteristic_add(self->handle, &char_md, &attr_char_value, &handles); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to add characteristic, status: 0x%08lX", err_code)); + translate("Failed to add characteristic, status: 0x%08lX"), err_code)); } characteristic->user_desc_handle = handles.user_desc_handle; diff --git a/ports/nrf/common-hal/bleio/UUID.c b/ports/nrf/common-hal/bleio/UUID.c index 891c34ac4..9a2e101ea 100644 --- a/ports/nrf/common-hal/bleio/UUID.c +++ b/ports/nrf/common-hal/bleio/UUID.c @@ -94,19 +94,19 @@ void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, const mp_obj_t *uui const uint32_t err_code = sd_ble_uuid_vs_add(&vs_uuid, &self->uuid_vs_idx); if (err_code != NRF_SUCCESS) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Failed to add Vendor Specific UUID, status: 0x%08lX", err_code)); + translate("Failed to add Vendor Specific UUID, status: 0x%08lX"), err_code)); } } else { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Invalid UUID string length")); + translate("Invalid UUID string length"))); } return; } nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Invalid UUID parameter")); + translate("Invalid UUID parameter"))); } void common_hal_bleio_uuid_print(bleio_uuid_obj_t *self, const mp_print_t *print) { diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index 7ac42c740..ec23ff207 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -98,13 +98,13 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, i -= is_long ? 3 : 2; } } else { - mp_raise_ValueError("Wrong address length"); + mp_raise_ValueError(translate("Wrong address length")); } } else if (MP_OBJ_IS_TYPE(address, &mp_type_bytearray) || MP_OBJ_IS_TYPE(address, &mp_type_bytes)) { mp_buffer_info_t buf_info; mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ); if (buf_info.len != BLEIO_ADDRESS_BYTES) { - mp_raise_ValueError("Wrong number of bytes provided"); + mp_raise_ValueError(translate("Wrong number of bytes provided")); } for (size_t b = 0; b < BLEIO_ADDRESS_BYTES; ++b) { diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index 3563d3895..369f3f991 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -122,7 +122,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t self->uuid = MP_OBJ_TO_PTR(uuid); } else { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Invalid UUID parameter")); + translate("Invalid UUID parameter"))); } common_hal_bleio_characteristic_construct(self); diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c index 64cfb762f..94834ef7c 100644 --- a/shared-bindings/bleio/Device.c +++ b/shared-bindings/bleio/Device.c @@ -194,7 +194,7 @@ STATIC mp_obj_t bleio_device_make_new(const mp_obj_type_t *type, size_t n_args, self->address.type = scan_entry->address.type; memcpy(self->address.value, scan_entry->address.value, BLEIO_ADDRESS_BYTES); } else { - self->name = mp_obj_new_str(default_name, strlen(default_name), false); + self->name = mp_obj_new_str(default_name, strlen(default_name)); common_hal_bleio_adapter_get_address(&self->address); } @@ -207,7 +207,7 @@ STATIC mp_obj_t bleio_device_add_service(mp_obj_t self_in, mp_obj_t service_in) if (!self->is_peripheral) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Can't add services in Central mode")); + translate("Can't add services in Central mode"))); } service->device = self; @@ -223,7 +223,7 @@ STATIC mp_obj_t bleio_device_connect(mp_obj_t self_in) { if (self->is_peripheral) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Can't connect in Peripheral mode")); + translate("Can't connect in Peripheral mode"))); } common_hal_bleio_device_connect(self); @@ -253,7 +253,7 @@ static mp_obj_t bleio_device_set_name(mp_obj_t self_in, mp_obj_t value) { if (!self->is_peripheral) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Can't change the name in Central mode")); + translate("Can't change the name in Central mode"))); } self->name = value; @@ -274,7 +274,7 @@ STATIC mp_obj_t bleio_device_start_advertising(mp_uint_t n_args, const mp_obj_t if (!self->is_peripheral) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Can't advertise in Central mode")); + translate("Can't advertise in Central mode"))); } enum { ARG_connectable, ARG_data }; @@ -310,7 +310,7 @@ STATIC mp_obj_t bleio_device_stop_advertising(mp_obj_t self_in) { if (!self->is_peripheral) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Can't advertise in Central mode")); + translate("Can't advertise in Central mode"))); } common_hal_bleio_device_stop_advertising(self); diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index 2eed24cd8..e452c7267 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -177,7 +177,7 @@ STATIC mp_obj_t scanentry_get_name(mp_obj_t self_in) { return mp_const_none; } - return mp_obj_new_str((const char*)name, name_len - 1, false); + return mp_obj_new_str((const char*)name, name_len - 1); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_name_obj, scanentry_get_name); diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index 6e112880a..2d09cbc3c 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -102,7 +102,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, self->uuid = MP_OBJ_TO_PTR(uuid); } else { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "Invalid UUID parameter")); + translate("Invalid UUID parameter"))); } return MP_OBJ_FROM_PTR(self); -- cgit v1.2.3