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

Rel 5 #573

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
26a10b2
Update Pybytes to version 1.6.1
Xykon Nov 23, 2020
d600b20
Update pycom_version.h
Xykon Nov 23, 2020
742cc14
Update _pybytes_protocol.py
Xykon Nov 23, 2020
8340e1e
version 1.20.2.r3
peter-pycom Dec 23, 2020
3f690a5
Fix an issue that Bluetooth init() failed after deinit()
geza-pycom Dec 28, 2020
826e233
Add API create_128bit_le_uuid_from_string()
geza-pycom Oct 20, 2020
684e9da
Fix a bug causing multi-heap assert exception in modcoap and improve …
geza-pycom Dec 29, 2020
627e39c
removed exit 0 condition for tests
msariisik Jan 7, 2021
8cd6d21
revert back exit 0 condition on Jenkins
msariisik Jan 11, 2021
120f929
Rtc utime fix (#206)
gijsio Jan 11, 2021
f04187b
update version to 1.20.2.r4
peter-pycom Jan 11, 2021
af93a22
Merge pull request #215 from pycom/release_v1.20.2.r4
gijsio Jan 11, 2021
bee94a2
Merge remote-tracking branch 'public/Dev' into release_v1.20.2.r4
peter-pycom Jan 12, 2021
ffb0e1c
Merge pull request #515 from pycom/release_v1.20.2.r4_again
Xykon Jan 12, 2021
12e32a6
add gps coordinates to the pygate json status
gijsio Aug 27, 2020
c046f5f
fixes the re-initialization of lora OTAA
gijsio Aug 27, 2020
21af0b7
Revert "add gps coordinates to the pygate json status"
gijsio Aug 27, 2020
a5dff88
fixed the timeout
gijsio Aug 27, 2020
6153b01
removed commented code
gijsio Jan 15, 2021
144e161
Fix problem in mod_coap_resource_callback_enable() which forbids to d…
geza-pycom Jan 21, 2021
ed4e191
Lora reinit fix (#219)
gijsio Jan 25, 2021
9499afd
vfs_littlefs_file.c: Prevent double close of a file
robert-hh Jan 31, 2021
8baf148
vfs_littlefs_file.c: Move tagging files as closed.
robert-hh Mar 4, 2021
9253101
Adjust the fix so calling other file operations (e.g. write, read etc…
geza-pycom Mar 7, 2021
39ca300
Adjust to be the same as FatFs
geza-pycom Mar 7, 2021
56dd0ed
Add the modified functionality to the regression tests
geza-pycom Mar 7, 2021
a37510c
Update Copyright header
Xykon Mar 9, 2021
a66cdec
sflash_diskio_littlefs.c: Enable block level wear-leveling
robert-hh Jan 14, 2021
bdebb49
sflash_diskio_littlefs.c: change block_cycles to 100
geza-pycom Mar 21, 2021
7d28bd1
mperror.c: Move noticing of the next heartbeat transition (#235)
geza-pycom Apr 10, 2021
46d4a31
LTE: fix conditional in lte_check_attached
Jan 20, 2021
aace45a
Define uart id as int instead of mp_obj
knagymate Feb 16, 2020
d6a17b1
machuart: change default to UART 1
peter-pycom Feb 19, 2021
4cf7273
fix mpy-cross build
peter-pycom Feb 19, 2021
efaea4d
thread: allocate internal mem
peter-pycom Jun 30, 2021
39de84e
Merge pull request #279 from pycom/thread_malloc
gijsio Jul 16, 2021
b596cea
micropython task: allocate internal ram
gijsio Jul 16, 2021
68c0063
Fix for the missing certificated in WPA2 Enterprise connection (#263)
VladPetrovici Jun 28, 2021
08cbc20
update pybytes 1.7.0 975e984
peter-pycom Sep 22, 2021
04a4454
bump version to 1.20.2.r5
peter-pycom Sep 22, 2021
e932a94
lora: Fix losing of multicast params
peter-pycom Oct 5, 2021
b3b1575
Merge branch 'Dev' of github.com:pycom/pycom-micropython-sigfox into …
peter-pycom Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update pybytes 1.7.0 975e984
  • Loading branch information
peter-pycom committed Sep 22, 2021
commit 08cbc20875a01684ad00e322465bdae347aad8d6
6 changes: 4 additions & 2 deletions esp32/frozen/Pybytes/_OTA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={}&current_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={}&current_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()))
Expand Down
26 changes: 18 additions & 8 deletions esp32/frozen/Pybytes/_flash_control_OTA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand All @@ -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 = []
Expand All @@ -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)
Expand All @@ -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])
Expand All @@ -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()
Expand All @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion esp32/frozen/Pybytes/_main_pybytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 4 additions & 2 deletions esp32/frozen/Pybytes/_msg_handl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
65 changes: 58 additions & 7 deletions esp32/frozen/Pybytes/_pybytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
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, pygate_init, RTC, pygate_debug_level, reset

try:
from periodical_pin import PeriodicalPin
except:
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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -280,11 +285,51 @@ 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:
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:
Expand Down Expand Up @@ -428,6 +473,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
Expand Down
5 changes: 3 additions & 2 deletions esp32/frozen/Pybytes/_pybytes_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions esp32/frozen/Pybytes/_pybytes_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion esp32/frozen/Pybytes/_pybytes_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import os
import pycom # pylint: disable=import-error
import _thread
import time

from machine import RTC
from time import timezone
Expand All @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions esp32/frozen/Pybytes/_pybytes_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading