From 8d07cd9da9737a73b6a9c1f35a3427f8db25ed91 Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Mon, 27 Jul 2020 10:58:01 +0200 Subject: [PATCH 01/25] Add timeout parameter to lte_send_at_cmd timeout=0 means wait forever... --- esp32/lte/lteppp.c | 2 +- esp32/mods/modlte.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/esp32/lte/lteppp.c b/esp32/lte/lteppp.c index 3e92dab996..61e96eeccf 100644 --- a/esp32/lte/lteppp.c +++ b/esp32/lte/lteppp.c @@ -256,7 +256,7 @@ bool lteppp_wait_at_rsp (const char *expected_rsp, uint32_t timeout, bool from_m if (timeout_cnt > 0) { timeout_cnt--; } - } while (timeout_cnt > 0 && 0 == rx_len); + } while ((timeout_cnt > 0 || timeout == 0) && 0 == rx_len); memset(lteppp_trx_buffer, 0, LTE_UART_BUFFER_SIZE); uint16_t len_count = 0; diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index a705bf35d6..ba3cc8d14b 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -1231,6 +1231,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m lte_check_inppp(); STATIC const mp_arg_t allowed_args[] = { { MP_QSTR_cmd, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_obj = mp_const_none} }, }; // parse args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -1241,7 +1242,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m if (MP_OBJ_IS_STR_OR_BYTES(args[0].u_obj)) { size_t len; - lte_push_at_command_ext((char *)(mp_obj_str_get_data(args[0].u_obj, &len)), LTE_RX_TIMEOUT_MAX_MS, NULL, len); + lte_push_at_command_ext((char *)(mp_obj_str_get_data(args[0].u_obj, &len)), args[0].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, len); } else { @@ -1253,7 +1254,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m vstr_add_str(&vstr, modlte_rsp.data); while(modlte_rsp.data_remaining) { - lte_push_at_command_ext("Pycom_Dummy", LTE_RX_TIMEOUT_MAX_MS, NULL, strlen("Pycom_Dummy") ); + lte_push_at_command_ext("Pycom_Dummy", args[0].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, strlen("Pycom_Dummy") ); vstr_add_str(&vstr, modlte_rsp.data); } return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); From 09e39fe6dc5da7b0d6e02492d5d0c3bff850744f Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Mon, 27 Jul 2020 11:59:32 +0200 Subject: [PATCH 02/25] Update modlte.c Fix timeout parameter check --- esp32/mods/modlte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index ba3cc8d14b..d5aaed6967 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -1242,7 +1242,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m if (MP_OBJ_IS_STR_OR_BYTES(args[0].u_obj)) { size_t len; - lte_push_at_command_ext((char *)(mp_obj_str_get_data(args[0].u_obj, &len)), args[0].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, len); + lte_push_at_command_ext((char *)(mp_obj_str_get_data(args[0].u_obj, &len)), args[1].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, len); } else { @@ -1254,7 +1254,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m vstr_add_str(&vstr, modlte_rsp.data); while(modlte_rsp.data_remaining) { - lte_push_at_command_ext("Pycom_Dummy", args[0].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, strlen("Pycom_Dummy") ); + lte_push_at_command_ext("Pycom_Dummy", args[1].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, strlen("Pycom_Dummy") ); vstr_add_str(&vstr, modlte_rsp.data); } return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); From d93abce3084c2e3d43c7c2b1ab228a5acb7d9a18 Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Mon, 27 Jul 2020 12:09:30 +0200 Subject: [PATCH 03/25] Update modlte.c Assign LTE_RX_TIMEOUT_MAX_MS as default value --- esp32/mods/modlte.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index d5aaed6967..49d6ef993c 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -1231,7 +1231,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m lte_check_inppp(); STATIC const mp_arg_t allowed_args[] = { { MP_QSTR_cmd, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_obj = mp_const_none} }, + { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = LTE_RX_TIMEOUT_MAX_MS} }, }; // parse args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -1242,7 +1242,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m if (MP_OBJ_IS_STR_OR_BYTES(args[0].u_obj)) { size_t len; - lte_push_at_command_ext((char *)(mp_obj_str_get_data(args[0].u_obj, &len)), args[1].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, len); + lte_push_at_command_ext((char *)(mp_obj_str_get_data(args[0].u_obj, &len)), args[1].u_int, NULL, len); } else { @@ -1254,7 +1254,7 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m vstr_add_str(&vstr, modlte_rsp.data); while(modlte_rsp.data_remaining) { - lte_push_at_command_ext("Pycom_Dummy", args[1].u_obj == mp_const_none ? LTE_RX_TIMEOUT_MAX_MS : args[1].u_int, NULL, strlen("Pycom_Dummy") ); + lte_push_at_command_ext("Pycom_Dummy", args[1].u_int, NULL, strlen("Pycom_Dummy") ); vstr_add_str(&vstr, modlte_rsp.data); } return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); From 86665a21e77f80d53bd8fb1ea9ce2c4e7fdc7e09 Mon Sep 17 00:00:00 2001 From: Roberto Colistete Jr Date: Wed, 5 Aug 2020 02:53:19 -0300 Subject: [PATCH 04/25] PYCOM : make option MICROPY_FLOAT_IMPL --- esp32/Makefile | 11 +++++++++++ esp32/mpconfigport.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/esp32/Makefile b/esp32/Makefile index 0ab16d2762..fadc7325bf 100644 --- a/esp32/Makefile +++ b/esp32/Makefile @@ -123,6 +123,17 @@ CFLAGS_XTENSA_PSRAM = -mfix-esp32-psram-cache-issue CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_PSRAM) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD) CFLAGS_SIGFOX = $(CFLAGS_XTENSA) -O2 -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD) +# Configure floating point support +ifeq ($(MICROPY_FLOAT_IMPL),double) +CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE +else +ifeq ($(MICROPY_FLOAT_IMPL),none) +CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE +else +CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT +endif +endif + LDFLAGS = -nostdlib -Wl,-Map=$(@:.elf=.map) -Wl,--no-check-sections -u call_user_start_cpu0 LDFLAGS += -Wl,-static -Wl,--undefined=uxTopUsedPriority -Wl,--gc-sections diff --git a/esp32/mpconfigport.h b/esp32/mpconfigport.h index 9870415bd2..e6d2228138 100644 --- a/esp32/mpconfigport.h +++ b/esp32/mpconfigport.h @@ -101,7 +101,9 @@ #define MICROPY_PY_UTIMEQ (1) #define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) +#ifndef MICROPY_FLOAT_IMPL // can be configured by make option #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) +#endif #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) #define MICROPY_OPT_COMPUTED_GOTO (1) #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) From a06c0146db129a1e82242b13b3b5e95c6f3a7789 Mon Sep 17 00:00:00 2001 From: Roberto Colistete Jr Date: Thu, 6 Aug 2020 22:06:51 -0300 Subject: [PATCH 05/25] PYCOM : improved option MICROPY_FLOAT_IMPL --- esp32/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esp32/Makefile b/esp32/Makefile index fadc7325bf..758ca21036 100644 --- a/esp32/Makefile +++ b/esp32/Makefile @@ -130,9 +130,11 @@ else ifeq ($(MICROPY_FLOAT_IMPL),none) CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE else +ifeq ($(MICROPY_FLOAT_IMPL),single) CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT endif endif +endif LDFLAGS = -nostdlib -Wl,-Map=$(@:.elf=.map) -Wl,--no-check-sections -u call_user_start_cpu0 LDFLAGS += -Wl,-static -Wl,--undefined=uxTopUsedPriority -Wl,--gc-sections From 38f90197b3800291f7fcc2c77753a3963b8413d6 Mon Sep 17 00:00:00 2001 From: Geza Husi Date: Wed, 21 Oct 2020 18:46:59 +0200 Subject: [PATCH 06/25] Fix memory leak happens after Bluetooth disconnect, fix a problem in Bluetooth.deinit() and fix Bluetooth connection resume after machine.wakeup(True) --- esp32/mods/modbt.c | 91 ++++++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index a800f80c35..47594e21b5 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -265,7 +265,6 @@ static esp_ble_adv_params_t bt_adv_params = { static bool mod_bt_allow_resume_deinit; static uint16_t mod_bt_gatts_mtu_restore = 0; -static bool mod_bt_is_conn_restore_available; static nvs_handle modbt_nvs_handle; static uint8_t tx_pwr_level_to_dbm[] = {-12, -9, -6, -3, 0, 3, 6, 9}; @@ -324,7 +323,6 @@ void modbt_init0(void) { esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); mod_bt_allow_resume_deinit = false; - mod_bt_is_conn_restore_available = false; } void modbt_deinit(bool allow_reconnect) @@ -363,11 +361,14 @@ void modbt_deinit(bool allow_reconnect) xEventGroupWaitBits(bt_event_group, MOD_BT_GATTS_DISCONN_EVT | MOD_BT_GATTS_CLOSE_EVT, true, true, 1000/portTICK_PERIOD_MS); } + esp_ble_gattc_app_unregister(MOD_BT_CLIENT_APP_ID); + esp_ble_gatts_app_unregister(MOD_BT_SERVER_APP_ID); + esp_bluedroid_disable(); esp_bluedroid_deinit(); esp_bt_controller_disable(); + esp_bt_controller_deinit(); bt_obj.init = false; - mod_bt_is_conn_restore_available = false; xEventGroupClearBits(bt_event_group, MOD_BT_GATTC_MTU_EVT | MOD_BT_GATTS_MTU_EVT | MOD_BT_GATTS_DISCONN_EVT | MOD_BT_GATTS_CLOSE_EVT); } } @@ -393,34 +394,39 @@ void bt_resume(bool reconnect) esp_ble_gatt_set_local_mtu(mod_bt_gatts_mtu_restore); - bt_connection_obj_t *connection_obj = NULL; - - if(MP_STATE_PORT(btc_conn_list).len > 0) + // If this list has 0 elements it means there were no active connections + if(MP_STATE_PORT(btc_conn_list).len > 0 && reconnect) { - /* Get the Last gattc connection obj before sleep */ - connection_obj = ((bt_connection_obj_t *)(MP_STATE_PORT(btc_conn_list).items[MP_STATE_PORT(btc_conn_list).len - 1])); - } + /* Enable Scan */ + modbt_start_scan(MP_OBJ_NEW_SMALL_INT(-1)); + mp_hal_delay_ms(50); + while(!bt_obj.scanning){ + /* Wait for scanning to start */ + } - if (reconnect) - { - /* Check if there was a gattc connection Active before sleep */ - if (connection_obj != NULL) { - if (connection_obj->conn_id >= 0) { - /* Enable Scan */ - modbt_start_scan(MP_OBJ_NEW_SMALL_INT(-1)); - mp_hal_delay_ms(50); - while(!bt_obj.scanning){ - /* Wait for scanning to start */ - } - /* re-connect to Last Connection */ - mp_obj_list_remove((void *)&MP_STATE_PORT(btc_conn_list), connection_obj); - mp_obj_list_append((void *)&MP_STATE_PORT(btc_conn_list), modbt_connect(mp_obj_new_bytes((const byte *)connection_obj->srv_bda, 6))); + /* Re-connect to all previously existing connections */ + // Need to save the old connections into a temporary list because during connect the original list is manipulated (items added) + mp_obj_list_t btc_conn_list_tmp; + mp_obj_list_init(&btc_conn_list_tmp, 0); + for (mp_uint_t i = 0; i < MP_STATE_PORT(btc_conn_list).len; i++) { + bt_connection_obj_t *connection_obj = ((bt_connection_obj_t *)(MP_STATE_PORT(btc_conn_list).items[i])); + mp_obj_list_append(&btc_conn_list_tmp, connection_obj); + } - mod_bt_is_conn_restore_available = true; + // Connect to the old connections + for (mp_uint_t i = 0; i < btc_conn_list_tmp.len; i++) { + bt_connection_obj_t *connection_obj = ((bt_connection_obj_t *)(btc_conn_list_tmp.items[i])); + // Initiates re-connection + bt_connection_obj_t *new_connection_obj = modbt_connect(mp_obj_new_bytes((const byte *)connection_obj->srv_bda, 6)); + // If new connection object has been created then overwrite the original one so from the MicroPython code the same reference can be used + if(new_connection_obj != mp_const_none) { + memcpy(connection_obj, new_connection_obj, sizeof(bt_connection_obj_t)); + // As modbt_connect appends the new connection to the original list, it needs to be removed because it is not needed + mp_obj_list_remove((void *)&MP_STATE_PORT(btc_conn_list), new_connection_obj); } } - /* See if there was an averstisment active before Sleep */ + /* See if there was an advertisement active before Sleep */ if(bt_obj.advertising) { esp_ble_gap_start_advertising(&bt_adv_params); } @@ -554,8 +560,7 @@ static void set_pin(uint32_t new_pin) static void close_connection (int32_t conn_id) { for (mp_uint_t i = 0; i < MP_STATE_PORT(btc_conn_list).len; i++) { bt_connection_obj_t *connection_obj = ((bt_connection_obj_t *)(MP_STATE_PORT(btc_conn_list).items[i])); - /* Only reset Conn Id if it is a normal disconnect not module de-init to mark conn obj to be restored */ - if (connection_obj->conn_id == conn_id && (!mod_bt_allow_resume_deinit)) { + if (connection_obj->conn_id == conn_id) { connection_obj->conn_id = -1; mp_obj_list_remove((void *)&MP_STATE_PORT(btc_conn_list), connection_obj); } @@ -1408,7 +1413,13 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ EventBits_t uxBits; if (bt_obj.busy) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "operation already in progress")); + // Only drop exception if not called from bt_resume() API, otherwise return with mp_const_none on error + if(mod_bt_allow_resume_deinit == false) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "operation already in progress")); + } + else { + return mp_const_none; + } } if (bt_obj.scanning) { @@ -1427,13 +1438,20 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ if (ESP_OK != esp_ble_gattc_open(bt_obj.gattc_if, bufinfo.buf, BLE_ADDR_TYPE_PUBLIC, true)) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); } + MP_THREAD_GIL_EXIT(); if (xQueueReceive(xScanQueue, &bt_event, timeout) == pdTRUE) { MP_THREAD_GIL_ENTER(); if (bt_event.connection.conn_id < 0) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "connection refused")); + // Only drop exception if not called from bt_resume() API, otherwise return with mp_const_none on error + if(mod_bt_allow_resume_deinit == false) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "connection refused")); + } + else { + return mp_const_none; + } } // setup the object @@ -1452,6 +1470,7 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ } memcpy(conn->srv_bda, bt_event.connection.srv_bda, 6); mp_obj_list_append((void *)&MP_STATE_PORT(btc_conn_list), conn); + return conn; } else @@ -1459,7 +1478,14 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ MP_THREAD_GIL_ENTER(); (void)esp_ble_gap_disconnect(bufinfo.buf); - nlr_raise(mp_obj_new_exception_msg(&mp_type_TimeoutError, "timed out")); + + // Only drop exception if not called from bt_resume() API, otherwise return with mp_const_none on error + if(mod_bt_allow_resume_deinit == false) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_TimeoutError, "timed out")); + } + else { + return mp_const_none; + } } return mp_const_none; } @@ -2272,8 +2298,9 @@ STATIC mp_obj_t bt_conn_disconnect(mp_obj_t self_in) { if (self->conn_id >= 0) { esp_ble_gattc_close(bt_obj.gattc_if, self->conn_id); esp_ble_gap_disconnect(self->srv_bda); - /* Only reset Conn Id if it is a normal disconnect not module de-init to mark conn obj to be restored */ - if(!mod_bt_allow_resume_deinit) + /* Only reset Conn Id if it is needed that the connection should be established again after wakeup + * otherwise this connection will be completely removed in close_connection() call triggered by ESP_GATTC_DISCONNECT_EVT event */ + if(mod_bt_allow_resume_deinit) { self->conn_id = -1; } From ca10cd1e52687cda8431d245bcd041f29f62bee0 Mon Sep 17 00:00:00 2001 From: Geza Husi Date: Sat, 24 Oct 2020 14:13:11 +0200 Subject: [PATCH 07/25] Fix a problem when machine.sleep(resume_wifi_ble=True) drops exception when Pybytes & SmartConfig is used, but no WLAN connection has been established --- esp32/mods/modmachine.c | 4 +- esp32/mods/modwlan.c | 101 ++++++++++++++++++++++++++++------------ esp32/mods/modwlan.h | 2 +- 3 files changed, 75 insertions(+), 32 deletions(-) diff --git a/esp32/mods/modmachine.c b/esp32/mods/modmachine.c index fc9e2e8b26..9b1acd228d 100644 --- a/esp32/mods/modmachine.c +++ b/esp32/mods/modmachine.c @@ -435,13 +435,13 @@ STATIC mp_obj_t machine_sleep (uint n_args, const mp_obj_t *arg) { } modbt_deinit(reconnect); - wlan_deinit(NULL); + // TRUE means wlan_deinit is called from machine_sleep + wlan_deinit(mp_const_true); if(ESP_OK != esp_light_sleep_start()) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Wifi or BT not stopped before sleep")); } - /* resume wlan */ wlan_resume(reconnect); /* resume bt */ diff --git a/esp32/mods/modwlan.c b/esp32/mods/modwlan.c index 9b222b64c4..cdb9f387f9 100644 --- a/esp32/mods/modwlan.c +++ b/esp32/mods/modwlan.c @@ -96,14 +96,14 @@ wlan_obj_t wlan_obj = { .irq_enabled = false, .pwrsave = false, .is_promiscuous = false, - .sta_conn_timeout = false + .sta_conn_timeout = false, + .country = NULL }; /* TODO: Maybe we can add possibility to create IRQs for wifi events */ static EventGroupHandle_t wifi_event_group; -static bool mod_wlan_is_deinit = false; static uint16_t mod_wlan_ap_number_of_connections = 0; /* Variables holding wlan conn params for wakeup recovery of connections */ @@ -135,6 +135,7 @@ SemaphoreHandle_t smartConfigTimeout_mutex; static const int ESPTOUCH_DONE_BIT = BIT1; static const int ESPTOUCH_STOP_BIT = BIT2; +static const int ESPTOUCH_SLEEP_STOP_BIT = BIT3; static bool wlan_smart_config_enabled = false; /****************************************************************************** @@ -202,24 +203,36 @@ void wlan_pre_init (void) { wlan_obj.mutex = xSemaphoreCreateMutex(); timeout_mutex = xSemaphoreCreateMutex(); smartConfigTimeout_mutex = xSemaphoreCreateMutex(); - memcpy(wlan_obj.country.cc, (const char*)"NA", sizeof(wlan_obj.country.cc)); // create Smart Config Task xTaskCreatePinnedToCore(TASK_SMART_CONFIG, "SmartConfig", SMART_CONF_TASK_STACK_SIZE / sizeof(StackType_t), NULL, SMART_CONF_TASK_PRIORITY, &SmartConfTaskHandle, 1); } void wlan_resume (bool reconnect) { - if (!wlan_obj.started && mod_wlan_is_deinit) { - - mod_wlan_is_deinit = false; - - if(reconnect) - { - wifi_country_t* country = NULL; - - if(strcmp((const char*)wlan_obj.country.cc, "NA")) - { - country = &(wlan_obj.country); + // Configure back WLAN as it was before if reconnect is TRUE + if(reconnect) { + // If SmartConfig enabled then re-start it + if(wlan_smart_config_enabled) { + // Do initial configuration as at this point the Wifi Driver is not initialized + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); + wlan_set_antenna(wlan_obj.antenna); + wlan_set_mode(wlan_obj.mode); + wlan_set_bandwidth(wlan_obj.bandwidth); + if(wlan_obj.country != NULL) { + esp_wifi_set_country(wlan_obj.country); + } + xTaskNotifyGive(SmartConfTaskHandle); + } + // Otherwise set up WLAN with the same parameters as it was before + else { + // In wlan_setup the wlan_obj.country is overwritten with the value coming from setup_config, need to save it out + wifi_country_t country; + wifi_country_t* country_ptr = NULL; + if(wlan_obj.country != NULL) { + memcpy(&country, wlan_obj.country, sizeof(wifi_country_t)); + country_ptr = &country; } wlan_internal_setup_t setup_config = { @@ -234,11 +247,11 @@ void wlan_resume (bool reconnect) false, wlan_conn_recover_hidden, wlan_obj.bandwidth, - country, + country_ptr, &(wlan_obj.max_tx_pwr) }; - // initialize the wlan subsystem + // Initialize & reconnect to the previous connection wlan_setup(&setup_config); } } @@ -258,12 +271,15 @@ void wlan_setup (wlan_internal_setup_t *config) { wlan_set_bandwidth(config->bandwidth); if (config->country != NULL) { - - if(ESP_OK != esp_wifi_set_country(config->country)) + esp_err_t ret = esp_wifi_set_country(config->country); + if(ESP_OK != ret) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); } - memcpy(&(wlan_obj.country), config->country, sizeof(wlan_obj.country)); + if(wlan_obj.country == NULL) { + wlan_obj.country = (wifi_country_t*)malloc(sizeof(wifi_country_t)); + } + memcpy(wlan_obj.country, config->country, sizeof(wifi_country_t)); } if(config->max_tx_pr != NULL) @@ -950,9 +966,8 @@ static void TASK_SMART_CONFIG (void *pvParameters) { static uint32_t thread_notification; smartConf_init: - wlan_smart_config_enabled = false; connected = false; - // Block task till notification is recieved + // Block task till notification is received thread_notification = ulTaskNotifyTake(pdTRUE, portMAX_DELAY); if (thread_notification) { @@ -967,30 +982,37 @@ static void TASK_SMART_CONFIG (void *pvParameters) { } CHECK_ESP_ERR(esp_smartconfig_set_type(SC_TYPE_ESPTOUCH), smartConf_init) CHECK_ESP_ERR(esp_smartconfig_start(smart_config_callback), smartConf_init) - wlan_smart_config_enabled = true; goto smartConf_start; } goto smartConf_init; smartConf_start: - //mp_printf(&mp_plat_print, "\n-------SmartConfig Started-------\n"); + wlan_smart_config_enabled = true; + mp_printf(&mp_plat_print, "\n-------SmartConfig Started-------\n"); /*create Timer */ wlan_smartConfig_timeout = xTimerCreate("smartConfig_Timer", 60000 / portTICK_PERIOD_MS, 0, 0, wlan_timer_callback); /*start Timer */ xTimerStart(wlan_smartConfig_timeout, 0); while (1) { - uxBits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT | ESPTOUCH_DONE_BIT | ESPTOUCH_STOP_BIT, true, false, portMAX_DELAY); + uxBits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT | ESPTOUCH_DONE_BIT | ESPTOUCH_STOP_BIT | ESPTOUCH_SLEEP_STOP_BIT, true, false, portMAX_DELAY); if(uxBits & ESPTOUCH_STOP_BIT) { + wlan_smart_config_enabled = false; esp_smartconfig_stop(); //mp_printf(&mp_plat_print, "\nSmart Config Aborted or Timed-out\n"); goto smartConf_init; } + if(uxBits & ESPTOUCH_SLEEP_STOP_BIT) { + esp_smartconfig_stop(); + //mp_printf(&mp_plat_print, "\nSmart Config Aborted because sleep operation has been requested\n"); + goto smartConf_init; + } if(uxBits & CONNECTED_BIT) { //mp_printf(&mp_plat_print, "WiFi Connected to ap\n"); connected = true; } if(uxBits & ESPTOUCH_DONE_BIT) { //mp_printf(&mp_plat_print, "smartconfig over\n"); + wlan_smart_config_enabled = false; esp_smartconfig_stop(); wlan_stop_smartConfig_timer(); //set event flag @@ -1244,11 +1266,25 @@ mp_obj_t wlan_deinit(mp_obj_t self_in) { if (wlan_obj.started) { + bool called_from_sleep = false; + // stop smart config if enabled - if(wlan_smart_config_enabled) - { - xEventGroupSetBits(wifi_event_group, ESPTOUCH_STOP_BIT); - vTaskDelay(100/portTICK_PERIOD_MS); + if(wlan_smart_config_enabled) { + // If the input parameter is not the object itself but a simple boolean, it is interpreted that + // wlan_deinit is called from machine_sleep() + if(mp_obj_get_type(self_in) == &mp_type_bool) { + called_from_sleep = (bool)mp_obj_get_int(self_in); + if(called_from_sleep == true) { + // stop smart config with special event + xEventGroupSetBits(wifi_event_group, ESPTOUCH_SLEEP_STOP_BIT); + vTaskDelay(100/portTICK_PERIOD_MS); + } + } + else { + // stop smart config with original STOP event + xEventGroupSetBits(wifi_event_group, ESPTOUCH_STOP_BIT); + vTaskDelay(100/portTICK_PERIOD_MS); + } } mod_network_deregister_nic(&wlan_obj); @@ -1262,7 +1298,11 @@ mp_obj_t wlan_deinit(mp_obj_t self_in) { /* stop and free wifi resource */ esp_wifi_deinit(); - mod_wlan_is_deinit = true; + // Only free up memory area of country information if this deinit is not called from machine.sleep() + if(called_from_sleep == false) { + free(wlan_obj.country); + wlan_obj.country = NULL; + } wlan_obj.started = false; mod_network_deregister_nic(&wlan_obj); } @@ -2446,6 +2486,9 @@ STATIC mp_obj_t wlan_country(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); } + if(wlan_obj.country == NULL) { + wlan_obj.country = (wifi_country_t*)malloc(sizeof(wifi_country_t)); + } memcpy(&(wlan_obj.country), &country_config, sizeof(wlan_obj.country)); return mp_const_none; diff --git a/esp32/mods/modwlan.h b/esp32/mods/modwlan.h index 1dcdc6e51a..97f572b15f 100644 --- a/esp32/mods/modwlan.h +++ b/esp32/mods/modwlan.h @@ -73,7 +73,7 @@ typedef struct _wlan_obj_t { uint8_t channel; uint8_t antenna; int8_t max_tx_pwr; - wifi_country_t country; + wifi_country_t* country; // my own ssid, key and mac uint8_t ssid[(MODWLAN_SSID_LEN_MAX + 1)]; From ca673c0cd065618a02b14d93bca4d993ff9e993d Mon Sep 17 00:00:00 2001 From: Geza Husi Date: Sun, 25 Oct 2020 13:17:50 +0100 Subject: [PATCH 08/25] Small changes --- esp32/mods/modbt.c | 8 +++++++- esp32/mods/modmachine.c | 1 + esp32/mods/modwlan.c | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index 47594e21b5..6bfbe9d6a8 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -1436,7 +1436,13 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ /* Initiate a background connection, esp_ble_gattc_open returns immediately */ if (ESP_OK != esp_ble_gattc_open(bt_obj.gattc_if, bufinfo.buf, BLE_ADDR_TYPE_PUBLIC, true)) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); + // Only drop exception if not called from bt_resume() API, otherwise return with mp_const_none on error + if(mod_bt_allow_resume_deinit == false) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); + } + else { + return mp_const_none; + } } MP_THREAD_GIL_EXIT(); diff --git a/esp32/mods/modmachine.c b/esp32/mods/modmachine.c index 9b1acd228d..40b2e71571 100644 --- a/esp32/mods/modmachine.c +++ b/esp32/mods/modmachine.c @@ -442,6 +442,7 @@ STATIC mp_obj_t machine_sleep (uint n_args, const mp_obj_t *arg) { { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Wifi or BT not stopped before sleep")); } + /* resume wlan */ wlan_resume(reconnect); /* resume bt */ diff --git a/esp32/mods/modwlan.c b/esp32/mods/modwlan.c index cdb9f387f9..81efbd1818 100644 --- a/esp32/mods/modwlan.c +++ b/esp32/mods/modwlan.c @@ -988,7 +988,6 @@ static void TASK_SMART_CONFIG (void *pvParameters) { smartConf_start: wlan_smart_config_enabled = true; - mp_printf(&mp_plat_print, "\n-------SmartConfig Started-------\n"); /*create Timer */ wlan_smartConfig_timeout = xTimerCreate("smartConfig_Timer", 60000 / portTICK_PERIOD_MS, 0, 0, wlan_timer_callback); /*start Timer */ @@ -2489,7 +2488,7 @@ STATIC mp_obj_t wlan_country(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ if(wlan_obj.country == NULL) { wlan_obj.country = (wifi_country_t*)malloc(sizeof(wifi_country_t)); } - memcpy(&(wlan_obj.country), &country_config, sizeof(wlan_obj.country)); + memcpy(wlan_obj.country, &country_config, sizeof(wifi_country_t)); return mp_const_none; } From e3f3b417b4c4f1b064ff038cf160d84c2d5f0c2e Mon Sep 17 00:00:00 2001 From: Geza Husi Date: Sun, 25 Oct 2020 13:59:47 +0100 Subject: [PATCH 09/25] Adding these changes because looks good and even they not needed with esp-idf 3.3.1 adding them to keep sync with the FW with esp-idf 4.1 --- esp32/mods/modbt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index 6bfbe9d6a8..831daa248b 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -389,6 +389,10 @@ void bt_resume(bool reconnect) nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Bluetooth enable failed")); } + esp_ble_gap_register_callback(gap_events_handler); + esp_ble_gattc_register_callback(gattc_events_handler); + esp_ble_gatts_register_callback(gatts_event_handler); + esp_ble_gattc_app_register(MOD_BT_CLIENT_APP_ID); esp_ble_gatts_app_register(MOD_BT_SERVER_APP_ID); From c3e7b6cc3faf81df44fd7a0cdfe8665662d4d812 Mon Sep 17 00:00:00 2001 From: gijsio <67470426+gijsio@users.noreply.github.com> Date: Wed, 28 Oct 2020 11:12:58 +0100 Subject: [PATCH 10/25] pygate: reset the JIT queue margins reverts: 8c99657 --- esp32/pygate/lora_pkt_fwd/jitqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32/pygate/lora_pkt_fwd/jitqueue.c b/esp32/pygate/lora_pkt_fwd/jitqueue.c index 7241627032..c078e2f39b 100644 --- a/esp32/pygate/lora_pkt_fwd/jitqueue.c +++ b/esp32/pygate/lora_pkt_fwd/jitqueue.c @@ -42,7 +42,7 @@ Maintainer: Michael Coracin /* --- PRIVATE CONSTANTS & TYPES -------------------------------------------- */ #define TX_START_DELAY 1500 /* microseconds */ /* TODO: get this value from HAL? */ -#define TX_MARGIN_DELAY 1000000 /* Packet overlap margin in microseconds */ +#define TX_MARGIN_DELAY 1000 /* Packet overlap margin in microseconds */ /* TODO: How much margin should we take? */ #define TX_JIT_DELAY 50000 /* Pre-delay to program packet for TX in microseconds */ #define TX_MAX_ADVANCE_DELAY ((JIT_NUM_BEACON_IN_QUEUE + 1) * 128 * 1E6) /* Maximum advance delay accepted for a TX packet, compared to current time */ From 9f4489611162f559c4eb407009211b397c62e97b Mon Sep 17 00:00:00 2001 From: Geza Husi Date: Tue, 3 Nov 2020 17:54:41 +0100 Subject: [PATCH 11/25] Resume the BT Connection from the original list if connection was not successfully established during resume so GC can free up the area --- esp32/mods/modbt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index 831daa248b..e38bd2ef84 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -428,6 +428,10 @@ void bt_resume(bool reconnect) // As modbt_connect appends the new connection to the original list, it needs to be removed because it is not needed mp_obj_list_remove((void *)&MP_STATE_PORT(btc_conn_list), new_connection_obj); } + else { + // Remove the old connection from the original list because connection could not be established with it + mp_obj_list_remove((void *)&MP_STATE_PORT(btc_conn_list), connection_obj); + } } /* See if there was an advertisement active before Sleep */ From da9f54514263076f0164675f76ec5e7493ec7ab3 Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Thu, 12 Nov 2020 20:01:32 +0100 Subject: [PATCH 12/25] Update _terminal.py Fix terminal redirection --- esp32/frozen/Pybytes/_terminal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp32/frozen/Pybytes/_terminal.py b/esp32/frozen/Pybytes/_terminal.py index 9906a1ba2d..7125ff5729 100644 --- a/esp32/frozen/Pybytes/_terminal.py +++ b/esp32/frozen/Pybytes/_terminal.py @@ -7,13 +7,14 @@ ''' from machine import UART +import os class Terminal: def __init__(self, pybytes_protocol): self.__pybytes_protocol = pybytes_protocol - self.original_terminal = UART(0, 115200) + self.original_terminal = os.dupterm() self.message_from_pybytes = False self.message_to_send = '' From 944d708bda908679fbc8ce9b95e1a87ceb082cf4 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Thu, 27 Aug 2020 15:47:53 +0200 Subject: [PATCH 13/25] lorapf: add pygate_reset() to power cycle the module this will reset the esp32 and the LTE modem on the GPy this requires PIC FW v12 --- esp32/mods/modmachine.c | 8 ++++++ esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c | 35 ++++++++++++++++++++++++ esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h | 1 + 3 files changed, 44 insertions(+) diff --git a/esp32/mods/modmachine.c b/esp32/mods/modmachine.c index 40b2e71571..b5d07bfd3c 100644 --- a/esp32/mods/modmachine.c +++ b/esp32/mods/modmachine.c @@ -287,6 +287,13 @@ STATIC mp_obj_t machine_pygate_deinit (void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_pygate_deinit_obj, machine_pygate_deinit); + +STATIC mp_obj_t machine_pygate_reset (void) { + pygate_reset(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_pygate_reset_obj, machine_pygate_reset); + STATIC mp_obj_t machine_pygate_debug_level (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC const mp_arg_t allowed_args[] = { { MP_QSTR_level, MP_ARG_INT, }, @@ -622,6 +629,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { #ifdef PYGATE_ENABLED { MP_OBJ_NEW_QSTR(MP_QSTR_pygate_init), (mp_obj_t)&machine_pygate_init_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pygate_deinit), (mp_obj_t)&machine_pygate_deinit_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_pygate_reset), (mp_obj_t)&machine_pygate_reset_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pygate_debug_level), (mp_obj_t)&machine_pygate_debug_level_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pygate_cmd_decode), (mp_obj_t)&machine_pygate_cmd_decode_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pygate_cmd_get), (mp_obj_t)&machine_pygate_cmd_get_obj }, diff --git a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c index 238a75fd01..97c993a1e3 100644 --- a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c +++ b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c @@ -71,6 +71,9 @@ License: Revised BSD License, see LICENSE.TXT file include in the project #include "py/obj.h" #include "py/mpprint.h" #include "modmachine.h" +#include "machpin.h" +#include "pins.h" +#include "sx1308-config.h" /* -------------------------------------------------------------------------- */ /* --- PRIVATE MACROS ------------------------------------------------------- */ @@ -903,6 +906,38 @@ void lora_gw_init(const char* global_conf) { MSG_INFO("lora_gw_init() done fh=%u high=%u\n", xPortGetFreeHeapSize(), uxTaskGetStackHighWaterMark(NULL)); } +void pygate_reset() { + MSG_INFO("pygate_reset\n"); + + // pull sx1257 and sx1308 reset high, the PIC FW should power cycle the ESP32 as a result + pin_obj_t* sx1308_rst = SX1308_RST_PIN; + pin_config(sx1308_rst, -1, -1, GPIO_MODE_OUTPUT, MACHPIN_PULL_NONE, 0); + pin_obj_t* sx1257_rst = (&PIN_MODULE_P8); + pin_config(sx1257_rst, -1, -1, GPIO_MODE_OUTPUT, MACHPIN_PULL_NONE, 0); + + sx1308_rst->value = 1; + sx1257_rst->value = 1; + + pin_set_value(sx1308_rst); + pin_set_value(sx1257_rst); + + vTaskDelay(5000 / portTICK_PERIOD_MS); + + // if this is still being executed, then it seems the ESP32 reset did not take place + // set the two reset lines low again and stop the lora gw task, to make sure we return to a defined state + MSG_ERROR("pygate_reset failed to reset\n"); + sx1308_rst->value = 0; + sx1257_rst->value = 0; + pin_set_value(sx1308_rst); + pin_set_value(sx1257_rst); + + if (xLoraGwTaskHndl){ + vTaskDelete(xLoraGwTaskHndl); + xLoraGwTaskHndl = NULL; + } + +} + int lora_gw_get_debug_level(){ return debug_level; } diff --git a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h index 160d025856..3b2bbf83d2 100644 --- a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h +++ b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h @@ -28,6 +28,7 @@ Maintainer: Michael Coracin #include "py/mpprint.h" int lora_gw_init(char *); +void pygate_reset(); int lora_gw_get_debug_level(); void lora_gw_set_debug_level(int level); From 58db509e407b6809a6b5848e938471d401c87f79 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Wed, 26 Aug 2020 16:32:19 +0200 Subject: [PATCH 14/25] LTE: check for SIM card before attaching --- esp32/mods/modlte.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index 8a6ac67f01..7552047925 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -860,6 +860,11 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t lte_check_attached(lte_legacyattach_flag); if (lteppp_get_state() < E_LTE_ATTACHING) { + + if ( ! lte_check_sim_present() ) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_RuntimeError, "Sim card not present")); + } + const char *carrier = "standard"; if (!lte_push_at_command("AT+SQNCTM?", LTE_RX_TIMEOUT_MAX_MS)) { if (!lte_push_at_command("AT+SQNCTM?", LTE_RX_TIMEOUT_MAX_MS)) { @@ -913,13 +918,13 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } else { + // argument 'band' if (args[0].u_obj != mp_const_none) { - // argument 'band' lte_add_band(mp_obj_get_int(args[0].u_obj), is_hw_new_band_support, is_sw_new_band_support, version); } + // argument 'bands' if (args[6].u_obj != mp_const_none){ - // argument 'bands' mp_obj_t *bands; size_t n_bands=0; mp_obj_get_array(args[6].u_obj, &n_bands, &bands); @@ -933,12 +938,14 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } else { lte_obj.carrier = true; } + + // argument 'cid' if (args[3].u_obj != mp_const_none) { lte_obj.cid = args[3].u_int; } + // argument 'apn' if (args[1].u_obj != mp_const_none || args[4].u_obj != mp_const_none) { - const char* strapn; const char* strtype; @@ -964,11 +971,14 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); } } + + // argument 'log' if (args[2].u_obj == mp_const_false) { lte_push_at_command("AT!=\"disablelog 1\"", LTE_RX_TIMEOUT_MAX_MS); } else { lte_push_at_command("AT!=\"disablelog 0\"", LTE_RX_TIMEOUT_MAX_MS); } + lteppp_set_state(E_LTE_ATTACHING); if (!lte_push_at_command("AT+CFUN=1", LTE_RX_TIMEOUT_MAX_MS)) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); From b822a70f8a97aca73e207e1c90f5d73a56edd66b Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Fri, 6 Nov 2020 17:57:14 +0100 Subject: [PATCH 15/25] lorapf: fix warnings --- esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c | 6 ++--- esp32/pygate/lora_pkt_fwd/trace.h | 28 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c index 97c993a1e3..0938dab46b 100644 --- a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c +++ b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c @@ -230,7 +230,7 @@ static struct lgw_tx_gain_lut_s txlut; /* TX gain table */ static uint32_t tx_freq_min[LGW_RF_CHAIN_NB]; /* lowest frequency supported by TX chain */ static uint32_t tx_freq_max[LGW_RF_CHAIN_NB]; /* highest frequency supported by TX chain */ -int debug_level = INFO_; +int debug_level = LORAPF_INFO_; /* -------------------------------------------------------------------------- */ /* --- PRIVATE FUNCTIONS DECLARATION ---------------------------------------- */ @@ -1358,8 +1358,8 @@ void TASK_lora_gw(void *pvParameters) { } /* display a report */ -#if DEBUG_LEVEL >= INFO_ - if ( debug_level >= INFO_){ +#if LORAPF_DEBUG_LEVEL >= LORAPF_INFO_ + if ( debug_level >= LORAPF_INFO_){ MSG_INFO("[main] report\n##### %s #####\n", stat_timestamp); mp_printf(&mp_plat_print, "### [UPSTREAM] ###\n"); mp_printf(&mp_plat_print, "# RF packets received by concentrator: %u\n", cp_nb_rx_rcv); diff --git a/esp32/pygate/lora_pkt_fwd/trace.h b/esp32/pygate/lora_pkt_fwd/trace.h index 3fbe77ac78..fdc399abdb 100644 --- a/esp32/pygate/lora_pkt_fwd/trace.h +++ b/esp32/pygate/lora_pkt_fwd/trace.h @@ -32,42 +32,42 @@ Maintainer: Michael Coracin #include "py/mpprint.h" // debug levels -#define DEBUG 4 -#define INFO_ 3 -#define WARN_ 2 -#define ERROR 1 +#define LORAPF_DEBUG 4 +#define LORAPF_INFO_ 3 +#define LORAPF_WARN_ 2 +#define LORAPF_ERROR 1 // run time debug level extern int debug_level; // compile time debug level -#define DEBUG_LEVEL INFO_ +#define LORAPF_DEBUG_LEVEL LORAPF_INFO_ #define MSG_DX(LEVEL, fmt, ...) \ do { \ if (debug_level >= LEVEL) \ - mp_printf(&mp_plat_print, "[%u] lorapf: " #LEVEL " " fmt, mp_hal_ticks_ms(), ##__VA_ARGS__); \ + mp_printf(&mp_plat_print, "[%u] " #LEVEL ":" fmt, mp_hal_ticks_ms(), ##__VA_ARGS__); \ } while (0) -#if DEBUG_LEVEL >= DEBUG -#define MSG_DEBUG(...) MSG_DX(DEBUG, __VA_ARGS__) +#if LORAPF_DEBUG_LEVEL >= LORAPF_DEBUG +#define MSG_DEBUG(...) MSG_DX(LORAPF_DEBUG, __VA_ARGS__) #else #define MSG_DEBUG(...) (void)0 #endif -#if DEBUG_LEVEL >= INFO_ -#define MSG_INFO(...) MSG_DX(INFO_, __VA_ARGS__) +#if LORAPF_DEBUG_LEVEL >= LORAPF_INFO_ +#define MSG_INFO(...) MSG_DX(LORAPF_INFO_, __VA_ARGS__) #else #define MSG_INFO(...) (void)0 #endif -#if DEBUG_LEVEL >= WARN_ -#define MSG_WARN(...) MSG_DX(WARN_, __VA_ARGS__) +#if LORAPF_DEBUG_LEVEL >= LORAPF_WARN_ +#define MSG_WARN(...) MSG_DX(LORAPF_WARN_, __VA_ARGS__) #else #define MSG_WARN(...) (void)0 #endif -#if DEBUG_LEVEL >= ERROR -#define MSG_ERROR(...) MSG_DX(ERROR, __VA_ARGS__) +#if LORAPF_DEBUG_LEVEL >= LORAPF_ERROR +#define MSG_ERROR(...) MSG_DX(LORAPF_ERROR, __VA_ARGS__) #else #define MSG_ERROR(...) (void)0 #endif From 7d2e8e053c8d755b0f528b0c3ff67aeefcf7b556 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Mon, 9 Nov 2020 12:20:52 +0100 Subject: [PATCH 16/25] str_utils: add hexdump() --- esp32/util/str_utils.c | 41 +++++++++++++++++++++++++++++++++++++++++ esp32/util/str_utils.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/esp32/util/str_utils.c b/esp32/util/str_utils.c index 8702e75610..beb94908f9 100644 --- a/esp32/util/str_utils.c +++ b/esp32/util/str_utils.c @@ -1,5 +1,6 @@ #include "str_utils.h" #include +#include /** * Create a string representation of a uint8 @@ -18,3 +19,43 @@ void sprint_binary_u8(char* s, uint8_t v){ ); } +/* hexdump a buffer +*/ +void hexdump(const uint8_t* buf, size_t len){ + const size_t line_len = 16; + uint8_t line[line_len+1]; + memset(line, ' ', line_len); + line[line_len] = '\0'; + + for ( size_t i = 0; i < len; ++i) { + uint8_t c = buf[i]; + printf("%02x ", c); + if ( (c >= (uint8_t)'a' && c <= (uint8_t)'z') + || (c >= (uint8_t)'A' && c <= (uint8_t)'Z') + || (c >= (uint8_t)'0' && c <= (uint8_t)'9') ) + { + line[i%line_len] = c; + } else { + line[i%line_len] = '.'; + } + + // space after 8 bytes + if (i%16 == 7) + printf(" "); + // end of line after 16 bytes + if (i%16==15){ + printf(" |%s|\n", line); + memset(line, ' ', line_len); + } + } + if ( len % line_len ){ + // space after 8 bytes + if ( len % line_len < 7) + printf(" "); + // spaces for bytes we didn't have to print + for ( size_t j = line_len; j > len % line_len; j-- ){ + printf(" "); + } + printf(" |%s|\n", line); + } +} diff --git a/esp32/util/str_utils.h b/esp32/util/str_utils.h index 258b6d1dc0..298ed561b7 100644 --- a/esp32/util/str_utils.h +++ b/esp32/util/str_utils.h @@ -14,4 +14,6 @@ void sprint_binary_u8(char* s, uint8_t v); +void hexdump(const uint8_t* buf, size_t len); + #endif From 49373491a14347be129a2fd8cea6420f01a52a0e Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Mon, 9 Nov 2020 12:25:32 +0100 Subject: [PATCH 17/25] lte: debug MSG and state --- esp32/lte/lteppp.c | 231 ++++++++++++++++++++++++++++++++++++-------- esp32/lte/lteppp.h | 4 + esp32/mods/modlte.c | 20 +++- 3 files changed, 211 insertions(+), 44 deletions(-) diff --git a/esp32/lte/lteppp.c b/esp32/lte/lteppp.c index 500d8af94f..6b2fc1fe50 100644 --- a/esp32/lte/lteppp.c +++ b/esp32/lte/lteppp.c @@ -60,10 +60,21 @@ static char lteppp_trx_buffer[LTE_UART_BUFFER_SIZE + 1]; #ifdef LTE_DEBUG_BUFF static lte_log_t lteppp_log; #endif +//#define LTEPPP_DEBUG +#ifdef LTEPPP_DEBUG +// #define MSG(fmt, ...) printf("[%u] LTEPPP %s: " fmt, mp_hal_ticks_ms(), __func__, ##__VA_ARGS__) +#define MSG(fmt, ...) do { \ + printf("[%u] LTEPPP %s: " fmt, mp_hal_ticks_ms(), __func__, ##__VA_ARGS__); \ + lteppp_print_states(); \ + } while (0) +#else +#define MSG(fmt, ...) (void)0 +#endif + static char lteppp_queue_buffer[LTE_UART_BUFFER_SIZE]; static uart_dev_t* lteppp_uart_reg; -static QueueHandle_t xCmdQueue; -static QueueHandle_t xRxQueue; +static QueueHandle_t xCmdQueue = NULL; +static QueueHandle_t xRxQueue = NULL; static lte_state_t lteppp_lte_state; static lte_legacy_t lteppp_lte_legacy; static SemaphoreHandle_t xLTESem; @@ -83,7 +94,7 @@ static ltepppconnstatus_t lteppp_connstatus = LTE_PPP_IDLE; static ip_addr_t ltepp_dns_info[2]={0}; -static QueueHandle_t uart0_queue; +static QueueHandle_t uart0_queue = NULL; static bool lte_uart_break_evt = false; @@ -97,12 +108,16 @@ static bool lteppp_send_at_cmd(const char *cmd, uint32_t timeout); static bool lteppp_check_sim_present(void); static void lteppp_status_cb (ppp_pcb *pcb, int err_code, void *ctx); static uint32_t lteppp_output_callback(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx); +#ifdef LTEPPP_DEBUG +static void lteppp_print_states(); +#endif /****************************************************************************** DEFINE PUBLIC FUNCTIONS ******************************************************************************/ void connect_lte_uart (void) { + MSG("\n"); // initialize the UART interface uart_config_t config; @@ -116,10 +131,10 @@ void connect_lte_uart (void) { uart_param_config(LTE_UART_ID, &config); // configure the UART pins - pin_config(MICROPY_LTE_TX_PIN, -1, U2TXD_OUT_IDX, GPIO_MODE_OUTPUT, MACHPIN_PULL_NONE, 1); - pin_config(MICROPY_LTE_RX_PIN, U2RXD_IN_IDX, -1, GPIO_MODE_INPUT, MACHPIN_PULL_NONE, 1); - pin_config(MICROPY_LTE_RTS_PIN, -1, U2RTS_OUT_IDX, GPIO_MODE_OUTPUT, MACHPIN_PULL_NONE, 1); - pin_config(MICROPY_LTE_CTS_PIN, U2CTS_IN_IDX, -1, GPIO_MODE_INPUT, MACHPIN_PULL_NONE, 1); + pin_config(MICROPY_LTE_TX_PIN, -1, U2TXD_OUT_IDX, GPIO_MODE_OUTPUT, MACHPIN_PULL_NONE, 1); + pin_config(MICROPY_LTE_RX_PIN, U2RXD_IN_IDX, -1, GPIO_MODE_INPUT, MACHPIN_PULL_NONE, 1); + pin_config(MICROPY_LTE_RTS_PIN, -1, U2RTS_OUT_IDX, GPIO_MODE_OUTPUT, MACHPIN_PULL_NONE, 1); + pin_config(MICROPY_LTE_CTS_PIN, U2CTS_IN_IDX, -1, GPIO_MODE_INPUT, MACHPIN_PULL_NONE, 1); vTaskDelay(5 / portTICK_RATE_MS); @@ -138,10 +153,13 @@ void connect_lte_uart (void) { uart_set_rts(LTE_UART_ID, false); xTaskCreatePinnedToCore(TASK_UART_EVT, "LTE_UART_EVT", 2048 / sizeof(StackType_t), NULL, 12, &xLTEUartEvtTaskHndl, 1); + + MSG("done\n"); } void lteppp_init(void) { + MSG("\n"); if (!xLTETaskHndl) { lteppp_lte_state = E_LTE_INIT; @@ -164,12 +182,14 @@ void lteppp_init(void) { lteppp_log.log = malloc(LTE_LOG_BUFF_SIZE); #endif } + MSG("done\n"); } void lteppp_start (void) { uart_set_hw_flow_ctrl(LTE_UART_ID, UART_HW_FLOWCTRL_CTS_RTS, 64); vTaskDelay(5); } + #ifdef LTE_DEBUG_BUFF char* lteppp_get_log_buff(void) { @@ -189,6 +209,7 @@ char* lteppp_get_log_buff(void) return lteppp_log.log; } #endif + lte_modem_conn_state_t lteppp_modem_state(void) { lte_modem_conn_state_t state; @@ -219,6 +240,7 @@ void lteppp_set_legacy(lte_legacy_t legacy) { } void lteppp_connect (void) { + MSG("\n"); uart_flush(LTE_UART_ID); vTaskDelay(25); pppapi_set_default(lteppp_pcb); @@ -226,12 +248,15 @@ void lteppp_connect (void) { pppapi_set_auth(lteppp_pcb, PPPAUTHTYPE_PAP, "", ""); pppapi_connect(lteppp_pcb, 0); lteppp_connstatus = LTE_PPP_IDLE; + MSG("done\n"); } void lteppp_disconnect(void) { + MSG("\n"); pppapi_close(lteppp_pcb, 0); vTaskDelay(150); lteppp_connstatus = LTE_PPP_IDLE; + MSG("done\n"); } void lteppp_send_at_command (lte_task_cmd_data_t *cmd, lte_task_rsp_data_t *rsp) { @@ -371,37 +396,40 @@ lte_legacy_t lteppp_get_legacy(void) { } void lteppp_deinit (void) { - + MSG("\n"); uart_set_hw_flow_ctrl(LTE_UART_ID, UART_HW_FLOWCTRL_DISABLE, 0); uart_set_rts(LTE_UART_ID, false); xSemaphoreTake(xLTESem, portMAX_DELAY); lteppp_lte_state = E_LTE_INIT; lteppp_modem_conn_state = E_LTE_MODEM_DISCONNECTED; xSemaphoreGive(xLTESem); + MSG("done\n"); } uint32_t lteppp_ipv4(void) { return lte_ipv4addr; } -bool ltepp_is_ppp_conn_up(void) -{ +bool ltepp_is_ppp_conn_up(void) { + MSG("\n"); return ltepp_ppp_conn_up; } -void lteppp_suspend(void) -{ +void lteppp_suspend(void) { + MSG("\n"); lteppp_connstatus = LTE_PPP_SUSPENDED; } -void lteppp_resume(void) -{ +void lteppp_resume(void) { + MSG("\n"); lteppp_connstatus = LTE_PPP_RESUMED; } + /****************************************************************************** DEFINE PRIVATE FUNCTIONS ******************************************************************************/ static void TASK_LTE (void *pvParameters) { + MSG("\n"); bool sim_present; lte_task_cmd_data_t *lte_task_cmd = (lte_task_cmd_data_t *)lteppp_trx_buffer; lte_task_rsp_data_t *lte_task_rsp = (lte_task_rsp_data_t *)lteppp_trx_buffer; @@ -411,11 +439,12 @@ static void TASK_LTE (void *pvParameters) { connect_lte_uart(); modem_init: - + MSG("modem_init\n"); thread_notification = ulTaskNotifyTake(pdTRUE, portMAX_DELAY); if (thread_notification) { + MSG("notif\n"); xSemaphoreTake(xLTE_modem_Conn_Sem, portMAX_DELAY); xSemaphoreTake(xLTESem, portMAX_DELAY); lteppp_modem_conn_state = E_LTE_MODEM_CONNECTING; @@ -426,6 +455,7 @@ static void TASK_LTE (void *pvParameters) { // exit PPP session if applicable if(lteppp_send_at_cmd("+++", LTE_PPP_BACK_OFF_TIME_MS)) { + MSG("+++\n"); vTaskDelay(LTE_PPP_BACK_OFF_TIME_MS / portTICK_RATE_MS); while(!lteppp_send_at_cmd("AT", LTE_RX_TIMEOUT_MIN_MS)) { @@ -449,6 +479,7 @@ static void TASK_LTE (void *pvParameters) { vTaskDelay(LTE_PPP_BACK_OFF_TIME_MS / portTICK_RATE_MS); if (lteppp_send_at_cmd("+++", LTE_PPP_BACK_OFF_TIME_MS)) { + MSG("+++ after AT\n"); while(!lteppp_send_at_cmd("AT", LTE_RX_TIMEOUT_MIN_MS)) { if (at_trials >= LTE_AT_CMD_TRIALS) { @@ -518,6 +549,7 @@ static void TASK_LTE (void *pvParameters) { lteppp_modem_conn_state = E_LTE_MODEM_CONNECTED; xSemaphoreGive(xLTESem); xSemaphoreGive(xLTE_modem_Conn_Sem); + MSG("forever\n"); lte_state_t state; for (;;) { vTaskDelay(LTE_TASK_PERIOD_MS); @@ -531,6 +563,7 @@ static void TASK_LTE (void *pvParameters) { xSemaphoreGive(xLTESem); state = lteppp_get_state(); if (xQueueReceive(xCmdQueue, lteppp_trx_buffer, 0)) { + MSG("cmd\n"); bool expect_continuation = lte_task_cmd->expect_continuation; lteppp_send_at_cmd_exp(lte_task_cmd->data, lte_task_cmd->timeout, NULL, &(lte_task_rsp->data_remaining), lte_task_cmd->dataLen, lte_task_cmd->expect_continuation); if(!expect_continuation) @@ -548,15 +581,19 @@ static void TASK_LTE (void *pvParameters) { // check for IP connection if(lteppp_ipv4() > 0) { + if ( ! ltepp_ppp_conn_up) + MSG("set ltepp_ppp_conn_up\n"); ltepp_ppp_conn_up = true; } else { + MSG("else, ppp, no ipv4\n"); if(ltepp_ppp_conn_up == true) { ltepp_ppp_conn_up = false; lteppp_set_state(E_LTE_ATTACHED); } + MSG("else, ppp, no ipv4 done\n"); } // wait for characters received uart_get_buffered_data_len(LTE_UART_ID, &rx_len); @@ -571,6 +608,9 @@ static void TASK_LTE (void *pvParameters) { } else { + if ( ltepp_ppp_conn_up) + MSG("set ltepp_ppp_conn_up to false\n"); + ltepp_ppp_conn_up = false; } } @@ -579,8 +619,7 @@ static void TASK_LTE (void *pvParameters) { goto modem_init; } -static void TASK_UART_EVT (void *pvParameters) -{ +static void TASK_UART_EVT (void *pvParameters) { uart_event_t event; uint8_t buff[50] = {0}; for(;;) { @@ -609,9 +648,14 @@ static void TASK_UART_EVT (void *pvParameters) case UART_BREAK: if (E_LTE_PPP == lteppp_get_state()) { lte_uart_break_evt = true; + MSG("uart_break evt and ppp, so break=true\n"); + } else { + // this should not happen, because the sequans modem only issues a break event when in ppp + MSG("uart_break evt, but no ppp, so do nothing\n"); } break; default: + MSG("evt %u %u\n", event.type, event.size); break; } } @@ -739,8 +783,8 @@ static void lteppp_status_cb (ppp_pcb *pcb, int err_code, void *ctx) { switch (err_code) { case PPPERR_NONE: -// printf("status_cb: Connected\n"); - #if PPP_IPV4_SUPPORT + MSG("Connected\n"); +#if PPP_IPV4_SUPPORT lte_gw = pppif->gw.u_addr.ip4.addr; lte_netmask = pppif->netmask.u_addr.ip4.addr; lte_ipv4addr = pppif->ip_addr.u_addr.ip4.addr; @@ -749,59 +793,168 @@ static void lteppp_status_cb (ppp_pcb *pcb, int err_code, void *ctx) { ltepp_dns_info[0] = dns_getserver(0); ltepp_dns_info[1] = dns_getserver(1); } -// printf("ipaddr = %s\n", ipaddr_ntoa(&pppif->ip_addr)); -// printf("gateway = %s\n", ipaddr_ntoa(&pppif->gw)); -// printf("netmask = %s\n", ipaddr_ntoa(&pppif->netmask)); - #endif - #if PPP_IPV6_SUPPORT + MSG("ipaddr = %s\n", ipaddr_ntoa(&pppif->ip_addr)); + MSG("gateway = %s\n", ipaddr_ntoa(&pppif->gw)); + MSG("netmask = %s\n", ipaddr_ntoa(&pppif->netmask)); +#endif +#if PPP_IPV6_SUPPORT memcpy(lte_ipv6addr.addr, netif_ip6_addr(pppif, 0), sizeof(lte_ipv4addr)); -// printf("ip6addr = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); - #endif + MSG("ip6addr = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); +#endif break; case PPPERR_PARAM: -// printf("status_cb: Invalid parameter\n"); + MSG("Invalid parameter\n"); break; case PPPERR_OPEN: -// printf("status_cb: Unable to open PPP session\n"); + MSG("Unable to open PPP session\n"); break; case PPPERR_DEVICE: -// printf("status_cb: Invalid I/O device for PPP\n"); + MSG("Invalid I/O device for PPP\n"); break; case PPPERR_ALLOC: -// printf("status_cb: Unable to allocate resources\n"); + MSG("Unable to allocate resources\n"); break; case PPPERR_USER: -// printf("status_cb: User interrupt (disconnected)\n"); + MSG("User interrupt (disconnected)\n"); lte_ipv4addr = 0; memset(lte_ipv6addr.addr, 0, sizeof(lte_ipv4addr)); break; case PPPERR_CONNECT: -// printf("status_cb: Connection lost\n"); + MSG("\n\n\nConnection lost\n"); lte_ipv4addr = 0; memset(lte_ipv6addr.addr, 0, sizeof(lte_ipv4addr)); break; case PPPERR_AUTHFAIL: -// printf("status_cb: Failed authentication challenge\n"); + MSG("Failed authentication challenge\n"); break; case PPPERR_PROTOCOL: -// printf("status_cb: Failed to meet protocol\n"); + MSG("Failed to meet protocol\n"); break; case PPPERR_PEERDEAD: -// printf("status_cb: Connection timeout\n"); + MSG("Connection timeout\n"); break; case PPPERR_IDLETIMEOUT: -// printf("status_cb: Idle Timeout\n"); + MSG("Idle Timeout\n"); break; case PPPERR_CONNECTTIME: -// printf("status_cb: Max connect time reached\n"); + MSG("Max connect time reached\n"); break; case PPPERR_LOOPBACK: -// printf("status_cb: Loopback detected\n"); + MSG("Loopback detected\n"); break; default: -// printf("status_cb: Unknown error code %d\n", err_code); + MSG("Unknown error code %d\n", err_code); lte_ipv4addr = 0; memset(lte_ipv6addr.addr, 0, sizeof(lte_ipv4addr)); break; } } + +#ifdef LTEPPP_DEBUG +static void lteppp_print_states(){ + if (!xLTESem) + return; + static lte_modem_conn_state_t last_c = 0xff; + lte_modem_conn_state_t c = lteppp_modem_state(); + static lte_state_t last_s = 0xff; + lte_state_t s = lteppp_get_state(); + static bool last_u = false; + bool u = ltepp_ppp_conn_up; + static ltepppconnstatus_t last_C = 0xff; + ltepppconnstatus_t C = lteppp_connstatus; + static bool last_b = false; + bool b = lte_uart_break_evt; + static size_t last_cmd = 0; + size_t cmd = 0; + if (xCmdQueue) + cmd = uxQueueMessagesWaiting(xCmdQueue); + static size_t last_rx = 0; + size_t rx = 0; + if (xRxQueue) + rx = uxQueueMessagesWaiting(xRxQueue); + static size_t last_uart = 0; + size_t uart = 0; + if (uart0_queue) + uart = uxQueueMessagesWaiting(uart0_queue); + + + if ( last_c != c + || last_s != s + || last_u != u + || last_C != C + || last_b != b + || last_cmd != cmd + || last_rx != rx + || last_uart != uart + ) { + + + printf("c=%u", c); // lteppp_modem_conn_state + switch(c){ + case E_LTE_MODEM_CONNECTED: + printf("=CTED "); + break; + case E_LTE_MODEM_CONNECTING: + printf("=CING "); + break; + case E_LTE_MODEM_DISCONNECTED: + printf("=DISC "); + break; + } + + printf("s=%u", s); // lteppp_lte_state + switch (s){ + case E_LTE_INIT: + printf("=INIT "); + break; + case E_LTE_IDLE: + printf("=IDLE "); + break; + case E_LTE_ATTACHING: + printf("=AING "); + break; + case E_LTE_ATTACHED: + printf("=ATTA "); + break; + case E_LTE_PPP: + printf("=PPP "); + break; + case E_LTE_SUSPENDED: + printf("=SUSP "); + } + + printf("u=%u ", u); + + printf("C=%u", C); + switch(C){ + case LTE_PPP_IDLE: + printf("=IDLE "); + break; + case LTE_PPP_RESUMED: + printf("=RESU "); + break; + case LTE_PPP_SUSPENDED: + printf("=SUSP "); + break; + } + printf("b=%u ", b); + + if (xCmdQueue) + printf("cmd[%u] ", uxQueueMessagesWaiting(xCmdQueue)); + if (xRxQueue) + printf("rx[%u] ", uxQueueMessagesWaiting(xRxQueue)); + if (uart0_queue) + printf("u0[%u] ", uxQueueMessagesWaiting(uart0_queue)); + printf("\n"); + + last_c = c; + last_s = s; + last_u = u; + last_C = C; + last_b = b; + last_cmd = cmd; + last_rx = rx; + last_uart = uart; + } +} +#endif diff --git a/esp32/lte/lteppp.h b/esp32/lte/lteppp.h index c8e608dee3..8ca52c5d7b 100644 --- a/esp32/lte/lteppp.h +++ b/esp32/lte/lteppp.h @@ -63,6 +63,7 @@ typedef enum { E_LTE_MODEM_CONNECTING, E_LTE_MODEM_DISCONNECTED } lte_modem_conn_state_t; + #ifdef LTE_DEBUG_BUFF typedef struct { char* log; @@ -70,12 +71,14 @@ typedef struct { bool truncated; } lte_log_t; #endif + typedef struct { uint32_t timeout; char data[LTE_AT_CMD_DATA_SIZE_MAX]; size_t dataLen; bool expect_continuation; } lte_task_cmd_data_t; + #pragma pack(1) typedef struct { char data[LTE_UART_BUFFER_SIZE]; @@ -127,6 +130,7 @@ extern void lteppp_suspend(void); extern void lteppp_resume(void); extern void lteppp_set_default_inf(void); + #ifdef LTE_DEBUG_BUFF extern char* lteppp_get_log_buff(void); #endif diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index 7552047925..1f18c0e129 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -151,6 +151,10 @@ STATIC mp_obj_t lte_deinit(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t STATIC mp_obj_t lte_disconnect(mp_obj_t self_in); static void lte_set_default_inf(void); static void lte_callback_handler(void* arg); + +//#define MSG(fmt, ...) printf("[%u] modlte: " fmt, mp_hal_ticks_ms(), ##__VA_ARGS__) +#define MSG(fmt, ...) (void)0 + /****************************************************************************** DEFINE PUBLIC FUNCTIONS ******************************************************************************/ @@ -188,9 +192,12 @@ static void lte_callback_handler(void* arg) lte_obj_t *self = arg; if (self->handler && self->handler != mp_const_none) { - + MSG("call callback(handler=%p, arg=%p)\n", self->handler_arg, self->handler); mp_call_function_1(self->handler, self->handler_arg); + }else{ + MSG("no callback\n"); } + } static bool lte_push_at_command_ext_cont (char *cmd_str, uint32_t timeout, const char *expected_rsp, size_t len, bool continuation) @@ -1064,15 +1071,15 @@ STATIC mp_obj_t lte_suspend(mp_obj_t self_in) { lte_check_init(); if (lteppp_get_state() == E_LTE_PPP) { lteppp_suspend(); - //printf("Pausing ppp...\n"); + MSG("Pausing ppp...\n"); lte_pause_ppp(); - //printf("Pausing ppp done...\n"); + MSG("Pausing ppp done...\n"); lteppp_set_state(E_LTE_SUSPENDED); while (true) { mp_hal_delay_ms(LTE_RX_TIMEOUT_MIN_MS); - //printf("Sending AT...\n"); + MSG("Sending AT...\n"); if (lte_push_at_command("AT", LTE_RX_TIMEOUT_MAX_MS)) { - //printf("OK\n"); + MSG("OK\n"); break; } } @@ -1177,11 +1184,13 @@ STATIC mp_obj_t lte_resume(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } if (lte_push_at_command_ext("ATO", LTE_RX_TIMEOUT_MAX_MS, LTE_CONNECT_RSP, strlen("ATO") )) { + MSG("resume ATO OK\n"); lteppp_connect(); lteppp_resume(); lteppp_set_state(E_LTE_PPP); vTaskDelay(1500); } else { + MSG("resume ATO failed -> reconnect\n"); lteppp_disconnect(); lteppp_set_state(E_LTE_ATTACHED); lte_check_attached(lte_legacyattach_flag); @@ -1190,6 +1199,7 @@ STATIC mp_obj_t lte_resume(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } else if (lteppp_get_state() == E_LTE_PPP) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "modem already connected")); } else { + MSG("resume do nothing\n"); //Do Nothing } return mp_const_none; From 9cc50b2dc9279af9f8269385efeb9f9136707e37 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Tue, 10 Nov 2020 19:43:13 +0100 Subject: [PATCH 18/25] lte: callback LTE_EVENT_BREAK - disable the existing LTE_EVENT_COVERAGE_LOST - disable sending +++ at a break --- esp32/lte/lteppp.c | 50 ++++++++++++++++++++++++--------------------- esp32/mods/modlte.c | 31 ++++++++++++++++------------ esp32/mods/modlte.h | 25 ++++++++++++++--------- 3 files changed, 60 insertions(+), 46 deletions(-) diff --git a/esp32/lte/lteppp.c b/esp32/lte/lteppp.c index 6b2fc1fe50..220caa1ac6 100644 --- a/esp32/lte/lteppp.c +++ b/esp32/lte/lteppp.c @@ -29,6 +29,7 @@ #include "esp32_mphal.h" #include "lwip/dns.h" #include "modlte.h" +#include "str_utils.h" /****************************************************************************** DEFINE CONSTANTS @@ -569,11 +570,11 @@ static void TASK_LTE (void *pvParameters) { if(!expect_continuation) xQueueSend(xRxQueue, (void *)lte_task_rsp, (TickType_t)portMAX_DELAY); } - else if(state == E_LTE_PPP && lte_uart_break_evt) - { - lteppp_send_at_cmd("+++", LTE_PPP_BACK_OFF_TIME_MS); - lteppp_suspend(); - } + //else if(state == E_LTE_PPP && lte_uart_break_evt) + //{ + // lteppp_send_at_cmd("+++", LTE_PPP_BACK_OFF_TIME_MS); + // lteppp_suspend(); + //} else { if (state == E_LTE_PPP) { @@ -621,34 +622,37 @@ static void TASK_LTE (void *pvParameters) { static void TASK_UART_EVT (void *pvParameters) { uart_event_t event; - uint8_t buff[50] = {0}; + //uint8_t buff[50] = {0}; for(;;) { //Waiting for UART event. if(xQueueReceive(uart0_queue, (void * )&event, (portTickType)portMAX_DELAY)) { - switch(event.type) - { + switch(event.type) { case UART_DATA: - if (lte_uart_break_evt) { - - uint32_t rx_len = uart_read_bytes(LTE_UART_ID, buff, LTE_UART_BUFFER_SIZE, - LTE_TRX_WAIT_MS(LTE_UART_BUFFER_SIZE) / portTICK_RATE_MS); - - if ((rx_len) && (strstr((const char *)buff, "OK") != NULL)) - { - if(strstr((const char *)buff, "+CEREG: 4") != NULL) - { - modlte_urc_events(LTE_EVENT_COVERAGE_LOST); - } - - lte_uart_break_evt = false; - } - } + // if (lte_uart_break_evt) { + + // uint32_t rx_len = uart_read_bytes(LTE_UART_ID, buff, LTE_UART_BUFFER_SIZE, + // LTE_TRX_WAIT_MS(LTE_UART_BUFFER_SIZE) / portTICK_RATE_MS); + + // MSG("uart_data evt + break (%u)\n", rx_len); + // hexdump(buff, rx_len); + // if ((rx_len) && (strstr((const char *)buff, "OK") != NULL)) { + // MSG("OK\n"); + // if(strstr((const char *)buff, "+CEREG: 4") != NULL) { + // MSG("CEREG 4, trigger callback\n"); + // modlte_urc_events(LTE_EVENT_COVERAGE_LOST); + // } + // lte_uart_break_evt = false; + // MSG("break=false\n"); + // } + // } break; case UART_BREAK: + // MSG("LTE_UART: uart_break evt, ppp=%u (4=ppp)\n", lteppp_get_state()); if (E_LTE_PPP == lteppp_get_state()) { lte_uart_break_evt = true; MSG("uart_break evt and ppp, so break=true\n"); + modlte_urc_events(LTE_EVENT_BREAK); } else { // this should not happen, because the sequans modem only issues a break event when in ppp MSG("uart_break evt, but no ppp, so do nothing\n"); diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index 1f18c0e129..d1e825b426 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -105,7 +105,7 @@ /****************************************************************************** DECLARE PRIVATE DATA ******************************************************************************/ -static lte_obj_t lte_obj = {.init = false, .trigger = LTE_TRIGGER_NONE, .events = 0, .handler = NULL, .handler_arg = NULL}; +static lte_obj_t lte_obj = {.init = false, .trigger = LTE_EVENT_NONE, .events = 0, .handler = NULL, .handler_arg = NULL}; static lte_task_rsp_data_t modlte_rsp; uart_dev_t* uart_driver_0 = &UART0; uart_dev_t* uart_driver_lte = &UART2; @@ -171,18 +171,22 @@ void modlte_start_modem(void) void modlte_urc_events(lte_events_t events) { - switch(events) + // set the events to report to the user, the clearing is done upon reading via lte_events() + if ( (events & LTE_EVENT_COVERAGE_LOST) + && (lte_obj.trigger & LTE_EVENT_COVERAGE_LOST) ) { - case LTE_EVENT_COVERAGE_LOST: - if ((lte_obj.trigger & LTE_TRIGGER_SIG_LOST)) { - lte_obj.events |= (uint32_t)LTE_TRIGGER_SIG_LOST; - } - mp_irq_queue_interrupt(lte_callback_handler, <e_obj); - break; - default: - break; + lte_obj.events |= (uint32_t)LTE_EVENT_COVERAGE_LOST; } + if ( (events & LTE_EVENT_BREAK) + && (lte_obj.trigger & LTE_EVENT_BREAK) ) + { + lte_obj.events |= (uint32_t)LTE_EVENT_BREAK; + } + + //MSG("urc(%u) l.trig=%u l.eve=%d\n", events, lte_obj.trigger, lte_obj.events); + mp_irq_queue_interrupt(lte_callback_handler, <e_obj); } + //***************************************************************************** // DEFINE STATIC FUNCTIONS //***************************************************************************** @@ -192,10 +196,10 @@ static void lte_callback_handler(void* arg) lte_obj_t *self = arg; if (self->handler && self->handler != mp_const_none) { - MSG("call callback(handler=%p, arg=%p)\n", self->handler_arg, self->handler); + //MSG("call callback(handler=%p, arg=%p)\n", self->handler_arg, self->handler); mp_call_function_1(self->handler, self->handler_arg); }else{ - MSG("no callback\n"); + //MSG("no callback\n"); } } @@ -1598,7 +1602,8 @@ STATIC const mp_map_elem_t lte_locals_dict_table[] = { // class constants { MP_OBJ_NEW_QSTR(MP_QSTR_IP), MP_OBJ_NEW_QSTR(MP_QSTR_IP) }, { MP_OBJ_NEW_QSTR(MP_QSTR_IPV4V6), MP_OBJ_NEW_QSTR(MP_QSTR_IPV4V6) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_EVENT_COVERAGE_LOSS), MP_OBJ_NEW_SMALL_INT(LTE_TRIGGER_SIG_LOST) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_EVENT_COVERAGE_LOSS), MP_OBJ_NEW_SMALL_INT(LTE_EVENT_COVERAGE_LOST) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_EVENT_BREAK), MP_OBJ_NEW_SMALL_INT(LTE_EVENT_BREAK) }, // PSM Power Saving Mode { MP_OBJ_NEW_QSTR(MP_QSTR_PSM_PERIOD_2S), MP_OBJ_NEW_SMALL_INT(PSM_PERIOD_2S) }, { MP_OBJ_NEW_QSTR(MP_QSTR_PSM_PERIOD_30S), MP_OBJ_NEW_SMALL_INT(PSM_PERIOD_30S) }, diff --git a/esp32/mods/modlte.h b/esp32/mods/modlte.h index f38439babe..10880877d4 100644 --- a/esp32/mods/modlte.h +++ b/esp32/mods/modlte.h @@ -16,8 +16,19 @@ #define LTE_MAX_RX_SIZE 1024 -#define LTE_TRIGGER_NONE 0x00000000 -#define LTE_TRIGGER_SIG_LOST 0x00000001 +// // trigger and event definitions used in Micropython API +// #define LTE_EVENT_NONE 0x00000000 +// #define LTE_EVENT_COVERAGE_LOST 0x00000001 +// #define LTE_EVENT_BREAK 0x00000002 + + +typedef enum +{ + LTE_EVENT_NONE = 0x00000000, + LTE_EVENT_COVERAGE_LOST = 0x00000001, + LTE_EVENT_BREAK = 0x00000002, +}lte_events_t; + typedef struct _lte_obj_t { mp_obj_base_t base; @@ -26,18 +37,12 @@ typedef struct _lte_obj_t { uint8_t cid; bool init; bool carrier; - uint32_t trigger; - int32_t events; + lte_events_t trigger; + lte_events_t events; mp_obj_t handler; mp_obj_t handler_arg; } lte_obj_t; -typedef enum -{ - LTE_EVENT_COVERAGE_LOST = 0, - LTE_EVENT_MAX -}lte_events_t; - /****************************************************************************** DECLARE PUBLIC FUNCTIONS From a641ac5e7f51cfd80741d7343474e184692c96c6 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Tue, 10 Nov 2020 19:46:41 +0100 Subject: [PATCH 19/25] modlte: improve exception texts --- esp32/mods/modlte.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index d1e825b426..f825b04432 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -243,7 +243,7 @@ static void lte_pause_ppp(void) { if (!lte_push_at_command("AT", LTE_RX_TIMEOUT_MIN_MS)) { mp_hal_delay_ms(LTE_PPP_BACK_OFF_TIME_MS); if (!lte_push_at_command("AT", LTE_RX_TIMEOUT_MIN_MS)) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Pause PPP failed")); } } } @@ -1174,13 +1174,13 @@ STATIC mp_obj_t lte_resume(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if (lteppp_get_state() == E_LTE_PPP) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible)); + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Modem is already connected")); } lte_check_attached(lte_legacyattach_flag); if (lteppp_get_state() == E_LTE_SUSPENDED || lteppp_get_state() == E_LTE_ATTACHED) { if (lteppp_get_state() == E_LTE_ATTACHED && lteppp_get_legacy() == E_LTE_LEGACY) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible)); + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Operation failed (attached and legacy)")); } // char at_cmd[LTE_AT_CMD_SIZE_MAX - 4]; if (args[0].u_obj != mp_const_none) { From 8e631efefb6b3d7be6731f826c06dcaf85231785 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Wed, 11 Nov 2020 16:27:48 +0100 Subject: [PATCH 20/25] lte: reduce AT+CEREG from 2 to 1 this way we only get unsolicited result codes for *state* changes (registered, registration lost), instead of for every *cell* change. This means fewer UART break signals, which in turn means fewer callbacks to deal with. --- esp32/lte/lteppp.c | 3 ++- esp32/mods/modlte.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/esp32/lte/lteppp.c b/esp32/lte/lteppp.c index 220caa1ac6..ad7f70c28b 100644 --- a/esp32/lte/lteppp.c +++ b/esp32/lte/lteppp.c @@ -520,7 +520,8 @@ static void TASK_LTE (void *pvParameters) { lteppp_send_at_cmd("ATE0", LTE_RX_TIMEOUT_MIN_MS); // disable PSM if enabled by default lteppp_send_at_cmd("AT+CPSMS=0", LTE_RX_TIMEOUT_MIN_MS); - + // set registration URC to 1, ie for status changes + lteppp_send_at_cmd("AT+CEREG=1", LTE_RX_TIMEOUT_MIN_MS); // at least enable access to the SIM lteppp_send_at_cmd("AT+CFUN?", LTE_RX_TIMEOUT_MAX_MS); char *pos = strstr(lteppp_trx_buffer, "+CFUN: "); diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index f825b04432..1372c679c8 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -280,15 +280,15 @@ static bool lte_check_attached(bool legacy) { mp_hal_delay_ms(LTE_RX_TIMEOUT_MIN_MS); lte_push_at_command("AT+CEREG?", LTE_RX_TIMEOUT_MIN_MS); } - if (((pos = strstr(modlte_rsp.data, "+CEREG: 2,1,")) || (pos = strstr(modlte_rsp.data, "+CEREG: 2,5,"))) + if (((pos = strstr(modlte_rsp.data, "+CEREG: 1,1")) || (pos = strstr(modlte_rsp.data, "+CEREG: 1,5"))) && (strlen(pos) >= 31) && (pos[30] == '7' || pos[30] == '9')) { attached = true; } } else { - if ((pos = strstr(modlte_rsp.data, "+CEREG: 2,1,")) || (pos = strstr(modlte_rsp.data, "+CEREG: 2,5,"))) { + if ((pos = strstr(modlte_rsp.data, "+CEREG: 1,1")) || (pos = strstr(modlte_rsp.data, "+CEREG: 1,5"))) { attached = true; } else { - if((pos = strstr(modlte_rsp.data, "+CEREG: 2,4"))) + if((pos = strstr(modlte_rsp.data, "+CEREG: 1,4"))) { lte_ue_is_out_of_coverage = true; } From 6b4f392084ea3f4d1845e33c81acd8548c468952 Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Fri, 6 Nov 2020 23:07:05 +0100 Subject: [PATCH 21/25] BLE update --- esp32/mods/modbt.c | 60 ++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index e38bd2ef84..99a79a6570 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -113,6 +113,7 @@ typedef struct { int32_t conn_id; uint16_t mtu; esp_gatt_if_t gatt_if; + esp_ble_addr_type_t addr_type; } bt_connection_obj_t; typedef struct { @@ -284,7 +285,7 @@ STATIC void gattc_char_callback_handler(void *arg); STATIC void gatts_char_callback_handler(void *arg); static mp_obj_t modbt_start_scan(mp_obj_t timeout); static mp_obj_t modbt_conn_disconnect(mp_obj_t self_in); -static mp_obj_t modbt_connect(mp_obj_t addr); +static mp_obj_t modbt_connect(mp_obj_t addr, esp_ble_addr_type_t addr_type); /****************************************************************************** DEFINE PUBLIC FUNCTIONS @@ -421,7 +422,7 @@ void bt_resume(bool reconnect) for (mp_uint_t i = 0; i < btc_conn_list_tmp.len; i++) { bt_connection_obj_t *connection_obj = ((bt_connection_obj_t *)(btc_conn_list_tmp.items[i])); // Initiates re-connection - bt_connection_obj_t *new_connection_obj = modbt_connect(mp_obj_new_bytes((const byte *)connection_obj->srv_bda, 6)); + bt_connection_obj_t *new_connection_obj = modbt_connect(mp_obj_new_bytes((const byte *)connection_obj->srv_bda, 6), connection_obj->addr_type); // If new connection object has been created then overwrite the original one so from the MicroPython code the same reference can be used if(new_connection_obj != mp_const_none) { memcpy(connection_obj, new_connection_obj, sizeof(bt_connection_obj_t)); @@ -477,19 +478,19 @@ static void create_hash(uint32_t pin, uint8_t *h_value) { bt_hash_obj_t pin_hash; mbedtls_sha1_context sha1_context; - + mbedtls_sha1_init(&sha1_context); mbedtls_sha1_starts_ret(&sha1_context); - + pin_hash.pin = pin; mbedtls_sha1_update_ret(&sha1_context, pin_hash.value, 4); - + mbedtls_sha1_finish_ret(&sha1_context, h_value); mbedtls_sha1_free(&sha1_context); } -static bool pin_changed(uint32_t new_pin) -{ +static bool pin_changed(uint32_t new_pin) +{ bool ret = false; uint32_t h_size = MOD_BT_HASH_SIZE; uint8_t h_stored[MOD_BT_HASH_SIZE] = {0}; @@ -501,9 +502,9 @@ static bool pin_changed(uint32_t new_pin) mp_printf(&mp_plat_print, "Error opening secure BLE NVS namespace!\n"); } nvs_get_blob(modbt_nvs_handle, key, h_stored, &h_size); - + create_hash(new_pin, h_created); - + if (memcmp(h_stored, h_created, MOD_BT_HASH_SIZE) != 0) { esp_err = nvs_set_blob(modbt_nvs_handle, key, h_created, h_size); if (esp_err == ESP_OK) { @@ -511,7 +512,7 @@ static bool pin_changed(uint32_t new_pin) ret = true; } } - + nvs_close(modbt_nvs_handle); return ret; @@ -1415,7 +1416,7 @@ STATIC mp_obj_t bt_events(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(bt_events_obj, bt_events); -static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ +static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout, esp_ble_addr_type_t addr_type){ bt_event_result_t bt_event; EventBits_t uxBits; @@ -1443,7 +1444,7 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ bt_obj.busy = true; /* Initiate a background connection, esp_ble_gattc_open returns immediately */ - if (ESP_OK != esp_ble_gattc_open(bt_obj.gattc_if, bufinfo.buf, BLE_ADDR_TYPE_PUBLIC, true)) { + if (ESP_OK != esp_ble_gattc_open(bt_obj.gattc_if, bufinfo.buf, addr_type, true)) { // Only drop exception if not called from bt_resume() API, otherwise return with mp_const_none on error if(mod_bt_allow_resume_deinit == false) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); @@ -1473,6 +1474,7 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ conn->base.type = (mp_obj_t)&mod_bt_connection_type; conn->conn_id = bt_event.connection.conn_id; conn->gatt_if = bt_event.connection.gatt_if; + conn->addr_type = addr_type; MP_THREAD_GIL_EXIT(); uxBits = xEventGroupWaitBits(bt_event_group, MOD_BT_GATTC_MTU_EVT, true, true, 1000/portTICK_PERIOD_MS); @@ -1510,6 +1512,7 @@ STATIC mp_obj_t bt_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t STATIC const mp_arg_t allowed_args[] = { { MP_QSTR_addr, MP_ARG_REQUIRED | MP_ARG_OBJ, }, { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_addr_type, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, }; // parse arguments @@ -1518,7 +1521,7 @@ STATIC mp_obj_t bt_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t mp_obj_t addr = args[0].u_obj; - /* Timeout parameter is in miliseconds */ + /* Timeout parameter is in milliseconds */ TickType_t timeout; if(args[1].u_obj == MP_OBJ_NULL){ timeout = portMAX_DELAY; @@ -1534,13 +1537,30 @@ STATIC mp_obj_t bt_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } } - return bt_connect_helper(addr, timeout); + /* addr_type parameter */ + uint32_t addr_type; + if(args[2].u_obj == MP_OBJ_NULL){ + addr_type = BLE_ADDR_TYPE_PUBLIC; + } + else + { + if(MP_OBJ_IS_SMALL_INT(args[2].u_obj) == true) { + addr_type = mp_obj_get_int(args[2].u_obj); + } + else + { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "If addr_type is specified it must be a valid integer number")); + } + } + + + return bt_connect_helper(addr, timeout, addr_type); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bt_connect_obj, 1, bt_connect); -static mp_obj_t modbt_connect(mp_obj_t addr) +static mp_obj_t modbt_connect(mp_obj_t addr, esp_ble_addr_type_t addr_type) { - return bt_connect_helper(addr, portMAX_DELAY); + return bt_connect_helper(addr, portMAX_DELAY, addr_type); } @@ -1553,7 +1573,7 @@ STATIC mp_obj_t bt_set_advertisement_params (mp_uint_t n_args, const mp_obj_t *p { MP_QSTR_channel_map, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_adv_filter_policy, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, }; - + // parse args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(args), allowed_args, args); @@ -1706,14 +1726,14 @@ STATIC mp_obj_t bt_set_advertisement_raw(mp_obj_t self_in, mp_obj_t raw_data) { memcpy(data, (uint8_t *)bufinfo.buf, sizeof(data)); data_len = sizeof(data); } - + esp_ble_gap_config_adv_data_raw(data, data_len); - + // wait for the advertisement data to be configured bt_gatts_event_result_t gatts_event; xQueueReceive(xGattsQueue, &gatts_event, portMAX_DELAY); } - + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(bt_set_advertisement_raw_obj, bt_set_advertisement_raw); From 4254ab23a9b54c71ccf19b5c3bd6a67e28f8a53a Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Thu, 12 Nov 2020 13:13:58 +0100 Subject: [PATCH 22/25] update idf 3394ee573 --- esp32/Makefile | 2 +- esp32/bootloader/lib/libbootloader_support.a | Bin 324790 -> 324790 bytes esp32/bootloader/lib/libefuse.a | Bin 115932 -> 115932 bytes esp32/bootloader/lib/liblog.a | Bin 18684 -> 18684 bytes esp32/bootloader/lib/libmicro-ecc.a | Bin 158340 -> 158340 bytes esp32/bootloader/lib/libsoc.a | Bin 213400 -> 213400 bytes esp32/bootloader/lib/libspi_flash.a | Bin 43628 -> 43628 bytes esp32/esp32.project.ld | 42 +++++++++---------- esp32/lib/libapp_update.a | Bin 69512 -> 69512 bytes esp32/lib/libbootloader_support.a | Bin 243940 -> 243940 bytes esp32/lib/libbt.a | Bin 7471572 -> 7471572 bytes esp32/lib/libcoap.a | Bin 418802 -> 418818 bytes esp32/lib/libcxx.a | Bin 65212 -> 65212 bytes esp32/lib/libdriver.a | Bin 1909154 -> 1909154 bytes esp32/lib/libefuse.a | Bin 115388 -> 115388 bytes esp32/lib/libesp32.a | Bin 1024568 -> 1024568 bytes esp32/lib/libesp_adc_cal.a | Bin 33184 -> 33184 bytes esp32/lib/libesp_ringbuf.a | Bin 104344 -> 104344 bytes esp32/lib/libespcoredump.a | Bin 47962 -> 47962 bytes esp32/lib/libethernet.a | Bin 155698 -> 155698 bytes esp32/lib/libexpat.a | Bin 992478 -> 992478 bytes esp32/lib/libfreertos.a | Bin 515386 -> 515386 bytes esp32/lib/libheap.a | Bin 158484 -> 158484 bytes esp32/lib/libjsmn.a | Bin 16702 -> 16702 bytes esp32/lib/libjson.a | Bin 266198 -> 266198 bytes esp32/lib/liblog.a | Bin 37660 -> 37660 bytes esp32/lib/liblwip.a | Bin 3068308 -> 3068404 bytes esp32/lib/libmbedtls.a | Bin 3183298 -> 3183298 bytes esp32/lib/libmdns.a | Bin 508432 -> 508432 bytes esp32/lib/libmicro-ecc.a | Bin 158564 -> 158564 bytes esp32/lib/libnewlib.a | Bin 130752 -> 130752 bytes esp32/lib/libnghttp.a | Bin 1306882 -> 1306882 bytes esp32/lib/libnvs_flash.a | Bin 719066 -> 719066 bytes esp32/lib/libopenssl.a | Bin 263156 -> 263156 bytes esp32/lib/libpthread.a | Bin 110114 -> 110114 bytes esp32/lib/libsdmmc.a | Bin 190996 -> 190996 bytes esp32/lib/libsmartconfig_ack.a | Bin 19190 -> 19190 bytes esp32/lib/libsoc.a | Bin 216626 -> 216626 bytes esp32/lib/libspi_flash.a | Bin 194026 -> 194026 bytes esp32/lib/libtcpip_adapter.a | Bin 123260 -> 123260 bytes esp32/lib/libvfs.a | Bin 190764 -> 190764 bytes esp32/lib/libwpa_supplicant.a | Bin 2592646 -> 2592646 bytes esp32/lib/libxtensa-debug-module.a | Bin 9746 -> 9746 bytes 43 files changed, 22 insertions(+), 22 deletions(-) diff --git a/esp32/Makefile b/esp32/Makefile index 758ca21036..10ca433cca 100644 --- a/esp32/Makefile +++ b/esp32/Makefile @@ -14,7 +14,7 @@ ifeq ($(wildcard boards/$(BOARD)/.),) $(error Invalid BOARD specified) endif -IDF_HASH=c61fe64 +IDF_HASH=3394ee5 TARGET ?= boot_app diff --git a/esp32/bootloader/lib/libbootloader_support.a b/esp32/bootloader/lib/libbootloader_support.a index 53016037610853131a32b73b8da38c84161e5967..7f15307e23ba07a1d2090ea9924804d719e15558 100644 GIT binary patch delta 308 zcmdn?Qh3`-;R%wQW(KB)7DkrlmK&8^IpI8u%>|tLu?X(u0#32b`_gomp$cv1;$^&P zi6+M6&M2vkA|}4wx`^>e4vLuAcDehEy=`b>r&5_B?a{=XmNKoBK@;OT#3ZYQ5Zi9> yhACbd!3Q~a`#OH+ulvx%4xM98wMB?+H{fBB4uJD5!TPddSRPJA7yHEG!vp|l{!{z_ delta 308 zcmdn?Qh3`-;R%wQrk2L01|}9pW*e1UIpI9h%>|tLu?X(u0#32b`_gomp$cv1;$^&P zi6+M6&M2u37c&ED72j@M#CRkJMNDkF+oDkz5wtE7r6ic delta 83 zcmcc9$$qDkeS##Xsim>0fr*8Y#YUxaP6TiBBF^I>NZg{h?j$5G+d<}S2<~>Fa>i4> E0P$=W!TF?j$0(=iJT delta 35 jcmew}k@3$&#tD*~rk2L01|}9pW)qdpBRCs>F?j$0()tSn diff --git a/esp32/bootloader/lib/libmicro-ecc.a b/esp32/bootloader/lib/libmicro-ecc.a index d4380c398d188eb5ff3d5f038401ad0c8f0c537f..0effdb6e3e2eac120eeb6e6a9a8ffc190ce9c597 100644 GIT binary patch delta 45 tcmZp<%Gq+2bAlwNnSrUHg^{JX0fr*8Y`9`JFj0j%yH^%mFjEvjAF*5aK002ZW4s-wj diff --git a/esp32/bootloader/lib/libsoc.a b/esp32/bootloader/lib/libsoc.a index 8fcf86f031c94002e6a4071b2d2b255384fbcd4e..4de815ae6ed10708edb0f047d3675971c9d8d3d1 100644 GIT binary patch delta 323 zcmbQy%sZo*cY-9RnSrUHg^{I&!A7NOb{Nmxa=P72M)A#i*-cnb#l$uX@GwfFiy5f< zilB?lu|5ko9b%r?=8jNP9&~kg5*z){#cDQ)qNx+#ym8M8BXo5Y?;}%D#l*LN3}N)K zL=_a<9@EEolM5lZ9q2o469gaZ+wGla84Vmz1;w`C;APtS4JK$|08zP?h55A&05o-4 AF8}}l delta 323 zcmbQy%sZo*cY-9Rsim>0fr*8Y#YUxSb~w*`y4_4h@y&bLO;}LH#5N1?FiN9~8L0b; zpo`71K8r9NY@XQWj!;t`bai(U8~xD5YBq?XsT1G4anA}PbafT)BU4eu#J7J8Vf3*? z6%^YZ)5my|3n922=sRr_1Rw0%?VV>C4IJQt79c^f?KgOtwthnu6yLshoRtA<<#^wxA;Fn*f uU}&UZWME_f7AZ50fr*8Y=|-h!CIoMD8x#8nB<{3N!i>fSR))q_CZ-Hf;8mKZ uU~HgZWME_f7AZ5tMqgEQ!5gwn tZ

&+kp<;jBp&(Aq$={`RXDRL0rcp!kp`mE;u8Z`C$--;5KF-CIIYTU_bx> delta 303 zcmaFzk?+Yzz6p|?rk2L01|}9pW*e2ZbHI6~)92k{6x;lRW1%^c*f|F#iOstl?k`0W z1FPHdY^Nof*!Bquj61c^1v9)E8QakXJ1#NuB3Zp1XykfXbVWHo7=2aI1#ieQy;VX8 rZU;JWGrHrpFL=h}s|#0T2KL!@9uekTe{{ha$;=OfFa)s1;UJn0t@z;T zOtGxuUfGH(Bk8PLUv!#&!j4_hbyn(Qbc!x@b{*-4Ra#V3tkiXP_S_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Y1ONa4 delta 1325 zcmbu9Ur19?9LLYOcgI~v%AC5n38jtNpIfHZrpd@fkc8C?9sQ*QD>)FY zj9+z8A$uzNVO$ z&}@okEBvD`?p`6AQ8e8=dzXltkj{6R{I6J@xt?GkEZ9X@_`u(_TtQe?!HBh3u{m?{ z)oQ^brH|GNVMB@N@s`1o?4bRsYM9BMtFXqUAV)GO{{Glbn-c8QH}BD$XL7e4LYQhdE2g$2jLBH*+pP zKFzrh`6B0HJA|Wo&@^L) zt8Syvlc%({Fth0(#RI`Ftc}S$#XnBX@Y-#pVMyTAIrxF`9+b)sHjn@QB!njHv=Z9! zPJ9HAo$Kz4SzVM18a7yl&V_o-Qu=*5iz=$GN;FTMN;JOE($$u@9Hx@?(0E}gVTm{Q z(o@EbjfnyJz@nKwtuY#JjR|9sv{$n_S*{Qx&owVTJ}b_LGICtl=&y|2U&k(#YI$l^ clR-9Olh&R;2pKH#t}y#_bG_BE%$`L40MsHXkpKVy diff --git a/esp32/lib/libcxx.a b/esp32/lib/libcxx.a index 387b1b4a5c3ad8629845eb2c4885f9cf6f55f84b..d29dc54e0b2bef72a726e99621b88266b993d975 100644 GIT binary patch delta 52 qcmdnZgh%}%V^>)>4T&1IY2yaAxG4*UQB diff --git a/esp32/lib/libdriver.a b/esp32/lib/libdriver.a index 44dfd403ec9d201c5d7ed2f42ed6cc0d6b7851a0..d4608c3a3949c4802f9e3cc137d1201b4926fd0d 100644 GIT binary patch delta 566 zcmZ2ce>k(-js7h;L>#FnEU~c0q?vyggWsaeJ^F zQ-?f~gg_6sMEf6GrtN=hna{66l@Q{W-SR9z%({KIJX=T_n&fuPrihq!p$;DScmCvb3=HzWA% zK%=({^zf{nj}Qa!y5%a`baK@I{( z;}L?}fg!qG0>N*8utQ+`gB^mOcOk?;9+hbSQY^InOR=!cemUFL7-DeTg&SJ(|S!>O)*SZV18c6F9ibn-TnW zpkuZR^zf{nj}Qa`;xf3QPf`-2^VpLZd|KtUtX{-s!G`ENg+ zJ}I)j_@w9@MI;HJLh0(A2Ia}(?aGrSwkuDToWKs# Z0h9!JtNqd}Ng$R2V(IOdX31P=0|4IQt$zRj diff --git a/esp32/lib/libefuse.a b/esp32/lib/libefuse.a index f0fe41c4e8c34a3c596dbd73460e4b1ed3451f1c..90fc08d324cc73e4932a56e64a4ba28e9e06ffb8 100644 GIT binary patch delta 98 zcmdnf%D$(SeS##XnSrUHg^{I&!A7NWP6TiIyfQ|y%{w?PL(s(p;&{{1#cYm7ZbXP} J2kMpc0RT`s8@&Jk delta 98 zcmdnf%D$(SeS##Xsim>0fr*8Y#YUxaP6TiIyfQ|y%{w?PL(s(p;&{{1#cYm7ZbXP} J2kMpc0RUA*8`b~- diff --git a/esp32/lib/libesp32.a b/esp32/lib/libesp32.a index 07ff639a616d8399839ce0a224fa0f59bb1fd42e..fd107af1808452094748c058d561f5306aa215bb 100644 GIT binary patch delta 879 zcmdmS#BRqCy9ttps%A$z{*s$+SLeeb9#Vx*F zcRu@q2qZzj6P)7P-+pJGL=k4}6YEl4VX&Jf=|^Ee;RA%x)eb)EcO5&)Ym B`_ljb delta 878 zcmdmS#BRqCy9ttYre5u$@Gc=rTHfg_S2 z&~xJ3bGbN|bRY?WwHr?66fs2zZU+i>TOs(B+p0CL)v_G-8w7eomE-Sr#D%w)cY*UuO%N*o@0fr*8Y#YCmY2+n3c#z_qTz@-W( diff --git a/esp32/lib/libesp_ringbuf.a b/esp32/lib/libesp_ringbuf.a index 1d5648c6d9ca2324b6cd12789faa03a0c949c7ba..77010891aa547f5972984b2d94b8d20c46d2a047 100644 GIT binary patch delta 39 ocmbQSo^8f@wh59PW(KB)7Dkp98x=1w!8y%8nYRCAVw^t(0P`ITssI20 delta 39 ocmbQSo^8f@wh59Prk2L01|}B98x=1w!8y%8nYRCAVw^t(0P`CRrT_o{ diff --git a/esp32/lib/libespcoredump.a b/esp32/lib/libespcoredump.a index eb72849eec556951a940cfd8d1dbd93257c8153f..9647c581da8571025e816be85e56002bc961a853 100644 GIT binary patch delta 79 zcmcchjp^1mrU{Z9W(KB)7Dkp98x6)6(Uo6j&V)rn>pCLjp1D5<`~QEF_w&nLl8pSHToDg bYa#KU>|kuSK;oBtWb8Ia;&W&+X_*56?4lsd delta 120 zcmdmVfOFFU&Iyv7rk2L01|}B9h8vacvch==n>pCLjp1Cw<`~QEF_w&nLl8pSHToDg bYa#KU>|kuSK;oBtWb8Ia;&W&+X_*56=UgDL diff --git a/esp32/lib/libexpat.a b/esp32/lib/libexpat.a index dc664cc7ad24310f41e3b269cd8201a2bbbf93ab..0b497bb02e596d5ba8c7d71bd9f427e64fb322f9 100644 GIT binary patch delta 177 zcmcb2(&pYtn+cMfW(KB)7Dkp9W*e0ra=>{e(-l0}#haBm+m$&PftU%1nSq!Eh*^P{ zZM!lj`xiU7db4(*dLZTiVoo6D0%C3;=Gm^`!8_Rjt`2OjSo@_8-tCt<_-rSmNo?1X U;SXei3z~skA+~*<0>1+b01(+M=>Px# delta 177 zcmcb2(&pYtn+cMfrk2L01|}B9MjMqLav*rq6+GC*o0U1+l{p!KmLR;a?; z-xV>II&r|vn%=L>F0s9NE8`hCGY5jDl!lT}#+ESO5TM{bc(9 delta 349 zcmdnBOMcfb`3aJork2L01|}B9#v7Fm3d4DZ)1I)2ZDtZVsEjJq{K$O!BXh>LR&Ze> zkjm}viWp0s5Mt9OD6@-iZ{EsyMh+neR+x8%kx>XutnV3P?MyT=tp+C6RunPuc7Il8 zAZ7t#*6seRY)|Cj^2T7ZgH+j;?t_aNZF|DDm=n&0C^__&%~t|0W(0AkJ{x<4EL_ld lJJ9jWG6+7}iEr+Sow^aBXL=kb Tlh}3#en!z>2*K?@!EK2EA4?i8 delta 99 zcmbPojdRL1&Iyv7rk2L01|}B9#v7GRv%`5t)8jaq#5ePDB!t4nj6q^zn|orXZbTE? R?!eC|`U@er9jI_yA^=L!8i)V@ diff --git a/esp32/lib/libjsmn.a b/esp32/lib/libjsmn.a index 13b6ac144d10e0b7e442400a95db8fcb11267435..68768c2cf00d5bc7dd9544be8d53381847f683ae 100644 GIT binary patch delta 35 icmdnj#JI1Cae^eLnSrUHg^{I&$wZ}41ZQKzJ_i7|stPLr delta 35 icmdnj#JI1Cae^eLsim>0fr*8&@kFIi1ZQKzJ_i7|p$a7c diff --git a/esp32/lib/libjson.a b/esp32/lib/libjson.a index 823cb2eedac5bd4b0ffd945495fbb64861cb1585..37188d324e2eb38fade596f10cf6a12db71b35b1 100644 GIT binary patch delta 70 zcmcaMU*Ot&feDhFW(KB)7Dkp9rW=)FIT5_+0*jc$n&)x0&*Nm=K97?ra|T?_q#Y=? KU0@OOv0MPzxD=28 delta 70 zcmcaMU*Ot&feDhFrk2L01|}B9#v7GlIT5_+0*jc$n&)x0&*Nm=K97?ra|S}L9VoY5 JU=j1NTmaaC6omi) diff --git a/esp32/lib/liblog.a b/esp32/lib/liblog.a index 94e274e03ac8767bec9ae32d3b6c3c64ccf099ac..29326a63b59c45988d9d5eefb2b95b21dc05e11c 100644 GIT binary patch delta 37 lcmbQUjA_m?rU{aqW(KB)7Dkp9rW=*`84QHktMnz!`& zwOD>Fmd@5&=_U6)B|c{&jVrMdW5WkY{J;^~nq)6l-KJYd*o&zls;OC4V$Bs->D>bh zRlitiFwToy|Gav)le5_3Q7mJ$yTrdQQlDCFr?vf{HqEuuoX0qL8f-K}b;@)Ho-$oi z@y)HGVnVaT@LzKw0OO*RDEK*3qP^l^-P+r&UamL&Awx&xt({5 zDY4ULjCRkCx6|5|xL-@K*LJwiud>yu$A=H%C!P}*Se3ESWlOmlvWwqI(+!TYXzcuh2m=pVq`NnD* z_(|0XWjdZv=5udX|Lpp7o~8FS{mrTaB{l1Q^SwI5F0gj8^w(`Rnx4P$vovF?MQfTI zuz=@o(C@MvoO{&jKhCnm<+u9l`R#A@h2<6v+p;&G3G(G%m$AY3ZPE zK|2FZY_e#cy&-z8O$qE8NbqE)XpdhF3{SU<%Qzm`IMz<1j|2V3STuSoWC4d=Z?u{V zXa=4)F6f_Dnli@xoS^V%o3;|)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VJuKlg*MurdX5CL^g_wu^y9$vC2AAVfc&QT4V{X~4D94$dSA|B(O1CVGj@c;k- delta 1794 zcmZ8hZ%k8H6i@BoDb%)u($~^fYFpbnVSR01p;g8-Y7AL)L=zKrE{v%dVWG)f78W-# z5Ng!8Mm}7VB~bqxMMNDv8snb<^TV==2~FI>Hq7|4X)={HAx6!1`<~o$!-w_b;0-h5d5!~r2Z2Sz1dQurP)J+$D z;bvHbtn^eigWD|B;^~O0_$PuD!;^g3zuEb>8 zOhcq$p<#u|bonn)ECOoZIec{#;xpwJuj6;s^A&@(hL0H-%Ws7R`t^3(2M7Yy&G{Eo zhw9r;?50sH!hHh0*HMob$Dpyw@jlK_jL>#8gW+dKlq*Wm*{89HMg=sCJNukSonL{3 zKIa5|Zt?Sti09X!3HGdWt>TCj9YFW`7z1UAB+I=P=-BLoB;`q{~r zVQh=Nbsn?{KDhvk^803iQJqgTa-gzWFYUf~k^}RvA%B#bmxFP@SIh}gRn`vqa2lv| zWs$YFe4ca2kzWjKv|@%C{%P@-RWO<4!*K^)z{CD5`$x&a^b7yQZAKGRxnIK4XKcmg zH(+tgJFR$O5IRbhwe`;-H{4m~--&EMoj--o2@?9h6%*RZO3+qTInkD&x+<${t2)}} zFis6s^~V`wNa@gk_gxt91~d`GRihqk3rw*ej!Y(RdaaQCG|-6>LeSU};3S3ARdRnG l=-P&CFnB*ud>nJtm5E)_U#K~xf>U2gYf7;aq{GrN;eY6vF;V~k diff --git a/esp32/lib/libmdns.a b/esp32/lib/libmdns.a index 5eae7b2f522025d3f370aa0a039452a02f09a50a..0a90dd4cd2725f5986ef48a1177c8805f639d13f 100644 GIT binary patch delta 93 zcmbQxB0m9$Bst9tObsoJEG^78Dp@nbd8W;2%-hqL8LPJkYH2>@j24;KIc diff --git a/esp32/lib/libnewlib.a b/esp32/lib/libnewlib.a index 5bfc45b70f00b12a410e98bce3fc04adaa27b9c8..2d38cb67ff60565c3c65db3f95b97fb24505f570 100644 GIT binary patch delta 222 zcmX@`m;JzB_6d@lW(KB)7DkqqCL5I&GsAhto6j+~uSVj=t$(eE;7&frEVeo0q9qHO z(1EKT?NNocUl3)Cv_TOQ-|iX2m>~ccGXa_=zWrhn;}RsX?RCYB+d~m*w%eU#yey31 SgY_8RWqiPoF7}qOUl0I~R6_p% delta 222 zcmX@`m;JzB_6d@lrk2L01|}B9<{On3GsAgio6j+~uSVj=t$(eE;7&frEVeo0q9qHO z(1EKT?NNocUl3)Cv_TOQ-|iX2m?3~Bb}@-@2|~<#dtEW(_E5MQ^X+yg87~VX_&^tk RZ#TTl_<$c>>@8!zAOMhELjC{% diff --git a/esp32/lib/libnghttp.a b/esp32/lib/libnghttp.a index 71693b85eb9e29cfa7877c59ddb6dd056ea51e80..c6f1c210f6b269d26f7d9964422aa374934057c7 100644 GIT binary patch delta 509 zcmZpA0m|GYZ#{(A_)Q&iEr1x$C#207c`v?vZH;oCle4e z12GE_vjQ<25VLRJ?8&jE5U$v)yLgxidm=`-NzJc2^|+g9ZGL`A`g#-2P-ezda(fzy^tLcV-kgVt~-tE?^|EUBE~% rSq4S3#P-R4f;~Y9b<=?sh;O%FD40?S7qox`%3&#??T4j=?XLj0fr*8Q!A2!t6By6fe0o4MquAy?lfO@q#3oGP5#PRAigAJ< zlHdkkUh(bGI*f1h5Q5u*y14@p{OMpt)oU217$OM*6^U=xzsH!84HvYS4ziuzbLDT+j74PZog14r4mUH6b0>vrG&O0mJ+tV1^_)tmDT_N diff --git a/esp32/lib/libnvs_flash.a b/esp32/lib/libnvs_flash.a index 27fecd791efeca9f012914afebdc5c4e748f4670..85d5b40816121a3a34835ba3ea763204dcb224b5 100644 GIT binary patch delta 175 zcmcchQTx_M?Fo{cW(KB)7Dkqq<{OoKh2cDt%@xAorAXWx9ka#ZT+`;71?@Ep7`N9f zU@De|3!82Kv72f3E+qb(GUn#<2!6YU8_RYLH&*EoxR`mn&n#9TX4~#Fi~W5)lDLZ$ PN4tv@=XMttQ-=H~MVe!GSn%XSSnR_PEVF`rqi?LM>Ew)@Ote_xLz?jps} O?jpsx-9?IP+C2b_!8G~+ diff --git a/esp32/lib/libopenssl.a b/esp32/lib/libopenssl.a index 4d179e3fca44707f6eafba12f47857d6bb705a41..940b07af9da59fca53d089af2a12133db7d86639 100644 GIT binary patch delta 185 zcmey;F7TyYV1gv4nSrUHg^{JD=|-jPya?WOz7j^U%|Cd*Dxiz;=s(QD5SukI99?YB rN6#jNSUb?X?R+In&FKg+upQes+-6dgMi>0>jp^iXbio^+m}LY3ST{BD delta 185 zcmey;F7TyYV1gv4sim>0fr*8Q@kXWXyl|e;biNWsvCThtzbc@M@#sIy!VsG^F&tfN v&qvQDgjhS!yzP7?OwH*CF|ZxmH{51Yl!gl$Lj*s3V>MNx?P9 diff --git a/esp32/lib/libpthread.a b/esp32/lib/libpthread.a index 3e4296cf4167bfc1ed5640f3ad5d547532174e90..c03c03d409550f95564da9a2c7520a1037683b94 100644 GIT binary patch delta 79 zcmZ2vLJYq10uvWYq81(BZM{wMC5xQxF8kH_ZDow Jw}8=w7XX?;7oY$D delta 79 zcmZ24G98zB$vory4F~vH9Pz k=vo99q-lGF3uA2(LTvlLWsLiGBKSZx;@j^gFqwA(0QxU1TmS$7 delta 131 zcmbPog?q{s?g^5drk2L01|}9JCL5Lhv%z`Blm8tP+w8#3>4G98zB$vory3!&`QNeV kS_BuQX?ukWV{H;#%w+q&WsLiG!ucSB#kb#0U^4Fn0Prm=F8}}l diff --git a/esp32/lib/libsmartconfig_ack.a b/esp32/lib/libsmartconfig_ack.a index 3cdd913d8ba4ca3ac3ebba7c309d4c800fb6e675..e1741be7dc0be4bba1b3a9e1427e62e3e9448be5 100644 GIT binary patch delta 35 jcmex1mGRqD#tD*~W(KB)7Dkqq<`b3HA~+jw$aw(((0vNy delta 35 jcmex1mGRqD#tD*~rk2L01|}9JCKHv`A~+jw$aw((&_)W` diff --git a/esp32/lib/libsoc.a b/esp32/lib/libsoc.a index f8b9343c083ce12975cb7ed5cd5e3c1521438b8e..6aec8764b35343e070f4c6460e8b1cb91a917316 100644 GIT binary patch delta 299 zcmdlqhj-H)-U*VNW(KB)7Dkqq78{lBvcq}ilOHIGZe$*z>;eG%c_)7W diff --git a/esp32/lib/libtcpip_adapter.a b/esp32/lib/libtcpip_adapter.a index cc61eeb67b00e11399605ed280b6c9f1ac7d203d..763f3f2741bfdaf7595594735a5ac49b544d4d79 100644 GIT binary patch delta 41 pcmex!i2ctY_6d@lW(KB)7DkqqmK&AQSrEMDNi5qZu`s^60{|e04RZhh delta 41 pcmex!i2ctY_6d@lrk2L01|}9JrW=*gSrEMDNi5qZu`s^60{|cQ4QBuV diff --git a/esp32/lib/libvfs.a b/esp32/lib/libvfs.a index f5031c088f98cae4913a44f6fde9a9136ab34c2a..3e49b40f6f7151f3a1e1549518ad69c90a34bf65 100644 GIT binary patch delta 61 zcmZ2;iF?f@?g^5dW(KB)7DkqqmK&A)nc+N(<|^jxRm_a3&Krf(2@7iyn{)V_%F2i-HIv7bYS}YD$PucJA5OdEAHl;rX5C{Lgd#&vQ@j(4eZ9 zeEliWW|M~>a)NiXDybN=?KHvbzdBxqnBS!4z2l=tT!_^d zMG0R0R_*>U20i(z4h)BhAY|35PL-p~iDZoc1GiKcGZ3Vi<`I=Ics8k6gf+ivs3wr4 z#IjNgjF(4bRffaW_J}nMD@w9?*m)T-v4ArB&ynr34+3cK&P3EK}NWM8k$d zJA*Bz*>hL4kDVx6nPhnMN_)5vLE6@xW$m;(1TFMJ(tMo`=Iiv%Y_=eYoq7;EV@8;Q zh2BBh_Qb%pCw7uep+%;%_4aRU!BR*;l-=B30St?AE;WKgmUy)s_mSP06k$)};j$+F z{nJpUMVSCWYMhFP#;JtaX0$+^tj_V(E#H&Gf?o*IvUK;8&VFYQ+}8}Vbu5;Z zKNsr17$SpzDH#}YxYE)dF8Q+^Wm35gXY$&Q-B5s=#m2U82vSY6o~*n9WE8>8 H&|!^Z)+M}T2gmciq`UBSN5e0F)T<)9}=XcEDGOvhtELOR2roKAC-?Di~Si;fI{y8?8z#!fZQL@CB}pmmwAqwY+b9^oSd=`oajo zXV|Je7{Z_@Pt$?nFcE~zTFogd%A82j2{3R=b1@x3nrR-<_)%?G3uuOFP?FLMj9bGp zD?{OGd)OL=6~$RR?7R${SU{Qm=g8}`55hN7g3uaZ zfLP~euGwU2$lVfMfcZ-&GQpi@U6aJ#eEwVKWCPgXL=-oNg=p{Y1Kc!9l1Vil3M#o$ zkqId!1-Rb8@y8ehvP|w`7OPY1KXB_A2vWJ!buJDUrW3ehBKyiiGNlb?By2eKGtA=M zdFQU^AG=VtvdQr1mHu!6g7jKhIN;BAKxr2cmt<+Z2xLK6($2WmR+Vsjp$PPrb8vFXHsg~7zC2JG=*aFGwCW}v8v=KPFsl&Lc99yxGT~I z*e==C#r@Zp_O2UcDg#O@hICjlh>2V1fL@Lmk&(_W$F3GTb34QJ3}vb}c09B7CxbvN wKL3@)v?Ix{&n8a}`1R)eKj=`sUQKQ*yN}&=2N!eSu)m94BC7}s#uL{32;OEM0X8uJLaq!V delta 48 ncmbQ_Gs$OyB&VsRv8jQHg^AfjrMU>s#uL{32;OEM0X8uJLE#J& From 6e2ff2942d2546ca640923b8de5816560560c672 Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Mon, 23 Nov 2020 19:42:05 +0100 Subject: [PATCH 23/25] Update Pybytes to version 1.6.1 --- esp32/frozen/Pybytes/_OTA.py | 14 +- esp32/frozen/Pybytes/_pybytes_constants.py | 9 +- .../Pybytes/_pybytes_machine_learning.py | 176 ++++++++++++++++++ esp32/frozen/Pybytes/_pybytes_protocol.py | 82 +++++--- .../frozen/Pybytes/_pybytes_pymesh_config.py | 32 ++-- esp32/frozen/Pybytes/_terminal.py | 10 +- esp32/pycom_version.h | 2 +- 7 files changed, 282 insertions(+), 43 deletions(-) create mode 100644 esp32/frozen/Pybytes/_pybytes_machine_learning.py diff --git a/esp32/frozen/Pybytes/_OTA.py b/esp32/frozen/Pybytes/_OTA.py index 63d20ac3ec..a1391035c3 100644 --- a/esp32/frozen/Pybytes/_OTA.py +++ b/esp32/frozen/Pybytes/_OTA.py @@ -137,7 +137,6 @@ def update(self, customManifest=None, fwtype=None, token=None): def get_file(self, f): new_path = "{}.new".format(f['dst_path']) - # If a .new file exists from a previously failed update delete it try: os.remove(new_path) @@ -184,6 +183,15 @@ def delete_file(self, f): def write_firmware(self, f): # hash = + url = f['URL'].split("//")[1].split("/")[0] + + if url.find(":") > -1: + self.ip = url.split(":")[0] + self.port = int(url.split(":")[1]) + else: + self.ip = url + self.port = 443 + self.get_data( f['URL'].split("/", 3)[-1], hash=True, @@ -222,7 +230,6 @@ def _http_get(self, path, host): def get_data(self, req, dest_path=None, hash=False, firmware=False): h = None - useSSL = int(self.port) == 443 # Connect to server @@ -232,11 +239,9 @@ def get_data(self, req, dest_path=None, hash=False, firmware=False): if (int(self.port) == 443): print("Wrapping socket") s = ssl.wrap_socket(s) - print("Sending request") # Request File s.sendall(self._http_get(req, "{}:{}".format(self.ip, self.port))) - try: content = bytearray() fp = None @@ -247,6 +252,7 @@ def get_data(self, req, dest_path=None, hash=False, firmware=False): fp = open(dest_path, 'wb') if firmware: + print_debug(4, "Starting OTA...") pycom.ota_start() h = uhashlib.sha1() diff --git a/esp32/frozen/Pybytes/_pybytes_constants.py b/esp32/frozen/Pybytes/_pybytes_constants.py index aa1d27cd67..8ae4058530 100644 --- a/esp32/frozen/Pybytes/_pybytes_constants.py +++ b/esp32/frozen/Pybytes/_pybytes_constants.py @@ -69,11 +69,12 @@ class constants: __TYPE_OTA = 0x05 __TYPE_FCOTA = 0x06 __TYPE_PONG = 0x07 - __TYPE_PYMESH = 0x0D - __TYPE_PYBYTES = 0x0E - __TYPE_RELEASE_INFO = 0x0B __TYPE_RELEASE_DEPLOY = 0x0A + __TYPE_RELEASE_INFO = 0x0B __TYPE_DEVICE_NETWORK_DEPLOY = 0x0C + __TYPE_PYMESH = 0x0D + __TYPE_PYBYTES = 0x0E + __TYPE_ML = 0x0F __PYBYTES_PROTOCOL = ">B%ds" __PYBYTES_PROTOCOL_PING = ">B" __PYBYTES_INTERNAL_PROTOCOL = ">BBH" @@ -90,6 +91,8 @@ class constants: __COMMAND_ANALOG_WRITE = 4 __COMMAND_CUSTOM_METHOD = 5 __COMMAND_CUSTOM_LOCATION = 6 + __COMMAND_START_SAMPLE = 7 + __COMMAND_DEPLOY_MODEL = 8 __FCOTA_COMMAND_HIERARCHY_ACQUISITION = 0x00 __FCOTA_COMMAND_FILE_ACQUISITION = 0x01 diff --git a/esp32/frozen/Pybytes/_pybytes_machine_learning.py b/esp32/frozen/Pybytes/_pybytes_machine_learning.py new file mode 100644 index 0000000000..5c1fce6626 --- /dev/null +++ b/esp32/frozen/Pybytes/_pybytes_machine_learning.py @@ -0,0 +1,176 @@ +''' +Copyright (c) 2020, Pycom Limited. +This software is licensed under the GNU GPL version 3 or any +later version, with permitted additional terms. For more information +see the Pycom Licence v1.0 document supplied with this file, or +available at https://www.pycom.io/opensource/licensing +''' + +import math +import json + +try: + from pybytes_debug import print_debug +except: + from _pybytes_debug import print_debug + +try: + import urequest +except: + import _urequest as urequest + +try: + from pybytes_constants import constants +except: + from _pybytes_constants import constants + +import pycom + +try: + from LIS2HH12 import * +except: + print_debug(5, "LIS2HH12 not imported") + +# 20 seconds, max window in time for recording +MAX_LEN_MSEC = const(20000) + +# 350Hz, max frequency +MAX_FREQ_HZ = const(350) + + +class MlFeatures(): + def __init__(self, pybytes_protocol=None, parameters=None): + if parameters is not None: + self.__length = parameters["length"] + self.__label = parameters["label"] + self.__sampleName = parameters["sampleName"] + self.__type = parameters["type"] + self.__device = parameters["device"] + self.__model = parameters["model"] + self.__mlSample = parameters["mlSample"] + self.__frequency = parameters["frequency"] + self.__pybytes_protocol = pybytes_protocol + self.__data = [] + + def _debug_hack(self, pybytes): + self.__pybytes = pybytes + + def start_sampling(self, pin): + # here define the required libraries + try: + from pysense import Pysense + except: + print_debug(5, "pysense not imported") + + try: + from pytrack import Pytrack + except: + print_debug(5, "pytrack not imported") + + lib = False + try: + py = Pysense() + lib = True + except NameError: + print_debug(5, "Pysense not defined") + + if not lib: + try: + py = Pytrack() + except NameError: + print_debug(5, "Check if Pysense/Pytrack libraries are loaded") + return + + try: + li = LIS2HH12(py) + except NameError: + print_debug(5, "LIS2HH12 library are not loaded") + return + li.set_odr(ODR_400_HZ) + + # make the max record length to 20 seconds + self.__length = min(MAX_LEN_MSEC, self.__length) + + # make the max frequency to 350Hz + self.__frequency = min(MAX_FREQ_HZ, self.__frequency) + + # compute time interval between 2 consecutive samples + delta_t_us = int(1000000.0 / self.__frequency) + # compute the number of samples to be acquisition + samples_num = math.ceil(self.__length * self.__frequency / 1000) + 1 + + try: + pycom.heartbeat(False) + pycom.rgbled(0x7f7f00) + except: + pass + time.sleep(0.5) + + self.__data = [] + index = 0 + print("Start acquisition data for %d msec, freq %d Hz" % (self.__length, self.__frequency)) + + next_ts = time.ticks_us() + ts_orig = next_ts + while True: + while time.ticks_diff(next_ts, time.ticks_us()) > 0: + pass + acc = li.acceleration() + ts = next_ts + self.__data.append((ts - ts_orig, acc)) + next_ts = ts + delta_t_us + index += 1 + if index >= samples_num: + break # done + + print("Done acquisition %d samples, real freq %.1f Hz" % (index, index / (self.__length / 1000))) + self._parse_data(pin) + + def _send_data(self, data, pin, acc, ts): + if self.__pybytes_protocol is not None: + if self.__type == 2: + self.__label = self.__sampleName + self.__pybytes_protocol.send_pybytes_custom_method_values(pin, [ + data], + 'sample/{}/{}/{}/{}/{}'.format(self.__label, self.__type, self.__model, self.__device, self.__mlSample)) + else: + self.__pybytes.send_signal(pin & 0xFF, str((int(ts / 1000), acc))) + + def _parse_data(self, pin): + print("_parse_data, %d samples" % len(self.__data)) + try: + pycom.rgbled(0x8d05f5) + except: + pass + data = ['{"data": "ml"}'] + for (ts, acc) in self.__data: + data.append('{' + '"data": [{},{},{}], "ms": {}'.format(acc[0], acc[1], acc[2], int(ts / 1000)) + '}') + if len(data) > 25: + self._send_data(data, pin, acc, ts) + data = ['{"data": "ml"}'] + self._send_data(data, pin, acc, ts) + try: + pycom.heartbeat(True) + except: + pass + + def deploy_model(self, modelId, silent=False): + try: + file = '/flash/model_definition.json' + modelDefinition = {} + url = '{}://{}/ml/{}'.format( + constants.__DEFAULT_PYCONFIG_PROTOCOL, + constants.__DEFAULT_PYCONFIG_DOMAIN, + modelId + ) + print_debug(2, '{}'.format(url)) + result = urequest.get(url, headers={'content-type': 'application/json'}) + modelDefinition = json.loads(result.content.decode()) + print_debug(2, 'modelDefinition: {}'.format(modelDefinition)) + f = open(file, 'w') + f.write(json.dumps(modelDefinition).encode('utf-8')) + f.close() + print_debug(2, "Model definition written to {}".format(file)) + except Exception as e: + if not silent: + print_debug(2, "Exception: {}".format(e)) diff --git a/esp32/frozen/Pybytes/_pybytes_protocol.py b/esp32/frozen/Pybytes/_pybytes_protocol.py index 385d8c6f9c..6934f3ee44 100644 --- a/esp32/frozen/Pybytes/_pybytes_protocol.py +++ b/esp32/frozen/Pybytes/_pybytes_protocol.py @@ -31,6 +31,11 @@ except: from _pybytes_pymesh_config import PybytesPymeshConfig +try: + from pybytes_machine_learning import MlFeatures +except: + from _pybytes_machine_learning import MlFeatures + try: from pybytes_config_reader import PybytesConfigReader except: @@ -281,10 +286,10 @@ def __process_recv_message(self, message): splittedBody = bodyString.split(',') if (len(splittedBody) >= 2): path = splittedBody[0] - print_debug(2, path[len(path)-7:len(path)]) - if (path[len(path)-7:len(path)] != '.pymakr'): + print_debug(2, path[len(path) - 7:len(path)]) + if (path[len(path) - 7:len(path)] != '.pymakr'): self.send_fcota_ping('updating file...') - newContent = bodyString[len(path)+1:len(body)] + newContent = bodyString[len(path) + 1:len(body)] if (self.__FCOTA.update_file_content(path, newContent) is True): # noqa size = self.__FCOTA.get_file_size(path) self.send_fcota_file(newContent, path, size) @@ -319,7 +324,18 @@ def __process_recv_message(self, message): if (len(body) > 3): value = body[2] << 8 | body[3] - if (command == constants.__COMMAND_PIN_MODE): + if (command == constants.__COMMAND_START_SAMPLE): + parameters = ujson.loads(body[2: len(body)].decode("utf-8")) + sampling = MlFeatures(self, parameters=parameters) + sampling.start_sampling(pin=parameters["pin"]) + self.send_ota_response(result=2, topic='sample') + elif (command == constants.__COMMAND_DEPLOY_MODEL): + parameters = ujson.loads(body[2: len(body)].decode("utf-8")) + sampling = MlFeatures() + sampling.deploy_model(modelId=parameters["modelId"]) + self.send_ota_response(result=2, topic='deploymlmodel') + + elif (command == constants.__COMMAND_PIN_MODE): pass elif (command == constants.__COMMAND_DIGITAL_READ): @@ -633,16 +649,11 @@ def write_firmware(self, customManifest=None): def get_application_details(self, body): application = self.__conf.get('application') if application is not None: - if 'id' in application and application['id']: - applicationID = application['id'] - else: - applicationID = body['applicationId'] if 'release' in application and 'codeFilename' in application['release']: currentReleaseID = application['release']['codeFilename'] else: currentReleaseID = None else: - applicationID = body['applicationId'] currentReleaseID = None self.__conf['application'] = { "id": "", @@ -652,6 +663,7 @@ def get_application_details(self, body): "version": 0 } } + applicationID = body['applicationId'] return (applicationID, currentReleaseID) def get_update_manifest(self, applicationID, newReleaseID, currentReleaseID): @@ -755,21 +767,46 @@ def update_network_config(self, letResp): except Exception as e: print_debug(1, "error while updating network config pybytes_config.json! {}".format(e)) - def update_firmware(self, body): + def update_firmware(self, body, applicationID, fw_type='pybytes'): if "firmware" not in body: print_debug(0, "no firmware to update") return - version = body['firmware']["version"] - print_debug(0, "updating firmware to {}".format(version)) - customManifest = { - "firmware": { - "URL": "https://{}/downloads/appimg/firmware_{}_{}.bin".format( - constants.__DEFAULT_SW_HOST, - os.uname().sysname, - version), + + if "version" in body['firmware']: + version = body['firmware']["version"] + print_debug(0, "updating firmware to {}".format(version)) + + customManifest = { + "firmware": { + "URL": "https://{}/findupgrade?redirect=true&strict=true&type={}&model={}&version={}&download=true".format( + constants.__DEFAULT_SW_HOST, + fw_type, + os.uname().sysname, + version), + } } - } - self.write_firmware(customManifest) + self.write_firmware(customManifest) + else: + fileUrl = '{}://{}/firmware?'.format(constants.__DEFAULT_PYCONFIG_PROTOCOL, constants.__DEFAULT_PYCONFIG_DOMAIN) + customFirmwares = body['firmware']["customFirmwares"] + firmwareFilename = '' + for firmware in customFirmwares: + print_debug(1, "firmware['firmwareType']={} and os.uname().sysname.lower()={}".format(firmware['firmwareType'], os.uname().sysname.lower())) + print_debug(1, "firmware={}".format(firmware)) + if (firmware['firmwareType'] == os.uname().sysname.lower()): + firmwareFilename = firmware['firmwareFilename'] + targetFileLocation = '{}application_id={}&target_ver={}&target_path={}'.format( + fileUrl, + applicationID, + firmwareFilename, + '/{}.bin'.format(firmwareFilename) + ) + customManifest = { + "firmware": { + "URL": targetFileLocation, + } + } + self.write_firmware(customManifest) def deploy_new_release(self, body): try: @@ -783,12 +820,15 @@ def deploy_new_release(self, body): applicationID, currentReleaseID = self.get_application_details(body) letResp = self.get_update_manifest(applicationID, newReleaseID, currentReleaseID) + if not letResp: return + fwtype = 'pygate' if hasattr(os.uname(), 'pygate') else 'pybytes' + fwtype = 'pymesh' if hasattr(os.uname(), 'pymesh') else fwtype self.update_files(letResp, applicationID, newReleaseID) self.delete_files(letResp) self.update_application_config(letResp, applicationID) self.update_network_config(letResp) - self.update_firmware(letResp) + self.update_firmware(letResp, applicationID, fw_type=fwtype) machine.reset() diff --git a/esp32/frozen/Pybytes/_pybytes_pymesh_config.py b/esp32/frozen/Pybytes/_pybytes_pymesh_config.py index 116f797925..ff12070d1c 100644 --- a/esp32/frozen/Pybytes/_pybytes_pymesh_config.py +++ b/esp32/frozen/Pybytes/_pybytes_pymesh_config.py @@ -45,7 +45,10 @@ def pymesh_init(self): except: from _pymesh import Pymesh - pycom.heartbeat(False) + try: + pycom.heartbeat(False) + except: + pass # read config file, or set default values self.__pymesh_config = PymeshConfig.read_config() @@ -81,7 +84,7 @@ def unpack_pymesh_message(self, signal_number, value): # send data to the port equal with signal_number self.__pymesh.send_mess_external(pyb_ip, signal_number, pkt_start + value) - + time.sleep(3) # shouldn't send too fast to BR # hardcode monitoring data to be sent on signal #2 @@ -93,11 +96,14 @@ def pymesh_new_message_cb(self, rcv_ip, rcv_port, rcv_data): print_debug(99, 'Received: {} '.format(rcv_data)) # user code to be inserted, to send packet to the designated Mesh-external interface - for _ in range(3): - pycom.rgbled(0x888888) - time.sleep(.2) - pycom.rgbled(0) - time.sleep(.1) + try: + for _ in range(3): + pycom.rgbled(0x888888) + time.sleep(.2) + pycom.rgbled(0) + time.sleep(.1) + except: + pass return def pymesh_new_br_message_cb(self, rcv_ip, rcv_port, rcv_data, dest_ip, dest_port): @@ -106,11 +112,13 @@ def pymesh_new_br_message_cb(self, rcv_ip, rcv_port, rcv_data, dest_ip, dest_por print_debug(99, 'Incoming %d bytes from %s (port %d), to external IPv6 %s (port %d)' % (len(rcv_data), rcv_ip, rcv_port, dest_ip, dest_port)) print_debug(99, 'Received: {} '.format(rcv_data)) - for _ in range(2): - pycom.rgbled(0x0) - time.sleep(.1) - pycom.rgbled(0x663300) - + try: + for _ in range(2): + pycom.rgbled(0x0) + time.sleep(.1) + pycom.rgbled(0x663300) + except: + pass # try to find Pybytes Token if include in rcv_data token = "" if rcv_data.startswith(self.__pack_tocken_prefix): diff --git a/esp32/frozen/Pybytes/_terminal.py b/esp32/frozen/Pybytes/_terminal.py index 7125ff5729..35f0b82ec8 100644 --- a/esp32/frozen/Pybytes/_terminal.py +++ b/esp32/frozen/Pybytes/_terminal.py @@ -23,10 +23,16 @@ def write(self, data): self.message_to_send += data # self.__pybytes_protocol.__send_terminal_message(data) else: - self.original_terminal.write(data) + try: + self.original_terminal.write(data) + except: + pass def read(self, size): - return self.original_terminal.read(size) + try: + return self.original_terminal.read(size) + except: + return b'' def message_sent_from_pybytes_start(self): self.message_from_pybytes = True diff --git a/esp32/pycom_version.h b/esp32/pycom_version.h index dfa8be4d40..cbe246821c 100644 --- a/esp32/pycom_version.h +++ b/esp32/pycom_version.h @@ -17,7 +17,7 @@ #define SIGFOX_VERSION_NUMBER "1.0.1" #if (VARIANT == PYBYTES) -#define PYBYTES_VERSION_NUMBER "1.5.2" +#define PYBYTES_VERSION_NUMBER "1.6.1" #endif #ifdef PYGATE_ENABLED From 1097cbebd7cc341df4920595bac784dfee6170db Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Mon, 23 Nov 2020 19:42:37 +0100 Subject: [PATCH 24/25] Update pycom_version.h Firmware release 1.20.2.r2 --- esp32/pycom_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32/pycom_version.h b/esp32/pycom_version.h index cbe246821c..55b3ed1ca3 100644 --- a/esp32/pycom_version.h +++ b/esp32/pycom_version.h @@ -10,7 +10,7 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define SW_VERSION_NUMBER "1.20.2.rc11" +#define SW_VERSION_NUMBER "1.20.2.r2" #define LORAWAN_VERSION_NUMBER "1.0.2" From 72bc4a7328a05bbb68f632d1d6d50a783cdaa829 Mon Sep 17 00:00:00 2001 From: Christian Ehlers Date: Mon, 23 Nov 2020 20:44:32 +0100 Subject: [PATCH 25/25] Update _pybytes_protocol.py Use correct web call for release upgrades --- esp32/frozen/Pybytes/_pybytes_protocol.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/esp32/frozen/Pybytes/_pybytes_protocol.py b/esp32/frozen/Pybytes/_pybytes_protocol.py index 6934f3ee44..f7d1ba41ed 100644 --- a/esp32/frozen/Pybytes/_pybytes_protocol.py +++ b/esp32/frozen/Pybytes/_pybytes_protocol.py @@ -69,6 +69,7 @@ import struct import machine import ujson +import pycom class PybytesProtocol: @@ -778,13 +779,16 @@ def update_firmware(self, body, applicationID, fw_type='pybytes'): customManifest = { "firmware": { - "URL": "https://{}/findupgrade?redirect=true&strict=true&type={}&model={}&version={}&download=true".format( + "URL": "https://{}/manifest.json?sysname={}&wmac={}&ota_slot={}&fwtype={}&target_ver={}&download=true".format( constants.__DEFAULT_SW_HOST, - fw_type, os.uname().sysname, + hexlify(machine.unique_id()).decode('ascii'), + hex(pycom.ota_slot()), + fw_type, version), } } + print_debug(5, "Custom Manifest: {}".format(customManifest)) self.write_firmware(customManifest) else: fileUrl = '{}://{}/firmware?'.format(constants.__DEFAULT_PYCONFIG_PROTOCOL, constants.__DEFAULT_PYCONFIG_DOMAIN)