From b92cea79b32fc89bff4153f5f5f0840a988a52d2 Mon Sep 17 00:00:00 2001 From: gijsio <67470426+gijsio@users.noreply.github.com> Date: Tue, 15 Jun 2021 09:11:09 +0200 Subject: [PATCH 1/3] Depracation notice (#148) * Create readme.md * for reference only * partition -> part --- pymesh/readme.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pymesh/readme.md diff --git a/pymesh/readme.md b/pymesh/readme.md new file mode 100644 index 0000000..0be1a7a --- /dev/null +++ b/pymesh/readme.md @@ -0,0 +1,3 @@ +# For reference only + +This library is the open-source part of the Pymesh LoRa Firmware which can be provisioned through Pybytes and cannot be used as stand-alone on a Pybytes or Pygate type firmware. Please check the [Pycom Documentation](https://docs.pycom.io/pybytes/pymeshintegration/provisioning/) on how to get Pymesh type firmware provisioned to your device. You will not have to use this library in your project or flash it to your device separately, as it is already included in the firmware. From 478211f5873f90aebff99ea8dd83c9379867dd8e Mon Sep 17 00:00:00 2001 From: gijsio <67470426+gijsio@users.noreply.github.com> Date: Thu, 17 Jun 2021 16:58:10 +0200 Subject: [PATCH 2/3] added missing parentheses --- shields/pysense_2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shields/pysense_2.py b/shields/pysense_2.py index 4edcd95..ff793e7 100644 --- a/shields/pysense_2.py +++ b/shields/pysense_2.py @@ -48,7 +48,7 @@ lt = LTR329ALS01(py) -print("Light (channel Blue, channel Red): " + str(lt.light()," Lux: ", str(lt.lux()), "lx")) +print("Light (channel Blue, channel Red): " + str(lt.light())," Lux: ", str(lt.lux()), "lx") li = LIS2HH12(py) print("Acceleration: " + str(li.acceleration())) @@ -69,4 +69,4 @@ pybytes.send_signal(3, lt.light()) pybytes.send_signal(4, li.acceleration()) pybytes.send_battery_level(int(battery_percentage)) - print("Sent data to pybytes") \ No newline at end of file + print("Sent data to pybytes") From 75d0e67cb421e0576a3a9677bb0d9d81f27ebdb7 Mon Sep 17 00:00:00 2001 From: Peter Putz Date: Wed, 27 Oct 2021 14:39:49 +0200 Subject: [PATCH 3/3] pymesh: do not (re-)create LoRa instances in pymesh_config It seems there is a rare chance to end up with a frozen device at the point where the lora=LoRa() object is recreated. There is no real need to do this inside pymesh_config, so as a workaround we simply make one object only and pass the lora_mac --- pymesh/pymesh_frozen/lib/pymesh_config.py | 12 ++++-------- pymesh/pymesh_frozen/lorawan/main.py | 9 +++++++-- pymesh/pymesh_frozen/main.py | 9 +++++++-- pymesh/pymesh_frozen/main_BR.py | 7 ++++++- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/pymesh/pymesh_frozen/lib/pymesh_config.py b/pymesh/pymesh_frozen/lib/pymesh_config.py index 798f8f8..74a0292 100644 --- a/pymesh/pymesh_frozen/lib/pymesh_config.py +++ b/pymesh/pymesh_frozen/lib/pymesh_config.py @@ -5,7 +5,6 @@ see the Pycom Licence v1.0 document supplied with this file, or available at https://www.pycom.io/opensource/licensing ''' -import ubinascii import json from network import LoRa @@ -78,10 +77,7 @@ def write_config(pymesh_config, force_restart = False): time.sleep(1) machine.deepsleep(1000) - def check_mac(pymesh_config): - lora = LoRa(mode=LoRa.LORA, region= LoRa.EU868) - MAC = int(str(ubinascii.hexlify(lora.mac()))[2:-1], 16) - + def check_mac(pymesh_config, MAC): if pymesh_config.get('MAC') is None: # if MAC config unspecified, set it to LoRa MAC print_debug(3, "Set MAC in config file as " + str(MAC)) @@ -102,7 +98,7 @@ def check_mac(pymesh_config): print_debug(3, "MAC ok" + str(MAC)) - def read_config(): + def read_config(MAC): file = PymeshConfig.CONFIG_FILENAME pymesh_config = {} error_file = True @@ -138,10 +134,10 @@ def read_config(): pymesh_config['br_ena'] = PymeshConfig.BR_ENABLE pymesh_config['br_prio'] = PymeshConfig.BR_PRIORITY - PymeshConfig.check_mac(pymesh_config) + PymeshConfig.check_mac(pymesh_config, MAC) print_debug(3, "Default settings:" + str(pymesh_config)) PymeshConfig.write_config(pymesh_config, True) - PymeshConfig.check_mac(pymesh_config) + PymeshConfig.check_mac(pymesh_config, MAC) print_debug(3, "Settings:" + str(pymesh_config)) return pymesh_config diff --git a/pymesh/pymesh_frozen/lorawan/main.py b/pymesh/pymesh_frozen/lorawan/main.py index 223cee6..33f33da 100644 --- a/pymesh/pymesh_frozen/lorawan/main.py +++ b/pymesh/pymesh_frozen/lorawan/main.py @@ -1,5 +1,7 @@ -import pycom import time +import ubinascii +import pycom +from network import LoRa try: from pymesh_config import PymeshConfig @@ -28,8 +30,11 @@ def new_message_cb(rcv_ip, rcv_port, rcv_data): pycom.heartbeat(False) +lora = LoRa(mode=LoRa.LORA, region= LoRa.EU868) +lora_mac = int(str(ubinascii.hexlify(lora.mac()))[2:-1], 16) + # read config file, or set default values -pymesh_config = PymeshConfig.read_config() +pymesh_config = PymeshConfig.read_config(lora_mac) #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) diff --git a/pymesh/pymesh_frozen/main.py b/pymesh/pymesh_frozen/main.py index 4cf6fbd..5d7c17a 100644 --- a/pymesh/pymesh_frozen/main.py +++ b/pymesh/pymesh_frozen/main.py @@ -1,5 +1,7 @@ -import pycom import time +import ubinascii +import pycom +from network import LoRa try: from pymesh_config import PymeshConfig @@ -28,8 +30,11 @@ def new_message_cb(rcv_ip, rcv_port, rcv_data): pycom.heartbeat(False) +lora = LoRa(mode=LoRa.LORA, region= LoRa.EU868) +lora_mac = int(str(ubinascii.hexlify(lora.mac()))[2:-1], 16) + # read config file, or set default values -pymesh_config = PymeshConfig.read_config() +pymesh_config = PymeshConfig.read_config(lora_mac) #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) diff --git a/pymesh/pymesh_frozen/main_BR.py b/pymesh/pymesh_frozen/main_BR.py index 3c53257..fdb9780 100644 --- a/pymesh/pymesh_frozen/main_BR.py +++ b/pymesh/pymesh_frozen/main_BR.py @@ -1,5 +1,7 @@ import time +import ubinascii import pycom +from network import LoRa # 2 = test pybytes OTA feature # 4 = added device_id (pybytes token) in the packets to BR @@ -66,8 +68,11 @@ def new_br_message_cb(rcv_ip, rcv_port, rcv_data, dest_ip, dest_port): pycom.heartbeat(False) +lora = LoRa(mode=LoRa.LORA, region= LoRa.EU868) +lora_mac = int(str(ubinascii.hexlify(lora.mac()))[2:-1], 16) + # read config file, or set default values -pymesh_config = PymeshConfig.read_config() +pymesh_config = PymeshConfig.read_config(lora_mac) #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb)