From ee8119779e22c21fe7771a054e4cf6ee921b4352 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 17 May 2019 15:47:12 -0400 Subject: [PATCH 01/25] WIP --- shared-bindings/bleio/ScanEntry.c | 7 ++----- shared-bindings/bleio/Scanner.c | 23 ++++++++--------------- shared-bindings/bleio/Scanner.h | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index e6b9550780..67e4a38c02 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -37,9 +37,6 @@ #include "shared-module/bleio/AdvertisementData.h" #include "shared-module/bleio/ScanEntry.h" -// Work-in-progress: orphaned for now. -//| :orphan: -//| //| .. currentmodule:: bleio //| //| :class:`ScanEntry` -- BLE scan response entry @@ -63,7 +60,7 @@ //| .. attribute:: name //| //| The name of the device. (read-only) -//| This attribute might be `None` if the data was missing from the advertisement packet. +//| Will be be `None` if the data was missing from the advertisement packet. //| //| .. attribute:: raw_data @@ -87,7 +84,7 @@ //| .. 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. +//| Will 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; diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index f5424f706c..73b6e6a0b2 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -32,9 +33,6 @@ #define DEFAULT_INTERVAL 100 #define DEFAULT_WINDOW 100 -// Work-in-progress: orphaned for now. -//| :orphan: -//| //| .. currentmodule:: bleio //| //| :class:`Scanner` -- scan for nearby BLE devices @@ -46,7 +44,7 @@ //| //| import bleio //| scanner = bleio.Scanner() -//| entries = scanner.scan(2500) +//| entries = scanner.scan(2.5) # Scan for 2.5 seconds //| print(entries) //| @@ -57,33 +55,28 @@ //| .. attribute:: interval //| -//| The interval (in ms) between the start of two consecutive scan windows. -//| Allowed values are between 10ms and 10.24 sec. +//| The interval (in seconds) between the start of two consecutive scan windows. +//| Allowed values are between 0.010 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. +//| The duration (in seconds) in which a single BLE channel is scanned. +//| Allowed values are between 0.010 and 10.24 sec. //| //| .. method:: scan(timeout) //| //| Performs a BLE scan. //| -//| :param int timeout: the scan timeout in ms +//| :param float timeout: the scan timeout in seconds //| :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, const mp_obj_t *all_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 0, 0, false); + bleio_scanner_obj_t *self = m_new_obj(bleio_scanner_obj_t); self->base.type = type; diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h index 9bd0717476..c72136389b 100644 --- a/shared-bindings/bleio/Scanner.h +++ b/shared-bindings/bleio/Scanner.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy From 1639354e5fc886ee4b2064eaceedfd26ebbe1cd3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 23 May 2019 16:07:54 -0400 Subject: [PATCH 02/25] Scanner working, but not very first time --- ports/nrf/bluetooth/ble_drv.h | 5 +- ports/nrf/common-hal/bleio/Scanner.c | 26 ++---- shared-bindings/bleio/Scanner.c | 120 ++++++++++----------------- shared-bindings/bleio/Scanner.h | 2 +- shared-bindings/bleio/__init__.c | 8 +- 5 files changed, 56 insertions(+), 105 deletions(-) diff --git a/ports/nrf/bluetooth/ble_drv.h b/ports/nrf/bluetooth/ble_drv.h index cdb4c9b033..133d77b48d 100644 --- a/ports/nrf/bluetooth/ble_drv.h +++ b/ports/nrf/bluetooth/ble_drv.h @@ -30,10 +30,6 @@ #include "ble.h" -#if (BLUETOOTH_SD == 132) && (BLE_API_VERSION == 2) -#define NRF52 -#endif - #define MAX_TX_IN_PROGRESS 10 #ifndef BLE_GATT_ATT_MTU_DEFAULT @@ -43,6 +39,7 @@ #define BLE_CONN_CFG_TAG_CUSTOM 1 #define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) +#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION)) // 0.625 msecs (625 usecs) #define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625) #define UNIT_0_625_MS (625) diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index d2e19b5f9f..d4479515e7 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -36,14 +36,12 @@ #include "shared-bindings/bleio/Scanner.h" #include "shared-module/bleio/ScanEntry.h" -#if (BLUETOOTH_SD == 140) static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_MIN]; static ble_data_t m_scan_buffer = { m_scan_buffer_data, BLE_GAP_SCAN_BUFFER_MIN }; -#endif STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { bleio_scanner_obj_t *scanner = (bleio_scanner_obj_t*)scanner_in; @@ -61,48 +59,34 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { entry->address.type = report->peer_addr.addr_type; memcpy(entry->address.value, report->peer_addr.addr, BLEIO_ADDRESS_BYTES); -#if (BLUETOOTH_SD == 140) entry->data = mp_obj_new_bytearray(report->data.len, report->data.p_data); -#else - entry->data = mp_obj_new_bytearray(report->dlen, report->data); -#endif mp_obj_list_append(scanner->adv_reports, entry); -#if (BLUETOOTH_SD == 140) const uint32_t err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer); if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg_varg(translate("Failed to continue scanning, err 0x%04x"), err_code); } -#endif } -void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout) { +void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { ble_drv_add_event_handler(on_ble_evt, self); ble_gap_scan_params_t scan_params = { - .interval = MSEC_TO_UNITS(self->interval, UNIT_0_625_MS), - .window = MSEC_TO_UNITS(self->window, UNIT_0_625_MS), -#if (BLUETOOTH_SD == 140) + .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS), + .window = SEC_TO_UNITS(window, UNIT_0_625_MS), .scan_phys = BLE_GAP_PHY_1MBPS, -#endif }; common_hal_bleio_adapter_set_enabled(true); uint32_t err_code; -#if (BLUETOOTH_SD == 140) err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer); -#else - err_code = sd_ble_gap_scan_start(&scan_params); -#endif if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg_varg(translate("Failed to start scanning, err 0x%04x"), err_code); } - if (timeout > 0) { - mp_hal_delay_ms(timeout); - sd_ble_gap_scan_stop(); - } + mp_hal_delay_ms(timeout * 1000); + sd_ble_gap_scan_stop(); } diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index 73b6e6a0b2..5615ce1030 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -30,8 +30,12 @@ #include "shared-bindings/bleio/ScanEntry.h" #include "shared-bindings/bleio/Scanner.h" -#define DEFAULT_INTERVAL 100 -#define DEFAULT_WINDOW 100 +#define INTERVAL_DEFAULT (0.1f) +#define INTERVAL_MIN (0.0025f) +#define INTERVAL_MIN_STRING "0.0025" +#define INTERVAL_MAX (40.959375f) +#define INTERVAL_MAX_STRING "40.959375" +#define WINDOW_DEFAULT (0.1f) //| .. currentmodule:: bleio //| @@ -45,109 +49,76 @@ //| import bleio //| scanner = bleio.Scanner() //| entries = scanner.scan(2.5) # Scan for 2.5 seconds -//| print(entries) //| //| .. class:: Scanner() //| //| Create a new Scanner object. //| - -//| .. attribute:: interval -//| -//| The interval (in seconds) between the start of two consecutive scan windows. -//| Allowed values are between 0.010 and 10.24 sec. -//| - -//| .. attribute:: window -//| -//| The duration (in seconds) in which a single BLE channel is scanned. -//| Allowed values are between 0.010 and 10.24 sec. -//| - -//| .. method:: scan(timeout) -//| -//| Performs a BLE scan. -//| -//| :param float timeout: the scan timeout in seconds -//| :returns: advertising packets found -//| :rtype: list of :py:class:`bleio.ScanEntry` -//| STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 0, 0, false); - 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); +//| .. method:: scan(timeout, \*, interval=0.1, window=0.1) +//| +//| Performs a BLE scan. +//| +//| :param float timeout: the scan timeout in seconds +//| :param float interval: the interval (in seconds) between the start of two consecutive scan windows +//| Must be in the range 0.0025 - 40.959375 seconds. +//| :param float window: the duration (in seconds) to scan a single BLE channel +//| `window` must be <= `interval`. +//| :returns: advertising packets found +//| :rtype: list of :py:class:`bleio.ScanEntry` +//| +STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_timeout, ARG_interval, ARG_window }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_timeout, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_window, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_obj = MP_OBJ_NULL} }, + }; - return mp_obj_new_int(self->interval); -} -MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanner_get_interval_obj, bleio_scanner_get_interval); + bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + 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); -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); + const mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); - self->interval = mp_obj_get_int(value); + if (args[ARG_interval].u_obj == MP_OBJ_NULL) { + args[ARG_interval].u_obj = mp_obj_new_float(INTERVAL_DEFAULT); + } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_set_interval_obj, bleio_scanner_set_interval); + if (args[ARG_window].u_obj == MP_OBJ_NULL) { + args[ARG_window].u_obj = mp_obj_new_float(WINDOW_DEFAULT); + } -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 }, -}; + const mp_float_t interval = mp_obj_float_get(args[ARG_interval].u_obj); + if (interval < INTERVAL_MIN || interval > INTERVAL_MAX) { + mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), INTERVAL_MIN_STRING, INTERVAL_MAX_STRING); + } -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); + const mp_float_t window = mp_obj_float_get(args[ARG_window].u_obj); + if (window > interval) { + mp_raise_ValueError(translate("window must be <= interval")); + } self->adv_reports = mp_obj_new_list(0, NULL); - common_hal_bleio_scanner_scan(self, timeout); + common_hal_bleio_scanner_scan(self, timeout, interval, window); return self->adv_reports; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_scan_obj, scanner_scan); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanner_scan_obj, 2, bleio_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); @@ -155,7 +126,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_scanner_locals_dict, bleio_scanner_locals_dict 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 index c72136389b..54c09675ba 100644 --- a/shared-bindings/bleio/Scanner.h +++ b/shared-bindings/bleio/Scanner.h @@ -33,7 +33,7 @@ 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); +void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window); extern void common_hal_bleio_scanner_stop(bleio_scanner_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 7348655acc..907d211016 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -64,8 +64,8 @@ // Descriptor // Device //| Peripheral -// ScanEntry -// Scanner +//| ScanEntry +//| Scanner //| Service //| UUID //| @@ -86,8 +86,8 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { // { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, { MP_ROM_QSTR(MP_QSTR_Peripheral), MP_ROM_PTR(&bleio_peripheral_type) }, // Hide work-in-progress. -// { 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_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) }, { MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) }, From 6cec81bcb54fe69d179f6596d8dae96b6f3beea2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 23 May 2019 22:05:16 -0400 Subject: [PATCH 03/25] Need to enable ble before scanning --- ports/nrf/common-hal/bleio/Peripheral.c | 2 +- ports/nrf/common-hal/bleio/Scanner.c | 1 + shared-bindings/bleio/__init__.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 0a5a8069de..83191d4870 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -288,7 +288,7 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) { - common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__ + common_hal_bleio_adapter_set_enabled(true); self->gatt_role = GATT_ROLE_SERVER; self->conn_handle = BLE_CONN_HANDLE_INVALID; diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index d4479515e7..b76caaf213 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -70,6 +70,7 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { } void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { + common_hal_bleio_adapter_set_enabled(true); ble_drv_add_event_handler(on_ble_evt, self); ble_gap_scan_params_t scan_params = { diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 907d211016..03aef2eced 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -85,7 +85,6 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) }, // { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, { MP_ROM_QSTR(MP_QSTR_Peripheral), MP_ROM_PTR(&bleio_peripheral_type) }, -// Hide work-in-progress. { 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) }, From 12f1d9d30cf6e8c73db2eac5512c332cfde3031f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 31 May 2019 18:03:05 -0400 Subject: [PATCH 04/25] fix advertisement length check; add Service.secondary attribute --- ports/nrf/common-hal/bleio/Peripheral.c | 2 +- shared-bindings/bleio/Service.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 83191d4870..4aff75c9b7 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -52,7 +52,7 @@ static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; STATIC void check_data_fit(size_t pos, size_t data_len) { - if (pos + data_len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) { + if (pos + data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { mp_raise_ValueError(translate("Data too large for advertisement packet")); } } diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index c3be262602..d9bc4021f4 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -118,6 +118,24 @@ const mp_obj_property_t bleio_service_characteristics_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. attribute:: secondary +//| +//| True if this is a secondary service. (read-only) +//| +STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) { + bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_bool(self->is_secondary); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_secondary_obj, bleio_service_get_secondary); + +const mp_obj_property_t bleio_service_secondary_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_service_get_secondary_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + //| .. attribute:: uuid //| //| The UUID of this service. (read-only) @@ -138,6 +156,7 @@ const mp_obj_property_t bleio_service_uuid_obj = { STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_characteristics), MP_ROM_PTR(&bleio_service_characteristics_obj) }, + { MP_ROM_QSTR(MP_QSTR_secondary), MP_ROM_PTR(&bleio_service_secondary_obj) }, { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_service_uuid_obj) }, }; From 63ac37946df041519ffa822fde292f3be6d1840c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 2 Jun 2019 23:21:30 -0400 Subject: [PATCH 05/25] 1. Remove advertising data construction in C: it's all done in Python now 2. Add scan response capability to advertising. --- ports/nrf/common-hal/bleio/Broadcaster.c | 2 +- ports/nrf/common-hal/bleio/Peripheral.c | 141 +++-------------------- ports/nrf/common-hal/bleio/Peripheral.h | 7 +- shared-bindings/bleio/Broadcaster.c | 2 +- shared-bindings/bleio/Peripheral.c | 26 +++-- shared-bindings/bleio/Peripheral.h | 2 +- 6 files changed, 38 insertions(+), 142 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Broadcaster.c b/ports/nrf/common-hal/bleio/Broadcaster.c index a70209a7fc..a9e2a04c3f 100644 --- a/ports/nrf/common-hal/bleio/Broadcaster.c +++ b/ports/nrf/common-hal/bleio/Broadcaster.c @@ -39,7 +39,7 @@ static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval) { - common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__ + common_hal_bleio_adapter_set_enabled(true); const mp_float_t min = BLE_GAP_ADV_INTERVAL_MIN * ADV_INTERVAL_UNIT_FLOAT_SECS; const mp_float_t max = BLE_GAP_ADV_INTERVAL_MAX * ADV_INTERVAL_UNIT_FLOAT_SECS; diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 4aff75c9b7..ad28523ae8 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -51,63 +51,15 @@ static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; -STATIC void check_data_fit(size_t pos, size_t data_len) { - if (pos + data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { +STATIC void check_data_fit(size_t data_len) { + if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { mp_raise_ValueError(translate("Data too large for advertisement packet")); } } -STATIC uint32_t add_services_to_advertisement(bleio_peripheral_obj_t *self, size_t* adv_data_pos_p, size_t uuid_len) { - uint32_t uuids_total_size = 0; - const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); - uint32_t err_code = NRF_SUCCESS; - - check_data_fit(*adv_data_pos_p, 1 + 1); - - // Remember where length byte is; fill in later when we know the size. - const size_t length_pos = *adv_data_pos_p; - (*adv_data_pos_p)++; - - self->adv_data[(*adv_data_pos_p)++] = (uuid_len == 16) - ? BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE - : BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE; - - for (size_t i = 0; i < service_list->len; ++i) { - const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); - uint8_t encoded_size = 0; - - // Skip services of the wrong length and secondary services. - if (common_hal_bleio_uuid_get_size(service->uuid) != uuid_len || service->is_secondary) { - continue; - } - - ble_uuid_t uuid; - bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); - - err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &(self->adv_data[*adv_data_pos_p])); - if (err_code != NRF_SUCCESS) { - return err_code; - } - - check_data_fit(*adv_data_pos_p, encoded_size); - uuids_total_size += encoded_size; - (*adv_data_pos_p) += encoded_size; - } - - self->adv_data[length_pos] = 1 + uuids_total_size; // 1 for the field type. - return err_code; -} - - - -// if raw_data is a zero-length buffer, generate an advertising packet that advertises the -// services passed in when this Peripheral was created. -// If raw_data contains some bytes, use those bytes as the advertising packet. -// TODO: Generate the advertising packet in Python, not here. -STATIC uint32_t set_advertisement_data(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *raw_data) { +STATIC uint32_t start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) { common_hal_bleio_adapter_set_enabled(true); - size_t adv_data_pos = 0; uint32_t err_code; GET_STR_DATA_LEN(self->name, name_data, name_len); @@ -115,86 +67,18 @@ STATIC uint32_t set_advertisement_data(bleio_peripheral_obj_t *self, bool connec ble_gap_conn_sec_mode_t sec_mode; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); - // We'll add the name after everything else, shortening it if necessary. err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len); if (err_code != NRF_SUCCESS) { return err_code; } } - if (raw_data->len != 0) { - // User-supplied advertising packet. - check_data_fit(adv_data_pos, raw_data->len); - memcpy(&(self->adv_data[adv_data_pos]), raw_data->buf, raw_data->len); - adv_data_pos += raw_data->len; - } else { - // Build up advertising packet. - check_data_fit(adv_data_pos, 1 + 1 + 1); - self->adv_data[adv_data_pos++] = 2; - self->adv_data[adv_data_pos++] = BLE_GAP_AD_TYPE_FLAGS; - self->adv_data[adv_data_pos++] = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; + check_data_fit(advertising_data_bufinfo->len); + memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len); - // The 16-bit ids and 128-bit ids are grouped together by length, so find it whether we have - // 16 and/or 128-bit service UUIDs. + check_data_fit(scan_response_data_bufinfo->len); + memcpy(self->scan_response_data, scan_response_data_bufinfo->buf, scan_response_data_bufinfo->len); - const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); - if (service_list->len > 0) { - bool has_128bit_services = false; - bool has_16bit_services = false; - - 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->is_secondary) { - continue; - } - - switch (common_hal_bleio_uuid_get_size(service->uuid)) { - case 16: - has_16bit_services = true; - break; - case 128: - has_128bit_services = true; - break; - } - } - - // Add 16-bit service UUID's in a group, then 128-bit service UUID's. - - if (has_16bit_services) { - err_code = add_services_to_advertisement(self, &adv_data_pos, 16); - if (err_code != NRF_SUCCESS) { - return err_code; - } - } - - if (has_128bit_services) { - err_code = add_services_to_advertisement(self, &adv_data_pos, 128); - if (err_code != NRF_SUCCESS) { - return err_code; - } - } - } - - // Always include TX power. - check_data_fit(adv_data_pos, 1 + 1 + 1); - self->adv_data[adv_data_pos++] = 1 + 1; - self->adv_data[adv_data_pos++] = BLE_GAP_AD_TYPE_TX_POWER_LEVEL; - self->adv_data[adv_data_pos++] = 0; // TODO - allow power level to be set later. - - // We need room for at least a one-character name. - check_data_fit(adv_data_pos, 1 + 1 + 1); - - // How big a name can we fit? - size_t bytes_left = BLE_GAP_ADV_SET_DATA_SIZE_MAX - adv_data_pos - 1 - 1; - size_t partial_name_len = MIN(bytes_left, name_len); - self->adv_data[adv_data_pos++] = 1 + partial_name_len; - self->adv_data[adv_data_pos++] = (partial_name_len == name_len) - ? BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME - : BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME; - memcpy(&(self->adv_data[adv_data_pos]), name_data, partial_name_len); - adv_data_pos += partial_name_len; - } // end of advertising packet construction static ble_gap_adv_params_t m_adv_params = { .interval = MSEC_TO_UNITS(1000, UNIT_0_625_MS), @@ -211,8 +95,10 @@ STATIC uint32_t set_advertisement_data(bleio_peripheral_obj_t *self, bool connec common_hal_bleio_peripheral_stop_advertising(self); const ble_gap_adv_data_t ble_gap_adv_data = { - .adv_data.p_data = self->adv_data, - .adv_data.len = adv_data_pos, + .adv_data.p_data = self->advertising_data, + .adv_data.len = advertising_data_bufinfo->len, + .scan_rsp_data.p_data = scan_response_data_bufinfo-> len > 0 ? self->scan_response_data : NULL, + .scan_rsp_data.len = scan_response_data_bufinfo->len, }; err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params); @@ -322,12 +208,13 @@ bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) { return self->conn_handle != BLE_CONN_HANDLE_INVALID; } -void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *raw_data) { +void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) { if (connectable) { ble_drv_add_event_handler(peripheral_on_ble_evt, self); } - const uint32_t err_code = set_advertisement_data(self, connectable, raw_data); + const uint32_t err_code = start_advertising(self, connectable, + advertising_data_bufinfo, scan_response_data_bufinfo); if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code); } diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index b255fe9f40..bf1931dda4 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -43,10 +43,11 @@ typedef struct { mp_obj_t service_list; mp_obj_t notif_handler; mp_obj_t conn_handler; - // The advertising data buffer is held by us, not by the SD, so we must - // maintain it and not change it. If we need to change its contents during advertising, + // The advertising data and scan response buffers are held by us, not by the SD, so we must + // maintain them and not change it. If we need to change the contents during advertising, // there are tricks to get the SD to notice (see DevZone - TBS). - uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; + uint8_t advertising_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; + uint8_t scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; } bleio_peripheral_obj_t; diff --git a/shared-bindings/bleio/Broadcaster.c b/shared-bindings/bleio/Broadcaster.c index 209e664902..294f1a83a4 100644 --- a/shared-bindings/bleio/Broadcaster.c +++ b/shared-bindings/bleio/Broadcaster.c @@ -82,7 +82,7 @@ STATIC mp_obj_t bleio_broadcaster_make_new(const mp_obj_type_t *type, size_t n_a //| //| Start advertising using the given data packet. //| -//| :param buf data: advertising data packet, starting with advertising data flags (0x01) +//| :param buf data: advertising data packet //| STATIC mp_obj_t bleio_broadcaster_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 340485f353..960b3723c7 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -68,7 +68,8 @@ static const char default_name[] = "CIRCUITPY"; //| //| # Create a peripheral and start it up. //| periph = bleio.Peripheral([service]) -//| periph.start_advertising() +//| adv = ServerAdvertisement(periph) +//| periph.start_advertising(adv.advertising_data_bytes, adv.scan_response_bytes) //| //| while not periph.connected: //| # Wait for connection. @@ -181,33 +182,40 @@ const mp_obj_property_t bleio_peripheral_name_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. method:: start_advertising(*, connectable=True, data=None) +//| .. method:: start_advertising(data, *, scan_response=None, connectable=True) //| //| Starts advertising the peripheral. The peripheral's name and //| services are included in the advertisement packets. //| +//| :param buf data: advertising data packet bytes +//| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed. //| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral. -//| :param buf data: If `None`, advertise the services passed to this Peripheral when it was created. -//| If not `None`, then send the bytes in ``data`` as the advertising packet. +//| //| STATIC mp_obj_t bleio_peripheral_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - enum { ARG_connectable, ARG_data }; + enum { ARG_data, ARG_scan_response, ARG_connectable }; static const mp_arg_t allowed_args[] = { + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_scan_response, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, - { MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; 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); - mp_buffer_info_t bufinfo = { 0 }; + mp_buffer_info_t data_bufinfo; + mp_get_buffer_raise(args[ARG_data].u_obj, &data_bufinfo, MP_BUFFER_READ); + + // Pass an empty buffer if scan_response not provided. + mp_buffer_info_t scan_response_bufinfo = { 0 }; if (args[ARG_data].u_obj != mp_const_none) { - mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ); + mp_get_buffer_raise(args[ARG_scan_response].u_obj, &scan_response_bufinfo, MP_BUFFER_READ); } - common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, &bufinfo); + common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, + &data_bufinfo, &scan_response_bufinfo); return mp_const_none; } diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h index 02a5c1ef8e..c09c600885 100644 --- a/shared-bindings/bleio/Peripheral.h +++ b/shared-bindings/bleio/Peripheral.h @@ -34,7 +34,7 @@ extern const mp_obj_type_t bleio_peripheral_type; extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self); extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self); -extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, mp_buffer_info_t *raw_data); +extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H From 613e12f99fd101a2c6b4b738da398a270aede538 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 3 Jun 2019 20:40:05 -0400 Subject: [PATCH 06/25] Replace Broadcaster with enhanced Peripheral --- ports/nrf/common-hal/bleio/Broadcaster.c | 98 ---------------- ports/nrf/common-hal/bleio/Peripheral.c | 117 +++++++++---------- ports/nrf/common-hal/bleio/Peripheral.h | 1 + py/circuitpy_defns.mk | 2 - shared-bindings/bleio/AdvertisementData.c | 90 --------------- shared-bindings/bleio/Broadcaster.c | 132 ---------------------- shared-bindings/bleio/Broadcaster.h | 38 ------- shared-bindings/bleio/Device.c | 1 - shared-bindings/bleio/Device.h | 1 - shared-bindings/bleio/Peripheral.c | 46 +++++--- shared-bindings/bleio/Peripheral.h | 2 +- shared-bindings/bleio/__init__.c | 5 - shared-module/bleio/AdvertisementData.h | 7 -- 13 files changed, 90 insertions(+), 450 deletions(-) delete mode 100644 ports/nrf/common-hal/bleio/Broadcaster.c delete mode 100644 shared-bindings/bleio/AdvertisementData.c delete mode 100644 shared-bindings/bleio/Broadcaster.c delete mode 100644 shared-bindings/bleio/Broadcaster.h diff --git a/ports/nrf/common-hal/bleio/Broadcaster.c b/ports/nrf/common-hal/bleio/Broadcaster.c deleted file mode 100644 index a9e2a04c3f..0000000000 --- a/ports/nrf/common-hal/bleio/Broadcaster.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2018 Dan Halbert for Adafruit Industries - * - * 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.h" -#include "ble_drv.h" -#include "ble_hci.h" -#include "nrf_soc.h" -#include "py/runtime.h" - -#include "common-hal/bleio/Broadcaster.h" -#include "shared-bindings/bleio/Adapter.h" -#include "shared-bindings/bleio/Broadcaster.h" - -static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; - -void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval) { - common_hal_bleio_adapter_set_enabled(true); - const mp_float_t min = BLE_GAP_ADV_INTERVAL_MIN * ADV_INTERVAL_UNIT_FLOAT_SECS; - const mp_float_t max = BLE_GAP_ADV_INTERVAL_MAX * ADV_INTERVAL_UNIT_FLOAT_SECS; - - if (interval < min || interval > max) { - // Would like to print range using the constants above, but vargs would convert to double. - mp_raise_ValueError(translate("interval not in range 0.0020 to 10.24")); - } - self->interval = interval; -} - - -void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data) { - uint32_t err_code; - - if (data->len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) { - mp_raise_ValueError(translate("Data too large for advertisement packet")); - } - memcpy(self->adv_data, data->buf, data->len); - - ble_gap_adv_params_t m_adv_params = { - .interval = (uint32_t) (self->interval / ADV_INTERVAL_UNIT_FLOAT_SECS), - .properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED, - .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED, - .filter_policy = BLE_GAP_ADV_FP_ANY, - .primary_phy = BLE_GAP_PHY_1MBPS, - }; - - common_hal_bleio_broadcaster_stop_advertising(self); - - const ble_gap_adv_data_t ble_gap_adv_data = { - .adv_data.p_data = self->adv_data, - .adv_data.len = data->len, - }; - - err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params); - if (err_code == NRF_SUCCESS) { - err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM); - } - - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code); - } -} - -void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self) { - - if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) { - return; - } - - const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle); - - if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) { - mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code); - } -} diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index ad28523ae8..2cd52841a3 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -49,68 +49,12 @@ #define BLE_ADV_AD_TYPE_FIELD_SIZE 1 #define BLE_AD_TYPE_FLAGS_DATA_SIZE 1 -static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; - STATIC void check_data_fit(size_t data_len) { if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { mp_raise_ValueError(translate("Data too large for advertisement packet")); } } -STATIC uint32_t start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) { - common_hal_bleio_adapter_set_enabled(true); - - uint32_t err_code; - - GET_STR_DATA_LEN(self->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); - - err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len); - if (err_code != NRF_SUCCESS) { - return err_code; - } - } - - check_data_fit(advertising_data_bufinfo->len); - memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len); - - check_data_fit(scan_response_data_bufinfo->len); - memcpy(self->scan_response_data, scan_response_data_bufinfo->buf, scan_response_data_bufinfo->len); - - - static ble_gap_adv_params_t m_adv_params = { - .interval = MSEC_TO_UNITS(1000, UNIT_0_625_MS), - .properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED, - .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED, - .filter_policy = BLE_GAP_ADV_FP_ANY, - .primary_phy = BLE_GAP_PHY_1MBPS, - }; - - if (!connectable) { - m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED; - } - - common_hal_bleio_peripheral_stop_advertising(self); - - const ble_gap_adv_data_t ble_gap_adv_data = { - .adv_data.p_data = self->advertising_data, - .adv_data.len = advertising_data_bufinfo->len, - .scan_rsp_data.p_data = scan_response_data_bufinfo-> len > 0 ? self->scan_response_data : NULL, - .scan_rsp_data.len = scan_response_data_bufinfo->len, - }; - - err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params); - if (err_code != NRF_SUCCESS) { - return err_code; - } - - err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM); - - return err_code; -} - STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { bleio_peripheral_obj_t *self = (bleio_peripheral_obj_t*)self_in; @@ -172,12 +116,12 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } } - void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) { common_hal_bleio_adapter_set_enabled(true); self->gatt_role = GATT_ROLE_SERVER; self->conn_handle = BLE_CONN_HANDLE_INVALID; + self->adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; // Add all the services. @@ -208,13 +152,62 @@ bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) { return self->conn_handle != BLE_CONN_HANDLE_INVALID; } -void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) { +void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) { + + // interval value has already been validated. + if (connectable) { ble_drv_add_event_handler(peripheral_on_ble_evt, self); } - const uint32_t err_code = start_advertising(self, connectable, - advertising_data_bufinfo, scan_response_data_bufinfo); + common_hal_bleio_adapter_set_enabled(true); + + uint32_t err_code; + + GET_STR_DATA_LEN(self->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); + + err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to set device name, err 0x%04x"), err_code); + + } + } + + check_data_fit(advertising_data_bufinfo->len); + memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len); + + check_data_fit(scan_response_data_bufinfo->len); + memcpy(self->scan_response_data, scan_response_data_bufinfo->buf, scan_response_data_bufinfo->len); + + + ble_gap_adv_params_t adv_params = { + .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS), + .properties.type = connectable ? BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED + : BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED, + .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED, + .filter_policy = BLE_GAP_ADV_FP_ANY, + .primary_phy = BLE_GAP_PHY_1MBPS, + }; + + common_hal_bleio_peripheral_stop_advertising(self); + + const ble_gap_adv_data_t ble_gap_adv_data = { + .adv_data.p_data = self->advertising_data, + .adv_data.len = advertising_data_bufinfo->len, + .scan_rsp_data.p_data = scan_response_data_bufinfo-> len > 0 ? self->scan_response_data : NULL, + .scan_rsp_data.len = scan_response_data_bufinfo->len, + }; + + err_code = sd_ble_gap_adv_set_configure(&self->adv_handle, &ble_gap_adv_data, &adv_params); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to configure advertising, err 0x%04x"), err_code); + } + + err_code = sd_ble_gap_adv_start(self->adv_handle, BLE_CONN_CFG_TAG_CUSTOM); + if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code); } @@ -222,10 +215,10 @@ void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *self) { - if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) + if (self->adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) return; - const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle); + const uint32_t err_code = sd_ble_gap_adv_stop(self->adv_handle); if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) { mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code); diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index bf1931dda4..58526fc484 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -48,6 +48,7 @@ typedef struct { // there are tricks to get the SD to notice (see DevZone - TBS). uint8_t advertising_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; uint8_t scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; + uint8_t adv_handle; } bleio_peripheral_obj_t; diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 1aca339011..31af38d8d4 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -221,7 +221,6 @@ $(filter $(SRC_PATTERNS), \ audioio/AudioOut.c \ bleio/__init__.c \ bleio/Adapter.c \ - bleio/Broadcaster.c \ bleio/Characteristic.c \ bleio/CharacteristicBuffer.c \ bleio/Descriptor.c \ @@ -285,7 +284,6 @@ SRC_BINDINGS_ENUMS += \ $(filter $(SRC_PATTERNS), \ bleio/Address.c \ bleio/AddressType.c \ - bleio/AdvertisementData.c \ bleio/ScanEntry.c \ ) diff --git a/shared-bindings/bleio/AdvertisementData.c b/shared-bindings/bleio/AdvertisementData.c deleted file mode 100644 index 9cfdd74e90..0000000000 --- a/shared-bindings/bleio/AdvertisementData.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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/obj.h" -#include "shared-module/bleio/AdvertisementData.h" - -//| .. currentmodule:: bleio -//| -//| :class:`AdvertisementData` -- data used during BLE advertising -//| ============================================================== -//| -//| Represents the data to be broadcast during BLE advertising. -//| - -STATIC const mp_rom_map_elem_t bleio_advertisementdata_locals_dict_table[] = { - // Static variables - { MP_ROM_QSTR(MP_QSTR_FLAGS), MP_ROM_INT(AdFlags) }, - { MP_ROM_QSTR(MP_QSTR_INCOMPLETE_LIST_OF_16BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdIncompleteListOf16BitServiceClassUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_COMPLETE_LIST_OF_16BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdCompleteListOf16BitServiceClassUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_INCOMPLETE_LIST_OF_32BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdIncompleteListOf32BitServiceClassUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_COMPLETE_LIST_OF_32BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdCompleteListOf32BitServiceClassUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_INCOMPLETE_LIST_OF_128BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdIncompleteListOf128BitServiceClassUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_COMPLETE_LIST_OF_128BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdCompleteListOf128BitServiceClassUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_SHORTENED_LOCAL_NAME), MP_ROM_INT(AdShortenedLocalName) }, - { MP_ROM_QSTR(MP_QSTR_COMPLETE_LOCAL_NAME), MP_ROM_INT(AdCompleteLocalName) }, - { MP_ROM_QSTR(MP_QSTR_TX_POWER_LEVEL), MP_ROM_INT(AdTxPowerLevel) }, - { MP_ROM_QSTR(MP_QSTR_CLASS_OF_DEVICE), MP_ROM_INT(AdClassOfDevice) }, - { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_HASH_C), MP_ROM_INT(AdSimplePairingHashC) }, - { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_RANDOMIZER_R), MP_ROM_INT(AdSimplePairingRandomizerR) }, - { MP_ROM_QSTR(MP_QSTR_SECURITY_MANAGER_TK_VALUE), MP_ROM_INT(AdSecurityManagerTKValue) }, - { MP_ROM_QSTR(MP_QSTR_SECURITY_MANAGER_OOB_FLAGS), MP_ROM_INT(AdSecurityManagerOOBFlags) }, - { MP_ROM_QSTR(MP_QSTR_SLAVE_CONNECTION_INTERVAL_RANGE), MP_ROM_INT(AdSlaveConnectionIntervalRange) }, - { MP_ROM_QSTR(MP_QSTR_LIST_OF_16BIT_SERVICE_SOLICITATION_UUIDS), MP_ROM_INT(AdListOf16BitServiceSolicitationUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_LIST_OF_128BIT_SERVICE_SOLICITATION_UUIDS), MP_ROM_INT(AdListOf128BitServiceSolicitationUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_SERVICE_DATA), MP_ROM_INT(AdServiceData) }, - { MP_ROM_QSTR(MP_QSTR_PUBLIC_TARGET_ADDRESS), MP_ROM_INT(AdPublicTargetAddress) }, - { MP_ROM_QSTR(MP_QSTR_RANDOM_TARGET_ADDRESS), MP_ROM_INT(AdRandomTargetAddress) }, - { MP_ROM_QSTR(MP_QSTR_APPEARANCE), MP_ROM_INT(AdAppearance) }, - { MP_ROM_QSTR(MP_QSTR_ADVERTISING_INTERNAL), MP_ROM_INT(AdAdvertisingInterval) }, - { MP_ROM_QSTR(MP_QSTR_LE_BLUETOOTH_DEVICE_ADDRESS), MP_ROM_INT(AdLEBluetoothDeviceAddress) }, - { MP_ROM_QSTR(MP_QSTR_LE_ROLE), MP_ROM_INT(AdLERole) }, - { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_HASH_C256), MP_ROM_INT(AdSimplePairingHashC256) }, - { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_RANDOMIZER_R256), MP_ROM_INT(AdSimplePairingRandomizerR256) }, - { MP_ROM_QSTR(MP_QSTR_LIST_OF_32BIT_SERVICE_SOLICITATION_UUIDS), MP_ROM_INT(AdListOf32BitServiceSolicitationUUIDs) }, - { MP_ROM_QSTR(MP_QSTR_SERVICE_DATA_32BIT_UUID), MP_ROM_INT(AdServiceData32BitUUID) }, - { MP_ROM_QSTR(MP_QSTR_SERVICE_DATA_128BIT_UUID), MP_ROM_INT(AdServiceData128BitUUID) }, - { MP_ROM_QSTR(MP_QSTR_LE_SECURE_CONNECTIONS_CONFIRMATION_VALUE), MP_ROM_INT(AdLESecureConnectionsConfirmationValue) }, - { MP_ROM_QSTR(MP_QSTR_LE_SECURE_CONNECTIONS_RANDOM_VALUE), MP_ROM_INT(AdLESecureConnectionsRandomValue) }, - { MP_ROM_QSTR(MP_QSTR_URI), MP_ROM_INT(AdURI) }, - { MP_ROM_QSTR(MP_QSTR_INDOOR_POSITIONING), MP_ROM_INT(AdIndoorPositioning) }, - { MP_ROM_QSTR(MP_QSTR_TRANSPORT_DISCOVERY_DATA), MP_ROM_INT(AdTransportDiscoveryData) }, - { MP_ROM_QSTR(MP_QSTR_LE_SUPPORTED_FEATURES), MP_ROM_INT(AdLESupportedFeatures) }, - { MP_ROM_QSTR(MP_QSTR_CHANNEL_MAP_UPDATE_INDICATION), MP_ROM_INT(AdChannelMapUpdateIndication) }, - { MP_ROM_QSTR(MP_QSTR_PB_ADV), MP_ROM_INT(AdPBADV) }, - { MP_ROM_QSTR(MP_QSTR_MESH_MESSAGE), MP_ROM_INT(AdMeshMessage) }, - { MP_ROM_QSTR(MP_QSTR_MESH_BEACON), MP_ROM_INT(AdMeshBeacon) }, - { MP_ROM_QSTR(MP_QSTR_3D_INFORMATION_DATA), MP_ROM_INT(Ad3DInformationData) }, - { MP_ROM_QSTR(MP_QSTR_MANUFACTURER_SPECIFIC_DATA), MP_ROM_INT(AdManufacturerSpecificData) }, -}; - -STATIC MP_DEFINE_CONST_DICT(bleio_advertisementdata_locals_dict, bleio_advertisementdata_locals_dict_table); - -const mp_obj_type_t bleio_advertisementdata_type = { - { &mp_type_type }, - .name = MP_QSTR_AdvertisementData, - .locals_dict = (mp_obj_dict_t*)&bleio_advertisementdata_locals_dict -}; diff --git a/shared-bindings/bleio/Broadcaster.c b/shared-bindings/bleio/Broadcaster.c deleted file mode 100644 index 294f1a83a4..0000000000 --- a/shared-bindings/bleio/Broadcaster.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2018 Dan Halbert for Adafruit Industries - * - * 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 "ble_drv.h" -#include "py/runtime.h" - -#include "shared-bindings/bleio/Broadcaster.h" - -//| .. currentmodule:: bleio -//| -//| :class:`Broadcaster` -- Broadcast advertising packets. -//| ========================================================= -//| -//| Implement a BLE broadcaster which sends data in advertising packets and does not connect. -//| Used for beacons and other one-way data transmission. -//| -//| Usage:: -//| -//| import bleio -//| import time -//| -//| # Broadcast once a second. -//| broadcaster = bleio.Broadcaster(interval=1) -//| data = 0 -//| # Broadcast a byte of data that's incremented once a minute -//| while True: -//| # data is an entire advertising data packet, starting with flags. -//| broadcaster.start_advertising(data) -//| time.sleep(60) -//| data += 1 -//| -//| .. class:: Broadcaster(interval=1) -//| -//| Create a new Broadcaster object. - -//| :param float interval: how often to broadcast -//| - -STATIC mp_obj_t bleio_broadcaster_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_interval }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_interval, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} }, - }; - - 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); - - mp_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj); - - bleio_broadcaster_obj_t *self = m_new_obj(bleio_broadcaster_obj_t); - self->base.type = &bleio_broadcaster_type; - // Do port-specific initialization. interval will be validated. - common_hal_bleio_broadcaster_construct(self, interval); - - return MP_OBJ_FROM_PTR(self); -} - -//| .. method:: start_advertising(data) -//| -//| Start advertising using the given data packet. -//| -//| :param buf data: advertising data packet -//| -STATIC mp_obj_t bleio_broadcaster_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - - enum { ARG_data }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, - }; - - 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); - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ); - - common_hal_bleio_broadcaster_start_advertising(self, &bufinfo); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_broadcaster_start_advertising_obj, 0, bleio_broadcaster_start_advertising); - -//| .. method:: stop_advertising() -//| -//| Stop sending advertising packets. -STATIC mp_obj_t bleio_broadcaster_stop_advertising(mp_obj_t self_in) { - bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(self_in); - - common_hal_bleio_broadcaster_stop_advertising(self); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_broadcaster_stop_advertising_obj, bleio_broadcaster_stop_advertising); - -STATIC const mp_rom_map_elem_t bleio_broadcaster_locals_dict_table[] = { - // Methods - { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_broadcaster_start_advertising_obj) }, - { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_broadcaster_stop_advertising_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(bleio_broadcaster_locals_dict, bleio_broadcaster_locals_dict_table); - -const mp_obj_type_t bleio_broadcaster_type = { - { &mp_type_type }, - .name = MP_QSTR_Broadcaster, - .make_new = bleio_broadcaster_make_new, - .locals_dict = (mp_obj_dict_t*)&bleio_broadcaster_locals_dict -}; diff --git a/shared-bindings/bleio/Broadcaster.h b/shared-bindings/bleio/Broadcaster.h deleted file mode 100644 index 8aa125af97..0000000000 --- a/shared-bindings/bleio/Broadcaster.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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_BROADCASTER_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H - -#include "common-hal/bleio/Broadcaster.h" - -extern const mp_obj_type_t bleio_broadcaster_type; - -extern void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval); -extern void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data); -extern void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c index 80595ef339..fcdc84d270 100644 --- a/shared-bindings/bleio/Device.c +++ b/shared-bindings/bleio/Device.c @@ -39,7 +39,6 @@ #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" #include "shared-module/bleio/ScanEntry.h" diff --git a/shared-bindings/bleio/Device.h b/shared-bindings/bleio/Device.h index aebf1d639d..1f85abe9a1 100644 --- a/shared-bindings/bleio/Device.h +++ b/shared-bindings/bleio/Device.h @@ -27,7 +27,6 @@ #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" #include "shared-module/bleio/Service.h" diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 960b3723c7..1d657635f4 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -40,14 +40,18 @@ #include "shared-bindings/bleio/Peripheral.h" #include "shared-bindings/bleio/Service.h" #include "shared-bindings/bleio/UUID.h" -#include "shared-module/bleio/AdvertisementData.h" #include "shared-module/bleio/ScanEntry.h" #include "common-hal/bleio/Peripheral.h" -// TODO: Add unique MAC address part to name static const char default_name[] = "CIRCUITPY"; +#define ADV_INTERVAL_DEFAULT (1.0f) +#define ADV_INTERVAL_MIN (0.0020f) +#define ADV_INTERVAL_MIN_STRING "0.0020" +#define ADV_INTERVAL_MAX (10.24f) +#define ADV_INTERVAL_MAX_STRING "10.24" + //| .. currentmodule:: bleio //| //| :class:`Peripheral` -- A BLE peripheral device @@ -75,19 +79,21 @@ static const char default_name[] = "CIRCUITPY"; //| # Wait for connection. //| pass //| -//| .. class:: Peripheral(services, *, name='CIRCUITPY') +//| .. class:: Peripheral(services=(), \*, name='CIRCUITPY') //| //| Create a new Peripheral object. -//| :param iterable services: the Service objects representing services available from this peripheral. -//| :param str name: The name used when advertising this peripheral +//| :param iterable services: the Service objects representing services available from this peripheral, if any. +//| A non-connectable peripheral will have no services. +//| :param str name: The name used when advertising this peripheral. Use ``None`` when a name is not needed, +//| such as when the peripheral is a beacon //| STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_services, ARG_name }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, + { MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_empty_tuple} }, + { MP_QSTR_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -112,8 +118,11 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar } const mp_obj_t name = args[ARG_name].u_obj; - if (name == mp_const_none) { + if (name == MP_OBJ_NULL) { self->name = mp_obj_new_str(default_name, strlen(default_name)); + } else if (name == mp_const_none) { + // Make None be the empty string. + self->name = MP_OBJ_NEW_QSTR(MP_QSTR_); } else if (MP_OBJ_IS_STR(name)) { self->name = name; } else { @@ -182,7 +191,7 @@ const mp_obj_property_t bleio_peripheral_name_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. method:: start_advertising(data, *, scan_response=None, connectable=True) +//| .. method:: start_advertising(data, *, scan_response=None, connectable=True, interval=1) //| //| Starts advertising the peripheral. The peripheral's name and //| services are included in the advertisement packets. @@ -190,16 +199,17 @@ const mp_obj_property_t bleio_peripheral_name_obj = { //| :param buf data: advertising data packet bytes //| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed. //| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral. -//| +//| :param float interval: advertising interval, in seconds //| STATIC mp_obj_t bleio_peripheral_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - enum { ARG_data, ARG_scan_response, ARG_connectable }; + enum { ARG_data, ARG_scan_response, ARG_connectable, ARG_interval }; static const mp_arg_t allowed_args[] = { { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_scan_response, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, + { MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -210,11 +220,21 @@ STATIC mp_obj_t bleio_peripheral_start_advertising(mp_uint_t n_args, const mp_ob // Pass an empty buffer if scan_response not provided. mp_buffer_info_t scan_response_bufinfo = { 0 }; - if (args[ARG_data].u_obj != mp_const_none) { + if (args[ARG_scan_response].u_obj != mp_const_none) { mp_get_buffer_raise(args[ARG_scan_response].u_obj, &scan_response_bufinfo, MP_BUFFER_READ); } - common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, + if (args[ARG_interval].u_obj == MP_OBJ_NULL) { + args[ARG_interval].u_obj = mp_obj_new_float(1.0F); + } + + const mp_float_t interval = mp_obj_float_get(args[ARG_interval].u_obj); + if (interval < ADV_INTERVAL_MIN || interval > ADV_INTERVAL_MAX) { + mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), + ADV_INTERVAL_MIN_STRING, ADV_INTERVAL_MAX_STRING); + } + + common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, interval, &data_bufinfo, &scan_response_bufinfo); return mp_const_none; diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h index c09c600885..7ef45edcd6 100644 --- a/shared-bindings/bleio/Peripheral.h +++ b/shared-bindings/bleio/Peripheral.h @@ -34,7 +34,7 @@ extern const mp_obj_type_t bleio_peripheral_type; extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self); extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self); -extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); +extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, float interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 03aef2eced..4b98e4673c 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -28,8 +28,6 @@ #include "shared-bindings/bleio/__init__.h" #include "shared-bindings/bleio/Address.h" #include "shared-bindings/bleio/AddressType.h" -#include "shared-bindings/bleio/AdvertisementData.h" -#include "shared-bindings/bleio/Broadcaster.h" #include "shared-bindings/bleio/Characteristic.h" #include "shared-bindings/bleio/CharacteristicBuffer.h" #include "shared-bindings/bleio/Descriptor.h" @@ -57,7 +55,6 @@ //| AddressType //| AdvertisementData //| Adapter -//| Broadcaster //| Characteristic //| CharacteristicBuffer // Work-in-progress classes are omitted, and marked as :orphan: in their files. @@ -79,8 +76,6 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) }, { MP_ROM_QSTR(MP_QSTR_Address), MP_ROM_PTR(&bleio_address_type) }, - { MP_ROM_QSTR(MP_QSTR_AdvertisementData), MP_ROM_PTR(&bleio_advertisementdata_type) }, - { MP_ROM_QSTR(MP_QSTR_Broadcaster), MP_ROM_PTR(&bleio_broadcaster_type) }, { MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) }, { MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) }, // { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, diff --git a/shared-module/bleio/AdvertisementData.h b/shared-module/bleio/AdvertisementData.h index 738d53b23f..66855172ab 100644 --- a/shared-module/bleio/AdvertisementData.h +++ b/shared-module/bleio/AdvertisementData.h @@ -75,11 +75,4 @@ 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 From 1905d90eaa65b6b306c84038cc1ad32e4e601f65 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 5 Jun 2019 20:08:53 -0400 Subject: [PATCH 07/25] Make advertising data buffers long-lived --- ports/nrf/common-hal/bleio/Peripheral.c | 5 ++++- ports/nrf/common-hal/bleio/Peripheral.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 2cd52841a3..e522b50d28 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -177,9 +177,13 @@ void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, } check_data_fit(advertising_data_bufinfo->len); + // The advertising data buffers must not move, because the SoftDevice depends on them. + // So make them long-lived. + self->advertising_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true); memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len); check_data_fit(scan_response_data_bufinfo->len); + self->scan_response_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true); memcpy(self->scan_response_data, scan_response_data_bufinfo->buf, scan_response_data_bufinfo->len); @@ -214,7 +218,6 @@ void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, } void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *self) { - if (self->adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) return; diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index 58526fc484..eb0b0417a1 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -46,8 +46,8 @@ typedef struct { // The advertising data and scan response buffers are held by us, not by the SD, so we must // maintain them and not change it. If we need to change the contents during advertising, // there are tricks to get the SD to notice (see DevZone - TBS). - uint8_t advertising_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; - uint8_t scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; + uint8_t* advertising_data; + uint8_t* scan_response_data; uint8_t adv_handle; } bleio_peripheral_obj_t; From 6fed24e1b6fce58f2c06328b9bc8b8f9d9512b42 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 10 Jun 2019 07:18:28 -0400 Subject: [PATCH 08/25] WIP --- shared-bindings/bleio/Address.c | 58 +++++---------------------------- shared-bindings/bleio/UUID.c | 5 +-- 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index b7c76b7b2e..226c011a3d 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -53,9 +53,8 @@ STATIC uint8_t xdigit_8b_value(byte nibble1, byte nibble2) { //| Create a new Address object encapsulating the address value. //| The value itself can be one of: //| -//| - a `str` value in the format of 'XXXXXXXXXXXX' or 'XX:XX:XX:XX:XX:XX' (12 hex digits) -//| - a `bytes` or `bytearray` containing 6 bytes -//| - another Address object +//| :param buf: The address value to encapsulate +//| - a buffer object (bytearray, bytes) of 6 bytes //| //| :param address: The address to encapsulate //| @@ -84,54 +83,15 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t address = args[ARG_address].u_obj; - if (MP_OBJ_IS_STR(address)) { - GET_STR_DATA_LEN(address, str, str_len); - - size_t value_index = 0; - int str_index = str_len; - bool error = false; - - // Loop until fewer than two characters left. - while (str_index >= 1 && value_index < sizeof(self->value)) { - if (str[str_index] == ':') { - // Skip colon separators. - str_index--; - continue; - } - - if (!unichar_isxdigit(str[str_index]) || - !unichar_isxdigit(str[str_index-1])) { - error = true; - break; - } - - self->value[value_index] = xdigit_8b_value(str[str_index], - str[str_index-1]); - value_index += 1; - str_index -= 2; - } - // Check for correct number of hex digits and no parsing errors. - if (error || value_index != ADDRESS_BYTE_LEN || str_index != -1) { - mp_raise_ValueError_varg(translate("Address is not %d bytes long or is in wrong format"), - ADDRESS_BYTE_LEN); - } - } 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_varg(translate("Address must be %d bytes long"), BLEIO_ADDRESS_BYTES); - } - - for (size_t b = 0; b < BLEIO_ADDRESS_BYTES; ++b) { - self->value[BLEIO_ADDRESS_BYTES - b - 1] = ((uint8_t*)buf_info.buf)[b]; - } - } else if (MP_OBJ_IS_TYPE(address, &bleio_address_type)) { - // deep copy - bleio_address_obj_t *other = MP_OBJ_TO_PTR(address); - self->type = other->type; - memcpy(self->value, other->value, BLEIO_ADDRESS_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_varg(translate("Address must be %d bytes long"), BLEIO_ADDRESS_BYTES); } + for (size_t b = 0; b < BLEIO_ADDRESS_BYTES; ++b) { + self->value[BLEIO_ADDRESS_BYTES - b - 1] = ((uint8_t*)buf_info.buf)[b]; + } return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/bleio/UUID.c b/shared-bindings/bleio/UUID.c index c6ad9e6266..d054ea7191 100644 --- a/shared-bindings/bleio/UUID.c +++ b/shared-bindings/bleio/UUID.c @@ -48,8 +48,9 @@ //| //| - an `int` value in range 0 to 0xFFFF (Bluetooth SIG 16-bit UUID) //| - a buffer object (bytearray, bytes) of 16 bytes in little-endian order (128-bit UUID) +//| - a string of hex digits of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' //| -//| :param int/buffer value: The uuid value to encapsulate +//| :param value: The uuid value to encapsulate //| STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -63,7 +64,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, co if (MP_OBJ_IS_INT(value)) { mp_int_t uuid16 = mp_obj_get_int(value); if (uuid16 < 0 || uuid16 > 0xffff) { - mp_raise_ValueError(translate("UUID integer value not in range 0 to 0xffff")); + mp_raise_ValueError(translate("UUID integer value must be 0-0xffff")); } // NULL means no 128-bit value. From 1356819de195810da09b5fc051ef5cc9dc21b2f4 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 17 Jun 2019 23:16:40 -0400 Subject: [PATCH 09/25] Handle None for BLE name; fix ScanEntry bug; compile issue --- ports/nrf/Makefile | 2 +- shared-bindings/bleio/Peripheral.c | 5 +---- shared-bindings/bleio/ScanEntry.c | 1 + shared-module/displayio/TileGrid.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index d947ab34c0..b7ff2fcbaa 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -91,7 +91,7 @@ INC += -I../../supervisor/shared/usb ifeq ($(DEBUG), 1) CFLAGS += -ggdb # You may want to enable these flags to make setting breakpoints easier. - CFLAGS += -fno-inline -fno-ipa-sra + # CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -Os -DNDEBUG # TODO: Test with -flto diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index ca703bd535..4492a8e269 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -117,11 +117,8 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar } const mp_obj_t name = args[ARG_name].u_obj; - if (name == MP_OBJ_NULL) { + if (name == MP_OBJ_NULL || name == mp_const_none) { self->name = mp_obj_new_str(default_name, strlen(default_name)); - } else if (name == mp_const_none) { - // Make None be the empty string. - self->name = MP_OBJ_NEW_QSTR(MP_QSTR_); } else if (MP_OBJ_IS_STR(name)) { self->name = name; } else { diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index 475bade153..f66b3df4b8 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -55,6 +55,7 @@ STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; memcpy(address->bytes, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES); address->type = self->address.type; return MP_OBJ_TO_PTR(address); diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index 97b704c40e..43ce36ed37 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -440,7 +440,7 @@ void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) { displayio_area_t* displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *self, displayio_area_t* tail) { if (self->moved && !self->first_draw) { displayio_area_union(&self->previous_area, &self->current_area, &self->dirty_area); - if (displayio_area_size(&self->dirty_area) <= 2 * self->pixel_width * self->pixel_height) { + if (displayio_area_size(&self->dirty_area) <= 2U * self->pixel_width * self->pixel_height) { self->dirty_area.next = tail; return &self->dirty_area; } From 35b919185747c42e183ccfc41f99fd370acca450 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 18 Jun 2019 23:46:20 -0400 Subject: [PATCH 10/25] Don't operate directly on bleio objects in shared-bindings: use common_hal routines instead. Changes made but not yet tested. --- ports/nrf/common-hal/bleio/Broadcaster.h | 6 +-- ports/nrf/common-hal/bleio/Characteristic.c | 16 +++++- ports/nrf/common-hal/bleio/Characteristic.h | 8 +-- .../common-hal/bleio/CharacteristicBuffer.h | 6 +-- ports/nrf/common-hal/bleio/Device.c | 14 +++--- ports/nrf/common-hal/bleio/Peripheral.c | 18 ++++++- ports/nrf/common-hal/bleio/Peripheral.h | 12 +++-- ports/nrf/common-hal/bleio/Scanner.c | 12 ++++- .../nrf/common-hal}/bleio/Scanner.h | 9 ++-- ports/nrf/common-hal/bleio/Service.c | 36 ++++++++++++-- .../nrf/common-hal}/bleio/Service.h | 8 +-- ports/nrf/common-hal/bleio/__init__.h | 6 +-- py/circuitpy_defns.mk | 2 + py/obj.h | 1 + py/objlist.c | 4 +- shared-bindings/bleio/Address.c | 10 ++-- shared-bindings/bleio/Address.h | 5 ++ shared-bindings/bleio/Characteristic.c | 22 ++++----- shared-bindings/bleio/Characteristic.h | 5 +- shared-bindings/bleio/CharacteristicBuffer.c | 3 +- shared-bindings/bleio/Device.h | 2 +- shared-bindings/bleio/Peripheral.c | 25 +++++----- shared-bindings/bleio/Peripheral.h | 4 +- shared-bindings/bleio/ScanEntry.c | 24 +++------ shared-bindings/bleio/ScanEntry.h | 5 ++ shared-bindings/bleio/Scanner.c | 6 +-- shared-bindings/bleio/Scanner.h | 6 ++- shared-bindings/bleio/Service.c | 24 ++++----- shared-bindings/bleio/Service.h | 8 ++- shared-module/bleio/Address.c | 45 +++++++++++++++++ shared-module/bleio/Address.h | 2 + shared-module/bleio/Characteristic.h | 1 + shared-module/bleio/ScanEntry.c | 49 +++++++++++++++++++ shared-module/bleio/ScanEntry.h | 3 +- 34 files changed, 294 insertions(+), 113 deletions(-) rename {shared-module => ports/nrf/common-hal}/bleio/Scanner.h (83%) rename {shared-module => ports/nrf/common-hal}/bleio/Service.h (88%) create mode 100644 shared-module/bleio/Address.c create mode 100644 shared-module/bleio/ScanEntry.c diff --git a/ports/nrf/common-hal/bleio/Broadcaster.h b/ports/nrf/common-hal/bleio/Broadcaster.h index 72f93a4431..2d1ae69a12 100644 --- a/ports/nrf/common-hal/bleio/Broadcaster.h +++ b/ports/nrf/common-hal/bleio/Broadcaster.h @@ -25,8 +25,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H -#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H #include "ble.h" @@ -44,4 +44,4 @@ typedef struct { } bleio_broadcaster_obj_t; -#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 9409b73ce6..45fb1d092a 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -237,7 +237,11 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, } -void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) { +void common_hal_bleio_characteristic_set_service(bleio_characteristic_obj_t *self, bleio_service_obj_t *service) { + self->service = service; +} + +mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) { switch (common_hal_bleio_device_get_gatt_role(self->service->device)) { case GATT_ROLE_CLIENT: gattc_read(self); @@ -251,6 +255,8 @@ void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) mp_raise_RuntimeError(translate("bad GATT role")); break; } + + return self->value_data; } void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { @@ -285,3 +291,11 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, break; } } + +bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) { + return self->props; +} diff --git a/ports/nrf/common-hal/bleio/Characteristic.h b/ports/nrf/common-hal/bleio/Characteristic.h index bce1eec1d3..662485bad5 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.h +++ b/ports/nrf/common-hal/bleio/Characteristic.h @@ -24,11 +24,11 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H -#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H #include "shared-module/bleio/Characteristic.h" -#include "shared-module/bleio/Service.h" +#include "common-hal/bleio/Service.h" #include "common-hal/bleio/UUID.h" typedef struct { @@ -43,4 +43,4 @@ typedef struct { uint16_t sccd_handle; } bleio_characteristic_obj_t; -#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H diff --git a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h index b36f63fec3..6a44229f7a 100644 --- a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h +++ b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H -#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H #include "nrf_soc.h" @@ -40,4 +40,4 @@ typedef struct { ringbuf_t ringbuf; } bleio_characteristic_buffer_obj_t; -#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H diff --git a/ports/nrf/common-hal/bleio/Device.c b/ports/nrf/common-hal/bleio/Device.c index 5f625829e4..b1ac72e754 100644 --- a/ports/nrf/common-hal/bleio/Device.c +++ b/ports/nrf/common-hal/bleio/Device.c @@ -323,7 +323,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); service->base.type = &bleio_service_type; service->device = device; - service->char_list = mp_obj_new_list(0, NULL); + service->characteristic_list = mp_obj_new_list(0, NULL); service->start_handle = gattc_service->handle_range.start_handle; service->end_handle = gattc_service->handle_range.end_handle; service->handle = gattc_service->handle_range.start_handle; @@ -366,7 +366,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio characteristic->handle = gattc_char->handle_value; characteristic->service = m_char_discovery_service; - mp_obj_list_append(m_char_discovery_service->char_list, MP_OBJ_FROM_PTR(characteristic)); + mp_obj_list_append(m_char_discovery_service->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); } if (response->count > 0) { @@ -491,9 +491,9 @@ void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_servi mp_raise_OSError_msg(translate("Failed to add service")); } - const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list); - for (size_t i = 0; i < char_list->len; ++i) { - bleio_characteristic_obj_t *characteristic = char_list->items[i]; + const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); + for (size_t i = 0; i < characteristic_list->len; ++i) { + bleio_characteristic_obj_t *characteristic = characteristic_list->items[i]; common_hal_bleio_service_add_characteristic(service, characteristic); } } @@ -583,8 +583,8 @@ void common_hal_bleio_device_connect(bleio_device_obj_t *device) { bool found_char = discover_characteristics(device, service, service->start_handle); 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 mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); + const bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_list->len - 1]; const uint16_t next_handle = characteristic->handle + 1; if (next_handle >= service->end_handle) { diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index e59676fde4..36c20373d3 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -33,6 +33,7 @@ #include "ble_hci.h" #include "nrf_soc.h" #include "py/gc.h" +#include "py/objlist.h" #include "py/objstr.h" #include "py/runtime.h" #include "shared-bindings/bleio/Adapter.h" @@ -40,6 +41,7 @@ #include "shared-bindings/bleio/Peripheral.h" #include "shared-bindings/bleio/Service.h" #include "shared-bindings/bleio/UUID.h" +#include "common-hal/bleio/Service.h" #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) @@ -117,19 +119,23 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { } } -void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) { +void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *service_list, mp_obj_t name) { common_hal_bleio_adapter_set_enabled(true); + self->service_list = service_list; + self->name = name; + self->gatt_role = GATT_ROLE_SERVER; self->conn_handle = BLE_CONN_HANDLE_INVALID; self->adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; // Add all the services. - mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); for (size_t service_idx = 0; service_idx < service_list->len; ++service_idx) { bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[service_idx]); + common_hal_bleio_service_set_device(service, MP_OBJ_FROM_PTR(self)); + ble_uuid_t uuid; bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); @@ -149,10 +155,18 @@ void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) { } +mp_obj_list_t *common_hal_bleio_peripheral_get_service_list(bleio_peripheral_obj_t *self) { + return self->service_list; +} + bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) { return self->conn_handle != BLE_CONN_HANDLE_INVALID; } +mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self) { + return self->name; +} + void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) { // interval value has already been validated. diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index eb0b0417a1..9103fcf943 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -25,13 +25,16 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H -#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H #include #include "ble.h" +#include "py/obj.h" +#include "py/objlist.h" + #include "shared-module/bleio/__init__.h" #include "shared-module/bleio/Address.h" @@ -40,8 +43,7 @@ typedef struct { mp_obj_t name; gatt_role_t gatt_role; volatile uint16_t conn_handle; - mp_obj_t service_list; - mp_obj_t notif_handler; + mp_obj_list_t *service_list; mp_obj_t conn_handler; // The advertising data and scan response buffers are held by us, not by the SD, so we must // maintain them and not change it. If we need to change the contents during advertising, @@ -52,4 +54,4 @@ typedef struct { } bleio_peripheral_obj_t; -#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index 08600bc0ae..64f7decad2 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -30,6 +30,7 @@ #include "ble_drv.h" #include "ble_gap.h" #include "py/mphal.h" +#include "py/objlist.h" #include "py/runtime.h" #include "shared-bindings/bleio/Adapter.h" #include "shared-bindings/bleio/ScanEntry.h" @@ -68,6 +69,10 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { } } +void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self) { + self->adv_reports = mp_obj_new_list(0, NULL); +} + void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { common_hal_bleio_adapter_set_enabled(true); ble_drv_add_event_handler(on_ble_evt, self); @@ -78,7 +83,8 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout .scan_phys = BLE_GAP_PHY_1MBPS, }; - common_hal_bleio_adapter_set_enabled(true); + // Empty the advertising reports list. + mp_obj_list_clear(self->adv_reports); uint32_t err_code; err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer); @@ -90,3 +96,7 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout mp_hal_delay_ms(timeout * 1000); sd_ble_gap_scan_stop(); } + +mp_obj_t common_hal_bleio_scanner_get_adv_reports(bleio_scanner_obj_t *self) { + return self->adv_reports; +} diff --git a/shared-module/bleio/Scanner.h b/ports/nrf/common-hal/bleio/Scanner.h similarity index 83% rename from shared-module/bleio/Scanner.h rename to ports/nrf/common-hal/bleio/Scanner.h index 76f5e58669..a710664877 100644 --- a/shared-module/bleio/Scanner.h +++ b/ports/nrf/common-hal/bleio/Scanner.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,16 +25,16 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANNER_H -#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANNER_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H #include "py/obj.h" typedef struct { mp_obj_base_t base; - mp_obj_t adv_reports; + mp_obj_t adv_reports; // List of reports. uint16_t interval; uint16_t window; } bleio_scanner_obj_t; -#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANNER_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c index 26a1f1cff5..77d3f02599 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -29,18 +29,46 @@ #include "py/runtime.h" #include "common-hal/bleio/__init__.h" #include "common-hal/bleio/Characteristic.h" +#include "shared-bindings/bleio/Characteristic.h" #include "shared-bindings/bleio/Service.h" #include "shared-bindings/bleio/Adapter.h" -void common_hal_bleio_service_construct(bleio_service_obj_t *self) { +void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *characteristic_list, bool is_secondary) { + self->device = mp_const_none; + self->handle = 0xFFFF; + self->uuid = uuid; + self->characteristic_list = characteristic_list; + self->is_secondary = is_secondary; + + for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) { + bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_list->items[characteristic_idx]); + common_hal_bleio_characteristic_set_service(characteristic, self); + } + +} + +bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) { + return self->uuid; +} + +mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self) { + return self->characteristic_list; +} + +bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) { + return self->is_secondary; +} + +void common_hal_bleio_service_set_device(bleio_service_obj_t *self, mp_obj_t device) { + self->device = device; } // Call this after the Service has been added to the Peripheral. void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) { // Add all the characteristics. - const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list); - for (size_t char_idx = 0; char_idx < char_list->len; ++char_idx) { - bleio_characteristic_obj_t *characteristic = char_list->items[char_idx]; + const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(self->characteristic_list); + for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) { + bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_idx]; ble_gatts_char_md_t char_md = { .char_props.broadcast = characteristic->props.broadcast, diff --git a/shared-module/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h similarity index 88% rename from shared-module/bleio/Service.h rename to ports/nrf/common-hal/bleio/Service.h index 828d4cdc87..7998cc862a 100644 --- a/shared-module/bleio/Service.h +++ b/ports/nrf/common-hal/bleio/Service.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H -#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H #include "common-hal/bleio/UUID.h" @@ -36,9 +36,9 @@ typedef struct { bleio_uuid_obj_t *uuid; // May be a Peripheral, Central, etc. mp_obj_t *device; - mp_obj_t char_list; + mp_obj_t characteristic_list; uint16_t start_handle; uint16_t end_handle; } bleio_service_obj_t; -#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H diff --git a/ports/nrf/common-hal/bleio/__init__.h b/ports/nrf/common-hal/bleio/__init__.h index 9e044f37c1..0c46b631fc 100644 --- a/ports/nrf/common-hal/bleio/__init__.h +++ b/ports/nrf/common-hal/bleio/__init__.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H -#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H #include "shared-bindings/bleio/__init__.h" #include "shared-bindings/bleio/Adapter.h" @@ -39,4 +39,4 @@ gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device); uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device); -#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index fd43a11a67..435cf2c334 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -308,6 +308,8 @@ $(filter $(SRC_PATTERNS), \ bitbangio/SPI.c \ bitbangio/__init__.c \ board/__init__.c \ + bleio/Address.c \ + bleio/ScanEntry.c \ busio/OneWire.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ diff --git a/py/obj.h b/py/obj.h index 773043b593..6eead377db 100644 --- a/py/obj.h +++ b/py/obj.h @@ -763,6 +763,7 @@ void mp_obj_tuple_del(mp_obj_t self_in); mp_int_t mp_obj_tuple_hash(mp_obj_t self_in); // list +mp_obj_t mp_obj_list_clear(mp_obj_t self_in); mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg); mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value); void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items); diff --git a/py/objlist.c b/py/objlist.c index 16ca4b353e..558c4c6115 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -340,7 +340,7 @@ mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ return mp_const_none; } -STATIC mp_obj_t list_clear(mp_obj_t self_in) { +mp_obj_t mp_obj_list_clear(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list)); mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); self->len = 0; @@ -418,7 +418,7 @@ STATIC mp_obj_t list_reverse(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append); STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend); -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, mp_obj_list_clear); STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy); STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index); diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index 7367da5352..5875cf9bd8 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -74,13 +75,12 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, mp_raise_ValueError_varg(translate("Address must be %d bytes long"), NUM_BLEIO_ADDRESS_BYTES); } - memcpy(self->bytes, buf_info.buf, buf_info.len); - const mp_int_t address_type = args[ARG_address_type].u_int; if (address_type < BLEIO_ADDRESS_TYPE_MIN || address_type > BLEIO_ADDRESS_TYPE_MAX) { mp_raise_ValueError(translate("Address type out of range")); } - self->type = address_type; + + common_hal_bleio_address_construct(self, buf_info.buf, buf_info.len, address_type); return MP_OBJ_FROM_PTR(self); } @@ -97,7 +97,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bytes(self->bytes, NUM_BLEIO_ADDRESS_BYTES); + return common_hal_bleio_address_get_address_bytes(self); } MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_address_bytes_obj, bleio_address_get_address_bytes); @@ -113,7 +113,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_address_bytes_obj, bleio_address_get STATIC mp_obj_t bleio_address_get_type(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_NEW_SMALL_INT(self->type); + return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_address_get_type(self)); } MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_type_obj, bleio_address_get_type); diff --git a/shared-bindings/bleio/Address.h b/shared-bindings/bleio/Address.h index ef84d7432b..9652a9841a 100644 --- a/shared-bindings/bleio/Address.h +++ b/shared-bindings/bleio/Address.h @@ -28,6 +28,7 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESS_H #include "py/objtype.h" +#include "shared-module/bleio/Address.h" #define BLEIO_ADDRESS_TYPE_PUBLIC (0) #define BLEIO_ADDRESS_TYPE_RANDOM_STATIC (1) @@ -39,4 +40,8 @@ extern const mp_obj_type_t bleio_address_type; +extern void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, size_t bytes_length, uint8_t address_type); +extern mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self); +extern uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESS_H diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index ae83de8643..e48cfd433b 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -73,10 +73,10 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) { mp_raise_ValueError(translate("Expected a UUID")); } + bleio_uuid_obj_t *uuid_obj = MP_OBJ_TO_PTR(uuid); bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t); self->base.type = &bleio_characteristic_type; - self->uuid = MP_OBJ_TO_PTR(uuid); bleio_characteristic_properties_t properties; @@ -87,7 +87,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t properties.write = args[ARG_write].u_bool; properties.write_no_response = args[ARG_write_no_response].u_bool; - common_hal_bleio_characteristic_construct(self, uuid, properties); + common_hal_bleio_characteristic_construct(self, uuid_obj, properties); return MP_OBJ_FROM_PTR(self); } @@ -99,7 +99,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t STATIC mp_obj_t bleio_characteristic_get_broadcast(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->props.broadcast); + return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).broadcast); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_broadcast_obj, bleio_characteristic_get_broadcast); @@ -117,7 +117,7 @@ const mp_obj_property_t bleio_characteristic_broadcast_obj = { STATIC mp_obj_t bleio_characteristic_get_indicate(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->props.indicate); + return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).indicate); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_indicate_obj, bleio_characteristic_get_indicate); @@ -136,7 +136,7 @@ const mp_obj_property_t bleio_characteristic_indicate_obj = { STATIC mp_obj_t bleio_characteristic_get_notify(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->props.notify); + return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).notify); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_notify_obj, bleio_characteristic_get_notify); @@ -154,7 +154,7 @@ const mp_obj_property_t bleio_characteristic_notify_obj = { STATIC mp_obj_t bleio_characteristic_get_read(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->props.read); + return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).read); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_read_obj, bleio_characteristic_get_read); @@ -172,7 +172,7 @@ const mp_obj_property_t bleio_characteristic_read_obj = { STATIC mp_obj_t bleio_characteristic_get_write(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->props.write); + return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).write); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_obj, bleio_characteristic_get_write); @@ -190,7 +190,7 @@ const mp_obj_property_t bleio_characteristic_write_obj = { STATIC mp_obj_t bleio_characteristic_get_write_no_response(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->props.write_no_response); + return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).write_no_response); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_no_response_obj, bleio_characteristic_get_write_no_response); @@ -208,7 +208,7 @@ const mp_obj_property_t bleio_characteristic_write_no_response_obj = { STATIC mp_obj_t bleio_characteristic_get_uuid(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_FROM_PTR(self->uuid); + return MP_OBJ_FROM_PTR(common_hal_bleio_characteristic_get_uuid(self)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_uuid_obj, bleio_characteristic_get_uuid); @@ -228,9 +228,7 @@ const mp_obj_property_t bleio_characteristic_uuid_obj = { STATIC mp_obj_t bleio_characteristic_get_value(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_bleio_characteristic_get_value(self); - - return self->value_data; + return common_hal_bleio_characteristic_get_value(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_value_obj, bleio_characteristic_get_value); diff --git a/shared-bindings/bleio/Characteristic.h b/shared-bindings/bleio/Characteristic.h index 206cbcd403..ffee6bdbc7 100644 --- a/shared-bindings/bleio/Characteristic.h +++ b/shared-bindings/bleio/Characteristic.h @@ -32,7 +32,10 @@ extern const mp_obj_type_t bleio_characteristic_type; extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props); -extern void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self); +extern void common_hal_bleio_characteristic_set_service(bleio_characteristic_obj_t *self, bleio_service_obj_t *service); +extern mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self); extern void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo); +extern bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self); +extern bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H diff --git a/shared-bindings/bleio/CharacteristicBuffer.c b/shared-bindings/bleio/CharacteristicBuffer.c index a1dc663fd1..da79c5d7ae 100644 --- a/shared-bindings/bleio/CharacteristicBuffer.c +++ b/shared-bindings/bleio/CharacteristicBuffer.c @@ -85,9 +85,8 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t); self->base.type = &bleio_characteristic_buffer_type; - self->characteristic = MP_OBJ_TO_PTR(characteristic); - common_hal_bleio_characteristic_buffer_construct(self, self->characteristic, timeout, buffer_size); + common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer_size); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/bleio/Device.h b/shared-bindings/bleio/Device.h index 1f85abe9a1..e452a8ad6c 100644 --- a/shared-bindings/bleio/Device.h +++ b/shared-bindings/bleio/Device.h @@ -28,7 +28,7 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H #include "shared-module/bleio/Device.h" -#include "shared-module/bleio/Service.h" +#include "common-hal/bleio/Service.h" extern const mp_obj_type_t bleio_device_type; diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 4492a8e269..5397f4c3ab 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -101,32 +101,33 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar // If services is not an iterable, an exception will be thrown. mp_obj_iter_buf_t iter_buf; mp_obj_t iterable = mp_getiter(args[ARG_services].u_obj, &iter_buf); - mp_obj_t service; bleio_peripheral_obj_t *self = m_new_obj(bleio_peripheral_obj_t); self->base.type = &bleio_peripheral_type; - self->service_list = mp_obj_new_list(0, NULL); - self->notif_handler = mp_const_none; + + // Copy the services list and validate its items. + mp_obj_t service_list = mp_obj_new_list(0, NULL); + mp_obj_list_t *service_list_obj = MP_OBJ_FROM_PTR(service_list); + + mp_obj_t service; while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!MP_OBJ_IS_TYPE(service, &bleio_service_type)) { mp_raise_ValueError(translate("services includes an object that is not a Service")); } - bleio_service_obj_t *service_ptr = MP_OBJ_TO_PTR(service); - service_ptr->device = MP_OBJ_FROM_PTR(self); - mp_obj_list_append(self->service_list, service); + mp_obj_list_append(service_list, service); } const mp_obj_t name = args[ARG_name].u_obj; + mp_obj_t name_str; if (name == MP_OBJ_NULL || name == mp_const_none) { - self->name = mp_obj_new_str(default_name, strlen(default_name)); + name_str = mp_obj_new_str(default_name, strlen(default_name)); } else if (MP_OBJ_IS_STR(name)) { - self->name = name; + name_str = name; } else { mp_raise_ValueError(translate("name must be a string")); } - // Do port-specific initialization. - common_hal_bleio_peripheral_construct(self); + common_hal_bleio_peripheral_construct(self, service_list_obj, name_str); return MP_OBJ_FROM_PTR(self); } @@ -157,7 +158,7 @@ const mp_obj_property_t bleio_peripheral_connected_obj = { STATIC mp_obj_t bleio_peripheral_get_services(mp_obj_t self_in) { bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); // Return list as a tuple so user won't be able to change it. - mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); + mp_obj_list_t *service_list = common_hal_bleio_peripheral_get_service_list(self); return mp_obj_new_tuple(service_list->len, service_list->items); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_services_obj, bleio_peripheral_get_services); @@ -176,7 +177,7 @@ const mp_obj_property_t bleio_peripheral_services_obj = { STATIC mp_obj_t bleio_peripheral_get_name(mp_obj_t self_in) { bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - return self->name; + return common_hal_bleio_peripheral_get_name(self); } MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_name_obj, bleio_peripheral_get_name); diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h index 7ef45edcd6..6468325c27 100644 --- a/shared-bindings/bleio/Peripheral.h +++ b/shared-bindings/bleio/Peripheral.h @@ -32,8 +32,10 @@ extern const mp_obj_type_t bleio_peripheral_type; -extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self); +extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *service_list, mp_obj_t name); +extern mp_obj_list_t *common_hal_bleio_peripheral_get_service_list(bleio_peripheral_obj_t *self); extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self); +extern mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self); extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, float interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device); diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index f66b3df4b8..145d2b0236 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * Copyright (c) 2017 Glenn Ruben Bakke * @@ -27,10 +28,7 @@ #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-bindings/bleio/ScanEntry.h" #include "shared-bindings/bleio/UUID.h" @@ -53,18 +51,13 @@ //| STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); - - bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; - memcpy(address->bytes, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES); - address->type = self->address.type; - return MP_OBJ_TO_PTR(address); + return common_hal_bleio_scanentry_get_address(self); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_address_obj, bleio_scanentry_get_address); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_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, + .proxy = { (mp_obj_t)&bleio_scanentry_get_address_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj }, }; @@ -75,7 +68,7 @@ const mp_obj_property_t bleio_scanentry_address_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); - return self->data; + return common_hal_bleio_scanentry_get_raw_data(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_raw_data_obj, scanentry_get_raw_data); @@ -92,14 +85,13 @@ const mp_obj_property_t bleio_scanentry_raw_data_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); + return mp_obj_new_int(common_hal_bleio_scanentry_get_rssi(self)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_rssi_obj, scanentry_get_rssi); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_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, + .proxy = { (mp_obj_t)&bleio_scanentry_get_rssi_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj }, }; diff --git a/shared-bindings/bleio/ScanEntry.h b/shared-bindings/bleio/ScanEntry.h index 2b44ba3f4b..c1b52e6b4e 100644 --- a/shared-bindings/bleio/ScanEntry.h +++ b/shared-bindings/bleio/ScanEntry.h @@ -29,7 +29,12 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H #include "py/obj.h" +#include "shared-module/bleio/ScanEntry.h" extern const mp_obj_type_t bleio_scanentry_type; +mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self); +mp_obj_t common_hal_bleio_scanentry_get_raw_data(bleio_scanentry_obj_t *self); +mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index a249d53438..92f6a2a18b 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -61,6 +61,8 @@ STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, bleio_scanner_obj_t *self = m_new_obj(bleio_scanner_obj_t); self->base.type = type; + common_hal_bleio_scanner_construct(self); + return MP_OBJ_FROM_PTR(self); } @@ -108,11 +110,9 @@ STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_m mp_raise_ValueError(translate("window must be <= interval")); } - self->adv_reports = mp_obj_new_list(0, NULL); - common_hal_bleio_scanner_scan(self, timeout, interval, window); - return self->adv_reports; + return common_hal_bleio_scanner_get_adv_reports(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanner_scan_obj, 2, bleio_scanner_scan); diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h index 54c09675ba..b9e3ecdee5 100644 --- a/shared-bindings/bleio/Scanner.h +++ b/shared-bindings/bleio/Scanner.h @@ -29,11 +29,13 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H #include "py/objtype.h" -#include "shared-module/bleio/Scanner.h" +#include "common-hal/bleio/Scanner.h" extern const mp_obj_type_t bleio_scanner_type; -void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window); +extern void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self); +extern void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window); extern void common_hal_bleio_scanner_stop(bleio_scanner_obj_t *self); +extern mp_obj_t common_hal_bleio_scanner_get_adv_reports(bleio_scanner_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index d9bc4021f4..352ef8d6a8 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -67,18 +67,20 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, } bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t); - self->char_list = mp_obj_new_list(0, NULL); self->base.type = &bleio_service_type; - self->device = mp_const_none; - self->handle = 0xFFFF; - self->is_secondary = args[ARG_secondary].u_bool; - self->uuid = MP_OBJ_TO_PTR(uuid); + + const bool is_secondary = args[ARG_secondary].u_bool; + bleio_uuid_obj_t *uuid_obj = MP_OBJ_TO_PTR(uuid); // If characteristics is not an iterable, an exception will be thrown. mp_obj_iter_buf_t iter_buf; mp_obj_t iterable = mp_getiter(args[ARG_characteristics].u_obj, &iter_buf); mp_obj_t characteristic; + // Copy the characteristics list and validate its items. + mp_obj_t char_list = mp_obj_new_list(0, NULL); + mp_obj_list_t *char_list_obj = MP_OBJ_FROM_PTR(char_list); + while ((characteristic = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) { mp_raise_ValueError(translate("characteristics includes an object that is not a Characteristic")); @@ -89,12 +91,10 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, // The descriptor base UUID doesn't match the characteristic base UUID. mp_raise_ValueError(translate("Characteristic UUID doesn't match Service UUID")); } - characteristic_ptr->service = self; - mp_obj_list_append(self->char_list, characteristic); + mp_obj_list_append(char_list, characteristic); } - // Do port-specific initialization. - common_hal_bleio_service_construct(self); + common_hal_bleio_service_construct(self, uuid_obj, char_list_obj, is_secondary); return MP_OBJ_FROM_PTR(self); } @@ -106,7 +106,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, STATIC mp_obj_t bleio_service_get_characteristics(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); // Return list as a tuple so user won't be able to change it. - mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list); + mp_obj_list_t *char_list = common_hal_bleio_service_get_characteristic_list(self); return mp_obj_new_tuple(char_list->len, char_list->items); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_characteristics_obj, bleio_service_get_characteristics); @@ -125,7 +125,7 @@ const mp_obj_property_t bleio_service_characteristics_obj = { STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); - return mp_obj_new_bool(self->is_secondary); + return mp_obj_new_bool(common_hal_bleio_service_get_is_secondary(self)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_secondary_obj, bleio_service_get_secondary); @@ -143,7 +143,7 @@ const mp_obj_property_t bleio_service_secondary_obj = { STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_FROM_PTR(self->uuid); + return MP_OBJ_FROM_PTR(common_hal_bleio_service_get_uuid(self)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_uuid_obj, bleio_service_get_uuid); diff --git a/shared-bindings/bleio/Service.h b/shared-bindings/bleio/Service.h index 389db3b2e9..27d79f9539 100644 --- a/shared-bindings/bleio/Service.h +++ b/shared-bindings/bleio/Service.h @@ -28,11 +28,15 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H #include "shared-module/bleio/Characteristic.h" -#include "shared-module/bleio/Service.h" +#include "common-hal/bleio/Service.h" const mp_obj_type_t bleio_service_type; -extern void common_hal_bleio_service_construct(bleio_service_obj_t *self); +extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *char_list, bool is_secondary); +extern bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self); +extern mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self); +extern bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self); +extern void common_hal_bleio_service_set_device(bleio_service_obj_t *self, mp_obj_t device); extern void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H diff --git a/shared-module/bleio/Address.c b/shared-module/bleio/Address.c new file mode 100644 index 0000000000..e26bbe2acb --- /dev/null +++ b/shared-module/bleio/Address.c @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/objproperty.h" +#include "shared-bindings/bleio/Address.h" +#include "shared-module/bleio/Address.h" + +void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, size_t bytes_length, uint8_t address_type) { + memcpy(self->bytes, bytes, bytes_length); + self->type = address_type; +} + +mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self) { + return mp_obj_new_bytes(self->bytes, NUM_BLEIO_ADDRESS_BYTES); +} + +uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self) { + return self->type; +} diff --git a/shared-module/bleio/Address.h b/shared-module/bleio/Address.h index 65f493c16a..f66e97d640 100644 --- a/shared-module/bleio/Address.h +++ b/shared-module/bleio/Address.h @@ -27,6 +27,8 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H #define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H +#include "py/obj.h" + #define NUM_BLEIO_ADDRESS_BYTES 6 typedef struct { diff --git a/shared-module/bleio/Characteristic.h b/shared-module/bleio/Characteristic.h index 958837e64f..3132fd47b4 100644 --- a/shared-module/bleio/Characteristic.h +++ b/shared-module/bleio/Characteristic.h @@ -37,5 +37,6 @@ typedef struct { bool indicate : 1; } bleio_characteristic_properties_t; +// bleio_characteristic_obj_t is defined in ports/*/common-hal. #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H diff --git a/shared-module/bleio/ScanEntry.c b/shared-module/bleio/ScanEntry.c new file mode 100644 index 0000000000..44b50a4ce0 --- /dev/null +++ b/shared-module/bleio/ScanEntry.c @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * 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 "shared-bindings/bleio/Address.h" +#include "shared-module/bleio/Address.h" +#include "shared-module/bleio/ScanEntry.h" + +mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self) { + bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; + memcpy(address->bytes, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES); + address->type = self->address.type; + return MP_OBJ_TO_PTR(address); +} + +mp_obj_t common_hal_bleio_scanentry_get_raw_data(bleio_scanentry_obj_t *self) { + return self->data; +} + +mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self) { + return self->rssi; +} diff --git a/shared-module/bleio/ScanEntry.h b/shared-module/bleio/ScanEntry.h index 6ae7334a80..40e02f9fa0 100644 --- a/shared-module/bleio/ScanEntry.h +++ b/shared-module/bleio/ScanEntry.h @@ -27,7 +27,8 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANENTRY_H #define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANENTRY_H -#include "shared-module/bleio/Address.h" +#include "py/obj.h" +#include "shared-bindings/bleio/Address.h" typedef struct { mp_obj_base_t base; From a1b5d800f30418a08a39e73ba4b3e276ca6c7241 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 19 Jun 2019 10:42:36 -0400 Subject: [PATCH 11/25] Update copyrights; get ready for Central --- locale/ID.po | 69 +- locale/circuitpython.pot | 65 +- locale/de_DE.po | 82 ++- locale/en_US.po | 65 +- locale/en_x_pirate.po | 65 +- locale/es.po | 82 ++- locale/fil.po | 69 +- locale/fr.po | 82 ++- locale/it_IT.po | 69 +- locale/pl.po | 82 ++- locale/pt_BR.po | 69 +- locale/zh_Latn_pinyin.po | 82 ++- ports/nrf/Makefile | 1 - ports/nrf/bluetooth/ble_drv.c | 3 +- ports/nrf/bluetooth/ble_drv.h | 3 +- ports/nrf/bluetooth/ble_uart.c | 3 +- ports/nrf/common-hal/analogio/AnalogIn.c | 2 +- ports/nrf/common-hal/bleio/Adapter.c | 1 + ports/nrf/common-hal/bleio/Adapter.h | 3 +- ports/nrf/common-hal/bleio/Broadcaster.h | 47 -- ports/nrf/common-hal/bleio/Characteristic.c | 2 +- ports/nrf/common-hal/bleio/Characteristic.h | 3 +- .../common-hal/bleio/CharacteristicBuffer.h | 2 +- ports/nrf/common-hal/bleio/Descriptor.c | 3 +- ports/nrf/common-hal/bleio/Descriptor.h | 3 +- ports/nrf/common-hal/bleio/Device.c | 601 ------------------ ports/nrf/common-hal/bleio/Peripheral.c | 2 +- ports/nrf/common-hal/bleio/Peripheral.h | 2 +- ports/nrf/common-hal/bleio/Scanner.c | 3 +- ports/nrf/common-hal/bleio/Service.c | 1 + ports/nrf/common-hal/bleio/Service.h | 1 + ports/nrf/common-hal/bleio/UUID.c | 3 +- ports/nrf/common-hal/bleio/UUID.h | 3 +- ports/nrf/common-hal/bleio/__init__.c | 3 +- ports/nrf/common-hal/busio/I2C.c | 5 +- ports/nrf/common-hal/busio/SPI.c | 8 +- ports/nrf/mphalport.c | 3 +- shared-bindings/bleio/Adapter.c | 1 + shared-bindings/bleio/Adapter.h | 1 + shared-bindings/bleio/Address.h | 1 + shared-bindings/bleio/AdvertisementData.h | 1 + shared-bindings/bleio/Characteristic.c | 3 +- shared-bindings/bleio/Characteristic.h | 2 + shared-bindings/bleio/CharacteristicBuffer.h | 2 +- shared-bindings/bleio/Descriptor.c | 3 +- shared-bindings/bleio/Descriptor.h | 1 + shared-bindings/bleio/Device.c | 362 ----------- shared-bindings/bleio/Device.h | 1 + shared-bindings/bleio/Peripheral.c | 3 +- shared-bindings/bleio/Peripheral.h | 2 +- shared-bindings/bleio/ScanEntry.h | 1 + shared-bindings/bleio/Service.c | 3 +- shared-bindings/bleio/Service.h | 4 +- shared-bindings/bleio/UUID.c | 4 +- shared-bindings/bleio/UUID.h | 1 + shared-bindings/bleio/__init__.c | 7 +- shared-bindings/bleio/__init__.h | 3 +- shared-module/bleio/Address.h | 1 + shared-module/bleio/AdvertisementData.h | 1 + shared-module/bleio/Characteristic.h | 42 -- shared-module/bleio/Device.h | 45 -- shared-module/bleio/ScanEntry.h | 1 + 62 files changed, 602 insertions(+), 1486 deletions(-) delete mode 100644 ports/nrf/common-hal/bleio/Broadcaster.h delete mode 100644 ports/nrf/common-hal/bleio/Device.c delete mode 100644 shared-bindings/bleio/Device.c delete mode 100644 shared-module/bleio/Characteristic.h delete mode 100644 shared-module/bleio/Device.h diff --git a/locale/ID.po b/locale/ID.po index c1760e6b49..7017631095 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -218,16 +218,15 @@ msgstr "" msgid "A hardware interrupt channel is already in use" msgstr "Sebuah channel hardware interrupt sedang digunakan" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "" - #: shared-bindings/bleio/Address.c #, fuzzy, c-format msgid "Address must be %d bytes long" msgstr "buffers harus mempunyai panjang yang sama" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Semua perangkat I2C sedang digunakan" @@ -354,19 +353,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "" @@ -494,13 +493,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy msgid "Data too large for advertisement packet" msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Data too large for the advertisement packet" msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" @@ -551,7 +549,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to acquire mutex" msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" @@ -566,7 +564,7 @@ msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" msgid "Failed to add characteristic, err 0x%04x" msgstr "Gagal untuk menambahkan karakteristik, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to add service" msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX" @@ -591,12 +589,17 @@ msgstr "Gagal untuk megalokasikan buffer RX dari %d byte" msgid "Failed to change softdevice state" msgstr "Gagal untuk merubah status softdevice, error: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to connect:" msgstr "Gagal untuk menyambungkan, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to continue scanning" msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX" @@ -606,12 +609,12 @@ msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX" msgid "Failed to continue scanning, err 0x%04x" msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to create mutex" msgstr "Gagal untuk membuat mutex, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" msgstr "Gagal untuk menemukan layanan, status: 0x%08lX" @@ -651,7 +654,7 @@ msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Gagal untuk menambahkan Vendor Spesific UUID, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to release mutex" msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" @@ -661,18 +664,22 @@ msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" msgid "Failed to release mutex, err 0x%04x" msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start advertising" msgstr "Gagal untuk memulai advertisement, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Gagal untuk memulai advertisement, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start scanning" msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" @@ -682,12 +689,11 @@ msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" msgid "Failed to start scanning, err 0x%04x" msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to stop advertising" msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1221,7 +1227,7 @@ msgid "USB Error" msgstr "" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1366,8 +1372,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "argumen num/types tidak cocok" @@ -1920,8 +1926,9 @@ msgstr "" msgid "integer required" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2616,6 +2623,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d32502e181..bbf77887ae 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: 2019-06-12 00:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -219,12 +219,11 @@ msgstr "" #: shared-bindings/bleio/Address.c #, c-format -msgid "Address is not %d bytes long or is in wrong format" +msgid "Address must be %d bytes long" msgstr "" #: shared-bindings/bleio/Address.c -#, c-format -msgid "Address must be %d bytes long" +msgid "Address type out of range" msgstr "" #: ports/nrf/common-hal/busio/I2C.c @@ -349,19 +348,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "" @@ -484,12 +483,11 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "" @@ -539,7 +537,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to acquire mutex" msgstr "" @@ -553,7 +551,7 @@ msgstr "" msgid "Failed to add characteristic, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to add service" msgstr "" @@ -576,11 +574,16 @@ msgstr "" msgid "Failed to change softdevice state" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "" @@ -589,11 +592,11 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to create mutex" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "" @@ -630,7 +633,7 @@ msgstr "" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to release mutex" msgstr "" @@ -639,17 +642,21 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start advertising" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start scanning" msgstr "" @@ -658,11 +665,10 @@ msgstr "" msgid "Failed to start scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to stop advertising" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1188,7 +1194,7 @@ msgid "USB Error" msgstr "" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1323,8 +1329,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "" @@ -1876,8 +1882,9 @@ msgstr "" msgid "integer required" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2569,6 +2576,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 2bdaaf7126..8b559edab7 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: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -219,16 +219,15 @@ msgstr "3-arg pow() wird nicht unterstützt" msgid "A hardware interrupt channel is already in use" msgstr "Ein Hardware Interrupt Kanal wird schon benutzt" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "Die Adresse ist nicht %d Bytes lang oder das Format ist falsch" - #: shared-bindings/bleio/Address.c #, c-format msgid "Address must be %d bytes long" msgstr "Die Adresse muss %d Bytes lang sein" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Alle I2C-Peripheriegeräte sind in Benutzung" @@ -353,19 +352,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Kann dotstar nicht mit %s verwenden" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "Im Central mode können Dienste nicht hinzugefügt werden" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "Im Central mode kann advertise nicht gemacht werden" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "Im Central mode kann name nicht geändert werden" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "Im Peripheral mode kann keine Verbindung hergestellt werden" @@ -488,12 +487,11 @@ msgstr "Data 0 pin muss am Byte ausgerichtet sein" msgid "Data chunk must follow fmt chunk" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "Zu vielen Daten für das advertisement packet" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "Daten sind zu groß für das advertisement packet" @@ -543,7 +541,7 @@ msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to acquire mutex" msgstr "Akquirieren des Mutex gescheitert" @@ -557,7 +555,7 @@ msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Hinzufügen des Characteristic ist gescheitert. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to add service" msgstr "Dienst konnte nicht hinzugefügt werden" @@ -580,11 +578,16 @@ msgstr "Konnte keine RX Buffer mit %d allozieren" msgid "Failed to change softdevice state" msgstr "Fehler beim Ändern des Softdevice-Status" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "Verbindung fehlgeschlagen:" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "Der Scanvorgang kann nicht fortgesetzt werden" @@ -593,11 +596,11 @@ msgstr "Der Scanvorgang kann nicht fortgesetzt werden" msgid "Failed to continue scanning, err 0x%04x" msgstr "Der Scanvorgang kann nicht fortgesetzt werden. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to create mutex" msgstr "Erstellen des Mutex ist fehlgeschlagen" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "Es konnten keine Dienste gefunden werden" @@ -634,7 +637,7 @@ msgstr "gatts value konnte nicht gelesen werden. Status: 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Kann keine herstellerspezifische UUID hinzufügen. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to release mutex" msgstr "Loslassen des Mutex gescheitert" @@ -643,17 +646,21 @@ msgstr "Loslassen des Mutex gescheitert" msgid "Failed to release mutex, err 0x%04x" msgstr "Mutex konnte nicht freigegeben werden. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start advertising" msgstr "Kann advertisement nicht starten" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Kann advertisement nicht starten. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start scanning" msgstr "Der Scanvorgang kann nicht gestartet werden" @@ -662,11 +669,10 @@ msgstr "Der Scanvorgang kann nicht gestartet werden" msgid "Failed to start scanning, err 0x%04x" msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to stop advertising" msgstr "Kann advertisement nicht stoppen" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1217,8 +1223,8 @@ msgid "USB Error" msgstr "USB Fehler" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" -msgstr "UUID-Integer nicht im Bereich 0 bis 0xffff" +msgid "UUID integer value must be 0-0xffff" +msgstr "" #: shared-bindings/bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -1363,8 +1369,8 @@ msgstr "arg ist eine leere Sequenz" msgid "argument has wrong type" msgstr "Argument hat falschen Typ" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "Anzahl/Type der Argumente passen nicht" @@ -1917,9 +1923,10 @@ msgstr "int() arg 2 muss >= 2 und <= 36 sein" msgid "integer required" msgstr "integer erforderlich" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" -msgstr "Das Interval ist nicht im Bereich 0.0020 bis 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" @@ -2625,6 +2632,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "write_args muss eine Liste, ein Tupel oder None sein" @@ -2656,6 +2667,9 @@ msgstr "" #~ msgid "AP required" #~ msgstr "AP erforderlich" +#~ msgid "Address is not %d bytes long or is in wrong format" +#~ msgstr "Die Adresse ist nicht %d Bytes lang oder das Format ist falsch" + #~ msgid "C-level assert" #~ msgstr "C-Level Assert" @@ -2761,6 +2775,9 @@ msgstr "" #~ msgid "UART(1) can't read" #~ msgstr "UART(1) kann nicht lesen" +#~ msgid "UUID integer value not in range 0 to 0xffff" +#~ msgstr "UUID-Integer nicht im Bereich 0 bis 0xffff" + #~ msgid "Unable to remount filesystem" #~ msgstr "Dateisystem konnte nicht wieder eingebunden werden." @@ -2792,6 +2809,9 @@ msgstr "" #~ msgid "impossible baudrate" #~ msgstr "Unmögliche Baudrate" +#~ msgid "interval not in range 0.0020 to 10.24" +#~ msgstr "Das Interval ist nicht im Bereich 0.0020 bis 10.24" + #~ msgid "invalid alarm" #~ msgstr "ungültiger Alarm" diff --git a/locale/en_US.po b/locale/en_US.po index 152ece4327..616e89630a 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: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -219,12 +219,11 @@ msgstr "" #: shared-bindings/bleio/Address.c #, c-format -msgid "Address is not %d bytes long or is in wrong format" +msgid "Address must be %d bytes long" msgstr "" #: shared-bindings/bleio/Address.c -#, c-format -msgid "Address must be %d bytes long" +msgid "Address type out of range" msgstr "" #: ports/nrf/common-hal/busio/I2C.c @@ -349,19 +348,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "" @@ -484,12 +483,11 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "" @@ -539,7 +537,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to acquire mutex" msgstr "" @@ -553,7 +551,7 @@ msgstr "" msgid "Failed to add characteristic, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to add service" msgstr "" @@ -576,11 +574,16 @@ msgstr "" msgid "Failed to change softdevice state" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "" @@ -589,11 +592,11 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to create mutex" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "" @@ -630,7 +633,7 @@ msgstr "" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to release mutex" msgstr "" @@ -639,17 +642,21 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start advertising" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start scanning" msgstr "" @@ -658,11 +665,10 @@ msgstr "" msgid "Failed to start scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to stop advertising" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1188,7 +1194,7 @@ msgid "USB Error" msgstr "" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1323,8 +1329,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "" @@ -1876,8 +1882,9 @@ msgstr "" msgid "integer required" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2569,6 +2576,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index d91dc95cad..44db050456 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -221,12 +221,11 @@ msgstr "Avast! A hardware interrupt channel be used already" #: shared-bindings/bleio/Address.c #, c-format -msgid "Address is not %d bytes long or is in wrong format" +msgid "Address must be %d bytes long" msgstr "" #: shared-bindings/bleio/Address.c -#, c-format -msgid "Address must be %d bytes long" +msgid "Address type out of range" msgstr "" #: ports/nrf/common-hal/busio/I2C.c @@ -353,19 +352,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "" @@ -488,12 +487,11 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "" @@ -543,7 +541,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to acquire mutex" msgstr "" @@ -557,7 +555,7 @@ msgstr "" msgid "Failed to add characteristic, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to add service" msgstr "" @@ -580,11 +578,16 @@ msgstr "" msgid "Failed to change softdevice state" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "" @@ -593,11 +596,11 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to create mutex" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "" @@ -634,7 +637,7 @@ msgstr "" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to release mutex" msgstr "" @@ -643,17 +646,21 @@ msgstr "" msgid "Failed to release mutex, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start advertising" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start scanning" msgstr "" @@ -662,11 +669,10 @@ msgstr "" msgid "Failed to start scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to stop advertising" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1192,7 +1198,7 @@ msgid "USB Error" msgstr "" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1327,8 +1333,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "" @@ -1880,8 +1886,9 @@ msgstr "" msgid "integer required" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2573,6 +2580,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/es.po b/locale/es.po index d954d574c3..194dea86ba 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -223,16 +223,15 @@ msgstr "pow() con 3 argumentos no soportado" msgid "A hardware interrupt channel is already in use" msgstr "El canal EXTINT ya está siendo utilizado" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" - #: shared-bindings/bleio/Address.c #, fuzzy, c-format msgid "Address must be %d bytes long" msgstr "Direción debe ser %d bytes de largo" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Todos los periféricos I2C están siendo usados" @@ -363,19 +362,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "No se puede usar dotstar con %s" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "No se pueden agregar servicio en modo Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "No se puede anunciar en modo Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "No se puede cambiar el nombre en modo Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "No se puede conectar en modo Peripheral" @@ -500,13 +499,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "El Data Chunk debe seguir el fmt chunk" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy msgid "Data too large for advertisement packet" msgstr "Los datos no caben en el paquete de anuncio." -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Data too large for the advertisement packet" msgstr "Los datos no caben en el paquete de anuncio." @@ -559,7 +557,7 @@ msgstr "Se esperaba un tuple de %d, se obtuvo %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to acquire mutex" msgstr "No se puede adquirir el mutex, status: 0x%08lX" @@ -574,7 +572,7 @@ msgstr "No se puede adquirir el mutex, status: 0x%08lX" msgid "Failed to add characteristic, err 0x%04x" msgstr "No se puede añadir caracteristica, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to add service" msgstr "No se puede detener el anuncio. status: 0x%02x" @@ -599,12 +597,17 @@ msgstr "Falló la asignación del buffer RX de %d bytes" msgid "Failed to change softdevice state" msgstr "No se puede cambiar el estado del softdevice, error: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to connect:" msgstr "No se puede conectar. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to continue scanning" msgstr "No se puede iniciar el escaneo. status: 0x%02x" @@ -614,12 +617,12 @@ msgstr "No se puede iniciar el escaneo. status: 0x%02x" msgid "Failed to continue scanning, err 0x%04x" msgstr "No se puede iniciar el escaneo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to create mutex" msgstr "No se puede leer el valor del atributo. status 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" msgstr "No se puede descubrir servicios, status: 0x%08lX" @@ -659,7 +662,7 @@ msgstr "No se puede escribir el valor del atributo. status: 0x%02x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "No se puede agregar el Vendor Specific 128-bit UUID." -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to release mutex" msgstr "No se puede liberar el mutex, status: 0x%08lX" @@ -669,18 +672,22 @@ msgstr "No se puede liberar el mutex, status: 0x%08lX" msgid "Failed to release mutex, err 0x%04x" msgstr "No se puede liberar el mutex, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start advertising" msgstr "No se puede inicar el anuncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "No se puede inicar el anuncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start scanning" msgstr "No se puede iniciar el escaneo. status: 0x%02x" @@ -690,12 +697,11 @@ msgstr "No se puede iniciar el escaneo. status: 0x%02x" msgid "Failed to start scanning, err 0x%04x" msgstr "No se puede iniciar el escaneo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to stop advertising" msgstr "No se puede detener el anuncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1244,8 +1250,8 @@ msgid "USB Error" msgstr "Error USB" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" -msgstr "El valor integer UUID no está en el rango 0 a 0xffff" +msgid "UUID integer value must be 0-0xffff" +msgstr "" #: shared-bindings/bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -1389,8 +1395,8 @@ msgstr "argumento es una secuencia vacía" msgid "argument has wrong type" msgstr "el argumento tiene un tipo erroneo" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "argumento número/tipos no coinciden" @@ -1951,9 +1957,10 @@ msgstr "int() arg 2 debe ser >= 2 y <= 36" msgid "integer required" msgstr "Entero requerido" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" -msgstr "El intervalo está fuera del rango de 0.0020 a 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" @@ -2658,6 +2665,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "value_count debe ser > 0" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "write_args debe ser lista, tuple, o None" @@ -2691,6 +2702,9 @@ msgstr "paso cero" #~ msgid "AP required" #~ msgstr "AP requerido" +#~ msgid "Address is not %d bytes long or is in wrong format" +#~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" + #~ msgid "Cannot connect to AP" #~ msgstr "No se puede conectar a AP" @@ -2803,6 +2817,9 @@ msgstr "paso cero" #~ msgid "UART(1) can't read" #~ msgstr "UART(1) no puede leer" +#~ msgid "UUID integer value not in range 0 to 0xffff" +#~ msgstr "El valor integer UUID no está en el rango 0 a 0xffff" + #~ msgid "Unable to remount filesystem" #~ msgstr "Incapaz de montar de nuevo el sistema de archivos" @@ -2852,6 +2869,9 @@ msgstr "paso cero" #~ msgid "impossible baudrate" #~ msgstr "baudrate imposible" +#~ msgid "interval not in range 0.0020 to 10.24" +#~ msgstr "El intervalo está fuera del rango de 0.0020 a 10.24" + #~ msgid "invalid alarm" #~ msgstr "alarma inválida" diff --git a/locale/fil.po b/locale/fil.po index b6ad3643c8..9c688ec14b 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: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -220,16 +220,15 @@ msgstr "3-arg pow() hindi suportado" msgid "A hardware interrupt channel is already in use" msgstr "Isang channel ng hardware interrupt ay ginagamit na" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "" - #: shared-bindings/bleio/Address.c #, fuzzy, c-format msgid "Address must be %d bytes long" msgstr "ang palette ay dapat 32 bytes ang haba" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Lahat ng I2C peripherals ginagamit" @@ -356,19 +355,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "Hindi maarang maglagay ng service sa Central mode" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "Hindi ma advertise habang nasa Central mode" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "Hindi mapalitan ang pangalan sa Central mode" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "Hindi maconnect sa Peripheral mode" @@ -494,13 +493,12 @@ msgstr "graphic ay dapat 2048 bytes ang haba" msgid "Data chunk must follow fmt chunk" msgstr "Dapat sunurin ng Data chunk ang fmt chunk" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy msgid "Data too large for advertisement packet" msgstr "Hindi makasya ang data sa loob ng advertisement packet" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Data too large for the advertisement packet" msgstr "Hindi makasya ang data sa loob ng advertisement packet" @@ -554,7 +552,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to acquire mutex" msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" @@ -569,7 +567,7 @@ msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" msgid "Failed to add characteristic, err 0x%04x" msgstr "Nabigo sa paglagay ng characteristic, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to add service" msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX" @@ -594,12 +592,17 @@ msgstr "Nabigong ilaan ang RX buffer ng %d bytes" msgid "Failed to change softdevice state" msgstr "Nabigo sa pagbago ng softdevice state, error: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to connect:" msgstr "Hindi makaconnect, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to continue scanning" msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX" @@ -609,12 +612,12 @@ msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX" msgid "Failed to continue scanning, err 0x%04x" msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to create mutex" msgstr "Hindi matagumpay ang pagbuo ng mutex, status: 0x%0xlX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" msgstr "Nabigo sa pagdiscover ng services, status: 0x%08lX" @@ -654,7 +657,7 @@ msgstr "Hindi maisulat ang gatts value, status: 0x%08lX" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Hindi matagumpay ang paglagay ng Vender Specific UUID, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to release mutex" msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" @@ -664,18 +667,22 @@ msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" msgid "Failed to release mutex, err 0x%04x" msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start advertising" msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start scanning" msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" @@ -685,12 +692,11 @@ msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" msgid "Failed to start scanning, err 0x%04x" msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to stop advertising" msgstr "Hindi mahinto ang advertisement, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1241,7 +1247,7 @@ msgid "USB Error" msgstr "May pagkakamali ang USB" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1386,8 +1392,8 @@ msgstr "arg ay walang laman na sequence" msgid "argument has wrong type" msgstr "may maling type ang argument" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "hindi tugma ang argument num/types" @@ -1952,8 +1958,9 @@ msgstr "int() arg 2 ay dapat >=2 at <= 36" msgid "integer required" msgstr "kailangan ng int" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2657,6 +2664,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 6fd6e90157..60122a5d0b 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -221,16 +221,15 @@ msgstr "pow() non supporté avec 3 arguments" msgid "A hardware interrupt channel is already in use" msgstr "Un canal d'interruptions matérielles est déjà utilisé" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" - #: shared-bindings/bleio/Address.c #, fuzzy, c-format msgid "Address must be %d bytes long" msgstr "L'adresse doit être longue de %d octets" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c #, fuzzy msgid "All I2C peripherals are in use" @@ -361,19 +360,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Impossible d'utiliser 'dotstar' avec %s" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "Impossible d'ajouter des services en mode Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "Impossible de publier en mode Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "Modification du nom impossible en mode Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "Impossible de se connecter en mode 'Peripheral'" @@ -500,12 +499,11 @@ msgstr "La broche 'Data 0' doit être aligné sur l'octet" msgid "Data chunk must follow fmt chunk" msgstr "Un bloc de données doit suivre un bloc de format" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "Données trop volumineuses pour un paquet de diffusion" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "Données trop volumineuses pour le paquet de diffusion" @@ -557,7 +555,7 @@ msgstr "Tuple de longueur %d attendu, obtenu %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to acquire mutex" msgstr "Echec de l'obtention de mutex" @@ -572,7 +570,7 @@ msgstr "Echec de l'obtention de mutex, err 0x%04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Echec de l'ajout de caractéristique, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to add service" msgstr "Echec de l'ajout de service" @@ -597,12 +595,17 @@ msgstr "Echec de l'allocation de %d octets du tampon RX" msgid "Failed to change softdevice state" msgstr "Echec de la modification de l'état du périphérique" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to connect:" msgstr "Echec de connection:" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to continue scanning" msgstr "Impossible de poursuivre le scan" @@ -612,12 +615,12 @@ msgstr "Impossible de poursuivre le scan" msgid "Failed to continue scanning, err 0x%04x" msgstr "Impossible de poursuivre le scan, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to create mutex" msgstr "Echec de la création de mutex" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" msgstr "Echec de la découverte de services" @@ -658,7 +661,7 @@ msgstr "Impossible de lire la valeur de 'gatts', err 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Echec de l'ajout de l'UUID du fournisseur, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to release mutex" msgstr "Impossible de libérer mutex" @@ -668,18 +671,22 @@ msgstr "Impossible de libérer mutex" msgid "Failed to release mutex, err 0x%04x" msgstr "Impossible de libérer mutex, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start advertising" msgstr "Echec du démarrage de la diffusion" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Impossible de commencer à diffuser, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start scanning" msgstr "Impossible de commencer à scanner" @@ -689,12 +696,11 @@ msgstr "Impossible de commencer à scanner" msgid "Failed to start scanning, err 0x%04x" msgstr "Impossible de commencer à scanner, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to stop advertising" msgstr "Echec de l'arrêt de diffusion" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1261,8 +1267,8 @@ msgid "USB Error" msgstr "Erreur USB" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" -msgstr "valeur de l'entier UUID est hors-bornes 0 à 0xffff" +msgid "UUID integer value must be 0-0xffff" +msgstr "" #: shared-bindings/bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -1410,8 +1416,8 @@ msgstr "l'argument est une séquence vide" msgid "argument has wrong type" msgstr "l'argument est d'un mauvais type" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "argument num/types ne correspond pas" @@ -1984,9 +1990,10 @@ msgstr "l'argument 2 de int() doit être >=2 et <=36" msgid "integer required" msgstr "entier requis" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" -msgstr "intervalle hors bornes 0.0020 à 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" @@ -2699,6 +2706,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "'value_count' doit être > 0" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "'write_args' doit être une liste, un tuple ou 'None'" @@ -2733,6 +2744,9 @@ msgstr "'step' nul" #~ msgid "AP required" #~ msgstr "'AP' requis" +#~ msgid "Address is not %d bytes long or is in wrong format" +#~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" + #~ msgid "Cannot connect to AP" #~ msgstr "Impossible de se connecter à 'AP'" @@ -2835,6 +2849,9 @@ msgstr "'step' nul" #~ msgid "UART(1) can't read" #~ msgstr "UART(1) ne peut pas lire" +#~ msgid "UUID integer value not in range 0 to 0xffff" +#~ msgstr "valeur de l'entier UUID est hors-bornes 0 à 0xffff" + #~ msgid "Unable to remount filesystem" #~ msgstr "Impossible de remonter le système de fichiers" @@ -2881,6 +2898,9 @@ msgstr "'step' nul" #~ msgid "impossible baudrate" #~ msgstr "débit impossible" +#~ msgid "interval not in range 0.0020 to 10.24" +#~ msgstr "intervalle hors bornes 0.0020 à 10.24" + #~ msgid "invalid alarm" #~ msgstr "alarme invalide" diff --git a/locale/it_IT.po b/locale/it_IT.po index d89d4ae07b..6f0e90e176 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: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -219,16 +219,15 @@ msgstr "pow() con tre argmomenti non supportata" msgid "A hardware interrupt channel is already in use" msgstr "Un canale di interrupt hardware è già in uso" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "" - #: shared-bindings/bleio/Address.c #, fuzzy, c-format msgid "Address must be %d bytes long" msgstr "la palette deve essere lunga 32 byte" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Tutte le periferiche I2C sono in uso" @@ -356,19 +355,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "dotstar non può essere usato con %s" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "non si può aggiungere servizi in Central mode" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "non si può pubblicizzare in Central mode" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "non si può cambiare il nome in Central mode" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "non si può connettere in Periferal mode" @@ -495,13 +494,12 @@ msgstr "graphic deve essere lunga 2048 byte" msgid "Data chunk must follow fmt chunk" msgstr "" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy msgid "Data too large for advertisement packet" msgstr "Impossibile inserire dati nel pacchetto di advertisement." -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Data too large for the advertisement packet" msgstr "Impossibile inserire dati nel pacchetto di advertisement." @@ -554,7 +552,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to acquire mutex" msgstr "Impossibile allocare buffer RX" @@ -569,7 +567,7 @@ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Impossibile fermare advertisement. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to add service" msgstr "Impossibile fermare advertisement. status: 0x%02x" @@ -594,12 +592,17 @@ msgstr "Fallita allocazione del buffer RX di %d byte" msgid "Failed to change softdevice state" msgstr "Impossibile fermare advertisement. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to connect:" msgstr "Impossibile connettersi. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to continue scanning" msgstr "Impossible iniziare la scansione. status: 0x%02x" @@ -609,12 +612,12 @@ msgstr "Impossible iniziare la scansione. status: 0x%02x" msgid "Failed to continue scanning, err 0x%04x" msgstr "Impossible iniziare la scansione. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to create mutex" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" msgstr "Impossibile fermare advertisement. status: 0x%02x" @@ -653,7 +656,7 @@ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to release mutex" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" @@ -663,18 +666,22 @@ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" msgid "Failed to release mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start advertising" msgstr "Impossibile avviare advertisement. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Impossibile avviare advertisement. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start scanning" msgstr "Impossible iniziare la scansione. status: 0x%02x" @@ -684,12 +691,11 @@ msgstr "Impossible iniziare la scansione. status: 0x%02x" msgid "Failed to start scanning, err 0x%04x" msgstr "Impossible iniziare la scansione. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to stop advertising" msgstr "Impossibile fermare advertisement. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1240,7 +1246,7 @@ msgid "USB Error" msgstr "Errore USB" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1380,8 +1386,8 @@ msgstr "l'argomento è una sequenza vuota" msgid "argument has wrong type" msgstr "il tipo dell'argomento è errato" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "discrepanza di numero/tipo di argomenti" @@ -1944,8 +1950,9 @@ msgstr "il secondo argomanto di int() deve essere >= 2 e <= 36" msgid "integer required" msgstr "intero richiesto" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2655,6 +2662,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index e7dc248be9..a7155e0c8d 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -218,16 +218,15 @@ msgstr "3-argumentowy pow() jest niewspierany" msgid "A hardware interrupt channel is already in use" msgstr "Kanał przerwań sprzętowych w użyciu" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "Adres nie ma długości %d bajtów lub zły format" - #: shared-bindings/bleio/Address.c #, c-format msgid "Address must be %d bytes long" msgstr "Adres musi mieć %d bajtów" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Wszystkie peryferia I2C w użyciu" @@ -352,19 +351,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Nie można używać dotstar z %s" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "Nie można dodać serwisów w trybie Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "Nie można rozgłaszać w trybie Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "Nie można zmienić nazwy w trybie Central" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "Nie można się łączyć w trybie Peripheral" @@ -487,12 +486,11 @@ msgstr "Nóżka data 0 musi być wyrównana do bajtu" msgid "Data chunk must follow fmt chunk" msgstr "Fragment danych musi następować po fragmencie fmt" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" @@ -542,7 +540,7 @@ msgstr "Oczekiwano krotkę długości %d, otrzymano %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to acquire mutex" msgstr "Nie udało się uzyskać blokady" @@ -556,7 +554,7 @@ msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Nie udało się dodać charakterystyki, błąd 0x$04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to add service" msgstr "Nie udało się dodać serwisu" @@ -579,11 +577,16 @@ msgstr "Nie udała się alokacja %d bajtów na bufor RX" msgid "Failed to change softdevice state" msgstr "Nie udało się zmienić stanu softdevice" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "Nie udało się połączenie:" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "Nie udała się kontynuacja skanowania" @@ -592,11 +595,11 @@ msgstr "Nie udała się kontynuacja skanowania" msgid "Failed to continue scanning, err 0x%04x" msgstr "Nie udała się kontynuacja skanowania, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to create mutex" msgstr "Nie udało się stworzyć blokady" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "Nie udało się odkryć serwisów" @@ -633,7 +636,7 @@ msgstr "Nie udało się odczytać gatts, błąd 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Nie udało się zarejestrować UUID dostawcy, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to release mutex" msgstr "Nie udało się zwolnić blokady" @@ -642,17 +645,21 @@ msgstr "Nie udało się zwolnić blokady" msgid "Failed to release mutex, err 0x%04x" msgstr "Nie udało się zwolnić blokady, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start advertising" msgstr "Nie udało się rozpocząć rozgłaszania" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Nie udało się rozpocząć rozgłaszania, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start scanning" msgstr "Nie udało się rozpocząć skanowania" @@ -661,11 +668,10 @@ msgstr "Nie udało się rozpocząć skanowania" msgid "Failed to start scanning, err 0x%04x" msgstr "Nie udało się rozpocząć skanowania, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to stop advertising" msgstr "Nie udało się zatrzymać rozgłaszania" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1208,8 +1214,8 @@ msgid "USB Error" msgstr "Błąd USB" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" -msgstr "Wartość UUID poza zakresem 0 do 0xffff" +msgid "UUID integer value must be 0-0xffff" +msgstr "" #: shared-bindings/bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -1347,8 +1353,8 @@ msgstr "arg jest puste" msgid "argument has wrong type" msgstr "argument ma zły typ" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "zła liczba lub typ argumentów" @@ -1901,9 +1907,10 @@ msgstr "argument 2 do int() busi być pomiędzy 2 a 36" msgid "integer required" msgstr "wymagana liczba całkowita" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" -msgstr "przedział poza zakresem 0.0020 do 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" @@ -2596,6 +2603,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "value_count musi być > 0" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "write_args musi być listą, krotką lub None" @@ -2624,6 +2635,9 @@ msgstr "y poza zakresem" msgid "zero step" msgstr "zerowy krok" +#~ msgid "Address is not %d bytes long or is in wrong format" +#~ msgstr "Adres nie ma długości %d bajtów lub zły format" + #~ msgid "Invalid bit clock pin" #~ msgstr "Zła nóżka zegara" @@ -2635,3 +2649,9 @@ msgstr "zerowy krok" #~ msgid "Must be a Group subclass." #~ msgstr "Musi dziedziczyć z Group." + +#~ msgid "UUID integer value not in range 0 to 0xffff" +#~ msgstr "Wartość UUID poza zakresem 0 do 0xffff" + +#~ msgid "interval not in range 0.0020 to 10.24" +#~ msgstr "przedział poza zakresem 0.0020 do 10.24" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index f086191870..01eda181f5 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: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -219,16 +219,15 @@ msgstr "" msgid "A hardware interrupt channel is already in use" msgstr "Um canal de interrupção de hardware já está em uso" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "" - #: shared-bindings/bleio/Address.c #, fuzzy, c-format msgid "Address must be %d bytes long" msgstr "buffers devem ser o mesmo tamanho" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Todos os periféricos I2C estão em uso" @@ -353,19 +352,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "" @@ -490,13 +489,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "Pedaço de dados deve seguir o pedaço de cortes" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy msgid "Data too large for advertisement packet" msgstr "Não é possível ajustar dados no pacote de anúncios." -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Data too large for the advertisement packet" msgstr "Não é possível ajustar dados no pacote de anúncios." @@ -549,7 +547,7 @@ msgstr "" msgid "Failed sending command." msgstr "Falha ao enviar comando." -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to acquire mutex" msgstr "Falha ao alocar buffer RX" @@ -564,7 +562,7 @@ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Não pode parar propaganda. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to add service" msgstr "Não pode parar propaganda. status: 0x%02x" @@ -589,11 +587,16 @@ msgstr "Falha ao alocar buffer RX de %d bytes" msgid "Failed to change softdevice state" msgstr "Não pode parar propaganda. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "" @@ -602,12 +605,12 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to create mutex" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" msgstr "Não pode parar propaganda. status: 0x%02x" @@ -646,7 +649,7 @@ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Não é possível adicionar o UUID de 128 bits específico do fornecedor." -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to release mutex" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" @@ -656,18 +659,22 @@ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" msgid "Failed to release mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start advertising" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to start scanning" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" @@ -677,12 +684,11 @@ msgstr "Não é possível iniciar o anúncio. status: 0x%02x" msgid "Failed to start scanning, err 0x%04x" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to stop advertising" msgstr "Não pode parar propaganda. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1216,7 +1222,7 @@ msgid "USB Error" msgstr "Erro na USB" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" +msgid "UUID integer value must be 0-0xffff" msgstr "" #: shared-bindings/bleio/UUID.c @@ -1352,8 +1358,8 @@ msgstr "" msgid "argument has wrong type" msgstr "argumento tem tipo errado" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "" @@ -1909,8 +1915,9 @@ msgstr "" msgid "integer required" msgstr "inteiro requerido" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" msgstr "" #: extmod/machine_i2c.c @@ -2606,6 +2613,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index dd61f13628..79d803d674 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-11 14:59-0700\n" +"POT-Creation-Date: 2019-06-19 09:49-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -219,16 +219,15 @@ msgstr "bù zhīchí 3-arg pow ()" msgid "A hardware interrupt channel is already in use" msgstr "Yìngjiàn zhōngduàn tōngdào yǐ zài shǐyòng zhōng" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" - #: shared-bindings/bleio/Address.c #, c-format msgid "Address must be %d bytes long" msgstr "Dìzhǐ bìxū shì %d zì jié zhǎng" +#: shared-bindings/bleio/Address.c +msgid "Address type out of range" +msgstr "" + #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Suǒyǒu I2C wàiwéi qì zhèngzài shǐyòng" @@ -353,19 +352,19 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't add services in Central mode" msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't advertise in Central mode" msgstr "Wúfǎ zài zhōngyāng móshì zhōng guǎnggào" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't change the name in Central mode" msgstr "Wúfǎ gēnggǎi zhōngyāng móshì de míngchēng" -#: shared-bindings/bleio/Device.c +#: shared-bindings/bleio/Central.c msgid "Can't connect in Peripheral mode" msgstr "Wúfǎ zài biānyuán móshì zhōng liánjiē" @@ -488,12 +487,11 @@ msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí" msgid "Data chunk must follow fmt chunk" msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c msgid "Data too large for advertisement packet" msgstr "Guǎnggào bāo de shùjù tài dà" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Data too large for the advertisement packet" msgstr "Guǎnggào bāo de shùjù tài dà" @@ -543,7 +541,7 @@ msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to acquire mutex" msgstr "Wúfǎ huòdé mutex" @@ -557,7 +555,7 @@ msgstr "Wúfǎ huòdé mutex, err 0x%04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Tiānjiā tèxìng shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to add service" msgstr "Tiānjiā fúwù shībài" @@ -580,11 +578,16 @@ msgstr "Fēnpèi RX huǎnchōng qū%d zì jié shībài" msgid "Failed to change softdevice state" msgstr "Gēnggǎi ruǎn shèbèi zhuàngtài shībài" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to configure advertising, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to connect:" msgstr "Liánjiē shībài:" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to continue scanning" msgstr "Jìxù sǎomiáo shībài" @@ -593,11 +596,11 @@ msgstr "Jìxù sǎomiáo shībài" msgid "Failed to continue scanning, err 0x%04x" msgstr "Jìxù sǎomiáo shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to create mutex" msgstr "Wúfǎ chuàngjiàn hù chì suǒ" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "Fāxiàn fúwù shībài" @@ -634,7 +637,7 @@ msgstr "Wúfǎ dòu qǔ gatts zhí, err 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Wúfǎ zhùcè màizhǔ tèdìng de UUID, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to release mutex" msgstr "Wúfǎ shìfàng mutex" @@ -643,17 +646,21 @@ msgstr "Wúfǎ shìfàng mutex" msgid "Failed to release mutex, err 0x%04x" msgstr "Wúfǎ shìfàng mutex, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Peripheral.c +#, c-format +msgid "Failed to set device name, err 0x%04x" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start advertising" msgstr "Qǐdòng guǎnggào shībài" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Qǐdòng guǎnggào shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to start scanning" msgstr "Qǐdòng sǎomiáo shībài" @@ -662,11 +669,10 @@ msgstr "Qǐdòng sǎomiáo shībài" msgid "Failed to start scanning, err 0x%04x" msgstr "Qǐdòng sǎomiáo shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Device.c +#: ports/nrf/common-hal/bleio/Central.c msgid "Failed to stop advertising" msgstr "Wúfǎ tíngzhǐ guǎnggào" -#: ports/nrf/common-hal/bleio/Broadcaster.c #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" @@ -1213,8 +1219,8 @@ msgid "USB Error" msgstr "USB Cuòwù" #: shared-bindings/bleio/UUID.c -msgid "UUID integer value not in range 0 to 0xffff" -msgstr "UUID zhěngshù zhí bùzài fànwéi 0 zhì 0xffff" +msgid "UUID integer value must be 0-0xffff" +msgstr "" #: shared-bindings/bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -1355,8 +1361,8 @@ msgstr "cānshù shì yīgè kōng de xùliè" msgid "argument has wrong type" msgstr "cānshù lèixíng cuòwù" -#: py/argcheck.c shared-bindings/_stage/__init__.c -#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c +#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c +#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c msgid "argument num/types mismatch" msgstr "cānshù biānhào/lèixíng bù pǐpèi" @@ -1911,9 +1917,10 @@ msgstr "zhěngshù() cānshù 2 bìxū > = 2 qiě <= 36" msgid "integer required" msgstr "xūyào zhěngshù" -#: ports/nrf/common-hal/bleio/Broadcaster.c -msgid "interval not in range 0.0020 to 10.24" -msgstr "jùlí 0.0020 Zhì 10.24 Zhī jiān de jiàngé shíjiān" +#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" #: extmod/machine_i2c.c msgid "invalid I2C peripheral" @@ -2608,6 +2615,10 @@ msgstr "" msgid "value_count must be > 0" msgstr "zhí jìshù bìxū wèi > 0" +#: shared-bindings/bleio/Scanner.c +msgid "window must be <= interval" +msgstr "" + #: shared-bindings/_pixelbuf/PixelBuf.c msgid "write_args must be a list, tuple, or None" msgstr "xiě cānshù bìxū shì yuán zǔ, lièbiǎo huò None" @@ -2636,6 +2647,9 @@ msgstr "y zhí chāochū biānjiè" msgid "zero step" msgstr "líng bù" +#~ msgid "Address is not %d bytes long or is in wrong format" +#~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" + #~ msgid "Invalid bit clock pin" #~ msgstr "Wúxiào de wèi shízhōng yǐn jiǎo" @@ -2660,9 +2674,15 @@ msgstr "líng bù" #~ msgid "Only bit maps of 8 bit color or less are supported" #~ msgstr "Jǐn zhīchí 8 wèi yánsè huò xiǎoyú" +#~ msgid "UUID integer value not in range 0 to 0xffff" +#~ msgstr "UUID zhěngshù zhí bùzài fànwéi 0 zhì 0xffff" + #~ msgid "expected a DigitalInOut" #~ msgstr "qídài de DigitalInOut" +#~ msgid "interval not in range 0.0020 to 10.24" +#~ msgstr "jùlí 0.0020 Zhì 10.24 Zhī jiān de jiàngé shíjiān" + #~ msgid "row must be packed and word aligned" #~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí" diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index b7ff2fcbaa..18990485b4 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -159,7 +159,6 @@ SRC_C += \ boards/$(BOARD)/pins.c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).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/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index f6e575a8c2..6b17e7af29 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/bluetooth/ble_drv.h b/ports/nrf/bluetooth/ble_drv.h index 133d77b48d..d349fa4e07 100644 --- a/ports/nrf/bluetooth/ble_drv.h +++ b/ports/nrf/bluetooth/ble_drv.h @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/bluetooth/ble_uart.c b/ports/nrf/bluetooth/ble_uart.c index 7faaafb0ef..91d10cff15 100644 --- a/ports/nrf/bluetooth/ble_uart.c +++ b/ports/nrf/bluetooth/ble_uart.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * 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 diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c index 1e572f7cb9..f20802ac98 100644 --- a/ports/nrf/common-hal/analogio/AnalogIn.c +++ b/ports/nrf/common-hal/analogio/AnalogIn.c @@ -3,8 +3,8 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries - * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 120fcf0559..9d0912930b 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2016 Glenn Ruben Bakke * Copyright (c) 2018 Artur Pacholec * diff --git a/ports/nrf/common-hal/bleio/Adapter.h b/ports/nrf/common-hal/bleio/Adapter.h index 0497f9ac9c..5dcc625406 100644 --- a/ports/nrf/common-hal/bleio/Adapter.h +++ b/ports/nrf/common-hal/bleio/Adapter.h @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/bleio/Broadcaster.h b/ports/nrf/common-hal/bleio/Broadcaster.h deleted file mode 100644 index 2d1ae69a12..0000000000 --- a/ports/nrf/common-hal/bleio/Broadcaster.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2018 Artur Pacholec - * Copyright (c) 2018 Dan Halbert for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H -#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H - -#include "ble.h" - -#include "shared-module/bleio/__init__.h" -#include "shared-module/bleio/Address.h" - -typedef struct { - mp_obj_base_t base; - // In seconds. - mp_float_t interval; - // The advertising data buffer is held by us, not by the SD, so we must - // maintain it and not change it. If we need to change its contents during advertising, - // there are tricks to get the SD to notice (see DevZone - TBS). - uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; - -} bleio_broadcaster_obj_t; - -#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 45fb1d092a..346cfefbc5 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -34,7 +35,6 @@ #include "py/runtime.h" #include "common-hal/bleio/__init__.h" #include "common-hal/bleio/Characteristic.h" -#include "shared-module/bleio/Characteristic.h" STATIC volatile bleio_characteristic_obj_t *m_read_characteristic; STATIC volatile uint8_t m_tx_in_progress; diff --git a/ports/nrf/common-hal/bleio/Characteristic.h b/ports/nrf/common-hal/bleio/Characteristic.h index 662485bad5..451bae4712 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.h +++ b/ports/nrf/common-hal/bleio/Characteristic.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,9 +28,9 @@ #ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H #define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H -#include "shared-module/bleio/Characteristic.h" #include "common-hal/bleio/Service.h" #include "common-hal/bleio/UUID.h" +#include "shared-module/bleio/Characteristic.h" typedef struct { mp_obj_base_t base; diff --git a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h index 6a44229f7a..db8fd2fade 100644 --- a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h +++ b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/bleio/Descriptor.c b/ports/nrf/common-hal/bleio/Descriptor.c index 8282be8f2d..418cc07c17 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.c +++ b/ports/nrf/common-hal/bleio/Descriptor.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/bleio/Descriptor.h b/ports/nrf/common-hal/bleio/Descriptor.h index ee0886c22f..47552f39d8 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.h +++ b/ports/nrf/common-hal/bleio/Descriptor.h @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/bleio/Device.c b/ports/nrf/common-hal/bleio/Device.c deleted file mode 100644 index b1ac72e754..0000000000 --- a/ports/nrf/common-hal/bleio/Device.c +++ /dev/null @@ -1,601 +0,0 @@ -/* - * 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 - -#include "ble.h" -#include "ble_drv.h" -#include "ble_hci.h" -#include "nrf_soc.h" -#include "py/objstr.h" -#include "py/runtime.h" -#include "shared-bindings/bleio/Adapter.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" - -#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) - -#define BLE_ADV_LENGTH_FIELD_SIZE 1 -#define BLE_ADV_AD_TYPE_FIELD_SIZE 1 -#define BLE_AD_TYPE_FLAGS_DATA_SIZE 1 - -#ifndef BLE_GAP_ADV_MAX_SIZE -#define BLE_GAP_ADV_MAX_SIZE 31 -#endif - -static bleio_service_obj_t *m_char_discovery_service; -static volatile bool m_discovery_successful; -static nrf_mutex_t *m_discovery_mutex; - -#if (BLUETOOTH_SD == 140) -static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; - -static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_MIN]; - -static ble_data_t m_scan_buffer = { - .p_data = m_scan_buffer_data, - .len = BLE_GAP_SCAN_BUFFER_MIN -}; -#endif - -STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data) { - common_hal_bleio_adapter_set_enabled(true); - - uint8_t adv_data[BLE_GAP_ADV_MAX_SIZE]; - uint8_t byte_pos = 0; - uint32_t err_code; - -#define ADD_FIELD(field, len) \ - do { \ - if (byte_pos + (len) > BLE_GAP_ADV_MAX_SIZE) { \ - mp_raise_ValueError(translate("Data too large for the advertisement packet")); \ - } \ - adv_data[byte_pos] = (field); \ - byte_pos += (len); \ - } while (0) - - GET_STR_DATA_LEN(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); - - err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len); - if (err_code != NRF_SUCCESS) { - return err_code; - } - - // TODO: Shorten if too long - - ADD_FIELD(BLE_ADV_AD_TYPE_FIELD_SIZE + name_len, BLE_ADV_LENGTH_FIELD_SIZE); - ADD_FIELD(BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, BLE_ADV_AD_TYPE_FIELD_SIZE); - - memcpy(&adv_data[byte_pos], name_data, name_len); - byte_pos += name_len; - } - - // set flags, default to disc mode - if (raw_data->len == 0) { - ADD_FIELD(BLE_ADV_AD_TYPE_FIELD_SIZE + BLE_AD_TYPE_FLAGS_DATA_SIZE, BLE_ADV_LENGTH_FIELD_SIZE); - ADD_FIELD(BLE_GAP_AD_TYPE_FLAGS, BLE_AD_TYPE_FLAGS_DATA_SIZE); - ADD_FIELD(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE, BLE_AD_TYPE_FLAGS_DATA_SIZE); - } else { - if (byte_pos + raw_data->len > BLE_GAP_ADV_MAX_SIZE) { - mp_raise_ValueError(translate("Data too large for the advertisement packet")); - } - - memcpy(&adv_data[byte_pos], raw_data->buf, raw_data->len); - byte_pos += raw_data->len; - } - - const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(device->service_list); - if (service_list->len > 0) { - bool has_128bit_services = false; - bool has_16bit_services = false; - - 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->is_secondary) { - continue; - } - - switch (common_hal_bleio_uuid_get_size(service->uuid)) { - case 16: - has_16bit_services = true; - break; - case 128: - has_128bit_services = true; - break; - } - } - - if (has_16bit_services) { - const uint8_t size_byte_pos = byte_pos; - uint8_t uuid_total_size = 0; - - // skip length byte for now, apply total length post calculation - byte_pos += BLE_ADV_LENGTH_FIELD_SIZE; - - ADD_FIELD(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE, BLE_ADV_AD_TYPE_FIELD_SIZE); - - for (size_t i = 0; i < service_list->len; ++i) { - const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); - uint8_t encoded_size = 0; - - if (common_hal_bleio_uuid_get_size(service->uuid) != 16 || service->is_secondary) { - continue; - } - - ble_uuid_t uuid; - bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); - - err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]); - if (err_code != NRF_SUCCESS) { - return err_code; - } - - uuid_total_size += encoded_size; - byte_pos += encoded_size; - } - - adv_data[size_byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + uuid_total_size); - } - - if (has_128bit_services) { - const uint8_t size_byte_pos = byte_pos; - uint8_t uuid_total_size = 0; - - // skip length byte for now, apply total length post calculation - byte_pos += BLE_ADV_LENGTH_FIELD_SIZE; - - ADD_FIELD(BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, BLE_ADV_AD_TYPE_FIELD_SIZE); - - for (size_t i = 0; i < service_list->len; ++i) { - const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]); - uint8_t encoded_size = 0; - - if (common_hal_bleio_uuid_get_size(service->uuid) != 16 || service->is_secondary) { - continue; - } - - ble_uuid_t uuid; - bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); - - err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]); - if (err_code != NRF_SUCCESS) { - return err_code; - } - - uuid_total_size += encoded_size; - byte_pos += encoded_size; - } - - adv_data[size_byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + uuid_total_size); - } - } - -#if (BLUETOOTH_SD == 132) - err_code = sd_ble_gap_adv_data_set(adv_data, byte_pos, NULL, 0); - if (err_code != NRF_SUCCESS) { - return err_code; - } -#endif - - static ble_gap_adv_params_t m_adv_params = { - .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS), -#if (BLUETOOTH_SD == 140) - .properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED, - .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED, - .filter_policy = BLE_GAP_ADV_FP_ANY, - .primary_phy = BLE_GAP_PHY_1MBPS, -#else - .type = BLE_GAP_ADV_TYPE_ADV_IND, - .fp = BLE_GAP_ADV_FP_ANY, -#endif - }; - - if (!connectable) { -#if (BLUETOOTH_SD == 140) - m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED; -#else - m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND; -#endif - } - - common_hal_bleio_device_stop_advertising(device); - -#if (BLUETOOTH_SD == 140) - const ble_gap_adv_data_t ble_gap_adv_data = { - .adv_data.p_data = adv_data, - .adv_data.len = byte_pos, - }; - - err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params); - if (err_code != NRF_SUCCESS) { - return err_code; - } - - err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM); -#elif (BLUETOOTH_SD == 132 && BLE_API_VERSION == 4) - err_code = sd_ble_gap_adv_start(&m_adv_params, BLE_CONN_CFG_TAG_CUSTOM); -#else - err_code = sd_ble_gap_adv_start(&m_adv_params); -#endif - - return err_code; -} - -STATIC bool discover_services(bleio_device_obj_t *device, uint16_t start_handle) { - m_discovery_successful = false; - - uint32_t err_code = sd_ble_gattc_primary_services_discover(device->conn_handle, start_handle, NULL); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to discover services")); - } - - // Serialize discovery. - err_code = sd_mutex_acquire(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to acquire mutex")); - } - - // Wait for someone else to release m_discovery_mutex. - while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif - } - - err_code = sd_mutex_release(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } - - return m_discovery_successful; -} - -STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_obj_t *service, uint16_t start_handle) { - m_char_discovery_service = service; - - ble_gattc_handle_range_t handle_range; - handle_range.start_handle = start_handle; - handle_range.end_handle = service->end_handle; - - m_discovery_successful = false; - - uint32_t err_code = sd_ble_gattc_characteristics_discover(device->conn_handle, &handle_range); - if (err_code != NRF_SUCCESS) { - return false; - } - - err_code = sd_mutex_acquire(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to acquire mutex")); - } - - while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif - } - - err_code = sd_mutex_release(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } - - return m_discovery_successful; -} - -STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *response, bleio_device_obj_t *device) { - for (size_t i = 0; i < response->count; ++i) { - ble_gattc_service_t *gattc_service = &response->services[i]; - - bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); - service->base.type = &bleio_service_type; - service->device = device; - service->characteristic_list = mp_obj_new_list(0, NULL); - service->start_handle = gattc_service->handle_range.start_handle; - service->end_handle = gattc_service->handle_range.end_handle; - service->handle = gattc_service->handle_range.start_handle; - - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid); - service->uuid = uuid; - - mp_obj_list_append(device->service_list, service); - } - - if (response->count > 0) { - m_discovery_successful = true; - } - - const uint32_t err_code = sd_mutex_release(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } -} - -STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_device_obj_t *device) { - for (size_t i = 0; i < response->count; ++i) { - ble_gattc_char_t *gattc_char = &response->chars[i]; - - bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); - characteristic->base.type = &bleio_characteristic_type; - - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - uuid->base.type = &bleio_uuid_type; - bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); - characteristic->uuid = uuid; - - characteristic->props.broadcast = gattc_char->char_props.broadcast; - characteristic->props.indicate = gattc_char->char_props.indicate; - characteristic->props.notify = gattc_char->char_props.notify; - characteristic->props.read = gattc_char->char_props.read; - characteristic->props.write = gattc_char->char_props.write; - characteristic->props.write_no_response = gattc_char->char_props.write_wo_resp; - characteristic->handle = gattc_char->handle_value; - characteristic->service = m_char_discovery_service; - - mp_obj_list_append(m_char_discovery_service->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); - } - - if (response->count > 0) { - m_discovery_successful = true; - } - - const uint32_t err_code = sd_mutex_release(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } -} - -STATIC void on_adv_report(ble_gap_evt_adv_report_t *report, bleio_device_obj_t *device) { - uint32_t err_code; - - if (memcmp(report->peer_addr.addr, device->address.value, BLEIO_ADDRESS_BYTES) != 0) { -#if (BLUETOOTH_SD == 140) - err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to continue scanning")); - } -#endif - return; - } - - ble_gap_scan_params_t scan_params = { - .active = 1, - .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS), - .window = MSEC_TO_UNITS(100, UNIT_0_625_MS), - }; - - ble_gap_addr_t addr; - memset(&addr, 0, sizeof(addr)); - - addr.addr_type = report->peer_addr.addr_type; - memcpy(addr.addr, report->peer_addr.addr, BLEIO_ADDRESS_BYTES); - - 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, - }; - -#if (BLE_API_VERSION == 2) - err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params); -#else - err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM); -#endif - - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to connect:")); - } -} - -STATIC void on_ble_evt(ble_evt_t *ble_evt, void *device_in) { - bleio_device_obj_t *device = (bleio_device_obj_t*)device_in; - - switch (ble_evt->header.evt_id) { - case BLE_GAP_EVT_CONNECTED: - { - ble_gap_conn_params_t conn_params; - device->conn_handle = ble_evt->evt.gap_evt.conn_handle; - - sd_ble_gap_ppcp_get(&conn_params); - sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params); - break; - } - - case BLE_GAP_EVT_DISCONNECTED: - device->conn_handle = BLE_CONN_HANDLE_INVALID; - break; - - case BLE_GAP_EVT_ADV_REPORT: - on_adv_report(&ble_evt->evt.gap_evt.params.adv_report, device); - break; - - case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: - on_primary_srv_discovery_rsp(&ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp, device); - break; - - case BLE_GATTC_EVT_CHAR_DISC_RSP: - on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, device); - break; - - case BLE_GATTS_EVT_SYS_ATTR_MISSING: - sd_ble_gatts_sys_attr_set(ble_evt->evt.gatts_evt.conn_handle, NULL, 0, 0); - break; - -#if (BLE_API_VERSION == 4) - case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: - sd_ble_gatts_exchange_mtu_reply(device->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); - break; -#endif - - case BLE_GAP_EVT_SEC_PARAMS_REQUEST: - sd_ble_gap_sec_params_reply(device->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); - break; - - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: - { - ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request; - sd_ble_gap_conn_param_update(device->conn_handle, &request->conn_params); - break; - } - } -} - -void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_service_obj_t *service) { - ble_uuid_t uuid; - bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); - - uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY; - if (service->is_secondary) { - service_type = BLE_GATTS_SRVC_TYPE_SECONDARY; - } - - common_hal_bleio_adapter_set_enabled(true); - - const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to add service")); - } - - const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); - for (size_t i = 0; i < characteristic_list->len; ++i) { - bleio_characteristic_obj_t *characteristic = characteristic_list->items[i]; - common_hal_bleio_service_add_characteristic(service, characteristic); - } -} - -void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data) { - if (connectable) { - ble_drv_add_event_handler(on_ble_evt, device); - } - - const uint32_t err_code = set_advertisement_data(device, connectable, raw_data); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to start advertising")); - } -} - -void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device) { - uint32_t err_code; - -#if (BLUETOOTH_SD == 140) - if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) - return; - - err_code = sd_ble_gap_adv_stop(m_adv_handle); -#else - err_code = sd_ble_gap_adv_stop(); -#endif - - if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) { - mp_raise_OSError_msg(translate("Failed to stop advertising")); - } -} - -void common_hal_bleio_device_connect(bleio_device_obj_t *device) { - ble_drv_add_event_handler(on_ble_evt, device); - - ble_gap_scan_params_t scan_params = { - .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS), - .window = MSEC_TO_UNITS(100, UNIT_0_625_MS), -#if (BLUETOOTH_SD == 140) - .scan_phys = BLE_GAP_PHY_1MBPS, -#endif - }; - - common_hal_bleio_adapter_set_enabled(true); - - uint32_t err_code; -#if (BLUETOOTH_SD == 140) - err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer); -#else - err_code = sd_ble_gap_scan_start(&scan_params); -#endif - - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to start scanning")); - } - - while (device->conn_handle == BLE_CONN_HANDLE_INVALID) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif - } - - // TODO: read name - - if (m_discovery_mutex == NULL) { - m_discovery_mutex = m_new_ll(nrf_mutex_t, 1); - - err_code = sd_mutex_new(m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to create mutex")); - } - } - - // find services - bool found_service = discover_services(device, BLE_GATT_HANDLE_START); - 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 = discover_services(device, service->end_handle + 1); - } - - // 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 = discover_characteristics(device, service, service->start_handle); - while (found_char) { - const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); - const bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_list->len - 1]; - - const uint16_t next_handle = characteristic->handle + 1; - if (next_handle >= service->end_handle) { - break; - } - - found_char = discover_characteristics(device, service, next_handle); - } - } -} - -void common_hal_bleio_device_disconnect(bleio_device_obj_t *device) { - sd_ble_gap_disconnect(device->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); -} diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 36c20373d3..69e75ff27d 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -3,8 +3,8 @@ * * The MIT License (MIT) * - * Copyright (c) 2018 Artur Pacholec * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index 9103fcf943..725bc14314 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -3,8 +3,8 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec - * Copyright (c) 2018 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index 64f7decad2..6715bd7a28 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c index 77d3f02599..55193c5cb0 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/ports/nrf/common-hal/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h index 7998cc862a..b5acf39ae0 100644 --- a/ports/nrf/common-hal/bleio/Service.h +++ b/ports/nrf/common-hal/bleio/Service.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/ports/nrf/common-hal/bleio/UUID.c b/ports/nrf/common-hal/bleio/UUID.c index 23e643433f..ebd6b6d1fb 100644 --- a/ports/nrf/common-hal/bleio/UUID.c +++ b/ports/nrf/common-hal/bleio/UUID.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/bleio/UUID.h b/ports/nrf/common-hal/bleio/UUID.h index b464093ea1..7d3a6204ec 100644 --- a/ports/nrf/common-hal/bleio/UUID.h +++ b/ports/nrf/common-hal/bleio/UUID.h @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/bleio/__init__.c b/ports/nrf/common-hal/bleio/__init__.c index cfb701019d..58b81f066d 100644 --- a/ports/nrf/common-hal/bleio/__init__.c +++ b/ports/nrf/common-hal/bleio/__init__.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 05106d4905..538c87f2da 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -3,9 +3,10 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Sandeep Mistry All right reserved. - * Copyright (c) 2017 hathach + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2017 hathach + * Copyright (c) 2016 Sandeep Mistry All right reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 8881bdc6b3..6ab6d9493b 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -1,9 +1,11 @@ /* * SPI Master library for nRF5x. - * Copyright (c) 2015 Arduino LLC - * Copyright (c) 2016 Sandeep Mistry All right reserved. - * Copyright (c) 2017 hathach + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2017 hathach + * Copyright (c) 2016 Sandeep Mistry All right reserved. + * Copyright (c) 2015 Arduino LLC * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index ea864e7ceb..7d9463d0be 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2015 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2015 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 diff --git a/shared-bindings/bleio/Adapter.c b/shared-bindings/bleio/Adapter.c index d9449d3ab0..7b8df51034 100644 --- a/shared-bindings/bleio/Adapter.c +++ b/shared-bindings/bleio/Adapter.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/Adapter.h b/shared-bindings/bleio/Adapter.h index fe3886e59e..de9d1d6db1 100644 --- a/shared-bindings/bleio/Adapter.h +++ b/shared-bindings/bleio/Adapter.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/Address.h b/shared-bindings/bleio/Address.h index 9652a9841a..bff1542cf0 100644 --- a/shared-bindings/bleio/Address.h +++ b/shared-bindings/bleio/Address.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/AdvertisementData.h b/shared-bindings/bleio/AdvertisementData.h index 05b5a2c8da..3313cde3b2 100644 --- a/shared-bindings/bleio/AdvertisementData.h +++ b/shared-bindings/bleio/AdvertisementData.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index e48cfd433b..859611f91a 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * 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 diff --git a/shared-bindings/bleio/Characteristic.h b/shared-bindings/bleio/Characteristic.h index ffee6bdbc7..1938845a9a 100644 --- a/shared-bindings/bleio/Characteristic.h +++ b/shared-bindings/bleio/Characteristic.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,6 +28,7 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H +#include "shared-module/bleio/Characteristic.h" #include "common-hal/bleio/Characteristic.h" extern const mp_obj_type_t bleio_characteristic_type; diff --git a/shared-bindings/bleio/CharacteristicBuffer.h b/shared-bindings/bleio/CharacteristicBuffer.h index f25017c19e..b45835ff39 100644 --- a/shared-bindings/bleio/CharacteristicBuffer.h +++ b/shared-bindings/bleio/CharacteristicBuffer.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c index b32f4f08ec..9e051c89e3 100644 --- a/shared-bindings/bleio/Descriptor.c +++ b/shared-bindings/bleio/Descriptor.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * 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 diff --git a/shared-bindings/bleio/Descriptor.h b/shared-bindings/bleio/Descriptor.h index f47378ee16..f4634d3933 100644 --- a/shared-bindings/bleio/Descriptor.h +++ b/shared-bindings/bleio/Descriptor.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c deleted file mode 100644 index fcdc84d270..0000000000 --- a/shared-bindings/bleio/Device.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * 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/Device.h" -#include "shared-module/bleio/ScanEntry.h" - -// Work-in-progress: orphaned for now. -//| :orphan: -//| -//| .. currentmodule:: bleio -//| -//| :class:`Device` -- BLE device -//| ========================================================= -//| -//| **IGNORE ``Device`` and all its documentation. -//| It is being replaced by `Peripheral` and other classes.** -//| -//| 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 `bleio.Device.start_advertising` -//| and `bleio.Device.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 `bleio.Device.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, scan_entry=None) -//| -//| Create a new Device object. If the `address` or :py:data:`scan_entry` parameters are not `None`, -//| the role is set to Central, otherwise it's set to Peripheral. -//| -//| :param bleio.Address address: The address of the device to connect to -//| :param bleio.ScanEntry scan_entry: The scan entry returned from `bleio.Scanner` -//| - -//| .. 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. -//| - -// TODO: Add unique MAC address part to name -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); - - enum { ARG_address, ARG_scan_entry }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_address, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_scan_entry, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, - }; - - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - const mp_obj_t address_obj = args[ARG_address].u_obj; - const mp_obj_t scan_entry_obj = args[ARG_scan_entry].u_obj; - - 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 if (scan_entry_obj != mp_const_none) { - bleio_scanentry_obj_t *scan_entry = MP_OBJ_TO_PTR(scan_entry_obj); - - self->is_peripheral = false; - 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)); - 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, - translate("Can't add services in Central mode"))); - } - - service->device = self; - - 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, - translate("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, - translate("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, - translate("Can't advertise in Central mode"))); - } - - enum { ARG_connectable, ARG_data }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, - { MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - }; - - 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); - - mp_buffer_info_t bufinfo = { 0 }; - if (args[ARG_data].u_obj != mp_const_none) { - mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ); - } - - const 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 = service_list->items[i]; - if (service->handle == 0xFFFF) { - common_hal_bleio_device_add_service(self, service); - } - } - - common_hal_bleio_device_start_advertising(self, args[ARG_connectable].u_bool, &bufinfo); - - 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, - translate("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 index e452a8ad6c..d19b8c886b 100644 --- a/shared-bindings/bleio/Device.h +++ b/shared-bindings/bleio/Device.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 5397f4c3ab..e270c599c6 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h index 6468325c27..16438bba6d 100644 --- a/shared-bindings/bleio/Peripheral.h +++ b/shared-bindings/bleio/Peripheral.h @@ -3,8 +3,8 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec - * Copyright (c) 2018 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/shared-bindings/bleio/ScanEntry.h b/shared-bindings/bleio/ScanEntry.h index c1b52e6b4e..3a02f2facf 100644 --- a/shared-bindings/bleio/ScanEntry.h +++ b/shared-bindings/bleio/ScanEntry.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * Copyright (c) 2017 Glenn Ruben Bakke * diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index 352ef8d6a8..2719164d88 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * 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 diff --git a/shared-bindings/bleio/Service.h b/shared-bindings/bleio/Service.h index 27d79f9539..6693cc3bb3 100644 --- a/shared-bindings/bleio/Service.h +++ b/shared-bindings/bleio/Service.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,12 +28,11 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H -#include "shared-module/bleio/Characteristic.h" #include "common-hal/bleio/Service.h" const mp_obj_type_t bleio_service_type; -extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *char_list, bool is_secondary); +extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *characteristic_list, bool is_secondary); extern bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self); extern mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self); extern bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self); diff --git a/shared-bindings/bleio/UUID.c b/shared-bindings/bleio/UUID.c index f79dfa6752..9725050586 100644 --- a/shared-bindings/bleio/UUID.c +++ b/shared-bindings/bleio/UUID.c @@ -3,9 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec - * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * 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 diff --git a/shared-bindings/bleio/UUID.h b/shared-bindings/bleio/UUID.h index aef2c1e29e..caf039aecb 100644 --- a/shared-bindings/bleio/UUID.h +++ b/shared-bindings/bleio/UUID.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 06c00d5880..ca45a846ec 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 @@ -53,11 +54,10 @@ //| Address //| AdvertisementData //| Adapter +//| Central //| Characteristic //| CharacteristicBuffer -// Work-in-progress classes are omitted, and marked as :orphan: in their files. // Descriptor -// Device //| Peripheral //| ScanEntry //| Scanner @@ -74,6 +74,7 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) }, { MP_ROM_QSTR(MP_QSTR_Address), MP_ROM_PTR(&bleio_address_type) }, +// { MP_ROM_QSTR(MP_QSTR_Central), MP_ROM_PTR(&bleio_central_type) }, { MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) }, { MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) }, // { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, diff --git a/shared-bindings/bleio/__init__.h b/shared-bindings/bleio/__init__.h index 1f4e0a66ff..4aa6dd45b7 100644 --- a/shared-bindings/bleio/__init__.h +++ b/shared-bindings/bleio/__init__.h @@ -3,8 +3,9 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 diff --git a/shared-module/bleio/Address.h b/shared-module/bleio/Address.h index f66e97d640..eb1aab2581 100644 --- a/shared-module/bleio/Address.h +++ b/shared-module/bleio/Address.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-module/bleio/AdvertisementData.h b/shared-module/bleio/AdvertisementData.h index 66855172ab..89cdfb0700 100644 --- a/shared-module/bleio/AdvertisementData.h +++ b/shared-module/bleio/AdvertisementData.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/shared-module/bleio/Characteristic.h b/shared-module/bleio/Characteristic.h deleted file mode 100644 index 3132fd47b4..0000000000 --- a/shared-module/bleio/Characteristic.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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_CHARACTERISTIC_H -#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H - -// Flags for each characteristic property. Common across ports. -typedef struct { - bool broadcast : 1; - bool read : 1; - bool write_no_response : 1; - bool write : 1; - bool notify : 1; - bool indicate : 1; -} bleio_characteristic_properties_t; - -// bleio_characteristic_obj_t is defined in ports/*/common-hal. - -#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H diff --git a/shared-module/bleio/Device.h b/shared-module/bleio/Device.h deleted file mode 100644 index 8d9ece5ef0..0000000000 --- a/shared-module/bleio/Device.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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; - volatile 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 index 40e02f9fa0..4e7028ba2a 100644 --- a/shared-module/bleio/ScanEntry.h +++ b/shared-module/bleio/ScanEntry.h @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy From 24ac1fdcabdcdb02f9807192d3cb2a4210b4afc8 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 19 Jun 2019 21:54:28 -0400 Subject: [PATCH 12/25] WIP: backup only; not compiled --- ports/nrf/bluetooth/ble_drv.h | 2 + ports/nrf/common-hal/bleio/Central.c | 312 ++++++++++++++++++++ ports/nrf/common-hal/bleio/Central.h | 45 +++ ports/nrf/common-hal/bleio/Characteristic.c | 88 +++--- ports/nrf/common-hal/bleio/Service.h | 2 + ports/nrf/common-hal/bleio/__init__.c | 10 +- py/circuitpy_defns.mk | 1 + shared-bindings/bleio/Central.c | 186 ++++++++++++ shared-bindings/bleio/Central.h | 39 +++ shared-module/bleio/Characteristic.h | 40 +++ 10 files changed, 664 insertions(+), 61 deletions(-) create mode 100644 ports/nrf/common-hal/bleio/Central.c create mode 100644 ports/nrf/common-hal/bleio/Central.h create mode 100644 shared-bindings/bleio/Central.c create mode 100644 shared-bindings/bleio/Central.h create mode 100644 shared-module/bleio/Characteristic.h diff --git a/ports/nrf/bluetooth/ble_drv.h b/ports/nrf/bluetooth/ble_drv.h index d349fa4e07..a066f588fa 100644 --- a/ports/nrf/bluetooth/ble_drv.h +++ b/ports/nrf/bluetooth/ble_drv.h @@ -43,7 +43,9 @@ #define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION)) // 0.625 msecs (625 usecs) #define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625) +// Microseconds is the base unit. The macros above know that. #define UNIT_0_625_MS (625) +#define UNIT_1_25_MS (1250) #define UNIT_10_MS (10000) typedef void (*ble_drv_evt_handler_t)(ble_evt_t*, void*); diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c new file mode 100644 index 0000000000..af5a56b76c --- /dev/null +++ b/ports/nrf/common-hal/bleio/Central.c @@ -0,0 +1,312 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "ble.h" +#include "ble_drv.h" +#include "ble_hci.h" +#include "nrf_soc.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "shared-bindings/bleio/Adapter.h" +#include "shared-bindings/bleio/Characteristic.h" +#include "shared-bindings/bleio/Central.h" +#include "shared-bindings/bleio/Service.h" +#include "shared-bindings/bleio/UUID.h" + +static bleio_service_obj_t *m_char_discovery_service; +static volatile bool m_discovery_successful; + +STATIC bool discover_next_services(bleio_central_obj_t *self, uint16_t start_handle) { + m_discovery_successful = false; + + uint32_t err_code = sd_ble_gattc_primary_services_discover(self->conn_handle, start_handle, NULL); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to discover services")); + } + + // Serialize discovery. + err_code = sd_mutex_acquire(&m_discovery_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to acquire mutex")); + } + + // Wait for someone else to release m_discovery_mutex. + while (sd_mutex_acquire(&m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif + } + + err_code = sd_mutex_release(&m_discovery_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to release mutex")); + } + + return m_discovery_successful; +} + +STATIC bool discover_next_characteristics(bleio_central_obj_t *self, bleio_service_obj_t *service, uint16_t start_handle) { + m_char_discovery_service = service; + + ble_gattc_handle_range_t handle_range; + handle_range.start_handle = start_handle; + handle_range.end_handle = service->end_handle; + + m_discovery_successful = false; + + uint32_t err_code = sd_ble_gattc_characteristics_discover(self->conn_handle, &handle_range); + if (err_code != NRF_SUCCESS) { + return false; + } + + err_code = sd_mutex_acquire(&m_discovery_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to acquire mutex")); + } + + while (sd_mutex_acquire(&m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { + MICROPY_VM_HOOK_LOOP; + } + + err_code = sd_mutex_release(&m_discovery_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to release mutex")); + } + + return m_discovery_successful; +} + +STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *response, bleio_central_obj_t *central) { + for (size_t i = 0; i < response->count; ++i) { + ble_gattc_service_t *gattc_service = &response->services[i]; + + bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); + service->base.type = &bleio_service_type; + service->device = central; + service->characteristic_list = mp_obj_new_list(0, NULL); + service->start_handle = gattc_service->handle_range.start_handle; + service->end_handle = gattc_service->handle_range.end_handle; + service->handle = gattc_service->handle_range.start_handle; + + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid); + service->uuid = uuid; + + mp_obj_list_append(central->service_list, service); + } + + if (response->count > 0) { + m_discovery_successful = true; + } + + const uint32_t err_code = sd_mutex_release(&m_discovery_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to release mutex")); + } +} + +STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_central_obj_t *central) { + for (size_t i = 0; i < response->count; ++i) { + ble_gattc_char_t *gattc_char = &response->chars[i]; + + bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); + characteristic->base.type = &bleio_characteristic_type; + + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + uuid->base.type = &bleio_uuid_type; + bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); + characteristic->uuid = uuid; + + characteristic->props.broadcast = gattc_char->char_props.broadcast; + characteristic->props.indicate = gattc_char->char_props.indicate; + characteristic->props.notify = gattc_char->char_props.notify; + characteristic->props.read = gattc_char->char_props.read; + characteristic->props.write = gattc_char->char_props.write; + characteristic->props.write_no_response = gattc_char->char_props.write_wo_resp; + characteristic->handle = gattc_char->handle_value; + characteristic->service = m_char_discovery_service; + + mp_obj_list_append(m_char_discovery_service->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); + } + + if (response->count > 0) { + m_discovery_successful = true; + } + + const uint32_t err_code = sd_mutex_release(&m_discovery_mutex); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg(translate("Failed to release mutex")); + } +} + +STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { + bleio_central_obj_t *central = (bleio_central_obj_t*)central_in; + + switch (ble_evt->header.evt_id) { + case BLE_GAP_EVT_CONNECTED: + { + ble_gap_conn_params_t conn_params; + central->conn_handle = ble_evt->evt.gap_evt.conn_handle; + + sd_ble_gap_ppcp_get(&conn_params); + sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params); + break; + } + + case BLE_GAP_EVT_TIMEOUT: + if (central->attempting_to_connect) { + // Signal that connection attempt has timed out. + central->attempting_to_connect = false; + } + break; + + case BLE_GAP_EVT_DISCONNECTED: + central->conn_handle = BLE_CONN_HANDLE_INVALID; + break; + + case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: + on_primary_srv_discovery_rsp(&ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp, central); + break; + + case BLE_GATTC_EVT_CHAR_DISC_RSP: + on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, central); + break; + + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + sd_ble_gatts_sys_attr_set(ble_evt->evt.gatts_evt.conn_handle, NULL, 0, 0); + break; + + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: + sd_ble_gatts_exchange_mtu_reply(central->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); + break; + + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); + break; + + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: + { + ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request; + sd_ble_gap_conn_param_update(central->conn_handle, &request->conn_params); + break; + } + } +} + +void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout) { + common_hal_bleio_adapter_set_enabled(true); + ble_drv_add_event_handler(on_ble_evt, self); + + ble_gap_scan_params_t scan_params = { + .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS), + .window = MSEC_TO_UNITS(100, UNIT_0_625_MS), + .scan_phys = BLE_GAP_PHY_1MBPS, + // timeout of 0 means no timeout + .timeout = SEC_TO_UNITS(timeout, UNIT_10_MS), + }; + + ble_gap_conn_params_t conn_params = { + .conn_sup_timeout = MSEC_TO_UNITS(4000, UNIT_10_MS), + .min_conn_interval = MSEC_TO_UNITS(15, UNIT_1_25_MS), + .max_conn_interval = MSEC_TO_UNITS(300, UNIT_1_25_MS), + .slave_latency = 0, // number of conn events + }; + + self->attempting_to_connect = true; + + uint32_t err_code = sd_ble_gap_connect(&scan_params, &m_scan_buffer); + + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to start connecting, error 0x%04x"), err_code); + } + + while (self->conn_handle == BLE_CONN_HANDLE_INVALID && self->attempting_to_connect) { + #ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP + #endif + } + + if (!self->attempting_to_connect) { + mp_raise_OSError_msg(translate("Failed to connect: timeout")); + } + + // Conenction successful. + // Now discover all services on the remote peripheral. Ask for services repeatedly + // until no more are left. + + uint16_t next_start_handle; + + next_start_handle = BLE_GATT_HANDLE_START; + + while (1) { + if(!discover_next_services(self, discovery_start_handle)) { + break; + } + + // discover_next_services() appends to service_list. + const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); + + // Get the most recently discovered service, and ask for services with handles + // starting after the last attribute handle of t + const bleio_service_obj_t *service = service_list->items[service_list->len - 1]; + next_start_handle = service->end_handle + 1; + } + + // Now, for each service, discover its characteristics. + // find characteristics in each service + const 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 = service_list->items[i]; + + next_start_handle = service->start_handle; + + while (1) { + if (!discover_next_characteristics(self, service, service->start_handle)) { + break; + } + + // discover_next_characteristics() appends to the characteristic_list. + const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); + + // Get the most recently discovered characteristic. + const bleio_characteristic_obj_t *characteristic = + characteristic_list->items[characteristic_list->len - 1]; + next_start_handle = characteristic->handle + 1; + if (next_start_handle >= service->end_handle) { + // Went past the end of the range of handles for this service. + break; + } + } + } +} + +void common_hal_bleio_central_disconnect(bleio_central_obj_t *self) { + sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); +} diff --git a/ports/nrf/common-hal/bleio/Central.h b/ports/nrf/common-hal/bleio/Central.h new file mode 100644 index 0000000000..c44cf3b771 --- /dev/null +++ b/ports/nrf/common-hal/bleio/Central.h @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H +#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H + +#include + +#include "shared-module/bleio/Address.h" + +typedef struct { + mp_obj_base_t base; + mp_obj_t remote_name; + bleio_address_obj_t address; + volatile bool attempting_to_connect; + volatile uint16_t conn_handle; + mp_obj_t service_list; + mp_obj_t conn_handler; +} bleio_central_obj_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 346cfefbc5..70ebd7aba3 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -37,9 +37,6 @@ #include "common-hal/bleio/Characteristic.h" STATIC volatile bleio_characteristic_obj_t *m_read_characteristic; -STATIC volatile uint8_t m_tx_in_progress; -// Serialize gattc writes that send a response. This might be done per object? -STATIC nrf_mutex_t *m_write_mutex; STATIC uint16_t get_cccd(bleio_characteristic_obj_t *characteristic) { const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device); @@ -118,17 +115,21 @@ STATIC void gatts_notify_indicate(bleio_characteristic_obj_t *characteristic, mp .p_data = bufinfo->buf, }; - while (m_tx_in_progress >= MAX_TX_IN_PROGRESS) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif - } - const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device); - m_tx_in_progress++; - const uint32_t err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params); - if (err_code != NRF_SUCCESS) { - m_tx_in_progress--; + + while (1) { + const uint32_t err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params); + if (err_code == NRF_SUCCESS) { + break; + } + // TX buffer is full + // We could wait for an event indicating the write is complete, but just retrying is easier. + if (err_code == NRF_ERROR_RESOURCES) { + MICROPY_VM_HOOK_LOOP; + continue; + } + + // Some real error has occurred. mp_raise_OSError_msg_varg(translate("Failed to notify or indicate attribute value, err 0x%04x"), err_code); } @@ -144,11 +145,8 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) { mp_raise_OSError_msg_varg(translate("Failed to read attribute value, err 0x%04x"), err_code); } -// while (m_read_characteristic != NULL) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif + MICROPY_VM_HOOK_LOOP; } } @@ -158,67 +156,47 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in ble_gattc_write_params_t write_params = { .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL, - .write_op = BLE_GATT_OP_WRITE_REQ, + .write_op = characteristic->props.write_no_response ? BLE_GATT_OP_WRITE_CMD : BLE_GATT_OP_WRITE_REQ, .handle = characteristic->handle, .p_value = bufinfo->buf, .len = bufinfo->len, }; - if (characteristic->props.write_no_response) { - write_params.write_op = BLE_GATT_OP_WRITE_CMD; - - err_code = sd_mutex_acquire(m_write_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to acquire mutex, err 0x%04x"), err_code); + while (1) { + uint32 err_code = sd_ble_gattc_write(conn_handle, &write_params); + if (err_code == NRF_SUCCESS) { + break; } - } - err_code = sd_ble_gattc_write(conn_handle, &write_params); - if (err_code != NRF_SUCCESS) { + // Write with response will return NRF_ERROR_BUSY if the response has not been received. + // Write without reponse will return NRF_ERROR_RESOURCES if too many writes are pending. + if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) { + // We could wait for an event indicating the write is complete, but just retrying is easier. + MICROPY_VM_HOOK_LOOP; + continue; + } + + // Some real error occurred. mp_raise_OSError_msg_varg(translate("Failed to write attribute value, err 0x%04x"), err_code); } - while (sd_mutex_acquire(m_write_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif - } - - err_code = sd_mutex_release(m_write_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to release mutex, err 0x%04x"), err_code); - } } STATIC void characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) { switch (ble_evt->header.evt_id) { - case BLE_GATTS_EVT_HVN_TX_COMPLETE: - { - uint8_t count = ble_evt->evt.gatts_evt.params.hvn_tx_complete.count; - // Don't underflow the count. - if (count >= m_tx_in_progress) { - m_tx_in_progress = 0; - } else { - m_tx_in_progress -= count; - } - break; - } + + // More events may be handled later, so keep this as a switch. case BLE_GATTC_EVT_READ_RSP: { ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp; m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data); - // Flag to busy-wait loop that we've read the characteristic. + // Indicate to busy-wait loop that we've read the characteristic. m_read_characteristic = NULL; break; } - case BLE_GATTC_EVT_WRITE_RSP: - // Someone else can write now. - sd_mutex_release(m_write_mutex); - break; - - // For debugging. + // For debugging. default: // mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id); break; diff --git a/ports/nrf/common-hal/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h index b5acf39ae0..dc794ff28c 100644 --- a/ports/nrf/common-hal/bleio/Service.h +++ b/ports/nrf/common-hal/bleio/Service.h @@ -32,12 +32,14 @@ typedef struct { mp_obj_base_t base; + // Handle for this service. uint16_t handle; bool is_secondary; bleio_uuid_obj_t *uuid; // May be a Peripheral, Central, etc. mp_obj_t *device; mp_obj_t characteristic_list; + // Range of attribute handles of this service. uint16_t start_handle; uint16_t end_handle; } bleio_service_obj_t; diff --git a/ports/nrf/common-hal/bleio/__init__.c b/ports/nrf/common-hal/bleio/__init__.c index 58b81f066d..699dcc57fd 100644 --- a/ports/nrf/common-hal/bleio/__init__.c +++ b/ports/nrf/common-hal/bleio/__init__.c @@ -49,9 +49,8 @@ const super_adapter_obj_t common_hal_bleio_adapter_obj = { gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device) { if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) { return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role; -// Does not exist yet. -// } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) { -// return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role; + } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) { + return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role; } else { return GATT_ROLE_NONE; } @@ -60,9 +59,8 @@ gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device) { uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device) { if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) { return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle; -// Does not exist yet. -// } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) { -// return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle; + } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) { + return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle; } else { return 0; } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 435cf2c334..782314fc70 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -224,6 +224,7 @@ $(filter $(SRC_PATTERNS), \ audioio/AudioOut.c \ bleio/__init__.c \ bleio/Adapter.c \ + bleio/Central.c \ bleio/Characteristic.c \ bleio/CharacteristicBuffer.c \ bleio/Descriptor.c \ diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c new file mode 100644 index 0000000000..e5fd66348e --- /dev/null +++ b/shared-bindings/bleio/Central.c @@ -0,0 +1,186 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 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 + +#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/Central.h" +#include "shared-bindings/bleio/Service.h" +#include "shared-bindings/bleio/UUID.h" + +//| .. currentmodule:: bleio +//| +//| :class:`Central` -- A BLE central device +//| ========================================================= +//| +//| Implement a BLE central, which runs locally. Can connect to a given address. +//| +//| Usage:: +//| +//| import bleio +//| +//| scanner = bleio.Scanner() +//| entries = scanner.scan(2.5) +//| +//| my_entry = None +//| for entry in entries: +//| if entry.name is not None and entry.name == 'MyCentral': +//| my_entry = entry +//| break +//| +//| central = bleio.Central(my_entry.address) +//| central.connect() +//| + +//| .. class:: Central(address=None, scan_entry=None) +//| +//| Create a new Central object. If the `address` or :py:data:`scan_entry` parameters are not `None`, +//| the role is set to Central, otherwise it's set to Peripheral. +//| +//| :param bleio.Address address: The address of the central to connect to +//| :param bleio.ScanEntry scan_entry: The scan entry returned from `bleio.Scanner` +//| +STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 0, 1, true); + bleio_central_obj_t *self = m_new_obj(bleio_central_obj_t); + self->base.type = &bleio_central_type; + self->service_list = mp_obj_new_list(0, NULL); + self->conn_handler = mp_const_none; + self->conn_handle = 0xFFFF; + + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); + + enum { ARG_address, ARG_scan_entry }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_address, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_scan_entry, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const mp_obj_t address_obj = args[ARG_address].u_obj; + const mp_obj_t scan_entry_obj = args[ARG_scan_entry].u_obj; + + if (!MP_OBJ_IS_TYPE(address_obj, &bleio_address_type)) { + mp_raise_ValueError("Expected an Address"); + } + + return MP_OBJ_FROM_PTR(self); +} + + + +//| .. method:: connect() +//| +//| Attempts a connection to the remote peripheral. If the connection is successful, +//| +STATIC mp_obj_t bleio_central_connect(mp_obj_t self_in) { + bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); + + if (self->is_peripheral) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + translate("Can't connect in Peripheral mode"))); + } + + common_hal_bleio_central_connect(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_connect_obj, bleio_central_connect); + + +//| .. method:: disconnect() +//| +//| Disconnects from the remote peripheral. +//| +STATIC mp_obj_t bleio_central_disconnect(mp_obj_t self_in) { + bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); + + common_hal_bleio_central_disconnect(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_disconnect); + +//| .. attribute:: remote_name (read-only) +//| +//| The name of the remote peripheral, if connected. May be None if no name was advertised. +//| +STATIC mp_obj_t bleio_central_get_remote_name(mp_obj_t self_in) { + bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return self->remote_name; +} +MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_name_obj, bleio_central_get_remote_name); + +//| .. attribute:: remote_services (read-only) +//| +//| Empty until connected, then a list of services provided by the remote peripheral. +//| +STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) { + bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return self->service_list; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services); + +const mp_obj_property_t bleio_central_remote_services_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_central_get_remote_services_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_central_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_central_disconnect_obj) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_remote_name), MP_ROM_PTR(&bleio_central_remote_name_obj) }, + { MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(bleio_central_locals_dict, bleio_central_locals_dict_table); + +const mp_obj_type_t bleio_central_type = { + { &mp_type_type }, + .name = MP_QSTR_Central, + .make_new = bleio_central_make_new, + .locals_dict = (mp_obj_dict_t*)&bleio_central_locals_dict +}; diff --git a/shared-bindings/bleio/Central.h b/shared-bindings/bleio/Central.h new file mode 100644 index 0000000000..5ea2119af0 --- /dev/null +++ b/shared-bindings/bleio/Central.h @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H + +#include "common-hal/bleio/Central.h" +#include "common-hal/bleio/Service.h" + +extern const mp_obj_type_t bleio_device_type; + +extern void common_hal_bleio_device_connect(bleio_device_obj_t *device); +extern void common_hal_bleio_device_disconnect(bleio_device_obj_t *device); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H diff --git a/shared-module/bleio/Characteristic.h b/shared-module/bleio/Characteristic.h new file mode 100644 index 0000000000..27b43588fa --- /dev/null +++ b/shared-module/bleio/Characteristic.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * 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_CHARACTERISTIC_H +#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H + +// Flags for each characteristic property. Common across ports. +typedef struct { + bool broadcast : 1; + bool read : 1; + bool write_no_response : 1; + bool write : 1; + bool notify : 1; + bool indicate : 1; +} bleio_characteristic_properties_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H From 4881e1ff55768c027404cc6a1375c43d4c3acf2a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 21 Jun 2019 18:04:04 -0400 Subject: [PATCH 13/25] WIP: Central compiles; now will test --- ports/nrf/common-hal/bleio/Central.c | 73 +++++++++----------- ports/nrf/common-hal/bleio/Central.h | 4 +- ports/nrf/common-hal/bleio/Characteristic.c | 3 +- ports/nrf/common-hal/bleio/Service.h | 2 +- ports/nrf/common-hal/bleio/__init__.c | 1 + shared-bindings/bleio/Central.c | 67 +++++------------- shared-bindings/bleio/Central.h | 8 ++- shared-bindings/bleio/Characteristic.c | 8 +-- shared-bindings/bleio/CharacteristicBuffer.c | 2 +- shared-bindings/bleio/Device.h | 42 ----------- shared-bindings/bleio/Peripheral.c | 6 +- shared-bindings/bleio/Service.c | 24 +++---- 12 files changed, 78 insertions(+), 162 deletions(-) delete mode 100644 shared-bindings/bleio/Device.h diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c index af5a56b76c..5864a8a56f 100644 --- a/ports/nrf/common-hal/bleio/Central.c +++ b/ports/nrf/common-hal/bleio/Central.c @@ -41,34 +41,22 @@ #include "shared-bindings/bleio/UUID.h" static bleio_service_obj_t *m_char_discovery_service; +static volatile bool m_discovery_in_process; static volatile bool m_discovery_successful; STATIC bool discover_next_services(bleio_central_obj_t *self, uint16_t start_handle) { m_discovery_successful = false; + m_discovery_in_process = true; uint32_t err_code = sd_ble_gattc_primary_services_discover(self->conn_handle, start_handle, NULL); if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg(translate("Failed to discover services")); } - // Serialize discovery. - err_code = sd_mutex_acquire(&m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to acquire mutex")); + // Wait for a discovery event. + while (m_discovery_in_process) { + MICROPY_VM_HOOK_LOOP; } - - // Wait for someone else to release m_discovery_mutex. - while (sd_mutex_acquire(&m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP -#endif - } - - err_code = sd_mutex_release(&m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } - return m_discovery_successful; } @@ -80,26 +68,17 @@ STATIC bool discover_next_characteristics(bleio_central_obj_t *self, bleio_servi handle_range.end_handle = service->end_handle; m_discovery_successful = false; + m_discovery_in_process = true; uint32_t err_code = sd_ble_gattc_characteristics_discover(self->conn_handle, &handle_range); if (err_code != NRF_SUCCESS) { return false; } - err_code = sd_mutex_acquire(&m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to acquire mutex")); - } - - while (sd_mutex_acquire(&m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) { + // Wait for a discovery event. + while (m_discovery_in_process) { MICROPY_VM_HOOK_LOOP; } - - err_code = sd_mutex_release(&m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } - return m_discovery_successful; } @@ -109,7 +88,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); service->base.type = &bleio_service_type; - service->device = central; + service->device = MP_OBJ_FROM_PTR(central); service->characteristic_list = mp_obj_new_list(0, NULL); service->start_handle = gattc_service->handle_range.start_handle; service->end_handle = gattc_service->handle_range.end_handle; @@ -125,11 +104,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res if (response->count > 0) { m_discovery_successful = true; } - - const uint32_t err_code = sd_mutex_release(&m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } + m_discovery_in_process = false; } STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_central_obj_t *central) { @@ -159,11 +134,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio if (response->count > 0) { m_discovery_successful = true; } - - const uint32_t err_code = sd_mutex_release(&m_discovery_mutex); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Failed to release mutex")); - } + m_discovery_in_process = false; } STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { @@ -189,6 +160,8 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { case BLE_GAP_EVT_DISCONNECTED: central->conn_handle = BLE_CONN_HANDLE_INVALID; + m_discovery_successful = false; + m_discovery_in_process = false; break; case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: @@ -220,10 +193,22 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { } } +void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address_obj_t *address) { + common_hal_bleio_adapter_set_enabled(true); + + self->service_list = mp_obj_new_list(0, NULL); + self->gatt_role = GATT_ROLE_CLIENT; + self->conn_handle = BLE_CONN_HANDLE_INVALID; +} + void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout) { common_hal_bleio_adapter_set_enabled(true); ble_drv_add_event_handler(on_ble_evt, self); + ble_gap_addr_t addr; + addr.addr_type = self->address.type; + memcpy(addr.addr, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES); + ble_gap_scan_params_t scan_params = { .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS), .window = MSEC_TO_UNITS(100, UNIT_0_625_MS), @@ -241,7 +226,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time self->attempting_to_connect = true; - uint32_t err_code = sd_ble_gap_connect(&scan_params, &m_scan_buffer); + uint32_t err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM); if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg_varg(translate("Failed to start connecting, error 0x%04x"), err_code); @@ -266,7 +251,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time next_start_handle = BLE_GATT_HANDLE_START; while (1) { - if(!discover_next_services(self, discovery_start_handle)) { + if(!discover_next_services(self, next_start_handle)) { break; } @@ -310,3 +295,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time void common_hal_bleio_central_disconnect(bleio_central_obj_t *self) { sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); } + +mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) { + return self->service_list; +} diff --git a/ports/nrf/common-hal/bleio/Central.h b/ports/nrf/common-hal/bleio/Central.h index c44cf3b771..ba4a92187b 100644 --- a/ports/nrf/common-hal/bleio/Central.h +++ b/ports/nrf/common-hal/bleio/Central.h @@ -30,16 +30,16 @@ #include +#include "shared-module/bleio/__init__.h" #include "shared-module/bleio/Address.h" typedef struct { mp_obj_base_t base; - mp_obj_t remote_name; + gatt_role_t gatt_role; bleio_address_obj_t address; volatile bool attempting_to_connect; volatile uint16_t conn_handle; mp_obj_t service_list; - mp_obj_t conn_handler; } bleio_central_obj_t; #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 70ebd7aba3..d2f961fe65 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -152,7 +152,6 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) { STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) { const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device); - uint32_t err_code; ble_gattc_write_params_t write_params = { .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL, @@ -163,7 +162,7 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in }; while (1) { - uint32 err_code = sd_ble_gattc_write(conn_handle, &write_params); + uint32_t err_code = sd_ble_gattc_write(conn_handle, &write_params); if (err_code == NRF_SUCCESS) { break; } diff --git a/ports/nrf/common-hal/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h index dc794ff28c..90f52027db 100644 --- a/ports/nrf/common-hal/bleio/Service.h +++ b/ports/nrf/common-hal/bleio/Service.h @@ -37,7 +37,7 @@ typedef struct { bool is_secondary; bleio_uuid_obj_t *uuid; // May be a Peripheral, Central, etc. - mp_obj_t *device; + mp_obj_t device; mp_obj_t characteristic_list; // Range of attribute handles of this service. uint16_t start_handle; diff --git a/ports/nrf/common-hal/bleio/__init__.c b/ports/nrf/common-hal/bleio/__init__.c index 699dcc57fd..2dba5780c1 100644 --- a/ports/nrf/common-hal/bleio/__init__.c +++ b/ports/nrf/common-hal/bleio/__init__.c @@ -28,6 +28,7 @@ #include "shared-bindings/bleio/__init__.h" #include "shared-bindings/bleio/Adapter.h" +#include "shared-bindings/bleio/Central.h" #include "shared-bindings/bleio/Peripheral.h" #include "common-hal/bleio/__init__.h" diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c index e5fd66348e..b3be906067 100644 --- a/shared-bindings/bleio/Central.c +++ b/shared-bindings/bleio/Central.c @@ -35,11 +35,10 @@ #include "py/objstr.h" #include "py/runtime.h" #include "shared-bindings/bleio/Adapter.h" -#include "shared-bindings/bleio/AddressType.h" +#include "shared-bindings/bleio/Address.h" #include "shared-bindings/bleio/Characteristic.h" #include "shared-bindings/bleio/Central.h" #include "shared-bindings/bleio/Service.h" -#include "shared-bindings/bleio/UUID.h" //| .. currentmodule:: bleio //| @@ -62,44 +61,28 @@ //| break //| //| central = bleio.Central(my_entry.address) -//| central.connect() +//| central.connect(10.0) # timeout after 10 seconds //| -//| .. class:: Central(address=None, scan_entry=None) -//| -//| Create a new Central object. If the `address` or :py:data:`scan_entry` parameters are not `None`, -//| the role is set to Central, otherwise it's set to Peripheral. +//| .. class:: Central(address) //| +//| Create a new Central object. //| :param bleio.Address address: The address of the central to connect to -//| :param bleio.ScanEntry scan_entry: The scan entry returned from `bleio.Scanner` //| -STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { - mp_arg_check_num(n_args, n_kw, 0, 1, true); +STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 1, 1, false); + bleio_central_obj_t *self = m_new_obj(bleio_central_obj_t); self->base.type = &bleio_central_type; - self->service_list = mp_obj_new_list(0, NULL); - self->conn_handler = mp_const_none; - self->conn_handle = 0xFFFF; - - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); - - enum { ARG_address, ARG_scan_entry }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_address, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_scan_entry, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, - }; - - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - const mp_obj_t address_obj = args[ARG_address].u_obj; - const mp_obj_t scan_entry_obj = args[ARG_scan_entry].u_obj; + const mp_obj_t address_obj = pos_args[0]; if (!MP_OBJ_IS_TYPE(address_obj, &bleio_address_type)) { - mp_raise_ValueError("Expected an Address"); + mp_raise_ValueError(translate("Expected an Address")); } + bleio_address_obj_t *address = MP_OBJ_TO_PTR(address_obj); + common_hal_bleio_central_construct(self, address); + return MP_OBJ_FROM_PTR(self); } @@ -109,19 +92,15 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, //| //| Attempts a connection to the remote peripheral. If the connection is successful, //| -STATIC mp_obj_t bleio_central_connect(mp_obj_t self_in) { +STATIC mp_obj_t bleio_central_connect(mp_obj_t self_in, mp_obj_t timeout_in) { bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); - if (self->is_peripheral) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - translate("Can't connect in Peripheral mode"))); - } - - common_hal_bleio_central_connect(self); + mp_float_t timeout = mp_obj_float_get(timeout_in); + common_hal_bleio_central_connect(self, timeout); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_connect_obj, bleio_central_connect); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_central_connect_obj, bleio_central_connect); //| .. method:: disconnect() @@ -137,17 +116,6 @@ STATIC mp_obj_t bleio_central_disconnect(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_disconnect); -//| .. attribute:: remote_name (read-only) -//| -//| The name of the remote peripheral, if connected. May be None if no name was advertised. -//| -STATIC mp_obj_t bleio_central_get_remote_name(mp_obj_t self_in) { - bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); - - return self->remote_name; -} -MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_name_obj, bleio_central_get_remote_name); - //| .. attribute:: remote_services (read-only) //| //| Empty until connected, then a list of services provided by the remote peripheral. @@ -155,7 +123,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_name_obj, bleio_central_get_r STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) { bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); - return self->service_list; + return common_hal_bleio_central_get_remote_services(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services); @@ -172,7 +140,6 @@ STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_central_disconnect_obj) }, // Properties - { MP_ROM_QSTR(MP_QSTR_remote_name), MP_ROM_PTR(&bleio_central_remote_name_obj) }, { MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) }, }; diff --git a/shared-bindings/bleio/Central.h b/shared-bindings/bleio/Central.h index 5ea2119af0..c6fb50bc0c 100644 --- a/shared-bindings/bleio/Central.h +++ b/shared-bindings/bleio/Central.h @@ -31,9 +31,11 @@ #include "common-hal/bleio/Central.h" #include "common-hal/bleio/Service.h" -extern const mp_obj_type_t bleio_device_type; +extern const mp_obj_type_t bleio_central_type; -extern void common_hal_bleio_device_connect(bleio_device_obj_t *device); -extern void common_hal_bleio_device_disconnect(bleio_device_obj_t *device); +extern void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address_obj_t *address); +extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout); +extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self); +extern mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index 859611f91a..050992bb86 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -69,12 +69,12 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mp_obj_t uuid = args[ARG_uuid].u_obj; + const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) { + if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { mp_raise_ValueError(translate("Expected a UUID")); } - bleio_uuid_obj_t *uuid_obj = MP_OBJ_TO_PTR(uuid); + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t); self->base.type = &bleio_characteristic_type; @@ -88,7 +88,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t properties.write = args[ARG_write].u_bool; properties.write_no_response = args[ARG_write_no_response].u_bool; - common_hal_bleio_characteristic_construct(self, uuid_obj, properties); + common_hal_bleio_characteristic_construct(self, uuid, properties); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/bleio/CharacteristicBuffer.c b/shared-bindings/bleio/CharacteristicBuffer.c index da79c5d7ae..827f4947b3 100644 --- a/shared-bindings/bleio/CharacteristicBuffer.c +++ b/shared-bindings/bleio/CharacteristicBuffer.c @@ -86,7 +86,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t); self->base.type = &bleio_characteristic_buffer_type; - common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer_size); + common_hal_bleio_characteristic_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), timeout, buffer_size); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/bleio/Device.h b/shared-bindings/bleio/Device.h deleted file mode 100644 index d19b8c886b..0000000000 --- a/shared-bindings/bleio/Device.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Dan Halbert for Adafruit Industries - * Copyright (c) 2018 Artur Pacholec - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H - -#include "shared-module/bleio/Device.h" -#include "common-hal/bleio/Service.h" - -extern const mp_obj_type_t bleio_device_type; - -extern void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_service_obj_t *service); -extern void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data); -extern void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device); -extern void common_hal_bleio_device_connect(bleio_device_obj_t *device); -extern void common_hal_bleio_device_disconnect(bleio_device_obj_t *device); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index e270c599c6..002999b5d6 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -107,8 +107,8 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar self->base.type = &bleio_peripheral_type; // Copy the services list and validate its items. - mp_obj_t service_list = mp_obj_new_list(0, NULL); - mp_obj_list_t *service_list_obj = MP_OBJ_FROM_PTR(service_list); + mp_obj_t service_list_obj = mp_obj_new_list(0, NULL); + mp_obj_list_t *service_list = MP_OBJ_FROM_PTR(service_list_obj); mp_obj_t service; while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { @@ -128,7 +128,7 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar mp_raise_ValueError(translate("name must be a string")); } - common_hal_bleio_peripheral_construct(self, service_list_obj, name_str); + common_hal_bleio_peripheral_construct(self, service_list, name_str); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index 2719164d88..e687019d14 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -61,9 +61,9 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mp_obj_t uuid = args[ARG_uuid].u_obj; + const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) { + if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { mp_raise_ValueError(translate("Expected a UUID")); } @@ -71,31 +71,31 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, self->base.type = &bleio_service_type; const bool is_secondary = args[ARG_secondary].u_bool; - bleio_uuid_obj_t *uuid_obj = MP_OBJ_TO_PTR(uuid); + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); // If characteristics is not an iterable, an exception will be thrown. mp_obj_iter_buf_t iter_buf; mp_obj_t iterable = mp_getiter(args[ARG_characteristics].u_obj, &iter_buf); - mp_obj_t characteristic; + mp_obj_t characteristic_obj; // Copy the characteristics list and validate its items. - mp_obj_t char_list = mp_obj_new_list(0, NULL); - mp_obj_list_t *char_list_obj = MP_OBJ_FROM_PTR(char_list); + mp_obj_t char_list_obj = mp_obj_new_list(0, NULL); + mp_obj_list_t *char_list = MP_OBJ_FROM_PTR(char_list); - while ((characteristic = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) { + while ((characteristic_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (!MP_OBJ_IS_TYPE(characteristic_obj, &bleio_characteristic_type)) { mp_raise_ValueError(translate("characteristics includes an object that is not a Characteristic")); } - bleio_characteristic_obj_t *characteristic_ptr = MP_OBJ_TO_PTR(characteristic); + bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_obj); if (common_hal_bleio_uuid_get_uuid128_reference(uuid) != - common_hal_bleio_uuid_get_uuid128_reference(characteristic_ptr->uuid)) { + common_hal_bleio_uuid_get_uuid128_reference(characteristic->uuid)) { // The descriptor base UUID doesn't match the characteristic base UUID. mp_raise_ValueError(translate("Characteristic UUID doesn't match Service UUID")); } - mp_obj_list_append(char_list, characteristic); + mp_obj_list_append(char_list_obj, characteristic_obj); } - common_hal_bleio_service_construct(self, uuid_obj, char_list_obj, is_secondary); + common_hal_bleio_service_construct(self, uuid, char_list, is_secondary); return MP_OBJ_FROM_PTR(self); } From 140904ec84ad1900f280c1febaa89a499c42b8c5 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 22 Jun 2019 22:10:15 -0400 Subject: [PATCH 14/25] getting Scanner to work --- ports/nrf/common-hal/bleio/Scanner.c | 17 +++++---- ports/nrf/common-hal/bleio/Scanner.h | 2 +- shared-bindings/bleio/Address.c | 53 ++++++++++++++++++++++++++-- shared-bindings/bleio/Address.h | 2 +- shared-bindings/bleio/ScanEntry.c | 19 +++++----- shared-bindings/bleio/ScanEntry.h | 2 +- shared-bindings/bleio/Scanner.c | 4 +-- shared-bindings/bleio/Scanner.h | 2 +- shared-bindings/bleio/UUID.c | 6 ++++ shared-module/bleio/Address.c | 8 ++--- shared-module/bleio/Address.h | 2 +- shared-module/bleio/ScanEntry.c | 8 ++--- shared-module/bleio/ScanEntry.h | 2 +- 13 files changed, 90 insertions(+), 37 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index 6715bd7a28..04dc62f956 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -57,12 +57,15 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { entry->base.type = &bleio_scanentry_type; entry->rssi = report->rssi; - memcpy(entry->address.bytes, report->data.p_data, NUM_BLEIO_ADDRESS_BYTES); - entry->address.type = report->peer_addr.addr_type; + bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; + common_hal_bleio_address_construct(MP_OBJ_TO_PTR(address), + report->peer_addr.addr, report->peer_addr.addr_type); + entry->address = address; entry->data = mp_obj_new_bytes(report->data.p_data, report->data.len); - mp_obj_list_append(scanner->adv_reports, entry); + mp_obj_list_append(scanner->scan_entries, MP_OBJ_FROM_PTR(entry)); const uint32_t err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer); if (err_code != NRF_SUCCESS) { @@ -71,7 +74,7 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { } void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self) { - self->adv_reports = mp_obj_new_list(0, NULL); + self->scan_entries = mp_obj_new_list(0, NULL); } void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { @@ -85,7 +88,7 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout }; // Empty the advertising reports list. - mp_obj_list_clear(self->adv_reports); + mp_obj_list_clear(self->scan_entries); uint32_t err_code; err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer); @@ -98,6 +101,6 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout sd_ble_gap_scan_stop(); } -mp_obj_t common_hal_bleio_scanner_get_adv_reports(bleio_scanner_obj_t *self) { - return self->adv_reports; +mp_obj_t common_hal_bleio_scanner_get_scan_entries(bleio_scanner_obj_t *self) { + return self->scan_entries; } diff --git a/ports/nrf/common-hal/bleio/Scanner.h b/ports/nrf/common-hal/bleio/Scanner.h index a710664877..3768a52cb8 100644 --- a/ports/nrf/common-hal/bleio/Scanner.h +++ b/ports/nrf/common-hal/bleio/Scanner.h @@ -32,7 +32,7 @@ typedef struct { mp_obj_base_t base; - mp_obj_t adv_reports; // List of reports. + mp_obj_t scan_entries; uint16_t interval; uint16_t window; } bleio_scanner_obj_t; diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index 5875cf9bd8..0e094c2e35 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -80,7 +80,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, mp_raise_ValueError(translate("Address type out of range")); } - common_hal_bleio_address_construct(self, buf_info.buf, buf_info.len, address_type); + common_hal_bleio_address_construct(self, buf_info.buf, address_type); return MP_OBJ_FROM_PTR(self); } @@ -101,6 +101,13 @@ STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_address_bytes_obj, bleio_address_get_address_bytes); +const mp_obj_property_t bleio_address_address_bytes_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&bleio_address_get_address_bytes_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + //| .. attribute:: type //| //| The address type (read-only). One of these integers: @@ -124,9 +131,47 @@ const mp_obj_property_t bleio_address_type_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| .. method:: __eq__(other) +//| +//| Two Address objects are equal if their addresses and address types are equal. +//| +STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + switch (op) { + // Two Addresses are equal if their address bytes and address_type are equal + case MP_BINARY_OP_EQUAL: + if (MP_OBJ_IS_TYPE(rhs_in, &bleio_address_type)) { + bleio_address_obj_t *lhs = MP_OBJ_TO_PTR(lhs_in); + bleio_address_obj_t *rhs = MP_OBJ_TO_PTR(rhs_in); + return mp_obj_new_bool( + mp_obj_equal(common_hal_bleio_address_get_address_bytes(lhs), + common_hal_bleio_address_get_address_bytes(rhs)) && + common_hal_bleio_address_get_type(lhs) == + common_hal_bleio_address_get_type(rhs)); + + } else { + return mp_const_false; + } + + default: + return MP_OBJ_NULL; // op not supported + } +} + +STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t address_bytes = common_hal_bleio_address_get_address_bytes(self); + + mp_buffer_info_t buf_info; + mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ); + const uint8_t *buf = (uint8_t *) buf_info.buf; + mp_printf(print, + "%02x:%02x:%02x:%02x:%02x:%02x", + buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); +} + STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_get_address_bytes_obj) }, - { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_address_get_type_obj) }, + { MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_address_bytes_obj) }, + { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_address_type_obj) }, // These match the BLE_GAP_ADDR_TYPES values used by the nRF library. { MP_ROM_QSTR(MP_QSTR_PUBLIC), MP_OBJ_NEW_SMALL_INT(0) }, { MP_ROM_QSTR(MP_QSTR_RANDOM_STATIC), MP_OBJ_NEW_SMALL_INT(1) }, @@ -141,5 +186,7 @@ const mp_obj_type_t bleio_address_type = { { &mp_type_type }, .name = MP_QSTR_Address, .make_new = bleio_address_make_new, + .print = bleio_address_print, + .binary_op = bleio_address_binary_op, .locals_dict = (mp_obj_dict_t*)&bleio_address_locals_dict }; diff --git a/shared-bindings/bleio/Address.h b/shared-bindings/bleio/Address.h index bff1542cf0..5e02ee210f 100644 --- a/shared-bindings/bleio/Address.h +++ b/shared-bindings/bleio/Address.h @@ -41,7 +41,7 @@ extern const mp_obj_type_t bleio_address_type; -extern void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, size_t bytes_length, uint8_t address_type); +extern void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, uint8_t address_type); extern mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self); extern uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self); diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index 145d2b0236..b7798175cc 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -62,19 +62,19 @@ const mp_obj_property_t bleio_scanentry_address_obj = { (mp_obj_t)&mp_const_none_obj }, }; -//| .. attribute:: raw_data +//| .. attribute:: advertisement_bytes //| //| All the advertisement data present in the packet, returned as a ``bytes`` object. (read-only) //| -STATIC mp_obj_t scanentry_get_raw_data(mp_obj_t self_in) { +STATIC mp_obj_t scanentry_get_advertisement_bytes(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); - return common_hal_bleio_scanentry_get_raw_data(self); + return common_hal_bleio_scanentry_get_advertisement_bytes(self); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_raw_data_obj, scanentry_get_raw_data); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_advertisement_bytes_obj, scanentry_get_advertisement_bytes); -const mp_obj_property_t bleio_scanentry_raw_data_obj = { +const mp_obj_property_t bleio_scanentry_advertisement_bytes_obj = { .base.type = &mp_type_property, - .proxy = { (mp_obj_t)&bleio_scanentry_get_raw_data_obj, + .proxy = { (mp_obj_t)&bleio_scanentry_get_advertisement_bytes_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj }, }; @@ -96,10 +96,11 @@ const mp_obj_property_t bleio_scanentry_rssi_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_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_address), MP_ROM_PTR(&bleio_scanentry_address_obj) }, + { MP_ROM_QSTR(MP_QSTR_advertisement_bytes), MP_ROM_PTR(&bleio_scanentry_advertisement_bytes_obj) }, + { MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&bleio_scanentry_rssi_obj) }, }; STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_dict_table); diff --git a/shared-bindings/bleio/ScanEntry.h b/shared-bindings/bleio/ScanEntry.h index 3a02f2facf..77e93175f9 100644 --- a/shared-bindings/bleio/ScanEntry.h +++ b/shared-bindings/bleio/ScanEntry.h @@ -35,7 +35,7 @@ extern const mp_obj_type_t bleio_scanentry_type; mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self); -mp_obj_t common_hal_bleio_scanentry_get_raw_data(bleio_scanentry_obj_t *self); +mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_t *self); mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index 92f6a2a18b..d50f69fc5b 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -42,7 +42,7 @@ //| :class:`Scanner` -- scan for nearby BLE devices //| ========================================================= //| -//| Allows scanning for nearby BLE devices. +//| Scan for nearby BLE devices. //| //| Usage:: //| @@ -112,7 +112,7 @@ STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_m common_hal_bleio_scanner_scan(self, timeout, interval, window); - return common_hal_bleio_scanner_get_adv_reports(self); + return common_hal_bleio_scanner_get_scan_entries(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanner_scan_obj, 2, bleio_scanner_scan); diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h index b9e3ecdee5..1bbab78f4f 100644 --- a/shared-bindings/bleio/Scanner.h +++ b/shared-bindings/bleio/Scanner.h @@ -36,6 +36,6 @@ extern const mp_obj_type_t bleio_scanner_type; extern void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self); extern void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window); extern void common_hal_bleio_scanner_stop(bleio_scanner_obj_t *self); -extern mp_obj_t common_hal_bleio_scanner_get_adv_reports(bleio_scanner_obj_t *self); +extern mp_obj_t common_hal_bleio_scanner_get_scan_entries(bleio_scanner_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H diff --git a/shared-bindings/bleio/UUID.c b/shared-bindings/bleio/UUID.c index 9725050586..0db7435f44 100644 --- a/shared-bindings/bleio/UUID.c +++ b/shared-bindings/bleio/UUID.c @@ -220,6 +220,12 @@ STATIC mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } +//| + +//| .. method:: __eq__(other) +//| +//| Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit. +//| STATIC mp_obj_t bleio_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { // Two UUID's are equal if their uuid16 values and uuid128 references match. diff --git a/shared-module/bleio/Address.c b/shared-module/bleio/Address.c index e26bbe2acb..6bc458b7cc 100644 --- a/shared-module/bleio/Address.c +++ b/shared-module/bleio/Address.c @@ -27,17 +27,17 @@ #include -#include "py/objproperty.h" +#include "py/objstr.h" #include "shared-bindings/bleio/Address.h" #include "shared-module/bleio/Address.h" -void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, size_t bytes_length, uint8_t address_type) { - memcpy(self->bytes, bytes, bytes_length); +void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, uint8_t address_type) { + self->bytes = mp_obj_new_bytes(bytes, NUM_BLEIO_ADDRESS_BYTES); self->type = address_type; } mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self) { - return mp_obj_new_bytes(self->bytes, NUM_BLEIO_ADDRESS_BYTES); + return self->bytes; } uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self) { diff --git a/shared-module/bleio/Address.h b/shared-module/bleio/Address.h index eb1aab2581..39789842f7 100644 --- a/shared-module/bleio/Address.h +++ b/shared-module/bleio/Address.h @@ -35,7 +35,7 @@ typedef struct { mp_obj_base_t base; uint8_t type; - uint8_t bytes[NUM_BLEIO_ADDRESS_BYTES]; + mp_obj_t bytes; // a bytes() object } bleio_address_obj_t; #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H diff --git a/shared-module/bleio/ScanEntry.c b/shared-module/bleio/ScanEntry.c index 44b50a4ce0..306ac33c58 100644 --- a/shared-module/bleio/ScanEntry.c +++ b/shared-module/bleio/ScanEntry.c @@ -33,14 +33,10 @@ #include "shared-module/bleio/ScanEntry.h" mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self) { - bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); - address->base.type = &bleio_address_type; - memcpy(address->bytes, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES); - address->type = self->address.type; - return MP_OBJ_TO_PTR(address); + return MP_OBJ_FROM_PTR(self->address); } -mp_obj_t common_hal_bleio_scanentry_get_raw_data(bleio_scanentry_obj_t *self) { +mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_t *self) { return self->data; } diff --git a/shared-module/bleio/ScanEntry.h b/shared-module/bleio/ScanEntry.h index 4e7028ba2a..b302460e67 100644 --- a/shared-module/bleio/ScanEntry.h +++ b/shared-module/bleio/ScanEntry.h @@ -35,7 +35,7 @@ typedef struct { mp_obj_base_t base; bool connectable; int8_t rssi; - bleio_address_obj_t address; + bleio_address_obj_t *address; mp_obj_t data; } bleio_scanentry_obj_t; From 6ea01ea9b0334a175419f9d449be25a5838627da Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 29 Jun 2019 00:20:06 -0400 Subject: [PATCH 15/25] Central is connecting; characteristics can be read and written --- ports/nrf/Makefile | 2 +- ports/nrf/common-hal/bleio/Central.c | 151 +++++++++++--------- ports/nrf/common-hal/bleio/Central.h | 3 +- ports/nrf/common-hal/bleio/Characteristic.c | 10 +- ports/nrf/common-hal/bleio/Scanner.c | 4 +- shared-bindings/bleio/Central.c | 59 +++++--- shared-bindings/bleio/Central.h | 4 +- shared-bindings/bleio/Characteristic.c | 17 ++- shared-bindings/bleio/Peripheral.c | 4 +- shared-bindings/bleio/Service.c | 17 ++- shared-bindings/bleio/UUID.c | 3 + shared-bindings/bleio/__init__.c | 5 +- 12 files changed, 182 insertions(+), 97 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 18990485b4..83f87536bd 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -91,7 +91,7 @@ INC += -I../../supervisor/shared/usb ifeq ($(DEBUG), 1) CFLAGS += -ggdb # You may want to enable these flags to make setting breakpoints easier. - # CFLAGS += -fno-inline -fno-ipa-sra + CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -Os -DNDEBUG # TODO: Test with -flto diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c index 5864a8a56f..0eedd2b568 100644 --- a/ports/nrf/common-hal/bleio/Central.c +++ b/ports/nrf/common-hal/bleio/Central.c @@ -44,11 +44,13 @@ static bleio_service_obj_t *m_char_discovery_service; static volatile bool m_discovery_in_process; static volatile bool m_discovery_successful; -STATIC bool discover_next_services(bleio_central_obj_t *self, uint16_t start_handle) { +// service_uuid may be NULL, to discover all services. +STATIC bool discover_next_services(bleio_central_obj_t *self, uint16_t start_handle, ble_uuid_t *service_uuid) { m_discovery_successful = false; m_discovery_in_process = true; - uint32_t err_code = sd_ble_gattc_primary_services_discover(self->conn_handle, start_handle, NULL); + uint32_t err_code = sd_ble_gattc_primary_services_discover(self->conn_handle, start_handle, service_uuid); + if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg(translate("Failed to discover services")); } @@ -88,15 +90,26 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); service->base.type = &bleio_service_type; + service->device = MP_OBJ_FROM_PTR(central); service->characteristic_list = mp_obj_new_list(0, NULL); service->start_handle = gattc_service->handle_range.start_handle; service->end_handle = gattc_service->handle_range.end_handle; service->handle = gattc_service->handle_range.start_handle; - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid); - service->uuid = uuid; + if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) { + // Known service UUID. + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + uuid->base.type = &bleio_uuid_type; + bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid); + service->uuid = uuid; + service->device = MP_OBJ_FROM_PTR(central); + } else { + // The discovery response contained a 128-bit UUID that has not yet been registered with the + // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it. + // For now, just set the UUID to NULL. + service->uuid = NULL; + } mp_obj_list_append(central->service_list, service); } @@ -114,10 +127,18 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); characteristic->base.type = &bleio_characteristic_type; - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); - uuid->base.type = &bleio_uuid_type; - bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); - characteristic->uuid = uuid; + if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) { + // Known characteristic UUID. + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + uuid->base.type = &bleio_uuid_type; + bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); + characteristic->uuid = uuid; + } else { + // The discovery response contained a 128-bit UUID that has not yet been registered with the + // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it. + // For now, just set the UUID to NULL. + characteristic->uuid = NULL; + } characteristic->props.broadcast = gattc_char->char_props.broadcast; characteristic->props.indicate = gattc_char->char_props.indicate; @@ -137,25 +158,18 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio m_discovery_in_process = false; } -STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { +STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { bleio_central_obj_t *central = (bleio_central_obj_t*)central_in; switch (ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: - { - ble_gap_conn_params_t conn_params; central->conn_handle = ble_evt->evt.gap_evt.conn_handle; - - sd_ble_gap_ppcp_get(&conn_params); - sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params); + central->waiting_to_connect = false; break; - } case BLE_GAP_EVT_TIMEOUT: - if (central->attempting_to_connect) { - // Signal that connection attempt has timed out. - central->attempting_to_connect = false; - } + // Handle will be invalid. + central->waiting_to_connect = false; break; case BLE_GAP_EVT_DISCONNECTED: @@ -172,14 +186,6 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, central); break; - case BLE_GATTS_EVT_SYS_ATTR_MISSING: - sd_ble_gatts_sys_attr_set(ble_evt->evt.gatts_evt.conn_handle, NULL, 0, 0); - break; - - case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: - sd_ble_gatts_exchange_mtu_reply(central->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); - break; - case BLE_GAP_EVT_SEC_PARAMS_REQUEST: sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); break; @@ -193,7 +199,7 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *central_in) { } } -void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address_obj_t *address) { +void common_hal_bleio_central_construct(bleio_central_obj_t *self) { common_hal_bleio_adapter_set_enabled(true); self->service_list = mp_obj_new_list(0, NULL); @@ -201,13 +207,16 @@ void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address self->conn_handle = BLE_CONN_HANDLE_INVALID; } -void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout) { +void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids) { common_hal_bleio_adapter_set_enabled(true); - ble_drv_add_event_handler(on_ble_evt, self); + ble_drv_add_event_handler(central_on_ble_evt, self); ble_gap_addr_t addr; - addr.addr_type = self->address.type; - memcpy(addr.addr, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES); + + addr.addr_type = address->type; + mp_buffer_info_t address_buf_info; + mp_get_buffer_raise(address->bytes, &address_buf_info, MP_BUFFER_READ); + memcpy(addr.addr, (uint8_t *) address_buf_info.buf, NUM_BLEIO_ADDRESS_BYTES); ble_gap_scan_params_t scan_params = { .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS), @@ -224,7 +233,7 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time .slave_latency = 0, // number of conn events }; - self->attempting_to_connect = true; + self->waiting_to_connect = true; uint32_t err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM); @@ -232,50 +241,68 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time mp_raise_OSError_msg_varg(translate("Failed to start connecting, error 0x%04x"), err_code); } - while (self->conn_handle == BLE_CONN_HANDLE_INVALID && self->attempting_to_connect) { - #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP - #endif + while (self->waiting_to_connect) { + MICROPY_VM_HOOK_LOOP; } - if (!self->attempting_to_connect) { + if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { mp_raise_OSError_msg(translate("Failed to connect: timeout")); } - // Conenction successful. - // Now discover all services on the remote peripheral. Ask for services repeatedly - // until no more are left. + // Connection successful. + // Now discover services on the remote peripheral. - uint16_t next_start_handle; + if (service_uuids == mp_const_none) { - next_start_handle = BLE_GATT_HANDLE_START; + // List of service UUID's not given, so discover all available services. - while (1) { - if(!discover_next_services(self, next_start_handle)) { - break; + uint16_t next_start_handle = BLE_GATT_HANDLE_START; + + while (discover_next_services(self, next_start_handle, MP_OBJ_NULL)) { + // discover_next_services() appends to service_list. + const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); + + // Get the most recently discovered service, and then ask for services + // whose handles start after the last attribute handle inside that service. + const bleio_service_obj_t *service = service_list->items[service_list->len - 1]; + next_start_handle = service->end_handle + 1; } + } else { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(service_uuids, &iter_buf); + mp_obj_t uuid_obj; + while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { + mp_raise_ValueError(translate("non-UUID found in service_uuids")); + } + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); - // discover_next_services() appends to service_list. - const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); + ble_uuid_t nrf_uuid; + bleio_uuid_convert_to_nrf_ble_uuid(uuid, &nrf_uuid); - // Get the most recently discovered service, and ask for services with handles - // starting after the last attribute handle of t - const bleio_service_obj_t *service = service_list->items[service_list->len - 1]; - next_start_handle = service->end_handle + 1; + // Service might or might not be discovered; that's ok. Caller has to check + // Central.remote_services to find out. + // We only need to call this once for each service to discover. + discover_next_services(self, BLE_GATT_HANDLE_START, &nrf_uuid); + } } - // Now, for each service, discover its characteristics. - // find characteristics in each service + const 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 = service_list->items[i]; - next_start_handle = service->start_handle; + // Skip the service if it had an unknown (unregistered) UUID. + if (service->uuid == NULL) { + continue; + } - while (1) { - if (!discover_next_characteristics(self, service, service->start_handle)) { - break; - } + uint16_t next_start_handle = service->start_handle; + + // Stop when we go past the end of the range of handles for this service or + // discovery call returns nothing. + while (next_start_handle <= service->end_handle && + discover_next_characteristics(self, service, next_start_handle)) { // discover_next_characteristics() appends to the characteristic_list. const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); @@ -284,10 +311,6 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t time const bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_list->len - 1]; next_start_handle = characteristic->handle + 1; - if (next_start_handle >= service->end_handle) { - // Went past the end of the range of handles for this service. - break; - } } } } diff --git a/ports/nrf/common-hal/bleio/Central.h b/ports/nrf/common-hal/bleio/Central.h index ba4a92187b..8b38e87ac0 100644 --- a/ports/nrf/common-hal/bleio/Central.h +++ b/ports/nrf/common-hal/bleio/Central.h @@ -36,8 +36,7 @@ typedef struct { mp_obj_base_t base; gatt_role_t gatt_role; - bleio_address_obj_t address; - volatile bool attempting_to_connect; + volatile bool waiting_to_connect; volatile uint16_t conn_handle; mp_obj_t service_list; } bleio_central_obj_t; diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index d2f961fe65..ea43d8a8ab 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -60,7 +60,7 @@ STATIC uint16_t get_cccd(bleio_characteristic_obj_t *characteristic) { } STATIC void gatts_read(bleio_characteristic_obj_t *characteristic) { - // This might be BLE_CONN_HANDLE_INVALID if we're not conected, but that's OK, because + // This might be BLE_CONN_HANDLE_INVALID if we're not connected, but that's OK, because // we can still read and write the local value. const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device); @@ -135,8 +135,15 @@ STATIC void gatts_notify_indicate(bleio_characteristic_obj_t *characteristic, mp } +STATIC void check_connected(uint16_t conn_handle) { + if (conn_handle == BLE_CONN_HANDLE_INVALID) { + mp_raise_OSError_msg(translate("Not connected")); + } +} + STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) { const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device); + check_connected(conn_handle); m_read_characteristic = characteristic; @@ -152,6 +159,7 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) { STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) { const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device); + check_connected(conn_handle); ble_gattc_write_params_t write_params = { .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL, diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index 04dc62f956..fa4f3923c8 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -45,7 +45,7 @@ static ble_data_t m_scan_buffer = { BLE_GAP_SCAN_BUFFER_MIN }; -STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { +STATIC void scanner_on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { bleio_scanner_obj_t *scanner = (bleio_scanner_obj_t*)scanner_in; ble_gap_evt_adv_report_t *report = &ble_evt->evt.gap_evt.params.adv_report; @@ -79,7 +79,7 @@ void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self) { void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { common_hal_bleio_adapter_set_enabled(true); - ble_drv_add_event_handler(on_ble_evt, self); + ble_drv_add_event_handler(scanner_on_ble_evt, self); ble_gap_scan_params_t scan_params = { .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS), diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c index b3be906067..dd2dd0d50f 100644 --- a/shared-bindings/bleio/Central.c +++ b/shared-bindings/bleio/Central.c @@ -64,43 +64,68 @@ //| central.connect(10.0) # timeout after 10 seconds //| -//| .. class:: Central(address) +//| .. class:: Central() //| //| Create a new Central object. -//| :param bleio.Address address: The address of the central to connect to //| STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_arg_check_num(n_args, kw_args, 0, 0, false); bleio_central_obj_t *self = m_new_obj(bleio_central_obj_t); self->base.type = &bleio_central_type; - const mp_obj_t address_obj = pos_args[0]; - if (!MP_OBJ_IS_TYPE(address_obj, &bleio_address_type)) { - mp_raise_ValueError(translate("Expected an Address")); - } - - bleio_address_obj_t *address = MP_OBJ_TO_PTR(address_obj); - common_hal_bleio_central_construct(self, address); + common_hal_bleio_central_construct(self); return MP_OBJ_FROM_PTR(self); } -//| .. method:: connect() -//| +//| .. method:: connect(address, timeout, *, service_uuids=None) //| Attempts a connection to the remote peripheral. If the connection is successful, +//| Do BLE discovery for the listed services, to find their handles and characteristics. +//| The attribute `remote_services` will contain a list of all discovered services. //| -STATIC mp_obj_t bleio_central_connect(mp_obj_t self_in, mp_obj_t timeout_in) { - bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); +//| :param bleio.Address address: The address of the peripheral to connect to +//| :param float/int timeout: Try to connect for timeout seconds. +//| :param iterable service_uuids: a collection of `UUID` objects for the services +//| provided by the peripheral that you want to use. +//| The peripheral may provide more services, but services not listed are ignored. +//| If a service in `service_uuids` is not found during discovery, it will not +//| appear in `remote_services`. +//| +//| If `services` is None, then all services will undergo discovery, which can be slow. +//| +//| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you +//| you must have already created a `UUID` object for that UUID in order for the +//| service or characteristic to be discovered. (This restriction may be lifted in the future.) +//| +STATIC mp_obj_t bleio_central_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + bleio_central_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - mp_float_t timeout = mp_obj_float_get(timeout_in); - common_hal_bleio_central_connect(self, timeout); + enum { ARG_address, ARG_timeout, ARG_service_uuids }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_timeout, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_service_uuids, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + }; + + 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); + + if (!MP_OBJ_IS_TYPE(args[ARG_address].u_obj, &bleio_address_type)) { + mp_raise_ValueError(translate("Expected an Address")); + } + + bleio_address_obj_t *address = MP_OBJ_TO_PTR(args[ARG_address].u_obj); + mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); + + // common_hal_bleio_central_connect() will validate that services is an iterable or None. + common_hal_bleio_central_connect(self, address, timeout, args[ARG_service_uuids].u_obj); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_central_connect_obj, bleio_central_connect); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_central_connect_obj, 3, bleio_central_connect); //| .. method:: disconnect() diff --git a/shared-bindings/bleio/Central.h b/shared-bindings/bleio/Central.h index c6fb50bc0c..542ba8fa2f 100644 --- a/shared-bindings/bleio/Central.h +++ b/shared-bindings/bleio/Central.h @@ -33,8 +33,8 @@ extern const mp_obj_type_t bleio_central_type; -extern void common_hal_bleio_central_construct(bleio_central_obj_t *self, bleio_address_obj_t *address); -extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, mp_float_t timeout); +extern void common_hal_bleio_central_construct(bleio_central_obj_t *self); +extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids); extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self); extern mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self); diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index 050992bb86..ede38c86b3 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -205,11 +205,13 @@ const mp_obj_property_t bleio_characteristic_write_no_response_obj = { //| .. attribute:: uuid //| //| The UUID of this characteristic. (read-only) +//| Will be ``None`` if the 128-bit UUID for this characteristic is not known. //| STATIC mp_obj_t bleio_characteristic_get_uuid(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_FROM_PTR(common_hal_bleio_characteristic_get_uuid(self)); + bleio_uuid_obj_t *uuid = common_hal_bleio_characteristic_get_uuid(self); + return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_uuid_obj, bleio_characteristic_get_uuid); @@ -262,12 +264,23 @@ STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&bleio_characteristic_write_obj) }, { MP_ROM_QSTR(MP_QSTR_write_no_response), MP_ROM_PTR(&bleio_characteristic_write_no_response_obj) }, }; - STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_locals_dict, bleio_characteristic_locals_dict_table); +STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "Characteristic("); + if (self->uuid) { + bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind); + } else { + mp_printf(print, "Unregistered uUID"); + } + mp_printf(print, ")"); +} + const mp_obj_type_t bleio_characteristic_type = { { &mp_type_type }, .name = MP_QSTR_Characteristic, .make_new = bleio_characteristic_make_new, + .print = bleio_characteristic_print, .locals_dict = (mp_obj_dict_t*)&bleio_characteristic_locals_dict }; diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 002999b5d6..37a765ae9c 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -113,7 +113,7 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar mp_obj_t service; while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!MP_OBJ_IS_TYPE(service, &bleio_service_type)) { - mp_raise_ValueError(translate("services includes an object that is not a Service")); + mp_raise_ValueError(translate("non-Service found in services")); } mp_obj_list_append(service_list, service); } @@ -237,7 +237,7 @@ STATIC mp_obj_t bleio_peripheral_start_advertising(mp_uint_t n_args, const mp_ob return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_start_advertising_obj, 0, bleio_peripheral_start_advertising); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_start_advertising_obj, 2, bleio_peripheral_start_advertising); //| .. method:: stop_advertising() //| diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index e687019d14..e6bb7dcc3f 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -140,11 +140,13 @@ const mp_obj_property_t bleio_service_secondary_obj = { //| .. attribute:: uuid //| //| The UUID of this service. (read-only) +//| Will be ``None`` if the 128-bit UUID for this service is not known. //| STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_FROM_PTR(common_hal_bleio_service_get_uuid(self)); + bleio_uuid_obj_t *uuid = common_hal_bleio_service_get_uuid(self); + return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_uuid_obj, bleio_service_get_uuid); @@ -160,12 +162,23 @@ STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_secondary), MP_ROM_PTR(&bleio_service_secondary_obj) }, { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_service_uuid_obj) }, }; - STATIC MP_DEFINE_CONST_DICT(bleio_service_locals_dict, bleio_service_locals_dict_table); +STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "Service("); + if (self->uuid) { + bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind); + } else { + mp_printf(print, "unregistered UUID"); + } + mp_printf(print, ")"); +} + const mp_obj_type_t bleio_service_type = { { &mp_type_type }, .name = MP_QSTR_Service, .make_new = bleio_service_make_new, + .print = bleio_service_print, .locals_dict = (mp_obj_dict_t*)&bleio_service_locals_dict }; diff --git a/shared-bindings/bleio/UUID.c b/shared-bindings/bleio/UUID.c index 0db7435f44..dca7ea0109 100644 --- a/shared-bindings/bleio/UUID.c +++ b/shared-bindings/bleio/UUID.c @@ -50,6 +50,9 @@ //| - a buffer object (bytearray, bytes) of 16 bytes in little-endian order (128-bit UUID) //| - a string of hex digits of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' //| +//| Creating a 128-bit UUID registers the UUID with the onboard BLE software, and provides a +//| temporary 16-bit UUID that can be used in place of the full 128-bit UUID. +//| //| :param value: The uuid value to encapsulate //| :type value: int or typing.ByteString //| diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index ca45a846ec..9e80b49e37 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -28,9 +28,10 @@ #include "shared-bindings/bleio/__init__.h" #include "shared-bindings/bleio/Address.h" +#include "shared-bindings/bleio/Central.h" #include "shared-bindings/bleio/Characteristic.h" #include "shared-bindings/bleio/CharacteristicBuffer.h" -#include "shared-bindings/bleio/Descriptor.h" +// #include "shared-bindings/bleio/Descriptor.h" #include "shared-bindings/bleio/Peripheral.h" #include "shared-bindings/bleio/ScanEntry.h" #include "shared-bindings/bleio/Scanner.h" @@ -74,7 +75,7 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) }, { MP_ROM_QSTR(MP_QSTR_Address), MP_ROM_PTR(&bleio_address_type) }, -// { MP_ROM_QSTR(MP_QSTR_Central), MP_ROM_PTR(&bleio_central_type) }, + { MP_ROM_QSTR(MP_QSTR_Central), MP_ROM_PTR(&bleio_central_type) }, { MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) }, { MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) }, // { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) }, From bf8a35b2f835fbc97d54867f8e21b486a46c245b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 2 Jul 2019 22:34:54 -0400 Subject: [PATCH 16/25] WIP: CharacteristicBuffer for Central; not working: need to set remote Characteristic Service --- ports/nrf/common-hal/bleio/Central.c | 61 +++++++------ ports/nrf/common-hal/bleio/Characteristic.c | 47 +++++----- .../common-hal/bleio/CharacteristicBuffer.c | 45 ++++++--- ports/nrf/common-hal/bleio/Peripheral.c | 91 ++++++++++--------- shared-bindings/bleio/Central.c | 26 +++++- shared-bindings/bleio/Central.h | 1 + shared-bindings/bleio/CharacteristicBuffer.c | 9 +- shared-bindings/bleio/Peripheral.c | 1 - shared-bindings/bleio/Service.c | 2 +- 9 files changed, 164 insertions(+), 119 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c index 0eedd2b568..5bd5a6321e 100644 --- a/ports/nrf/common-hal/bleio/Central.c +++ b/ports/nrf/common-hal/bleio/Central.c @@ -162,40 +162,41 @@ STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { bleio_central_obj_t *central = (bleio_central_obj_t*)central_in; switch (ble_evt->header.evt_id) { - case BLE_GAP_EVT_CONNECTED: - central->conn_handle = ble_evt->evt.gap_evt.conn_handle; - central->waiting_to_connect = false; - break; + case BLE_GAP_EVT_CONNECTED: + central->conn_handle = ble_evt->evt.gap_evt.conn_handle; + central->waiting_to_connect = false; + break; - case BLE_GAP_EVT_TIMEOUT: - // Handle will be invalid. - central->waiting_to_connect = false; - break; + case BLE_GAP_EVT_TIMEOUT: + // Handle will be invalid. + central->waiting_to_connect = false; + break; - case BLE_GAP_EVT_DISCONNECTED: - central->conn_handle = BLE_CONN_HANDLE_INVALID; - m_discovery_successful = false; - m_discovery_in_process = false; - break; + case BLE_GAP_EVT_DISCONNECTED: + central->conn_handle = BLE_CONN_HANDLE_INVALID; + m_discovery_successful = false; + m_discovery_in_process = false; + break; - case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: - on_primary_srv_discovery_rsp(&ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp, central); - break; + case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: + on_primary_srv_discovery_rsp(&ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp, central); + break; - case BLE_GATTC_EVT_CHAR_DISC_RSP: - on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, central); - break; + case BLE_GATTC_EVT_CHAR_DISC_RSP: + on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, central); + break; - case BLE_GAP_EVT_SEC_PARAMS_REQUEST: - sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); - break; + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); + break; - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: - { - ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request; - sd_ble_gap_conn_param_update(central->conn_handle, &request->conn_params); - break; - } + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: + { + ble_gap_evt_conn_param_update_request_t *request = + &ble_evt->evt.gap_evt.params.conn_param_update_request; + sd_ble_gap_conn_param_update(central->conn_handle, &request->conn_params); + break; + } } } @@ -319,6 +320,10 @@ void common_hal_bleio_central_disconnect(bleio_central_obj_t *self) { sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); } +bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self) { + return self->conn_handle != BLE_CONN_HANDLE_INVALID; +} + mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) { return self->service_list; } diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index ea43d8a8ab..c00d8c30bf 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -249,34 +249,35 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, uint16_t cccd = 0; switch (common_hal_bleio_device_get_gatt_role(self->service->device)) { - case GATT_ROLE_SERVER: - if (self->props.notify || self->props.indicate) { - cccd = get_cccd(self); - } - // It's possible that both notify and indicate are set. - if (self->props.notify && (cccd & BLE_GATT_HVX_NOTIFICATION)) { - gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_NOTIFICATION); - sent = true; - } - if (self->props.indicate && (cccd & BLE_GATT_HVX_INDICATION)) { - gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_INDICATION); - sent = true; - } - if (!sent) { - gatts_write(self, bufinfo); - } - break; + case GATT_ROLE_SERVER: + if (self->props.notify || self->props.indicate) { + cccd = get_cccd(self); + } + // It's possible that both notify and indicate are set. + if (self->props.notify && (cccd & BLE_GATT_HVX_NOTIFICATION)) { + gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_NOTIFICATION); + sent = true; + } + if (self->props.indicate && (cccd & BLE_GATT_HVX_INDICATION)) { + gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_INDICATION); + sent = true; + } + if (!sent) { + gatts_write(self, bufinfo); + } + break; - case GATT_ROLE_CLIENT: - gattc_write(self, bufinfo); - break; + case GATT_ROLE_CLIENT: + gattc_write(self, bufinfo); + break; - default: - mp_raise_RuntimeError(translate("bad GATT role")); - break; + default: + mp_raise_RuntimeError(translate("bad GATT role")); + break; } } + bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) { return self->uuid; } diff --git a/ports/nrf/common-hal/bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/bleio/CharacteristicBuffer.c index 19b3b85ea7..59eaaf02b9 100644 --- a/ports/nrf/common-hal/bleio/CharacteristicBuffer.c +++ b/ports/nrf/common-hal/bleio/CharacteristicBuffer.c @@ -40,25 +40,42 @@ #include "common-hal/bleio/__init__.h" #include "common-hal/bleio/CharacteristicBuffer.h" +STATIC void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *data, uint16_t len) { + // Push all the data onto the ring buffer. + uint8_t is_nested_critical_region; + sd_nvic_critical_region_enter(&is_nested_critical_region); + for (size_t i = 0; i < len; i++) { + ringbuf_put(&self->ringbuf, data[i]); + } + sd_nvic_critical_region_exit(is_nested_critical_region); +} + STATIC void characteristic_buffer_on_ble_evt(ble_evt_t *ble_evt, void *param) { bleio_characteristic_buffer_obj_t *self = (bleio_characteristic_buffer_obj_t *) param; switch (ble_evt->header.evt_id) { - case BLE_GATTS_EVT_WRITE: { - ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write; - // Event handle must match the handle for my characteristic. - if (evt_write->handle == self->characteristic->handle) { - // Push all the data onto the ring buffer. - uint8_t is_nested_critical_region; - sd_nvic_critical_region_enter(&is_nested_critical_region); - for (size_t i = 0; i < evt_write->len; i++) { - ringbuf_put(&self->ringbuf, evt_write->data[i]); + case BLE_GATTS_EVT_WRITE: { + // A client wrote to this server characteristic. + + ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write; + // Event handle must match the handle for my characteristic. + if (evt_write->handle == self->characteristic->handle) { + write_to_ringbuf(self, evt_write->data, evt_write->len); + } + break; + } + + case BLE_GATTC_EVT_HVX: { + // A remote service wrote to this characteristic. + + ble_gattc_evt_hvx_t* evt_hvx = &ble_evt->evt.gattc_evt.params.hvx; + // Must be a notification, and event handle must match the handle for my characteristic. + if (evt_hvx->type == BLE_GATT_HVX_NOTIFICATION && + evt_hvx->handle == self->characteristic->handle) { + write_to_ringbuf(self, evt_hvx->data, evt_hvx->len); } - sd_nvic_critical_region_exit(is_nested_critical_region); break; } } - } - } // Assumes that timeout and buffer_size have been validated before call. @@ -82,13 +99,11 @@ int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_ // Wait for all bytes received or timeout while ( (ringbuf_count(&self->ringbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { -#ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP ; + MICROPY_VM_HOOK_LOOP; // Allow user to break out of a timeout with a KeyboardInterrupt. if ( mp_hal_is_interrupted() ) { return 0; } -#endif } // Copy received data. Lock out write interrupt handler while copying. diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 69e75ff27d..fc9a146c31 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -62,60 +62,61 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { bleio_peripheral_obj_t *self = (bleio_peripheral_obj_t*)self_in; switch (ble_evt->header.evt_id) { - case BLE_GAP_EVT_CONNECTED: { - // Central has connected. - ble_gap_conn_params_t conn_params; - self->conn_handle = ble_evt->evt.gap_evt.conn_handle; - sd_ble_gap_ppcp_get(&conn_params); - sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params); - break; - } + case BLE_GAP_EVT_CONNECTED: { + // Central has connected. + ble_gap_conn_params_t conn_params; + self->conn_handle = ble_evt->evt.gap_evt.conn_handle; + sd_ble_gap_ppcp_get(&conn_params); + sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params); + break; + } - case BLE_GAP_EVT_DISCONNECTED: - // Central has disconnected. - self->conn_handle = BLE_CONN_HANDLE_INVALID; - break; + case BLE_GAP_EVT_DISCONNECTED: + // Central has disconnected. + self->conn_handle = BLE_CONN_HANDLE_INVALID; + break; - case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { - ble_gap_phys_t const phys = { - .rx_phys = BLE_GAP_PHY_AUTO, - .tx_phys = BLE_GAP_PHY_AUTO, - }; - sd_ble_gap_phy_update(ble_evt->evt.gap_evt.conn_handle, &phys); - break; - } + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { + ble_gap_phys_t const phys = { + .rx_phys = BLE_GAP_PHY_AUTO, + .tx_phys = BLE_GAP_PHY_AUTO, + }; + sd_ble_gap_phy_update(ble_evt->evt.gap_evt.conn_handle, &phys); + break; + } - case BLE_GAP_EVT_ADV_SET_TERMINATED: - // Someday may handle timeouts or limit reached. - break; + case BLE_GAP_EVT_ADV_SET_TERMINATED: + // Someday may handle timeouts or limit reached. + break; - case BLE_GAP_EVT_SEC_PARAMS_REQUEST: - sd_ble_gap_sec_params_reply(self->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); - break; + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + sd_ble_gap_sec_params_reply(self->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); + break; - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: { - ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request; - sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params); - break; - } + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: { + ble_gap_evt_conn_param_update_request_t *request = + &ble_evt->evt.gap_evt.params.conn_param_update_request; + sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params); + break; + } - case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: - sd_ble_gap_data_length_update(self->conn_handle, NULL, NULL); - break; + case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: + sd_ble_gap_data_length_update(self->conn_handle, NULL, NULL); + break; - case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: { - sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); - break; - } + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: { + sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); + break; + } - case BLE_GATTS_EVT_SYS_ATTR_MISSING: - sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); - break; + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); + break; - default: - // For debugging. - // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id); - break; + default: + // For debugging. + // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id); + break; } } diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c index dd2dd0d50f..efadcbb2ab 100644 --- a/shared-bindings/bleio/Central.c +++ b/shared-bindings/bleio/Central.c @@ -141,6 +141,25 @@ STATIC mp_obj_t bleio_central_disconnect(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_disconnect); +//| .. attribute:: connected +//| +//| True if connected to a remove peripheral. +//| +STATIC mp_obj_t bleio_central_get_connected(mp_obj_t self_in) { + bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_bool(common_hal_bleio_central_get_connected(self)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_connected_obj, bleio_central_get_connected); + +const mp_obj_property_t bleio_central_connected_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_central_get_connected_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + + //| .. attribute:: remote_services (read-only) //| //| Empty until connected, then a list of services provided by the remote peripheral. @@ -161,11 +180,12 @@ const mp_obj_property_t bleio_central_remote_services_obj = { STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = { // Methods - { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_central_connect_obj) }, - { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_central_disconnect_obj) }, + { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_central_connect_obj) }, + { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_central_disconnect_obj) }, // Properties - { MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) }, + { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_central_connected_obj) }, + { MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) }, }; STATIC MP_DEFINE_CONST_DICT(bleio_central_locals_dict, bleio_central_locals_dict_table); diff --git a/shared-bindings/bleio/Central.h b/shared-bindings/bleio/Central.h index 542ba8fa2f..2ca4239454 100644 --- a/shared-bindings/bleio/Central.h +++ b/shared-bindings/bleio/Central.h @@ -36,6 +36,7 @@ extern const mp_obj_type_t bleio_central_type; extern void common_hal_bleio_central_construct(bleio_central_obj_t *self); extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids); extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self); +extern bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self); extern mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H diff --git a/shared-bindings/bleio/CharacteristicBuffer.c b/shared-bindings/bleio/CharacteristicBuffer.c index 827f4947b3..26f9e012b5 100644 --- a/shared-bindings/bleio/CharacteristicBuffer.c +++ b/shared-bindings/bleio/CharacteristicBuffer.c @@ -49,10 +49,13 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self //| //| .. class:: CharacteristicBuffer(characteristic, *, timeout=1, buffer_size=64) //| -//| Create a new Characteristic object identified by the specified UUID. +//| Monitor the given Characteristic. Each time a new value is written to the Characteristic +//| add the newly-written bytes to a FIFO buffer. //| -//| :param bleio.Characteristic characteristic: The characteristic to monitor -//| :param int timeout: the timeout in seconds to wait for the first character and between subsequent characters.//| +//| :param bleio.Characteristic characteristic: The Characteristic to monitor. +//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic +//| in a remote Service that a Central has connected to. +//| :param int timeout: the timeout in seconds to wait for the first character and between subsequent characters. //| :param int buffer_size: Size of ring buffer that stores incoming data coming from client. //| Must be >= 1. //| diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 37a765ae9c..665f5baafe 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -140,7 +140,6 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar STATIC mp_obj_t bleio_peripheral_get_connected(mp_obj_t self_in) { bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); - // Return list as a tuple so user won't be able to change it. return mp_obj_new_bool(common_hal_bleio_peripheral_get_connected(self)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_connected_obj, bleio_peripheral_get_connected); diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index e6bb7dcc3f..f8993ef619 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -80,7 +80,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, // Copy the characteristics list and validate its items. mp_obj_t char_list_obj = mp_obj_new_list(0, NULL); - mp_obj_list_t *char_list = MP_OBJ_FROM_PTR(char_list); + mp_obj_list_t *char_list = MP_OBJ_TO_PTR(char_list_obj); while ((characteristic_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!MP_OBJ_IS_TYPE(characteristic_obj, &bleio_characteristic_type)) { From 09ddff8df1349c590e6c0533b6f5085fbcb92483 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 7 Jul 2019 00:07:47 -0400 Subject: [PATCH 17/25] WIP: Need descriptors for Central CCCD discovery; not done yet --- ports/nrf/common-hal/bleio/Central.c | 163 ++++++++++++++++---- ports/nrf/common-hal/bleio/Central.h | 3 +- ports/nrf/common-hal/bleio/Characteristic.c | 27 ++-- ports/nrf/common-hal/bleio/Characteristic.h | 3 +- ports/nrf/common-hal/bleio/Descriptor.c | 1 - ports/nrf/common-hal/bleio/Descriptor.h | 2 + ports/nrf/common-hal/bleio/Peripheral.c | 4 + ports/nrf/common-hal/bleio/Service.c | 9 +- ports/nrf/common-hal/bleio/Service.h | 3 +- shared-bindings/bleio/Central.c | 4 +- shared-bindings/bleio/Central.h | 2 +- shared-bindings/bleio/Descriptor.c | 3 - shared-bindings/bleio/Peripheral.c | 16 ++ shared-bindings/bleio/Peripheral.h | 1 + 14 files changed, 183 insertions(+), 58 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c index 5bd5a6321e..f7077f4b9a 100644 --- a/ports/nrf/common-hal/bleio/Central.c +++ b/ports/nrf/common-hal/bleio/Central.c @@ -37,10 +37,13 @@ #include "shared-bindings/bleio/Adapter.h" #include "shared-bindings/bleio/Characteristic.h" #include "shared-bindings/bleio/Central.h" +#include "shared-bindings/bleio/Descriptor.h" #include "shared-bindings/bleio/Service.h" #include "shared-bindings/bleio/UUID.h" static bleio_service_obj_t *m_char_discovery_service; +static bleio_characteristic_obj_t *m_desc_discovery_characteristic; + static volatile bool m_discovery_in_process; static volatile bool m_discovery_successful; @@ -84,6 +87,28 @@ STATIC bool discover_next_characteristics(bleio_central_obj_t *self, bleio_servi return m_discovery_successful; } +STATIC bool discover_next_descriptors(bleio_central_obj_t *self, bleio_characteristic_obj_t *characteristic, uint16_t start_handle, uint16_t end_handle) { + m_desc_discovery_characteristic = characteristic; + + ble_gattc_handle_range_t handle_range; + handle_range.start_handle = start_handle; + handle_range.end_handle = end_handle; + + m_discovery_successful = false; + m_discovery_in_process = true; + + uint32_t err_code = sd_ble_gattc_characteristics_discover(self->conn_handle, &handle_range); + if (err_code != NRF_SUCCESS) { + return false; + } + + // Wait for a discovery event. + while (m_discovery_in_process) { + MICROPY_VM_HOOK_LOOP; + } + return m_discovery_successful; +} + STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *response, bleio_central_obj_t *central) { for (size_t i = 0; i < response->count; ++i) { ble_gattc_service_t *gattc_service = &response->services[i]; @@ -127,25 +152,30 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); characteristic->base.type = &bleio_characteristic_type; + bleio_uuid_obj_t *uuid = NULL; + if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) { // Known characteristic UUID. - bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + uuid = m_new_obj(bleio_uuid_obj_t); uuid->base.type = &bleio_uuid_type; bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid); - characteristic->uuid = uuid; } else { // The discovery response contained a 128-bit UUID that has not yet been registered with the // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it. - // For now, just set the UUID to NULL. - characteristic->uuid = NULL; + // For now, just leave the UUID as NULL. } - characteristic->props.broadcast = gattc_char->char_props.broadcast; - characteristic->props.indicate = gattc_char->char_props.indicate; - characteristic->props.notify = gattc_char->char_props.notify; - characteristic->props.read = gattc_char->char_props.read; - characteristic->props.write = gattc_char->char_props.write; - characteristic->props.write_no_response = gattc_char->char_props.write_wo_resp; + bleio_characteristic_properties_t props; + + props.broadcast = gattc_char->char_props.broadcast; + props.indicate = gattc_char->char_props.indicate; + props.notify = gattc_char->char_props.notify; + props.read = gattc_char->char_props.read; + props.write = gattc_char->char_props.write; + props.write_no_response = gattc_char->char_props.write_wo_resp; + + // Call common_hal_bleio_characteristic_construct() to set up evt handler. + common_hal_bleio_characteristic_construct(characteristic, uuid, props); characteristic->handle = gattc_char->handle_value; characteristic->service = m_char_discovery_service; @@ -158,6 +188,39 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio m_discovery_in_process = false; } +STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, bleio_central_obj_t *central) { + for (size_t i = 0; i < response->count; ++i) { + ble_gattc_desc_t *gattc_desc = &response->descs[i]; + + bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); + descriptor->base.type = &bleio_descriptor_type; + + bleio_uuid_obj_t *uuid = NULL; + + if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) { + // Known descriptor UUID. + uuid = m_new_obj(bleio_uuid_obj_t); + uuid->base.type = &bleio_uuid_type; + bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid); + } else { + // The discovery response contained a 128-bit UUID that has not yet been registered with the + // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it. + // For now, just leave the UUID as NULL. + } + + common_hal_bleio_descriptor_construct(descriptor, uuid); + descriptor->handle = gattc_desc->handle; + descriptor->characteristic = m_desc_discovery_characteristic; + + mp_obj_list_append(m_desc_discovery_characteristic->descriptor_list, MP_OBJ_FROM_PTR(descriptor)); + } + + if (response->count > 0) { + m_discovery_successful = true; + } + m_discovery_in_process = false; +} + STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { bleio_central_obj_t *central = (bleio_central_obj_t*)central_in; @@ -186,17 +249,24 @@ STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, central); break; + case BLE_GATTC_EVT_DESC_DISC_RSP: + on_desc_discovery_rsp(&ble_evt->evt.gattc_evt.params.desc_disc_rsp, central); + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); break; - case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: - { + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: { ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request; sd_ble_gap_conn_param_update(central->conn_handle, &request->conn_params); break; } + + default: + // For debugging. + mp_printf(&mp_plat_print, "Unhandled central event: 0x%04x\n", ble_evt->header.evt_id); + break; } } @@ -257,16 +327,16 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_o // List of service UUID's not given, so discover all available services. - uint16_t next_start_handle = BLE_GATT_HANDLE_START; + uint16_t next_service_start_handle = BLE_GATT_HANDLE_START; - while (discover_next_services(self, next_start_handle, MP_OBJ_NULL)) { + while (discover_next_services(self, next_service_start_handle, MP_OBJ_NULL)) { // discover_next_services() appends to service_list. - const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list); // Get the most recently discovered service, and then ask for services // whose handles start after the last attribute handle inside that service. - const bleio_service_obj_t *service = service_list->items[service_list->len - 1]; - next_start_handle = service->end_handle + 1; + const bleio_service_obj_t *service = + MP_OBJ_TO_PTR(self->service_list->items[self->service_list->len - 1]); + next_service_start_handle = service->end_handle + 1; } } else { mp_obj_iter_buf_t iter_buf; @@ -289,30 +359,65 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_o } - const 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 = service_list->items[i]; + for (size_t service_idx = 0; service_idx < self->service_list->len; ++service_idx) { + bleio_service_obj_t *service = MP_OBJ_TO_PTR(self->service_list->items[service_idx]); // Skip the service if it had an unknown (unregistered) UUID. if (service->uuid == NULL) { continue; } - uint16_t next_start_handle = service->start_handle; + uint16_t next_char_start_handle = service->start_handle; // Stop when we go past the end of the range of handles for this service or // discovery call returns nothing. - while (next_start_handle <= service->end_handle && - discover_next_characteristics(self, service, next_start_handle)) { + // discover_next_characteristics() appends to the characteristic_list. + while (next_char_start_handle <= service->end_handle && + discover_next_characteristics(self, service, next_char_start_handle)) { - // discover_next_characteristics() appends to the characteristic_list. - const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list); - // Get the most recently discovered characteristic. + // Get the most recently discovered characteristic, and then ask for characteristics + // whose handles start after the last attribute handle inside that characteristic. const bleio_characteristic_obj_t *characteristic = - characteristic_list->items[characteristic_list->len - 1]; - next_start_handle = characteristic->handle + 1; + MP_OBJ_TO_PTR(service->characteristic_list->items[service->characteristic_list->len - 1]); + next_char_start_handle = characteristic->handle + 1; } + + // Got characteristics for this service. Now discover descriptors for each characteristic. + for (size_t char_idx = 0; char_idx < service->characteristic_list->len; ++char_idx) { + bleio_characteristic_obj_t *characteristic = + MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx]); + const bool last_characteristic = char_idx == service->characteristic_list->len - 1; + bleio_characteristic_obj_t *next_characteristic = last_characteristic + ? NULL + : MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx + 1]); + + // Skip the characteristic if it had an unknown (unregistered) UUID. + if (characteristic->uuid == NULL) { + continue; + } + + uint16_t next_desc_start_handle = characteristic->handle + 1; + + // Don't run past the end of this service or the beginning of the next characteristic. + uint16_t next_desc_end_handle = next_characteristic == NULL + ? service->end_handle + : next_characteristic->handle; + + // Stop when we go past the end of the range of handles for this service or + // discovery call returns nothing. + // discover_next_descriptors() appends to the descriptor_list. + while (next_desc_start_handle <= service->end_handle && + discover_next_descriptors(self, characteristic, next_desc_start_handle, next_desc_end_handle)) { + + // Get the most recently discovered descriptor, and then ask for descriptors + // whose handles start after that descriptor's handle. + const bleio_descriptor_obj_t *descriptor = + MP_OBJ_TO_PTR(characteristic->descriptor_list->items[characteristic->descriptor_list->len - 1]); + next_desc_start_handle = descriptor->handle + 1; + } + } + } } @@ -324,6 +429,6 @@ bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self) { return self->conn_handle != BLE_CONN_HANDLE_INVALID; } -mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) { +mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) { return self->service_list; } diff --git a/ports/nrf/common-hal/bleio/Central.h b/ports/nrf/common-hal/bleio/Central.h index 8b38e87ac0..ac16700888 100644 --- a/ports/nrf/common-hal/bleio/Central.h +++ b/ports/nrf/common-hal/bleio/Central.h @@ -30,6 +30,7 @@ #include +#include "py/objlist.h" #include "shared-module/bleio/__init__.h" #include "shared-module/bleio/Address.h" @@ -38,7 +39,7 @@ typedef struct { gatt_role_t gatt_role; volatile bool waiting_to_connect; volatile uint16_t conn_handle; - mp_obj_t service_list; + mp_obj_list_t *service_list; } bleio_central_obj_t; #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index c00d8c30bf..1db0a9378d 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -194,27 +194,26 @@ STATIC void characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) { // More events may be handled later, so keep this as a switch. - case BLE_GATTC_EVT_READ_RSP: - { - ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp; - m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data); - // Indicate to busy-wait loop that we've read the characteristic. - m_read_characteristic = NULL; - break; - } + case BLE_GATTC_EVT_READ_RSP: { + ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp; + m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data); + // Indicate to busy-wait loop that we've read the characteristic. + m_read_characteristic = NULL; + break; + } - // For debugging. - default: - // mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id); - break; + // For debugging. + default: + // mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id); + break; } } void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props) { - self->service = NULL; + self->service = mp_const_none; self->uuid = uuid; - self->value_data = NULL; + self->value_data = mp_const_none; self->props = props; self->handle = BLE_GATT_HANDLE_INVALID; diff --git a/ports/nrf/common-hal/bleio/Characteristic.h b/ports/nrf/common-hal/bleio/Characteristic.h index 451bae4712..7cb2275968 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.h +++ b/ports/nrf/common-hal/bleio/Characteristic.h @@ -36,9 +36,10 @@ typedef struct { mp_obj_base_t base; bleio_service_obj_t *service; bleio_uuid_obj_t *uuid; - mp_obj_t value_data; + volatile mp_obj_t value_data; uint16_t handle; bleio_characteristic_properties_t props; + mp_obj_list_t *descriptor_list; uint16_t user_desc_handle; uint16_t cccd_handle; uint16_t sccd_handle; diff --git a/ports/nrf/common-hal/bleio/Descriptor.c b/ports/nrf/common-hal/bleio/Descriptor.c index 418cc07c17..d3f2a0ff84 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.c +++ b/ports/nrf/common-hal/bleio/Descriptor.c @@ -30,7 +30,6 @@ #include "shared-bindings/bleio/UUID.h" void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid) { - // TODO: set handle ??? self->uuid = uuid; } diff --git a/ports/nrf/common-hal/bleio/Descriptor.h b/ports/nrf/common-hal/bleio/Descriptor.h index 47552f39d8..b7af6a42f9 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.h +++ b/ports/nrf/common-hal/bleio/Descriptor.h @@ -30,11 +30,13 @@ #define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_DESCRIPTOR_H #include "py/obj.h" +#include "common-hal/bleio/Characteristic.h" #include "common-hal/bleio/UUID.h" typedef struct { mp_obj_base_t base; uint16_t handle; + bleio_characteristic_obj_t *characteristic; bleio_uuid_obj_t *uuid; } bleio_descriptor_obj_t; diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index fc9a146c31..b31bb84b0c 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -243,3 +243,7 @@ void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *self) mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code); } } + +void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *self) { + sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); +} diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c index 55193c5cb0..9939de775d 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -42,7 +42,8 @@ void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_ob self->is_secondary = is_secondary; for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) { - bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_list->items[characteristic_idx]); + bleio_characteristic_obj_t *characteristic = + MP_OBJ_TO_PTR(characteristic_list->items[characteristic_idx]); common_hal_bleio_characteristic_set_service(characteristic, self); } @@ -67,9 +68,9 @@ void common_hal_bleio_service_set_device(bleio_service_obj_t *self, mp_obj_t dev // Call this after the Service has been added to the Peripheral. void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) { // Add all the characteristics. - const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(self->characteristic_list); - for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) { - bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_idx]; + for (size_t characteristic_idx = 0; characteristic_idx < self->characteristic_list->len; ++characteristic_idx) { + bleio_characteristic_obj_t *characteristic = + MP_OBJ_TO_PTR(self->characteristic_list->items[characteristic_idx]); ble_gatts_char_md_t char_md = { .char_props.broadcast = characteristic->props.broadcast, diff --git a/ports/nrf/common-hal/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h index 90f52027db..583593fb80 100644 --- a/ports/nrf/common-hal/bleio/Service.h +++ b/ports/nrf/common-hal/bleio/Service.h @@ -28,6 +28,7 @@ #ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H #define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H +#include "py/objlist.h" #include "common-hal/bleio/UUID.h" typedef struct { @@ -38,7 +39,7 @@ typedef struct { bleio_uuid_obj_t *uuid; // May be a Peripheral, Central, etc. mp_obj_t device; - mp_obj_t characteristic_list; + mp_obj_list_t *characteristic_list; // Range of attribute handles of this service. uint16_t start_handle; uint16_t end_handle; diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c index efadcbb2ab..95ba19dd0b 100644 --- a/shared-bindings/bleio/Central.c +++ b/shared-bindings/bleio/Central.c @@ -79,8 +79,6 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); } - - //| .. method:: connect(address, timeout, *, service_uuids=None) //| Attempts a connection to the remote peripheral. If the connection is successful, //| Do BLE discovery for the listed services, to find their handles and characteristics. @@ -167,7 +165,7 @@ const mp_obj_property_t bleio_central_connected_obj = { STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) { bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); - return common_hal_bleio_central_get_remote_services(self); + return MP_OBJ_FROM_PTR(common_hal_bleio_central_get_remote_services(self)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services); diff --git a/shared-bindings/bleio/Central.h b/shared-bindings/bleio/Central.h index 2ca4239454..0e84037f91 100644 --- a/shared-bindings/bleio/Central.h +++ b/shared-bindings/bleio/Central.h @@ -37,6 +37,6 @@ extern void common_hal_bleio_central_construct(bleio_central_obj_t *self); extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids); extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self); extern bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self); -extern mp_obj_t common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self); +extern mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c index 9e051c89e3..723352ea12 100644 --- a/shared-bindings/bleio/Descriptor.c +++ b/shared-bindings/bleio/Descriptor.c @@ -49,9 +49,6 @@ enum { DescriptorUuidTimeTriggerSetting = 0x290E, }; -// Work-in-progress: orphaned for now. -//| :orphan: -//| //| .. currentmodule:: bleio //| //| :class:`Descriptor` -- BLE descriptor diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 665f5baafe..320d834718 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -250,10 +250,26 @@ STATIC mp_obj_t bleio_peripheral_stop_advertising(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_stop_advertising_obj, bleio_peripheral_stop_advertising); +//| .. method:: disconnect() +//| +//| Disconnects from the remote central. +//| Normally the central initiates a disconnection. Use this only +//| if necessary for your application. +//| +STATIC mp_obj_t bleio_peripheral_disconnect(mp_obj_t self_in) { + bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in); + + common_hal_bleio_peripheral_disconnect(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_disconnect_obj, bleio_peripheral_disconnect); + STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = { // Methods { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_peripheral_start_advertising_obj) }, { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_peripheral_stop_advertising_obj) }, + { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_peripheral_disconnect_obj) }, // Properties { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_peripheral_connected_obj) }, diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h index 16438bba6d..846250a5fc 100644 --- a/shared-bindings/bleio/Peripheral.h +++ b/shared-bindings/bleio/Peripheral.h @@ -38,5 +38,6 @@ extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *se extern mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self); extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, float interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device); +extern void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *device); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H From 118b26b335c7153eeb4847e04019cdc0829ca960 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 9 Jul 2019 00:21:46 -0400 Subject: [PATCH 18/25] UARTClient now works both directions --- ports/nrf/common-hal/bleio/Central.c | 59 +++++++++---- ports/nrf/common-hal/bleio/Characteristic.c | 53 ++++++++++-- ports/nrf/common-hal/bleio/Descriptor.c | 4 +- ports/nrf/common-hal/bleio/Peripheral.c | 4 +- ports/nrf/common-hal/bleio/Peripheral.h | 1 - ports/nrf/common-hal/bleio/Service.c | 6 +- shared-bindings/bleio/Address.c | 21 ++--- shared-bindings/bleio/AdvertisementData.h | 35 -------- shared-bindings/bleio/Characteristic.c | 50 ++++++++++- shared-bindings/bleio/Characteristic.h | 5 +- shared-bindings/bleio/Descriptor.c | 93 +++++++++++++-------- shared-bindings/bleio/Descriptor.h | 18 ++++ shared-bindings/bleio/Peripheral.c | 3 +- shared-bindings/bleio/Service.c | 2 +- shared-bindings/bleio/Service.h | 1 - shared-bindings/bleio/__init__.c | 7 +- 16 files changed, 239 insertions(+), 123 deletions(-) delete mode 100644 shared-bindings/bleio/AdvertisementData.h diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c index f7077f4b9a..d90737411f 100644 --- a/ports/nrf/common-hal/bleio/Central.c +++ b/ports/nrf/common-hal/bleio/Central.c @@ -97,7 +97,7 @@ STATIC bool discover_next_descriptors(bleio_central_obj_t *self, bleio_character m_discovery_successful = false; m_discovery_in_process = true; - uint32_t err_code = sd_ble_gattc_characteristics_discover(self->conn_handle, &handle_range); + uint32_t err_code = sd_ble_gattc_descriptors_discover(self->conn_handle, &handle_range); if (err_code != NRF_SUCCESS) { return false; } @@ -116,8 +116,10 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); service->base.type = &bleio_service_type; + // Initialize several fields at once. + common_hal_bleio_service_construct(service, NULL, mp_obj_new_list(0, NULL), false); + service->device = MP_OBJ_FROM_PTR(central); - service->characteristic_list = mp_obj_new_list(0, NULL); service->start_handle = gattc_service->handle_range.start_handle; service->end_handle = gattc_service->handle_range.end_handle; service->handle = gattc_service->handle_range.start_handle; @@ -152,6 +154,8 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); characteristic->base.type = &bleio_characteristic_type; + characteristic->descriptor_list = mp_obj_new_list(0, NULL); + bleio_uuid_obj_t *uuid = NULL; if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) { @@ -174,8 +178,8 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio props.write = gattc_char->char_props.write; props.write_no_response = gattc_char->char_props.write_wo_resp; - // Call common_hal_bleio_characteristic_construct() to set up evt handler. - common_hal_bleio_characteristic_construct(characteristic, uuid, props); + // Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler. + common_hal_bleio_characteristic_construct(characteristic, uuid, props, mp_obj_new_list(0, NULL)); characteristic->handle = gattc_char->handle_value; characteristic->service = m_char_discovery_service; @@ -192,6 +196,27 @@ STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, bleio for (size_t i = 0; i < response->count; ++i) { ble_gattc_desc_t *gattc_desc = &response->descs[i]; + // Remember handles for certain well-known descriptors. + switch (gattc_desc->uuid.uuid) { + case DESCRIPTOR_UUID_CLIENT_CHARACTERISTIC_CONFIGURATION: + m_desc_discovery_characteristic->cccd_handle = gattc_desc->handle; + break; + + case DESCRIPTOR_UUID_SERVER_CHARACTERISTIC_CONFIGURATION: + m_desc_discovery_characteristic->sccd_handle = gattc_desc->handle; + break; + + case DESCRIPTOR_UUID_CHARACTERISTIC_USER_DESCRIPTION: + m_desc_discovery_characteristic->user_desc_handle = gattc_desc->handle; + break; + + default: + // TODO: sd_ble_gattc_descriptors_discover() can return things that are not descriptors, + // so ignore those. + // https://devzone.nordicsemi.com/f/nordic-q-a/49500/sd_ble_gattc_descriptors_discover-is-returning-attributes-that-are-not-descriptors + break; + } + bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); descriptor->base.type = &bleio_descriptor_type; @@ -251,6 +276,7 @@ STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { case BLE_GATTC_EVT_DESC_DISC_RSP: on_desc_discovery_rsp(&ble_evt->evt.gattc_evt.params.desc_disc_rsp, central); + break; case BLE_GAP_EVT_SEC_PARAMS_REQUEST: sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL); @@ -265,7 +291,7 @@ STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { default: // For debugging. - mp_printf(&mp_plat_print, "Unhandled central event: 0x%04x\n", ble_evt->header.evt_id); + // mp_printf(&mp_plat_print, "Unhandled central event: 0x%04x\n", ble_evt->header.evt_id); break; } } @@ -330,13 +356,13 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_o uint16_t next_service_start_handle = BLE_GATT_HANDLE_START; while (discover_next_services(self, next_service_start_handle, MP_OBJ_NULL)) { - // discover_next_services() appends to service_list. + // discover_next_services() appends to service_list. - // Get the most recently discovered service, and then ask for services - // whose handles start after the last attribute handle inside that service. - const bleio_service_obj_t *service = - MP_OBJ_TO_PTR(self->service_list->items[self->service_list->len - 1]); - next_service_start_handle = service->end_handle + 1; + // Get the most recently discovered service, and then ask for services + // whose handles start after the last attribute handle inside that service. + const bleio_service_obj_t *service = + MP_OBJ_TO_PTR(self->service_list->items[self->service_list->len - 1]); + next_service_start_handle = service->end_handle + 1; } } else { mp_obj_iter_buf_t iter_buf; @@ -384,10 +410,11 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_o } // Got characteristics for this service. Now discover descriptors for each characteristic. - for (size_t char_idx = 0; char_idx < service->characteristic_list->len; ++char_idx) { + size_t char_list_len = service->characteristic_list->len; + for (size_t char_idx = 0; char_idx < char_list_len; ++char_idx) { bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx]); - const bool last_characteristic = char_idx == service->characteristic_list->len - 1; + const bool last_characteristic = char_idx == char_list_len - 1; bleio_characteristic_obj_t *next_characteristic = last_characteristic ? NULL : MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx + 1]); @@ -402,13 +429,15 @@ void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_o // Don't run past the end of this service or the beginning of the next characteristic. uint16_t next_desc_end_handle = next_characteristic == NULL ? service->end_handle - : next_characteristic->handle; + : next_characteristic->handle - 1; // Stop when we go past the end of the range of handles for this service or // discovery call returns nothing. // discover_next_descriptors() appends to the descriptor_list. while (next_desc_start_handle <= service->end_handle && - discover_next_descriptors(self, characteristic, next_desc_start_handle, next_desc_end_handle)) { + next_desc_start_handle < next_desc_end_handle && + discover_next_descriptors(self, characteristic, + next_desc_start_handle, next_desc_end_handle)) { // Get the most recently discovered descriptor, and then ask for descriptors // whose handles start after that descriptor's handle. diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 1db0a9378d..17417a5e64 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -162,7 +162,6 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in check_connected(conn_handle); ble_gattc_write_params_t write_params = { - .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL, .write_op = characteristic->props.write_no_response ? BLE_GATT_OP_WRITE_CMD : BLE_GATT_OP_WRITE_REQ, .handle = characteristic->handle, .p_value = bufinfo->buf, @@ -210,19 +209,19 @@ STATIC void characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) { } -void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props) { +void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, mp_obj_list_t *descriptor_list) { self->service = mp_const_none; self->uuid = uuid; self->value_data = mp_const_none; self->props = props; + self->descriptor_list = descriptor_list; self->handle = BLE_GATT_HANDLE_INVALID; ble_drv_add_event_handler(characteristic_on_ble_evt, self); - } -void common_hal_bleio_characteristic_set_service(bleio_characteristic_obj_t *self, bleio_service_obj_t *service) { - self->service = service; +mp_obj_list_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self) { + return self->descriptor_list; } mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) { @@ -284,3 +283,47 @@ bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_ bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) { return self->props; } + +void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { + if (self->cccd_handle == BLE_GATT_HANDLE_INVALID) { + mp_raise_ValueError(translate("No CCCD for this Characteristic")); + } + + if (common_hal_bleio_device_get_gatt_role(self->service->device) != GATT_ROLE_CLIENT) { + mp_raise_ValueError(translate("Can't set CCCD for local Characteristic")); + } + + uint16_t cccd_value = + (notify ? BLE_GATT_HVX_NOTIFICATION : 0) | + (indicate ? BLE_GATT_HVX_INDICATION : 0); + + const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(self->service->device); + check_connected(conn_handle); + + + ble_gattc_write_params_t write_params = { + .write_op = BLE_GATT_OP_WRITE_REQ, + .handle = self->cccd_handle, + .p_value = (uint8_t *) &cccd_value, + .len = 2, + }; + + while (1) { + uint32_t err_code = sd_ble_gattc_write(conn_handle, &write_params); + if (err_code == NRF_SUCCESS) { + break; + } + + // Write with response will return NRF_ERROR_BUSY if the response has not been received. + // Write without reponse will return NRF_ERROR_RESOURCES if too many writes are pending. + if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) { + // We could wait for an event indicating the write is complete, but just retrying is easier. + MICROPY_VM_HOOK_LOOP; + continue; + } + + // Some real error occurred. + mp_raise_OSError_msg_varg(translate("Failed to write CCCD, err 0x%04x"), err_code); + } + +} diff --git a/ports/nrf/common-hal/bleio/Descriptor.c b/ports/nrf/common-hal/bleio/Descriptor.c index d3f2a0ff84..005af6eaae 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.c +++ b/ports/nrf/common-hal/bleio/Descriptor.c @@ -37,6 +37,6 @@ mp_int_t common_hal_bleio_descriptor_get_handle(bleio_descriptor_obj_t *self) { return self->handle; } -mp_obj_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) { - return MP_OBJ_FROM_PTR(self->uuid); +bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) { + return self->uuid; } diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index b31bb84b0c..608bd1342b 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -135,13 +135,13 @@ void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_ for (size_t service_idx = 0; service_idx < service_list->len; ++service_idx) { bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[service_idx]); - common_hal_bleio_service_set_device(service, MP_OBJ_FROM_PTR(self)); + service->device = MP_OBJ_FROM_PTR(self); ble_uuid_t uuid; bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY; - if (service->is_secondary) { + if (common_hal_bleio_service_get_is_secondary(service)) { service_type = BLE_GATTS_SRVC_TYPE_SECONDARY; } diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index 725bc14314..2a12517159 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -44,7 +44,6 @@ typedef struct { gatt_role_t gatt_role; volatile uint16_t conn_handle; mp_obj_list_t *service_list; - mp_obj_t conn_handler; // The advertising data and scan response buffers are held by us, not by the SD, so we must // maintain them and not change it. If we need to change the contents during advertising, // there are tricks to get the SD to notice (see DevZone - TBS). diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c index 9939de775d..b6fcde8277 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -44,7 +44,7 @@ void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_ob for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) { bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_list->items[characteristic_idx]); - common_hal_bleio_characteristic_set_service(characteristic, self); + characteristic->service = self; } } @@ -61,10 +61,6 @@ bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) { return self->is_secondary; } -void common_hal_bleio_service_set_device(bleio_service_obj_t *self, mp_obj_t device) { - self->device = device; -} - // Call this after the Service has been added to the Peripheral. void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) { // Add all the characteristics. diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index 0e094c2e35..cfad8fc11d 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -49,10 +49,10 @@ //| //| :param buf address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes. //| :param int address_type: one of these integers: -//| - `bleio.Address.PUBLIC` = 0 -//| - `bleio.Address.RANDOM_STATIC` = 1 -//| - `bleio.Address.RANDOM_PRIVATE_RESOLVABLE` = 2 -//| - `bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE` = 3 +//| - ``bleio.Address.PUBLIC`` = 0 +//| - ``bleio.Address.RANDOM_STATIC`` = 1 +//| - ``bleio.Address.RANDOM_PRIVATE_RESOLVABLE`` = 2 +//| - ``bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE`` = 3 //| STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -89,11 +89,6 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, //| //| The bytes that make up the device address (read-only) //| -//| - `bleio.Address.PUBLIC` -//| - `bleio.Address.RANDOM_STATIC` -//| - `bleio.Address.RANDOM_PRIVATE_RESOLVABLE` -//| - `bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE` -//| STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -112,10 +107,10 @@ const mp_obj_property_t bleio_address_address_bytes_obj = { //| //| The address type (read-only). One of these integers: //| -//| - `bleio.Address.PUBLIC` -//| - `bleio.Address.RANDOM_STATIC` -//| - `bleio.Address.RANDOM_PRIVATE_RESOLVABLE` -//| - `bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE` +//| - ``bleio.Address.PUBLIC`` = 0 +//| - ``bleio.Address.RANDOM_STATIC`` = 1 +//| - ``bleio.Address.RANDOM_PRIVATE_RESOLVABLE`` = 2 +//| - ``bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE`` = 3 //| STATIC mp_obj_t bleio_address_get_type(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/bleio/AdvertisementData.h b/shared-bindings/bleio/AdvertisementData.h deleted file mode 100644 index 3313cde3b2..0000000000 --- a/shared-bindings/bleio/AdvertisementData.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Dan Halbert for Adafruit Industries - * Copyright (c) 2018 Artur Pacholec - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADVERTISEMENTDATA_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADVERTISEMENTDATA_H - -#include "py/obj.h" - -extern const mp_obj_type_t bleio_advertisementdata_type; - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADVERTISEMENTDATA_H diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index ede38c86b3..0d5f8f79ac 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -88,7 +88,8 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t properties.write = args[ARG_write].u_bool; properties.write_no_response = args[ARG_write_no_response].u_bool; - common_hal_bleio_characteristic_construct(self, uuid, properties); + // Initialize, with an empty descriptor list. + common_hal_bleio_characteristic_construct(self, uuid, properties, mp_obj_new_list(0, NULL)); return MP_OBJ_FROM_PTR(self); } @@ -254,11 +255,58 @@ const mp_obj_property_t bleio_characteristic_value_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. attribute:: descriptors +//| +//| A tuple of `bleio.Descriptor` that describe this characteristic. (read-only) +//| +STATIC mp_obj_t bleio_characteristic_get_descriptors(mp_obj_t self_in) { + bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); + // Return list as a tuple so user won't be able to change it. + mp_obj_list_t *char_list = common_hal_bleio_characteristic_get_descriptor_list(self); + return mp_obj_new_tuple(char_list->len, char_list->items); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_descriptors_obj, bleio_characteristic_get_descriptors); + +const mp_obj_property_t bleio_characteristic_descriptors_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_characteristic_get_descriptors_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + +//| .. method:: set_cccd(*, notify=False, indicate=False) +//| +//| Set the remote characteristic's CCCD to enable or disable notification and indication. +//| +//| :param bool notify: True if Characteristic should receive notifications of remote writes +//| :param float indicate: True if Characteristic should receive indications of remote writes +//| +STATIC mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + enum { ARG_notify, ARG_indicate }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_notify, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_indicate, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + }; + + 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); + + common_hal_bleio_characteristic_set_cccd(self, args[ARG_notify].u_bool, args[ARG_indicate].u_bool); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_set_cccd_obj, 1, bleio_characteristic_set_cccd); + + STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_broadcast), MP_ROM_PTR(&bleio_characteristic_broadcast_obj) }, + { MP_ROM_QSTR(MP_QSTR_descriptors), MP_ROM_PTR(&bleio_characteristic_descriptors_obj) }, { MP_ROM_QSTR(MP_QSTR_indicate), MP_ROM_PTR(&bleio_characteristic_indicate_obj) }, { MP_ROM_QSTR(MP_QSTR_notify), MP_ROM_PTR(&bleio_characteristic_notify_obj) }, { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&bleio_characteristic_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_set_cccd), MP_ROM_PTR(&bleio_characteristic_set_cccd_obj) }, { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_characteristic_uuid_obj) }, { MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&bleio_characteristic_value_obj) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&bleio_characteristic_write_obj) }, diff --git a/shared-bindings/bleio/Characteristic.h b/shared-bindings/bleio/Characteristic.h index 1938845a9a..d450c42b4e 100644 --- a/shared-bindings/bleio/Characteristic.h +++ b/shared-bindings/bleio/Characteristic.h @@ -33,11 +33,12 @@ extern const mp_obj_type_t bleio_characteristic_type; -extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props); -extern void common_hal_bleio_characteristic_set_service(bleio_characteristic_obj_t *self, bleio_service_obj_t *service); +extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, mp_obj_list_t *descriptor_list); extern mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self); extern void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo); extern bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self); extern bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self); +extern mp_obj_list_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self); +extern void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c index 723352ea12..f392838926 100644 --- a/shared-bindings/bleio/Descriptor.c +++ b/shared-bindings/bleio/Descriptor.c @@ -31,24 +31,6 @@ #include "shared-bindings/bleio/Descriptor.h" #include "shared-bindings/bleio/UUID.h" -enum { - DescriptorUuidCharacteristicExtendedProperties = 0x2900, - DescriptorUuidCharacteristicUserDescription = 0x2901, - DescriptorUuidClientCharacteristicConfiguration = 0x2902, - DescriptorUuidServerCharacteristicConfiguration = 0x2903, - DescriptorUuidCharacteristicPresentationFormat = 0x2904, - DescriptorUuidCharacteristicAggregateFormat = 0x2905, - DescriptorUuidValidRange = 0x2906, - DescriptorUuidExternalReportReference = 0x2907, - DescriptorUuidReportReference = 0x2908, - DescriptorUuidNumberOfDigitals = 0x2909, - DescriptorUuidValueTriggerSetting = 0x290A, - DescriptorUuidEnvironmentalSensingConfiguration = 0x290B, - DescriptorUuidEnvironmentalSensingMeasurement = 0x290C, - DescriptorUuidEnvironmentalSensingTriggerSetting = 0x290D, - DescriptorUuidTimeTriggerSetting = 0x290E, -}; - //| .. currentmodule:: bleio //| //| :class:`Descriptor` -- BLE descriptor @@ -111,7 +93,9 @@ const mp_obj_property_t bleio_descriptor_handle_obj = { STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); - return common_hal_bleio_descriptor_get_uuid(self); + + bleio_uuid_obj_t *uuid = common_hal_bleio_descriptor_get_uuid(self); + return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_uuid_obj, bleio_descriptor_get_uuid); @@ -128,28 +112,69 @@ STATIC const mp_rom_map_elem_t bleio_descriptor_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_descriptor_uuid_obj) }, // Static variables - { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_EXTENDED_PROPERTIES), MP_ROM_INT(DescriptorUuidCharacteristicExtendedProperties) }, - { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_USER_DESCRIPTION), MP_ROM_INT(DescriptorUuidCharacteristicUserDescription) }, - { MP_ROM_QSTR(MP_QSTR_CLIENT_CHARACTERISTIC_CONFIGURATION), MP_ROM_INT(DescriptorUuidClientCharacteristicConfiguration) }, - { MP_ROM_QSTR(MP_QSTR_SERVER_CHARACTERISTIC_CONFIGURATION), MP_ROM_INT(DescriptorUuidServerCharacteristicConfiguration) }, - { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_PRESENTATION_FORMAT), MP_ROM_INT(DescriptorUuidCharacteristicPresentationFormat) }, - { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_AGGREGATE_FORMAT), MP_ROM_INT(DescriptorUuidCharacteristicAggregateFormat) }, - { MP_ROM_QSTR(MP_QSTR_VALID_RANGE), MP_ROM_INT(DescriptorUuidValidRange) }, - { MP_ROM_QSTR(MP_QSTR_EXTERNAL_REPORT_REFERENCE), MP_ROM_INT(DescriptorUuidExternalReportReference) }, - { MP_ROM_QSTR(MP_QSTR_REPORT_REFERENCE), MP_ROM_INT(DescriptorUuidReportReference) }, - { MP_ROM_QSTR(MP_QSTR_NUMBER_OF_DIGITALS), MP_ROM_INT(DescriptorUuidNumberOfDigitals) }, - { MP_ROM_QSTR(MP_QSTR_VALUE_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidValueTriggerSetting) }, - { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_CONFIGURATION), MP_ROM_INT(DescriptorUuidEnvironmentalSensingConfiguration) }, - { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_MEASUREMENT ), MP_ROM_INT(DescriptorUuidEnvironmentalSensingMeasurement) }, - { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidEnvironmentalSensingTriggerSetting) }, - { MP_ROM_QSTR(MP_QSTR_TIME_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidTimeTriggerSetting) } + { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_EXTENDED_PROPERTIES), + MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_EXTENDED_PROPERTIES) }, + + { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_USER_DESCRIPTION), + MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_USER_DESCRIPTION) }, + + { MP_ROM_QSTR(MP_QSTR_CLIENT_CHARACTERISTIC_CONFIGURATION), + MP_ROM_INT(DESCRIPTOR_UUID_CLIENT_CHARACTERISTIC_CONFIGURATION) }, + + { MP_ROM_QSTR(MP_QSTR_SERVER_CHARACTERISTIC_CONFIGURATION), + MP_ROM_INT(DESCRIPTOR_UUID_SERVER_CHARACTERISTIC_CONFIGURATION) }, + + { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_PRESENTATION_FORMAT), + MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_PRESENTATION_FORMAT) }, + + { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_AGGREGATE_FORMAT), + MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_AGGREGATE_FORMAT) }, + + { MP_ROM_QSTR(MP_QSTR_VALID_RANGE), + MP_ROM_INT(DESCRIPTOR_UUID_VALID_RANGE) }, + + { MP_ROM_QSTR(MP_QSTR_EXTERNAL_REPORT_REFERENCE), + MP_ROM_INT(DESCRIPTOR_UUID_EXTERNAL_REPORT_REFERENCE) }, + + { MP_ROM_QSTR(MP_QSTR_REPORT_REFERENCE), + MP_ROM_INT(DESCRIPTOR_UUID_REPORT_REFERENCE) }, + + { MP_ROM_QSTR(MP_QSTR_NUMBER_OF_DIGITALS), + MP_ROM_INT(DESCRIPTOR_UUID_NUMBER_OF_DIGITALS) }, + + { MP_ROM_QSTR(MP_QSTR_VALUE_TRIGGER_SETTING), + MP_ROM_INT(DESCRIPTOR_UUID_VALUE_TRIGGER_SETTING) }, + + { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_CONFIGURATION), + MP_ROM_INT(DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_CONFIGURATION) }, + + { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_MEASUREMENT ), + MP_ROM_INT(DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_MEASUREMENT) }, + + { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_TRIGGER_SETTING), + MP_ROM_INT(DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_TRIGGER_SETTING) }, + + { MP_ROM_QSTR(MP_QSTR_TIME_TRIGGER_SETTING), + MP_ROM_INT(DESCRIPTOR_UUID_TIME_TRIGGER_SETTING) }, }; STATIC MP_DEFINE_CONST_DICT(bleio_descriptor_locals_dict, bleio_descriptor_locals_dict_table); +STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { + bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_printf(print, "Descriptor("); + if (self->uuid) { + bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind); + } else { + mp_printf(print, "Unregistered uUID"); + } + mp_printf(print, ")"); +} + const mp_obj_type_t bleio_descriptor_type = { { &mp_type_type }, .name = MP_QSTR_Descriptor, .make_new = bleio_descriptor_make_new, + .print = bleio_descriptor_print, .locals_dict = (mp_obj_dict_t*)&bleio_descriptor_locals_dict }; diff --git a/shared-bindings/bleio/Descriptor.h b/shared-bindings/bleio/Descriptor.h index f4634d3933..fd11ea08cd 100644 --- a/shared-bindings/bleio/Descriptor.h +++ b/shared-bindings/bleio/Descriptor.h @@ -31,6 +31,24 @@ #include "common-hal/bleio/Descriptor.h" #include "common-hal/bleio/UUID.h" +enum { + DESCRIPTOR_UUID_CHARACTERISTIC_EXTENDED_PROPERTIES = 0x2900, + DESCRIPTOR_UUID_CHARACTERISTIC_USER_DESCRIPTION = 0x2901, + DESCRIPTOR_UUID_CLIENT_CHARACTERISTIC_CONFIGURATION = 0x2902, + DESCRIPTOR_UUID_SERVER_CHARACTERISTIC_CONFIGURATION = 0x2903, + DESCRIPTOR_UUID_CHARACTERISTIC_PRESENTATION_FORMAT = 0x2904, + DESCRIPTOR_UUID_CHARACTERISTIC_AGGREGATE_FORMAT = 0x2905, + DESCRIPTOR_UUID_VALID_RANGE = 0x2906, + DESCRIPTOR_UUID_EXTERNAL_REPORT_REFERENCE = 0x2907, + DESCRIPTOR_UUID_REPORT_REFERENCE = 0x2908, + DESCRIPTOR_UUID_NUMBER_OF_DIGITALS = 0x2909, + DESCRIPTOR_UUID_VALUE_TRIGGER_SETTING = 0x290A, + DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_CONFIGURATION = 0x290B, + DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_MEASUREMENT = 0x290C, + DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_TRIGGER_SETTING = 0x290D, + DESCRIPTOR_UUID_TIME_TRIGGER_SETTING = 0x290E, +}; + extern const mp_obj_type_t bleio_descriptor_type; extern void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid); diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 320d834718..b8d4c39753 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -82,13 +82,12 @@ static const char default_name[] = "CIRCUITPY"; //| .. class:: Peripheral(services=(), \*, name='CIRCUITPY') //| //| Create a new Peripheral object. - +//| //| :param iterable services: the Service objects representing services available from this peripheral, if any. //| A non-connectable peripheral will have no services. //| :param str name: The name used when advertising this peripheral. Use ``None`` when a name is not needed, //| such as when the peripheral is a beacon //| - STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_services, ARG_name }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index f8993ef619..af215c6a50 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, //| .. attribute:: characteristics //| -//| A `list` of `bleio.Characteristic` that are offered by this service. (read-only) +//| A tuple of `bleio.Characteristic` that are offered by this service. (read-only) //| STATIC mp_obj_t bleio_service_get_characteristics(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/bleio/Service.h b/shared-bindings/bleio/Service.h index 6693cc3bb3..f646c81a9b 100644 --- a/shared-bindings/bleio/Service.h +++ b/shared-bindings/bleio/Service.h @@ -36,7 +36,6 @@ extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_ extern bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self); extern mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self); extern bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self); -extern void common_hal_bleio_service_set_device(bleio_service_obj_t *self, mp_obj_t device); extern void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 9e80b49e37..ba3bae6c75 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -53,15 +53,14 @@ //| :maxdepth: 3 //| //| Address -//| AdvertisementData //| Adapter //| Central //| Characteristic //| CharacteristicBuffer -// Descriptor +//| Descriptor //| Peripheral -//| ScanEntry -//| Scanner +//| ScanEntry +//| Scanner //| Service //| UUID //| From ddd4d616db3d60e5f6aa2a313be3206393e104b1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 9 Jul 2019 08:43:54 -0400 Subject: [PATCH 19/25] make translate --- locale/ID.po | 139 +++++++++++++++++----------------- locale/circuitpython.pot | 85 ++++++++------------- locale/de_DE.po | 133 ++++++++++++++++++--------------- locale/en_US.po | 85 ++++++++------------- locale/en_x_pirate.po | 85 ++++++++------------- locale/es.po | 156 ++++++++++++++++++++++----------------- locale/fil.po | 153 +++++++++++++++++++++----------------- locale/fr.po | 154 +++++++++++++++++++++----------------- locale/it_IT.po | 153 +++++++++++++++++++++----------------- locale/pl.po | 136 +++++++++++++++++++--------------- locale/pt_BR.po | 127 ++++++++++++++++--------------- locale/zh_Latn_pinyin.po | 136 +++++++++++++++++++--------------- 12 files changed, 801 insertions(+), 741 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 7017631095..ea16b3dec1 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -353,20 +353,8 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c @@ -498,11 +486,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Data too large for the advertisement packet" -msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -540,6 +523,10 @@ msgstr "" msgid "Expected a UUID" msgstr "" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -549,12 +536,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to acquire mutex" -msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" @@ -564,11 +546,6 @@ msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" msgid "Failed to add characteristic, err 0x%04x" msgstr "Gagal untuk menambahkan karakteristik, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to add service" -msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to add service, err 0x%04x" @@ -595,25 +572,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to connect:" -msgstr "Gagal untuk menyambungkan, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to continue scanning" -msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to create mutex" -msgstr "Gagal untuk membuat mutex, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" @@ -654,12 +620,7 @@ msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Gagal untuk menambahkan Vendor Spesific UUID, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to release mutex" -msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" @@ -669,36 +630,31 @@ msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start advertising" -msgstr "Gagal untuk memulai advertisement, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Gagal untuk memulai advertisement, status: 0x%08lX" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start scanning" -msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to stop advertising" -msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, fuzzy, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -914,6 +870,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip" @@ -964,6 +924,7 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c #, fuzzy msgid "Not connected" @@ -2143,6 +2104,14 @@ msgstr "tidak ada modul yang bernama '%q'" msgid "no such attribute" msgstr "" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "argumen non-default mengikuti argumen standar(default)" @@ -2352,10 +2321,6 @@ msgstr "" msgid "script compilation not supported" msgstr "kompilasi script tidak didukung" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "" @@ -2673,6 +2638,10 @@ msgstr "" #~ msgid "Cannot update i/f status" #~ msgstr "Tidak dapat memperbarui status i/f" +#, fuzzy +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" + #~ msgid "Don't know how to pass object to native function" #~ msgstr "Tidak tahu cara meloloskan objek ke fungsi native" @@ -2685,6 +2654,26 @@ msgstr "" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Errod pada ffi_prep_cif" +#, fuzzy +#~ msgid "Failed to acquire mutex" +#~ msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to add service" +#~ msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to connect:" +#~ msgstr "Gagal untuk menyambungkan, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to continue scanning" +#~ msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to create mutex" +#~ msgstr "Gagal untuk membuat mutex, status: 0x%08lX" + #, fuzzy #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Gagal untuk melaporkan nilai atribut, status: 0x%08lX" @@ -2693,6 +2682,22 @@ msgstr "" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX" +#, fuzzy +#~ msgid "Failed to release mutex" +#~ msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to start advertising" +#~ msgstr "Gagal untuk memulai advertisement, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to start scanning" +#~ msgstr "Gagal untuk melakukan scanning, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to stop advertising" +#~ msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX" + #~ msgid "GPIO16 does not support pull up." #~ msgstr "GPIO16 tidak mendukung pull up" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index bbf77887ae..4c399471be 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: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -348,20 +348,8 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c @@ -487,10 +475,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -528,6 +512,10 @@ msgstr "" msgid "Expected a UUID" msgstr "" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -537,11 +525,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to acquire mutex" -msgstr "" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "" @@ -551,10 +535,6 @@ msgstr "" msgid "Failed to add characteristic, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to add service" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to add service, err 0x%04x" @@ -580,11 +560,7 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" +msgid "Failed to connect: timeout" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -592,10 +568,6 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to create mutex" -msgstr "" - #: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "" @@ -633,11 +605,7 @@ msgstr "" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to release mutex" -msgstr "" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "" @@ -647,17 +615,14 @@ msgstr "" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start advertising" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start scanning" +#, c-format +msgid "Failed to start connecting, error 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -665,15 +630,16 @@ msgstr "" msgid "Failed to start scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to stop advertising" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -889,6 +855,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "" @@ -939,6 +909,7 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c msgid "Not connected" msgstr "" @@ -2098,6 +2069,14 @@ msgstr "" msgid "no such attribute" msgstr "" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "" @@ -2306,10 +2285,6 @@ msgstr "" msgid "script compilation not supported" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 8b559edab7..5231231295 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: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -352,21 +352,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Kann dotstar nicht mit %s verwenden" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "Im Central mode können Dienste nicht hinzugefügt werden" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "Im Central mode kann advertise nicht gemacht werden" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "Im Central mode kann name nicht geändert werden" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "Im Peripheral mode kann keine Verbindung hergestellt werden" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -491,10 +479,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "Zu vielen Daten für das advertisement packet" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "Daten sind zu groß für das advertisement packet" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Die Zielkapazität ist kleiner als destination_length." @@ -532,6 +516,10 @@ msgstr "Characteristic wird erwartet" msgid "Expected a UUID" msgstr "Eine UUID wird erwartet" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -541,11 +529,7 @@ msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to acquire mutex" -msgstr "Akquirieren des Mutex gescheitert" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" @@ -555,10 +539,6 @@ msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Hinzufügen des Characteristic ist gescheitert. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to add service" -msgstr "Dienst konnte nicht hinzugefügt werden" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to add service, err 0x%04x" @@ -584,22 +564,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "Verbindung fehlgeschlagen:" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" -msgstr "Der Scanvorgang kann nicht fortgesetzt werden" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Der Scanvorgang kann nicht fortgesetzt werden. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to create mutex" -msgstr "Erstellen des Mutex ist fehlgeschlagen" - #: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "Es konnten keine Dienste gefunden werden" @@ -637,11 +609,7 @@ msgstr "gatts value konnte nicht gelesen werden. Status: 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Kann keine herstellerspezifische UUID hinzufügen. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to release mutex" -msgstr "Loslassen des Mutex gescheitert" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Mutex konnte nicht freigegeben werden. Status: 0x%04x" @@ -651,33 +619,31 @@ msgstr "Mutex konnte nicht freigegeben werden. Status: 0x%04x" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start advertising" -msgstr "Kann advertisement nicht starten" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Kann advertisement nicht starten. Status: 0x%04x" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start scanning" -msgstr "Der Scanvorgang kann nicht gestartet werden" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to stop advertising" -msgstr "Kann advertisement nicht stoppen" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Kann advertisement nicht stoppen. Status: 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -902,6 +868,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Kein DAC im Chip vorhanden" @@ -952,6 +922,7 @@ msgstr "Kein Speicherplatz auf Gerät" msgid "No such file/directory" msgstr "Keine solche Datei/Verzeichnis" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c msgid "Not connected" msgstr "Nicht verbunden" @@ -2145,6 +2116,14 @@ msgstr "Kein Modul mit dem Namen '%q'" msgid "no such attribute" msgstr "" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "ein non-default argument folgt auf ein default argument" @@ -2357,10 +2336,6 @@ msgstr "Der schedule stack ist voll" msgid "script compilation not supported" msgstr "kompilieren von Skripten ist nicht unterstützt" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "" @@ -2673,6 +2648,18 @@ msgstr "" #~ msgid "C-level assert" #~ msgstr "C-Level Assert" +#~ msgid "Can't add services in Central mode" +#~ msgstr "Im Central mode können Dienste nicht hinzugefügt werden" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "Im Central mode kann advertise nicht gemacht werden" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "Im Central mode kann name nicht geändert werden" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "Im Peripheral mode kann keine Verbindung hergestellt werden" + #~ msgid "Cannot connect to AP" #~ msgstr "Kann nicht zu AP verbinden" @@ -2685,6 +2672,9 @@ msgstr "" #~ msgid "Cannot update i/f status" #~ msgstr "Kann i/f Status nicht updaten" +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Daten sind zu groß für das advertisement packet" + #~ msgid "Don't know how to pass object to native function" #~ msgstr "" #~ "Ich weiß nicht, wie man das Objekt an die native Funktion übergeben kann" @@ -2698,12 +2688,39 @@ msgstr "" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Fehler in ffi_prep_cif" +#~ msgid "Failed to acquire mutex" +#~ msgstr "Akquirieren des Mutex gescheitert" + +#~ msgid "Failed to add service" +#~ msgstr "Dienst konnte nicht hinzugefügt werden" + +#~ msgid "Failed to connect:" +#~ msgstr "Verbindung fehlgeschlagen:" + +#~ msgid "Failed to continue scanning" +#~ msgstr "Der Scanvorgang kann nicht fortgesetzt werden" + +#~ msgid "Failed to create mutex" +#~ msgstr "Erstellen des Mutex ist fehlgeschlagen" + #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Kann den Attributwert nicht mitteilen. Status: 0x%04x" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Kann den Attributwert nicht lesen. Status: 0x%04x" +#~ msgid "Failed to release mutex" +#~ msgstr "Loslassen des Mutex gescheitert" + +#~ msgid "Failed to start advertising" +#~ msgstr "Kann advertisement nicht starten" + +#~ msgid "Failed to start scanning" +#~ msgstr "Der Scanvorgang kann nicht gestartet werden" + +#~ msgid "Failed to stop advertising" +#~ msgstr "Kann advertisement nicht stoppen" + #~ msgid "Function requires lock." #~ msgstr "" #~ "Die Funktion erwartet, dass der 'lock'-Befehl zuvor ausgeführt wurde" diff --git a/locale/en_US.po b/locale/en_US.po index 616e89630a..f1b9bae28c 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: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -348,20 +348,8 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c @@ -487,10 +475,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -528,6 +512,10 @@ msgstr "" msgid "Expected a UUID" msgstr "" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -537,11 +525,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to acquire mutex" -msgstr "" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "" @@ -551,10 +535,6 @@ msgstr "" msgid "Failed to add characteristic, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to add service" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to add service, err 0x%04x" @@ -580,11 +560,7 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" +msgid "Failed to connect: timeout" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -592,10 +568,6 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to create mutex" -msgstr "" - #: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "" @@ -633,11 +605,7 @@ msgstr "" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to release mutex" -msgstr "" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "" @@ -647,17 +615,14 @@ msgstr "" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start advertising" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start scanning" +#, c-format +msgid "Failed to start connecting, error 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -665,15 +630,16 @@ msgstr "" msgid "Failed to start scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to stop advertising" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -889,6 +855,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "" @@ -939,6 +909,7 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c msgid "Not connected" msgstr "" @@ -2098,6 +2069,14 @@ msgstr "" msgid "no such attribute" msgstr "" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "" @@ -2306,10 +2285,6 @@ msgstr "" msgid "script compilation not supported" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 44db050456..1c9ca9f1bb 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -352,20 +352,8 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c @@ -491,10 +479,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -532,6 +516,10 @@ msgstr "" msgid "Expected a UUID" msgstr "" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -541,11 +529,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to acquire mutex" -msgstr "" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "" @@ -555,10 +539,6 @@ msgstr "" msgid "Failed to add characteristic, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to add service" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to add service, err 0x%04x" @@ -584,11 +564,7 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" +msgid "Failed to connect: timeout" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -596,10 +572,6 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to create mutex" -msgstr "" - #: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "" @@ -637,11 +609,7 @@ msgstr "" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to release mutex" -msgstr "" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "" @@ -651,17 +619,14 @@ msgstr "" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start advertising" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start scanning" +#, c-format +msgid "Failed to start connecting, error 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -669,15 +634,16 @@ msgstr "" msgid "Failed to start scanning, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to stop advertising" -msgstr "" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -893,6 +859,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Shiver me timbers! There be no DAC on this chip" @@ -943,6 +913,7 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c msgid "Not connected" msgstr "" @@ -2102,6 +2073,14 @@ msgstr "" msgid "no such attribute" msgstr "" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "" @@ -2310,10 +2289,6 @@ msgstr "" msgid "script compilation not supported" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "" diff --git a/locale/es.po b/locale/es.po index 194dea86ba..013266aa7c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -362,21 +362,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "No se puede usar dotstar con %s" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "No se pueden agregar servicio en modo Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "No se puede anunciar en modo Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "No se puede cambiar el nombre en modo Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "No se puede conectar en modo Peripheral" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -504,11 +492,6 @@ msgstr "El Data Chunk debe seguir el fmt chunk" msgid "Data too large for advertisement packet" msgstr "Los datos no caben en el paquete de anuncio." -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Data too large for the advertisement packet" -msgstr "Los datos no caben en el paquete de anuncio." - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Capacidad de destino es mas pequeña que destination_length." @@ -548,6 +531,10 @@ msgstr "No se puede agregar la Característica." msgid "Expected a UUID" msgstr "Se espera un %q" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -557,12 +544,7 @@ msgstr "Se esperaba un tuple de %d, se obtuvo %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to acquire mutex" -msgstr "No se puede adquirir el mutex, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "No se puede adquirir el mutex, status: 0x%08lX" @@ -572,11 +554,6 @@ msgstr "No se puede adquirir el mutex, status: 0x%08lX" msgid "Failed to add characteristic, err 0x%04x" msgstr "No se puede añadir caracteristica, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to add service" -msgstr "No se puede detener el anuncio. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to add service, err 0x%04x" @@ -603,25 +580,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to connect:" -msgstr "No se puede conectar. status: 0x%02x" - -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to continue scanning" -msgstr "No se puede iniciar el escaneo. status: 0x%02x" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "No se puede iniciar el escaneo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to create mutex" -msgstr "No se puede leer el valor del atributo. status 0x%02x" - #: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" @@ -662,12 +628,7 @@ msgstr "No se puede escribir el valor del atributo. status: 0x%02x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "No se puede agregar el Vendor Specific 128-bit UUID." -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to release mutex" -msgstr "No se puede liberar el mutex, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "No se puede liberar el mutex, status: 0x%08lX" @@ -677,36 +638,31 @@ msgstr "No se puede liberar el mutex, status: 0x%08lX" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start advertising" -msgstr "No se puede inicar el anuncio. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "No se puede inicar el anuncio. status: 0x%02x" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start scanning" -msgstr "No se puede iniciar el escaneo. status: 0x%02x" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "No se puede iniciar el escaneo. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to stop advertising" -msgstr "No se puede detener el anuncio. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "No se puede detener el anuncio. status: 0x%02x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, fuzzy, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -928,6 +884,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "El chip no tiene DAC" @@ -978,6 +938,7 @@ msgstr "No queda espacio en el dispositivo" msgid "No such file/directory" msgstr "No existe el archivo/directorio" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c #, fuzzy msgid "Not connected" @@ -2177,6 +2138,14 @@ msgstr "ningún módulo se llama '%q'" msgid "no such attribute" msgstr "no hay tal atributo" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "argumento no predeterminado sigue argumento predeterminado" @@ -2393,10 +2362,6 @@ msgstr "" msgid "script compilation not supported" msgstr "script de compilación no soportado" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "services incluye un objeto que no es servicio" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "signo no permitido en el espeficador de string format" @@ -2705,6 +2670,18 @@ msgstr "paso cero" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" +#~ msgid "Can't add services in Central mode" +#~ msgstr "No se pueden agregar servicio en modo Central" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "No se puede anunciar en modo Central" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "No se puede cambiar el nombre en modo Central" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "No se puede conectar en modo Peripheral" + #~ msgid "Cannot connect to AP" #~ msgstr "No se puede conectar a AP" @@ -2717,6 +2694,10 @@ msgstr "paso cero" #~ msgid "Cannot update i/f status" #~ msgstr "No se puede actualizar i/f status" +#, fuzzy +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Los datos no caben en el paquete de anuncio." + #~ msgid "Don't know how to pass object to native function" #~ msgstr "No se sabe cómo pasar objeto a función nativa" @@ -2729,6 +2710,26 @@ msgstr "paso cero" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Error en ffi_prep_cif" +#, fuzzy +#~ msgid "Failed to acquire mutex" +#~ msgstr "No se puede adquirir el mutex, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to add service" +#~ msgstr "No se puede detener el anuncio. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to connect:" +#~ msgstr "No se puede conectar. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to continue scanning" +#~ msgstr "No se puede iniciar el escaneo. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to create mutex" +#~ msgstr "No se puede leer el valor del atributo. status 0x%02x" + #, fuzzy #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "No se puede notificar el valor del anuncio. status: 0x%02x" @@ -2737,6 +2738,22 @@ msgstr "paso cero" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "No se puede leer el valor del atributo. status 0x%02x" +#, fuzzy +#~ msgid "Failed to release mutex" +#~ msgstr "No se puede liberar el mutex, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to start advertising" +#~ msgstr "No se puede inicar el anuncio. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to start scanning" +#~ msgstr "No se puede iniciar el escaneo. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to stop advertising" +#~ msgstr "No se puede detener el anuncio. status: 0x%02x" + #~ msgid "Function requires lock." #~ msgstr "La función requiere lock" @@ -2909,6 +2926,9 @@ msgstr "paso cero" #~ msgid "scan failed" #~ msgstr "scan ha fallado" +#~ msgid "services includes an object that is not a Service" +#~ msgstr "services incluye un objeto que no es servicio" + #~ msgid "too many arguments" #~ msgstr "muchos argumentos" diff --git a/locale/fil.po b/locale/fil.po index 9c688ec14b..951695bb79 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: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -355,21 +355,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "Hindi maarang maglagay ng service sa Central mode" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "Hindi ma advertise habang nasa Central mode" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "Hindi mapalitan ang pangalan sa Central mode" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "Hindi maconnect sa Peripheral mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -498,11 +486,6 @@ msgstr "Dapat sunurin ng Data chunk ang fmt chunk" msgid "Data too large for advertisement packet" msgstr "Hindi makasya ang data sa loob ng advertisement packet" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Data too large for the advertisement packet" -msgstr "Hindi makasya ang data sa loob ng advertisement packet" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -543,6 +526,10 @@ msgstr "Hindi mabasa and Characteristic." msgid "Expected a UUID" msgstr "Umasa ng %q" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -552,12 +539,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to acquire mutex" -msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" @@ -567,11 +549,6 @@ msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" msgid "Failed to add characteristic, err 0x%04x" msgstr "Nabigo sa paglagay ng characteristic, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to add service" -msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to add service, err 0x%04x" @@ -598,25 +575,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to connect:" -msgstr "Hindi makaconnect, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to continue scanning" -msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to create mutex" -msgstr "Hindi matagumpay ang pagbuo ng mutex, status: 0x%0xlX" - #: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" @@ -657,12 +623,7 @@ msgstr "Hindi maisulat ang gatts value, status: 0x%08lX" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Hindi matagumpay ang paglagay ng Vender Specific UUID, status: 0x%08lX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to release mutex" -msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" @@ -672,36 +633,31 @@ msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start advertising" -msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start scanning" -msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to stop advertising" -msgstr "Hindi mahinto ang advertisement, status: 0x%08lX" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Hindi mahinto ang advertisement, status: 0x%08lX" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, fuzzy, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -923,6 +879,10 @@ msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Walang DAC sa chip" @@ -973,6 +933,7 @@ msgstr "" msgid "No such file/directory" msgstr "Walang file/directory" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c #, fuzzy msgid "Not connected" @@ -2179,6 +2140,14 @@ msgstr "walang module na '%q'" msgid "no such attribute" msgstr "walang ganoon na attribute" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "non-default argument sumusunod sa default argument" @@ -2392,10 +2361,6 @@ msgstr "puno na ang schedule stack" msgid "script compilation not supported" msgstr "script kompilasyon hindi supportado" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "sign hindi maaring string format specifier" @@ -2704,6 +2669,18 @@ msgstr "zero step" #~ msgid "C-level assert" #~ msgstr "C-level assert" +#~ msgid "Can't add services in Central mode" +#~ msgstr "Hindi maarang maglagay ng service sa Central mode" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "Hindi ma advertise habang nasa Central mode" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "Hindi mapalitan ang pangalan sa Central mode" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "Hindi maconnect sa Peripheral mode" + #~ msgid "Cannot connect to AP" #~ msgstr "Hindi maka connect sa AP" @@ -2716,6 +2693,10 @@ msgstr "zero step" #~ msgid "Cannot update i/f status" #~ msgstr "Hindi ma-update i/f status" +#, fuzzy +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Hindi makasya ang data sa loob ng advertisement packet" + #~ msgid "Don't know how to pass object to native function" #~ msgstr "Hindi alam ipasa ang object sa native function" @@ -2728,6 +2709,26 @@ msgstr "zero step" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Pagkakamali sa ffi_prep_cif" +#, fuzzy +#~ msgid "Failed to acquire mutex" +#~ msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to add service" +#~ msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to connect:" +#~ msgstr "Hindi makaconnect, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to continue scanning" +#~ msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX" + +#, fuzzy +#~ msgid "Failed to create mutex" +#~ msgstr "Hindi matagumpay ang pagbuo ng mutex, status: 0x%0xlX" + #, fuzzy #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Hindi mabalitaan ang attribute value, status: 0x%08lX" @@ -2736,6 +2737,22 @@ msgstr "zero step" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX" +#, fuzzy +#~ msgid "Failed to release mutex" +#~ msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to start advertising" +#~ msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX" + +#, fuzzy +#~ msgid "Failed to start scanning" +#~ msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX" + +#, fuzzy +#~ msgid "Failed to stop advertising" +#~ msgstr "Hindi mahinto ang advertisement, status: 0x%08lX" + #~ msgid "Function requires lock." #~ msgstr "Kailangan ng lock ang function." diff --git a/locale/fr.po b/locale/fr.po index 60122a5d0b..abed1204c5 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -360,21 +360,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Impossible d'utiliser 'dotstar' avec %s" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "Impossible d'ajouter des services en mode Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "Impossible de publier en mode Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "Modification du nom impossible en mode Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "Impossible de se connecter en mode 'Peripheral'" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -503,10 +491,6 @@ msgstr "Un bloc de données doit suivre un bloc de format" msgid "Data too large for advertisement packet" msgstr "Données trop volumineuses pour un paquet de diffusion" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "Données trop volumineuses pour le paquet de diffusion" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "La capacité de destination est plus petite que 'destination_length'." @@ -546,6 +530,10 @@ msgstr "Une 'Characteristic' est attendue" msgid "Expected a UUID" msgstr "Un UUID est attendu" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -555,12 +543,7 @@ msgstr "Tuple de longueur %d attendu, obtenu %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to acquire mutex" -msgstr "Echec de l'obtention de mutex" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Echec de l'obtention de mutex, err 0x%04x" @@ -570,11 +553,6 @@ msgstr "Echec de l'obtention de mutex, err 0x%04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Echec de l'ajout de caractéristique, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to add service" -msgstr "Echec de l'ajout de service" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to add service, err 0x%04x" @@ -601,25 +579,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to connect:" -msgstr "Echec de connection:" - -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to continue scanning" -msgstr "Impossible de poursuivre le scan" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Impossible de poursuivre le scan, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to create mutex" -msgstr "Echec de la création de mutex" - #: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" @@ -661,12 +628,7 @@ msgstr "Impossible de lire la valeur de 'gatts', err 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Echec de l'ajout de l'UUID du fournisseur, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to release mutex" -msgstr "Impossible de libérer mutex" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Impossible de libérer mutex, err 0x%04x" @@ -676,36 +638,31 @@ msgstr "Impossible de libérer mutex, err 0x%04x" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start advertising" -msgstr "Echec du démarrage de la diffusion" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Impossible de commencer à diffuser, err 0x%04x" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start scanning" -msgstr "Impossible de commencer à scanner" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Impossible de commencer à scanner, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to stop advertising" -msgstr "Echec de l'arrêt de diffusion" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Echec de l'arrêt de diffusion, err 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, fuzzy, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -931,6 +888,10 @@ msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Pas de DAC sur la puce" @@ -981,6 +942,7 @@ msgstr "Il n'y a plus d'espace libre sur le périphérique" msgid "No such file/directory" msgstr "Fichier/dossier introuvable" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c #, fuzzy msgid "Not connected" @@ -2212,6 +2174,14 @@ msgstr "pas de module '%q'" msgid "no such attribute" msgstr "pas de tel attribut" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "" @@ -2432,10 +2402,6 @@ msgstr "pile de planification pleine" msgid "script compilation not supported" msgstr "compilation de script non supportée" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "'services' inclut un object qui n'est pas un 'Service'" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "signe non autorisé dans les spéc. de formats de chaînes de caractères" @@ -2747,6 +2713,18 @@ msgstr "'step' nul" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" +#~ msgid "Can't add services in Central mode" +#~ msgstr "Impossible d'ajouter des services en mode Central" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "Impossible de publier en mode Central" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "Modification du nom impossible en mode Central" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "Impossible de se connecter en mode 'Peripheral'" + #~ msgid "Cannot connect to AP" #~ msgstr "Impossible de se connecter à 'AP'" @@ -2759,6 +2737,9 @@ msgstr "'step' nul" #~ msgid "Cannot update i/f status" #~ msgstr "le status i/f ne peut être mis à jour" +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Données trop volumineuses pour le paquet de diffusion" + #~ msgid "Don't know how to pass object to native function" #~ msgstr "Ne sais pas comment passer l'objet à une fonction native" @@ -2771,6 +2752,26 @@ msgstr "'step' nul" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Erreur dans ffi_prep_cif" +#, fuzzy +#~ msgid "Failed to acquire mutex" +#~ msgstr "Echec de l'obtention de mutex" + +#, fuzzy +#~ msgid "Failed to add service" +#~ msgstr "Echec de l'ajout de service" + +#, fuzzy +#~ msgid "Failed to connect:" +#~ msgstr "Echec de connection:" + +#, fuzzy +#~ msgid "Failed to continue scanning" +#~ msgstr "Impossible de poursuivre le scan" + +#, fuzzy +#~ msgid "Failed to create mutex" +#~ msgstr "Echec de la création de mutex" + #, fuzzy #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%08lX" @@ -2779,6 +2780,22 @@ msgstr "'step' nul" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX" +#, fuzzy +#~ msgid "Failed to release mutex" +#~ msgstr "Impossible de libérer mutex" + +#, fuzzy +#~ msgid "Failed to start advertising" +#~ msgstr "Echec du démarrage de la diffusion" + +#, fuzzy +#~ msgid "Failed to start scanning" +#~ msgstr "Impossible de commencer à scanner" + +#, fuzzy +#~ msgid "Failed to stop advertising" +#~ msgstr "Echec de l'arrêt de diffusion" + #~ msgid "Function requires lock." #~ msgstr "La fonction nécessite un verrou." @@ -2936,6 +2953,9 @@ msgstr "'step' nul" #~ msgid "scan failed" #~ msgstr "échec du scan" +#~ msgid "services includes an object that is not a Service" +#~ msgstr "'services' inclut un object qui n'est pas un 'Service'" + #~ msgid "too many arguments" #~ msgstr "trop d'arguments" diff --git a/locale/it_IT.po b/locale/it_IT.po index 6f0e90e176..0637d2e493 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: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -355,21 +355,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "dotstar non può essere usato con %s" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "non si può aggiungere servizi in Central mode" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "non si può pubblicizzare in Central mode" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "non si può cambiare il nome in Central mode" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "non si può connettere in Periferal mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -499,11 +487,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "Impossibile inserire dati nel pacchetto di advertisement." -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Data too large for the advertisement packet" -msgstr "Impossibile inserire dati nel pacchetto di advertisement." - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "La capacità di destinazione è più piccola di destination_length." @@ -543,6 +526,10 @@ msgstr "Non è possibile aggiungere Characteristic." msgid "Expected a UUID" msgstr "Atteso un %q" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -552,12 +539,7 @@ msgstr "" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to acquire mutex" -msgstr "Impossibile allocare buffer RX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" @@ -567,11 +549,6 @@ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Impossibile fermare advertisement. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to add service" -msgstr "Impossibile fermare advertisement. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to add service, err 0x%04x" @@ -598,25 +575,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to connect:" -msgstr "Impossibile connettersi. status: 0x%02x" - -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to continue scanning" -msgstr "Impossible iniziare la scansione. status: 0x%02x" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Impossible iniziare la scansione. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to create mutex" -msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" @@ -656,12 +622,7 @@ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to release mutex" -msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" @@ -671,36 +632,31 @@ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start advertising" -msgstr "Impossibile avviare advertisement. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Impossibile avviare advertisement. status: 0x%02x" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start scanning" -msgstr "Impossible iniziare la scansione. status: 0x%02x" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Impossible iniziare la scansione. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to stop advertising" -msgstr "Impossibile fermare advertisement. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Impossibile fermare advertisement. status: 0x%02x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, fuzzy, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -922,6 +878,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Nessun DAC sul chip" @@ -972,6 +932,7 @@ msgstr "Non che spazio sul dispositivo" msgid "No such file/directory" msgstr "Nessun file/directory esistente" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c #, fuzzy msgid "Not connected" @@ -2173,6 +2134,14 @@ msgstr "nessun modulo chiamato '%q'" msgid "no such attribute" msgstr "attributo inesistente" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "argomento non predefinito segue argmoento predfinito" @@ -2390,10 +2359,6 @@ msgstr "" msgid "script compilation not supported" msgstr "compilazione dello scrip non suportata" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "segno non permesso nello spcificatore di formato della stringa" @@ -2702,6 +2667,18 @@ msgstr "zero step" #~ msgid "C-level assert" #~ msgstr "assert a livello C" +#~ msgid "Can't add services in Central mode" +#~ msgstr "non si può aggiungere servizi in Central mode" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "non si può pubblicizzare in Central mode" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "non si può cambiare il nome in Central mode" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "non si può connettere in Periferal mode" + #~ msgid "Cannot connect to AP" #~ msgstr "Impossible connettersi all'AP" @@ -2714,6 +2691,10 @@ msgstr "zero step" #~ msgid "Cannot update i/f status" #~ msgstr "Impossibile aggiornare status di i/f" +#, fuzzy +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Impossibile inserire dati nel pacchetto di advertisement." + #~ msgid "Don't know how to pass object to native function" #~ msgstr "Non so come passare l'oggetto alla funzione nativa" @@ -2726,6 +2707,26 @@ msgstr "zero step" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Errore in ffi_prep_cif" +#, fuzzy +#~ msgid "Failed to acquire mutex" +#~ msgstr "Impossibile allocare buffer RX" + +#, fuzzy +#~ msgid "Failed to add service" +#~ msgstr "Impossibile fermare advertisement. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to connect:" +#~ msgstr "Impossibile connettersi. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to continue scanning" +#~ msgstr "Impossible iniziare la scansione. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to create mutex" +#~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" + #, fuzzy #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x" @@ -2734,6 +2735,22 @@ msgstr "zero step" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" +#, fuzzy +#~ msgid "Failed to release mutex" +#~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to start advertising" +#~ msgstr "Impossibile avviare advertisement. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to start scanning" +#~ msgstr "Impossible iniziare la scansione. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to stop advertising" +#~ msgstr "Impossibile fermare advertisement. status: 0x%02x" + #~ msgid "GPIO16 does not support pull up." #~ msgstr "GPIO16 non supporta pull-up" diff --git a/locale/pl.po b/locale/pl.po index a7155e0c8d..4ea878146a 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -351,21 +351,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Nie można używać dotstar z %s" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "Nie można dodać serwisów w trybie Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "Nie można rozgłaszać w trybie Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "Nie można zmienić nazwy w trybie Central" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "Nie można się łączyć w trybie Peripheral" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -490,10 +478,6 @@ msgstr "Fragment danych musi następować po fragmencie fmt" msgid "Data too large for advertisement packet" msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Pojemność celu mniejsza od destination_length." @@ -531,6 +515,10 @@ msgstr "Oczekiwano charakterystyki" msgid "Expected a UUID" msgstr "Oczekiwano UUID" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -540,11 +528,7 @@ msgstr "Oczekiwano krotkę długości %d, otrzymano %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to acquire mutex" -msgstr "Nie udało się uzyskać blokady" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" @@ -554,10 +538,6 @@ msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Nie udało się dodać charakterystyki, błąd 0x$04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to add service" -msgstr "Nie udało się dodać serwisu" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to add service, err 0x%04x" @@ -583,22 +563,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "Nie udało się połączenie:" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" -msgstr "Nie udała się kontynuacja skanowania" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Nie udała się kontynuacja skanowania, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to create mutex" -msgstr "Nie udało się stworzyć blokady" - #: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "Nie udało się odkryć serwisów" @@ -636,11 +608,7 @@ msgstr "Nie udało się odczytać gatts, błąd 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Nie udało się zarejestrować UUID dostawcy, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to release mutex" -msgstr "Nie udało się zwolnić blokady" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Nie udało się zwolnić blokady, błąd 0x%04x" @@ -650,33 +618,31 @@ msgstr "Nie udało się zwolnić blokady, błąd 0x%04x" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start advertising" -msgstr "Nie udało się rozpocząć rozgłaszania" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Nie udało się rozpocząć rozgłaszania, błąd 0x%04x" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start scanning" -msgstr "Nie udało się rozpocząć skanowania" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Nie udało się rozpocząć skanowania, błąd 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to stop advertising" -msgstr "Nie udało się zatrzymać rozgłaszania" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Nie udało się zatrzymać rozgłaszania, błąd 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -899,6 +865,10 @@ msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Brak DAC" @@ -949,6 +919,7 @@ msgstr "Brak miejsca" msgid "No such file/directory" msgstr "Brak pliku/katalogu" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c msgid "Not connected" msgstr "Nie podłączono" @@ -2123,6 +2094,14 @@ msgstr "brak modułu o nazwie '%q'" msgid "no such attribute" msgstr "nie ma takiego atrybutu" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "argument z wartością domyślną przed argumentem bez" @@ -2333,10 +2312,6 @@ msgstr "stos planu pełen" msgid "script compilation not supported" msgstr "kompilowanie skryptów nieobsługiwane" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "obiekt typu innego niż Service w services" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "znak jest niedopuszczalny w specyfikacji formatu łańcucha" @@ -2638,6 +2613,48 @@ msgstr "zerowy krok" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Adres nie ma długości %d bajtów lub zły format" +#~ msgid "Can't add services in Central mode" +#~ msgstr "Nie można dodać serwisów w trybie Central" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "Nie można rozgłaszać w trybie Central" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "Nie można zmienić nazwy w trybie Central" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "Nie można się łączyć w trybie Peripheral" + +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" + +#~ msgid "Failed to acquire mutex" +#~ msgstr "Nie udało się uzyskać blokady" + +#~ msgid "Failed to add service" +#~ msgstr "Nie udało się dodać serwisu" + +#~ msgid "Failed to connect:" +#~ msgstr "Nie udało się połączenie:" + +#~ msgid "Failed to continue scanning" +#~ msgstr "Nie udała się kontynuacja skanowania" + +#~ msgid "Failed to create mutex" +#~ msgstr "Nie udało się stworzyć blokady" + +#~ msgid "Failed to release mutex" +#~ msgstr "Nie udało się zwolnić blokady" + +#~ msgid "Failed to start advertising" +#~ msgstr "Nie udało się rozpocząć rozgłaszania" + +#~ msgid "Failed to start scanning" +#~ msgstr "Nie udało się rozpocząć skanowania" + +#~ msgid "Failed to stop advertising" +#~ msgstr "Nie udało się zatrzymać rozgłaszania" + #~ msgid "Invalid bit clock pin" #~ msgstr "Zła nóżka zegara" @@ -2655,3 +2672,6 @@ msgstr "zerowy krok" #~ msgid "interval not in range 0.0020 to 10.24" #~ msgstr "przedział poza zakresem 0.0020 do 10.24" + +#~ msgid "services includes an object that is not a Service" +#~ msgstr "obiekt typu innego niż Service w services" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 01eda181f5..d924171566 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: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -352,20 +352,8 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c @@ -494,11 +482,6 @@ msgstr "Pedaço de dados deve seguir o pedaço de cortes" msgid "Data too large for advertisement packet" msgstr "Não é possível ajustar dados no pacote de anúncios." -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Data too large for the advertisement packet" -msgstr "Não é possível ajustar dados no pacote de anúncios." - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -538,6 +521,10 @@ msgstr "Não é possível adicionar Característica." msgid "Expected a UUID" msgstr "Esperado um" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -547,12 +534,7 @@ msgstr "" msgid "Failed sending command." msgstr "Falha ao enviar comando." -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to acquire mutex" -msgstr "Falha ao alocar buffer RX" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" @@ -562,11 +544,6 @@ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Não pode parar propaganda. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to add service" -msgstr "Não pode parar propaganda. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to add service, err 0x%04x" @@ -593,11 +570,7 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" +msgid "Failed to connect: timeout" msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c @@ -605,11 +578,6 @@ msgstr "" msgid "Failed to continue scanning, err 0x%04x" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to create mutex" -msgstr "Não é possível ler o valor do atributo. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Central.c #, fuzzy msgid "Failed to discover services" @@ -649,12 +617,7 @@ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Não é possível adicionar o UUID de 128 bits específico do fornecedor." -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to release mutex" -msgstr "Não é possível ler o valor do atributo. status: 0x%02x" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, fuzzy, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" @@ -664,36 +627,31 @@ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start advertising" -msgstr "Não é possível iniciar o anúncio. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" #: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to start scanning" -msgstr "Não é possível iniciar o anúncio. status: 0x%02x" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, fuzzy, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Não é possível iniciar o anúncio. status: 0x%02x" -#: ports/nrf/common-hal/bleio/Central.c -#, fuzzy -msgid "Failed to stop advertising" -msgstr "Não pode parar propaganda. status: 0x%02x" - #: ports/nrf/common-hal/bleio/Peripheral.c #, fuzzy, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Não pode parar propaganda. status: 0x%02x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, fuzzy, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -912,6 +870,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Nenhum DAC no chip" @@ -962,6 +924,7 @@ msgstr "" msgid "No such file/directory" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c #, fuzzy msgid "Not connected" @@ -2132,6 +2095,14 @@ msgstr "" msgid "no such attribute" msgstr "" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "" @@ -2341,10 +2312,6 @@ msgstr "" msgid "script compilation not supported" msgstr "compilação de script não suportada" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "" @@ -2660,6 +2627,10 @@ msgstr "passo zero" #~ msgid "Cannot update i/f status" #~ msgstr "Não é possível atualizar o status i/f" +#, fuzzy +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Não é possível ajustar dados no pacote de anúncios." + #~ msgid "Don't know how to pass object to native function" #~ msgstr "Não sabe como passar o objeto para a função nativa" @@ -2672,6 +2643,18 @@ msgstr "passo zero" #~ msgid "Error in ffi_prep_cif" #~ msgstr "Erro no ffi_prep_cif" +#, fuzzy +#~ msgid "Failed to acquire mutex" +#~ msgstr "Falha ao alocar buffer RX" + +#, fuzzy +#~ msgid "Failed to add service" +#~ msgstr "Não pode parar propaganda. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to create mutex" +#~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" + #, fuzzy #~ msgid "Failed to notify or indicate attribute value, err %0x04x" #~ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x" @@ -2680,6 +2663,22 @@ msgstr "passo zero" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" +#, fuzzy +#~ msgid "Failed to release mutex" +#~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to start advertising" +#~ msgstr "Não é possível iniciar o anúncio. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to start scanning" +#~ msgstr "Não é possível iniciar o anúncio. status: 0x%02x" + +#, fuzzy +#~ msgid "Failed to stop advertising" +#~ msgstr "Não pode parar propaganda. status: 0x%02x" + #~ msgid "GPIO16 does not support pull up." #~ msgstr "GPIO16 não suporta pull up." diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 79d803d674..c48cb6b2c7 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-06-19 09:49-0400\n" +"POT-Creation-Date: 2019-07-09 08:43-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -352,21 +352,9 @@ msgstr "" msgid "Can not use dotstar with %s" msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" -#: shared-bindings/bleio/Central.c -msgid "Can't add services in Central mode" -msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" - -#: shared-bindings/bleio/Central.c -msgid "Can't advertise in Central mode" -msgstr "Wúfǎ zài zhōngyāng móshì zhōng guǎnggào" - -#: shared-bindings/bleio/Central.c -msgid "Can't change the name in Central mode" -msgstr "Wúfǎ gēnggǎi zhōngyāng móshì de míngchēng" - -#: shared-bindings/bleio/Central.c -msgid "Can't connect in Peripheral mode" -msgstr "Wúfǎ zài biānyuán móshì zhōng liánjiē" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "Can't set CCCD for local Characteristic" +msgstr "" #: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" @@ -491,10 +479,6 @@ msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" msgid "Data too large for advertisement packet" msgstr "Guǎnggào bāo de shùjù tài dà" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Data too large for the advertisement packet" -msgstr "Guǎnggào bāo de shùjù tài dà" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Mùbiāo róngliàng xiǎoyú mùdì de_chángdù." @@ -532,6 +516,10 @@ msgstr "Yùqí de tèdiǎn" msgid "Expected a UUID" msgstr "Yùqí UUID" +#: shared-bindings/bleio/Central.c +msgid "Expected an Address" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -541,11 +529,7 @@ msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" msgid "Failed sending command." msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to acquire mutex" -msgstr "Wúfǎ huòdé mutex" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to acquire mutex, err 0x%04x" msgstr "Wúfǎ huòdé mutex, err 0x%04x" @@ -555,10 +539,6 @@ msgstr "Wúfǎ huòdé mutex, err 0x%04x" msgid "Failed to add characteristic, err 0x%04x" msgstr "Tiānjiā tèxìng shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to add service" -msgstr "Tiānjiā fúwù shībài" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to add service, err 0x%04x" @@ -584,22 +564,14 @@ msgid "Failed to configure advertising, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to connect:" -msgstr "Liánjiē shībài:" - -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to continue scanning" -msgstr "Jìxù sǎomiáo shībài" +msgid "Failed to connect: timeout" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, c-format msgid "Failed to continue scanning, err 0x%04x" msgstr "Jìxù sǎomiáo shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to create mutex" -msgstr "Wúfǎ chuàngjiàn hù chì suǒ" - #: ports/nrf/common-hal/bleio/Central.c msgid "Failed to discover services" msgstr "Fāxiàn fúwù shībài" @@ -637,11 +609,7 @@ msgstr "Wúfǎ dòu qǔ gatts zhí, err 0x%04x" msgid "Failed to register Vendor-Specific UUID, err 0x%04x" msgstr "Wúfǎ zhùcè màizhǔ tèdìng de UUID, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to release mutex" -msgstr "Wúfǎ shìfàng mutex" - -#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c +#: ports/nrf/sd_mutex.c #, c-format msgid "Failed to release mutex, err 0x%04x" msgstr "Wúfǎ shìfàng mutex, err 0x%04x" @@ -651,33 +619,31 @@ msgstr "Wúfǎ shìfàng mutex, err 0x%04x" msgid "Failed to set device name, err 0x%04x" msgstr "" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start advertising" -msgstr "Qǐdòng guǎnggào shībài" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to start advertising, err 0x%04x" msgstr "Qǐdòng guǎnggào shībài, err 0x%04x" #: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to start scanning" -msgstr "Qǐdòng sǎomiáo shībài" +#, c-format +msgid "Failed to start connecting, error 0x%04x" +msgstr "" #: ports/nrf/common-hal/bleio/Scanner.c #, c-format msgid "Failed to start scanning, err 0x%04x" msgstr "Qǐdòng sǎomiáo shībài, err 0x%04x" -#: ports/nrf/common-hal/bleio/Central.c -msgid "Failed to stop advertising" -msgstr "Wúfǎ tíngzhǐ guǎnggào" - #: ports/nrf/common-hal/bleio/Peripheral.c #, c-format msgid "Failed to stop advertising, err 0x%04x" msgstr "Wúfǎ tíngzhǐ guǎnggào, err 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "Failed to write CCCD, err 0x%04x" +msgstr "" + #: ports/nrf/common-hal/bleio/Characteristic.c #, c-format msgid "Failed to write attribute value, err 0x%04x" @@ -899,6 +865,10 @@ msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi msgid "Must be a %q subclass." msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogOut.c msgid "No DAC on chip" msgstr "Méiyǒu DAC zài xīnpiàn shàng de" @@ -949,6 +919,7 @@ msgstr "Shèbèi shàng méiyǒu kònggé" msgid "No such file/directory" msgstr "Méiyǒu cǐ lèi wénjiàn/mùlù" +#: ports/nrf/common-hal/bleio/Characteristic.c #: shared-bindings/bleio/CharacteristicBuffer.c msgid "Not connected" msgstr "Wèi liánjiē" @@ -2135,6 +2106,14 @@ msgstr "méiyǒu mókuài '%q'" msgid "no such attribute" msgstr "méiyǒu cǐ shǔxìng" +#: shared-bindings/bleio/Peripheral.c +msgid "non-Service found in services" +msgstr "" + +#: ports/nrf/common-hal/bleio/Central.c +msgid "non-UUID found in service_uuids" +msgstr "" + #: py/compile.c msgid "non-default argument follows default argument" msgstr "bùshì mòrèn cānshù zūnxún mòrèn cānshù" @@ -2345,10 +2324,6 @@ msgstr "jìhuà duīzhàn yǐ mǎn" msgid "script compilation not supported" msgstr "bù zhīchí jiǎoběn biānyì" -#: shared-bindings/bleio/Peripheral.c -msgid "services includes an object that is not a Service" -msgstr "fúwù bāokuò yīgè bùshì fúwù de wùjiàn" - #: py/objstr.c msgid "sign not allowed in string format specifier" msgstr "zìfú chuàn géshì shuōmíng fú zhōng bù yǔnxǔ shǐyòng fúhào" @@ -2650,6 +2625,48 @@ msgstr "líng bù" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" +#~ msgid "Can't add services in Central mode" +#~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" + +#~ msgid "Can't advertise in Central mode" +#~ msgstr "Wúfǎ zài zhōngyāng móshì zhōng guǎnggào" + +#~ msgid "Can't change the name in Central mode" +#~ msgstr "Wúfǎ gēnggǎi zhōngyāng móshì de míngchēng" + +#~ msgid "Can't connect in Peripheral mode" +#~ msgstr "Wúfǎ zài biānyuán móshì zhōng liánjiē" + +#~ msgid "Data too large for the advertisement packet" +#~ msgstr "Guǎnggào bāo de shùjù tài dà" + +#~ msgid "Failed to acquire mutex" +#~ msgstr "Wúfǎ huòdé mutex" + +#~ msgid "Failed to add service" +#~ msgstr "Tiānjiā fúwù shībài" + +#~ msgid "Failed to connect:" +#~ msgstr "Liánjiē shībài:" + +#~ msgid "Failed to continue scanning" +#~ msgstr "Jìxù sǎomiáo shībài" + +#~ msgid "Failed to create mutex" +#~ msgstr "Wúfǎ chuàngjiàn hù chì suǒ" + +#~ msgid "Failed to release mutex" +#~ msgstr "Wúfǎ shìfàng mutex" + +#~ msgid "Failed to start advertising" +#~ msgstr "Qǐdòng guǎnggào shībài" + +#~ msgid "Failed to start scanning" +#~ msgstr "Qǐdòng sǎomiáo shībài" + +#~ msgid "Failed to stop advertising" +#~ msgstr "Wúfǎ tíngzhǐ guǎnggào" + #~ msgid "Invalid bit clock pin" #~ msgstr "Wúxiào de wèi shízhōng yǐn jiǎo" @@ -2686,6 +2703,9 @@ msgstr "líng bù" #~ msgid "row must be packed and word aligned" #~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí" +#~ msgid "services includes an object that is not a Service" +#~ msgstr "fúwù bāokuò yīgè bùshì fúwù de wùjiàn" + #~ msgid "too many arguments" #~ msgstr "tài duō cānshù" From d8a4f71ec77a9aa8f5e037a94b7dd72022f24e86 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 9 Jul 2019 09:11:04 -0400 Subject: [PATCH 20/25] translation merges --- locale/ID.po | 6 +++--- locale/circuitpython.pot | 6 +++--- locale/de_DE.po | 6 +++--- locale/en_US.po | 6 +++--- locale/en_x_pirate.po | 6 +++--- locale/es.po | 31 ++++++++++++++++++------------- locale/fil.po | 6 +++--- locale/fr.po | 6 +++--- locale/it_IT.po | 6 +++--- locale/pl.po | 6 +++--- locale/pt_BR.po | 6 +++--- locale/zh_Latn_pinyin.po | 6 +++--- 12 files changed, 51 insertions(+), 46 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 65e21e5e4c..33e63bd2ce 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1341,8 +1341,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "argumen num/types tidak cocok" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index eb1c3cc739..6b38f11e31 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:07-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1308,8 +1308,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index dc9199dbc0..cf115716fb 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -1348,8 +1348,8 @@ msgstr "arg ist eine leere Sequenz" msgid "argument has wrong type" msgstr "Argument hat falschen Typ" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "Anzahl/Type der Argumente passen nicht" diff --git a/locale/en_US.po b/locale/en_US.po index a7b7cb36bd..ab1776aa24 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -1308,8 +1308,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index dc157140c5..550966a943 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -1312,8 +1312,8 @@ msgstr "" msgid "argument has wrong type" msgstr "" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "" diff --git a/locale/es.po b/locale/es.po index 441b1af5c5..a1e90b0eb9 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:07-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -219,11 +219,6 @@ msgstr "pow() con 3 argumentos no soportado" msgid "A hardware interrupt channel is already in use" msgstr "El canal EXTINT ya está siendo utilizado" -#: shared-bindings/bleio/Address.c -#, c-format -msgid "Address is not %d bytes long or is in wrong format" -msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" - #: shared-bindings/bleio/Address.c #, c-format msgid "Address must be %d bytes long" @@ -251,7 +246,9 @@ msgstr "Todos los canales de eventos estan siendo usados" #: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "All sync event channels in use" -msgstr "Todos los canales de eventos de sincronización (sync event channels) están siendo utilizados" +msgstr "" +"Todos los canales de eventos de sincronización (sync event channels) están " +"siendo utilizados" #: shared-bindings/pulseio/PWMOut.c msgid "All timers for this pin are in use" @@ -291,7 +288,9 @@ msgstr "Valores del array deben ser bytes individuales." #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running.\n" -msgstr "Intento de allocation de heap cuando la VM de MicroPython no estaba corriendo.\n" +msgstr "" +"Intento de allocation de heap cuando la VM de MicroPython no estaba " +"corriendo.\n" #: main.c msgid "Auto-reload is off.\n" @@ -301,7 +300,9 @@ msgstr "Auto-recarga deshabilitada.\n" msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" -msgstr "Auto-reload habilitado. Simplemente guarda los archivos via USB para ejecutarlos o entra al REPL para desabilitarlos.\n" +msgstr "" +"Auto-reload habilitado. Simplemente guarda los archivos via USB para " +"ejecutarlos o entra al REPL para desabilitarlos.\n" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must share a clock unit" @@ -657,6 +658,7 @@ msgid "Failed to write CCCD, err 0x%04x" msgstr "" #: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format msgid "Failed to write attribute value, err 0x%04x" msgstr "No se puede escribir el valor del atributo. err: 0x%04x" @@ -712,7 +714,9 @@ msgstr "operación I2C no soportada" msgid "" "Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/" "mpy-update for more info." -msgstr "Archivo .mpy incompatible. Actualice todos los archivos .mpy. Consulte http://adafru.it/mpy-update para más información" +msgstr "" +"Archivo .mpy incompatible. Actualice todos los archivos .mpy. Consulte " +"http://adafru.it/mpy-update para más información" #: shared-bindings/_pew/PewPew.c msgid "Incorrect buffer size" @@ -941,7 +945,8 @@ msgstr "No reproduciendo" msgid "" "Object has been deinitialized and can no longer be used. Create a new object." msgstr "" -"El objeto se ha desinicializado y ya no se puede utilizar. Crea un nuevo objeto" +"El objeto se ha desinicializado y ya no se puede utilizar. Crea un nuevo " +"objeto" #: ports/nrf/common-hal/busio/UART.c msgid "Odd parity is not supported" @@ -1352,8 +1357,8 @@ msgstr "argumento es una secuencia vacía" msgid "argument has wrong type" msgstr "el argumento tiene un tipo erroneo" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "argumento número/tipos no coinciden" diff --git a/locale/fil.po b/locale/fil.po index 3e8e53f08b..29e969566d 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -1361,8 +1361,8 @@ msgstr "arg ay walang laman na sequence" msgid "argument has wrong type" msgstr "may maling type ang argument" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "hindi tugma ang argument num/types" diff --git a/locale/fr.po b/locale/fr.po index 4ce6d5e0ba..3a4c418d48 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -1386,8 +1386,8 @@ msgstr "l'argument est une séquence vide" msgid "argument has wrong type" msgstr "l'argument est d'un mauvais type" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "argument num/types ne correspond pas" diff --git a/locale/it_IT.po b/locale/it_IT.po index 47ed3d95c9..7504fb1575 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -1355,8 +1355,8 @@ msgstr "l'argomento è una sequenza vuota" msgid "argument has wrong type" msgstr "il tipo dell'argomento è errato" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "discrepanza di numero/tipo di argomenti" diff --git a/locale/pl.po b/locale/pl.po index 1361119cf0..dd4cf7db4a 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -1332,8 +1332,8 @@ msgstr "arg jest puste" msgid "argument has wrong type" msgstr "argument ma zły typ" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "zła liczba lub typ argumentów" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 897a057f97..8b74349faa 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: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -1329,8 +1329,8 @@ msgstr "" msgid "argument has wrong type" msgstr "argumento tem tipo errado" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 5f03dc6aa4..d8d11cd858 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-09 08:43-0400\n" +"POT-Creation-Date: 2019-07-09 09:06-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -1340,8 +1340,8 @@ msgstr "cānshù shì yīgè kōng de xùliè" msgid "argument has wrong type" msgstr "cānshù lèixíng cuòwù" -#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c -#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c msgid "argument num/types mismatch" msgstr "cānshù biānhào/lèixíng bù pǐpèi" From 514d4146d3bf786fe6c582a645e305e709b618ad Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 11 Jul 2019 18:23:45 -0400 Subject: [PATCH 21/25] Fix sphinx warnings. --- shared-bindings/bleio/Central.c | 8 ++++---- shared-bindings/bleio/Scanner.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c index 95ba19dd0b..a21f711af7 100644 --- a/shared-bindings/bleio/Central.c +++ b/shared-bindings/bleio/Central.c @@ -86,16 +86,16 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, //| //| :param bleio.Address address: The address of the peripheral to connect to //| :param float/int timeout: Try to connect for timeout seconds. -//| :param iterable service_uuids: a collection of `UUID` objects for the services +//| :param iterable service_uuids: a collection of :py:class:~`UUID` objects for the services //| provided by the peripheral that you want to use. //| The peripheral may provide more services, but services not listed are ignored. -//| If a service in `service_uuids` is not found during discovery, it will not +//| If a service in service_uuids is not found during discovery, it will not //| appear in `remote_services`. //| -//| If `services` is None, then all services will undergo discovery, which can be slow. +//| If service_uuids is None, then all services will undergo discovery, which can be slow. //| //| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you -//| you must have already created a `UUID` object for that UUID in order for the +//| you must have already created a :py:class:~`UUID` object for that UUID in order for the //| service or characteristic to be discovered. (This restriction may be lifted in the future.) //| STATIC mp_obj_t bleio_central_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index d50f69fc5b..79ab34931e 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -73,8 +73,8 @@ STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, //| :param float timeout: the scan timeout in seconds //| :param float interval: the interval (in seconds) between the start of two consecutive scan windows //| Must be in the range 0.0025 - 40.959375 seconds. -//| :param float window: the duration (in seconds) to scan a single BLE channel -//| `window` must be <= `interval`. +//| :param float window: the duration (in seconds) to scan a single BLE channel. +//| window must be <= interval. //| :returns: advertising packets found //| :rtype: list of :py:class:`bleio.ScanEntry` //| From 12b98be7441d189ff3d26fde188729a9bc3d257f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 11 Jul 2019 18:42:41 -0400 Subject: [PATCH 22/25] merge from master and make translate --- locale/circuitpython.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 6b38f11e31..2ad3316c7f 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: 2019-07-09 09:07-0400\n" +"POT-Creation-Date: 2019-07-11 18:42-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From cb99546ea569bd91421e7ee0884c2756387a12d3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 11 Jul 2019 18:56:29 -0400 Subject: [PATCH 23/25] update frozen libraries --- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- frozen/Adafruit_CircuitPython_Crickit | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_IRRemote | 2 +- frozen/Adafruit_CircuitPython_LIS3DH | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_seesaw | 2 +- frozen/circuitpython-stage | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 6b34029659..b9280af514 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 6b3402965999d068316882d63fae3ab26006477c +Subproject commit b9280af5142fc41639229544678e23b5cca07c3a diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index 1d38fd81ed..154b74de02 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit 1d38fd81edd30f1bd70c0cfe77819ab610ea89a3 +Subproject commit 154b74de020764597ba49f0d1e8cc18d55b3643b diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index a168680356..617bb0787f 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit a1686803566793ec2de7e043bf6822e47cfa31d1 +Subproject commit 617bb0787f2c61283d248632a62b27be80f64b29 diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index 836bb9843f..89faee0eb0 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit 836bb9843fd793683061c15150944f8897d806e9 +Subproject commit 89faee0eb08a6855e14f117c514fecf2dd90769d diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote index aa4428f304..70865ac6e0 160000 --- a/frozen/Adafruit_CircuitPython_IRRemote +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -1 +1 @@ -Subproject commit aa4428f304b982aa19a5800822e78c47dc8a3b6c +Subproject commit 70865ac6e09f821b26ec727e2df300a6d9ebf6b3 diff --git a/frozen/Adafruit_CircuitPython_LIS3DH b/frozen/Adafruit_CircuitPython_LIS3DH index a03f901127..bd7ddc67dc 160000 --- a/frozen/Adafruit_CircuitPython_LIS3DH +++ b/frozen/Adafruit_CircuitPython_LIS3DH @@ -1 +1 @@ -Subproject commit a03f9011279f9e630549432589463912831fcee1 +Subproject commit bd7ddc67dc86f7ad0115f58ab80d5605739c6482 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index 98563ab658..ddc7484498 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit 98563ab65800aac6464f671c0d005df56ecaa6c6 +Subproject commit ddc74844983b35b027bd45091c7b8bb3c8d7a2d1 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index c0ed34813a..c0bdd8b103 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit c0ed34813a608b64ed044826553918ddbad12f0c +Subproject commit c0bdd8b10383725ee9293f5d88fb8d47eb1272bd diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index 1d12cfc0b7..f1171f9408 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit 1d12cfc0b729b4ae0a2f3f4e7c1933a0fbd3b166 +Subproject commit f1171f94083ba64d153ff3f90eeb07500331d6e1 diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index 733cdf5916..6d1ae72916 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit 733cdf591639f9dbb5d9187a21411f759e1ba82f +Subproject commit 6d1ae72916cf240ea86185c45f844d59f56d8ec3 From 364ee62d108bbdc1d4da8bb646a9332a68964b76 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 16 Jul 2019 19:53:36 -0400 Subject: [PATCH 24/25] Address review comments. --- conf.py | 1 + ports/nrf/common-hal/bleio/Scanner.c | 13 ++-- shared-bindings/bleio/Address.c | 52 ++++++++++------ shared-bindings/bleio/Central.c | 19 +++--- shared-bindings/bleio/Characteristic.c | 6 +- shared-bindings/bleio/Descriptor.c | 6 +- shared-bindings/bleio/Peripheral.c | 1 + shared-bindings/bleio/ScanEntry.c | 1 - shared-bindings/bleio/Scanner.c | 8 +-- shared-bindings/bleio/Scanner.h | 3 +- shared-bindings/bleio/Service.c | 6 +- shared-module/bleio/AdvertisementData.h | 79 ------------------------- 12 files changed, 65 insertions(+), 130 deletions(-) delete mode 100644 shared-module/bleio/AdvertisementData.h diff --git a/conf.py b/conf.py index 8586573887..6b0f40da6b 100644 --- a/conf.py +++ b/conf.py @@ -84,6 +84,7 @@ version = release = '0.0.0' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ["**/build*", + ".git", ".venv", ".direnv", "docs/README.md", diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c index fa4f3923c8..57ce940abd 100644 --- a/ports/nrf/common-hal/bleio/Scanner.c +++ b/ports/nrf/common-hal/bleio/Scanner.c @@ -74,10 +74,9 @@ STATIC void scanner_on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) { } void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self) { - self->scan_entries = mp_obj_new_list(0, NULL); } -void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { +mp_obj_t common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) { common_hal_bleio_adapter_set_enabled(true); ble_drv_add_event_handler(scanner_on_ble_evt, self); @@ -87,8 +86,7 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout .scan_phys = BLE_GAP_PHY_1MBPS, }; - // Empty the advertising reports list. - mp_obj_list_clear(self->scan_entries); + self->scan_entries = mp_obj_new_list(0, NULL); uint32_t err_code; err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer); @@ -99,8 +97,9 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout mp_hal_delay_ms(timeout * 1000); sd_ble_gap_scan_stop(); -} -mp_obj_t common_hal_bleio_scanner_get_scan_entries(bleio_scanner_obj_t *self) { - return self->scan_entries; + // Return list, and don't hang on to it, so it can be GC'd. + mp_obj_t entries = self->scan_entries; + self->scan_entries = MP_OBJ_NULL; + return entries; } diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index cfad8fc11d..37f01042ce 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -48,13 +48,9 @@ //| The value itself can be one of: //| //| :param buf address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes. -//| :param int address_type: one of these integers: -//| - ``bleio.Address.PUBLIC`` = 0 -//| - ``bleio.Address.RANDOM_STATIC`` = 1 -//| - ``bleio.Address.RANDOM_PRIVATE_RESOLVABLE`` = 2 -//| - ``bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE`` = 3 +//| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`, +//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`. //| - STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_address_type }; static const mp_arg_t allowed_args[] = { @@ -105,12 +101,9 @@ const mp_obj_property_t bleio_address_address_bytes_obj = { //| .. attribute:: type //| -//| The address type (read-only). One of these integers: -//| -//| - ``bleio.Address.PUBLIC`` = 0 -//| - ``bleio.Address.RANDOM_STATIC`` = 1 -//| - ``bleio.Address.RANDOM_PRIVATE_RESOLVABLE`` = 2 -//| - ``bleio.Address.RANDOM_PRIVATE_NON_RESOLVABLE`` = 3 +//| The address type (read-only). +//| One of the integer values: `PUBLIC`, `RANDOM_STATIC`, +//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`. //| STATIC mp_obj_t bleio_address_get_type(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -154,16 +147,37 @@ STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t address_bytes = common_hal_bleio_address_get_address_bytes(self); + if (kind == PRINT_STR) { + mp_buffer_info_t buf_info; + mp_obj_t address_bytes = common_hal_bleio_address_get_address_bytes(self); + mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ); - mp_buffer_info_t buf_info; - mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ); - const uint8_t *buf = (uint8_t *) buf_info.buf; - mp_printf(print, - "%02x:%02x:%02x:%02x:%02x:%02x", - buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); + const uint8_t *buf = (uint8_t *) buf_info.buf; + mp_printf(print, + "%02x:%02x:%02x:%02x:%02x:%02x", + buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); + } else { + mp_printf(print, "
"); + } } +//| .. data:: PUBLIC +//| +//| A publicly known address, with a company ID (high 24 bits)and company-assigned part (low 24 bits). +//| +//| .. data:: RANDOM_STATIC +//| +//| A randomly generated address that does not change often. It may never change or may change after +//| a power cycle. +//| +//| .. data:: RANDOM_PRIVATE_RESOLVABLE +//| +//| An address that is usable when the peer knows the other device's secret Identity Resolving Key (IRK). +//| +//| .. data:: RANDOM_PRIVATE_NON_RESOLVABLE +//| +//| A randomly generated address that changes on every connection. +//| STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_address_bytes_obj) }, { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_address_type_obj) }, diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c index a21f711af7..fc00bce5cc 100644 --- a/shared-bindings/bleio/Central.c +++ b/shared-bindings/bleio/Central.c @@ -56,7 +56,7 @@ //| //| my_entry = None //| for entry in entries: -//| if entry.name is not None and entry.name == 'MyCentral': +//| if entry.name is not None and entry.name == 'MyPeripheral': //| my_entry = entry //| break //| @@ -86,13 +86,13 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, //| //| :param bleio.Address address: The address of the peripheral to connect to //| :param float/int timeout: Try to connect for timeout seconds. -//| :param iterable service_uuids: a collection of :py:class:~`UUID` objects for the services +//| :param iterable service_uuids_whitelist: an iterable of :py:class:~`UUID` objects for the services //| provided by the peripheral that you want to use. //| The peripheral may provide more services, but services not listed are ignored. //| If a service in service_uuids is not found during discovery, it will not //| appear in `remote_services`. //| -//| If service_uuids is None, then all services will undergo discovery, which can be slow. +//| If service_uuids_whitelist is None, then all services will undergo discovery, which can be slow. //| //| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you //| you must have already created a :py:class:~`UUID` object for that UUID in order for the @@ -101,11 +101,11 @@ STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, STATIC mp_obj_t bleio_central_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_central_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - enum { ARG_address, ARG_timeout, ARG_service_uuids }; + enum { ARG_address, ARG_timeout, ARG_service_uuids_whitelist }; static const mp_arg_t allowed_args[] = { { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_timeout, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_service_uuids, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_service_uuids_whitelist, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -119,7 +119,7 @@ STATIC mp_obj_t bleio_central_connect(mp_uint_t n_args, const mp_obj_t *pos_args mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); // common_hal_bleio_central_connect() will validate that services is an iterable or None. - common_hal_bleio_central_connect(self, address, timeout, args[ARG_service_uuids].u_obj); + common_hal_bleio_central_connect(self, address, timeout, args[ARG_service_uuids_whitelist].u_obj); return mp_const_none; } @@ -160,12 +160,15 @@ const mp_obj_property_t bleio_central_connected_obj = { //| .. attribute:: remote_services (read-only) //| -//| Empty until connected, then a list of services provided by the remote peripheral. +//| A tuple of services provided by the remote peripheral. +//| If the Central is not connected, an empty tuple will be returned. //| STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) { bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in); - return MP_OBJ_FROM_PTR(common_hal_bleio_central_get_remote_services(self)); + // Return list as a tuple so user won't be able to change it. + mp_obj_list_t *service_list = common_hal_bleio_central_get_remote_services(self); + return mp_obj_new_tuple(service_list->len, service_list->items); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services); diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index 0d5f8f79ac..3bf0476ab5 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -316,13 +316,13 @@ STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_locals_dict, bleio_characterist STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "Characteristic("); if (self->uuid) { + mp_printf(print, "Characteristic("); bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind); + mp_printf(print, ")"); } else { - mp_printf(print, "Unregistered uUID"); + mp_printf(print, ""); } - mp_printf(print, ")"); } const mp_obj_type_t bleio_characteristic_type = { diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c index f392838926..f2e5aa01df 100644 --- a/shared-bindings/bleio/Descriptor.c +++ b/shared-bindings/bleio/Descriptor.c @@ -162,13 +162,13 @@ STATIC MP_DEFINE_CONST_DICT(bleio_descriptor_locals_dict, bleio_descriptor_local STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "Descriptor("); if (self->uuid) { + mp_printf(print, "Descriptor("); bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind); + mp_printf(print, ")"); } else { - mp_printf(print, "Unregistered uUID"); + mp_printf(print, ""); } - mp_printf(print, ")"); } const mp_obj_type_t bleio_descriptor_type = { diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index b8d4c39753..1302c96523 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -63,6 +63,7 @@ static const char default_name[] = "CIRCUITPY"; //| Usage:: //| //| import bleio +//| from adafruit_ble.advertising import ServerAdvertisement //| //| # Create a Characteristic. //| chara = bleio.Characteristic(bleio.UUID(0x2919), read=True, notify=True) diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index b7798175cc..6eb02c7166 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -32,7 +32,6 @@ #include "shared-bindings/bleio/Address.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/Scanner.c b/shared-bindings/bleio/Scanner.c index 79ab34931e..712425c25f 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -75,8 +75,8 @@ STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, //| Must be in the range 0.0025 - 40.959375 seconds. //| :param float window: the duration (in seconds) to scan a single BLE channel. //| window must be <= interval. -//| :returns: advertising packets found -//| :rtype: list of :py:class:`bleio.ScanEntry` +//| :returns: an iterable of `bleio.ScanEntry` objects +//| :rtype: iterable //| STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_timeout, ARG_interval, ARG_window }; @@ -110,9 +110,7 @@ STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_m mp_raise_ValueError(translate("window must be <= interval")); } - common_hal_bleio_scanner_scan(self, timeout, interval, window); - - return common_hal_bleio_scanner_get_scan_entries(self); + return common_hal_bleio_scanner_scan(self, timeout, interval, window); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanner_scan_obj, 2, bleio_scanner_scan); diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h index 1bbab78f4f..3a0ce7eae4 100644 --- a/shared-bindings/bleio/Scanner.h +++ b/shared-bindings/bleio/Scanner.h @@ -34,8 +34,7 @@ extern const mp_obj_type_t bleio_scanner_type; extern void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self); -extern void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window); +extern mp_obj_t common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window); extern void common_hal_bleio_scanner_stop(bleio_scanner_obj_t *self); -extern mp_obj_t common_hal_bleio_scanner_get_scan_entries(bleio_scanner_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index af215c6a50..db06069913 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -166,13 +166,13 @@ STATIC MP_DEFINE_CONST_DICT(bleio_service_locals_dict, bleio_service_locals_dict STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "Service("); if (self->uuid) { + mp_printf(print, "Service("); bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind); + mp_printf(print, ")"); } else { - mp_printf(print, "unregistered UUID"); + mp_printf(print, ""); } - mp_printf(print, ")"); } const mp_obj_type_t bleio_service_type = { diff --git a/shared-module/bleio/AdvertisementData.h b/shared-module/bleio/AdvertisementData.h deleted file mode 100644 index 89cdfb0700..0000000000 --- a/shared-module/bleio/AdvertisementData.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Dan Halbert for Adafruit Industries - * Copyright (c) 2018 Artur Pacholec - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_SHARED_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, - AdIncompleteListOf16BitServiceClassUUIDs = 0x02, - AdCompleteListOf16BitServiceClassUUIDs = 0x03, - AdIncompleteListOf32BitServiceClassUUIDs = 0x04, - AdCompleteListOf32BitServiceClassUUIDs = 0x05, - AdIncompleteListOf128BitServiceClassUUIDs = 0x06, - AdCompleteListOf128BitServiceClassUUIDs = 0x07, - AdShortenedLocalName = 0x08, - AdCompleteLocalName = 0x09, - AdTxPowerLevel = 0x0A, - AdClassOfDevice = 0x0D, - AdSimplePairingHashC = 0x0E, - AdSimplePairingRandomizerR = 0x0F, - AdSecurityManagerTKValue = 0x10, - AdSecurityManagerOOBFlags = 0x11, - AdSlaveConnectionIntervalRange = 0x12, - AdListOf16BitServiceSolicitationUUIDs = 0x14, - AdListOf128BitServiceSolicitationUUIDs = 0x15, - AdServiceData = 0x16, - AdPublicTargetAddress = 0x17, - AdRandomTargetAddress = 0x18, - AdAppearance = 0x19, - AdAdvertisingInterval = 0x1A, - AdLEBluetoothDeviceAddress = 0x1B, - AdLERole = 0x1C, - AdSimplePairingHashC256 = 0x1D, - AdSimplePairingRandomizerR256 = 0x1E, - AdListOf32BitServiceSolicitationUUIDs = 0x1F, - AdServiceData32BitUUID = 0x20, - AdServiceData128BitUUID = 0x21, - AdLESecureConnectionsConfirmationValue = 0x22, - AdLESecureConnectionsRandomValue = 0x23, - AdURI = 0x24, - AdIndoorPositioning = 0x25, - AdTransportDiscoveryData = 0x26, - AdLESupportedFeatures = 0x27, - AdChannelMapUpdateIndication = 0x28, - AdPBADV = 0x29, - AdMeshMessage = 0x2A, - AdMeshBeacon = 0x2B, - Ad3DInformationData = 0x3D, - AdManufacturerSpecificData = 0xFF, -}; - -#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H From 1c31cf5f6a6d9cff6f086114f6e0a03b5247c623 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 16 Jul 2019 21:03:36 -0400 Subject: [PATCH 25/25] sphinx fix --- shared-bindings/bleio/Scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index 712425c25f..269c42591d 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -75,7 +75,7 @@ STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, //| Must be in the range 0.0025 - 40.959375 seconds. //| :param float window: the duration (in seconds) to scan a single BLE channel. //| window must be <= interval. -//| :returns: an iterable of `bleio.ScanEntry` objects +//| :returns: an iterable of `ScanEntry` objects //| :rtype: iterable //| STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {