Skip to content

BLE fixes; magtag name fix #3848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-12-14 12:59-0500\n"
"POT-Creation-Date: 2020-12-18 17:12-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -3001,7 +3001,7 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr ""

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgid "max_length must be >= 0"
msgstr ""

#: extmod/ulab/code/ndarray.c
Expand Down Expand Up @@ -3139,6 +3139,14 @@ msgstr ""
msgid "non-keyword arg after keyword arg"
msgstr ""

#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "non-zero timeout must be > 0.01"
msgstr ""

#: shared-bindings/_bleio/Adapter.c
msgid "non-zero timeout must be >= interval"
msgstr ""

#: extmod/ulab/code/linalg/linalg.c
msgid "norm is defined for 1D and 2D arrays"
msgstr ""
Expand Down Expand Up @@ -3556,6 +3564,10 @@ msgstr ""
msgid "timeout must be 0.0-100.0 seconds"
msgstr ""

#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "timeout must be < 655.35 secs"
msgstr ""

#: shared-bindings/_bleio/CharacteristicBuffer.c
msgid "timeout must be >= 0.0"
msgstr ""
Expand Down
4 changes: 2 additions & 2 deletions locale/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -3073,8 +3073,8 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr "max_length debe ser 0-%d cuando fixed_length es %s"

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "max_lenght debe ser > 0"
msgid "max_length must be >= 0"
msgstr "max_lenght debe ser >= 0"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
4 changes: 2 additions & 2 deletions locale/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -3093,8 +3093,8 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr "max_length doit être 0-%d lorsque fixed_length est %s"

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "max_length doit être > 0"
msgid "max_length must be >= 0"
msgstr "max_length doit être >= 0"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
2 changes: 1 addition & 1 deletion locale/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -3063,7 +3063,7 @@ msgstr "max_length moet 0-%d zijn als fixed_length %s is"

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "max_length moet >0 zijn"
msgstr "max_length moet >= 0 zijn"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
4 changes: 2 additions & 2 deletions locale/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -3023,8 +3023,8 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr ""

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "max_length musi być > 0"
msgid "max_length must be >= 0"
msgstr "max_length musi być >= 0"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
4 changes: 2 additions & 2 deletions locale/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -3085,8 +3085,8 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr "o max_length deve ser 0-%d quando Fixed_length for %s"

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "max_length deve ser > 0"
msgid "max_length must be >= 0"
msgstr "max_length deve ser >= 0"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
4 changes: 2 additions & 2 deletions locale/sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -3056,8 +3056,8 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr "max_length måste vara 0-%d när fixed_length är %s"

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "max_length måste vara > 0"
msgid "max_length must be >= 0"
msgstr "max_length måste vara >= 0"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
4 changes: 2 additions & 2 deletions locale/zh_Latn_pinyin.po
Original file line number Diff line number Diff line change
Expand Up @@ -3047,8 +3047,8 @@ msgid "max_length must be 0-%d when fixed_length is %s"
msgstr "Dāng gùdìng chángdù wèi %s shí, zuìdà chángdù bìxū wèi 0-%d"

#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
msgid "max_length must be > 0"
msgstr "Max_length bìxū > 0"
msgid "max_length must be >= 0"
msgstr "Max_length bìxū >= 0"

#: extmod/ulab/code/ndarray.c
msgid "maximum number of dimensions is 4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

//Micropython setup

#define MICROPY_HW_BOARD_NAME "MagTag"
#define MICROPY_HW_BOARD_NAME "Adafruit MagTag"
#define MICROPY_HW_MCU_NAME "ESP32S2"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO1)
Expand Down
11 changes: 10 additions & 1 deletion ports/nrf/common-hal/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,16 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t*
ble_drv_add_event_handler(scan_on_ble_evt, self->scan_results);

uint32_t nrf_timeout = SEC_TO_UNITS(timeout, UNIT_10_MS);
if (timeout <= 0.0001) {
if (nrf_timeout > UINT16_MAX) {
// 0xffff / 100
mp_raise_ValueError(translate("timeout must be < 655.35 secs"));
}
if (nrf_timeout == 0 && timeout > 0.0f) {
// Make sure converted timeout is > 0 if original timeout is > 0.
mp_raise_ValueError(translate("non-zero timeout must be > 0.01"));
}

if (nrf_timeout) {
nrf_timeout = BLE_GAP_SCAN_TIMEOUT_UNLIMITED;
}

Expand Down
13 changes: 10 additions & 3 deletions shared-bindings/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include "shared-bindings/_bleio/Address.h"
#include "shared-bindings/_bleio/Adapter.h"

#define ADV_INTERVAL_MIN (0.0020f)
#define ADV_INTERVAL_MIN_STRING "0.0020"
#define ADV_INTERVAL_MIN (0.02001f)
#define ADV_INTERVAL_MIN_STRING "0.02001"
#define ADV_INTERVAL_MAX (10.24f)
#define ADV_INTERVAL_MAX_STRING "10.24"
// 20ms is recommended by Apple
Expand Down Expand Up @@ -307,7 +307,7 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);

mp_float_t timeout = 0;
mp_float_t timeout = 0.0f;
if (args[ARG_timeout].u_obj != mp_const_none) {
timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
}
Expand All @@ -325,6 +325,13 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args
mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), INTERVAL_MIN_STRING, INTERVAL_MAX_STRING);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
if (timeout != 0.0f && timeout < interval) {
mp_raise_ValueError(translate("non-zero timeout must be >= interval"));
}
#pragma GCC diagnostic pop

const mp_float_t window = mp_obj_float_get(args[ARG_window].u_obj);
if (window > interval) {
mp_raise_ValueError(translate("window must be <= interval"));
Expand Down
4 changes: 2 additions & 2 deletions shared-bindings/_bleio/Characteristic.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_
common_hal_bleio_attribute_security_mode_check_valid(write_perm);

const mp_int_t max_length_int = args[ARG_max_length].u_int;
if (max_length_int <= 0) {
mp_raise_ValueError(translate("max_length must be > 0"));
if (max_length_int < 0) {
mp_raise_ValueError(translate("max_length must be >= 0"));
}
const size_t max_length = (size_t) max_length_int;
const bool fixed_length = args[ARG_fixed_length].u_bool;
Expand Down
4 changes: 2 additions & 2 deletions shared-bindings/_bleio/Descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o
common_hal_bleio_attribute_security_mode_check_valid(write_perm);

const mp_int_t max_length_int = args[ARG_max_length].u_int;
if (max_length_int <= 0) {
mp_raise_ValueError(translate("max_length must be > 0"));
if (max_length_int < 0) {
mp_raise_ValueError(translate("max_length must be >= 0"));
}
const size_t max_length = (size_t) max_length_int;
const bool fixed_length = args[ARG_fixed_length].u_bool;
Expand Down