diff --git a/drivers/sx127x/sx1272/sx1272.c b/drivers/sx127x/sx1272/sx1272.c index b78bae1465..29a8961643 100644 --- a/drivers/sx127x/sx1272/sx1272.c +++ b/drivers/sx127x/sx1272/sx1272.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/drivers/sx127x/sx1276/sx1276.c b/drivers/sx127x/sx1276/sx1276.c index 870c4abae1..87d9064ddd 100755 --- a/drivers/sx127x/sx1276/sx1276.c +++ b/drivers/sx127x/sx1276/sx1276.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/drivers/sx1308/sx1308-config.h b/drivers/sx1308/sx1308-config.h index e2be4ee6d6..3cf3814ffd 100644 --- a/drivers/sx1308/sx1308-config.h +++ b/drivers/sx1308/sx1308-config.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/drivers/sx1308/sx1308-spi.c b/drivers/sx1308/sx1308-spi.c index 96deabd83d..4650a8b010 100644 --- a/drivers/sx1308/sx1308-spi.c +++ b/drivers/sx1308/sx1308-spi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -9,7 +9,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2018, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/drivers/sx1308/sx1308-spi.h b/drivers/sx1308/sx1308-spi.h index b8ec2f9949..fd325e9687 100644 --- a/drivers/sx1308/sx1308-spi.h +++ b/drivers/sx1308/sx1308-spi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -9,7 +9,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2018, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/drivers/sx1308/sx1308.c b/drivers/sx1308/sx1308.c index 75ffb8e76a..8930ebb59e 100644 --- a/drivers/sx1308/sx1308.c +++ b/drivers/sx1308/sx1308.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/drivers/sx1308/sx1308.h b/drivers/sx1308/sx1308.h index 898863d360..5cdfa48cf1 100644 --- a/drivers/sx1308/sx1308.h +++ b/drivers/sx1308/sx1308.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -9,7 +9,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2018, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/Makefile b/esp32/Makefile index 5826d20992..3e475b7132 100644 --- a/esp32/Makefile +++ b/esp32/Makefile @@ -1,5 +1,5 @@ # -# Copyright © 2020, Pycom Limited. +# Copyright © 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/app_sys_evt.h b/esp32/app_sys_evt.h index 849e109dbb..00b00441be 100644 --- a/esp32/app_sys_evt.h +++ b/esp32/app_sys_evt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/application.mk b/esp32/application.mk index 299e96f87b..189a98b231 100644 --- a/esp32/application.mk +++ b/esp32/application.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/boards/FIPY/mpconfigboard.h b/esp32/boards/FIPY/mpconfigboard.h index 13cd4b120f..8a39ab9f29 100644 --- a/esp32/boards/FIPY/mpconfigboard.h +++ b/esp32/boards/FIPY/mpconfigboard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/boards/GPY/mpconfigboard.h b/esp32/boards/GPY/mpconfigboard.h index b53c2c8e89..6f7d9078aa 100644 --- a/esp32/boards/GPY/mpconfigboard.h +++ b/esp32/boards/GPY/mpconfigboard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/boards/LOPY/mpconfigboard.h b/esp32/boards/LOPY/mpconfigboard.h index e07d3d658d..48b1541d3f 100644 --- a/esp32/boards/LOPY/mpconfigboard.h +++ b/esp32/boards/LOPY/mpconfigboard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/boards/LOPY4/mpconfigboard.h b/esp32/boards/LOPY4/mpconfigboard.h index 95b835feda..bc8fab3252 100644 --- a/esp32/boards/LOPY4/mpconfigboard.h +++ b/esp32/boards/LOPY4/mpconfigboard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/boards/SIPY/mpconfigboard.h b/esp32/boards/SIPY/mpconfigboard.h index 229ea22d4b..799f142521 100644 --- a/esp32/boards/SIPY/mpconfigboard.h +++ b/esp32/boards/SIPY/mpconfigboard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/boards/WIPY/mpconfigboard.h b/esp32/boards/WIPY/mpconfigboard.h index 5a37216506..6449424156 100644 --- a/esp32/boards/WIPY/mpconfigboard.h +++ b/esp32/boards/WIPY/mpconfigboard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/boards/esp32_prefix.c b/esp32/boards/esp32_prefix.c index 206dd7b701..eba76268d0 100644 --- a/esp32/boards/esp32_prefix.c +++ b/esp32/boards/esp32_prefix.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/boards/make-pins.py b/esp32/boards/make-pins.py index df11593d31..69749aff7b 100644 --- a/esp32/boards/make-pins.py +++ b/esp32/boards/make-pins.py @@ -2,7 +2,7 @@ # This file is derived from the MicroPython project, http://micropython.org/ # -# Copyright (c) 2020, Pycom Limited and its licensors. +# Copyright (c) 2021, Pycom Limited and its licensors. # # 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 diff --git a/esp32/bootloader/bootmgr.c b/esp32/bootloader/bootmgr.c index 2db85adddd..233a513eb1 100644 --- a/esp32/bootloader/bootmgr.c +++ b/esp32/bootloader/bootmgr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/bootloader/bootmgr.h b/esp32/bootloader/bootmgr.h index 6b1877688d..b84acf6796 100644 --- a/esp32/bootloader/bootmgr.h +++ b/esp32/bootloader/bootmgr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/bootloader/mperror.c b/esp32/bootloader/mperror.c index d11795cf6d..c7dc6786b5 100644 --- a/esp32/bootloader/mperror.c +++ b/esp32/bootloader/mperror.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/fatfs/src/drivers/sd_diskio.c b/esp32/fatfs/src/drivers/sd_diskio.c index 3bd90b2c41..3220f4a9c7 100644 --- a/esp32/fatfs/src/drivers/sd_diskio.c +++ b/esp32/fatfs/src/drivers/sd_diskio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/fatfs/src/drivers/sd_diskio.h b/esp32/fatfs/src/drivers/sd_diskio.h index 0c1d012da2..09bc7ea0cb 100644 --- a/esp32/fatfs/src/drivers/sd_diskio.h +++ b/esp32/fatfs/src/drivers/sd_diskio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/frozen/LTE/sqnsbrz.py b/esp32/frozen/LTE/sqnsbrz.py index 0755c2c8a1..147e42caff 100644 --- a/esp32/frozen/LTE/sqnsbrz.py +++ b/esp32/frozen/LTE/sqnsbrz.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/frozen/LTE/sqnsupgrade.py b/esp32/frozen/LTE/sqnsupgrade.py index 2aa6a49f2c..068200d6d4 100644 --- a/esp32/frozen/LTE/sqnsupgrade.py +++ b/esp32/frozen/LTE/sqnsupgrade.py @@ -1,7 +1,7 @@ #!/usr/bin/env python VERSION = "1.2.6" -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/frozen/Pybytes/_OTA.py b/esp32/frozen/Pybytes/_OTA.py index a1391035c3..48f8a1aac1 100644 --- a/esp32/frozen/Pybytes/_OTA.py +++ b/esp32/frozen/Pybytes/_OTA.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -63,10 +63,12 @@ def get_update_manifest(self, fwtype=None, token=None): wmac = hexlify(machine.unique_id()).decode('ascii') if fwtype == 'pymesh': request_template = "manifest.json?current_ver={}&sysname={}&token={}&ota_slot={}&wmac={}&fwtype={}¤t_fwtype={}" - req = request_template.format(current_version, sysname, token, hex(pycom.ota_slot()), wmac.upper(), fwtype, 'pymesh' if hasattr(os.uname(),'pymesh') else 'pybytes') + current_fwtype = 'pymesh' if hasattr(os.uname(), 'pymesh') else 'pybytes' + req = request_template.format(current_version, sysname, token, hex(pycom.ota_slot()), wmac.upper(), fwtype, current_fwtype) elif fwtype == 'pygate': request_template = "manifest.json?current_ver={}&sysname={}&ota_slot={}&wmac={}&fwtype={}¤t_fwtype={}" - req = request_template.format(current_version, sysname, hex(pycom.ota_slot()), wmac.upper(), fwtype, 'pygate' if hasattr(os.uname(),'pygate') else 'pybytes') + current_fwtype = 'pygate' if hasattr(os.uname(), 'pygate') else 'pybytes' + req = request_template.format(current_version, sysname, hex(pycom.ota_slot()), wmac.upper(), fwtype, current_fwtype) else: request_template = "manifest.json?current_ver={}&sysname={}&wmac={}&ota_slot={}" req = request_template.format(current_version, sysname, wmac, hex(pycom.ota_slot())) diff --git a/esp32/frozen/Pybytes/_coap.py b/esp32/frozen/Pybytes/_coap.py index 234fccd3ac..cbd6cbeb6f 100644 --- a/esp32/frozen/Pybytes/_coap.py +++ b/esp32/frozen/Pybytes/_coap.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_flash_control_OTA.py b/esp32/frozen/Pybytes/_flash_control_OTA.py index 22b195112f..78682f2ba2 100644 --- a/esp32/frozen/Pybytes/_flash_control_OTA.py +++ b/esp32/frozen/Pybytes/_flash_control_OTA.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -17,10 +17,20 @@ class FCOTA: def __init__(self): pass + def is_folder(self, name): + try: + os.listdir(name) + return True + except: + return False + + def is_file(self, name): + return not self.is_folder(name) + def update_file_content(self, path, newContent): print_debug(2, 'Updating file [{}]'.format(path)) - if '.' in path: + if self.is_file(path): listfDir = path.split('/') currentPath = '/' for value in listfDir: @@ -34,7 +44,7 @@ def update_file_content(self, path, newContent): # check if dir exists if value not in parentList: # create dir - if '.' in currentPath: + if self.is_file(currentPath): continue os.mkdir(currentPath) @@ -52,7 +62,7 @@ def update_file_content(self, path, newContent): def delete_file(self, path): print_debug(2, 'FCOTA deleting file [{}]'.format(path)) try: - if ('.' in path): + if self.is_file(path): os.remove(path) else: targetedFiles = [] @@ -67,7 +77,7 @@ def delete_file(self, path): while maxDepth >= 0: for elem in targetedFiles: if elem.count('/') == maxDepth: - if '.' in elem: + if self.is_file(elem): os.remove(elem) else: os.rmdir(elem) @@ -87,7 +97,7 @@ def convert_bytes(self, num): def get_file_size(self, path): print_debug(2, 'FCOTA getting file infos [{}]'.format(path)) - if '.' in path: + if self.is_file(path): fileInfo = os.stat(path) print_debug(2, 'printing fileInfo tupple: ' + str(fileInfo)) return self.convert_bytes(fileInfo[6]) @@ -96,7 +106,7 @@ def get_file_size(self, path): def get_file_content(self, path): print_debug(2, 'FCOTA reading file [{}]'.format(path)) - if '.' in path: + if self.is_file(path): f = open(path, 'r') content = f.read() f.close() @@ -113,7 +123,7 @@ def get_flash_hierarchy(self): hierarchy = os.listdir() folders = [] for elem in hierarchy: - if '.' not in elem: + if self.is_folder(elem): folders.append(elem) while len(folders) > 0: @@ -130,7 +140,7 @@ def get_flash_hierarchy(self): path = folders[i] + '/' + subFolders[j] hierarchy.append(path) - if '.' not in path: + if self.is_folder(path): foldersToCheck.append(path) j += 1 diff --git a/esp32/frozen/Pybytes/_main_pybytes.py b/esp32/frozen/Pybytes/_main_pybytes.py index f89ab25054..668ddd0e76 100644 --- a/esp32/frozen/Pybytes/_main_pybytes.py +++ b/esp32/frozen/Pybytes/_main_pybytes.py @@ -1,6 +1,6 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -96,4 +96,4 @@ # def custom_print(params): # print("Custom method called") # return [255, 20] - # pybytes.add_custom_method(0, custom_print) + # pybytes.add_custom_method(0, custom_print) \ No newline at end of file diff --git a/esp32/frozen/Pybytes/_mqtt.py b/esp32/frozen/Pybytes/_mqtt.py index 89be0d3f73..c1d5060025 100644 --- a/esp32/frozen/Pybytes/_mqtt.py +++ b/esp32/frozen/Pybytes/_mqtt.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_mqtt_core.py b/esp32/frozen/Pybytes/_mqtt_core.py index 80da83bf98..d5f6ad1b23 100644 --- a/esp32/frozen/Pybytes/_mqtt_core.py +++ b/esp32/frozen/Pybytes/_mqtt_core.py @@ -2,7 +2,7 @@ umqtt is a simple MQTT client for MicroPython. Original code: https://github.com/micropython/micropython-lib/tree/master/umqtt.simple -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_msg_handl.py b/esp32/frozen/Pybytes/_msg_handl.py index a1b200587d..d045d239c9 100644 --- a/esp32/frozen/Pybytes/_msg_handl.py +++ b/esp32/frozen/Pybytes/_msg_handl.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -31,6 +31,7 @@ def __init__( receive_timeout=3000, reconnectMethod=None ): + print_debug(5, 'starting new MsgHandler') self._host = "" self._port = -1 self._sock = None @@ -152,7 +153,8 @@ def _receive_packet(self): try: self._sock.setblocking(False) msg_type = self._sock.recv(1) - except socket.error: + except socket.error as err: + print_debug(2, '_receive_packet() socket error: {}'.format(err)) self.disconnect() self.reconnectMethod() return False @@ -213,7 +215,7 @@ def _send_packet(self, packet): else: print_debug(2, 'Packet sent. (Length: %d)' % written) except socket.error as err: - print_debug(2, 'Socket send error {0}'.format(err)) + print_debug(2, '_send_packet() socket error {0}'.format(err)) return False return True if len(packet) == written else False diff --git a/esp32/frozen/Pybytes/_periodical_pin.py b/esp32/frozen/Pybytes/_periodical_pin.py index df2463e552..976c034378 100644 --- a/esp32/frozen/Pybytes/_periodical_pin.py +++ b/esp32/frozen/Pybytes/_periodical_pin.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_pybytes.py b/esp32/frozen/Pybytes/_pybytes.py index 4251baa2c6..14bb4b080b 100644 --- a/esp32/frozen/Pybytes/_pybytes.py +++ b/esp32/frozen/Pybytes/_pybytes.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -11,9 +11,10 @@ import time import pycom import sys +import gc from network import WLAN from binascii import hexlify, a2b_base64 -from machine import Timer, deepsleep, pin_sleep_wakeup, unique_id +from machine import Timer, deepsleep, pin_sleep_wakeup, unique_id, reset, RTC try: from periodical_pin import PeriodicalPin @@ -21,9 +22,9 @@ from _periodical_pin import PeriodicalPin try: - from pybytes_debug import print_debug + from pybytes_debug import print_debug, DEBUG except: - from _pybytes_debug import print_debug + from _pybytes_debug import print_debug, DEBUG try: from pybytes_config_reader import PybytesConfigReader @@ -36,7 +37,7 @@ class Pybytes: WAKEUP_ALL_LOW = const(0) # noqa: F821 WAKEUP_ANY_HIGH = const(1) # noqa: F821 - def __init__(self, config, activation=False, autoconnect=False): + def __init__(self, config, activation=False, autoconnect=False, user_callback=None): self.__frozen = globals().get('__name__') == '_pybytes' self.__activation = activation self.__custom_message_callback = None @@ -45,11 +46,15 @@ def __init__(self, config, activation=False, autoconnect=False): self.__smart_config = False self.__conf = {} self.__pymesh = None + self.__user_callback = user_callback if not self.__activation: self.__conf = config self.__conf_reader = PybytesConfigReader(config) pycom.wifi_on_boot(False, True) + if pycom.lte_modem_en_on_boot(): + pycom.lte_modem_en_on_boot(False) + reset() self.__check_dump_ca() self.__create_pybytes_connection(self.__conf) @@ -66,7 +71,7 @@ def __create_pybytes_connection(self, conf): except: from _pybytes_connection import PybytesConnection - self.__pybytes_connection = PybytesConnection(conf, self.__recv_message) + self.__pybytes_connection = PybytesConnection(conf, self.__recv_message, user_callback=self.__user_callback) def __check_config(self): try: @@ -155,9 +160,9 @@ def send_node_signal(self, signal_number, value, token): topic = 'br/{}'.format(token) self.__pybytes_connection.__pybytes_protocol.send_pybytes_custom_method_values(signal_number, [value], topic) - def send_signal(self, signal_number, value): + def send_signal(self, signal_number, value, nomesh=False): self.__check_init() - if self.__pymesh: + if self.__pymesh and not nomesh: self.__pymesh.unpack_pymesh_message(signal_number, value) else: self.__pybytes_connection.__pybytes_protocol.send_pybytes_custom_method_values(signal_number, [value]) @@ -280,11 +285,52 @@ def connect(self): from _pybytes_pymesh_config import PybytesPymeshConfig self.__pymesh = PybytesPymeshConfig(self) self.__pymesh.pymesh_init() + elif hasattr(os.uname(), 'pygate') and self.get_config('gateway'): + # PYGATE FIRMWARE VERSION + buf = None + try: + from machine import pygate_init, pygate_debug_level + with open('/flash/pybytes_pygate_config.json','r') as fp: + buf = fp.read() + except Exception as e: + print_debug(5, e) + print('pybytes_pygate_config.json file is missing or has wrong format') + return + + try: + print('Syncing RTC via ntp...', end='') + rtc = RTC() + if not rtc.synced(): + rtc.ntp_sync(server="pool.ntp.org") + to_s = 20 + while not rtc.synced() and to_s > 0: + print('.', end='') + time.sleep(1) + to_s -= 1 + if not rtc.synced(): + print('RTC sync failed. Gateway will not work') + return + print(" RTC synced") + + except Exception as e: + print_debug(5, e) + print('RTC sync failed. Gateway will not work') + return + + try: + gc.collect() + if not DEBUG: + pygate_debug_level(0) + pygate_init(buf) + except Exception as e: + print('Pygate failed to start', e) + return else: print('ERROR! Could not connect to Pybytes!') except Exception as ex: print("Unable to connect to Pybytes: {}".format(ex)) + sys.print_exception(ex) def write_config(self, file='/flash/pybytes_config.json', silent=False): try: @@ -428,6 +474,12 @@ def deepsleep(self, ms, pins=None, mode=None, enable_pull=None): self.disconnect() deepsleep(ms) + def message_queue_len(self): + try: + return len(pybytes.__pybytes_connection.__connection.__mqtt._msgHandler._output_queue) + except: + return None + def dump_ca(self, ca_file='/flash/cert/pycom-ca.pem'): try: from _pybytes_ca import PYBYTES_CA diff --git a/esp32/frozen/Pybytes/_pybytes_ca.py b/esp32/frozen/Pybytes/_pybytes_ca.py index 292d045718..c9a91548fd 100644 --- a/esp32/frozen/Pybytes/_pybytes_ca.py +++ b/esp32/frozen/Pybytes/_pybytes_ca.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_pybytes_config.py b/esp32/frozen/Pybytes/_pybytes_config.py index 3b980a02a9..f80ed6aa7b 100644 --- a/esp32/frozen/Pybytes/_pybytes_config.py +++ b/esp32/frozen/Pybytes/_pybytes_config.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_pybytes_config_reader.py b/esp32/frozen/Pybytes/_pybytes_config_reader.py index bb13ab1842..43b252d426 100644 --- a/esp32/frozen/Pybytes/_pybytes_config_reader.py +++ b/esp32/frozen/Pybytes/_pybytes_config_reader.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_pybytes_connection.py b/esp32/frozen/Pybytes/_pybytes_connection.py index 6ddc2d68c4..d24fe85c25 100644 --- a/esp32/frozen/Pybytes/_pybytes_connection.py +++ b/esp32/frozen/Pybytes/_pybytes_connection.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -46,7 +46,7 @@ class PybytesConnection: - def __init__(self, config, message_callback): + def __init__(self, config, message_callback, user_callback=None): if config is not None: self.__conf = config self.__conf_reader = PybytesConfigReader(config) @@ -61,7 +61,8 @@ def __init__(self, config, message_callback): self.__mqtt_download_topic = "d" + self.__device_id self.__mqtt_upload_topic = "u" + self.__device_id self.__pybytes_protocol = PybytesProtocol( - config, message_callback, pybytes_connection=self + config, message_callback, pybytes_connection=self, + user_callback=user_callback ) self.__connection = None self.__connection_status = constants.__CONNECTION_STATUS_DISCONNECTED diff --git a/esp32/frozen/Pybytes/_pybytes_constants.py b/esp32/frozen/Pybytes/_pybytes_constants.py index 8ae4058530..8d2efc54b1 100644 --- a/esp32/frozen/Pybytes/_pybytes_constants.py +++ b/esp32/frozen/Pybytes/_pybytes_constants.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -75,6 +75,7 @@ class constants: __TYPE_PYMESH = 0x0D __TYPE_PYBYTES = 0x0E __TYPE_ML = 0x0F + __TYPE_USER = 0x08 __PYBYTES_PROTOCOL = ">B%ds" __PYBYTES_PROTOCOL_PING = ">B" __PYBYTES_INTERNAL_PROTOCOL = ">BBH" @@ -100,6 +101,8 @@ class constants: __FCOTA_PING = 0x03 __FCOTA_COMMAND_FILE_DELETE = 0x04 __FCOTA_COMMAND_FILE_UPDATE_NO_RESET = 0x05 + __FCOTA_COMMAND_GATEWAY_DEPLOY = 0x06 + __FCOTA_COMMAND_TOGGLE_GATEWAY = 0x07 __DEVICE_TYPE_WIPY = 0x00 __DEVICE_TYPE_LOPY = 0x01 diff --git a/esp32/frozen/Pybytes/_pybytes_debug.py b/esp32/frozen/Pybytes/_pybytes_debug.py index a8be1ddbaf..36ad935fe4 100644 --- a/esp32/frozen/Pybytes/_pybytes_debug.py +++ b/esp32/frozen/Pybytes/_pybytes_debug.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -8,6 +8,8 @@ import os import pycom # pylint: disable=import-error +import _thread +import time from machine import RTC from time import timezone @@ -22,7 +24,11 @@ def print_debug(level, msg): """Print log messages into console.""" if DEBUG is not None and level <= DEBUG: - print(msg) + print("[{:15.3f}] [{:10d}] {}".format( + time.ticks_ms() / 1000, + _thread.get_ident(), + msg + )) def print_debug_local(level, msg): diff --git a/esp32/frozen/Pybytes/_pybytes_library.py b/esp32/frozen/Pybytes/_pybytes_library.py index 78ee000abc..6cc5d040c5 100644 --- a/esp32/frozen/Pybytes/_pybytes_library.py +++ b/esp32/frozen/Pybytes/_pybytes_library.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -94,10 +94,13 @@ def pack_info_message(self, releaseVersion=None): if hasattr(os.uname(), 'pymesh'): body.append(constants.__FWTYPE_PYMESH) + print_debug(4, "pymesh") elif hasattr(os.uname(), 'pygate'): body.append(constants.__FWTYPE_PYGATE) + print_debug(4, "pygate") else: body.append(constants.__FWTYPE_DEFAULT) + print_debug(4, "pybytes") return self.__pack_message(constants.__TYPE_INFO, body) diff --git a/esp32/frozen/Pybytes/_pybytes_machine_learning.py b/esp32/frozen/Pybytes/_pybytes_machine_learning.py index 5c1fce6626..3c0131da00 100644 --- a/esp32/frozen/Pybytes/_pybytes_machine_learning.py +++ b/esp32/frozen/Pybytes/_pybytes_machine_learning.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_pybytes_main.py b/esp32/frozen/Pybytes/_pybytes_main.py index f89ab25054..2afd232a9b 100644 --- a/esp32/frozen/Pybytes/_pybytes_main.py +++ b/esp32/frozen/Pybytes/_pybytes_main.py @@ -1,6 +1,6 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_pybytes_protocol.py b/esp32/frozen/Pybytes/_pybytes_protocol.py index f7d1ba41ed..2628b4d070 100644 --- a/esp32/frozen/Pybytes/_pybytes_protocol.py +++ b/esp32/frozen/Pybytes/_pybytes_protocol.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 @@ -50,6 +50,12 @@ from pybytes_debug import print_debug except: from _pybytes_debug import print_debug + +try: + from pybytes_pyconfig import Pyconfig +except: + from _pybytes_pyconfig import Pyconfig + try: import urequest except: @@ -64,6 +70,7 @@ from network import Coap import os +import sys import _thread import time import struct @@ -73,7 +80,7 @@ class PybytesProtocol: - def __init__(self, config, message_callback, pybytes_connection): + def __init__(self, config, message_callback, pybytes_connection, user_callback=None): self.__conf = config self.__conf_reader = PybytesConfigReader(config) self.__thread_stack_size = 8192 @@ -84,6 +91,7 @@ def __init__(self, config, message_callback, pybytes_connection): self.__pybytes_library = PybytesLibrary( pybytes_connection=pybytes_connection, pybytes_protocol=self) self.__user_message_callback = message_callback + self.__user_callback = user_callback self.__pins = {} self.__pin_modes = {} self.__custom_methods = {} @@ -150,19 +158,28 @@ def __check_lora_messages(self): def __process_recv_message(self, message): print_debug(5, "This is PybytesProtocol.__process_recv_message()") - if message.payload: network_type, message_type, body = self.__pybytes_library.unpack_message(message.payload) + print_debug(99,'Message: network_type={}, message_type={}, body={}'.format(network_type, message_type, body)) else: # for lora messages network_type, message_type, body = self.__pybytes_library.unpack_message(message) + print_debug(99,'Message: network_type={}, message_type={}, body={}'.format(network_type, message_type, body)) if self.__user_message_callback is not None: + if (message_type == constants.__TYPE_PING): self.send_ping_message() elif message_type == constants.__TYPE_PONG and self.__conf.get('connection_watchdog', True): self.__pybytes_connection.__wifi_lte_watchdog.feed() + print_debug(5, 'message type is PONG, feed watchdog') + + elif (message_type == constants.__TYPE_USER and self.__user_callback is not None): + try: + self.__user_callback(body) + except Exception as ex: + sys.print_exception(ex) elif (message_type == constants.__TYPE_INFO): self.send_info_message() @@ -184,9 +201,10 @@ def __process_recv_message(self, message): self.deploy_new_release(body) elif (message_type == constants.__TYPE_DEVICE_NETWORK_DEPLOY): + # allows for WiFi or LTE, no need to specify ssid/password as we're already connected ota = WiFiOTA( - self.__conf['wifi']['ssid'], - self.__conf['wifi']['password'], + None, + None, self.__conf['ota_server']['domain'], self.__conf['ota_server']['port'] ) @@ -314,6 +332,21 @@ def __process_recv_message(self, message): else: self.send_fcota_ping('deletion failed!') + elif (command == constants.__FCOTA_COMMAND_GATEWAY_DEPLOY): + self.deploy_gateway() + + elif (command == constants.__FCOTA_COMMAND_TOGGLE_GATEWAY): + bodyString = body[1:len(body)].decode() + try: + self.toggleGateway( + True if bodyString == 'true' else False + ) + machine.reset() + except Exception as ex: + print( + 'error toggleGateway({}):{}'.format(bodyString, ex) + ) + else: print_debug(2, "Unknown FCOTA command received") @@ -836,3 +869,41 @@ def deploy_new_release(self, body): self.update_network_config(letResp) self.update_firmware(letResp, applicationID, fw_type=fwtype) machine.reset() + + def deploy_gateway(self): + print_debug(0, 'deploying gateway...') + pyconfig_url = '{}://{}'.format( + constants.__DEFAULT_PYCONFIG_PROTOCOL, + constants.__DEFAULT_PYCONFIG_DOMAIN + ) + device_id = self.__conf['device_id'] + pyconfig = Pyconfig(pyconfig_url, device_id) + pygate_configurations = pyconfig.get_gateway_config() + + print_debug(5, pygate_configurations) + + json_pygate_string = ujson.dumps(pygate_configurations) + self.__FCOTA.update_file_content( + '/flash/pybytes_pygate_config.json', + json_pygate_string + ) + self.toggleGateway(True) + + if not hasattr(os.uname(), 'pygate'): + print_debug(0, 'OTA deploy Pygate Firmware') + ota = WiFiOTA( + self.__conf['wifi']['ssid'], + self.__conf['wifi']['password'], + self.__conf['ota_server']['domain'], + self.__conf['ota_server']['port'] + ) + ota.update(fwtype='pygate', token=device_id) + machine.reset() + + def toggleGateway(self, value): + self.__conf['gateway'] = value + json_string = ujson.dumps(self.__conf) + self.__FCOTA.update_file_content( + '/flash/pybytes_config.json', + json_string + ) diff --git a/esp32/frozen/Pybytes/_pybytes_pyconfig.py b/esp32/frozen/Pybytes/_pybytes_pyconfig.py new file mode 100644 index 0000000000..fa41bb9189 --- /dev/null +++ b/esp32/frozen/Pybytes/_pybytes_pyconfig.py @@ -0,0 +1,44 @@ +''' +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 +''' +try: + from pybytes_debug import print_debug +except: + from _pybytes_debug import print_debug + +try: + import urequest +except: + import _urequest as urequest + + +class Pyconfig: + """ + A class used to represent communication with pybytes + all pybytes communication should happen with one rest api + called pyconfig microServices + + + """ + + def __init__(self, url, device_id): + self.base_url = url + self.device_id = device_id + + def get_gateway_config(self): + target_url = '{}/device/gateway/{}'.format(self.base_url, self.device_id) + headers = { + 'content-type': 'application/json' + } + try: + request = urequest.get(target_url, headers=headers) + configurations = request.json() + request.close() + print_debug(6, "Response Details: {}".format(configurations)) + return configurations + except Exception as ex: + print_debug(1, "error while calling {}!: {}".format(target_url, ex)) diff --git a/esp32/frozen/Pybytes/_pybytes_pymesh_config.py b/esp32/frozen/Pybytes/_pybytes_pymesh_config.py index e87bb71880..895622f1e6 100644 --- a/esp32/frozen/Pybytes/_pybytes_pymesh_config.py +++ b/esp32/frozen/Pybytes/_pybytes_pymesh_config.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/frozen/Pybytes/_terminal.py b/esp32/frozen/Pybytes/_terminal.py index 35f0b82ec8..a5fa9ee664 100644 --- a/esp32/frozen/Pybytes/_terminal.py +++ b/esp32/frozen/Pybytes/_terminal.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2020, Pycom Limited. +Copyright (c) 2021, 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 diff --git a/esp32/ftp/ftp.c b/esp32/ftp/ftp.c index 2ea6efbdbb..4da2114497 100644 --- a/esp32/ftp/ftp.c +++ b/esp32/ftp/ftp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/ftp/ftp.h b/esp32/ftp/ftp.h index 39e9d4658c..4f7197da51 100644 --- a/esp32/ftp/ftp.h +++ b/esp32/ftp/ftp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/ftp/updater.c b/esp32/ftp/updater.c index b106a2c562..54c2a34435 100644 --- a/esp32/ftp/updater.c +++ b/esp32/ftp/updater.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/ftp/updater.h b/esp32/ftp/updater.h index 1cfa832a95..2c30249773 100644 --- a/esp32/ftp/updater.h +++ b/esp32/ftp/updater.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/hal/esp32_mphal.c b/esp32/hal/esp32_mphal.c index cdca99d8b5..78f8324fdc 100644 --- a/esp32/hal/esp32_mphal.c +++ b/esp32/hal/esp32_mphal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/hal/esp32_mphal.h b/esp32/hal/esp32_mphal.h index 8958e391ed..a025aef1d0 100644 --- a/esp32/hal/esp32_mphal.h +++ b/esp32/hal/esp32_mphal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/littlefs/sflash_diskio_littlefs.c b/esp32/littlefs/sflash_diskio_littlefs.c index f386cf47f4..ea61ada52c 100644 --- a/esp32/littlefs/sflash_diskio_littlefs.c +++ b/esp32/littlefs/sflash_diskio_littlefs.c @@ -45,7 +45,7 @@ struct lfs_config lfscfg = .prog_size = SFLASH_BLOCK_SIZE, .block_size = SFLASH_BLOCK_SIZE, .block_count = 0, // To be initialized according to the flash size of the chip - .block_cycles = 0, // No block-level wear-leveling + .block_cycles = 100, // Enable block-level wear-leveling /* Current implementation of littlefs_read/prog/erase/sync() functions only operates with * full blocks, always the starting address of the block is passed to the driver. * This helps on the Power-loss resilient behavior of LittleFS, with this approach the File System will not be corrupted by corruption of a single file/block diff --git a/esp32/littlefs/vfs_littlefs_file.c b/esp32/littlefs/vfs_littlefs_file.c index aa7a90edb5..4003521325 100644 --- a/esp32/littlefs/vfs_littlefs_file.c +++ b/esp32/littlefs/vfs_littlefs_file.c @@ -20,6 +20,7 @@ typedef struct _pyb_file_obj_t { vfs_lfs_struct_t* littlefs; struct lfs_file_config cfg; // Attributes of the file, e.g.: timestamp bool timestamp_update; // For requesting timestamp update when closing the file + bool opened; // Indicate whether the file is opened } pyb_file_obj_t; STATIC void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { @@ -31,6 +32,12 @@ STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (self->opened == false) { + // Return EINVAL just as FatFS if the file is not opened + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } + xSemaphoreTake(self->littlefs->mutex, portMAX_DELAY); lfs_ssize_t sz_out = lfs_file_read(&self->littlefs->lfs ,&self->fp, buf, size); xSemaphoreGive(self->littlefs->mutex); @@ -46,6 +53,12 @@ STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t siz pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (self->opened == false) { + // Return EINVAL just as FatFS if the file is not opened + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } + xSemaphoreTake(self->littlefs->mutex, portMAX_DELAY); lfs_ssize_t sz_out = lfs_file_write(&self->littlefs->lfs, &self->fp, buf, size); // Request timestamp update if file has been written successfully @@ -89,6 +102,12 @@ STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, } else if (request == MP_STREAM_FLUSH) { + if (self->opened == false) { + // Return EINVAL just as FatFS if the file is not opened + *errcode = MP_EINVAL; + return MP_STREAM_ERROR; + } + xSemaphoreTake(self->littlefs->mutex, portMAX_DELAY); int res = lfs_file_sync(&self->littlefs->lfs, &self->fp); xSemaphoreGive(self->littlefs->mutex); @@ -101,16 +120,21 @@ STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, } else if (request == MP_STREAM_CLOSE) { + if (self->opened == false) { + // Return 0 just as FatFs if the file is not opened + return 0; + } + xSemaphoreTake(self->littlefs->mutex, portMAX_DELAY); int res = littlefs_close_common_helper(&self->littlefs->lfs, &self->fp, &self->cfg, &self->timestamp_update); xSemaphoreGive(self->littlefs->mutex); + if (res < 0) { *errcode = littleFsErrorToErrno(res); return MP_STREAM_ERROR; } - // Free up the object so GC does not need to do that - m_del_obj(pyb_file_obj_t, self); + self->opened = false; // indicate a closed file return 0; } else { *errcode = MP_EINVAL; @@ -165,6 +189,7 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); o->base.type = type; o->timestamp_update = false; + o->opened = false; xSemaphoreTake(vfs->fs.littlefs.mutex, portMAX_DELAY); const char *fname = concat_with_cwd(&vfs->fs.littlefs, mp_obj_str_get_str(args[0].u_obj)); @@ -178,6 +203,7 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar } o->littlefs = &vfs->fs.littlefs; + o->opened = true; // File is opened successfully return MP_OBJ_FROM_PTR(o); } diff --git a/esp32/lora/board.c b/esp32/lora/board.c index 7a6c7f1bd9..d250be35b2 100644 --- a/esp32/lora/board.c +++ b/esp32/lora/board.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/board.h b/esp32/lora/board.h index fc4829f8b5..758967bf7d 100644 --- a/esp32/lora/board.h +++ b/esp32/lora/board.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/gpio-board.c b/esp32/lora/gpio-board.c index babbbcefdd..d2ea596fee 100644 --- a/esp32/lora/gpio-board.c +++ b/esp32/lora/gpio-board.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/gpio-board.h b/esp32/lora/gpio-board.h index a5d3577cea..1477fd053c 100644 --- a/esp32/lora/gpio-board.h +++ b/esp32/lora/gpio-board.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/ot-log.c b/esp32/lora/ot-log.c index d9de4a30e4..58a5e04713 100644 --- a/esp32/lora/ot-log.c +++ b/esp32/lora/ot-log.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/ot-log.h b/esp32/lora/ot-log.h index 678e92c9ec..5ca68d005f 100644 --- a/esp32/lora/ot-log.h +++ b/esp32/lora/ot-log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/ot-settings.c b/esp32/lora/ot-settings.c index 3948116791..25c95d53e9 100644 --- a/esp32/lora/ot-settings.c +++ b/esp32/lora/ot-settings.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/ot-settings.h b/esp32/lora/ot-settings.h index a367d41473..521979c831 100644 --- a/esp32/lora/ot-settings.h +++ b/esp32/lora/ot-settings.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/otplat_alarm.c b/esp32/lora/otplat_alarm.c index 9506db43e3..1f114a6d93 100644 --- a/esp32/lora/otplat_alarm.c +++ b/esp32/lora/otplat_alarm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/otplat_alarm.h b/esp32/lora/otplat_alarm.h index bdbfa6af59..ad9d9641bd 100644 --- a/esp32/lora/otplat_alarm.h +++ b/esp32/lora/otplat_alarm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/otplat_radio.c b/esp32/lora/otplat_radio.c index 365a6771a0..bbe3297429 100644 --- a/esp32/lora/otplat_radio.c +++ b/esp32/lora/otplat_radio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/otplat_radio.h b/esp32/lora/otplat_radio.h index f0baa82918..2f5f859305 100644 --- a/esp32/lora/otplat_radio.h +++ b/esp32/lora/otplat_radio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/lora/pinName-board.h b/esp32/lora/pinName-board.h index a50a67b1c3..4ff7e32474 100644 --- a/esp32/lora/pinName-board.h +++ b/esp32/lora/pinName-board.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/spi-board.c b/esp32/lora/spi-board.c index 27a7b6330a..61b51077a7 100644 --- a/esp32/lora/spi-board.c +++ b/esp32/lora/spi-board.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/spi-board.h b/esp32/lora/spi-board.h index 4c77ec4aa5..78241eb7e3 100644 --- a/esp32/lora/spi-board.h +++ b/esp32/lora/spi-board.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/timer-board.c b/esp32/lora/timer-board.c index 7c11b0e392..5ea025b796 100644 --- a/esp32/lora/timer-board.c +++ b/esp32/lora/timer-board.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lora/timer-board.h b/esp32/lora/timer-board.h index cde36de4fb..19c3cd8bd5 100644 --- a/esp32/lora/timer-board.h +++ b/esp32/lora/timer-board.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/lte/lteppp.c b/esp32/lte/lteppp.c index 01035c1d74..bb801adf05 100644 --- a/esp32/lte/lteppp.c +++ b/esp32/lte/lteppp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -117,8 +117,9 @@ static void lteppp_print_states(); DEFINE PUBLIC FUNCTIONS ******************************************************************************/ -void connect_lte_uart (void) { - MSG("\n"); +void connect_lte_uart (bool reconnect) { + MSG("connect_lte_uart\n"); + uart_driver_delete(LTE_UART_ID); // initialize the UART interface uart_config_t config; @@ -128,7 +129,8 @@ void connect_lte_uart (void) { config.stop_bits = UART_STOP_BITS_1; config.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS; config.rx_flow_ctrl_thresh = 64; - config.use_ref_tick = false; + // Use UART_SCLK_APB as originally use_ref_tick = false was used here + config.source_clk = UART_SCLK_APB; uart_param_config(LTE_UART_ID, &config); // configure the UART pins @@ -153,6 +155,11 @@ void connect_lte_uart (void) { uart_set_rts(LTE_UART_ID, false); + if (reconnect) { + uart_set_hw_flow_ctrl(LTE_UART_ID, UART_HW_FLOWCTRL_CTS_RTS, 64); + vTaskDelay(5); + } + xTaskCreatePinnedToCore(TASK_UART_EVT, "LTE_UART_EVT", 2048 / sizeof(StackType_t), NULL, 12, &xLTEUartEvtTaskHndl, 1); MSG("done\n"); @@ -481,7 +488,7 @@ static void TASK_LTE (void *pvParameters) { uint8_t at_trials = 0; static uint32_t thread_notification; - connect_lte_uart(); + connect_lte_uart(false); modem_init: MSG("modem_init\n"); diff --git a/esp32/lte/lteppp.h b/esp32/lte/lteppp.h index 64b260e80e..ea2350eec3 100644 --- a/esp32/lte/lteppp.h +++ b/esp32/lte/lteppp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -123,7 +123,7 @@ extern bool lteppp_wait_at_rsp (const char *expected_rsp, uint32_t timeout, bool lte_modem_conn_state_t lteppp_get_modem_conn_state(void); void lteppp_set_modem_conn_state(lte_modem_conn_state_t state); -extern void connect_lte_uart (void); +extern void connect_lte_uart (bool reconnect); extern bool ltepp_is_ppp_conn_up(void); diff --git a/esp32/main.c b/esp32/main.c index 5f921cf8f5..ae2c7c8b67 100644 --- a/esp32/main.c +++ b/esp32/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -173,7 +173,7 @@ void app_main(void) { micropy_lpwan_dio_pin_num = 23; micropy_lpwan_dio_pin = &pin_GPIO23; - mpTaskStack = malloc(MICROPY_TASK_STACK_SIZE_PSRAM); + mpTaskStack = heap_caps_malloc(MICROPY_TASK_STACK_SIZE_PSRAM, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); // create the MicroPython task mpTaskHandle = @@ -196,7 +196,7 @@ void app_main(void) { micropy_lpwan_dio_pin_num = 23; micropy_lpwan_dio_pin = &pin_GPIO23; - mpTaskStack = malloc(MICROPY_TASK_STACK_SIZE); + mpTaskStack = heap_caps_malloc(MICROPY_TASK_STACK_SIZE, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); // create the MicroPython task mpTaskHandle = diff --git a/esp32/mods/lwipsocket.c b/esp32/mods/lwipsocket.c index ebe5e70859..5bc5b977d9 100644 --- a/esp32/mods/lwipsocket.c +++ b/esp32/mods/lwipsocket.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/lwipsocket.h b/esp32/mods/lwipsocket.h index 08c5b30528..6beac8005b 100644 --- a/esp32/mods/lwipsocket.h +++ b/esp32/mods/lwipsocket.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machcan.c b/esp32/mods/machcan.c index 3715acb540..61c092aa25 100644 --- a/esp32/mods/machcan.c +++ b/esp32/mods/machcan.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machcan.h b/esp32/mods/machcan.h index 2b62acf5c5..afcb77bd37 100644 --- a/esp32/mods/machcan.h +++ b/esp32/mods/machcan.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machine_i2c.c b/esp32/mods/machine_i2c.c index a29c0492be..d060a06446 100644 --- a/esp32/mods/machine_i2c.c +++ b/esp32/mods/machine_i2c.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/machine_i2c.h b/esp32/mods/machine_i2c.h index 9762b88904..29dc7e931d 100644 --- a/esp32/mods/machine_i2c.h +++ b/esp32/mods/machine_i2c.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/machpin.c b/esp32/mods/machpin.c index ced3e65ef5..f01e69b059 100644 --- a/esp32/mods/machpin.c +++ b/esp32/mods/machpin.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/machpin.h b/esp32/mods/machpin.h index af432283c6..745c1356fc 100644 --- a/esp32/mods/machpin.h +++ b/esp32/mods/machpin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machpwm.c b/esp32/mods/machpwm.c index 323deb4f46..d7298ce096 100644 --- a/esp32/mods/machpwm.c +++ b/esp32/mods/machpwm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machpwm.h b/esp32/mods/machpwm.h index ea268c78c1..10e6d21afc 100644 --- a/esp32/mods/machpwm.h +++ b/esp32/mods/machpwm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machrmt.c b/esp32/mods/machrmt.c index 880f64b803..ee224b24d5 100644 --- a/esp32/mods/machrmt.c +++ b/esp32/mods/machrmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machrmt.h b/esp32/mods/machrmt.h index bfae12b30f..9053573f71 100644 --- a/esp32/mods/machrmt.h +++ b/esp32/mods/machrmt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machrtc.c b/esp32/mods/machrtc.c index f2a819b68b..e4f8335867 100644 --- a/esp32/mods/machrtc.c +++ b/esp32/mods/machrtc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -48,7 +48,6 @@ typedef struct _mach_rtc_obj_t { bool synced; } mach_rtc_obj_t; -static RTC_DATA_ATTR uint64_t delta_from_epoch_til_boot; static RTC_DATA_ATTR uint32_t rtc_user_mem_len; static RTC_DATA_ATTR uint8_t rtc_user_mem_data[MEM_USER_MAXLEN]; @@ -61,10 +60,10 @@ void rtc_init0(void) { void mach_rtc_set_us_since_epoch(uint64_t nowus) { struct timeval tv; - // store the packet timestamp - gettimeofday(&tv, NULL); - delta_from_epoch_til_boot = nowus - (uint64_t)((tv.tv_sec * 1000000ull) + tv.tv_usec); + tv.tv_usec = nowus % 1000000ull; + tv.tv_sec = nowus / 1000000ull; + settimeofday(&tv, NULL); } void mach_rtc_synced (void) { @@ -78,8 +77,9 @@ bool mach_is_rtc_synced (void) { uint64_t mach_rtc_get_us_since_epoch(void) { struct timeval tv; gettimeofday(&tv, NULL); - return (uint64_t)((tv.tv_sec * 1000000ull) + tv.tv_usec) + delta_from_epoch_til_boot; -}; + return (uint64_t)(tv.tv_sec * 1000000ull ) + (tv.tv_usec); + +} STATIC uint64_t mach_rtc_datetime_us(const mp_obj_t datetime) { timeutils_struct_time_t tm; @@ -132,8 +132,6 @@ STATIC void mach_rtc_datetime(const mp_obj_t datetime) { if (datetime != mp_const_none) { useconds = mach_rtc_datetime_us(datetime); mach_rtc_set_us_since_epoch(useconds); - } else { - mach_rtc_set_us_since_epoch(0); } } @@ -197,14 +195,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mach_rtc_init_obj, 1, mach_rtc_init); STATIC mp_obj_t mach_rtc_now (mp_obj_t self_in) { timeutils_struct_time_t tm; uint64_t useconds; + + useconds = mach_rtc_get_us_since_epoch(); - struct timeval now; - gettimeofday(&now, NULL); - - // get the time from the RTC - useconds = (now.tv_sec * 1000000ull ) + (now.tv_usec); timeutils_seconds_since_epoch_to_struct_time((useconds) / 1000000ull, &tm); - mp_obj_t tuple[8] = { mp_obj_new_int(tm.tm_year), mp_obj_new_int(tm.tm_mon), diff --git a/esp32/mods/machrtc.h b/esp32/mods/machrtc.h index 2f61ca6a76..a97ab92412 100644 --- a/esp32/mods/machrtc.h +++ b/esp32/mods/machrtc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machspi.c b/esp32/mods/machspi.c index 6ac7f81df0..9e005d5e65 100644 --- a/esp32/mods/machspi.c +++ b/esp32/mods/machspi.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/machspi.h b/esp32/mods/machspi.h index 73fa967d77..c913e869a7 100644 --- a/esp32/mods/machspi.h +++ b/esp32/mods/machspi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machtimer.c b/esp32/mods/machtimer.c index 03e2c902bc..d0db382f94 100644 --- a/esp32/mods/machtimer.c +++ b/esp32/mods/machtimer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machtimer.h b/esp32/mods/machtimer.h index e2ed094fb1..6024fc62ff 100644 --- a/esp32/mods/machtimer.h +++ b/esp32/mods/machtimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machtouch.h b/esp32/mods/machtouch.h index 0ad70ced7e..5f17b9952e 100644 --- a/esp32/mods/machtouch.h +++ b/esp32/mods/machtouch.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machuart.c b/esp32/mods/machuart.c index e92009c2a4..0c7a06dafe 100644 --- a/esp32/mods/machuart.c +++ b/esp32/mods/machuart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -456,7 +456,7 @@ STATIC mp_obj_t mach_uart_init_helper(mach_uart_obj_t *self, const mp_arg_val_t } STATIC const mp_arg_t mach_uart_init_args[] = { - { MP_QSTR_id, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_id, MP_ARG_INT, {.u_int = MACH_UART_1} }, { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 9600} }, { MP_QSTR_bits, MP_ARG_INT, {.u_int = 8} }, { MP_QSTR_parity, MP_ARG_OBJ, {.u_obj = mp_const_none} }, @@ -473,7 +473,7 @@ STATIC mp_obj_t mach_uart_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_arg_parse_all(n_args, all_args, &kw_args, MP_ARRAY_SIZE(args), mach_uart_init_args, args); // work out the uart id - uint uart_id = mp_obj_get_int(args[0].u_obj); + uint uart_id = args[0].u_int; #if defined(GPY) || defined(FIPY) if (uart_id > MACH_UART_1) { diff --git a/esp32/mods/machuart.h b/esp32/mods/machuart.h index f116a29414..9d573619be 100644 --- a/esp32/mods/machuart.h +++ b/esp32/mods/machuart.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machwdt.c b/esp32/mods/machwdt.c index ad4e165958..31dbe91392 100644 --- a/esp32/mods/machwdt.c +++ b/esp32/mods/machwdt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/machwdt.h b/esp32/mods/machwdt.h index 10f3a83cca..9e9c5ad40b 100644 --- a/esp32/mods/machwdt.h +++ b/esp32/mods/machwdt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index 8b8ae40d1d..f11c7d2622 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -1062,12 +1062,9 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ /// \class Bluetooth static mp_obj_t bt_init_helper(bt_obj_t *self, const mp_arg_val_t *args) { if (!self->init) { - if (!self->controller_active) { - esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - esp_bt_controller_init(&bt_cfg); - self->controller_active = true; - } + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); + esp_bt_controller_init(&bt_cfg); esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ESP_OK != esp_bluedroid_init()) { diff --git a/esp32/mods/modbt.h b/esp32/mods/modbt.h index 5c04a98f18..32a97f32b4 100644 --- a/esp32/mods/modbt.h +++ b/esp32/mods/modbt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modcoap.c b/esp32/mods/modcoap.c index cae166d61d..1157892f62 100644 --- a/esp32/mods/modcoap.c +++ b/esp32/mods/modcoap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -43,7 +43,6 @@ typedef struct mod_coap_resource_obj_s { coap_resource_t* coap_resource; struct mod_coap_resource_obj_s* next; uint8_t* value; - unsigned char* uri; uint32_t max_age; uint16_t etag_value; uint16_t value_len; @@ -208,9 +207,10 @@ STATIC mod_coap_resource_obj_t* add_resource(const char* uri, uint8_t mediatype, resource->next = NULL; // uri parameter pointer will be destroyed, pass a pointer to a permanent location - resource->uri = m_malloc(strlen(uri)); - memcpy(resource->uri, uri, strlen(uri)); - resource->coap_resource = coap_resource_init((const unsigned char* )resource->uri, strlen(uri), 0); + unsigned char* uri_ptr = (unsigned char*)malloc(strlen(uri)); + memcpy(uri_ptr, uri, strlen(uri)); + // Pass COAP_RESOURCE_FLAGS_RELEASE_URI so Coap Library will free up the memory allocated to store the URI when the Resource is deleted + resource->coap_resource = coap_resource_init(uri_ptr, strlen(uri), COAP_RESOURCE_FLAGS_RELEASE_URI); if(resource->coap_resource != NULL) { // Add the resource to the Coap context coap_add_resource(context->context, resource->coap_resource); @@ -238,7 +238,7 @@ STATIC mod_coap_resource_obj_t* add_resource(const char* uri, uint8_t mediatype, return resource; } else { - m_free(resource->uri); + free(uri_ptr); m_del_obj(mod_coap_resource_obj_t, resource); // Resource cannot be created return NULL; @@ -278,14 +278,12 @@ STATIC void remove_resource_by_key(coap_key_t key) { previous->next = current->next; } - // Free the URI - m_free(current->uri); // Free the resource in coap's scope coap_delete_resource(context->context, key); // Free the element in MP scope - m_free(current->value); + free(current->value); // Free the resource itself - m_free(current); + m_del_obj(mod_coap_resource_obj_t, current); return; } @@ -320,7 +318,7 @@ STATIC void resource_update_value(mod_coap_resource_obj_t* resource, mp_obj_t ne // Invalidate current data first resource->value_len = 0; - m_free(resource->value); + free(resource->value); if (mp_obj_is_integer(new_value)) { @@ -334,7 +332,7 @@ STATIC void resource_update_value(mod_coap_resource_obj_t* resource, mp_obj_t ne } // Allocate memory for the new data - resource->value = m_malloc(resource->value_len); + resource->value = malloc(resource->value_len); memcpy(resource->value, &value, sizeof(value)); } else { @@ -344,7 +342,7 @@ STATIC void resource_update_value(mod_coap_resource_obj_t* resource, mp_obj_t ne resource->value_len = value_bufinfo.len; // Allocate memory for the new data - resource->value = m_malloc(resource->value_len); + resource->value = malloc(resource->value_len); memcpy(resource->value, value_bufinfo.buf, resource->value_len); } } @@ -748,16 +746,13 @@ STATIC coap_pdu_t * modcoap_new_request // Helper function to create a new option for a request message STATIC coap_list_t * modcoap_new_option_node(unsigned short key, unsigned int length, unsigned char *data) { - coap_list_t *node = m_malloc(sizeof(coap_list_t) + sizeof(coap_option) + length); + coap_list_t *node = malloc(sizeof(coap_list_t) + sizeof(coap_option) + length); if (node) { coap_option *option; option = (coap_option *)(node->data); COAP_OPTION_KEY(*option) = key; COAP_OPTION_LENGTH(*option) = length; memcpy(COAP_OPTION_DATA(*option), data, length); - } else { - m_free(node); - node = NULL; } return node; @@ -821,7 +816,7 @@ STATIC mp_obj_t mod_coap_resource_callback_enable(mp_obj_t self_in, mp_obj_t req mod_coap_resource_obj_t* self = (mod_coap_resource_obj_t*)self_in; mp_int_t request_type = mp_obj_get_int(request_type_in); - bool enable = mp_obj_get_int(request_type_in) == 0 ? false : true; + bool enable = mp_obj_get_int(enable_in) == 0 ? false : true; if(request_type & MODCOAP_REQUEST_GET) { if(enable) coap_register_handler(self->coap_resource, COAP_REQUEST_GET, coap_resource_callback_get); @@ -937,7 +932,7 @@ STATIC mp_obj_t mod_coap_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map // Only 1 context is supported currently if(initialized == false) { - MP_STATE_PORT(coap_ptr) = m_malloc(sizeof(mod_coap_obj_t)); + MP_STATE_PORT(coap_ptr) = m_new_obj(mod_coap_obj_t); coap_obj_ptr = MP_STATE_PORT(coap_ptr); coap_obj_ptr->context = NULL; coap_obj_ptr->resources = NULL; @@ -1235,19 +1230,21 @@ STATIC mp_obj_t mod_coap_send_request(mp_uint_t n_args, const mp_obj_t *pos_args //TODO: allocate the proper length size_t length = 300; unsigned char* path = malloc(length); - int segments = coap_split_path(coap_uri.path.s, coap_uri.path.length, path, &length); + // Need to use a different pointer because when the segments are composed the pointer itself is moved + unsigned char* path_segment = path; + int segments = coap_split_path(coap_uri.path.s, coap_uri.path.length, path_segment, &length); // Insert the segments as separate URI-Path options while (segments--) { - node = modcoap_new_option_node(COAP_OPTION_URI_PATH, COAP_OPT_LENGTH(path), COAP_OPT_VALUE(path)); + node = modcoap_new_option_node(COAP_OPTION_URI_PATH, COAP_OPT_LENGTH(path_segment), COAP_OPT_VALUE(path_segment)); if(node != NULL) { LL_APPEND(coap_obj_ptr->optlist, node); } - - path += COAP_OPT_SIZE(path); + // Move the path_segment pointer to the next segment + path_segment += COAP_OPT_SIZE(path_segment); } - + // Free up the memory using the pointer pointing to the beginning of the memory area free(path); // Put Content Format option if given @@ -1271,7 +1268,7 @@ STATIC mp_obj_t mod_coap_send_request(mp_uint_t n_args, const mp_obj_t *pos_args while(coap_obj_ptr->optlist != NULL) { next = coap_obj_ptr->optlist->next; coap_obj_ptr->optlist->next = NULL; - m_free(coap_obj_ptr->optlist); + free(coap_obj_ptr->optlist); coap_obj_ptr->optlist = next; } diff --git a/esp32/mods/modcoap.h b/esp32/mods/modcoap.h index 76a89f7190..78d5f40e3d 100644 --- a/esp32/mods/modcoap.h +++ b/esp32/mods/modcoap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modeth.c b/esp32/mods/modeth.c index 984fdfc220..c0afe812ee 100644 --- a/esp32/mods/modeth.c +++ b/esp32/mods/modeth.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modeth.h b/esp32/mods/modeth.h index 3470318ca8..f067e9b921 100644 --- a/esp32/mods/modeth.h +++ b/esp32/mods/modeth.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modled.c b/esp32/mods/modled.c index 665db353c4..4488328f8a 100644 --- a/esp32/mods/modled.c +++ b/esp32/mods/modled.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modled.h b/esp32/mods/modled.h index 7981405c1d..d2b6d8bc3d 100644 --- a/esp32/mods/modled.h +++ b/esp32/mods/modled.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modlora.c b/esp32/mods/modlora.c index 94f742094d..162fee8325 100644 --- a/esp32/mods/modlora.c +++ b/esp32/mods/modlora.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -1103,7 +1103,7 @@ static void TASK_LoRa (void *pvParameters) { mibReq.Type = MIB_NETWORK_ACTIVATION; mibReq.Param.NetworkActivation = ACTIVATION_TYPE_OTAA; LoRaMacMibSetRequestConfirm( &mibReq ); - + TimerStart( &TxNextActReqTimer ); mlmeReq.Type = MLME_JOIN; mlmeReq.Req.Join.DevEui = (uint8_t *)lora_obj.u.otaa.DevEui; @@ -1692,7 +1692,9 @@ static bool lora_tx_space (void) { /// \class LoRa - Semtech SX1272 radio driver static mp_obj_t lora_init_helper(lora_obj_t *self, const mp_arg_val_t *args) { lora_cmd_data_t cmd_data; - +#if defined(FIPY) || defined(LOPY4) + xSemaphoreGive(xLoRaSigfoxSem); +#endif cmd_data.info.init.stack_mode = args[0].u_int; lora_validate_mode (cmd_data.info.init.stack_mode); @@ -1974,6 +1976,7 @@ STATIC mp_obj_t lora_join(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t * timeout -= LORA_JOIN_WAIT_MS; } if (timeout <= 0) { + TimerStop( &TxNextActReqTimer ); nlr_raise(mp_obj_new_exception_msg(&mp_type_TimeoutError, "timed out")); } } @@ -1990,26 +1993,28 @@ STATIC mp_obj_t lora_join_multicast_group (mp_uint_t n_args, const mp_obj_t *pos { MP_QSTR_mcNwkKey, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_mcAppKey, MP_ARG_REQUIRED | 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); - + mp_buffer_info_t bufinfo_0, bufinfo_1; mp_get_buffer_raise(args[1].u_obj, &bufinfo_0, MP_BUFFER_READ); mp_get_buffer_raise(args[2].u_obj, &bufinfo_1, MP_BUFFER_READ); - - MulticastParams_t *channelParam = m_new_obj(MulticastParams_t); + + MulticastParams_t *channelParam = heap_caps_malloc(sizeof(MulticastParams_t), MALLOC_CAP_SPIRAM); channelParam->Next = NULL; channelParam->DownLinkCounter = 0; channelParam->Address = args[0].u_int; memcpy(channelParam->NwkSKey, bufinfo_0.buf, sizeof(channelParam->NwkSKey)); memcpy(channelParam->AppSKey, bufinfo_1.buf, sizeof(channelParam->AppSKey)); - + if (LoRaMacMulticastChannelLink(channelParam) == LORAMAC_STATUS_OK) { return mp_const_true; } - + + // adding to the list failed, so free the memory again + free(channelParam); return mp_const_false; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(lora_join_multicast_group_obj, 0, lora_join_multicast_group); @@ -2018,7 +2023,7 @@ STATIC mp_obj_t lora_leave_multicast_group (mp_obj_t self_in, mp_obj_t multicast uint32_t mcAddr = mp_obj_get_int(multicast_addr_obj); MulticastParams_t *channelParam = LoRaMacMulticastGetChannel(mcAddr); if (LoRaMacMulticastChannelUnlink(channelParam) == LORAMAC_STATUS_OK) { - m_del_obj(MulticastParams_t, channelParam); + free(channelParam); return mp_const_true; } return mp_const_false; diff --git a/esp32/mods/modlora.h b/esp32/mods/modlora.h index e2b7b0e4ac..4136c8dd0b 100644 --- a/esp32/mods/modlora.h +++ b/esp32/mods/modlora.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index b823883ef9..3a81b42125 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020, Pycom Limited and its licensors. +* Copyright (c) 2021, Pycom Limited and its licensors. * * 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 @@ -223,7 +223,18 @@ static bool lte_push_at_command_ext_cont (char *cmd_str, uint32_t timeout, const } static bool lte_push_at_command_ext(char *cmd_str, uint32_t timeout, const char *expected_rsp, size_t len) { - return lte_push_at_command_ext_cont(cmd_str, timeout, expected_rsp, len, false); + if (len > LTE_AT_CMD_DATA_SIZE_MAX) { + uint32_t cmd_full = len / LTE_AT_CMD_DATA_SIZE_MAX; + uint32_t cmd_remain = len % LTE_AT_CMD_DATA_SIZE_MAX; + for (int i=0; i < cmd_full; i++) { + if (!lte_push_at_command_ext_cont(cmd_str+(i*LTE_AT_CMD_DATA_SIZE_MAX), timeout, expected_rsp, LTE_AT_CMD_DATA_SIZE_MAX, true)) { + return false; + } + } + return lte_push_at_command_ext_cont(cmd_str+(cmd_full*LTE_AT_CMD_DATA_SIZE_MAX), timeout, expected_rsp, cmd_remain, false); + } else { + return lte_push_at_command_ext_cont(cmd_str, timeout, expected_rsp, len, false); + } } static bool lte_push_at_command (char *cmd_str, uint32_t timeout) { @@ -280,8 +291,7 @@ 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: 1,1")) || (pos = strstr(modlte_rsp.data, "+CEREG: 1,5"))) - && (strlen(pos) >= 31) && (pos[30] == '7' || pos[30] == '9')) { + if ((pos = strstr(modlte_rsp.data, "+CEREG: 1,1")) || (pos = strstr(modlte_rsp.data, "+CEREG: 1,5"))) { attached = true; } } else { @@ -1524,7 +1534,7 @@ STATIC mp_obj_t lte_debug_buff(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(lte_debug_buff_obj, lte_debug_buff); #endif STATIC mp_obj_t lte_reconnect_uart (void) { - connect_lte_uart(); + connect_lte_uart(true); lteppp_disconnect(); lte_obj.init = false; return mp_const_none; diff --git a/esp32/mods/modlte.h b/esp32/mods/modlte.h index 10880877d4..83fa6c615b 100644 --- a/esp32/mods/modlte.h +++ b/esp32/mods/modlte.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020, Pycom Limited and its licensors. +* Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modmachine.c b/esp32/mods/modmachine.c index 28f4f4b9e0..3dad51c2f9 100644 --- a/esp32/mods/modmachine.c +++ b/esp32/mods/modmachine.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modmachine.h b/esp32/mods/modmachine.h index 4bf602975a..85ce0f28ee 100644 --- a/esp32/mods/modmachine.h +++ b/esp32/mods/modmachine.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modmdns.c b/esp32/mods/modmdns.c index bb0814d220..ab66a9d653 100644 --- a/esp32/mods/modmdns.c +++ b/esp32/mods/modmdns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modmdns.h b/esp32/mods/modmdns.h index cb3a095868..1f3686d6ea 100644 --- a/esp32/mods/modmdns.h +++ b/esp32/mods/modmdns.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modmesh.c b/esp32/mods/modmesh.c index 0e2a67aa9e..e81d79b10c 100644 --- a/esp32/mods/modmesh.c +++ b/esp32/mods/modmesh.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modmesh.h b/esp32/mods/modmesh.h index 5460e00528..a27a4dedb7 100644 --- a/esp32/mods/modmesh.h +++ b/esp32/mods/modmesh.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modnetwork.c b/esp32/mods/modnetwork.c index 26e52323b3..ea7763d595 100644 --- a/esp32/mods/modnetwork.c +++ b/esp32/mods/modnetwork.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modnetwork.h b/esp32/mods/modnetwork.h index 97aee48580..ddab095522 100644 --- a/esp32/mods/modnetwork.h +++ b/esp32/mods/modnetwork.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modpycom.c b/esp32/mods/modpycom.c index a4007622f0..8ef265607d 100644 --- a/esp32/mods/modpycom.c +++ b/esp32/mods/modpycom.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -1013,6 +1013,53 @@ STATIC mp_obj_t mod_pycom_sigfox_info (size_t n_args, const mp_obj_t *pos_args, } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_pycom_sigfox_info_obj, 0, mod_pycom_sigfox_info); +// This function creates a 128 bit long UUID stored in a byte array in Little Endian order from an input String +STATIC mp_obj_t create_128bit_le_uuid_from_string(mp_obj_t uuid_in) { + + size_t length; + uint8_t new_uuid[16]; + uint8_t i, j; + + const char* uuid_char_in = mp_obj_str_get_data(uuid_in, &length); + // 1 character is stored on 1 byte because we received a String + // For 128 bit UUID maximum 32 characters long String can be accepted + if (length > 32) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Input string must not be longer than 32 characters!")); + } + + // Pre-fill the whole array with 0 because the remaining/not given digits will be 0 + char uuid_char[32] = {0}; + memcpy(uuid_char, uuid_char_in, length); + + for(i = 0, j = 0; i < 32; i = i+2) { + + uint8_t lower_nibble = 0; + uint8_t upper_nibble = 0; + + if(uuid_char[i] > 0) { + upper_nibble = hex_from_char(uuid_char[i]); + } + + if(uuid_char[i+1] > 0) { + lower_nibble = hex_from_char(uuid_char[i+1]); + } + + if(lower_nibble == 16 || upper_nibble == 16) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "UUID must only contain hexadecimal digits!")); + } + + // Pack together the 4 bits digits into 1 byte + // Convert to Little Endian order because we expect that the digits of the input String follows the Natural Byte (Big Endian) order + new_uuid[15-j] = lower_nibble | (upper_nibble << 4); + j++; + } + + mp_obj_t new_uuid_mp = mp_obj_new_bytearray(16, new_uuid); + return new_uuid_mp; + +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(create_128bit_le_uuid_from_string_obj, create_128bit_le_uuid_from_string); + STATIC const mp_map_elem_t pycom_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_pycom) }, { MP_OBJ_NEW_QSTR(MP_QSTR_heartbeat), (mp_obj_t)&mod_pycom_heartbeat_obj }, @@ -1039,6 +1086,8 @@ STATIC const mp_map_elem_t pycom_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_wifi_pwd_sta), (mp_obj_t)&mod_pycom_wifi_pwd_sta_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_wifi_pwd_ap), (mp_obj_t)&mod_pycom_wifi_pwd_ap_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_wifi_mode_on_boot), (mp_obj_t)&mod_pycom_wifi_mode_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_create_128bit_le_uuid_from_string), (mp_obj_t)&create_128bit_le_uuid_from_string_obj }, + #if defined(FIPY) || defined(LOPY4) || defined(SIPY) { MP_OBJ_NEW_QSTR(MP_QSTR_sigfox_info), (mp_obj_t)&mod_pycom_sigfox_info_obj }, diff --git a/esp32/mods/modsigfox_api.c b/esp32/mods/modsigfox_api.c index 0041b258ed..ffe9c55766 100644 --- a/esp32/mods/modsigfox_api.c +++ b/esp32/mods/modsigfox_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/moducrypto.c b/esp32/mods/moducrypto.c index f6340b8998..9eb0787d76 100644 --- a/esp32/mods/moducrypto.c +++ b/esp32/mods/moducrypto.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/moduhashlib.c b/esp32/mods/moduhashlib.c index 3652676181..07bad81aff 100644 --- a/esp32/mods/moduhashlib.c +++ b/esp32/mods/moduhashlib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/moduos.c b/esp32/mods/moduos.c index cb1b548e49..e9c90611f8 100644 --- a/esp32/mods/moduos.c +++ b/esp32/mods/moduos.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/moduos.h b/esp32/mods/moduos.h index c91eadf406..3c73114100 100644 --- a/esp32/mods/moduos.h +++ b/esp32/mods/moduos.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/moduqueue.c b/esp32/mods/moduqueue.c index 0a5aa10bdd..37f737ab7e 100644 --- a/esp32/mods/moduqueue.c +++ b/esp32/mods/moduqueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/moduqueue.h b/esp32/mods/moduqueue.h index bdefb02da5..d9ce833051 100644 --- a/esp32/mods/moduqueue.h +++ b/esp32/mods/moduqueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modusocket.c b/esp32/mods/modusocket.c index cd660932b2..f88a6ba315 100644 --- a/esp32/mods/modusocket.c +++ b/esp32/mods/modusocket.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modusocket.h b/esp32/mods/modusocket.h index e1a2b5e3d8..dbb33dae37 100644 --- a/esp32/mods/modusocket.h +++ b/esp32/mods/modusocket.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modussl.c b/esp32/mods/modussl.c index 9e1dbe9a02..f351b7af07 100644 --- a/esp32/mods/modussl.c +++ b/esp32/mods/modussl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modussl.h b/esp32/mods/modussl.h index 9784311eb4..4adcfb05df 100644 --- a/esp32/mods/modussl.h +++ b/esp32/mods/modussl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/modutime.c b/esp32/mods/modutime.c index adbf85bb59..3b69756bd0 100644 --- a/esp32/mods/modutime.c +++ b/esp32/mods/modutime.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mods/modwlan.c b/esp32/mods/modwlan.c index 55d5b793ea..56f6f8b0ab 100644 --- a/esp32/mods/modwlan.c +++ b/esp32/mods/modwlan.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -760,6 +760,28 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut goto os_error; } + /* Read certificates content (if they are available) for the WPA2 Enterprise authentication */ + if (auth == WIFI_AUTH_WPA2_ENTERPRISE) { + const char *wpa_cert = NULL; + if (wlan_wpa2_ent.ca_certs_path != NULL) { + wpa_cert = pycom_util_read_file(wlan_wpa2_ent.ca_certs_path, &wlan_obj.vstr_ca); + if(wpa_cert == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "certificate file not found")); + } + } + + if (wlan_wpa2_ent.client_key_path != NULL && wlan_wpa2_ent.client_cert_path != NULL) { + wpa_cert = pycom_util_read_file(wlan_wpa2_ent.client_key_path, &wlan_obj.vstr_key); + if(wpa_cert == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "device key certificate file not found")); + } + wpa_cert = pycom_util_read_file(wlan_wpa2_ent.client_cert_path, &wlan_obj.vstr_cert); + if(wpa_cert == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "device client certificate file not found")); + } + } + } + // The certificate files are already read at this point because this function runs outside of GIL, and the file_read functions uses MicroPython APIs if (auth == WIFI_AUTH_WPA2_ENTERPRISE) { // CA Certificate is not mandatory diff --git a/esp32/mods/modwlan.h b/esp32/mods/modwlan.h index 97f572b15f..8db8375a68 100644 --- a/esp32/mods/modwlan.h +++ b/esp32/mods/modwlan.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/pybadc.c b/esp32/mods/pybadc.c index 1f442fe2c9..8ae202e472 100644 --- a/esp32/mods/pybadc.c +++ b/esp32/mods/pybadc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/pybadc.h b/esp32/mods/pybadc.h index 53b6d885ad..93779f4113 100644 --- a/esp32/mods/pybadc.h +++ b/esp32/mods/pybadc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/pybdac.c b/esp32/mods/pybdac.c index ea809d1b78..a5d040abd4 100644 --- a/esp32/mods/pybdac.c +++ b/esp32/mods/pybdac.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/pybdac.h b/esp32/mods/pybdac.h index 7b537eea8b..3ea7d0b9df 100644 --- a/esp32/mods/pybdac.h +++ b/esp32/mods/pybdac.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/pybsd.c b/esp32/mods/pybsd.c index c6b6c1bcf3..e5cfb756cd 100644 --- a/esp32/mods/pybsd.c +++ b/esp32/mods/pybsd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mods/pybsd.h b/esp32/mods/pybsd.h index 130a51af49..f5e0661d47 100644 --- a/esp32/mods/pybsd.h +++ b/esp32/mods/pybsd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mpconfigport.h b/esp32/mpconfigport.h index e6d2228138..64a9af24ce 100644 --- a/esp32/mpconfigport.h +++ b/esp32/mpconfigport.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/mptask.c b/esp32/mptask.c index e5e89919d7..423bce4c3f 100644 --- a/esp32/mptask.c +++ b/esp32/mptask.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mptask.h b/esp32/mptask.h index f1ba4f870b..126f2b5579 100644 --- a/esp32/mptask.h +++ b/esp32/mptask.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/mpthreadport.c b/esp32/mpthreadport.c index de383be612..798a340392 100644 --- a/esp32/mpthreadport.c +++ b/esp32/mpthreadport.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 @@ -171,15 +171,15 @@ void mp_thread_create_ex(void *(*entry)(void*), void *arg, size_t *stack_size, i // allocate TCB, stack and linked-list node (must be outside thread_mutex lock) if (mp_chip_revision > 0) { // for revision 1 devices we allocate from the internal memory of the malloc heap - tcb = malloc(sizeof(StaticTask_t)); + tcb = heap_caps_malloc(sizeof(StaticTask_t), MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); if (!tcb) { goto memory_error; } - stack = malloc(*stack_size); + stack = heap_caps_malloc(*stack_size, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); if (!stack) { goto memory_error; } - th = malloc(sizeof(thread_t)); + th = heap_caps_malloc(sizeof(thread_t), MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); if (!th) { goto memory_error; } diff --git a/esp32/mpthreadport.h b/esp32/mpthreadport.h index c54d0bc4a7..3768aed421 100644 --- a/esp32/mpthreadport.h +++ b/esp32/mpthreadport.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/pycom_config.c b/esp32/pycom_config.c index 74c75b5752..9e9416cafd 100644 --- a/esp32/pycom_config.c +++ b/esp32/pycom_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pycom_config.h b/esp32/pycom_config.h index 9c23f5ae17..978d2d5013 100644 --- a/esp32/pycom_config.h +++ b/esp32/pycom_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pycom_version.h b/esp32/pycom_version.h index b85d758bb1..0e75d58a4c 100644 --- a/esp32/pycom_version.h +++ b/esp32/pycom_version.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -10,14 +10,14 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define SW_VERSION_NUMBER "1.20.2.r3" +#define SW_VERSION_NUMBER "1.20.2.r7" #define LORAWAN_VERSION_NUMBER "1.0.2" #define SIGFOX_VERSION_NUMBER "1.0.1" #if (VARIANT == PYBYTES) -#define PYBYTES_VERSION_NUMBER "1.6.1" +#define PYBYTES_VERSION_NUMBER "1.7.1" #endif #ifdef PYGATE_ENABLED diff --git a/esp32/pygate/concentrator/cmd_manager.c b/esp32/pygate/concentrator/cmd_manager.c index 2673147977..dba7ce5116 100644 --- a/esp32/pygate/concentrator/cmd_manager.c +++ b/esp32/pygate/concentrator/cmd_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/concentrator/cmd_manager.h b/esp32/pygate/concentrator/cmd_manager.h index f1ec140ba1..10c4d311ed 100644 --- a/esp32/pygate/concentrator/cmd_manager.h +++ b/esp32/pygate/concentrator/cmd_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/concentrator/loragw_hal_esp.c b/esp32/pygate/concentrator/loragw_hal_esp.c index 417a4abbc3..e0116a6f85 100644 --- a/esp32/pygate/concentrator/loragw_hal_esp.c +++ b/esp32/pygate/concentrator/loragw_hal_esp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/concentrator/loragw_hal_esp.h b/esp32/pygate/concentrator/loragw_hal_esp.h index 4734e978f6..05b6ea7f2a 100644 --- a/esp32/pygate/concentrator/loragw_hal_esp.h +++ b/esp32/pygate/concentrator/loragw_hal_esp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/concentrator/loragw_radio_esp.h b/esp32/pygate/concentrator/loragw_radio_esp.h index 702e71d633..9ee5a2fdb5 100644 --- a/esp32/pygate/concentrator/loragw_radio_esp.h +++ b/esp32/pygate/concentrator/loragw_radio_esp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/concentrator/loragw_reg_esp.c b/esp32/pygate/concentrator/loragw_reg_esp.c index 7fab0c7f4c..6da34bda4f 100644 --- a/esp32/pygate/concentrator/loragw_reg_esp.c +++ b/esp32/pygate/concentrator/loragw_reg_esp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/concentrator/loragw_reg_esp.h b/esp32/pygate/concentrator/loragw_reg_esp.h index 5c14fd18e6..da741cfb1a 100644 --- a/esp32/pygate/concentrator/loragw_reg_esp.h +++ b/esp32/pygate/concentrator/loragw_reg_esp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_aux.h b/esp32/pygate/hal/include/loragw_aux.h index 8e386b20f1..669f4118b6 100644 --- a/esp32/pygate/hal/include/loragw_aux.h +++ b/esp32/pygate/hal/include/loragw_aux.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_com.h b/esp32/pygate/hal/include/loragw_com.h index a720a92e02..5b080bf3a4 100644 --- a/esp32/pygate/hal/include/loragw_com.h +++ b/esp32/pygate/hal/include/loragw_com.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_com_esp.h b/esp32/pygate/hal/include/loragw_com_esp.h index f789bf617a..c4213c1ef2 100644 --- a/esp32/pygate/hal/include/loragw_com_esp.h +++ b/esp32/pygate/hal/include/loragw_com_esp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_hal.h b/esp32/pygate/hal/include/loragw_hal.h index c8cff296c7..ec3b27fced 100644 --- a/esp32/pygate/hal/include/loragw_hal.h +++ b/esp32/pygate/hal/include/loragw_hal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_mcu.h b/esp32/pygate/hal/include/loragw_mcu.h index 7196817440..e9d6a2b293 100644 --- a/esp32/pygate/hal/include/loragw_mcu.h +++ b/esp32/pygate/hal/include/loragw_mcu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_radio.h b/esp32/pygate/hal/include/loragw_radio.h index 4dfbf7c271..9176af0e19 100644 --- a/esp32/pygate/hal/include/loragw_radio.h +++ b/esp32/pygate/hal/include/loragw_radio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_reg.h b/esp32/pygate/hal/include/loragw_reg.h index af024a1fb5..a0aed0a3bb 100644 --- a/esp32/pygate/hal/include/loragw_reg.h +++ b/esp32/pygate/hal/include/loragw_reg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/include/loragw_sx125x.h b/esp32/pygate/hal/include/loragw_sx125x.h index c66713a123..b42a5e7aff 100644 --- a/esp32/pygate/hal/include/loragw_sx125x.h +++ b/esp32/pygate/hal/include/loragw_sx125x.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_aux.c b/esp32/pygate/hal/loragw_aux.c index b898b1e2d4..1e8cc4d89e 100644 --- a/esp32/pygate/hal/loragw_aux.c +++ b/esp32/pygate/hal/loragw_aux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_com.c b/esp32/pygate/hal/loragw_com.c index 9c1ce2d906..6e6d65c5e4 100644 --- a/esp32/pygate/hal/loragw_com.c +++ b/esp32/pygate/hal/loragw_com.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_com_esp.c b/esp32/pygate/hal/loragw_com_esp.c index 5f0211e4bc..6b9e0d8dbc 100644 --- a/esp32/pygate/hal/loragw_com_esp.c +++ b/esp32/pygate/hal/loragw_com_esp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_hal.c b/esp32/pygate/hal/loragw_hal.c index 36226eb10e..3933d20f56 100644 --- a/esp32/pygate/hal/loragw_hal.c +++ b/esp32/pygate/hal/loragw_hal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_mcu.c b/esp32/pygate/hal/loragw_mcu.c index 3b56ab7bf2..7f8b2854a9 100644 --- a/esp32/pygate/hal/loragw_mcu.c +++ b/esp32/pygate/hal/loragw_mcu.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_radio.c b/esp32/pygate/hal/loragw_radio.c index 672c1c866c..8f667f231f 100644 --- a/esp32/pygate/hal/loragw_radio.c +++ b/esp32/pygate/hal/loragw_radio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/hal/loragw_reg.c b/esp32/pygate/hal/loragw_reg.c index 3b8de47c6f..73b17b178e 100644 --- a/esp32/pygate/hal/loragw_reg.c +++ b/esp32/pygate/hal/loragw_reg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/base64.c b/esp32/pygate/lora_pkt_fwd/base64.c index addeda8074..b31c51111a 100644 --- a/esp32/pygate/lora_pkt_fwd/base64.c +++ b/esp32/pygate/lora_pkt_fwd/base64.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/base64.h b/esp32/pygate/lora_pkt_fwd/base64.h index 8515aa05bc..05a5e973dc 100644 --- a/esp32/pygate/lora_pkt_fwd/base64.h +++ b/esp32/pygate/lora_pkt_fwd/base64.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/jitqueue.c b/esp32/pygate/lora_pkt_fwd/jitqueue.c index c078e2f39b..d1bdce8dbf 100644 --- a/esp32/pygate/lora_pkt_fwd/jitqueue.c +++ b/esp32/pygate/lora_pkt_fwd/jitqueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/jitqueue.h b/esp32/pygate/lora_pkt_fwd/jitqueue.h index 01e69bab69..c3e28b6598 100644 --- a/esp32/pygate/lora_pkt_fwd/jitqueue.h +++ b/esp32/pygate/lora_pkt_fwd/jitqueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c index 0938dab46b..294e9c2609 100644 --- a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c +++ b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h index 3b2bbf83d2..0043a5494a 100644 --- a/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h +++ b/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/parson.c b/esp32/pygate/lora_pkt_fwd/parson.c index 452719762b..e24a196cf5 100644 --- a/esp32/pygate/lora_pkt_fwd/parson.c +++ b/esp32/pygate/lora_pkt_fwd/parson.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/parson.h b/esp32/pygate/lora_pkt_fwd/parson.h index f5d7221f25..a28ab16da1 100644 --- a/esp32/pygate/lora_pkt_fwd/parson.h +++ b/esp32/pygate/lora_pkt_fwd/parson.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/timersync.c b/esp32/pygate/lora_pkt_fwd/timersync.c index ed1c512382..9525acc945 100644 --- a/esp32/pygate/lora_pkt_fwd/timersync.c +++ b/esp32/pygate/lora_pkt_fwd/timersync.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/timersync.h b/esp32/pygate/lora_pkt_fwd/timersync.h index bf48fed0f9..68c01c055b 100644 --- a/esp32/pygate/lora_pkt_fwd/timersync.h +++ b/esp32/pygate/lora_pkt_fwd/timersync.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/pygate/lora_pkt_fwd/trace.h b/esp32/pygate/lora_pkt_fwd/trace.h index fdc399abdb..b995ddac26 100644 --- a/esp32/pygate/lora_pkt_fwd/trace.h +++ b/esp32/pygate/lora_pkt_fwd/trace.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/qstrdefsport.h b/esp32/qstrdefsport.h index 63a2b5d304..b7a5e0e252 100644 --- a/esp32/qstrdefsport.h +++ b/esp32/qstrdefsport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/serverstask.c b/esp32/serverstask.c index 016e449727..9639c27d74 100644 --- a/esp32/serverstask.c +++ b/esp32/serverstask.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/serverstask.h b/esp32/serverstask.h index 5762acbd28..f73a9d7a0f 100644 --- a/esp32/serverstask.h +++ b/esp32/serverstask.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/sigfox/modsigfox.h b/esp32/sigfox/modsigfox.h index eee2292b42..8e62b328dd 100644 --- a/esp32/sigfox/modsigfox.h +++ b/esp32/sigfox/modsigfox.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/telnet/telnet.c b/esp32/telnet/telnet.c index 91972ecdfe..1483928de1 100644 --- a/esp32/telnet/telnet.c +++ b/esp32/telnet/telnet.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/telnet/telnet.h b/esp32/telnet/telnet.h index 754f69b7e9..a2da541b1e 100644 --- a/esp32/telnet/telnet.h +++ b/esp32/telnet/telnet.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/tools/appsign.sh b/esp32/tools/appsign.sh index ba85a3091a..c371e6b209 100644 --- a/esp32/tools/appsign.sh +++ b/esp32/tools/appsign.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/flasher.py b/esp32/tools/flasher.py index 420223bd7d..eacfce4f6a 100644 --- a/esp32/tools/flasher.py +++ b/esp32/tools/flasher.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/fw_updater/pypic.py b/esp32/tools/fw_updater/pypic.py index d0701a4637..d5f16014ce 100755 --- a/esp32/tools/fw_updater/pypic.py +++ b/esp32/tools/fw_updater/pypic.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright (c) 2016-2020, Pycom Limited. +# Copyright (c) 2016-2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/fw_updater/updater.py b/esp32/tools/fw_updater/updater.py index 401330c2cd..2a7f9fcf92 100755 --- a/esp32/tools/fw_updater/updater.py +++ b/esp32/tools/fw_updater/updater.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright (c) 2016-2020, Pycom Limited. +# Copyright (c) 2016-2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/idfVerCheck.sh b/esp32/tools/idfVerCheck.sh index 3323cb8e0e..ebe6ebeff4 100644 --- a/esp32/tools/idfVerCheck.sh +++ b/esp32/tools/idfVerCheck.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/lopy_final_test_board_script.py b/esp32/tools/lopy_final_test_board_script.py index 63e5a5be05..5984f97023 100644 --- a/esp32/tools/lopy_final_test_board_script.py +++ b/esp32/tools/lopy_final_test_board_script.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/lopy_initial_test_board_script.py b/esp32/tools/lopy_initial_test_board_script.py index 0f47f653fa..d4c346092f 100644 --- a/esp32/tools/lopy_initial_test_board_script.py +++ b/esp32/tools/lopy_initial_test_board_script.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/lopy_qa_test_board_script.py b/esp32/tools/lopy_qa_test_board_script.py index 144c972b5e..f485627746 100644 --- a/esp32/tools/lopy_qa_test_board_script.py +++ b/esp32/tools/lopy_qa_test_board_script.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/lora/actility/actility.py b/esp32/tools/lora/actility/actility.py index bd98eb3232..162554532c 100644 --- a/esp32/tools/lora/actility/actility.py +++ b/esp32/tools/lora/actility/actility.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/lora/certification/certification.py b/esp32/tools/lora/certification/certification.py index 8c68811730..6f19c950be 100644 --- a/esp32/tools/lora/certification/certification.py +++ b/esp32/tools/lora/certification/certification.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/run_final_lopy_test.py b/esp32/tools/run_final_lopy_test.py index f16f1047c0..a55a0e65e0 100644 --- a/esp32/tools/run_final_lopy_test.py +++ b/esp32/tools/run_final_lopy_test.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/run_initial_lopy_test.py b/esp32/tools/run_initial_lopy_test.py index ade3c20b4a..d324e0b015 100644 --- a/esp32/tools/run_initial_lopy_test.py +++ b/esp32/tools/run_initial_lopy_test.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/run_initial_wipy_test.py b/esp32/tools/run_initial_wipy_test.py index c7769718f0..756c1d08a4 100644 --- a/esp32/tools/run_initial_wipy_test.py +++ b/esp32/tools/run_initial_wipy_test.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/run_qa_lopy_test.py b/esp32/tools/run_qa_lopy_test.py index 6cca6ff692..35b136d5b4 100644 --- a/esp32/tools/run_qa_lopy_test.py +++ b/esp32/tools/run_qa_lopy_test.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/run_qa_wipy_test.py b/esp32/tools/run_qa_wipy_test.py index 75a95056dd..27fa308fc1 100644 --- a/esp32/tools/run_qa_wipy_test.py +++ b/esp32/tools/run_qa_wipy_test.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/wipy_initial_test_board_script.py b/esp32/tools/wipy_initial_test_board_script.py index 61b79825d4..b973ca30a6 100644 --- a/esp32/tools/wipy_initial_test_board_script.py +++ b/esp32/tools/wipy_initial_test_board_script.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/tools/wipy_qa_test_board_script.py b/esp32/tools/wipy_qa_test_board_script.py index c29e547300..9f8da3d2b1 100644 --- a/esp32/tools/wipy_qa_test_board_script.py +++ b/esp32/tools/wipy_qa_test_board_script.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Pycom Limited. +# Copyright (c) 2021, Pycom Limited. # # This software is licensed under the GNU GPL version 3 or any # later version, with permitted additional terms. For more information diff --git a/esp32/util/antenna.c b/esp32/util/antenna.c index 8b884081de..6cbe63c7e7 100644 --- a/esp32/util/antenna.c +++ b/esp32/util/antenna.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/antenna.h b/esp32/util/antenna.h index b5e9c7dcf2..a45fa08d4a 100644 --- a/esp32/util/antenna.h +++ b/esp32/util/antenna.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/esp32chipinfo.c b/esp32/util/esp32chipinfo.c index 627e39f7e0..5d42a0e846 100644 --- a/esp32/util/esp32chipinfo.c +++ b/esp32/util/esp32chipinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/esp32chipinfo.h b/esp32/util/esp32chipinfo.h index 97957e6a86..bb0ea812d1 100644 --- a/esp32/util/esp32chipinfo.h +++ b/esp32/util/esp32chipinfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/fifo.c b/esp32/util/fifo.c index 5c4592b36d..bf854d29f2 100644 --- a/esp32/util/fifo.c +++ b/esp32/util/fifo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/fifo.h b/esp32/util/fifo.h index 79fec735b3..cb8b659578 100644 --- a/esp32/util/fifo.h +++ b/esp32/util/fifo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/gccollect.c b/esp32/util/gccollect.c index 3446bcf923..478eada1ac 100644 --- a/esp32/util/gccollect.c +++ b/esp32/util/gccollect.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/util/gccollect.h b/esp32/util/gccollect.h index 673c66f3c5..c717db9649 100644 --- a/esp32/util/gccollect.h +++ b/esp32/util/gccollect.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/util/help.c b/esp32/util/help.c index ed8ab8fbff..def284c16b 100644 --- a/esp32/util/help.c +++ b/esp32/util/help.c @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/esp32/util/mperror.c b/esp32/util/mperror.c index b963b45a18..d36cce2647 100644 --- a/esp32/util/mperror.c +++ b/esp32/util/mperror.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information @@ -131,16 +131,18 @@ bool mperror_heartbeat_signal (void) { mperror_heart_beat.do_disable = false; } else if (mperror_heart_beat.enabled) { if (!mperror_heart_beat.beating) { - if ((mperror_heart_beat.on_time = mp_hal_ticks_ms_non_blocking()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) { + if (mp_hal_ticks_ms_non_blocking() > mperror_heart_beat.off_time) { led_info.color.value = MPERROR_HEARTBEAT_COLOR; - led_set_color(&led_info, false, false); + led_set_color(&led_info, true, false); mperror_heart_beat.beating = true; + mperror_heart_beat.on_time = mp_hal_ticks_ms_non_blocking() + MPERROR_HEARTBEAT_ON_MS; } } else { - if ((mperror_heart_beat.off_time = mp_hal_ticks_ms_non_blocking()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) { + if (mp_hal_ticks_ms_non_blocking() > mperror_heart_beat.on_time) { led_info.color.value = 0; - led_set_color(&led_info, false, false); + led_set_color(&led_info, true, false); mperror_heart_beat.beating = false; + mperror_heart_beat.off_time = mp_hal_ticks_ms_non_blocking() + MPERROR_HEARTBEAT_OFF_MS; } } } diff --git a/esp32/util/mperror.h b/esp32/util/mperror.h index 98b2b89f9e..649313bc1e 100644 --- a/esp32/util/mperror.h +++ b/esp32/util/mperror.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/mpexception.c b/esp32/util/mpexception.c index d30db8c483..f862cc8e6d 100644 --- a/esp32/util/mpexception.c +++ b/esp32/util/mpexception.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/mpexception.h b/esp32/util/mpexception.h index 547263810a..0912f942d1 100644 --- a/esp32/util/mpexception.h +++ b/esp32/util/mpexception.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/mpirq.c b/esp32/util/mpirq.c index dc378506a3..706d3bf428 100644 --- a/esp32/util/mpirq.c +++ b/esp32/util/mpirq.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/mpirq.h b/esp32/util/mpirq.h index 8f4af32f08..5f1e4c3bc6 100644 --- a/esp32/util/mpirq.h +++ b/esp32/util/mpirq.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/mpsleep.c b/esp32/util/mpsleep.c index e14e5d8da1..246bc075bc 100644 --- a/esp32/util/mpsleep.c +++ b/esp32/util/mpsleep.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/mpsleep.h b/esp32/util/mpsleep.h index ab838a228d..110adf0326 100644 --- a/esp32/util/mpsleep.h +++ b/esp32/util/mpsleep.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/pycom_general_util.c b/esp32/util/pycom_general_util.c index 38c891c038..1f985838a7 100644 --- a/esp32/util/pycom_general_util.c +++ b/esp32/util/pycom_general_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/pycom_general_util.h b/esp32/util/pycom_general_util.h index 97cd1e3d14..c038ff06d9 100644 --- a/esp32/util/pycom_general_util.h +++ b/esp32/util/pycom_general_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/random.c b/esp32/util/random.c index 6516ea27b9..e5c59bff9c 100644 --- a/esp32/util/random.c +++ b/esp32/util/random.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/random.h b/esp32/util/random.h index 0a651e6af8..b49b017318 100644 --- a/esp32/util/random.h +++ b/esp32/util/random.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/socketfifo.c b/esp32/util/socketfifo.c index 58169799b1..9d6e88e602 100644 --- a/esp32/util/socketfifo.c +++ b/esp32/util/socketfifo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/esp32/util/socketfifo.h b/esp32/util/socketfifo.h index db7bfa4a7f..293de29800 100644 --- a/esp32/util/socketfifo.h +++ b/esp32/util/socketfifo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/lib/lora/system/gpio.h b/lib/lora/system/gpio.h index 95b13593c3..73ba736ea5 100644 --- a/lib/lora/system/gpio.h +++ b/lib/lora/system/gpio.h @@ -1,7 +1,7 @@ /* * This file is derived from the MicroPython project, http://micropython.org/ * - * Copyright (c) 2020, Pycom Limited and its licensors. + * Copyright (c) 2021, Pycom Limited and its licensors. * * 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 diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 2ab99d89b4..0af0049870 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -57,11 +57,20 @@ def get_version_info_from_docs_conf(): return git_tag, "" return None +def get_version_info_from_pycom_version(): + with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "esp32", "pycom_version.h")) as f: + for line in f: + if line.startswith("#define SW_VERSION_NUMBER"): + ver = line.strip().split('"')[1] + git_tag = "v" + ver + return git_tag, "" + return None + def make_version_header(filename): # Get version info using git, with fallback to docs/conf.py info = get_version_info_from_git() if info is None: - info = get_version_info_from_docs_conf() + info = get_version_info_from_pycom_version() git_tag, git_hash = info diff --git a/py/mpprint.c b/py/mpprint.c index 3be364d36a..98b65234dc 100644 --- a/py/mpprint.c +++ b/py/mpprint.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, Pycom Limited. + * Copyright (c) 2021, Pycom Limited. * * This software is licensed under the GNU GPL version 3 or any * later version, with permitted additional terms. For more information diff --git a/tests/esp32/fs_file.py b/tests/esp32/fs_file.py index ab647a0079..3924887bb2 100644 --- a/tests/esp32/fs_file.py +++ b/tests/esp32/fs_file.py @@ -74,6 +74,32 @@ def file_seek_test(path): print("{0}, f.tell(): {1}".format(path, f.tell())) f.close() +def file_double_close_test(path): + f = open(path) + # Nothing should be printed out + f.close() + f.close() + f.close() + +def file_operations_after_close_test(path): + f = open(path, "rw") + f.close() + try: + f.read() + except Exception as e: + print("{0}, Exception after f.read: {1}".format(path, e)) + try: + f.write("aaa") + except Exception as e: + print("{0}, Exception after f.write: {1}".format(path, e)) + try: + f.flush() + except Exception as e: + print("{0}, Exception after f.flush: {1}".format(path, e)) + # No exception should be dropped + f.seek(12) + f.tell() + sd = SD() sd_fat_fs = os.mkfat(sd) @@ -157,6 +183,14 @@ def file_seek_test(path): file_readline_test(f_path) file_readline_test(sd_path) +#Test multiple file.close +file_double_close_test(f_path) +file_double_close_test(sd_path) + +#Test other operations after file.close() +file_operations_after_close_test(f_path) +file_operations_after_close_test(sd_path) + os.remove(f_path) os.remove(sd_path) os.umount("/sd") diff --git a/tests/esp32/fs_file.py.exp b/tests/esp32/fs_file.py.exp index 42d8f43e3b..d671c7b9ec 100644 --- a/tests/esp32/fs_file.py.exp +++ b/tests/esp32/fs_file.py.exp @@ -66,3 +66,9 @@ bytearray(b'0123456789') /sd/t.txt, f.readline(10): 01234 /sd/t.txt, f.readlines(): ['01234\n', '56789'] +/flash/t.txt, Exception after f.read: [Errno 22] EINVAL +/flash/t.txt, Exception after f.write: [Errno 22] EINVAL +/flash/t.txt, Exception after f.flush: [Errno 22] EINVAL +/sd/t.txt, Exception after f.read: [Errno 22] EINVAL +/sd/t.txt, Exception after f.write: [Errno 22] EINVAL +/sd/t.txt, Exception after f.flush: [Errno 22] EINVAL