From 72d993d60c5e5238942491df00776ca31f9758a1 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 14 Jan 2019 15:14:40 -0800 Subject: py changes for supporting superclass constructors that take kwargs --- py/objstr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'py/objstr.c') diff --git a/py/objstr.c b/py/objstr.c index 621f1b837..637323f4c 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -132,14 +132,14 @@ STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t } } -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { #if MICROPY_CPYTHON_COMPAT - if (n_kw != 0) { + if (kw_args != NULL && kw_args->used != 0) { mp_arg_error_unimpl_kw(); } #endif - mp_arg_check_num(n_args, n_kw, 0, 3, false); + mp_arg_check_num(n_args, kw_args, 0, 3, false); switch (n_args) { case 0: @@ -190,11 +190,11 @@ mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_ } } -STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { (void)type_in; #if MICROPY_CPYTHON_COMPAT - if (n_kw != 0) { + if (kw_args != NULL && kw_args->used != 0) { mp_arg_error_unimpl_kw(); } #else @@ -455,7 +455,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { if (!MP_OBJ_IS_TYPE(arg, &mp_type_list) && !MP_OBJ_IS_TYPE(arg, &mp_type_tuple)) { // arg is not a list nor a tuple, try to convert it to a list // TODO: Try to optimize? - arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); + arg = mp_type_list.make_new(&mp_type_list, 1, &arg, NULL); } mp_obj_get_array(arg, &seq_len, &seq_items); @@ -1875,7 +1875,7 @@ STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) { args = new_args; n_args++; } - return mp_obj_str_make_new(&mp_type_str, n_args, 0, args); + return mp_obj_str_make_new(&mp_type_str, n_args, args, NULL); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode); @@ -1888,7 +1888,7 @@ STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) { args = new_args; n_args++; } - return bytes_make_new(NULL, n_args, 0, args); + return bytes_make_new(NULL, n_args, args, NULL); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj, 1, 3, str_encode); #endif -- cgit v1.2.3 From c27175496248424c0581211aa53a5371f44a37ce Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 14 Jan 2019 18:09:02 -0800 Subject: fixup micropy --- extmod/moduhashlib.c | 12 ++++++------ py/objenumerate.c | 2 +- py/objstr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'py/objstr.c') diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 1618594e9..970c63da8 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -66,8 +66,8 @@ STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_MBEDTLS -STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); +STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 0, 1, false); mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(mbedtls_sha256_context)); o->base.type = type; mbedtls_sha256_init((mbedtls_sha256_context*)&o->state); @@ -104,8 +104,8 @@ static void check_not_unicode(const mp_obj_t arg) { #endif } -STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); +STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 0, 1, false); mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX)); o->base.type = type; sha256_init((CRYAL_SHA256_CTX*)o->state); @@ -155,8 +155,8 @@ STATIC const mp_obj_type_t uhashlib_sha256_type = { STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg); #if MICROPY_SSL_AXTLS -STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 1, false); +STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 0, 1, false); mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(SHA1_CTX)); o->base.type = type; SHA1_Init((SHA1_CTX*)o->state); diff --git a/py/objenumerate.c b/py/objenumerate.c index 4919a9b8f..818725d85 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -59,7 +59,7 @@ STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, con o->iter = mp_getiter(arg_vals.iterable.u_obj, NULL); o->cur = arg_vals.start.u_int; #else - (void)n_kw; + (void)kw_args; mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); o->base.type = type; o->iter = mp_getiter(args[0], NULL); diff --git a/py/objstr.c b/py/objstr.c index 637323f4c..9b6cb0cf4 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -198,7 +198,7 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons mp_arg_error_unimpl_kw(); } #else - (void)n_kw; + (void)kw_args; #endif if (n_args == 0) { -- cgit v1.2.3 From c60f77d5ab5c68f1fdaf0c734b77629418c7f903 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 4 Feb 2019 15:33:36 -0800 Subject: Check sequence multiply for length overflow Fixes #1279 --- py/obj.h | 2 ++ py/objlist.c | 3 ++- py/objstr.c | 3 ++- py/objtuple.c | 3 ++- py/sequence.c | 9 +++++++++ 5 files changed, 17 insertions(+), 3 deletions(-) (limited to 'py/objstr.c') diff --git a/py/obj.h b/py/obj.h index 74ce6a0a9..95e208021 100644 --- a/py/obj.h +++ b/py/obj.h @@ -844,6 +844,8 @@ typedef struct { mp_int_t step; } mp_bound_slice_t; +// Compute the new length of a sequence and ensure an exception is thrown on overflow. +size_t mp_seq_multiply_len(size_t item_sz, size_t len); void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest); #if MICROPY_PY_BUILTINS_SLICE bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes); diff --git a/py/objlist.c b/py/objlist.c index 67940e44c..16ca4b353 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -126,7 +126,8 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { if (n < 0) { n = 0; } - mp_obj_list_t *s = list_new(o->len * n); + size_t new_len = mp_seq_multiply_len(o->len, n); + mp_obj_list_t *s = list_new(new_len); mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); return MP_OBJ_FROM_PTR(s); } diff --git a/py/objstr.c b/py/objstr.c index 9b6cb0cf4..7236d9772 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -332,8 +332,9 @@ mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i return mp_const_empty_bytes; } } + size_t new_len = mp_seq_multiply_len(lhs_len, n); vstr_t vstr; - vstr_init_len(&vstr, lhs_len * n); + vstr_init_len(&vstr, new_len); mp_seq_multiply(lhs_data, sizeof(*lhs_data), lhs_len, n, vstr.buf); return mp_obj_new_str_from_vstr(lhs_type, &vstr); } diff --git a/py/objtuple.c b/py/objtuple.c index d3262cebd..474f81c1a 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -160,7 +160,8 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { if (n <= 0) { return mp_const_empty_tuple; } - mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(o->len * n, NULL)); + size_t new_len = mp_seq_multiply_len(o->len, n); + mp_obj_tuple_t *s = MP_OBJ_TO_PTR(mp_obj_new_tuple(new_len, NULL)); mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); return MP_OBJ_FROM_PTR(s); } diff --git a/py/sequence.c b/py/sequence.c index cc31be983..26b432578 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -34,6 +34,15 @@ #define SWAP(type, var1, var2) { type t = var2; var2 = var1; var1 = t; } +// Detect when a multiply causes an overflow. +size_t mp_seq_multiply_len(size_t item_sz, size_t len) { + size_t new_len; + if (__builtin_umul_overflow(item_sz, len, &new_len)) { + mp_raise_msg(&mp_type_OverflowError, translate("small int overflow")); + } + return new_len; +} + // Implements backend of sequence * integer operation. Assumes elements are // memory-adjacent in sequence. void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest) { -- cgit v1.2.3 From 0865c9d38193b61898d631081161cac4d3365437 Mon Sep 17 00:00:00 2001 From: Noralf Trønnes Date: Tue, 12 Feb 2019 22:42:59 +0100 Subject: extmod/ure: Support search/match() pos and endpos parameters MICROPY_PY_URE_MATCH_SPAN_START_END is used to enable the functionality since it's similar. --- extmod/modure.c | 29 +++++++++++++++++++++++++++++ py/objstr.c | 9 +++++++++ py/objstr.h | 2 ++ py/objstrunicode.c | 20 ++++++++++++++++++++ 4 files changed, 60 insertions(+) (limited to 'py/objstr.c') diff --git a/extmod/modure.c b/extmod/modure.c index 847801966..a368ee8fa 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -178,6 +178,35 @@ STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *args) { size_t len; subj.begin = mp_obj_str_get_data(args[1], &len); subj.end = subj.begin + len; +#if MICROPY_PY_URE_MATCH_SPAN_START_END + if (n_args > 2) { + const mp_obj_type_t *self_type = mp_obj_get_type(args[1]); + mp_int_t str_len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(args[1])); + const byte *begin = (const byte *)subj.begin; + + int pos = mp_obj_get_int(args[2]); + if (pos >= str_len) { + return mp_const_none; + } + if (pos < 0) { + pos = 0; + } + const byte *pos_ptr = str_index_to_ptr(self_type, begin, len, MP_OBJ_NEW_SMALL_INT(pos), true); + + const byte *endpos_ptr = (const byte *)subj.end; + if (n_args > 3) { + int endpos = mp_obj_get_int(args[3]); + if (endpos <= pos) { + return mp_const_none; + } + // Will cap to length + endpos_ptr = str_index_to_ptr(self_type, begin, len, args[3], true); + } + + subj.begin = (const char *)pos_ptr; + subj.end = (const char *)endpos_ptr; + } +#endif int caps_num = (self->re.sub + 1) * 2; mp_obj_match_t *match = m_new_obj_var(mp_obj_match_t, char*, caps_num); // cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char diff --git a/py/objstr.c b/py/objstr.c index 7236d9772..ebd11d5cc 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -408,6 +408,15 @@ mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i #if !MICROPY_PY_BUILTINS_STR_UNICODE // objstrunicode defines own version +size_t str_offset_to_index(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + size_t offset) { + if (offset > self_len) { + mp_raise_ValueError(translate("offset out of bounds")); + } + + return offset; +} + const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, mp_obj_t index, bool is_slice) { size_t index_val = mp_get_index(type, self_len, index, is_slice); diff --git a/py/objstr.h b/py/objstr.h index 895130446..0efe62a80 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -71,6 +71,8 @@ mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, siz mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags); +size_t str_offset_to_index(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + size_t offset); const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, mp_obj_t index, bool is_slice); const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 03106f987..30000a51e 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -112,6 +112,26 @@ STATIC mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) { } } +size_t str_offset_to_index(const mp_obj_type_t *type, const byte *self_data, size_t self_len, + size_t offset) { + if (offset > self_len) { + mp_raise_ValueError(translate("offset out of bounds")); + } + + if (type == &mp_type_bytes) { + return offset; + } + + size_t index_val = 0; + const byte *s = self_data; + for (size_t i = 0; i < offset; i++, s++) { + if (!UTF8_IS_CONT(*s)) { + ++index_val; + } + } + return index_val; +} + // Convert an index into a pointer to its lead byte. Out of bounds indexing will raise IndexError or // be capped to the first/last character of the string, depending on is_slice. const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, -- cgit v1.2.3 From 91d791afd091ba38bb61689e88a7fc03b9679e00 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 31 Jul 2019 00:30:24 -0400 Subject: cleanup adapter.address; add uniquish suffix to BLE device name --- ports/nrf/common-hal/bleio/Adapter.c | 41 ++++++++++++++++++++++++++++-------- py/objstr.c | 6 ++++++ py/objstr.h | 3 +++ shared-bindings/bleio/Adapter.c | 36 +++++++++++++++++++++---------- shared-bindings/bleio/Adapter.h | 3 ++- shared-bindings/bleio/Address.c | 19 ++++++----------- shared-bindings/bleio/Peripheral.c | 21 +++++++----------- supervisor/shared/usb/usb.c | 5 ++--- 8 files changed, 85 insertions(+), 49 deletions(-) (limited to 'py/objstr.c') diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 9d0912930..936dfcb9b 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -34,10 +34,11 @@ #include "nrfx_power.h" #include "nrf_nvic.h" #include "nrf_sdm.h" +#include "py/objstr.h" #include "py/runtime.h" -#include "shared-bindings/bleio/Adapter.h" - #include "supervisor/usb.h" +#include "shared-bindings/bleio/Adapter.h" +#include "shared-bindings/bleio/Address.h" STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { mp_raise_msg_varg(&mp_type_AssertionError, @@ -132,20 +133,42 @@ bool common_hal_bleio_adapter_get_enabled(void) { return is_enabled; } -void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address) { - ble_gap_addr_t local_address; +void get_address(ble_gap_addr_t *address) { uint32_t err_code; common_hal_bleio_adapter_set_enabled(true); - err_code = sd_ble_gap_addr_get(&local_address); + err_code = sd_ble_gap_addr_get(address); if (err_code != NRF_SUCCESS) { mp_raise_OSError_msg(translate("Failed to get local address")); } +} + +bleio_address_obj_t *common_hal_bleio_adapter_get_address(void) { + common_hal_bleio_adapter_set_enabled(true); + + ble_gap_addr_t local_address; + get_address(&local_address); + + bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; + + common_hal_bleio_address_construct(address, local_address.addr, local_address.addr_type); + return address; +} + +mp_obj_t common_hal_bleio_adapter_get_default_name(void) { + common_hal_bleio_adapter_set_enabled(true); + + ble_gap_addr_t local_address; + get_address(&local_address); + + char name[] = { 'C', 'I', 'R', 'C', 'U', 'I', 'T', 'P', 'Y', 0, 0, 0, 0 }; - address->type = local_address.addr_type; + name[sizeof(name) - 4] = nibble_to_hex_lower[local_address.addr[1] >> 4 & 0xf]; + name[sizeof(name) - 3] = nibble_to_hex_lower[local_address.addr[1] & 0xf]; + name[sizeof(name) - 2] = nibble_to_hex_lower[local_address.addr[0] >> 4 & 0xf]; + name[sizeof(name) - 1] = nibble_to_hex_lower[local_address.addr[0] & 0xf]; - mp_buffer_info_t buf_info; - mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ); - memcpy(address->bytes, buf_info.buf, NUM_BLEIO_ADDRESS_BYTES); + return mp_obj_new_str(name, sizeof(name)); } diff --git a/py/objstr.c b/py/objstr.c index ebd11d5cc..afe11f00f 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -41,6 +41,12 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_ STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf); STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in); +const char nibble_to_hex_upper[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F'}; + +const char nibble_to_hex_lower[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f'}; + /******************************************************************************/ /* str */ diff --git a/py/objstr.h b/py/objstr.h index 0efe62a80..61a11d0bd 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -77,6 +77,9 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s mp_obj_t index, bool is_slice); const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction); +const char nibble_to_hex_upper[16]; +const char nibble_to_hex_lower[16]; + MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj); MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj); MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj); diff --git a/shared-bindings/bleio/Adapter.c b/shared-bindings/bleio/Adapter.c index 7b8df5103..2bb7f3465 100644 --- a/shared-bindings/bleio/Adapter.c +++ b/shared-bindings/bleio/Adapter.c @@ -53,12 +53,6 @@ //| //| State of the BLE adapter. //| - -//| .. attribute:: adapter.address -//| -//| MAC address of the BLE adapter. (read-only) -//| - STATIC mp_obj_t bleio_adapter_get_enabled(mp_obj_t self) { return mp_obj_new_bool(common_hal_bleio_adapter_get_enabled()); } @@ -80,13 +74,13 @@ const mp_obj_property_t bleio_adapter_enabled_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. attribute:: adapter.address +//| +//| MAC address of the BLE adapter. (read-only) +//| STATIC mp_obj_t bleio_adapter_get_address(mp_obj_t self) { - mp_obj_t obj = bleio_address_type.make_new(&bleio_address_type, 1, 0, mp_const_none); - bleio_address_obj_t *address = MP_OBJ_TO_PTR(obj); - - common_hal_bleio_adapter_get_address(address); + return MP_OBJ_FROM_PTR(common_hal_bleio_adapter_get_address()); - return obj; } MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_address_obj, bleio_adapter_get_address); @@ -97,9 +91,29 @@ const mp_obj_property_t bleio_adapter_address_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. attribute:: adapter.default_name +//| +//| default_name of the BLE adapter. (read-only) +//| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``, +//| to make it easy to distinguish multiple CircuitPython boards. +//| +STATIC mp_obj_t bleio_adapter_get_default_name(mp_obj_t self) { + return common_hal_bleio_adapter_get_default_name(); + +} +MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_default_name_obj, bleio_adapter_get_default_name); + +const mp_obj_property_t bleio_adapter_default_name_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_adapter_get_default_name_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + STATIC const mp_rom_map_elem_t bleio_adapter_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_enabled), MP_ROM_PTR(&bleio_adapter_enabled_obj) }, { MP_ROM_QSTR(MP_QSTR_address), MP_ROM_PTR(&bleio_adapter_address_obj) }, + { MP_ROM_QSTR(MP_QSTR_default_name), MP_ROM_PTR(&bleio_adapter_default_name_obj) }, }; STATIC MP_DEFINE_CONST_DICT(bleio_adapter_locals_dict, bleio_adapter_locals_dict_table); diff --git a/shared-bindings/bleio/Adapter.h b/shared-bindings/bleio/Adapter.h index de9d1d6db..72382616c 100644 --- a/shared-bindings/bleio/Adapter.h +++ b/shared-bindings/bleio/Adapter.h @@ -34,6 +34,7 @@ const mp_obj_type_t bleio_adapter_type; extern bool common_hal_bleio_adapter_get_enabled(void); extern void common_hal_bleio_adapter_set_enabled(bool enabled); -extern void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address); +extern bleio_address_obj_t *common_hal_bleio_adapter_get_address(void); +extern mp_obj_t common_hal_bleio_adapter_get_default_name(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADAPTER_H diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c index 37f01042c..475fc9427 100644 --- a/shared-bindings/bleio/Address.c +++ b/shared-bindings/bleio/Address.c @@ -147,18 +147,13 @@ 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); - 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); - - 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, "
"); - } + 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); + + const uint8_t *buf = (uint8_t *) buf_info.buf; + mp_printf(print, "
", + buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); } //| .. data:: PUBLIC diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index 981ea2246..6cd077999 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -45,8 +45,6 @@ #include "common-hal/bleio/Peripheral.h" -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" @@ -81,14 +79,14 @@ static const char default_name[] = "CIRCUITPY"; //| # Wait for connection. //| pass //| -//| .. class:: Peripheral(services=(), \*, name='CIRCUITPY') +//| .. class:: Peripheral(services=(), \*, name=None) //| //| 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 +//| :param str name: The name used when advertising this peripheral. If name is None, +//| bleio.adapter.default_name will be used. //| 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 }; @@ -119,22 +117,19 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar mp_obj_list_append(services_list, service); } - const mp_obj_t name = args[ARG_name].u_obj; - mp_obj_t name_str; + mp_obj_t name = args[ARG_name].u_obj; if (name == MP_OBJ_NULL || name == mp_const_none) { - name_str = mp_obj_new_str(default_name, strlen(default_name)); - } else if (MP_OBJ_IS_STR(name)) { - name_str = name; - } else { + name = common_hal_bleio_adapter_get_default_name(); + } else if (!MP_OBJ_IS_STR(name)) { mp_raise_ValueError(translate("name must be a string")); } - common_hal_bleio_peripheral_construct(self, services_list, name_str); + common_hal_bleio_peripheral_construct(self, services_list, name); return MP_OBJ_FROM_PTR(self); } -//| .. attribute:: connected +//| .. attribute:: connected (read-only) //| //| True if connected to a BLE Central device. //| diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 0678a3a3f..c1d70c5b0 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -25,6 +25,7 @@ */ #include "tick.h" +#include "py/objstr.h" #include "shared-bindings/microcontroller/Processor.h" #include "shared-module/usb_midi/__init__.h" #include "supervisor/port.h" @@ -43,13 +44,11 @@ void load_serial_number(void) { uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; common_hal_mcu_processor_get_uid(raw_id); - static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F'}; for (int i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { for (int j = 0; j < 2; j++) { uint8_t nibble = (raw_id[i] >> (j * 4)) & 0xf; // Strings are UTF-16-LE encoded. - usb_serial_number[1 + i * 2 + j] = nibble_to_hex[nibble]; + usb_serial_number[1 + i * 2 + j] = nibble_to_hex_upper[nibble]; } } } -- cgit v1.2.3 From 19c59b41edcfdbb2ef67c73729fb8c866dd360ad Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 28 Aug 2019 16:15:09 -0400 Subject: bleio: API change to create and connect related objects simulatenously: no orphan bleio objects --- locale/ID.po | 41 ++---- locale/circuitpython.pot | 41 ++---- locale/de_DE.po | 47 +++---- locale/en_US.po | 41 ++---- locale/en_x_pirate.po | 41 ++---- locale/es.po | 54 +++----- locale/fil.po | 41 ++---- locale/fr.po | 51 +++----- locale/it_IT.po | 47 +++---- locale/pl.po | 51 +++----- locale/pt_BR.po | 41 ++---- locale/zh_Latn_pinyin.po | 50 +++----- ports/nrf/common-hal/bleio/Adapter.c | 9 +- ports/nrf/common-hal/bleio/Central.c | 10 +- ports/nrf/common-hal/bleio/Central.h | 2 +- ports/nrf/common-hal/bleio/Characteristic.c | 67 +++++++--- ports/nrf/common-hal/bleio/Descriptor.c | 22 ++-- ports/nrf/common-hal/bleio/Descriptor.h | 2 +- ports/nrf/common-hal/bleio/Peripheral.c | 53 ++++---- ports/nrf/common-hal/bleio/Peripheral.h | 4 +- ports/nrf/common-hal/bleio/Service.c | 177 ++++++++++---------------- ports/nrf/common-hal/bleio/__init__.c | 16 +-- py/obj.h | 1 + py/objstr.c | 8 ++ shared-bindings/bleio/Characteristic.c | 189 ++++++++++++++-------------- shared-bindings/bleio/Characteristic.h | 4 +- shared-bindings/bleio/Descriptor.c | 63 ++-------- shared-bindings/bleio/Descriptor.h | 3 +- shared-bindings/bleio/Peripheral.c | 96 +++++++++----- shared-bindings/bleio/Peripheral.h | 4 +- shared-bindings/bleio/Service.c | 162 ++++++++++++++---------- shared-bindings/bleio/Service.h | 4 +- shared-bindings/bleio/__init__.h | 2 +- 33 files changed, 610 insertions(+), 834 deletions(-) (limited to 'py/objstr.c') diff --git a/locale/ID.po b/locale/ID.po index 95b1c26dc..2451899d9 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -437,18 +437,6 @@ msgstr "tidak dapat mendapatkan ukuran scalar secara tidak ambigu" msgid "Cannot write without MOSI pin." msgstr "" -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "" @@ -524,10 +512,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -565,7 +549,7 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "" @@ -588,6 +572,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -864,7 +849,7 @@ msgstr "Pin-pin tidak valid" msgid "Invalid polarity" msgstr "" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1705,10 +1690,6 @@ msgstr "tidak dapat melakukan relative import" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "" @@ -1769,10 +1750,6 @@ msgstr "" msgid "default 'except' must be last" msgstr "'except' standar harus terakhir" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2112,7 +2089,6 @@ msgstr "" msgid "math domain error" msgstr "" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2131,6 +2107,11 @@ msgstr "" msgid "memory allocation failed, heap is locked" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "modul tidak ditemukan" @@ -2218,10 +2199,6 @@ msgstr "" msgid "no such attribute" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d478baef4..c117663a6 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -427,18 +427,6 @@ msgstr "" msgid "Cannot write without MOSI pin." msgstr "" -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "" @@ -513,10 +501,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -554,7 +538,7 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "" @@ -577,6 +561,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -849,7 +834,7 @@ msgstr "" msgid "Invalid polarity" msgstr "" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1671,10 +1656,6 @@ msgstr "" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "" @@ -1735,10 +1716,6 @@ msgstr "" msgid "default 'except' must be last" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2078,7 +2055,6 @@ msgstr "" msgid "math domain error" msgstr "" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2097,6 +2073,11 @@ msgstr "" msgid "memory allocation failed, heap is locked" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "" @@ -2183,10 +2164,6 @@ msgstr "" msgid "no such attribute" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index e39d157f4..c8f3715a5 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -431,18 +431,6 @@ msgstr "sizeof scalar kann nicht eindeutig bestimmt werden" msgid "Cannot write without MOSI pin." msgstr "Kann nicht ohne MOSI-Pin schreiben." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "Characteristic UUID stimmt nicht mit der Service-UUID überein" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "Characteristic wird bereits von einem anderen Dienst verwendet." - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "Schreiben von CharacteristicBuffer ist nicht vorgesehen" @@ -517,10 +505,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "Zu vielen Daten für das advertisement packet" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Die Zielkapazität ist kleiner als destination_length." @@ -558,7 +542,7 @@ msgstr "Erwartet ein(e) %q" msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "Eine UUID wird erwartet" @@ -581,6 +565,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -855,7 +840,7 @@ msgstr "Ungültige Pins" msgid "Invalid polarity" msgstr "Ungültige Polarität" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1711,10 +1696,6 @@ msgstr "kann keinen relativen Import durchführen" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "" @@ -1775,10 +1756,6 @@ msgstr "" msgid "default 'except' must be last" msgstr "Die Standart-Ausnahmebehandlung muss als letztes sein" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2125,7 +2102,6 @@ msgstr "map buffer zu klein" msgid "math domain error" msgstr "" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2144,6 +2120,11 @@ msgstr "Speicherzuordnung fehlgeschlagen, Zuweisung von %u Bytes" msgid "memory allocation failed, heap is locked" msgstr "Speicherzuweisung fehlgeschlagen, der Heap ist gesperrt" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "Modul nicht gefunden" @@ -2230,10 +2211,6 @@ msgstr "" msgid "no such attribute" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -2790,6 +2767,12 @@ msgstr "" #~ msgid "Cannot update i/f status" #~ msgstr "Kann i/f Status nicht updaten" +#~ msgid "Characteristic UUID doesn't match Service UUID" +#~ msgstr "Characteristic UUID stimmt nicht mit der Service-UUID überein" + +#~ msgid "Characteristic already in use by another Service." +#~ msgstr "Characteristic wird bereits von einem anderen Dienst verwendet." + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Daten sind zu groß für das advertisement packet" diff --git a/locale/en_US.po b/locale/en_US.po index 186ac9a4f..086a5065d 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -427,18 +427,6 @@ msgstr "" msgid "Cannot write without MOSI pin." msgstr "" -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "" @@ -513,10 +501,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -554,7 +538,7 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "" @@ -577,6 +561,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -849,7 +834,7 @@ msgstr "" msgid "Invalid polarity" msgstr "" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1671,10 +1656,6 @@ msgstr "" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "" @@ -1735,10 +1716,6 @@ msgstr "" msgid "default 'except' must be last" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2078,7 +2055,6 @@ msgstr "" msgid "math domain error" msgstr "" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2097,6 +2073,11 @@ msgstr "" msgid "memory allocation failed, heap is locked" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "" @@ -2183,10 +2164,6 @@ msgstr "" msgid "no such attribute" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 21c49745c..86cd819ed 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -431,18 +431,6 @@ msgstr "" msgid "Cannot write without MOSI pin." msgstr "" -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "" @@ -517,10 +505,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -558,7 +542,7 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "" @@ -581,6 +565,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -853,7 +838,7 @@ msgstr "" msgid "Invalid polarity" msgstr "" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1675,10 +1660,6 @@ msgstr "" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "" @@ -1739,10 +1720,6 @@ msgstr "" msgid "default 'except' must be last" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2082,7 +2059,6 @@ msgstr "" msgid "math domain error" msgstr "" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2101,6 +2077,11 @@ msgstr "" msgid "memory allocation failed, heap is locked" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "" @@ -2187,10 +2168,6 @@ msgstr "" msgid "no such attribute" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/locale/es.po b/locale/es.po index 89052a6ba..8fb536ea7 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -435,18 +435,6 @@ msgstr "No se puede obtener inequívocamente sizeof escalar" msgid "Cannot write without MOSI pin." msgstr "No se puede escribir sin pin MOSI." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "Características UUID no concide con el Service UUID" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "Características ya esta en uso por otro Serivice" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "CharateristicBuffer escritura no proporcionada" @@ -521,10 +509,6 @@ msgstr "Trozo de datos debe seguir fmt chunk" msgid "Data too large for advertisement packet" msgstr "Data es muy grande para el paquete de advertisement." -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Capacidad de destino es mas pequeña que destination_length." @@ -562,7 +546,7 @@ msgstr "Se espera un %q" msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "Se esperaba un UUID" @@ -585,6 +569,7 @@ msgstr "Fallo enviando comando" msgid "Failed to acquire mutex, err 0x%04x" msgstr "No se puede adquirir el mutex, status: 0x%08lX" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -860,7 +845,7 @@ msgstr "pines inválidos" msgid "Invalid polarity" msgstr "Polaridad inválida" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1723,10 +1708,6 @@ msgstr "no se puedo realizar importación relativa" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "characteristics incluye un objeto que no es una Characteristica" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "chars buffer es demasiado pequeño" @@ -1787,10 +1768,6 @@ msgstr "números decimales no soportados" msgid "default 'except' must be last" msgstr "'except' por defecto deberia estar de último" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2135,7 +2112,6 @@ msgstr "map buffer muy pequeño" msgid "math domain error" msgstr "error de dominio matemático" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2154,6 +2130,11 @@ msgstr "la asignación de memoria falló, asignando %u bytes" msgid "memory allocation failed, heap is locked" msgstr "la asignación de memoria falló, el heap está bloqueado" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "módulo no encontrado" @@ -2240,10 +2221,6 @@ msgstr "" 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/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -2798,6 +2775,12 @@ msgstr "paso cero" #~ msgid "Cannot update i/f status" #~ msgstr "No se puede actualizar i/f status" +#~ msgid "Characteristic UUID doesn't match Service UUID" +#~ msgstr "Características UUID no concide con el Service UUID" + +#~ msgid "Characteristic already in use by another Service." +#~ msgstr "Características ya esta en uso por otro Serivice" + #, fuzzy #~ msgid "Data too large for the advertisement packet" #~ msgstr "Los datos no caben en el paquete de anuncio." @@ -2905,8 +2888,8 @@ msgstr "paso cero" #~ "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d " #~ "bpp given" #~ msgstr "" -#~ "Solo se admiten BMP monocromos, indexados de 8bpp y 16bpp o superiores:" -#~ "% d bppdado" +#~ "Solo se admiten BMP monocromos, indexados de 8bpp y 16bpp o superiores:% " +#~ "d bppdado" #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo color verdadero (24 bpp o superior) BMP admitido %x" @@ -2975,6 +2958,9 @@ msgstr "paso cero" #~ msgid "can't set STA config" #~ msgstr "no se puede establecer STA config" +#~ msgid "characteristics includes an object that is not a Characteristic" +#~ msgstr "characteristics incluye un objeto que no es una Characteristica" + #~ msgid "either pos or kw args are allowed" #~ msgstr "ya sea pos o kw args son permitidos" diff --git a/locale/fil.po b/locale/fil.po index b034afba0..9b9a58567 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -435,18 +435,6 @@ msgstr "Hindi puedeng hindi sigurado ang get sizeof scalar" msgid "Cannot write without MOSI pin." msgstr "Hindi maaring isulat kapag walang MOSI pin." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "" @@ -524,10 +512,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" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -567,7 +551,7 @@ msgstr "Umasa ng %q" msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c #, fuzzy msgid "Expected a UUID" @@ -591,6 +575,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -869,7 +854,7 @@ msgstr "Mali ang pins" msgid "Invalid polarity" msgstr "Mali ang polarity" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1731,10 +1716,6 @@ msgstr "hindi maaring isagawa ang relative import" msgid "casting" msgstr "casting" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "masyadong maliit ang buffer" @@ -1795,10 +1776,6 @@ msgstr "decimal numbers hindi sinusuportahan" msgid "default 'except' must be last" msgstr "default 'except' ay dapat sa huli" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2148,7 +2125,6 @@ msgstr "masyadong maliit ang buffer map" msgid "math domain error" msgstr "may pagkakamali sa math domain" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2167,6 +2143,11 @@ msgstr "nabigo ang paglalaan ng memorya, paglalaan ng %u bytes" msgid "memory allocation failed, heap is locked" msgstr "abigo ang paglalaan ng memorya, ang heap ay naka-lock" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "module hindi nakita" @@ -2254,10 +2235,6 @@ msgstr "" 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/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index d386723eb..b6183ca28 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -441,18 +441,6 @@ msgstr "Impossible d'obtenir la taille du scalaire sans ambigüité" msgid "Cannot write without MOSI pin." msgstr "Impossible d'écrire sans broche MOSI." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "L'UUID de 'Characteristic' ne correspond pas à l'UUID du Service" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "'Characteristic' déjà en utilisation par un autre service" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "Ecriture sur 'CharacteristicBuffer' non fournie" @@ -529,10 +517,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" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "La capacité de destination est plus petite que 'destination_length'." @@ -571,7 +555,7 @@ msgstr "Attendu un %q" msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c #, fuzzy msgid "Expected a UUID" @@ -595,6 +579,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Echec de l'obtention de mutex, err 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -877,7 +862,7 @@ msgstr "Broches invalides" msgid "Invalid polarity" msgstr "Polarité invalide" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1761,10 +1746,6 @@ msgstr "ne peut pas réaliser un import relatif" msgid "casting" msgstr "typage" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "'characteristics' inclut un objet qui n'est pas une 'Characteristic'" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "tampon de caractères trop petit" @@ -1830,10 +1811,6 @@ msgstr "nombres décimaux non supportés" msgid "default 'except' must be last" msgstr "l''except' par défaut doit être en dernier" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2180,7 +2157,6 @@ msgstr "tampon trop petit" msgid "math domain error" msgstr "erreur de domaine math" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2199,6 +2175,11 @@ msgstr "l'allocation de mémoire a échoué en allouant %u octets" msgid "memory allocation failed, heap is locked" msgstr "l'allocation de mémoire a échoué, le tas est vérrouillé" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "module introuvable" @@ -2287,10 +2268,6 @@ msgstr "" 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/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -2854,6 +2831,12 @@ msgstr "'step' nul" #~ msgid "Cannot update i/f status" #~ msgstr "le status i/f ne peut être mis à jour" +#~ msgid "Characteristic UUID doesn't match Service UUID" +#~ msgstr "L'UUID de 'Characteristic' ne correspond pas à l'UUID du Service" + +#~ msgid "Characteristic already in use by another Service." +#~ msgstr "'Characteristic' déjà en utilisation par un autre service" + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Données trop volumineuses pour le paquet de diffusion" @@ -3027,6 +3010,10 @@ msgstr "'step' nul" #~ msgid "can't set STA config" #~ msgstr "impossible de régler la config de 'STA'" +#~ msgid "characteristics includes an object that is not a Characteristic" +#~ msgstr "" +#~ "'characteristics' inclut un objet qui n'est pas une 'Characteristic'" + #~ msgid "either pos or kw args are allowed" #~ msgstr "soit 'pos', soit 'kw' est permis en argument" diff --git a/locale/it_IT.po b/locale/it_IT.po index 293ae97a0..01729d00b 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -436,18 +436,6 @@ msgstr "Impossibile ricavare la grandezza scalare di sizeof inequivocabilmente" msgid "Cannot write without MOSI pin." msgstr "Impossibile scrivere senza pin MOSI." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "caratteristico UUID non assomiglia servizio UUID" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "caratteristico già usato da un altro servizio" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "CharacteristicBuffer scritura non dato" @@ -525,10 +513,6 @@ msgstr "" msgid "Data too large for advertisement packet" msgstr "Impossibile inserire dati nel pacchetto di advertisement." -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "La capacità di destinazione è più piccola di destination_length." @@ -567,7 +551,7 @@ msgstr "Atteso un %q" msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c #, fuzzy msgid "Expected a UUID" @@ -591,6 +575,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -870,7 +855,7 @@ msgstr "Pin non validi" msgid "Invalid polarity" msgstr "Polarità non valida" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1722,10 +1707,6 @@ msgstr "impossibile effettuare l'importazione relativa" msgid "casting" msgstr "casting" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "buffer dei caratteri troppo piccolo" @@ -1788,10 +1769,6 @@ msgstr "numeri decimali non supportati" msgid "default 'except' must be last" msgstr "'except' predefinito deve essere ultimo" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2141,7 +2118,6 @@ msgstr "map buffer troppo piccolo" msgid "math domain error" msgstr "errore di dominio matematico" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2160,6 +2136,11 @@ msgstr "allocazione di memoria fallita, allocando %u byte" msgid "memory allocation failed, heap is locked" msgstr "allocazione di memoria fallita, l'heap è bloccato" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "modulo non trovato" @@ -2248,10 +2229,6 @@ msgstr "" msgid "no such attribute" msgstr "attributo inesistente" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -2809,6 +2786,12 @@ msgstr "zero step" #~ msgid "Cannot update i/f status" #~ msgstr "Impossibile aggiornare status di i/f" +#~ msgid "Characteristic UUID doesn't match Service UUID" +#~ msgstr "caratteristico UUID non assomiglia servizio UUID" + +#~ msgid "Characteristic already in use by another Service." +#~ msgstr "caratteristico già usato da un altro servizio" + #, fuzzy #~ msgid "Data too large for the advertisement packet" #~ msgstr "Impossibile inserire dati nel pacchetto di advertisement." diff --git a/locale/pl.po b/locale/pl.po index c275bd4d0..33a9f76ae 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -430,18 +430,6 @@ msgstr "Wielkość skalara jest niejednoznaczna" msgid "Cannot write without MOSI pin." msgstr "Nie można pisać bez nóżki MOSI." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "UUID charakterystyki inny niż UUID serwisu" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "Charakterystyka w użyciu w innym serwisie" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "Pisanie do CharacteristicBuffer niewspierane" @@ -516,10 +504,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" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "Pojemność celu mniejsza od destination_length." @@ -557,7 +541,7 @@ msgstr "Oczekiwano %q" msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "Oczekiwano UUID" @@ -580,6 +564,7 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -854,7 +839,7 @@ msgstr "Złe nóżki" msgid "Invalid polarity" msgstr "Zła polaryzacja" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1695,10 +1680,6 @@ msgstr "nie można wykonać relatywnego importu" msgid "casting" msgstr "rzutowanie" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "charakterystyki zawierają obiekt, który nie jest typu Characteristic" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "bufor chars zbyt mały" @@ -1759,10 +1740,6 @@ msgstr "liczby dziesiętne nieobsługiwane" msgid "default 'except' must be last" msgstr "domyślny 'except' musi być ostatni" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2103,7 +2080,6 @@ msgstr "bufor mapy zbyt mały" msgid "math domain error" msgstr "błąd domeny" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2122,6 +2098,11 @@ msgstr "alokacja pamięci nie powiodła się, alokowano %u bajtów" msgid "memory allocation failed, heap is locked" msgstr "alokacja pamięci nie powiodła się, sterta zablokowana" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "brak modułu" @@ -2208,10 +2189,6 @@ msgstr "" 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/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -2743,6 +2720,12 @@ msgstr "zerowy krok" #~ msgid "Can't connect in Peripheral mode" #~ msgstr "Nie można się łączyć w trybie Peripheral" +#~ msgid "Characteristic UUID doesn't match Service UUID" +#~ msgstr "UUID charakterystyki inny niż UUID serwisu" + +#~ msgid "Characteristic already in use by another Service." +#~ msgstr "Charakterystyka w użyciu w innym serwisie" + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" @@ -2799,6 +2782,10 @@ msgstr "zerowy krok" #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" +#~ msgid "characteristics includes an object that is not a Characteristic" +#~ msgstr "" +#~ "charakterystyki zawierają obiekt, który nie jest typu Characteristic" + #~ 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 2ae16f992..cc7a6ef3b 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -432,18 +432,6 @@ msgstr "" msgid "Cannot write without MOSI pin." msgstr "Não é possível ler sem um pino MOSI" -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "" - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "" @@ -520,10 +508,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." -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." msgstr "" @@ -562,7 +546,7 @@ msgstr "Esperado um" msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c #, fuzzy msgid "Expected a UUID" @@ -586,6 +570,7 @@ msgstr "Falha ao enviar comando." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, fuzzy, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -863,7 +848,7 @@ msgstr "Pinos inválidos" msgid "Invalid polarity" msgstr "" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1695,10 +1680,6 @@ msgstr "" msgid "casting" msgstr "" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "" @@ -1759,10 +1740,6 @@ msgstr "" msgid "default 'except' must be last" msgstr "" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2103,7 +2080,6 @@ msgstr "" msgid "math domain error" msgstr "" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2122,6 +2098,11 @@ msgstr "" msgid "memory allocation failed, heap is locked" msgstr "" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "" @@ -2209,10 +2190,6 @@ msgstr "" msgid "no such attribute" msgstr "" -#: shared-bindings/bleio/Peripheral.c -msgid "non-Service found in services" -msgstr "" - #: ports/nrf/common-hal/bleio/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 886bba62a..f0fbebb99 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-08-22 14:29-0700\n" +"POT-Creation-Date: 2019-08-28 16:09-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -431,18 +431,6 @@ msgstr "Wúfǎ míngquè de huòdé biāoliàng de dàxiǎo" msgid "Cannot write without MOSI pin." msgstr "Wúfǎ xiě rù MOSI de yǐn jiǎo." -#: shared-bindings/bleio/Service.c -msgid "Characteristic UUID doesn't match Service UUID" -msgstr "Zìfú UUID bù fúhé fúwù UUID" - -#: ports/nrf/common-hal/bleio/Service.c -msgid "Characteristic already in use by another Service." -msgstr "Qítā fúwù bùmén yǐ shǐyòng de gōngnéng." - -#: shared-bindings/bleio/Service.c -msgid "Characteristic is already attached to a Service" -msgstr "" - #: shared-bindings/bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" msgstr "Wèi tígōng zìfú huǎncún xiě rù" @@ -517,10 +505,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à" -#: shared-bindings/bleio/Characteristic.c -msgid "Descriptor is already attached to a Characteristic" -msgstr "" - #: 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ù." @@ -558,7 +542,7 @@ msgstr "Yùqí %q" msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" -#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Descriptor.c +#: shared-bindings/bleio/Characteristic.c shared-bindings/bleio/Peripheral.c #: shared-bindings/bleio/Service.c msgid "Expected a UUID" msgstr "Yùqí UUID" @@ -581,6 +565,7 @@ msgstr "Fāsòng mìnglìng shībài." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Wúfǎ huòdé mutex, err 0x%04x" +#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Service.c #, c-format msgid "Failed to add characteristic, err 0x%04x" @@ -855,7 +840,7 @@ msgstr "Wúxiào de yǐn jiǎo" msgid "Invalid polarity" msgstr "Wúxiào liǎng jí zhí" -#: shared-bindings/bleio/Characteristic.c +#: shared-bindings/bleio/Service.c msgid "Invalid properties" msgstr "" @@ -1704,10 +1689,6 @@ msgstr "wúfǎ zhíxíng xiāngguān dǎorù" msgid "casting" msgstr "tóuyǐng" -#: shared-bindings/bleio/Service.c -msgid "characteristics includes an object that is not a Characteristic" -msgstr "tèxìng bāokuò bùshì zìfú de wùtǐ" - #: shared-bindings/_stage/Text.c msgid "chars buffer too small" msgstr "zìfú huǎnchōng qū tài xiǎo" @@ -1770,10 +1751,6 @@ msgstr "bù zhīchí xiǎoshù shù" msgid "default 'except' must be last" msgstr "mòrèn 'except' bìxū shì zuìhòu yīgè" -#: shared-bindings/bleio/Characteristic.c -msgid "descriptors includes an object that is not a Descriptors" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" @@ -2115,7 +2092,6 @@ msgstr "dìtú huǎnchōng qū tài xiǎo" msgid "math domain error" msgstr "shùxué yù cuòwù" -#: ports/nrf/common-hal/bleio/Characteristic.c #: ports/nrf/common-hal/bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" @@ -2134,6 +2110,11 @@ msgstr "nèicún fēnpèi shībài, fēnpèi %u zì jié" msgid "memory allocation failed, heap is locked" msgstr "jìyì tǐ fēnpèi shībài, duī bèi suǒdìng" +#: ports/nrf/common-hal/bleio/Characteristic.c +#, c-format +msgid "mnax_length must be 0-%d when fixed_length is %s" +msgstr "" + #: py/builtinimport.c msgid "module not found" msgstr "zhǎo bù dào mókuài" @@ -2221,10 +2202,6 @@ msgstr "" 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/__init__.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -2759,6 +2736,12 @@ msgstr "líng bù" #~ msgid "Can't set CCCD for local Characteristic" #~ msgstr "Wúfǎ wéi běndì tèzhēng shèzhì CCCD" +#~ msgid "Characteristic UUID doesn't match Service UUID" +#~ msgstr "Zìfú UUID bù fúhé fúwù UUID" + +#~ msgid "Characteristic already in use by another Service." +#~ msgstr "Qítā fúwù bùmén yǐ shǐyòng de gōngnéng." + #~ msgid "Data too large for the advertisement packet" #~ msgstr "Guǎnggào bāo de shùjù tài dà" @@ -2828,6 +2811,9 @@ msgstr "líng bù" #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" +#~ msgid "characteristics includes an object that is not a Characteristic" +#~ msgstr "tèxìng bāokuò bùshì zìfú de wùtǐ" + #~ msgid "expected a DigitalInOut" #~ msgstr "qídài de DigitalInOut" diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 74650e212..74bee9e56 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -66,12 +66,14 @@ STATIC uint32_t ble_stack_enable(void) { }; uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler); - if (err_code != NRF_SUCCESS) + if (err_code != NRF_SUCCESS) { return err_code; + } err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); - if (err_code != NRF_SUCCESS) + if (err_code != NRF_SUCCESS) { return err_code; + } // Start with no event handlers, etc. ble_drv_reset(); @@ -112,8 +114,9 @@ STATIC uint32_t ble_stack_enable(void) { .conn_sup_timeout = BLE_CONN_SUP_TIMEOUT, }; err_code = sd_ble_gap_ppcp_set(&gap_conn_params); - if (err_code != NRF_SUCCESS) + if (err_code != NRF_SUCCESS) { return err_code; + } err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_UNKNOWN); return err_code; diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c index 3c5d97784..0f8432b73 100644 --- a/ports/nrf/common-hal/bleio/Central.c +++ b/ports/nrf/common-hal/bleio/Central.c @@ -76,7 +76,7 @@ STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) { void common_hal_bleio_central_construct(bleio_central_obj_t *self) { common_hal_bleio_adapter_set_enabled(true); - self->remote_services_list = mp_obj_new_list(0, NULL); + self->remote_service_list = mp_obj_new_list(0, NULL); self->conn_handle = BLE_CONN_HANDLE_INVALID; } @@ -134,12 +134,12 @@ bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self) { mp_obj_tuple_t *common_hal_bleio_central_discover_remote_services(bleio_central_obj_t *self, mp_obj_t service_uuids_whitelist) { common_hal_bleio_device_discover_remote_services(MP_OBJ_FROM_PTR(self), service_uuids_whitelist); // Convert to a tuple and then clear the list so the callee will take ownership. - mp_obj_tuple_t *services_tuple = mp_obj_new_tuple(self->remote_services_list->len, - self->remote_services_list->items); - mp_obj_list_clear(self->remote_services_list); + mp_obj_tuple_t *services_tuple = mp_obj_new_tuple(self->remote_service_list->len, + self->remote_service_list->items); + mp_obj_list_clear(self->remote_service_list); return services_tuple; } mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) { - return self->remote_services_list; + return self->remote_service_list; } diff --git a/ports/nrf/common-hal/bleio/Central.h b/ports/nrf/common-hal/bleio/Central.h index b7a9050b8..2e00aa35e 100644 --- a/ports/nrf/common-hal/bleio/Central.h +++ b/ports/nrf/common-hal/bleio/Central.h @@ -38,7 +38,7 @@ typedef struct { volatile bool waiting_to_connect; volatile uint16_t conn_handle; // Services discovered after connecting to a remote peripheral. - mp_obj_list_t *remote_services_list; + mp_obj_list_t *remote_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 604d24d73..012029b6c 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -124,29 +124,24 @@ STATIC void characteristic_gattc_read(bleio_characteristic_obj_t *characteristic ble_drv_remove_event_handler(characteristic_on_gattc_read_rsp_evt, characteristic); } -void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_obj_list_t *descriptor_list) { +void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { self->service = MP_OBJ_NULL; self->uuid = uuid; - self->value = mp_const_empty_bytes; self->handle = BLE_GATT_HANDLE_INVALID; self->props = props; self->read_perm = read_perm; self->write_perm = write_perm; - self->descriptor_list = descriptor_list; + self->descriptor_list = mp_obj_new_list(0, NULL); const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX; if (max_length < 0 || max_length > max_length_max) { - mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + mp_raise_ValueError_varg(translate("mnax_length must be 0-%d when fixed_length is %s"), max_length_max, fixed_length ? "True" : "False"); } self->max_length = max_length; self->fixed_length = fixed_length; - for (size_t descriptor_idx = 0; descriptor_idx < descriptor_list->len; ++descriptor_idx) { - bleio_descriptor_obj_t *descriptor = - MP_OBJ_TO_PTR(descriptor_list->items[descriptor_idx]); - descriptor->characteristic = self; - } + common_hal_bleio_characteristic_set_value(self, initial_value_bufinfo); } mp_obj_list_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self) { @@ -173,6 +168,15 @@ mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *s } void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { + if (self->fixed_length && bufinfo->len != self->max_length) { + mp_raise_ValueError(translate("Value length != required fixed length")); + } + if (bufinfo->len > self->max_length) { + mp_raise_ValueError(translate("Value length > max_length")); + } + + self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len); + // Do GATT operations only if this characteristic has been added to a registered service. if (self->handle != BLE_GATT_HANDLE_INVALID) { uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(self->service->device); @@ -182,12 +186,6 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo, (self->props & CHAR_PROP_WRITE_NO_RESPONSE)); } else { - if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); - } - if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); - } bool sent = false; uint16_t cccd = 0; @@ -213,8 +211,6 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, } } } - - self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len); } bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) { @@ -225,6 +221,43 @@ bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties return self->props; } +void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor) { + // Connect descriptor to parent characteristic. + descriptor->characteristic = self; + + ble_uuid_t desc_uuid; + bleio_uuid_convert_to_nrf_ble_uuid(descriptor->uuid, &desc_uuid); + + ble_gatts_attr_md_t desc_attr_md = { + // Data passed is not in a permanent location and should be copied. + .vloc = BLE_GATTS_VLOC_STACK, + .vlen = !descriptor->fixed_length, + }; + + bleio_attribute_gatts_set_security_mode(&desc_attr_md.read_perm, descriptor->read_perm); + bleio_attribute_gatts_set_security_mode(&desc_attr_md.write_perm, descriptor->write_perm); + + mp_buffer_info_t desc_value_bufinfo; + mp_get_buffer_raise(descriptor->value, &desc_value_bufinfo, MP_BUFFER_READ); + + ble_gatts_attr_t desc_attr = { + .p_uuid = &desc_uuid, + .p_attr_md = &desc_attr_md, + .init_len = desc_value_bufinfo.len, + .p_value = desc_value_bufinfo.buf, + .init_offs = 0, + .max_len = descriptor->max_length, + }; + + uint32_t err_code = sd_ble_gatts_descriptor_add(self->handle, &desc_attr, &descriptor->handle); + + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to add characteristic, err 0x%04x"), err_code); + } + + mp_obj_list_append(self->descriptor_list, MP_OBJ_FROM_PTR(descriptor)); +} + 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")); diff --git a/ports/nrf/common-hal/bleio/Descriptor.c b/ports/nrf/common-hal/bleio/Descriptor.c index 2a2019277..ee8d840f2 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.c +++ b/ports/nrf/common-hal/bleio/Descriptor.c @@ -35,10 +35,9 @@ static volatile bleio_descriptor_obj_t *m_read_descriptor; -void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length) { +void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { self->characteristic = MP_OBJ_NULL; self->uuid = uuid; - self->value = mp_const_empty_bytes; self->handle = BLE_GATT_HANDLE_INVALID; self->read_perm = read_perm; self->write_perm = write_perm; @@ -50,6 +49,8 @@ void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_u } self->max_length = max_length; self->fixed_length = fixed_length; + + common_hal_bleio_descriptor_set_value(self, initial_value_bufinfo); } bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) { @@ -119,6 +120,15 @@ mp_obj_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self) { } void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) { + if (self->fixed_length && bufinfo->len != self->max_length) { + mp_raise_ValueError(translate("Value length != required fixed length")); + } + if (bufinfo->len > self->max_length) { + mp_raise_ValueError(translate("Value length > max_length")); + } + + self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len); + // Do GATT operations only if this descriptor has been registered. if (self->handle != BLE_GATT_HANDLE_INVALID) { uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(self->characteristic->service->device); @@ -126,16 +136,8 @@ void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buff // false means WRITE_REQ, not write-no-response common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo, false); } else { - if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); - } - if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); - } - common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo); } } - self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len); } diff --git a/ports/nrf/common-hal/bleio/Descriptor.h b/ports/nrf/common-hal/bleio/Descriptor.h index 6db4d7be3..db1175146 100644 --- a/ports/nrf/common-hal/bleio/Descriptor.h +++ b/ports/nrf/common-hal/bleio/Descriptor.h @@ -31,7 +31,7 @@ #include "py/obj.h" -#include "shared-bindings/bleio/Characteristic.h" +#include "common-hal/bleio/Characteristic.h" #include "common-hal/bleio/UUID.h" typedef struct { diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 08a6d5066..6f8a1a2fc 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -71,7 +71,7 @@ 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; // For debugging. - mp_printf(&mp_plat_print, "Peripheral event: 0x%04x\n", ble_evt->header.evt_id); + // mp_printf(&mp_plat_print, "Peripheral event: 0x%04x\n", ble_evt->header.evt_id); switch (ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: { @@ -156,10 +156,8 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { ble_gap_evt_auth_status_t* status = &ble_evt->evt.gap_evt.params.auth_status; if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status) { // TODO _ediv = bonding_keys->own_enc.master_id.ediv; - mp_printf(&mp_plat_print, "Pairing succeeded, status: 0x%04x\n", status->auth_status); self->pair_status = PAIR_PAIRED; } else { - mp_printf(&mp_plat_print, "Pairing failed, status: 0x%04x\n", status->auth_status); self->pair_status = PAIR_NOT_PAIRED; } break; @@ -204,17 +202,17 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { default: // For debugging. - mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id); + // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id); break; } } -void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *services_list, mp_obj_t name) { +void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_t name) { common_hal_bleio_adapter_set_enabled(true); - self->services_list = services_list; + self->service_list = mp_obj_new_list(0, NULL); // Used only for discovery when acting as a client. - self->remote_services_list = mp_obj_new_list(0, NULL); + self->remote_service_list = mp_obj_new_list(0, NULL); self->name = name; self->conn_handle = BLE_CONN_HANDLE_INVALID; @@ -222,35 +220,30 @@ void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_ self->pair_status = PAIR_NOT_PAIRED; memset(&self->bonding_keys, 0, sizeof(self->bonding_keys)); +} - // Add all the services. - - for (size_t service_idx = 0; service_idx < services_list->len; ++service_idx) { - bleio_service_obj_t *service = MP_OBJ_TO_PTR(services_list->items[service_idx]); - - service->device = MP_OBJ_FROM_PTR(self); - - ble_uuid_t uuid; - bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); +void common_hal_bleio_peripheral_add_service(bleio_peripheral_obj_t *self, bleio_service_obj_t *service) { + service->device = MP_OBJ_FROM_PTR(self); - uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY; - if (common_hal_bleio_service_get_is_secondary(service)) { - service_type = BLE_GATTS_SRVC_TYPE_SECONDARY; - } + ble_uuid_t uuid; + bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid); - const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to add service, err 0x%04x"), err_code); - } + uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY; + if (common_hal_bleio_service_get_is_secondary(service)) { + service_type = BLE_GATTS_SRVC_TYPE_SECONDARY; + } - // Once the service has been registered, its characteristics can be added. - common_hal_bleio_service_add_all_characteristics(service); + const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to add service, err 0x%04x"), err_code); } + + mp_obj_list_append(self->service_list, MP_OBJ_FROM_PTR(service)); } mp_obj_list_t *common_hal_bleio_peripheral_get_services(bleio_peripheral_obj_t *self) { - return self->services_list; + return self->service_list; } bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) { @@ -344,9 +337,9 @@ void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *self) { mp_obj_tuple_t *common_hal_bleio_peripheral_discover_remote_services(bleio_peripheral_obj_t *self, mp_obj_t service_uuids_whitelist) { common_hal_bleio_device_discover_remote_services(MP_OBJ_FROM_PTR(self), service_uuids_whitelist); // Convert to a tuple and then clear the list so the callee will take ownership. - mp_obj_tuple_t *services_tuple = mp_obj_new_tuple(self->remote_services_list->len, - self->remote_services_list->items); - mp_obj_list_clear(self->remote_services_list); + mp_obj_tuple_t *services_tuple = mp_obj_new_tuple(self->remote_service_list->len, + self->remote_service_list->items); + mp_obj_list_clear(self->remote_service_list); return services_tuple; } diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h index b663c9601..1620874ca 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.h +++ b/ports/nrf/common-hal/bleio/Peripheral.h @@ -49,9 +49,9 @@ typedef struct { mp_obj_t name; volatile uint16_t conn_handle; // Services provided by this peripheral. - mp_obj_list_t *services_list; + mp_obj_list_t *service_list; // Remote services discovered when this peripheral is acting as a client. - mp_obj_list_t *remote_services_list; + mp_obj_list_t *remote_service_list; // 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 28e713cc8..e5201cc46 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -34,19 +34,13 @@ #include "shared-bindings/bleio/Service.h" #include "shared-bindings/bleio/Adapter.h" -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; +void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) { self->handle = 0xFFFF; self->uuid = uuid; - self->characteristic_list = characteristic_list; + self->characteristic_list = mp_obj_new_list(0, NULL); self->is_remote = false; 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]); - characteristic->service = self; - } + self->device = mp_const_none; } bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) { @@ -65,106 +59,67 @@ bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) { return self->is_secondary; } -// 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. - 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]); - - if (characteristic->handle != BLE_GATT_HANDLE_INVALID) { - mp_raise_ValueError(translate("Characteristic already in use by another Service.")); - } - - ble_gatts_char_md_t char_md = { - .char_props.broadcast = (characteristic->props & CHAR_PROP_BROADCAST) ? 1 : 0, - .char_props.read = (characteristic->props & CHAR_PROP_READ) ? 1 : 0, - .char_props.write_wo_resp = (characteristic->props & CHAR_PROP_WRITE_NO_RESPONSE) ? 1 : 0, - .char_props.write = (characteristic->props & CHAR_PROP_WRITE) ? 1 : 0, - .char_props.notify = (characteristic->props & CHAR_PROP_NOTIFY) ? 1 : 0, - .char_props.indicate = (characteristic->props & CHAR_PROP_INDICATE) ? 1 : 0, - }; - - ble_gatts_attr_md_t cccd_md = { - .vloc = BLE_GATTS_VLOC_STACK, - }; - - ble_uuid_t char_uuid; - bleio_uuid_convert_to_nrf_ble_uuid(characteristic->uuid, &char_uuid); - - ble_gatts_attr_md_t char_attr_md = { - .vloc = BLE_GATTS_VLOC_STACK, - .vlen = !characteristic->fixed_length, - }; - - if (char_md.char_props.notify || char_md.char_props.indicate) { - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); - // Make CCCD write permission match characteristic read permission. - bleio_attribute_gatts_set_security_mode(&cccd_md.write_perm, characteristic->read_perm); - - char_md.p_cccd_md = &cccd_md; - } - - bleio_attribute_gatts_set_security_mode(&char_attr_md.read_perm, characteristic->read_perm); - bleio_attribute_gatts_set_security_mode(&char_attr_md.write_perm, characteristic->write_perm); - - mp_buffer_info_t char_value_bufinfo; - mp_get_buffer_raise(characteristic->value, &char_value_bufinfo, MP_BUFFER_READ); - - ble_gatts_attr_t char_attr = { - .p_uuid = &char_uuid, - .p_attr_md = &char_attr_md, - .init_len = char_value_bufinfo.len, - .p_value = char_value_bufinfo.buf, - .init_offs = 0, - .max_len = characteristic->max_length, - }; - - ble_gatts_char_handles_t char_handles; - - uint32_t err_code; - err_code = sd_ble_gatts_characteristic_add(self->handle, &char_md, &char_attr, &char_handles); - if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to add characteristic, err 0x%04x"), err_code); - } - - characteristic->user_desc_handle = char_handles.user_desc_handle; - characteristic->cccd_handle = char_handles.cccd_handle; - characteristic->sccd_handle = char_handles.sccd_handle; - characteristic->handle = char_handles.value_handle; - - // Add the descriptors for this characteristic. - for (size_t descriptor_idx = 0; descriptor_idx < characteristic->descriptor_list->len; ++descriptor_idx) { - bleio_descriptor_obj_t *descriptor = - MP_OBJ_TO_PTR(characteristic->descriptor_list->items[descriptor_idx]); - - ble_uuid_t desc_uuid; - bleio_uuid_convert_to_nrf_ble_uuid(descriptor->uuid, &desc_uuid); - - ble_gatts_attr_md_t desc_attr_md = { - // Data passed is not in a permanent location and should be copied. - .vloc = BLE_GATTS_VLOC_STACK, - .vlen = !descriptor->fixed_length, - }; - - bleio_attribute_gatts_set_security_mode(&desc_attr_md.read_perm, descriptor->read_perm); - bleio_attribute_gatts_set_security_mode(&desc_attr_md.write_perm, descriptor->write_perm); - - mp_buffer_info_t desc_value_bufinfo; - mp_get_buffer_raise(descriptor->value, &desc_value_bufinfo, MP_BUFFER_READ); - - ble_gatts_attr_t desc_attr = { - .p_uuid = &desc_uuid, - .p_attr_md = &desc_attr_md, - .init_len = desc_value_bufinfo.len, - .p_value = desc_value_bufinfo.buf, - .init_offs = 0, - .max_len = descriptor->max_length, - }; - - err_code = sd_ble_gatts_descriptor_add(characteristic->handle, &desc_attr, &descriptor->handle); - - } // loop over descriptors - - } // loop over characteristics + +void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, bleio_characteristic_obj_t *characteristic) { + // Connect characteristic to parent service. + characteristic->service = self; + + ble_gatts_char_md_t char_md = { + .char_props.broadcast = (characteristic->props & CHAR_PROP_BROADCAST) ? 1 : 0, + .char_props.read = (characteristic->props & CHAR_PROP_READ) ? 1 : 0, + .char_props.write_wo_resp = (characteristic->props & CHAR_PROP_WRITE_NO_RESPONSE) ? 1 : 0, + .char_props.write = (characteristic->props & CHAR_PROP_WRITE) ? 1 : 0, + .char_props.notify = (characteristic->props & CHAR_PROP_NOTIFY) ? 1 : 0, + .char_props.indicate = (characteristic->props & CHAR_PROP_INDICATE) ? 1 : 0, + }; + + ble_gatts_attr_md_t cccd_md = { + .vloc = BLE_GATTS_VLOC_STACK, + }; + + ble_uuid_t char_uuid; + bleio_uuid_convert_to_nrf_ble_uuid(characteristic->uuid, &char_uuid); + + ble_gatts_attr_md_t char_attr_md = { + .vloc = BLE_GATTS_VLOC_STACK, + .vlen = !characteristic->fixed_length, + }; + + if (char_md.char_props.notify || char_md.char_props.indicate) { + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); + // Make CCCD write permission match characteristic read permission. + bleio_attribute_gatts_set_security_mode(&cccd_md.write_perm, characteristic->read_perm); + + char_md.p_cccd_md = &cccd_md; + } + + bleio_attribute_gatts_set_security_mode(&char_attr_md.read_perm, characteristic->read_perm); + bleio_attribute_gatts_set_security_mode(&char_attr_md.write_perm, characteristic->write_perm); + + mp_buffer_info_t char_value_bufinfo; + mp_get_buffer_raise(characteristic->value, &char_value_bufinfo, MP_BUFFER_READ); + + ble_gatts_attr_t char_attr = { + .p_uuid = &char_uuid, + .p_attr_md = &char_attr_md, + .init_len = char_value_bufinfo.len, + .p_value = char_value_bufinfo.buf, + .init_offs = 0, + .max_len = characteristic->max_length, + }; + + ble_gatts_char_handles_t char_handles; + + uint32_t err_code; + err_code = sd_ble_gatts_characteristic_add(self->handle, &char_md, &char_attr, &char_handles); + if (err_code != NRF_SUCCESS) { + mp_raise_OSError_msg_varg(translate("Failed to add characteristic, err 0x%04x"), err_code); + } + + characteristic->user_desc_handle = char_handles.user_desc_handle; + characteristic->cccd_handle = char_handles.cccd_handle; + characteristic->sccd_handle = char_handles.sccd_handle; + characteristic->handle = char_handles.value_handle; + + mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); } diff --git a/ports/nrf/common-hal/bleio/__init__.c b/ports/nrf/common-hal/bleio/__init__.c index 2e26ac07d..868e0a8e9 100644 --- a/ports/nrf/common-hal/bleio/__init__.c +++ b/ports/nrf/common-hal/bleio/__init__.c @@ -75,11 +75,11 @@ uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device) { } } -mp_obj_list_t *common_hal_bleio_device_get_remote_services_list(mp_obj_t device) { +mp_obj_list_t *common_hal_bleio_device_get_remote_service_list(mp_obj_t device) { if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) { - return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->remote_services_list; + return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->remote_service_list; } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) { - return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->remote_services_list; + return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->remote_service_list; } else { return NULL; } @@ -158,7 +158,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res 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); + common_hal_bleio_service_construct(service, NULL, false); service->device = device; service->is_remote = true; @@ -179,7 +179,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res service->uuid = NULL; } - mp_obj_list_append(common_hal_bleio_device_get_remote_services_list(device), service); + mp_obj_list_append(common_hal_bleio_device_get_remote_service_list(device), service); } if (response->count > 0) { @@ -275,7 +275,7 @@ STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, mp_ob } common_hal_bleio_descriptor_construct(descriptor, uuid, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN, - GATT_MAX_DATA_LENGTH, false); + GATT_MAX_DATA_LENGTH, false, mp_const_empty_bytes); descriptor->handle = gattc_desc->handle; descriptor->characteristic = m_desc_discovery_characteristic; @@ -316,12 +316,12 @@ STATIC void discovery_on_ble_evt(ble_evt_t *ble_evt, mp_obj_t device) { void common_hal_bleio_device_discover_remote_services(mp_obj_t device, mp_obj_t service_uuids_whitelist) { - mp_obj_list_t *remote_services_list = common_hal_bleio_device_get_remote_services_list(device); + mp_obj_list_t *remote_services_list = common_hal_bleio_device_get_remote_service_list(device); ble_drv_add_event_handler(discovery_on_ble_evt, device); // Start over with an empty list. - mp_obj_list_clear(MP_OBJ_FROM_PTR(common_hal_bleio_device_get_remote_services_list(device))); + mp_obj_list_clear(MP_OBJ_FROM_PTR(common_hal_bleio_device_get_remote_service_list(device))); if (service_uuids_whitelist == mp_const_none) { // List of service UUID's not given, so discover all available services. diff --git a/py/obj.h b/py/obj.h index c719c2945..cf4216d02 100644 --- a/py/obj.h +++ b/py/obj.h @@ -647,6 +647,7 @@ mp_obj_t mp_obj_new_str(const char* data, size_t len); mp_obj_t mp_obj_new_str_via_qstr(const char* data, size_t len); mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr); mp_obj_t mp_obj_new_bytes(const byte* data, size_t len); +mp_obj_t mp_obj_new_bytes_of_zeros(size_t len); mp_obj_t mp_obj_new_bytearray(size_t n, void *items); mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n); mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items); diff --git a/py/objstr.c b/py/objstr.c index afe11f00f..6ef9a15b5 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -2094,6 +2094,14 @@ mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) { return mp_obj_new_str_copy(&mp_type_bytes, data, len); } +mp_obj_t mp_obj_new_bytes_of_zeros(size_t len) { + vstr_t vstr; + vstr_init_len(&vstr, len); + memset(vstr.buf, 0, len); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} + + bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { if (MP_OBJ_IS_QSTR(s1) && MP_OBJ_IS_QSTR(s2)) { return s1 == s2; diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c index 4894ad114..d9d920b76 100644 --- a/shared-bindings/bleio/Characteristic.c +++ b/shared-bindings/bleio/Characteristic.c @@ -41,101 +41,18 @@ //| Stores information about a BLE service characteristic and allows reading //| and writing of the characteristic's value. //| +//| A Characteristic cannot be created directly. A new local Characteristic can be created +//| and attached to a Service by calling `Service.add_characteristic()`. +//| Remote Characteristic objects are created by `Central.discover_remote_services()` +//| or `Peripheral.discover_remote_services()` as part of remote Services. //| -//| .. class:: Characteristic(uuid, *, properties=0, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, descriptors=None) -//| -//| Create a new Characteristic object identified by the specified UUID. -//| -//| :param bleio.UUID uuid: The uuid of the characteristic -//| :param int properties: bitmask of these values bitwise-or'd together: `BROADCAST`, `INDICATE`, -//| `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE` -//| :param int read_perm: Specifies whether the characteristic can be read by a client, and if so, which -//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, -//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, -//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. -//| :param int write_perm: Specifies whether the characteristic can be written by a client, and if so, which -//| security mode is required. Values allowed are the same as ``read_perm``. -//| :param int max_length: Maximum length in bytes of the characteristic value. The maximum allowed is -//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum -//| number of data bytes that fit in a single BLE 4.x ATT packet. -//| :param bool fixed_length: True if the characteristic value is of fixed length. -//| :param iterable descriptors: BLE descriptors for this characteristic. -//| -STATIC mp_obj_t bleio_characteristic_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_uuid, ARG_properties, ARG_read_perm, ARG_write_perm, - ARG_max_length, ARG_fixed_length, ARG_descriptors }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_properties, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, - { MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, - { MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} }, - { MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_descriptors, 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, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - - if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { - mp_raise_ValueError(translate("Expected a UUID")); - } - bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); - - const bleio_characteristic_properties_t properties = args[ARG_properties].u_int; - if (properties & ~CHAR_PROP_ALL) { - mp_raise_ValueError(translate("Invalid properties")); - } - - const bleio_attribute_security_mode_t read_perm = args[ARG_read_perm].u_int; - common_hal_bleio_attribute_security_mode_check_valid(read_perm); - - const bleio_attribute_security_mode_t write_perm = args[ARG_write_perm].u_int; - common_hal_bleio_attribute_security_mode_check_valid(write_perm); - - mp_obj_t descriptors = args[ARG_descriptors].u_obj; - if (descriptors == mp_const_none) { - descriptors = mp_const_empty_tuple; - } - - bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t); - self->base.type = &bleio_characteristic_type; - - // Copy the descriptors list and validate its items. - mp_obj_t desc_list_obj = mp_obj_new_list(0, NULL); - mp_obj_list_t *desc_list = MP_OBJ_TO_PTR(desc_list_obj); - - // If descriptors is not an iterable, an exception will be thrown. - mp_obj_iter_buf_t iter_buf; - mp_obj_t descriptors_iter = mp_getiter(descriptors, &iter_buf); - - mp_obj_t descriptor_obj; - while ((descriptor_obj = mp_iternext(descriptors_iter)) != MP_OBJ_STOP_ITERATION) { - if (!MP_OBJ_IS_TYPE(descriptor_obj, &bleio_descriptor_type)) { - mp_raise_ValueError(translate("descriptors includes an object that is not a Descriptors")); - } - bleio_descriptor_obj_t *descriptor = MP_OBJ_TO_PTR(descriptor_obj); - if (common_hal_bleio_descriptor_get_characteristic(descriptor) != MP_OBJ_NULL) { - mp_raise_ValueError(translate("Descriptor is already attached to a Characteristic")); - } - mp_obj_list_append(desc_list_obj, descriptor_obj); - } - - // Range checking on max_length arg is done by the common_hal layer, because - // it may vary depending on underlying BLE implementation. - common_hal_bleio_characteristic_construct(self, uuid, properties, - read_perm, write_perm, - args[ARG_max_length].u_int, args[ARG_fixed_length].u_bool, - desc_list); - - return MP_OBJ_FROM_PTR(self); -} //| .. attribute:: properties //| -//| An int bitmask representing which properties are set. +//| An int bitmask representing which properties are set, specified as bitwise or'ing of +//| of these possible values. +//| `~Characteristic.BROADCAST`, `~Characteristic.INDICATE`, `~Characteristic.NOTIFY`, +//| `~Characteristic.READ`, `~Characteristic.WRITE`, `~Characteristic.WRITE_NO_RESPONSE`. //| STATIC mp_obj_t bleio_characteristic_get_properties(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -222,7 +139,7 @@ const mp_obj_property_t bleio_characteristic_descriptors_obj = { //| .. attribute:: service (read-only) //| -//| The Service this Characteristic is a part of. None if not yet assigned to a Service. +//| The Service this Characteristic is a part of. //| STATIC mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -238,6 +155,84 @@ const mp_obj_property_t bleio_characteristic_service_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. method:: add_descriptor(uuid, *, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, initial_value=b'') +//| +//| Create a new `Descriptor` object, and add it to this Service. +//| +//| :param bleio.UUID uuid: The uuid of the descriptor +//| :param int read_perm: Specifies whether the descriptor can be read by a client, and if so, which +//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, +//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, +//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. +//| :param int write_perm: Specifies whether the descriptor can be written by a client, and if so, which +//| security mode is required. Values allowed are the same as ``read_perm``. +//| :param int max_length: Maximum length in bytes of the descriptor value. The maximum allowed is +//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum +//| number of data bytes that fit in a single BLE 4.x ATT packet. +//| :param bool fixed_length: True if the descriptor value is of fixed length. +//| :param buf initial_value: The initial value for this descriptor. +//| +//| :return: the new `Descriptor`. +//| +STATIC mp_obj_t bleio_characteristic_add_descriptor(size_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_uuid, ARG_read_perm, ARG_write_perm, + ARG_max_length, ARG_fixed_length, ARG_initial_value }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} }, + { MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_initial_value, MP_ARG_KW_ONLY| MP_ARG_OBJ, {.u_obj = mp_const_empty_bytes} }, + }; + + 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); + + const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; + + if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { + mp_raise_ValueError(translate("Expected a UUID")); + } + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); + + const bleio_attribute_security_mode_t read_perm = args[ARG_read_perm].u_int; + common_hal_bleio_attribute_security_mode_check_valid(read_perm); + + const bleio_attribute_security_mode_t write_perm = args[ARG_write_perm].u_int; + common_hal_bleio_attribute_security_mode_check_valid(write_perm); + + const mp_int_t max_length = args[ARG_max_length].u_int; + const bool fixed_length = args[ARG_fixed_length].u_bool; + mp_obj_t initial_value = args[ARG_initial_value].u_obj; + + // Length will be validated in common_hal. + mp_buffer_info_t initial_value_bufinfo; + if (initial_value == mp_const_none) { + if (fixed_length && max_length > 0) { + initial_value = mp_obj_new_bytes_of_zeros(max_length); + } else { + initial_value = mp_const_empty_bytes; + } + } + mp_get_buffer_raise(initial_value, &initial_value_bufinfo, MP_BUFFER_READ); + + bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); + descriptor->base.type = &bleio_descriptor_type; + + // Range checking on max_length arg is done by the common_hal layer, because + // it may vary depending on underlying BLE implementation. + common_hal_bleio_descriptor_construct( + descriptor, uuid, read_perm, write_perm, max_length, fixed_length, &initial_value_bufinfo); + + common_hal_bleio_characteristic_add_descriptor(self, descriptor); + + return MP_OBJ_FROM_PTR(descriptor); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_descriptor_obj, 2, bleio_characteristic_add_descriptor); + //| .. method:: set_cccd(*, notify=False, indicate=False) //| //| Set the remote characteristic's CCCD to enable or disable notification and indication. @@ -265,10 +260,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_set_cccd_obj, 1, bleio_ch STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_properties), MP_ROM_PTR(&bleio_characteristic_get_properties) }, - { 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_properties), MP_ROM_PTR(&bleio_characteristic_get_properties) }, + { 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_add_descriptor), MP_ROM_PTR(&bleio_characteristic_add_descriptor_obj) }, + { MP_ROM_QSTR(MP_QSTR_set_cccd), MP_ROM_PTR(&bleio_characteristic_set_cccd_obj) }, // Bitmask constants to represent properties //| .. data:: BROADCAST @@ -319,7 +315,6 @@ STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in 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/Characteristic.h b/shared-bindings/bleio/Characteristic.h index 87942c8e9..d9d980b33 100644 --- a/shared-bindings/bleio/Characteristic.h +++ b/shared-bindings/bleio/Characteristic.h @@ -29,18 +29,20 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H #include "shared-bindings/bleio/Attribute.h" +#include "shared-bindings/bleio/Descriptor.h" #include "shared-module/bleio/Characteristic.h" #include "common-hal/bleio/Characteristic.h" 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, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_obj_list_t *descriptor_list); +extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo); 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 bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self); +extern void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor); 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 d7c2a85c7..db8d393d1 100644 --- a/shared-bindings/bleio/Descriptor.c +++ b/shared-bindings/bleio/Descriptor.c @@ -38,62 +38,14 @@ //| ========================================================= //| //| Stores information about a BLE descriptor. -//| Descriptors are encapsulated by BLE characteristics and provide contextual +//| Descriptors are attached to BLE characteristics and provide contextual //| information about the characteristic. //| - -//| .. class:: Descriptor(uuid, *, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`) -//| -//| Create a new descriptor object with the UUID uuid -//| -//| :param bleio.UUID uuid: The uuid of the descriptor -//| :param int read_perm: Specifies whether the descriptor can be read by a client, and if so, which -//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, -//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, -//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. -//| :param int write_perm: Specifies whether the descriptor can be written by a client, and if so, which -//| security mode is required. Values allowed are the same as ``read_perm``. -//| :param int max_length: Maximum length in bytes of the characteristic value. The maximum allowed is -//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum -//| number of data bytes that fit in a single BLE 4.x ATT packet. -//| :param bool fixed_length: True if the characteristic value is of fixed length. -//| -STATIC mp_obj_t bleio_descriptor_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_uuid, ARG_read_perm, ARG_write_perm, ARG_max_length, ARG_fixed_length }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN } }, - { MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN } }, - { MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} }, - { MP_QSTR_fixed_length, 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, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - const mp_obj_t uuid_arg = args[ARG_uuid].u_obj; - - if (!MP_OBJ_IS_TYPE(uuid_arg, &bleio_uuid_type)) { - mp_raise_ValueError(translate("Expected a UUID")); - } - - const bleio_attribute_security_mode_t read_perm = args[ARG_read_perm].u_int; - common_hal_bleio_attribute_security_mode_check_valid(read_perm); - - const bleio_attribute_security_mode_t write_perm = args[ARG_write_perm].u_int; - common_hal_bleio_attribute_security_mode_check_valid(write_perm); - - bleio_descriptor_obj_t *self = m_new_obj(bleio_descriptor_obj_t); - self->base.type = type; - bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_arg); - - // Range checking on max_length arg is done by the common_hal layer, because - // it may vary depending on underlying BLE implementation. - common_hal_bleio_descriptor_construct(self, uuid, read_perm, write_perm, - args[ARG_max_length].u_int, args[ARG_fixed_length].u_bool); - - return MP_OBJ_FROM_PTR(self); -} +//| A Descriptors cannot be created directly. A new local Descriptors can be created +//| and attached to a Descriptors by calling `Service.add_characteristic()`. +//| Remote Descriptor objects are created by `Central.discover_remote_services()` +//| or `Peripheral.discover_remote_services()` as part of remote Characteristics +//| in the remote Services that are discovered. //| .. attribute:: uuid //| @@ -116,7 +68,7 @@ const mp_obj_property_t bleio_descriptor_uuid_obj = { //| .. attribute:: characteristic (read-only) //| -//| The Characteristic this Descriptor is a part of. None if not yet assigned to a Characteristic. +//| The Characteristic this Descriptor is a part of. //| STATIC mp_obj_t bleio_descriptor_get_characteristic(mp_obj_t self_in) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -185,7 +137,6 @@ STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp 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 430c0d0b6..c6d49c06d 100644 --- a/shared-bindings/bleio/Descriptor.h +++ b/shared-bindings/bleio/Descriptor.h @@ -29,12 +29,13 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DESCRIPTOR_H #include "shared-module/bleio/Attribute.h" +#include "common-hal/bleio/Characteristic.h" #include "common-hal/bleio/Descriptor.h" #include "common-hal/bleio/UUID.h" 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, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length); +extern void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo); extern bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self); extern bleio_characteristic_obj_t *common_hal_bleio_descriptor_get_characteristic(bleio_descriptor_obj_t *self); extern mp_obj_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self); diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index b98e7f74b..3a78802ac 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -64,71 +64,98 @@ //| import bleio //| from adafruit_ble.advertising import ServerAdvertisement //| -//| # Create a Characteristic. -//| chara = bleio.Characteristic(bleio.UUID(0x2919), read=True, notify=True) +//| # Create a peripheral and start it up. +//| peripheral = bleio.Peripheral() //| -//| # Create a Service providing that one Characteristic. -//| serv = bleio.Service(bleio.UUID(0x180f), [chara]) +//| # Create a Service and add it to this Peripheral. +//| service = peripheral.addService(bleio.UUID(0x180f)) //| -//| # Create a peripheral and start it up. -//| periph = bleio.Peripheral([serv]) -//| adv = ServerAdvertisement(periph) -//| periph.start_advertising(adv.advertising_data_bytes, adv.scan_response_bytes) +//| # Create a Characteristic and add it to the Service. +//| characteristic = service.addCharacteristic( +//| bleio.UUID(0x2919), properties=Characteristic.READ | Characteristic.NOTIFY) //| -//| while not periph.connected: +//| adv = ServerAdvertisement(peripheral) +//| peripheral.start_advertising(adv.advertising_data_bytes, adv.scan_response_bytes) +//| +//| while not peripheral.connected: //| # Wait for connection. //| pass //| -//| .. class:: Peripheral(services=(), \*, name=None) +//| .. class:: Peripheral(name=None) //| //| 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. If name is None, //| bleio.adapter.default_name will be used. //| 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 }; + enum { ARG_name }; static const mp_arg_t allowed_args[] = { - { 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_QSTR_name, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - // 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); - bleio_peripheral_obj_t *self = m_new_obj(bleio_peripheral_obj_t); self->base.type = &bleio_peripheral_type; - // Copy the services list and validate its items. - mp_obj_t services_list_obj = mp_obj_new_list(0, NULL); - mp_obj_list_t *services_list = MP_OBJ_FROM_PTR(services_list_obj); - - 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("non-Service found in services")); - } - mp_obj_list_append(services_list, service); - } - mp_obj_t name = args[ARG_name].u_obj; - if (name == MP_OBJ_NULL || name == mp_const_none) { + if (name == mp_const_none) { name = common_hal_bleio_adapter_get_default_name(); } else if (!MP_OBJ_IS_STR(name)) { mp_raise_ValueError(translate("name must be a string")); } - common_hal_bleio_peripheral_construct(self, services_list, name); + common_hal_bleio_peripheral_construct(self, name); return MP_OBJ_FROM_PTR(self); } +//| .. method:: add_service(uuid, *, secondary=False) +//| +//| Create a new `Service` object, identitied by the specified UUID, and add it to this ``Peripheral``. +//| +//| To mark the service as secondary, pass `True` as :py:data:`secondary`. +//| +//| :param bleio.UUID uuid: The uuid of the service +//| :param bool secondary: If the service is a secondary one +// +//| :return: the new `Service` +//| +STATIC mp_obj_t bleio_peripheral_add_service(size_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_uuid, ARG_secondary }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_secondary, 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); + + const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; + + if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { + mp_raise_ValueError(translate("Expected a UUID")); + } + + const bool is_secondary = args[ARG_secondary].u_bool; + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); + + bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); + service->base.type = &bleio_service_type; + + common_hal_bleio_service_construct(service, uuid, is_secondary); + + common_hal_bleio_peripheral_add_service(self, service); + + return MP_OBJ_FROM_PTR(service); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_add_service_obj, 2, bleio_peripheral_add_service); + + //| .. attribute:: connected (read-only) //| //| True if connected to a BLE Central device. @@ -320,11 +347,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_pair_obj, bleio_peripheral_pai STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = { // Methods + { MP_ROM_QSTR(MP_QSTR_add_service), MP_ROM_PTR(&bleio_peripheral_add_service_obj) }, { 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) }, { MP_ROM_QSTR(MP_QSTR_discover_remote_services), MP_ROM_PTR(&bleio_peripheral_discover_remote_services_obj) }, - { MP_ROM_QSTR(MP_QSTR_pair) , MP_ROM_PTR(&bleio_peripheral_pair_obj) }, + { MP_ROM_QSTR(MP_QSTR_pair), MP_ROM_PTR(&bleio_peripheral_pair_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 597b65ce2..a4bc9542b 100644 --- a/shared-bindings/bleio/Peripheral.h +++ b/shared-bindings/bleio/Peripheral.h @@ -30,10 +30,12 @@ #include "py/objtuple.h" #include "common-hal/bleio/Peripheral.h" +#include "common-hal/bleio/Service.h" extern const mp_obj_type_t bleio_peripheral_type; -extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *service_list, mp_obj_t name); +extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_t name); +extern void common_hal_bleio_peripheral_add_service(bleio_peripheral_obj_t *self, bleio_service_obj_t *service); extern mp_obj_list_t *common_hal_bleio_peripheral_get_services(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); diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c index 6961b0b52..2497e9d47 100644 --- a/shared-bindings/bleio/Service.c +++ b/shared-bindings/bleio/Service.c @@ -39,73 +39,11 @@ //| //| Stores information about a BLE service and its characteristics. //| - -//| .. class:: Service(uuid, characteristics, *, secondary=False) -//| -//| Create a new Service object identified by the specified UUID. -//| -//| To mark the service as secondary, pass `True` as :py:data:`secondary`. -//| -//| :param bleio.UUID uuid: The uuid of the service -//| :param iterable characteristics: the Characteristic objects for this service -//| :param bool secondary: If the service is a secondary one +//| A Service cannot be created directly. A new local Service can be created +//| and attached to a Peripheral by calling `Peripheral.add_service()`. +//| Remote Service objects are created by `Central.discover_remote_services()` +//| or `Peripheral.discover_remote_services()`. //| -//| A Service may be remote (:py:data:`remote` is ``True``), but a remote Service -//| cannot be constructed directly. It is created by `Central.discover_remote_services()` -//| or `Peripheral.discover_remote_services()`. - -STATIC mp_obj_t bleio_service_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_uuid, ARG_characteristics, ARG_secondary }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_characteristics, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_secondary, 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, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - - if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { - mp_raise_ValueError(translate("Expected a UUID")); - } - - bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t); - self->base.type = &bleio_service_type; - - const bool is_secondary = args[ARG_secondary].u_bool; - 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_obj; - - // 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_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)) { - mp_raise_ValueError(translate("characteristics includes an object that is not a 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->uuid)) { - // The descriptor base UUID doesn't match the characteristic base UUID. - mp_raise_ValueError(translate("Characteristic UUID doesn't match Service UUID")); - } - if (common_hal_bleio_characteristic_get_service(characteristic) != MP_OBJ_NULL) { - mp_raise_ValueError(translate("Characteristic is already attached to a Service")); - } - mp_obj_list_append(char_list_obj, characteristic_obj); - } - - common_hal_bleio_service_construct(self, uuid, char_list, is_secondary); - - return MP_OBJ_FROM_PTR(self); -} //| .. attribute:: characteristics //| @@ -182,10 +120,101 @@ const mp_obj_property_t bleio_service_uuid_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| .. method:: add_characteristic(uuid, *, properties=0, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, initial_value=None) +//| +//| Create a new `Characteristic` object, and add it to this Service. +//| +//| :param bleio.UUID uuid: The uuid of the characteristic +//| :param int properties: The properties of the characteristic, +//| specified as a bitmask of these values bitwise-or'd together: +//| `Characteristic.BROADCAST`, `Characteristic.INDICATE`, `Characteristic.NOTIFY`, +//| `Characteristic.READ`, `Characteristic.WRITE`, `Characteristic.WRITE_NO_RESPONSE`. +//| :param int read_perm: Specifies whether the characteristic can be read by a client, and if so, which +//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`, +//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`, +//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`. +//| :param int write_perm: Specifies whether the characteristic can be written by a client, and if so, which +//| security mode is required. Values allowed are the same as ``read_perm``. +//| :param int max_length: Maximum length in bytes of the characteristic value. The maximum allowed is +//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum +//| number of data bytes that fit in a single BLE 4.x ATT packet. +//| :param bool fixed_length: True if the characteristic value is of fixed length. +//| :param buf initial_value: The initial value for this characteristic. If not given, will be +//| filled with zeros. +//| +//| :return: the new `Characteristic`. +//| +STATIC mp_obj_t bleio_service_add_characteristic(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + bleio_service_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + enum { ARG_uuid, ARG_properties, ARG_read_perm, ARG_write_perm, + ARG_max_length, ARG_fixed_length, ARG_initial_value }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_properties, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} }, + { MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_initial_value, 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); + + const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; + + if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) { + mp_raise_ValueError(translate("Expected a UUID")); + } + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); + + const bleio_characteristic_properties_t properties = args[ARG_properties].u_int; + if (properties & ~CHAR_PROP_ALL) { + mp_raise_ValueError(translate("Invalid properties")); + } + + const bleio_attribute_security_mode_t read_perm = args[ARG_read_perm].u_int; + common_hal_bleio_attribute_security_mode_check_valid(read_perm); + + const bleio_attribute_security_mode_t write_perm = args[ARG_write_perm].u_int; + common_hal_bleio_attribute_security_mode_check_valid(write_perm); + + const mp_int_t max_length = args[ARG_max_length].u_int; + const bool fixed_length = args[ARG_fixed_length].u_bool; + mp_obj_t initial_value = args[ARG_initial_value].u_obj; + + // Length will be validated in common_hal. + mp_buffer_info_t initial_value_bufinfo; + if (initial_value == mp_const_none) { + if (fixed_length && max_length > 0) { + initial_value = mp_obj_new_bytes_of_zeros(max_length); + } else { + initial_value = mp_const_empty_bytes; + } + } + mp_get_buffer_raise(initial_value, &initial_value_bufinfo, MP_BUFFER_READ); + + bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); + characteristic->base.type = &bleio_characteristic_type; + + // Range checking on max_length arg is done by the common_hal layer, because + // it may vary depending on underlying BLE implementation. + common_hal_bleio_characteristic_construct( + characteristic, uuid, properties, read_perm, write_perm, + max_length, fixed_length, &initial_value_bufinfo); + + common_hal_bleio_service_add_characteristic(self, characteristic); + + return MP_OBJ_FROM_PTR(characteristic); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_service_add_characteristic_obj, 2, bleio_service_add_characteristic); + 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) }, + { MP_ROM_QSTR(MP_QSTR_add_characteristic), MP_ROM_PTR(&bleio_service_add_characteristic_obj) }, }; STATIC MP_DEFINE_CONST_DICT(bleio_service_locals_dict, bleio_service_locals_dict_table); @@ -203,7 +232,6 @@ STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_pr 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/Service.h b/shared-bindings/bleio/Service.h index 716c2e8a9..91c08fbb8 100644 --- a/shared-bindings/bleio/Service.h +++ b/shared-bindings/bleio/Service.h @@ -32,11 +32,11 @@ 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 *characteristic_list, bool is_secondary); +extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, 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_remote(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_add_all_characteristics(bleio_service_obj_t *self); +extern void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, bleio_characteristic_obj_t *characteristic); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H diff --git a/shared-bindings/bleio/__init__.h b/shared-bindings/bleio/__init__.h index 89be71093..c84895068 100644 --- a/shared-bindings/bleio/__init__.h +++ b/shared-bindings/bleio/__init__.h @@ -41,7 +41,7 @@ extern const super_adapter_obj_t common_hal_bleio_adapter_obj; extern void common_hal_bleio_check_connected(uint16_t conn_handle); extern uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device); -extern mp_obj_list_t *common_hal_bleio_device_get_remote_services_list(mp_obj_t device); +extern mp_obj_list_t *common_hal_bleio_device_get_remote_service_list(mp_obj_t device); extern void common_hal_bleio_device_discover_remote_services(mp_obj_t device, mp_obj_t service_uuids_whitelist); extern mp_obj_t common_hal_bleio_gatts_read(uint16_t handle, uint16_t conn_handle); -- cgit v1.2.3 From 9435e01f9e46ed212adf592b008f3036e16c0fbd Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 14 Oct 2019 16:05:17 -0700 Subject: Support __bytes Fixes #1763 --- py/objstr.c | 16 ++++++++++++---- tests/basics/class_bytes.py | 9 +++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/basics/class_bytes.py (limited to 'py/objstr.c') diff --git a/py/objstr.c b/py/objstr.c index 6ef9a15b5..853868d21 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -31,6 +31,7 @@ #include "py/unicode.h" #include "py/objstr.h" #include "py/objlist.h" +#include "py/objtype.h" #include "py/runtime.h" #include "py/stackctrl.h" @@ -211,6 +212,10 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons return mp_const_empty_bytes; } + if (n_args > 1) { + goto wrong_args; + } + if (MP_OBJ_IS_STR(args[0])) { if (n_args < 2 || n_args > 3) { goto wrong_args; @@ -226,10 +231,6 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons return MP_OBJ_FROM_PTR(o); } - if (n_args > 1) { - goto wrong_args; - } - if (MP_OBJ_IS_SMALL_INT(args[0])) { mp_int_t len = MP_OBJ_SMALL_INT_VALUE(args[0]); if (len < 0) { @@ -241,6 +242,13 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } + // check if __bytes__ exists, and if so delegate to it + mp_obj_t dest[2]; + mp_load_method_maybe(args[0], MP_QSTR___bytes__, dest); + if (dest[0] != MP_OBJ_NULL) { + return mp_call_method_n_kw(0, 0, dest); + } + // check if argument has the buffer protocol mp_buffer_info_t bufinfo; if (mp_get_buffer(args[0], &bufinfo, MP_BUFFER_READ)) { diff --git a/tests/basics/class_bytes.py b/tests/basics/class_bytes.py new file mode 100644 index 000000000..75e2e7244 --- /dev/null +++ b/tests/basics/class_bytes.py @@ -0,0 +1,9 @@ +class C1: + def __init__(self, value): + self.value = value + + def __bytes__(self): + return self.value + +c1 = C1(b"class 1") +print(bytes(c1)) -- cgit v1.2.3 From 1610d06bb438961722c558bd695d6964c76cc080 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 14 Oct 2019 19:59:23 -0700 Subject: Switch arg check back to allow ignored args for strings --- py/objstr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'py/objstr.c') diff --git a/py/objstr.c b/py/objstr.c index 853868d21..fde264681 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -212,10 +212,6 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons return mp_const_empty_bytes; } - if (n_args > 1) { - goto wrong_args; - } - if (MP_OBJ_IS_STR(args[0])) { if (n_args < 2 || n_args > 3) { goto wrong_args; @@ -242,6 +238,10 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } + if (n_args > 1) { + goto wrong_args; + } + // check if __bytes__ exists, and if so delegate to it mp_obj_t dest[2]; mp_load_method_maybe(args[0], MP_QSTR___bytes__, dest); -- cgit v1.2.3 From 5d24ade5c9f7b1771b5b914835bd7ededc6fcdc0 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 29 Jan 2020 17:32:07 -0800 Subject: Tweak error messages to reduce code size. --- locale/ID.po | 42 ++------------------ locale/circuitpython.pot | 42 ++------------------ locale/de_DE.po | 58 ++++++++++------------------ locale/en_US.po | 42 ++------------------ locale/en_x_pirate.po | 42 ++------------------ locale/es.po | 65 +++++++++++++------------------ locale/fil.po | 56 ++++++++------------------- locale/fr.po | 65 +++++++++++++------------------ locale/it_IT.po | 56 ++++++++------------------- locale/ko.po | 42 ++------------------ locale/pl.po | 63 ++++++++++++------------------ locale/pt_BR.po | 42 ++------------------ locale/zh_Latn_pinyin.po | 66 ++++++++++++++------------------ ports/atmel-samd/common-hal/busio/UART.c | 2 +- py/objstr.c | 4 +- shared-bindings/displayio/I2CDisplay.c | 2 +- 16 files changed, 187 insertions(+), 502 deletions(-) (limited to 'py/objstr.c') diff --git a/locale/ID.po b/locale/ID.po index 6bdb0d4c0..36bfc4df6 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -512,11 +512,8 @@ msgstr "Clock unit sedang digunakan" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -661,10 +658,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -692,11 +685,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Gagal untuk mengalokasikan buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1148,10 +1141,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Tambahkan module apapun pada filesystem\n" @@ -1203,10 +1192,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1632,11 +1617,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2528,10 +2508,6 @@ msgstr "" msgid "queue overflow" msgstr "antrian meluap (overflow)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" @@ -2765,16 +2741,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "tipe tidak diketahui" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 35cd63edd..f85bcba83 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -502,11 +502,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -650,10 +647,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -681,11 +674,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1136,10 +1129,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1189,10 +1178,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1609,11 +1594,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2503,10 +2483,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2739,16 +2715,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 8fa78d64e..ba1915e43 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -506,11 +506,8 @@ msgstr "Clock unit wird benutzt" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Spalteneintrag muss digitalio.DigitalInOut sein" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "Der Befehl muss zwischen 0 und 255 liegen" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Der Befehl muss ein int zwischen 0 und 255 sein" @@ -654,10 +651,6 @@ msgstr "Erwartet ein(e) %q" msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Ein Service wird erwartet" @@ -685,11 +678,11 @@ msgstr "Kommando nicht gesendet." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Konnte keinen RX Buffer allozieren" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1151,10 +1144,6 @@ msgstr "Zugang verweigert" msgid "Pin does not have ADC capabilities" msgstr "Pin hat keine ADC Funktionalität" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Pixel außerhalb der Puffergrenzen" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "und alle Module im Dateisystem \n" @@ -1206,10 +1195,6 @@ msgstr "Eine RTC wird auf diesem Board nicht unterstützt" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "Bereich außerhalb der Grenzen" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Nur lesen möglich, da Schreibgeschützt" @@ -1637,11 +1622,6 @@ msgstr "Es müssen 8 oder 16 bits_per_sample sein" msgid "branch not in range" msgstr "Zweig ist außerhalb der Reichweite" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "buf ist zu klein. brauche %d Bytes" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "Puffer muss ein bytes-artiges Objekt sein" @@ -2541,10 +2521,6 @@ msgstr "" msgid "queue overflow" msgstr "Warteschlangenüberlauf" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "rawbuf hat nicht die gleiche Größe wie buf" - #: py/builtinimport.c msgid "relative import" msgstr "relativer Import" @@ -2784,16 +2760,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "unbekannter Typ" @@ -2921,6 +2887,9 @@ msgstr "" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Characteristic wird bereits von einem anderen Dienst verwendet." +#~ msgid "Command must be 0-255" +#~ msgstr "Der Befehl muss zwischen 0 und 255 liegen" + #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Konnte ble_uuid nicht decodieren. Status: 0x%04x" @@ -3122,6 +3091,12 @@ msgstr "" #~ msgid "Pins not valid for SPI" #~ msgstr "Pins nicht gültig für SPI" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Pixel außerhalb der Puffergrenzen" + +#~ msgid "Range out of bounds" +#~ msgstr "Bereich außerhalb der Grenzen" + #~ msgid "STA must be active" #~ msgstr "STA muss aktiv sein" @@ -3192,6 +3167,10 @@ msgstr "" #~ "Sie laufen im abgesicherten Modus, was bedeutet, dass etwas Unerwartetes " #~ "passiert ist.\n" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "buf ist zu klein. brauche %d Bytes" + #~ msgid "buffer too long" #~ msgstr "Buffer zu lang" @@ -3251,6 +3230,9 @@ msgstr "" #~ msgid "pin does not have IRQ capabilities" #~ msgstr "Pin hat keine IRQ Fähigkeiten" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "rawbuf hat nicht die gleiche Größe wie buf" + #~ msgid "readonly attribute" #~ msgstr "Readonly-Attribut" diff --git a/locale/en_US.po b/locale/en_US.po index df73627e6..c6a78b505 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -502,11 +502,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -650,10 +647,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -681,11 +674,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1136,10 +1129,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1189,10 +1178,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1609,11 +1594,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2503,10 +2483,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2739,16 +2715,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 58fdf9f70..12ca1d608 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -506,11 +506,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "" @@ -654,10 +651,6 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -685,11 +678,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1140,10 +1133,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "Belay that! Th' Pin be not ADC capable" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1193,10 +1182,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1613,11 +1598,6 @@ msgstr "" msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2507,10 +2487,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2743,16 +2719,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/es.po b/locale/es.po index 6521921a9..b4e098165 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -508,11 +508,8 @@ msgstr "Clock unit está siendo utilizado" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Entrada de columna debe ser digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Command debe estar entre 0 y 255." @@ -656,10 +653,6 @@ msgstr "Se espera un %q" msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -687,11 +680,11 @@ msgstr "Fallo enviando comando" msgid "Failed to acquire mutex, err 0x%04x" msgstr "No se puede adquirir el mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Ha fallado la asignación del buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1150,10 +1143,6 @@ msgstr "Permiso denegado" msgid "Pin does not have ADC capabilities" msgstr "Pin no tiene capacidad ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Pixel beyond bounds of buffer" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1205,11 +1194,6 @@ msgstr "RTC no soportado en esta placa" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "address fuera de límites" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Solo-lectura" @@ -1634,11 +1618,6 @@ msgstr "bits_per_sample debe ser 8 ó 16" msgid "branch not in range" msgstr "El argumento de chr() no esta en el rango(256)" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "buf es demasiado pequeño. necesita %d bytes" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "buffer debe de ser un objeto bytes-like" @@ -2542,10 +2521,6 @@ msgstr "pow() con 3 argumentos requiere enteros" msgid "queue overflow" msgstr "desbordamiento de cola(queue)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "rawbuf no es el mismo tamaño que buf" - #: py/builtinimport.c msgid "relative import" msgstr "import relativo" @@ -2781,16 +2756,6 @@ msgstr "especificador de conversión %c desconocido" msgid "unknown format code '%c' for object of type '%s'" msgstr "codigo format desconocido '%c' para el typo de objeto '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "codigo format desconocido '%c' para el typo de objeto 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "codigo format desconocido '%c' para objeto de tipo 'str'" - #: py/compile.c msgid "unknown type" msgstr "tipo desconocido" @@ -3143,6 +3108,13 @@ msgstr "paso cero" #~ msgid "Pins not valid for SPI" #~ msgstr "Pines no válidos para SPI" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Pixel beyond bounds of buffer" + +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "address fuera de límites" + #~ msgid "STA must be active" #~ msgstr "STA debe estar activo" @@ -3222,6 +3194,10 @@ msgstr "paso cero" #~ msgid "bad GATT role" #~ msgstr "mal GATT role" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "buf es demasiado pequeño. necesita %d bytes" + #~ msgid "buffer too long" #~ msgstr "buffer demasiado largo" @@ -3305,6 +3281,9 @@ msgstr "paso cero" #~ msgid "position must be 2-tuple" #~ msgstr "posición debe ser 2-tuple" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "rawbuf no es el mismo tamaño que buf" + #, fuzzy #~ msgid "readonly attribute" #~ msgstr "atributo no legible" @@ -3333,6 +3312,14 @@ msgstr "paso cero" #~ msgid "unknown config param" #~ msgstr "parámetro config desconocido" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "codigo format desconocido '%c' para el typo de objeto 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "codigo format desconocido '%c' para objeto de tipo 'str'" + #~ msgid "unknown status param" #~ msgstr "status param desconocido" diff --git a/locale/fil.po b/locale/fil.po index 69d7e169a..86378ba10 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -510,11 +510,8 @@ msgstr "Clock unit ginagamit" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "Sa gitna ng 0 o 255 dapat ang bytes." @@ -663,10 +660,6 @@ msgstr "Umasa ng %q" msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -695,11 +688,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Nabigong ilaan ang RX buffer" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1156,10 +1149,6 @@ msgstr "Walang pahintulot" msgid "Pin does not have ADC capabilities" msgstr "Ang pin ay walang kakayahan sa ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Kasama ang kung ano pang modules na sa filesystem\n" @@ -1211,11 +1200,6 @@ msgstr "Hindi supportado ang RTC sa board na ito" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "wala sa sakop ang address" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Basahin-lamang" @@ -1643,11 +1627,6 @@ msgstr "bits_per_sample ay dapat 8 o 16" msgid "branch not in range" msgstr "branch wala sa range" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "buffer ay dapat bytes-like object" @@ -2556,10 +2535,6 @@ msgstr "pow() na may 3 argumento kailangan ng integers" msgid "queue overflow" msgstr "puno na ang pila (overflow)" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" @@ -2796,16 +2771,6 @@ msgstr "hindi alam ang conversion specifier na %c" msgid "unknown format code '%c' for object of type '%s'" msgstr "hindi alam ang format code '%c' para sa object na ang type ay '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "hindi alam ang format code '%c' sa object na ang type ay 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "hindi alam ang format ng code na '%c' para sa object ng type ay 'str'" - #: py/compile.c msgid "unknown type" msgstr "hindi malaman ang type (unknown type)" @@ -3123,6 +3088,10 @@ msgstr "zero step" #~ msgid "Pins not valid for SPI" #~ msgstr "Mali ang pins para sa SPI" +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "wala sa sakop ang address" + #~ msgid "STA must be active" #~ msgstr "Dapat aktibo ang STA" @@ -3285,6 +3254,15 @@ msgstr "zero step" #~ msgid "unknown config param" #~ msgstr "hindi alam na config param" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "hindi alam ang format code '%c' sa object na ang type ay 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "" +#~ "hindi alam ang format ng code na '%c' para sa object ng type ay 'str'" + #~ msgid "unknown status param" #~ msgstr "hindi alam na status param" diff --git a/locale/fr.po b/locale/fr.po index a9124679f..b522b253d 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -515,11 +515,8 @@ msgstr "Horloge en cours d'utilisation" msgid "Column entry must be digitalio.DigitalInOut" msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "La commande doit être un entier entre 0 et 255" @@ -666,10 +663,6 @@ msgstr "Attendu un %q" msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -698,11 +691,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Echec de l'obtention de mutex, err 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Echec de l'allocation du tampon RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1170,10 +1163,6 @@ msgstr "Permission refusée" msgid "Pin does not have ADC capabilities" msgstr "La broche ne peut être utilisée pour l'ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Pixel au-delà des limites du tampon" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1224,11 +1213,6 @@ msgstr "RTC non supportée sur cette carte" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "adresse hors limites" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Lecture seule" @@ -1662,11 +1646,6 @@ msgstr "'bits_per_sample' doivent être 8 ou 16" msgid "branch not in range" msgstr "branche hors-bornes" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "'buf' est trop petit. Besoin de %d octets" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "le tampon doit être un objet bytes-like" @@ -2589,10 +2568,6 @@ msgstr "pow() avec 3 arguments nécessite des entiers" msgid "queue overflow" msgstr "dépassement de file" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "'rawbuf' n'est pas de la même taille que 'buf'" - #: py/builtinimport.c msgid "relative import" msgstr "import relatif" @@ -2830,16 +2805,6 @@ msgstr "spécification %c de conversion inconnue" msgid "unknown format code '%c' for object of type '%s'" msgstr "code de format '%c' inconnu pour un objet de type '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "code de format '%c' inconnu pour un objet de type 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "code de format '%c' inconnu pour un objet de type 'str'" - #: py/compile.c msgid "unknown type" msgstr "type inconnu" @@ -3201,6 +3166,13 @@ msgstr "'step' nul" #~ msgid "Pins not valid for SPI" #~ msgstr "Broche invalide pour le SPI" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Pixel au-delà des limites du tampon" + +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "adresse hors limites" + #~ msgid "STA must be active" #~ msgstr "'STA' doit être actif" @@ -3281,6 +3253,10 @@ msgstr "'step' nul" #~ msgid "bad GATT role" #~ msgstr "mauvais rôle GATT" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "'buf' est trop petit. Besoin de %d octets" + #~ msgid "buffer too long" #~ msgstr "tampon trop long" @@ -3364,6 +3340,9 @@ msgstr "'step' nul" #~ msgid "position must be 2-tuple" #~ msgstr "position doit être un 2-tuple" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "'rawbuf' n'est pas de la même taille que 'buf'" + #, fuzzy #~ msgid "readonly attribute" #~ msgstr "attribut en lecture seule" @@ -3389,6 +3368,14 @@ msgstr "'step' nul" #~ msgid "unknown config param" #~ msgstr "paramètre de config. inconnu" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "code de format '%c' inconnu pour un objet de type 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "code de format '%c' inconnu pour un objet de type 'str'" + #~ msgid "unknown status param" #~ msgstr "paramètre de statut inconnu" diff --git a/locale/it_IT.po b/locale/it_IT.po index 6164f6cf8..e4a06b769 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -511,11 +511,8 @@ msgstr "Unità di clock in uso" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "I byte devono essere compresi tra 0 e 255" @@ -663,10 +660,6 @@ msgstr "Atteso un %q" msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -695,11 +688,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Impossibile allocare buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1165,10 +1158,6 @@ msgstr "Permesso negato" msgid "Pin does not have ADC capabilities" msgstr "Il pin non ha capacità di ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1220,11 +1209,6 @@ msgstr "RTC non supportato su questa scheda" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Range out of bounds" -msgstr "indirizzo fuori limite" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Sola lettura" @@ -1648,11 +1632,6 @@ msgstr "i bit devono essere 7, 8 o 9" msgid "branch not in range" msgstr "argomento di chr() non è in range(256)" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2563,10 +2542,6 @@ msgstr "pow() con 3 argomenti richiede interi" msgid "queue overflow" msgstr "overflow della coda" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "importazione relativa" @@ -2803,16 +2778,6 @@ msgstr "specificatore di conversione %s sconosciuto" msgid "unknown format code '%c' for object of type '%s'" msgstr "codice di formattaione '%c' sconosciuto per oggetto di tipo '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'str'" - #: py/compile.c msgid "unknown type" msgstr "tipo sconosciuto" @@ -3134,6 +3099,10 @@ msgstr "zero step" #~ msgid "Pins not valid for SPI" #~ msgstr "Pin non validi per SPI" +#, fuzzy +#~ msgid "Range out of bounds" +#~ msgstr "indirizzo fuori limite" + #~ msgid "STA must be active" #~ msgstr "STA deve essere attiva" @@ -3272,6 +3241,15 @@ msgstr "zero step" #~ msgid "unknown config param" #~ msgstr "parametro di configurazione sconosciuto" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "" +#~ "codice di formattazione '%c' sconosciuto per oggetto di tipo 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "codice di formattazione '%c' sconosciuto per oggetto di tipo 'str'" + #~ msgid "unknown status param" #~ msgstr "prametro di stato sconosciuto" diff --git a/locale/ko.po b/locale/ko.po index ee4800626..fa4936682 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -506,11 +506,8 @@ msgstr "" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "명령은 0에서 255 사이의 정수(int) 여야합니다" @@ -654,10 +651,6 @@ msgstr "%q 이 예상되었습니다." msgid "Expected a Characteristic" msgstr "특성(Characteristic)이 예상되었습니다." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -685,11 +678,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1140,10 +1133,6 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "" @@ -1193,10 +1182,6 @@ msgstr "" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "" @@ -1614,11 +1599,6 @@ msgstr "bits_per_sample은 8 또는 16이어야합니다." msgid "branch not in range" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2508,10 +2488,6 @@ msgstr "" msgid "queue overflow" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2744,16 +2720,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 6a009357d..70106112e 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -505,11 +505,8 @@ msgstr "Jednostka zegara w użyciu" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Kolumny muszą być typu digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Komenda musi być int pomiędzy 0 a 255" @@ -653,10 +650,6 @@ msgstr "Oczekiwano %q" msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -684,11 +677,11 @@ msgstr "" msgid "Failed to acquire mutex, err 0x%04x" msgstr "Nie udało się uzyskać blokady, błąd 0x$04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Nie udała się alokacja bufora RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1141,10 +1134,6 @@ msgstr "Odmowa dostępu" msgid "Pin does not have ADC capabilities" msgstr "Nóżka nie obsługuje ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Piksel poza granicami bufora" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Oraz moduły w systemie plików\n" @@ -1194,10 +1183,6 @@ msgstr "Brak obsługi RTC" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "Zakres poza granicami" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Tylko do odczytu" @@ -1617,11 +1602,6 @@ msgstr "bits_per_sample musi być 8 lub 16" msgid "branch not in range" msgstr "skok poza zakres" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "buf zbyt mały. Wymagane %d bajtów" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "bufor mysi być typu bytes" @@ -2513,10 +2493,6 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" msgid "queue overflow" msgstr "przepełnienie kolejki" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "rawbuf nie jest tej samej wielkości co buf" - #: py/builtinimport.c msgid "relative import" msgstr "relatywny import" @@ -2750,16 +2726,6 @@ msgstr "zła specyfikacja konwersji %c" msgid "unknown format code '%c' for object of type '%s'" msgstr "zły kod formatowania '%c' dla obiektu typu '%s'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "zły kod foratowania '%c' dla obiektu typu 'float'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "zły kod formatowania '%c' dla obiektu typu 'str'" - #: py/compile.c msgid "unknown type" msgstr "zły typ" @@ -3009,6 +2975,12 @@ msgstr "zerowy krok" #~ msgid "Only slices with step=1 (aka None) are supported" #~ msgstr "Wspierane są tylko fragmenty z step=1 (albo None)" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Piksel poza granicami bufora" + +#~ msgid "Range out of bounds" +#~ msgstr "Zakres poza granicami" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX" @@ -3063,6 +3035,10 @@ msgstr "zerowy krok" #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "buf zbyt mały. Wymagane %d bajtów" + #, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "byteorder musi być typu ByteOrder (jest %s)" @@ -3077,6 +3053,9 @@ msgstr "zerowy krok" #~ msgid "name must be a string" #~ msgstr "nazwa musi być łańcuchem" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "rawbuf nie jest tej samej wielkości co buf" + #~ msgid "services includes an object that is not a Service" #~ msgstr "obiekt typu innego niż Service w services" @@ -3089,5 +3068,13 @@ msgstr "zerowy krok" #~ msgid "timeout >100 (units are now seconds, not msecs)" #~ msgstr "timeout > 100 (jednostkami są sekundy)" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "zły kod foratowania '%c' dla obiektu typu 'float'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "zły kod formatowania '%c' dla obiektu typu 'str'" + #~ msgid "write_args must be a list, tuple, or None" #~ msgstr "write_args musi być listą, krotką lub None" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 0d6592201..755dc6d97 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -507,11 +507,8 @@ msgstr "Unidade de Clock em uso" msgid "Column entry must be digitalio.DigitalInOut" msgstr "" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c #, fuzzy msgid "Command must be an int between 0 and 255" msgstr "Os bytes devem estar entre 0 e 255." @@ -658,10 +655,6 @@ msgstr "Esperado um" msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -690,11 +683,11 @@ msgstr "Falha ao enviar comando." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Não é possível ler o valor do atributo. status: 0x%02x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Falha ao alocar buffer RX" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1151,10 +1144,6 @@ msgstr "Permissão negada" msgid "Pin does not have ADC capabilities" msgstr "O pino não tem recursos de ADC" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "" - #: py/builtinhelp.c #, fuzzy msgid "Plus any modules on the filesystem\n" @@ -1205,10 +1194,6 @@ msgstr "O RTC não é suportado nesta placa" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Somente leitura" @@ -1629,11 +1614,6 @@ msgstr "bits devem ser 8" msgid "branch not in range" msgstr "Calibração está fora do intervalo" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -2525,10 +2505,6 @@ msgstr "" msgid "queue overflow" msgstr "estouro de fila" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2763,16 +2739,6 @@ msgstr "" msgid "unknown format code '%c' for object of type '%s'" msgstr "" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "" - #: py/compile.c msgid "unknown type" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d3ecc630c..369ce4426 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: 2020-01-18 11:56-0800\n" +"POT-Creation-Date: 2020-01-29 17:27-0800\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -506,11 +506,8 @@ msgstr "Shǐyòng shízhōng dānwèi" msgid "Column entry must be digitalio.DigitalInOut" msgstr "Liè tiáomù bìxū shì digitalio.DigitalInOut" -#: shared-bindings/displayio/I2CDisplay.c -msgid "Command must be 0-255" -msgstr "Mìnglìng bìxū wèi 0-255" - -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/displayio/ParallelBus.c msgid "Command must be an int between 0 and 255" msgstr "Mìnglìng bìxū shì 0 dào 255 zhī jiān de int" @@ -654,10 +651,6 @@ msgstr "Yùqí %q" msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" -#: shared-bindings/_pixelbuf/__init__.c -msgid "Expected a PixelBuf instance" -msgstr "" - #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Yùqí fúwù" @@ -685,11 +678,11 @@ msgstr "Fāsòng mìnglìng shībài." msgid "Failed to acquire mutex, err 0x%04x" msgstr "Wúfǎ huòdé mutex, err 0x%04x" -#: ports/atmel-samd/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c msgid "Failed to allocate RX buffer" msgstr "Fēnpèi RX huǎnchōng shībài" +#: ports/atmel-samd/common-hal/busio/UART.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/pulseio/PulseIn.c @@ -1146,10 +1139,6 @@ msgstr "Quánxiàn bèi jùjué" msgid "Pin does not have ADC capabilities" msgstr "Pin méiyǒu ADC nénglì" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Pixel beyond bounds of buffer" -msgstr "Xiàngsù chāochū huǎnchōng qū biānjiè" - #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" msgstr "Zài wénjiàn xìtǒng shàng tiānjiā rènhé mókuài\n" @@ -1199,10 +1188,6 @@ msgstr "Cǐ bǎn bù zhīchí RTC" msgid "Random number generation error" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Range out of bounds" -msgstr "Fànwéi chāochū biānjiè" - #: shared-bindings/pulseio/PulseIn.c msgid "Read-only" msgstr "Zhǐ dú" @@ -1626,11 +1611,6 @@ msgstr "měi jiàn yàngběn bìxū wèi 8 huò 16" msgid "branch not in range" msgstr "fēnzhī bùzài fànwéi nèi" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "buf is too small. need %d bytes" -msgstr "huǎnchōng tài xiǎo. Xūyào%d zì jié" - #: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "huǎnchōng qū bìxū shì zì jié lèi duìxiàng" @@ -2525,10 +2505,6 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" msgid "queue overflow" msgstr "duìliè yìchū" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "rawbuf is not the same size as buf" -msgstr "yuánshǐ huǎnchōng qū hé huǎnchōng qū de dàxiǎo bùtóng" - #: py/builtinimport.c msgid "relative import" msgstr "xiāngduì dǎorù" @@ -2763,16 +2739,6 @@ msgstr "wèizhī de zhuǎnhuàn biāozhù %c" msgid "unknown format code '%c' for object of type '%s'" msgstr "lèixíng '%s' duìxiàng wèizhī de géshì dàimǎ '%c'" -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'float'" -msgstr "lèixíng 'float' duìxiàng wèizhī de géshì dàimǎ '%c'" - -#: py/objstr.c -#, c-format -msgid "unknown format code '%c' for object of type 'str'" -msgstr "lèixíng 'str' duìxiàng wèizhī de géshì dàimǎ '%c'" - #: py/compile.c msgid "unknown type" msgstr "wèizhī lèixíng" @@ -2888,6 +2854,9 @@ msgstr "líng bù" #~ msgid "Characteristic already in use by another Service." #~ msgstr "Qítā fúwù bùmén yǐ shǐyòng de gōngnéng." +#~ msgid "Command must be 0-255" +#~ msgstr "Mìnglìng bìxū wèi 0-255" + #~ msgid "Could not decode ble_uuid, err 0x%04x" #~ msgstr "Wúfǎ jiěmǎ kě dú_uuid, err 0x%04x" @@ -3060,6 +3029,12 @@ msgstr "líng bù" #~ msgid "Only slices with step=1 (aka None) are supported" #~ msgstr "Jǐn zhīchí 1 bù qiēpiàn" +#~ msgid "Pixel beyond bounds of buffer" +#~ msgstr "Xiàngsù chāochū huǎnchōng qū biānjiè" + +#~ msgid "Range out of bounds" +#~ msgstr "Fànwéi chāochū biānjiè" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Ruǎn shèbèi wéihù, id: 0X%08lX, pc: 0X%08lX" @@ -3116,6 +3091,10 @@ msgstr "líng bù" #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" +#, c-format +#~ msgid "buf is too small. need %d bytes" +#~ msgstr "huǎnchōng tài xiǎo. Xūyào%d zì jié" + #, c-format #~ msgid "byteorder is not an instance of ByteOrder (got a %s)" #~ msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" @@ -3132,6 +3111,9 @@ msgstr "líng bù" #~ msgid "name must be a string" #~ msgstr "míngchēng bìxū shì yīgè zìfú chuàn" +#~ msgid "rawbuf is not the same size as buf" +#~ msgstr "yuánshǐ huǎnchōng qū hé huǎnchōng qū de dàxiǎo bùtóng" + #~ msgid "row must be packed and word aligned" #~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí" @@ -3150,6 +3132,14 @@ msgstr "líng bù" #~ msgid "too many arguments" #~ msgstr "tài duō cānshù" +#, c-format +#~ msgid "unknown format code '%c' for object of type 'float'" +#~ msgstr "lèixíng 'float' duìxiàng wèizhī de géshì dàimǎ '%c'" + +#, c-format +#~ msgid "unknown format code '%c' for object of type 'str'" +#~ msgstr "lèixíng 'str' duìxiàng wèizhī de géshì dàimǎ '%c'" + #~ msgid "unsupported bitmap type" #~ msgstr "bù zhīchí de bitmap lèixíng" diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 4ad47a58d..70857de6d 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -150,7 +150,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false, true); if (self->buffer == NULL) { common_hal_busio_uart_deinit(self); - mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); + mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), self->buffer_length * sizeof(uint8_t)); } } else { self->buffer_length = 0; diff --git a/py/objstr.c b/py/objstr.c index fde264681..a60f507e9 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1352,7 +1352,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar terse_str_format_value_error(); } else { mp_raise_ValueError_varg( - translate("unknown format code '%c' for object of type 'float'"), + translate("unknown format code '%c' for object of type '%s'"), type, mp_obj_get_type_str(arg)); } } @@ -1388,7 +1388,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar terse_str_format_value_error(); } else { mp_raise_ValueError_varg( - translate("unknown format code '%c' for object of type 'str'"), + translate("unknown format code '%c' for object of type '%s'"), type, mp_obj_get_type_str(arg)); } } diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index 4339d182f..9b863f656 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -118,7 +118,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_i2cdisplay_reset_obj, displayio_i2cdisplay_o STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj); if (!MP_OBJ_IS_SMALL_INT(command_obj) || command_int > 255 || command_int < 0) { - mp_raise_ValueError(translate("Command must be 0-255")); + mp_raise_ValueError(translate("Command must be an int between 0 and 255")); } uint8_t command = command_int; mp_buffer_info_t bufinfo; -- cgit v1.2.3