Skip to content

Commit 9ebffbd

Browse files
LisaLisa
authored andcommitted
Changed queue setup in plugins, there are now three queues: script,rule and value
Changed queue processing: there are now three independant queue processes: script, rule and value Changed AP SSID name to be unique Changed reboot sequence Changed db-table references to deepcopy Changed SOC unique identifier from binary to string Changed LoadForm to use deepcopy Changed device/controller delete: now it does a reload after 3 secs Changed I2C/SPI/UART setup in devices Fixed several bugs
1 parent cf2bca9 commit 9ebffbd

24 files changed

Lines changed: 696 additions & 374 deletions

modules/modcopy.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cd unix
22
cp ../../../micropython/micropython-async/aswitch.py .
33
cp ../../../micropython/micropython-async/asyn.py .
4+
cp ../../../micropython/micropython-lib/copy/copy.py .
45
cp ../../../micropython/micropython/drivers/dht/dht.py .
56
cp ../../../micropython/micropython/drivers/onewire/ds18x20.py .
67
cp ../../../micropython/micropython-lib/ffilib/ffilib.py .
@@ -13,6 +14,7 @@ cp ../../../micropython/micropython-lib/pkg_resources/pkg_resources.py .
1314
cp ../../../micropython/micropython-lib/re-pcre/re.py .
1415
cp ../../../micropython/micropython/drivers/sdcard/sdcard.py .
1516
cp ../../../micropython/micropython/drivers/display/ssd1306.py .
17+
cp ../../../micropython/micropython-lib/types/types.py .
1618
cp ../../../micropython/micropython-lib/uaiohttpclient/uaiohttpclient.py .
1719
cp -fR ../../../micropython/modbus/uModbus .
1820
mv -f uModbus umodbus
@@ -48,6 +50,7 @@ cp ../../../micropython/micropython/drivers/onewire/ds18x20.py .
4850
cp ../../../micropython/micropython/drivers/onewire/onewire.py .
4951
ln -sf ../unix/aswitch.py
5052
ln -sf ../unix/asyn.py
53+
ln -sf ../unix/copy.py
5154
ln -sf ../unix/collections
5255
ln -sf ../unix/console_sink.py
5356
ln -sf ../unix/filedb.py
@@ -63,6 +66,7 @@ ln -sf ../unix/re.py
6366
ln -sf ../unix/sdcard.py
6467
ln -sf ../unix/ssd1306.py
6568
ln -sf ../unix/syslog_sink.py
69+
ln -sf ../unix/types.py
6670
ln -sf ../unix/uaiohttpclient.py
6771
ln -sf ../unix/uasyncio
6872
ln -sf ../unix/ulog.py
@@ -84,6 +88,7 @@ cp ../../../micropython/micropython/drivers/onewire/ds18x20.py .
8488
cp ../../../micropython/micropython/drivers/onewire/onewire.py .
8589
ln -sf ../unix/aswitch.py
8690
ln -sf ../unix/asyn.py
91+
ln -sf ../unix/copy.py
8792
ln -sf ../unix/collections
8893
ln -sf ../unix/console_sink.py
8994
ln -sf ../unix/filedb.py
@@ -99,6 +104,7 @@ ln -sf ../unix/re.py
99104
ln -sf ../unix/sdcard.py
100105
ln -sf ../unix/ssd1306.py
101106
ln -sf ../unix/syslog_sink.py
107+
ln -sf ../unix/types.py
102108
ln -sf ../unix/uaiohttpclient.py
103109
ln -sf ../unix/uasyncio
104110
ln -sf ../unix/ulog.py

src/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,23 @@ def main(**params):
7575

7676
# Create async tasks
7777
loop.create_task(core._plugins.asyncdevices())
78-
loop.create_task(core._scripts.asyncscripts())
78+
loop.create_task(core._plugins.asyncvalues())
79+
# check if rules/scripts are needed!
80+
advanced = db.advancedTable.getrow()
81+
if advanced["scripts"] == "on": loop.create_task(core._scripts.asyncscripts())
82+
if advanced["rules"] == "on": loop.create_task(core._scripts.asyncrules())
7983

8084
# Run main loop
8185
core._log.info("Main: uPyEasy Main Async Loop on IP adress: "+ip_address+":"+str(port))
8286
while True:
83-
try:
84-
app.run(host=ip_address, port=port, debug=False, log=core._log)
85-
except Exception as e:
86-
core._log.debug("Main: Async loop exception: {}".format(repr(e)))
87+
if _debug < 2: app.run(host=ip_address, port=port, debug=False, log=core._log)
88+
else:
89+
try:
90+
app.run(host=ip_address, port=port, debug=False, log=core._log)
91+
except Exception as e:
92+
core._log.debug("Main: Async loop exception: {}".format(repr(e)))
93+
import sys
94+
sys.print_exception(e)
8795
#app.run(host=ip_address, port=config["port"],debug=True, key=ssl.key, cert=ssl.cert) # SSL version
8896
else:
8997
#No network, exit!

src/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Usage : Database functions to store and retrieve data
77
#
88
# Copyright (c) Lisa Esselink. All rights reserved.
9-
# Licensend under the Creative Commons Attribution-NonCommercial 4.0 International License.
9+
# Licensend under the Creative Commons Attribution-NonCommercial 4.0 International License.
1010
# See LICENSE file in the project root for full license information.
1111
#
1212

src/hal.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Usage : Run HW specific commands
99
#
1010
# Copyright (c) Lisa Esselink. All rights reserved.
11-
# Licensend under the Creative Commons Attribution-NonCommercial 4.0 International License.
11+
# Licensend under the Creative Commons Attribution-NonCommercial 4.0 International License.
1212
# See LICENSE file in the project root for full license information.
1313
#
1414

@@ -122,7 +122,12 @@ def init_network(self, mode = core.NET_STA):
122122
self._nic = wifi.WLAN(wifi.AP_IF)
123123
core._nic = self._nic
124124
self._nic.active(True)
125-
self._nic.config(essid="uPyEasy")
125+
machinename = self._utils.get_upyeasy_name()
126+
if machinename == core.initial_upyeasyname:
127+
ssidname = "{}-{}".format(core.initial_upyeasyname,_utils.get_machine_id())
128+
else:
129+
ssidname = "{}-{}".format(core.initial_upyeasyname,machinename)
130+
self._nic.config(essid=ssidname)
126131
ip_address_v4 = self._nic.ifconfig()[0]
127132
core.initial_upyeasywifi = core.NET_AP
128133
else:
@@ -158,7 +163,12 @@ def init_network(self, mode = core.NET_STA):
158163
self._log.debug("Hal: init esp32 network: STA+AP mode")
159164
self._apnic = wifi.WLAN(wifi.AP_IF)
160165
self._apnic.active(True)
161-
self._apnic.config(essid="uPyEasy")
166+
machinename = self._utils.get_upyeasy_name()
167+
if machinename == core.initial_upyeasyname:
168+
ssidname = "{}-{}".format(core.initial_upyeasyname,_utils.get_machine_id())
169+
else:
170+
ssidname = "{}-{}".format(core.initial_upyeasyname,machinename)
171+
self._apnic.config(essid=ssidname)
162172
core.initial_upyeasywifi = core.NET_STA_AP
163173
else:
164174
core.initial_upyeasywifi = core.NET_STA
@@ -171,7 +181,12 @@ def init_network(self, mode = core.NET_STA):
171181
self._nic = wifi.WLAN(wifi.AP_IF)
172182
core._nic = self._nic
173183
self._nic.active(True)
174-
self._nic.config(essid="uPyEasy")
184+
machinename = self._utils.get_upyeasy_name()
185+
if machinename == core.initial_upyeasyname:
186+
ssidname = "{}-{}".format(core.initial_upyeasyname,_utils.get_machine_id())
187+
else:
188+
ssidname = "{}-{}".format(core.initial_upyeasyname,machinename)
189+
self._nic.config(essid=ssidname)
175190
ip_address_v4 = self._nic.ifconfig()[0]
176191
core.initial_upyeasywifi = core.NET_AP
177192

0 commit comments

Comments
 (0)