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

Release 1.20.2.r2 #499

Merged
merged 31 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8d07cd9
Add timeout parameter to lte_send_at_cmd
Xykon Jul 27, 2020
09e39fe
Update modlte.c
Xykon Jul 27, 2020
d93abce
Update modlte.c
Xykon Jul 27, 2020
86665a2
PYCOM : make option MICROPY_FLOAT_IMPL
rcolistete Aug 5, 2020
a06c014
PYCOM : improved option MICROPY_FLOAT_IMPL
rcolistete Aug 7, 2020
218035c
Merge branch 'master' into lte_send_at_cmd_timeout
Xykon Aug 24, 2020
fdedb33
Merge pull request #167 from pycom/lte_send_at_cmd_timeout
Xykon Sep 21, 2020
38f9019
Fix memory leak happens after Bluetooth disconnect, fix a problem in …
geza-pycom Oct 21, 2020
ca10cd1
Fix a problem when machine.sleep(resume_wifi_ble=True) drops exceptio…
geza-pycom Oct 24, 2020
ca673c0
Small changes
geza-pycom Oct 25, 2020
e3f3b41
Adding these changes because looks good and even they not needed with…
geza-pycom Oct 25, 2020
c3e7b6c
pygate: reset the JIT queue margins
gijsio Oct 28, 2020
b728776
Merge pull request #193 from geza-pycom/Resume_problem_bt_disconnect_…
Xykon Nov 1, 2020
9f44896
Resume the BT Connection from the original list if connection was not…
geza-pycom Nov 3, 2020
e3f7111
Merge pull request #194 from geza-pycom/resume_problem_2
geza-pycom Nov 3, 2020
da9f545
Update _terminal.py
Xykon Nov 12, 2020
2064cbd
Merge pull request #174 from pycom/float_option
Xykon Nov 20, 2020
944d708
lorapf: add pygate_reset() to power cycle the module
peter-pycom Aug 27, 2020
58db509
LTE: check for SIM card before attaching
peter-pycom Aug 26, 2020
b822a70
lorapf: fix warnings
peter-pycom Nov 6, 2020
7d2e8e0
str_utils: add hexdump()
peter-pycom Nov 9, 2020
4937349
lte: debug MSG and state
peter-pycom Nov 9, 2020
9cc50b2
lte: callback LTE_EVENT_BREAK
peter-pycom Nov 10, 2020
a641ac5
modlte: improve exception texts
peter-pycom Nov 10, 2020
8e631ef
lte: reduce AT+CEREG from 2 to 1
peter-pycom Nov 11, 2020
6b4f392
BLE update
Xykon Nov 6, 2020
4254ab2
update idf 3394ee573
peter-pycom Nov 12, 2020
9a9a5b9
Merge remote-tracking branch 'pycom-micropython-sigfox/release_1.20.2…
Xykon Nov 23, 2020
6e2ff29
Update Pybytes to version 1.6.1
Xykon Nov 23, 2020
1097cbe
Update pycom_version.h
Xykon Nov 23, 2020
72bc4a7
Update _pybytes_protocol.py
Xykon Nov 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ifeq ($(wildcard boards/$(BOARD)/.),)
$(error Invalid BOARD specified)
endif

IDF_HASH=c61fe64
IDF_HASH=3394ee5

TARGET ?= boot_app

Expand Down Expand Up @@ -123,6 +123,19 @@ CFLAGS_XTENSA_PSRAM = -mfix-esp32-psram-cache-issue
CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_PSRAM) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
CFLAGS_SIGFOX = $(CFLAGS_XTENSA) -O2 -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)

# Configure floating point support
ifeq ($(MICROPY_FLOAT_IMPL),double)
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE
else
ifeq ($(MICROPY_FLOAT_IMPL),none)
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE
else
ifeq ($(MICROPY_FLOAT_IMPL),single)
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT
endif
endif
endif

LDFLAGS = -nostdlib -Wl,-Map=$(@:.elf=.map) -Wl,--no-check-sections -u call_user_start_cpu0
LDFLAGS += -Wl,-static -Wl,--undefined=uxTopUsedPriority -Wl,--gc-sections

Expand Down
Binary file modified esp32/bootloader/lib/libbootloader_support.a
Binary file not shown.
Binary file modified esp32/bootloader/lib/libefuse.a
Binary file not shown.
Binary file modified esp32/bootloader/lib/liblog.a
Binary file not shown.
Binary file modified esp32/bootloader/lib/libmicro-ecc.a
Binary file not shown.
Binary file modified esp32/bootloader/lib/libsoc.a
Binary file not shown.
Binary file modified esp32/bootloader/lib/libspi_flash.a
Binary file not shown.
42 changes: 21 additions & 21 deletions esp32/esp32.project.ld

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions esp32/frozen/Pybytes/_OTA.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def update(self, customManifest=None, fwtype=None, token=None):

def get_file(self, f):
new_path = "{}.new".format(f['dst_path'])

# If a .new file exists from a previously failed update delete it
try:
os.remove(new_path)
Expand Down Expand Up @@ -184,6 +183,15 @@ def delete_file(self, f):

def write_firmware(self, f):
# hash =
url = f['URL'].split("//")[1].split("/")[0]

if url.find(":") > -1:
self.ip = url.split(":")[0]
self.port = int(url.split(":")[1])
else:
self.ip = url
self.port = 443

self.get_data(
f['URL'].split("/", 3)[-1],
hash=True,
Expand Down Expand Up @@ -222,7 +230,6 @@ def _http_get(self, path, host):

def get_data(self, req, dest_path=None, hash=False, firmware=False):
h = None

useSSL = int(self.port) == 443

# Connect to server
Expand All @@ -232,11 +239,9 @@ def get_data(self, req, dest_path=None, hash=False, firmware=False):
if (int(self.port) == 443):
print("Wrapping socket")
s = ssl.wrap_socket(s)

print("Sending request")
# Request File
s.sendall(self._http_get(req, "{}:{}".format(self.ip, self.port)))

try:
content = bytearray()
fp = None
Expand All @@ -247,6 +252,7 @@ def get_data(self, req, dest_path=None, hash=False, firmware=False):
fp = open(dest_path, 'wb')

if firmware:
print_debug(4, "Starting OTA...")
pycom.ota_start()

h = uhashlib.sha1()
Expand Down
9 changes: 6 additions & 3 deletions esp32/frozen/Pybytes/_pybytes_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ class constants:
__TYPE_OTA = 0x05
__TYPE_FCOTA = 0x06
__TYPE_PONG = 0x07
__TYPE_PYMESH = 0x0D
__TYPE_PYBYTES = 0x0E
__TYPE_RELEASE_INFO = 0x0B
__TYPE_RELEASE_DEPLOY = 0x0A
__TYPE_RELEASE_INFO = 0x0B
__TYPE_DEVICE_NETWORK_DEPLOY = 0x0C
__TYPE_PYMESH = 0x0D
__TYPE_PYBYTES = 0x0E
__TYPE_ML = 0x0F
__PYBYTES_PROTOCOL = ">B%ds"
__PYBYTES_PROTOCOL_PING = ">B"
__PYBYTES_INTERNAL_PROTOCOL = ">BBH"
Expand All @@ -90,6 +91,8 @@ class constants:
__COMMAND_ANALOG_WRITE = 4
__COMMAND_CUSTOM_METHOD = 5
__COMMAND_CUSTOM_LOCATION = 6
__COMMAND_START_SAMPLE = 7
__COMMAND_DEPLOY_MODEL = 8

__FCOTA_COMMAND_HIERARCHY_ACQUISITION = 0x00
__FCOTA_COMMAND_FILE_ACQUISITION = 0x01
Expand Down
176 changes: 176 additions & 0 deletions esp32/frozen/Pybytes/_pybytes_machine_learning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
'''
Copyright (c) 2020, Pycom Limited.
This software is licensed under the GNU GPL version 3 or any
later version, with permitted additional terms. For more information
see the Pycom Licence v1.0 document supplied with this file, or
available at https://www.pycom.io/opensource/licensing
'''

import math
import json

try:
from pybytes_debug import print_debug
except:
from _pybytes_debug import print_debug

try:
import urequest
except:
import _urequest as urequest

try:
from pybytes_constants import constants
except:
from _pybytes_constants import constants

import pycom

try:
from LIS2HH12 import *
except:
print_debug(5, "LIS2HH12 not imported")

# 20 seconds, max window in time for recording
MAX_LEN_MSEC = const(20000)

# 350Hz, max frequency
MAX_FREQ_HZ = const(350)


class MlFeatures():
def __init__(self, pybytes_protocol=None, parameters=None):
if parameters is not None:
self.__length = parameters["length"]
self.__label = parameters["label"]
self.__sampleName = parameters["sampleName"]
self.__type = parameters["type"]
self.__device = parameters["device"]
self.__model = parameters["model"]
self.__mlSample = parameters["mlSample"]
self.__frequency = parameters["frequency"]
self.__pybytes_protocol = pybytes_protocol
self.__data = []

def _debug_hack(self, pybytes):
self.__pybytes = pybytes

def start_sampling(self, pin):
# here define the required libraries
try:
from pysense import Pysense
except:
print_debug(5, "pysense not imported")

try:
from pytrack import Pytrack
except:
print_debug(5, "pytrack not imported")

lib = False
try:
py = Pysense()
lib = True
except NameError:
print_debug(5, "Pysense not defined")

if not lib:
try:
py = Pytrack()
except NameError:
print_debug(5, "Check if Pysense/Pytrack libraries are loaded")
return

try:
li = LIS2HH12(py)
except NameError:
print_debug(5, "LIS2HH12 library are not loaded")
return
li.set_odr(ODR_400_HZ)

# make the max record length to 20 seconds
self.__length = min(MAX_LEN_MSEC, self.__length)

# make the max frequency to 350Hz
self.__frequency = min(MAX_FREQ_HZ, self.__frequency)

# compute time interval between 2 consecutive samples
delta_t_us = int(1000000.0 / self.__frequency)
# compute the number of samples to be acquisition
samples_num = math.ceil(self.__length * self.__frequency / 1000) + 1

try:
pycom.heartbeat(False)
pycom.rgbled(0x7f7f00)
except:
pass
time.sleep(0.5)

self.__data = []
index = 0
print("Start acquisition data for %d msec, freq %d Hz" % (self.__length, self.__frequency))

next_ts = time.ticks_us()
ts_orig = next_ts
while True:
while time.ticks_diff(next_ts, time.ticks_us()) > 0:
pass
acc = li.acceleration()
ts = next_ts
self.__data.append((ts - ts_orig, acc))
next_ts = ts + delta_t_us
index += 1
if index >= samples_num:
break # done

print("Done acquisition %d samples, real freq %.1f Hz" % (index, index / (self.__length / 1000)))
self._parse_data(pin)

def _send_data(self, data, pin, acc, ts):
if self.__pybytes_protocol is not None:
if self.__type == 2:
self.__label = self.__sampleName
self.__pybytes_protocol.send_pybytes_custom_method_values(pin, [
data],
'sample/{}/{}/{}/{}/{}'.format(self.__label, self.__type, self.__model, self.__device, self.__mlSample))
else:
self.__pybytes.send_signal(pin & 0xFF, str((int(ts / 1000), acc)))

def _parse_data(self, pin):
print("_parse_data, %d samples" % len(self.__data))
try:
pycom.rgbled(0x8d05f5)
except:
pass
data = ['{"data": "ml"}']
for (ts, acc) in self.__data:
data.append('{' + '"data": [{},{},{}], "ms": {}'.format(acc[0], acc[1], acc[2], int(ts / 1000)) + '}')
if len(data) > 25:
self._send_data(data, pin, acc, ts)
data = ['{"data": "ml"}']
self._send_data(data, pin, acc, ts)
try:
pycom.heartbeat(True)
except:
pass

def deploy_model(self, modelId, silent=False):
try:
file = '/flash/model_definition.json'
modelDefinition = {}
url = '{}://{}/ml/{}'.format(
constants.__DEFAULT_PYCONFIG_PROTOCOL,
constants.__DEFAULT_PYCONFIG_DOMAIN,
modelId
)
print_debug(2, '{}'.format(url))
result = urequest.get(url, headers={'content-type': 'application/json'})
modelDefinition = json.loads(result.content.decode())
print_debug(2, 'modelDefinition: {}'.format(modelDefinition))
f = open(file, 'w')
f.write(json.dumps(modelDefinition).encode('utf-8'))
f.close()
print_debug(2, "Model definition written to {}".format(file))
except Exception as e:
if not silent:
print_debug(2, "Exception: {}".format(e))
Loading