micrOSDevToolKit 2.9.10__py3-none-any.whl → 2.10.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of micrOSDevToolKit might be problematic. Click here for more details.

Files changed (41) hide show
  1. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +19 -19
  2. micrOS/source/Common.py +4 -4
  3. micrOS/source/InterConnect.py +14 -11
  4. micrOS/source/LM_espnow.py +27 -1
  5. micrOS/source/LM_intercon.py +3 -0
  6. micrOS/source/LM_light_sensor.py +7 -15
  7. micrOS/source/LM_oled_ui.py +18 -22
  8. micrOS/source/LM_oledui.py +13 -16
  9. micrOS/source/LM_presence.py +8 -11
  10. micrOS/source/LM_system.py +7 -6
  11. micrOS/source/LM_telegram.py +21 -16
  12. micrOS/source/Shell.py +22 -19
  13. micrOS/source/Tasks.py +30 -15
  14. micrOS/source/Web.py +3 -2
  15. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  16. {micrOSDevToolKit-2.9.10.dist-info → micrOSDevToolKit-2.10.2.dist-info}/METADATA +60 -28
  17. {micrOSDevToolKit-2.9.10.dist-info → micrOSDevToolKit-2.10.2.dist-info}/RECORD +41 -38
  18. toolkit/DevEnvOTA.py +13 -9
  19. toolkit/dashboard_apps/SystemTest.py +17 -6
  20. toolkit/lib/Repository.py +64 -0
  21. toolkit/lib/micrOSClient.py +25 -6
  22. toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
  23. toolkit/simulator_lib/aioespnow.py +28 -0
  24. toolkit/socketClient.py +2 -3
  25. toolkit/workspace/precompiled/Common.mpy +0 -0
  26. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  27. toolkit/workspace/precompiled/LM_espnow.py +27 -1
  28. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  29. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  30. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  31. toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
  32. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  33. toolkit/workspace/precompiled/LM_system.mpy +0 -0
  34. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  35. toolkit/workspace/precompiled/Shell.mpy +0 -0
  36. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  37. toolkit/workspace/precompiled/Web.mpy +0 -0
  38. {micrOSDevToolKit-2.9.10.data → micrOSDevToolKit-2.10.2.data}/scripts/devToolKit.py +0 -0
  39. {micrOSDevToolKit-2.9.10.dist-info → micrOSDevToolKit-2.10.2.dist-info}/LICENSE +0 -0
  40. {micrOSDevToolKit-2.9.10.dist-info → micrOSDevToolKit-2.10.2.dist-info}/WHEEL +0 -0
  41. {micrOSDevToolKit-2.9.10.dist-info → micrOSDevToolKit-2.10.2.dist-info}/top_level.txt +0 -0
@@ -21,7 +21,7 @@
21
21
  1
22
22
  ],
23
23
  "Tasks.py": [
24
- 9.55,
24
+ 9.38,
25
25
  12
26
26
  ],
27
27
  "Config.py": [
@@ -33,11 +33,11 @@
33
33
  0
34
34
  ],
35
35
  "Shell.py": [
36
- 9.11,
36
+ 9.34,
37
37
  1
38
38
  ],
39
39
  "Notify.py": [
40
- 8.46,
40
+ 9.74,
41
41
  3
42
42
  ],
43
43
  "Types.py": [
@@ -49,12 +49,12 @@
49
49
  4
50
50
  ],
51
51
  "Common.py": [
52
- 8.71,
52
+ 9.78,
53
53
  34
54
54
  ],
55
55
  "InterConnect.py": [
56
- 9.4,
57
- 1
56
+ 9.41,
57
+ 3
58
58
  ],
59
59
  "Debug.py": [
60
60
  8.4,
@@ -65,7 +65,7 @@
65
65
  8
66
66
  ],
67
67
  "Espnow.py": [
68
- 8.86,
68
+ 9.43,
69
69
  1
70
70
  ],
71
71
  "Scheduler.py": [
@@ -109,11 +109,11 @@
109
109
  0
110
110
  ],
111
111
  "LM_oled_ui.py": [
112
- 9.02,
112
+ 8.64,
113
113
  0
114
114
  ],
115
115
  "LM_system.py": [
116
- 8.26,
116
+ 8.19,
117
117
  5
118
118
  ],
119
119
  "LM_robustness.py": [
@@ -233,7 +233,7 @@
233
233
  0
234
234
  ],
235
235
  "LM_oledui.py": [
236
- 8.16,
236
+ 7.95,
237
237
  0
238
238
  ],
239
239
  "LM_espnow.py": [
@@ -241,7 +241,7 @@
241
241
  0
242
242
  ],
243
243
  "LM_telegram.py": [
244
- 9.57,
244
+ 9.58,
245
245
  0
246
246
  ],
247
247
  "LM_OV2640.py": [
@@ -261,7 +261,7 @@
261
261
  0
262
262
  ],
263
263
  "LM_light_sensor.py": [
264
- 8.97,
264
+ 9.17,
265
265
  0
266
266
  ],
267
267
  "LM_rp2w.py": [
@@ -269,7 +269,7 @@
269
269
  0
270
270
  ],
271
271
  "LM_presence.py": [
272
- 8.77,
272
+ 8.9,
273
273
  4
274
274
  ],
275
275
  "LM_trackball.py": [
@@ -298,7 +298,7 @@
298
298
  ],
299
299
  "LM_intercon.py": [
300
300
  8.18,
301
- 4
301
+ 0
302
302
  ],
303
303
  "LM_ds18.py": [
304
304
  6.0,
@@ -315,11 +315,11 @@
315
315
  },
316
316
  "summary": {
317
317
  "core": [
318
- 3367,
318
+ 3380,
319
319
  23
320
320
  ],
321
321
  "load": [
322
- 9061,
322
+ 9077,
323
323
  55
324
324
  ],
325
325
  "core_dep": [
@@ -330,8 +330,8 @@
330
330
  true,
331
331
  5
332
332
  ],
333
- "core_score": 9.09,
334
- "load_score": 8.21,
335
- "version": "2.9.9-0"
333
+ "core_score": 9.22,
334
+ "load_score": 8.2,
335
+ "version": "2.10.2-0"
336
336
  }
337
337
  }
micrOS/source/Common.py CHANGED
@@ -2,7 +2,6 @@
2
2
  micrOS Load Module programming Official API-s
3
3
  Designed by Marcell Ban aka BxNxM
4
4
  """
5
-
6
5
  from Server import Server, WebCli
7
6
  from Debug import errlog_add, console_write
8
7
  from Logger import logger, log_get
@@ -126,18 +125,19 @@ def manage_task(tag, operation):
126
125
  raise Exception(f"Invalid operation: {operation}")
127
126
 
128
127
 
129
- def exec_cmd(cmd, skip_check=False):
128
+ def exec_cmd(cmd, jsonify:bool=None, skip_check=False):
130
129
  """
131
130
  [LM] Single (sync) LM execution
132
131
  :param cmd: command string list
132
+ :param jsonify: request json output
133
133
  :param skip_check: skip cmd type check, micropython bug
134
134
  return state, output
135
135
  """
136
136
  # [BUG] Solution with isinstance/type is not reliable... micropython 1.22
137
137
  # Invalid type, must be list: <class list>" ...
138
138
  if skip_check:
139
- return lm_exec(cmd)
140
- return lm_exec(cmd) if isinstance(cmd, list) else False, f"Invalid type, must be list: {type(cmd)}"
139
+ return lm_exec(cmd, jsonify=jsonify)
140
+ return lm_exec(cmd, jsonify=jsonify) if isinstance(cmd, list) else False, f"CMD {type(cmd)}, must be list!"
141
141
 
142
142
 
143
143
  def notify(text=None) -> bool:
@@ -1,6 +1,6 @@
1
1
  from socket import getaddrinfo, SOCK_STREAM
2
2
  from re import compile
3
- import uasyncio as asyncio
3
+ from uasyncio import open_connection
4
4
  from Debug import errlog_add
5
5
  from Config import cfgget
6
6
  from Server import Server
@@ -22,7 +22,7 @@ class InterCon:
22
22
  pattern = compile(r'^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$')
23
23
  return bool(pattern.match(str_in))
24
24
 
25
- async def send_cmd(self, host, cmd):
25
+ async def send_cmd(self, host:str, cmd:list):
26
26
  """
27
27
  Async Main method to implement device-device communication with
28
28
  - dhcp host resolve and IP caching
@@ -50,7 +50,7 @@ class InterCon:
50
50
  if InterCon.validate_ipv4(host):
51
51
  try:
52
52
  # Create socket object
53
- self.reader, self.writer = await asyncio.open_connection(host, InterCon.PORT)
53
+ self.reader, self.writer = await open_connection(host, InterCon.PORT)
54
54
  # Send command over TCP/IP
55
55
  output = await self.__run_command(cmd, hostname)
56
56
  except OSError as e:
@@ -72,14 +72,13 @@ class InterCon:
72
72
  errlog_add(f"[ERR][intercon] Invalid host: {host}")
73
73
  return ''
74
74
 
75
- async def __run_command(self, cmd, hostname):
75
+ async def __run_command(self, cmd:list, hostname:str):
76
76
  """
77
77
  Implements receive data on open connection, command query and result collection
78
78
  :param cmd: command string to server socket shell
79
79
  :param hostname: hostname for prompt checking
80
80
  Return None here will trigger retry mechanism... + deletes cached IP
81
81
  """
82
- cmd = str.encode(cmd)
83
82
  data, prompt = await self.__receive_data()
84
83
  if "Connection is busy. Bye!" in prompt:
85
84
  return None
@@ -87,7 +86,7 @@ class InterCon:
87
86
  if hostname is None or prompt is None or str(prompt).replace('$', '').strip() == str(hostname).split('.')[0]:
88
87
  # Run command on validated device
89
88
  # TODO: Handle multiple cmd as input, separated by ; (????)
90
- self.writer.write(cmd)
89
+ self.writer.write(str.encode(' '.join(cmd)))
91
90
  await self.writer.drain()
92
91
  data, _ = await self.__receive_data(prompt=prompt)
93
92
  if data == '\0':
@@ -141,7 +140,7 @@ class InterCon:
141
140
  return data, prompt
142
141
 
143
142
 
144
- async def _send_cmd(host, cmd, com_obj):
143
+ async def _send_cmd(host:str, cmd:list, com_obj):
145
144
  """
146
145
  Async send command wrapper for further async task integration and sync send_cmd usage (main)
147
146
  :param host: hostname / IP address
@@ -154,12 +153,12 @@ async def _send_cmd(host, cmd, com_obj):
154
153
  out = await com_obj.send_cmd(host, cmd) # Send CMD
155
154
  if out is not None: # Retry mechanism
156
155
  break
157
- await asyncio.sleep_ms(100) # Retry mechanism
156
+ await com_obj.task.feed(sleep_ms=100) # Retry mechanism
158
157
  com_obj.task.out = '' if out is None else out
159
158
  return com_obj.task.out
160
159
 
161
160
 
162
- def send_cmd(host, cmd):
161
+ def send_cmd(host:str, cmd:list|str) -> dict:
163
162
  """
164
163
  Sync wrapper of async _send_cmd (InterCon.send_cmd consumer with retry)
165
164
  :param host: hostname / IP address
@@ -167,11 +166,15 @@ def send_cmd(host, cmd):
167
166
  """
168
167
  def _tagify():
169
168
  nonlocal host, cmd
170
- _mod = cmd.split(' ')[0].strip()
169
+ _mod = cmd[0]
171
170
  if InterCon.validate_ipv4(host):
172
171
  return f"{'.'.join(host.split('.')[-2:])}.{_mod}"
173
172
  return f"{host.replace('.local', '')}.{_mod}"
174
173
 
174
+ # Handle legacy string input
175
+ if isinstance(cmd, str):
176
+ cmd = cmd.split()
177
+
175
178
  com_obj = InterCon()
176
179
  tag = f"con.{_tagify()}"
177
180
  started = com_obj.task.create(callback=_send_cmd(host, cmd, com_obj), tag=tag)
@@ -182,7 +185,7 @@ def send_cmd(host, cmd):
182
185
  return result
183
186
 
184
187
 
185
- def host_cache():
188
+ def host_cache() -> dict:
186
189
  """
187
190
  Dump InterCon connection cache
188
191
  """
@@ -1,23 +1,49 @@
1
1
  import Espnow
2
2
 
3
3
  def load():
4
+ """
5
+ Initialize ESPNOW protocal
6
+ """
4
7
  return Espnow.initialize()
5
8
 
6
- def send(peer, msg='ping'):
9
+ def send(peer, msg='modules'):
10
+ """
11
+ Send message to peer (by mac address)
12
+ :param peer: mac address of espnow device
13
+ :param msg: message string/load module call
14
+ """
7
15
  return Espnow.espnow_send(peer, msg)
8
16
 
9
17
  def start_server():
18
+ """
19
+ Start ESPNOW server/listener
20
+ - this can receive espnow messages
21
+ - it includes Load Module execution logic (beta)
22
+ """
10
23
  return Espnow.espnow_server()
11
24
 
12
25
  def stats():
26
+ """
27
+ Get ESPNOW stats
28
+ """
13
29
  return Espnow.stats()
14
30
 
15
31
  def add_peer(peer):
32
+ """
33
+ Add ESPNOW peer to known hosts
34
+ - It is needed before first send(...)
35
+ """
16
36
  now = Espnow.initialize()
17
37
  return Espnow.add_peer(now, peer)
18
38
 
19
39
  def mac_address():
40
+ """
41
+ Get ESPNOW compatible mac address
42
+ """
20
43
  return Espnow.mac_address()
21
44
 
22
45
  def help():
46
+ """
47
+ [beta] ESPNOW sender/receiver with LM execution
48
+ """
23
49
  return 'load', 'send <peer> "ping"', 'start_server', 'add_peer <peer>', 'stats', 'mac_address'
@@ -4,6 +4,7 @@ from Common import syslog
4
4
 
5
5
  def sendcmd(*args, **kwargs):
6
6
  """
7
+ [!!!] OBSOLETE - NEW SYNTAX: system top >>node01.local
7
8
  Implements send command function towards micrOS devices
8
9
  example: sendcmd "hello" host="IP/hostname.local") OR sendcmd host="IP/hostname.local" cmd="system rssi")
9
10
  :param host[0]: host IP or Hostname
@@ -34,6 +35,7 @@ def sendcmd(*args, **kwargs):
34
35
 
35
36
  def addr_cache():
36
37
  """
38
+ [!!!] OBSOLETE -> new command: system hosts
37
39
  Dump intercon connection cache
38
40
  :return dict: device-ip pairs
39
41
  """
@@ -46,6 +48,7 @@ def addr_cache():
46
48
 
47
49
  def help(widgets=False):
48
50
  """
51
+ [!!!] OBSOLETE
49
52
  [i] micrOS LM naming convention - built-in help message
50
53
  :return tuple:
51
54
  (widgets=False) list of functions implemented by this application
@@ -5,12 +5,8 @@ ADC.ATTN_2_5DB — the full range voltage: 1.5V
5
5
  ADC.ATTN_6DB — the full range voltage: 2.0V
6
6
  ADC.ATTN_11DB — the full range voltage: 3.3V
7
7
  """
8
- from Common import SmartADC, micro_task
8
+ from Common import SmartADC, micro_task, exec_cmd
9
9
  from Types import resolve
10
- try:
11
- import LM_intercon as InterCon
12
- except:
13
- InterCon = None
14
10
  from microIO import bind_pin, pinmap_search
15
11
 
16
12
 
@@ -76,19 +72,15 @@ async def _task(on, off, threshold, tolerance=2, check_ms=5000):
76
72
  # TURN ON
77
73
  if percent <= threshold:
78
74
  if on != last_ev:
79
- if InterCon is not None:
80
- host = on[0]
81
- cmd = ' '.join(on[1:])
82
- InterCon.send_cmd(host, cmd)
83
- my_task.out = f"{percent}% <= threshold: {threshold}% - ON"
75
+ host = on[0]
76
+ state, _ = exec_cmd(on[1:] + [f">>{host}"], jsonify=True, skip_check=True)
77
+ my_task.out = f"{percent}% <= threshold: {threshold}% - ON [{'OK' if state else 'NOK'}]"
84
78
  last_ev = on
85
79
  elif percent > threshold+tolerance: # +tolerance to avoid "on/off/on/off" on threshold limit
86
80
  if off != last_ev:
87
- if InterCon is not None:
88
- host = off[0]
89
- cmd = ' '.join(off[1:])
90
- InterCon.send_cmd(host, cmd)
91
- my_task.out = f"{percent}% > threshold: {threshold+tolerance}% - OFF"
81
+ host = off[0]
82
+ state, _ = exec_cmd(off[1:] + [f">>{host}"], jsonify=True, skip_check=True)
83
+ my_task.out = f"{percent}% > threshold: {threshold+tolerance}% - OFF [{'OK' if state else 'NOK'}]"
92
84
  last_ev = off
93
85
  await my_task.feed(sleep_ms=check_ms) # Sample every <check_ms> sec
94
86
 
@@ -7,13 +7,9 @@ from Common import syslog, exec_cmd, manage_task
7
7
  from machine import Pin
8
8
  from Types import resolve
9
9
  try:
10
- from LM_system import memory_usage
10
+ from LM_system import memory_usage, hosts
11
11
  except:
12
12
  memory_usage = None # Optional function handling
13
- try:
14
- import LM_intercon as InterCon
15
- except:
16
- InterCon = None # Optional function handling
17
13
  try:
18
14
  from LM_gameOfLife import next_gen as gol_nextgen, reset as gol_reset
19
15
  except:
@@ -228,6 +224,7 @@ class PageUI:
228
224
  self.page_callback_list[self.active_page]() # <== Execute page functions
229
225
  except Exception as e:
230
226
  PageUI.PAGE_UI_OBJ.show_msg = f"Err: {e}" # Show page error in msgbox
227
+ syslog(f"oled_ui render error: {e}")
231
228
  PageUI.DISPLAY.show()
232
229
  self.__power_save()
233
230
  else:
@@ -322,7 +319,7 @@ class PageUI:
322
319
  #####################################
323
320
  # PAGE GENERATORS #
324
321
  #####################################
325
- def intercon_page(self, host, cmd, run=False):
322
+ def intercon_page(self, host:str, cmd:list, run=False):
326
323
  """Generic interconnect page core - create multiple page with it"""
327
324
  posx, posy = 5, 12
328
325
 
@@ -331,10 +328,13 @@ class PageUI:
331
328
  self.open_intercons.append(host)
332
329
  try:
333
330
  # Send CMD to other device & show result
334
- data_meta = InterCon.send_cmd(host, cmd)
335
- self.cmd_task_tag = data_meta['tag']
336
- if "Task is Busy" in data_meta['verdict'] and not run:
337
- self.cmd_out = data_meta['verdict'] # Otherwise the task start output not relevant on UI
331
+ state, data_meta = exec_cmd(cmd + [f">>{host}"], jsonify=True, skip_check=True)
332
+ if state:
333
+ self.cmd_task_tag = data_meta['tag']
334
+ if "Task is Busy" in data_meta['verdict'] and not run:
335
+ self.cmd_out = data_meta['verdict'] # Otherwise the task start output not relevant on UI
336
+ else:
337
+ self.cmd_out = f"Error: {data_meta}"
338
338
  except Exception as e:
339
339
  self.cmd_out = str(e)
340
340
  self.open_intercons.remove(host)
@@ -344,7 +344,7 @@ class PageUI:
344
344
  return
345
345
  # Draw host + cmd details
346
346
  PageUI.DISPLAY.text(host, 0, posy)
347
- PageUI.DISPLAY.text(cmd, posx, posy+10)
347
+ PageUI.DISPLAY.text(' '.join(cmd), posx, posy+10)
348
348
  # Update display output with retrieved task result (by TaskID)
349
349
  if self.cmd_task_tag is not None:
350
350
  task_buffer = manage_task(self.cmd_task_tag, 'show').replace(' ', '')
@@ -373,7 +373,7 @@ class PageUI:
373
373
  try:
374
374
  cmd_list = cmd.strip().split()
375
375
  # Send CMD to other device & show result
376
- state, out = exec_cmd(cmd_list)
376
+ state, out = exec_cmd(cmd_list, skip_check=True)
377
377
  try:
378
378
  self.cmd_out = ''.join(out.strip().split()).replace(' ', '')
379
379
  except Exception:
@@ -409,13 +409,12 @@ def _sys_page():
409
409
 
410
410
 
411
411
  def _intercon_cache(line_limit=3):
412
- if InterCon is None:
413
- return False
414
412
  line_start = 15
415
413
  line_cnt = 1
416
414
  PageUI.DISPLAY.text("InterCon cache", 0, line_start)
417
- if sum([1 for _ in InterCon.host_cache()]) > 0:
418
- for key, val in InterCon.host_cache().items():
415
+ cache = hosts()["intercon"]
416
+ if sum([1 for _ in cache]) > 0:
417
+ for key, val in cache.items():
419
418
  key = key.split('.')[0]
420
419
  val = '.'.join(val.split('.')[-2:])
421
420
  PageUI.DISPLAY.text(f" {val} {key}", 0, line_start+(line_cnt*10))
@@ -502,7 +501,7 @@ def msgbox(msg='micrOS msg'):
502
501
  return 'Show msg'
503
502
 
504
503
 
505
- def intercon_genpage(cmd=None, run=False):
504
+ def intercon_genpage(cmd:str=None, run=False):
506
505
  """
507
506
  Create intercon pages dynamically :)
508
507
  - based on cmd value.
@@ -512,7 +511,7 @@ def intercon_genpage(cmd=None, run=False):
512
511
  """
513
512
  raw = cmd.split()
514
513
  host = raw[0]
515
- cmd = ' '.join(raw[1:])
514
+ cmd = raw[1:]
516
515
  try:
517
516
  # Create page for intercon command
518
517
  PageUI.PAGE_UI_OBJ.add_page(lambda: PageUI.PAGE_UI_OBJ.intercon_page(host, cmd, run=run))
@@ -522,7 +521,7 @@ def intercon_genpage(cmd=None, run=False):
522
521
  return True
523
522
 
524
523
 
525
- def cmd_genpage(cmd=None, run=False):
524
+ def cmd_genpage(cmd:str=None, run=False):
526
525
  """
527
526
  Create load module execution pages dynamically :)
528
527
  - based on cmd value: load_module function (args)
@@ -530,9 +529,6 @@ def cmd_genpage(cmd=None, run=False):
530
529
  :param run: run button event at page init: True/False
531
530
  :return: page creation verdict
532
531
  """
533
- if not isinstance(cmd, str):
534
- return False
535
-
536
532
  try:
537
533
  # Create page for intercon command
538
534
  PageUI.PAGE_UI_OBJ.add_page(lambda: PageUI.PAGE_UI_OBJ.cmd_call_page(cmd, run=run))
@@ -4,13 +4,8 @@ from Types import resolve
4
4
  # Core modules
5
5
  from Config import cfgget
6
6
  from Time import uptime
7
-
8
7
  # Load Modules
9
- from LM_system import top, memory_usage, ifconfig, rssi as sta_rssi, list_stations
10
- try:
11
- import LM_intercon as InterCon
12
- except:
13
- InterCon = None # Optional function handling
8
+ from LM_system import top, memory_usage, ifconfig, rssi as sta_rssi, list_stations, hosts
14
9
  try:
15
10
  from LM_esp32 import temp as cpu_temp
16
11
  except Exception as e:
@@ -785,10 +780,13 @@ class PageUI:
785
780
  # Check open host connection
786
781
  try:
787
782
  # Send CMD to other device & show result
788
- data_meta = InterCon.send_cmd(host, cmd)
789
- self._cmd_task_tag = data_meta['tag']
790
- if "Task is Busy" in data_meta['verdict'] and not run:
791
- self.app_frame.press_output = data_meta['verdict'] # Otherwise the task start output not relevant on UI
783
+ state, data_meta = exec_cmd(cmd + [f">>{host}"], jsonify=True, skip_check=True)
784
+ if state:
785
+ self._cmd_task_tag = data_meta['tag']
786
+ if "Task is Busy" in data_meta['verdict'] and not run:
787
+ self.app_frame.press_output = data_meta['verdict'] # Otherwise the task start output not relevant on UI
788
+ else:
789
+ self.app_frame.press_output = f"Error: {data_meta}"
792
790
  except Exception as e:
793
791
  self.app_frame.press_output = str(e)
794
792
 
@@ -803,7 +801,7 @@ class PageUI:
803
801
  self._cmd_task_tag = None
804
802
  PageUI.write_lines(self.app_frame.press_output, display, x, y + 20, line_limit=2)
805
803
 
806
- PageUI.write_lines(f"{host.split(".")[0]}:{cmd}", display, x, y, line_limit=2)
804
+ PageUI.write_lines(f"{host.split(".")[0]}:{' '.join(cmd)}", display, x, y, line_limit=2)
807
805
  if run:
808
806
  if self._cmd_task_tag is None:
809
807
  _execute(display, w, h, x, y)
@@ -829,14 +827,13 @@ def _system_page(display, w, h, x, y):
829
827
  return True
830
828
 
831
829
  def _intercon_nodes_page(display, w, h, x, y):
832
- if InterCon is None:
833
- return False
834
830
  line_limit = 3
835
831
  line_start = y+5
836
832
  line_cnt = 1
837
833
  display.text("InterCon cache", x, line_start)
838
- if sum([1 for _ in InterCon.host_cache()]) > 0:
839
- for key, val in InterCon.host_cache().items():
834
+ cache = hosts()["intercon"]
835
+ if sum([1 for _ in cache]) > 0:
836
+ for key, val in cache.items():
840
837
  key = key.split('.')[0]
841
838
  val = '.'.join(val.split('.')[-2:])
842
839
  display.text(f" {val} {key}", x, line_start + (line_cnt * 10))
@@ -934,7 +931,7 @@ def intercon_genpage(cmd=None, run=False):
934
931
  """
935
932
  raw = cmd.split()
936
933
  host = raw[0]
937
- cmd = ' '.join(raw[1:])
934
+ cmd = raw[1:]
938
935
  try:
939
936
  # Create page for intercon command
940
937
  PageUI.INSTANCE.add_page(lambda display, w, h, x, y: PageUI.INSTANCE.intercon_exec_page(host, cmd, run, display, w, h, x, y))
@@ -1,10 +1,7 @@
1
1
  from microIO import bind_pin, pinmap_search
2
- from Common import SmartADC, micro_task, notify, syslog
2
+ from Common import SmartADC, micro_task, notify, syslog, exec_cmd
3
3
  from utime import ticks_ms
4
- try:
5
- import LM_intercon as InterCon
6
- except:
7
- InterCon = None
4
+
8
5
 
9
6
  class Data:
10
7
  TASK_TAG = 'presence._capture'
@@ -68,9 +65,9 @@ def __run_intercon(state):
68
65
  try:
69
66
  cmd = Data.ON_INTERCON_CLBK.split()
70
67
  host = cmd[0]
71
- cmd = ' '.join(cmd[1:])
72
- # Send CMD to other device & show result
73
- InterCon.send_cmd(host, cmd)
68
+ cmd = cmd[1:]
69
+ # Send CMD to other device
70
+ state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True, skip_check=True)
74
71
  except Exception as e:
75
72
  syslog(f"__run_intercon error: {e}")
76
73
  if state.lower() == "off":
@@ -79,9 +76,9 @@ def __run_intercon(state):
79
76
  try:
80
77
  cmd = Data.OFF_INTERCON_CLBK.split()
81
78
  host = cmd[0]
82
- cmd = ' '.join(cmd[1:])
83
- # Send CMD to other device & show result
84
- InterCon.send_cmd(host, cmd)
79
+ cmd = cmd[1:]
80
+ # Send CMD to other device
81
+ state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True, skip_check=True)
85
82
  except Exception as e:
86
83
  syslog(f"__run_intercon error: {e}")
87
84
 
@@ -212,14 +212,15 @@ def ifconfig():
212
212
  return network_config()
213
213
 
214
214
 
215
- def urequest_hosts():
215
+ def hosts():
216
216
  """
217
- Debug function for urequests address caching
218
- - returns all known http(s) host addresses
219
- - cache only in memory
217
+ Dump cached hosts
218
+ - urequests (only memory cache)
219
+ - intercon connection cache
220
220
  """
221
221
  from urequests import host_cache
222
- return host_cache()
222
+ from InterConnect import host_cache as ihost_cache
223
+ return {"urequests": host_cache(), "intercon": ihost_cache()}
223
224
 
224
225
 
225
226
  def notifications(enable=None):
@@ -246,4 +247,4 @@ def help(widgets=False):
246
247
  'ntp', 'rssi', 'list_stations', 'pinmap key="dhtpin"/None', 'alarms clean=False',
247
248
  'notifications enable=<None,True,False>',
248
249
  'sun refresh=False', 'ifconfig', 'memory_usage',
249
- 'disk_usage', 'urequest_hosts'), widgets=widgets)
250
+ 'disk_usage', 'hosts'), widgets=widgets)