Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Rc6 #416

Merged
merged 104 commits into from
Feb 28, 2020
Merged

Rc6 #416

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
54b8e88
BLE: Allow static passwords, remove bonded when pin changes
oligauc Oct 8, 2019
0b8c8a8
Merge pull request #64 from pycom/sec_ble
Oct 8, 2019
90eb9de
Update Jenkins File
Oct 7, 2019
6638953
mods/pyblte.c: Fix the lenght field for AT commands
robert-hh Oct 7, 2019
415af4d
mods/pybadc.c: Fix the argument handling of bits=x for adc.init()
robert-hh Oct 7, 2019
aae6c26
Restore previous wifi_on_boot behaviour.
Xykon Oct 8, 2019
3024c89
Bugfixes
Xykon Oct 8, 2019
b16e92d
Update Jenkinsfile and pycom_version.h
Xykon Oct 8, 2019
881be0e
Merge branch 'Dev' of https://github.com/pycom/pycom-micropython-sigfox
Oct 14, 2019
57b1110
Update Pybytes to 1.2.0 for new release 1.20.1.r2
Xykon Oct 30, 2019
8bc1f0c
Changes needed for idf 3.3.
geza-pycom Nov 13, 2019
36763fa
refactor: updated pybytes-devices to 1.3.0
jirkadev Nov 19, 2019
a57ae0c
chore: updated .gitignore file
jirkadev Nov 19, 2019
aca4712
Merge pull request #65 from husigeza/idf_3.3_support
geza-pycom Nov 19, 2019
5ecc3d0
Revert "Merge pull request #65 from husigeza/idf_3.3_support" (#67)
geza-pycom Nov 22, 2019
2c2c229
Update _pybytes_connection.py
Xykon Nov 25, 2019
9f1479a
Support Sigfox registration for Pybytes
Xykon Nov 30, 2019
8ad73f9
Update _pybytes_constants.py
Xykon Nov 30, 2019
3697c2a
Update pycom_version.h
Xykon Nov 30, 2019
3c65d90
PYFW-390: Update .gitignore to allow esp32/lib libraries to be updated
geza-pycom Nov 30, 2019
c5d4973
Merge pull request #69 from husigeza/PYFW-390
geza-pycom Nov 30, 2019
188ffd2
MDNS advertisement works
geza-pycom Nov 17, 2019
0ac25ff
Adding text to advertisement works
geza-pycom Nov 17, 2019
c79bb20
Query works
Nov 22, 2019
f65490d
Free up internal query results
Nov 26, 2019
1902f34
Change host_name to hostname
Nov 29, 2019
996f300
Rename text to txt
Nov 29, 2019
c2c64b5
Adding libmdns.a to esp32/lib
geza-pycom Nov 30, 2019
c40694a
Merge branch 'master' into pybytes-devices-v1.3.0
Xykon Nov 30, 2019
2071a1f
Update modpycom.c
Xykon Nov 30, 2019
004c97a
Release updates & bugfixes
Xykon Nov 30, 2019
2b017e1
Update sqnsupgrade.py
Xykon Nov 30, 2019
ade08b6
Update pycom_version.h
Xykon Nov 30, 2019
9978dfd
Update _pybytes_config.py
Xykon Nov 30, 2019
9d29de9
Merge pull request #68 from husigeza/mdns
geza-pycom Dec 3, 2019
d19e340
Adding gdbinit
geza-pycom Dec 18, 2019
7166cc0
Adding scripts for PyJTAG and short Readme
geza-pycom Jan 7, 2020
6f1451e
Update readme, move gdbinit
geza-pycom Jan 7, 2020
284cd01
Merge pull request #72 from husigeza/PyJTAG
geza-pycom Jan 11, 2020
0373d7e
re-integrate sigfox sources
peter-pycom Jan 13, 2020
34408c7
Merge pull request #66 from pycom/pybytes-devices-v1.3.0
Jan 14, 2020
e1df781
Merge pull request #73 from doniks/sigfox_reintegrate
doniks Jan 16, 2020
9a2d6c1
typo
peter-pycom Dec 6, 2019
ae96346
pyjtag clarifications
doniks Jan 20, 2020
c39484b
clarification
peter-pycom Jan 20, 2020
05c58d5
Merge pull request #75 from doniks/sigfox-readme-fix
doniks Jan 21, 2020
a87cdd9
update sigfox libraries - prep for LoPy4 certification in Regions 1,2…
peter-pycom Jan 21, 2020
f63954f
Merge pull request #74 from pycom/doniks-pyjtag-docs-improvements
doniks Jan 22, 2020
9493536
Replace xQueueSendFromISR call with xQueueSend when called from BLE e…
geza-pycom Jan 24, 2020
d6c1ccb
Merge pull request #80 from husigeza/Minor_fixes_BLE_Lora
geza-pycom Jan 28, 2020
e6bc45f
Replacing "switch-case" with "if-else if" in Region.c to avoid genera…
geza-pycom Jan 28, 2020
e87e98f
Merge pull request #81 from husigeza/Fix_LoraRegion
geza-pycom Jan 28, 2020
33ffef7
Merge pull request #76 from doniks/sigfox-ready-for-cert
doniks Jan 29, 2020
6756537
BLE characteristic update messages are lost if they sent too frequently
geza-pycom Jan 28, 2020
b410946
Merge pull request #82 from husigeza/PYFW-395
geza-pycom Jan 30, 2020
013147c
PYFW-394: mod_ssl_setup_socket() allocates memory while GIL is not lo…
geza-pycom Jan 28, 2020
d04991c
PYFW-401: Mutex of LFS can be locked in wlan_read_file or mod_ssl_rea…
geza-pycom Jan 28, 2020
fbdb44d
PYFW-402: wlan_do_connect() allocates memory while GIL is not locked
geza-pycom Jan 28, 2020
e51543b
PYFW-404: bt_connect_helper() uses MicroPython functions outside of GIL
geza-pycom Jan 28, 2020
492ffd9
PYFW-405: lte_send_at_cmd() uses MicroPython functions outside of GIL
geza-pycom Jan 28, 2020
beebc21
refactor lte_add_band() out of lte_attach()
peter-pycom Feb 4, 2020
150611f
add bands=() parameter to lte.attach()
peter-pycom Feb 4, 2020
01de258
Merge pull request #83 from husigeza/GIL_fixes
geza-pycom Feb 4, 2020
35d737f
PYFW-391: ESP-IDF 3.3.1 support (#86)
geza-pycom Feb 4, 2020
66d7dcd
Add pybytes_on_boot functionality (#87)
Xykon Feb 4, 2020
16ce927
Merge pull request #84 from doniks/lte-multiple-bands-again
Xykon Feb 4, 2020
a356ce7
Update pycom_version.h
Xykon Feb 4, 2020
45c4822
Merge branch 'master' into Dev
Xykon Feb 6, 2020
b3d3ea5
Merge pull request #88 from pycom/Dev
doniks Feb 6, 2020
09d3ee1
Update pycom_version.h
Xykon Feb 9, 2020
ef3384e
Added interface to save and resume SSL sessions
DvdGiessen Jan 28, 2020
3bcb37d
Added typechecks, copyright updated to 2020
knagymate Feb 10, 2020
6b9c880
Merge pull request #89 from husigeza/PR390
geza-pycom Feb 14, 2020
1d3ad0e
Implemented configuration options for BLE security
geza-pycom Feb 14, 2020
1de0f9b
Sigfox: finalizing certification RCZ1, 2, 4
peter-pycom Feb 19, 2020
84b9fd1
Merge pull request #93 from pycom/sigfox_cert_ready
doniks Feb 20, 2020
f2db523
protect sigfox private key
peter-pycom Feb 21, 2020
68c3374
raise exception if NV writing failed
peter-pycom Feb 24, 2020
ac40811
Ignore Visual Studio Code project files
peter-pycom Feb 24, 2020
cfe72ee
add Troubleshooting (#91)
doniks Feb 24, 2020
bc2d085
Merge pull request #94 from pycom/sigfox_private_key
peter-pycom Feb 24, 2020
5df479c
IDF 3.3.1 compiler update
Xykon Feb 26, 2020
b8f24a8
Update sqnsupgrade.py
Xykon Feb 26, 2020
68d2608
Update _pybytes_config.py
Xykon Feb 26, 2020
987adcf
Merge pull request #98 from pycom/1.22.0-98-g4638c4f-IDF-libs-libgcc.…
peter-pycom Feb 26, 2020
d38988a
Update pycom_version.h
Xykon Feb 26, 2020
a25a686
Merge pull request #99 from pycom/update_sqnsupgrade_for_release
peter-pycom Feb 26, 2020
bc41407
Merge pull request #100 from pycom/update_pybytes_for_release
peter-pycom Feb 26, 2020
3e69677
Merge pull request #101 from pycom/update_version
peter-pycom Feb 26, 2020
8d9faa6
Update IDF libraries
Xykon Feb 26, 2020
dddee59
Merge pull request #95 from pycom/ignore_vscode
peter-pycom Feb 27, 2020
77d25aa
Merge pull request #103 from pycom/update-idf-libs
Xykon Feb 27, 2020
237a8fe
sleep in main thread to yield
peter-pycom Feb 27, 2020
a7c6e2c
Update pyexec.c
Xykon Feb 27, 2020
bbf355d
Merge pull request #105 from pycom/fix_thread_tests
Xykon Feb 27, 2020
5c818cb
Fix double build frozen (#102)
peter-pycom Feb 27, 2020
9fb2548
default path and make executable (#104)
peter-pycom Feb 27, 2020
a0e3edd
Merge pull request #106 from pycom/allow_ctrl-d_when_pybytes_on_boot_…
peter-pycom Feb 28, 2020
88afbf5
update fw_updater to 6e96ea3
peter-pycom Feb 28, 2020
3e7e176
Merge pull request #108 from pycom/update_fwup
Xykon Feb 28, 2020
77b511a
Update updater.py and disable pybytes in Jenkins
peter-pycom Feb 28, 2020
a53e651
fix
peter-pycom Feb 28, 2020
07cde9e
Merge pull request #109 from pycom/update_fwup_and_Jenkins
peter-pycom Feb 28, 2020
867d922
1.20.2.rc6
peter-pycom Feb 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PYFW-401: Mutex of LFS can be locked in wlan_read_file or mod_ssl_rea…
…d_file
  • Loading branch information
geza-pycom committed Jan 30, 2020
commit d04991c95be3b7a341dbaaba9d3ad5671d70c2e8
1 change: 1 addition & 0 deletions esp32/application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ APP_UTIL_SRC_C = $(addprefix util/,\
mpsleep.c \
timeutils.c \
esp32chipinfo.c \
pycom_general_util.c \
)

APP_FATFS_SRC_C = $(addprefix fatfs/src/,\
Expand Down
87 changes: 4 additions & 83 deletions esp32/mods/modussl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,16 @@
#include "modusocket.h"
#include "modussl.h"
#include "mptask.h"
#include "pycom_general_util.h"

#include "ff.h"
#include "lfs.h"
#include "extmod/vfs.h"

#include "mptask.h"
/******************************************************************************
DEFINE CONSTANTS
******************************************************************************/
#define FILE_READ_SIZE 256
#define DEFAULT_SSL_READ_TIMEOUT 10 //sec

/******************************************************************************
DECLARE PRIVATE FUNCTIONS
******************************************************************************/
static char *mod_ssl_read_file (const char *file_path, vstr_t *vstr);

/******************************************************************************
DECLARE PRIVATE DATA
Expand Down Expand Up @@ -176,79 +170,6 @@ static int32_t mod_ssl_setup_socket (mp_obj_ssl_socket_t *ssl_sock, const char *
return 0;
}

static char *mod_ssl_read_file (const char *file_path, vstr_t *vstr) {
vstr_init(vstr, FILE_READ_SIZE);
char *filebuf = vstr->buf;
mp_uint_t actualsize;
mp_uint_t totalsize = 0;
static const TCHAR *path_relative;

if(isLittleFs(file_path))
{
vfs_lfs_struct_t* littlefs = lookup_path_littlefs(file_path, &path_relative);
if (littlefs == NULL) {
return NULL;
}

lfs_file_t fp;

xSemaphoreTake(littlefs->mutex, portMAX_DELAY);

int res = lfs_file_open(&littlefs->lfs, &fp, path_relative, LFS_O_RDONLY);
if(res < LFS_ERR_OK)
{
return NULL;
}

while (true) {
actualsize = lfs_file_read(&littlefs->lfs, &fp, filebuf, FILE_READ_SIZE);
if (actualsize < LFS_ERR_OK) {
return NULL;
}
totalsize += actualsize;
if (actualsize < FILE_READ_SIZE) {
break;
} else {
filebuf = vstr_extend(vstr, FILE_READ_SIZE);
}
}
lfs_file_close(&littlefs->lfs, &fp);

xSemaphoreGive(littlefs->mutex);

}
else
{
FATFS *fs = lookup_path_fatfs(file_path, &path_relative);
if (fs == NULL) {
return NULL;
}
FIL fp;
FRESULT res = f_open(fs, &fp, path_relative, FA_READ);
if (res != FR_OK) {
return NULL;
}

while (true) {
FRESULT res = f_read(&fp, filebuf, FILE_READ_SIZE, (UINT *)&actualsize);
if (res != FR_OK) {
f_close(&fp);
return NULL;
}
totalsize += actualsize;
if (actualsize < FILE_READ_SIZE) {
break;
} else {
filebuf = vstr_extend(vstr, FILE_READ_SIZE);
}
}
f_close(&fp);
}

vstr->len = totalsize;
vstr_null_terminated_str(vstr);
return vstr->buf;
}

/******************************************************************************/
// Micro Python bindings; SSL class
Expand Down Expand Up @@ -310,7 +231,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,

const char *ca_cert = NULL;
if (cafile_path) {
ca_cert = mod_ssl_read_file(cafile_path, &ssl_sock->vstr_ca);
ca_cert = pycom_util_read_file(cafile_path, &ssl_sock->vstr_ca);
if(ca_cert == NULL) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "CA file not found"));
}
Expand All @@ -319,11 +240,11 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,
const char *client_cert = NULL;
const char *client_key = NULL;
if (certfile_path && keyfile_path) {
client_cert = mod_ssl_read_file(certfile_path, &ssl_sock->vstr_ca);
client_cert = pycom_util_read_file(certfile_path, &ssl_sock->vstr_ca);
if(client_cert == NULL) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "certificate file not found"));
}
client_key = mod_ssl_read_file(keyfile_path, &ssl_sock->vstr_ca);
client_key = pycom_util_read_file(keyfile_path, &ssl_sock->vstr_ca);
if(client_key == NULL) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "key file not found"));
}
Expand Down
82 changes: 3 additions & 79 deletions esp32/mods/modwlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "esp_event_loop.h"
#include "ff.h"
#include "lfs.h"
#include "vfs_littlefs.h"
#include "esp_wpa2.h"
#include "esp_smartconfig.h"

Expand All @@ -58,6 +55,7 @@
#include "mpirq.h"
#include "mptask.h"
#include "pycom_config.h"
#include "pycom_general_util.h"

/******************************************************************************
DEFINE TYPES
Expand All @@ -67,7 +65,6 @@
DEFINE CONSTANTS
******************************************************************************/

#define FILE_READ_SIZE 256
#define BSSID_MAX_SIZE 6
#define MAX_WLAN_KEY_SIZE 65
#define MAX_AP_CONNECTED_STA 4
Expand Down Expand Up @@ -164,7 +161,6 @@ STATIC void wlan_set_antenna (uint8_t antenna);
static esp_err_t wlan_event_handler(void *ctx, system_event_t *event);
STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_auth_mode_t auth, const char* key, int32_t timeout, const wlan_wpa2_ent_obj_t * const wpa2_ent, const char *hostname, uint8_t channel);
static void wlan_init_wlan_recover_params(void);
static char *wlan_read_file (const char *file_path, vstr_t *vstr);
static void wlan_timer_callback( TimerHandle_t xTimer );
static void wlan_validate_country(const char * country);
static void wlan_validate_country_policy(uint8_t policy);
Expand Down Expand Up @@ -746,7 +742,7 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut
if (auth == WIFI_AUTH_WPA2_ENTERPRISE) {
// CA Certificate is not mandatory
if (wpa2_ent->ca_certs_path != NULL) {
if (wlan_read_file(wpa2_ent->ca_certs_path, &wlan_obj.vstr_ca)) {
if (pycom_util_read_file(wpa2_ent->ca_certs_path, &wlan_obj.vstr_ca)) {
if (ESP_OK != esp_wifi_sta_wpa2_ent_set_ca_cert((unsigned char*)wlan_obj.vstr_ca.buf, (int)wlan_obj.vstr_ca.len)) {
goto os_error;
}
Expand All @@ -757,7 +753,7 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut

// client certificate is necessary only in EAP-TLS method, this is ensured by wlan_validate_certificates() function
if (wpa2_ent->client_key_path != NULL && wpa2_ent->client_cert_path != NULL) {
if (wlan_read_file(wpa2_ent->client_key_path, &wlan_obj.vstr_key) && wlan_read_file(wpa2_ent->client_cert_path, &wlan_obj.vstr_cert)) {
if (pycom_util_read_file(wpa2_ent->client_key_path, &wlan_obj.vstr_key) && pycom_util_read_file(wpa2_ent->client_cert_path, &wlan_obj.vstr_cert)) {
if (ESP_OK != esp_wifi_sta_wpa2_ent_set_cert_key((unsigned char*)wlan_obj.vstr_cert.buf, (int)wlan_obj.vstr_cert.len,
(unsigned char*)wlan_obj.vstr_key.buf, (int)wlan_obj.vstr_key.len, NULL, 0)) {
goto os_error;
Expand Down Expand Up @@ -822,78 +818,6 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
}

STATIC char *wlan_read_file (const char *file_path, vstr_t *vstr) {
vstr_init(vstr, FILE_READ_SIZE);
char *filebuf = vstr->buf;
mp_uint_t actualsize;
mp_uint_t totalsize = 0;
static const TCHAR *path_relative;

if(isLittleFs(file_path))
{
vfs_lfs_struct_t* littlefs = lookup_path_littlefs(file_path, &path_relative);
if (littlefs == NULL) {
return NULL;
}

xSemaphoreTake(littlefs->mutex, portMAX_DELAY);

lfs_file_t fp;
int res = lfs_file_open(&littlefs->lfs, &fp, path_relative, LFS_O_RDONLY);
if(res < LFS_ERR_OK)
{
return NULL;
}

while (true) {
actualsize = lfs_file_read(&littlefs->lfs, &fp, filebuf, FILE_READ_SIZE);
if (actualsize < LFS_ERR_OK) {
return NULL;
}
totalsize += actualsize;
if (actualsize < FILE_READ_SIZE) {
break;
} else {
filebuf = vstr_extend(vstr, FILE_READ_SIZE);
}
}
lfs_file_close(&littlefs->lfs, &fp);

xSemaphoreGive(littlefs->mutex);

}
else
{
FATFS *fs = lookup_path_fatfs(file_path, &path_relative);
if (fs == NULL) {
return NULL;
}
FIL fp;
FRESULT res = f_open(fs, &fp, path_relative, FA_READ);
if (res != FR_OK) {
return NULL;
}

while (true) {
FRESULT res = f_read(&fp, filebuf, FILE_READ_SIZE, (UINT *)&actualsize);
if (res != FR_OK) {
f_close(&fp);
return NULL;
}
totalsize += actualsize;
if (actualsize < FILE_READ_SIZE) {
break;
} else {
filebuf = vstr_extend(vstr, FILE_READ_SIZE);
}
}
f_close(&fp);
}

vstr->len = totalsize;
vstr_null_terminated_str(vstr);
return vstr->buf;
}

static void wlan_init_wlan_recover_params(void)
{
Expand Down
117 changes: 117 additions & 0 deletions esp32/util/pycom_general_util.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright (c) 2019, 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
*/

#include <string.h>

#include "freertos/FreeRTOS.h"

#include "py/mpconfig.h"
#include "py/runtime.h"
#include "mptask.h"
#include "pycom_general_util.h"


/******************************************************************************
DEFINE CONSTANTS
******************************************************************************/
#define FILE_READ_SIZE 256

/******************************************************************************
DEFINE PUBLIC FUNCTIONS
******************************************************************************/
char *pycom_util_read_file (const char *file_path, vstr_t *vstr) {
vstr_init(vstr, FILE_READ_SIZE);
char *filebuf = vstr->buf;
mp_uint_t actualsize;
mp_uint_t totalsize = 0;
static const TCHAR *path_relative;
// THis is needed to be able to clean the VSTR if any error occurred
bool error = false;

if(isLittleFs(file_path)) {

vfs_lfs_struct_t* littlefs = lookup_path_littlefs(file_path, &path_relative);
if (littlefs == NULL) {
error = true;
}
else {

lfs_file_t fp;

xSemaphoreTake(littlefs->mutex, portMAX_DELAY);

int res = lfs_file_open(&littlefs->lfs, &fp, path_relative, LFS_O_RDONLY);
if(res < LFS_ERR_OK) {
error = true;
}
else {
while (error == false) {
actualsize = lfs_file_read(&littlefs->lfs, &fp, filebuf, FILE_READ_SIZE);
if (actualsize < LFS_ERR_OK) {
error = true;
}
else {
totalsize += actualsize;
if (actualsize < FILE_READ_SIZE) {
break;
} else {
filebuf = vstr_extend(vstr, FILE_READ_SIZE);
}
}
}

lfs_file_close(&littlefs->lfs, &fp);
}

xSemaphoreGive(littlefs->mutex);
}
}
else
{
FATFS *fs = lookup_path_fatfs(file_path, &path_relative);
if (fs == NULL) {
error = true;
}
else {
FIL fp;
FRESULT res = f_open(fs, &fp, path_relative, FA_READ);
if (res != FR_OK) {
error = true;
}
else {
while (error == false) {
FRESULT res = f_read(&fp, filebuf, FILE_READ_SIZE, (UINT *)&actualsize);
if (res != FR_OK) {
f_close(&fp);
error = true;
}
else {
totalsize += actualsize;
if (actualsize < FILE_READ_SIZE) {
break;
} else {
filebuf = vstr_extend(vstr, FILE_READ_SIZE);
}
}
}
f_close(&fp);
}
}
}

if(error == true) {
vstr_clear(vstr);
return NULL;
}
else {
vstr->len = totalsize;
vstr_null_terminated_str(vstr);
return vstr->buf;
}
}
Loading