Skip to content

Commit f187391

Browse files
committed
250503.1
1 parent 37a53cb commit f187391

9 files changed

+103
-62
lines changed

config.ecs

Lines changed: 85 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223

224224
variable Config
225225
variable ConfigFile
226+
variable Hosts
226227
variable Name
227228
variable Value
228229
variable ReturnValue
@@ -232,6 +233,7 @@
232233
variable Item
233234
variable HostSSID
234235
variable HostPassword
236+
variable SystemHostSSID
235237
variable SSID
236238
variable MAC
237239
variable Password
@@ -292,18 +294,26 @@ Start:
292294
put trim system `echo $HOME` cat `/.rbr.conf` into ConfigFile
293295
load Config from ConfigFile
294296
if Config is empty put json `{}` into Config else put json Config into Config
297+
if Config does not have property `hosts` set property `hosts` of Config to json `{}`
298+
if Config does not have property `systems` set property `systems` of Config to json `{}`
299+
if Config does not have property `current-system` set property `current-system` of Config to empty
300+
put property `hosts` of Config into Hosts
295301

296-
! Look for the host SSID and password. If they're not found, scan for them
297-
if Config does not have property `host-ssid` gosub to GetHost
298-
299-
put property `host-ssid` of Config into HostSSID
300-
put property `host-password` of Config into HostPassword
301-
302-
! Check we're on the right AP. If not, connect to it
303-
put `Checking current SSID...` into StatusMessage
302+
! Get the host SSID
303+
put `Getting host SSID...` into StatusMessage
304304
gosub to Working
305305
put trim system `LANG=C nmcli -t -f active,ssid dev wifi | grep ^yes | cut -d: -f2-` into HostSSID
306-
if HostSSID is not property `host-ssid` of Config gosub to ConnectToHost
306+
if Hosts has property HostSSID put property HostSSID of Hosts into HostPassword
307+
else
308+
begin
309+
gosub to GetHostPassword
310+
if HostPassword is not empty
311+
begin
312+
set property HostSSID of Hosts to HostPassword
313+
set property `hosts` of Config to Hosts
314+
end
315+
end
316+
save prettify Config to ConfigFile
307317
put `Connected to ` cat HostSSID into StatusMessage
308318
gosub to Idle
309319

@@ -316,8 +326,7 @@ Start:
316326
end
317327
gosub to RefreshSystemsCombo
318328

319-
! gosub to GetAllConfigData
320-
if ErrorFlag stop
329+
put empty into SystemHostSSID
321330

322331
! Select the current system
323332
if the count of SystemsCombo is 0 put empty into SystemName
@@ -326,7 +335,7 @@ Start:
326335
put the keys of Systems into Keys
327336
put element 0 of Keys into SystemName
328337
end
329-
set property `current` of Config to SystemName
338+
set property `current-system` of Config to SystemName
330339
if SystemName is not empty
331340
begin
332341
select SystemName in SystemsCombo
@@ -361,7 +370,6 @@ ScanSystemsClick:
361370
log `Scan for system controllers`
362371
disable ScanSystemsButton
363372
gosub to ScanSystems
364-
! if SystemName is not empty gosub to GetConfigData
365373
gosub to RefreshSystemsCombo
366374
gosub to PostConfigData
367375
gosub to ManageButtonStates
@@ -395,21 +403,50 @@ ScanSystems:
395403
increment P
396404
put from P of Result into SystemName
397405
put json `{}` into SystemConfig
406+
set property `host-ssid` of SystemConfig to HostSSID
407+
set property `host-password` of SystemConfig to HostPassword
398408
set property `ipaddr` of SystemConfig to IPAddr
399409
set property `mac` of SystemConfig to SystemMAC
400410
set property `password` of SystemConfig to SystemPassword
401411
set property `devices` of SystemConfig to json `{}`
402412
log `Adding ` cat SystemName cat ` to Systems`
403413
gosub UpdateSystems
414+
log prettify SystemConfig
404415
gosub to GetConfigData
405416
SS2:
406417
wait 10 ticks
407418
increment N
408419
end
409-
set property `current` of Config to SystemName
420+
set property `current-system` of Config to SystemName
410421
log `After scan: ` cat prettify Config
411422
go to OK
412423

424+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
425+
! Get the config data for a system
426+
GetConfigData:
427+
gosub to SetBusy
428+
if SystemName is empty return
429+
log `Get the config data for ` cat SystemName
430+
put property `devices` of SystemConfig into Devices
431+
get Value from url `https://rbrheating.com/ui/resources/php/rest.php/config/`
432+
cat SystemMAC cat `/` cat SystemPassword
433+
or
434+
begin
435+
put `Can't read the config file for ` cat SystemName cat `(` cat MAC cat `/` cat Password cat `)` into StatusMessage
436+
go to Error
437+
end
438+
! If the server has data, use it instead of the local config
439+
if Value is empty put `{}` into Value
440+
if Value is not `{}`
441+
begin
442+
log `Use config data from the server`
443+
put json Value into SystemConfig
444+
gosub to UpdateSystems
445+
end
446+
log prettify SystemConfig
447+
gosub to PostConfigData
448+
return
449+
413450
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
414451
! Refresh the systems combobox
415452
RefreshSystemsCombo:
@@ -433,11 +470,12 @@ SystemsComboSelect:
433470
if SystemName is not empty
434471
begin
435472
log `Select system ` cat SystemName
436-
set property `current` of Config to SystemName
473+
set property `current-system` of Config to SystemName
437474
put property SystemName of Systems into SystemConfig
438475
gosub to PopulateSystemInfo
439476
end
440477
gosub to ManageButtonStates
478+
if not ErrorFlag gosub to OK
441479
stop
442480

443481
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -456,8 +494,9 @@ RemoveSystemClick:
456494
remove the current item from SystemsCombo
457495
delete property SystemName of Systems
458496
put empty into SystemName
459-
set property `current` of Config to SystemsCombo
497+
set property `current-system` of Config to SystemsCombo
460498
set property `systems` of Config to Systems
499+
put empty into SystemHostSSID
461500
gosub to PostConfigData
462501
end
463502
if the count of SystemsCombo is 0 disable RemoveSystemButton
@@ -468,38 +507,6 @@ RemoveSystemClick:
468507
gosub to ManageButtonStates
469508
stop
470509

471-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
472-
! Get the config data for a system
473-
GetConfigData:
474-
gosub to SetBusy
475-
if SystemName is empty return
476-
log `Get the config data for ` cat SystemName
477-
! put property `systems` of Config into Systems
478-
put property SystemName of Systems into SystemConfig
479-
put property `mac` of SystemConfig into SystemMAC
480-
put property `devices` of SystemConfig into Devices
481-
put property `password` of SystemConfig into SystemPassword
482-
get Value from url `https://rbrheating.com/ui/resources/php/rest.php/config/`
483-
cat SystemMAC cat `/` cat SystemPassword
484-
or
485-
begin
486-
put `Can't read the config file for ` cat SystemName cat `(` cat MAC cat `/` cat Password cat `)` into StatusMessage
487-
go to Error
488-
end
489-
! If the server has data, use it instead of the local config
490-
! put json Value into Value
491-
! log `Value: ` cat prettify Value
492-
! return
493-
! put empty into Value
494-
if Value is not empty
495-
begin
496-
log `Use config data from the server`
497-
put json Value into SystemConfig
498-
gosub to UpdateSystems
499-
end
500-
gosub to PostConfigData
501-
return
502-
503510
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
504511
! Clear all the data for the selected system
505512
ClearSystemClick:
@@ -787,6 +794,28 @@ CreateDevice:
787794
! Populate the system information fields
788795
PopulateSystemInfo:
789796
log `Populate fields for ` cat SystemName
797+
put property `host-ssid` of SystemConfig into SystemHostSSID
798+
if SystemHostSSID is not HostSSID
799+
begin
800+
put property SystemHostSSID of Hosts into Password
801+
put `Connect to host ` cat SystemHostSSID cat ` with password ` cat Password into StatusMessage
802+
gosub to Working
803+
put system `nmcli dev wifi connect ` cat SystemHostSSID cat ` password ` cat Password into SystemCallResult
804+
split SystemCallResult on ` `
805+
if the elements of SystemCallResult is greater than 2
806+
begin
807+
index SystemCallResult to 2
808+
if SystemCallResult is `successfully`
809+
begin
810+
put SystemHostSSID into HostSSID
811+
put HostSSID into CurrentSSID
812+
put `Connected to ` cat HostSSID into StatusMessage
813+
go to Idle
814+
end
815+
end
816+
put `Failed to connect to ` cat HostSSID into StatusMessage
817+
go to Error
818+
end
790819
put property `mac` of SystemConfig into SystemMAC
791820
put property `password` of SystemConfig into SystemPassword
792821
put property `devices` of SystemConfig into Devices
@@ -926,7 +955,9 @@ GetHostPassword:
926955
log `Get the host password`
927956
put `Type the host password:` into Prompt
928957
put `Host password` into Title
929-
go to GetRequestedText
958+
gosub to GetRequestedText
959+
put ReturnValue into HostPassword
960+
return
930961

931962
GetRequestedText:
932963
create VLayout type QVBoxLayout
@@ -942,15 +973,14 @@ GetRequestedText:
942973
on click OKButton
943974
begin
944975
put LineInput into ReturnValue
945-
put `OK` into Result
946976
close Dialog
947977
return
948978
end
949979
add OKButton to HLayout
950980
create CancelButton text `Cancel` size 6
951981
on click CancelButton
952982
begin
953-
put `Cancel` into Result
983+
put empty into ReturnValue
954984
close Dialog
955985
return
956986
end
@@ -998,8 +1028,6 @@ GetAccessPoints:
9981028
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9991029
! Connect to the host router
10001030
ConnectToHost:
1001-
put property `host-ssid` of Config into HostSSID
1002-
put property `host-password` of Config into HostPassword
10031031
put `Connect to host ` cat HostSSID cat ` with password ` cat HostPassword into StatusMessage
10041032
gosub to Working
10051033
put system `nmcli dev wifi connect ` cat HostSSID cat ` password ` cat HostPassword into SystemCallResult
@@ -1011,22 +1039,18 @@ ConnectToHost:
10111039
begin
10121040
put HostSSID into CurrentSSID
10131041
put `Connected to ` cat HostSSID into StatusMessage
1014-
log StatusMessage
1015-
go to Working
1042+
go to Idle
10161043
end
10171044
end
10181045
put `Failed to connect to ` cat HostSSID into StatusMessage
1019-
! Fall into GetHost
1020-
1021-
GetHost:
10221046
gosub to GetAccessPoints
10231047
put `Select HostSSID` into Title
10241048
put `Select the home router for this system` into Prompt
10251049
gosub to SelectSSIDFromList
10261050
if HostSSID is empty go to Start
10271051
set property `host-ssid` of Config to HostSSID
10281052
if Config does not have property `host-password` gosub to GetHostPassword
1029-
set property `host-password` of Config to ReturnValue
1053+
set property `host-password` of Config to HostPassword
10301054
go to ConnectToHost
10311055

10321056
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1263,6 +1287,8 @@ Error:
12631287
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12641288
! Enable or disable the various buttons
12651289
ManageButtonStates:
1290+
if SystemHostSSID is not empty
1291+
if SystemHostSSID is not HostSSID go to SetBusy
12661292
! ScanDevicesButton
12671293
if the count of SystemsCombo is 0 disable ScanDevicesButton else enable ScanDevicesButton
12681294
! ClearSystemButton
-38.9 KB
Binary file not shown.
39.5 KB
Binary file not shown.
Binary file not shown.

easycoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
from .ec_timestamp import *
1010
from .ec_value import *
1111

12-
__version__ = "250502.1"
12+
__version__ = "250503.1"

easycoder/ec_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ def r_unlock(self, command):
16051605

16061606
def k_use(self, command):
16071607
if self.nextIs('graphics'):
1608+
print('Loading graphics module')
16081609
from .ec_pyside import Graphics
16091610
self.program.classes.append(Graphics)
16101611
self.program.processClasses()

easycoder/ec_pyside.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,13 @@ def k_select(self, command):
695695
if self.nextIsSymbol():
696696
record = self.getSymbolRecord()
697697
if record['keyword'] == 'combobox':
698-
command['name'] = record['name']
698+
command['widget'] = record['name']
699699
self.add(command)
700700
return True
701701
return False
702702

703703
def r_select(self, command):
704-
widget = self.getVariable(command['name'])['widget']
704+
widget = self.getVariable(command['widget'])['widget']
705705
if 'index' in command:
706706
index = self.getRuntimeValue(command['index'])
707707
else:

test.ecs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
! RBR-Now configuration
2+
3+
script RBRConfig
4+
5+
variable Script
6+
module RBRConfig
7+
8+
get Script from url `https://raw.githubusercontent.com/easycoder/easycoder-py/refs/heads/main/config.ecs`
9+
save Script to `temp.ecs`
10+
run `temp.ecs` as RBRConfig
11+
exit

test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from easycoder import Program
2+
3+
Program('test.ecs').start()

0 commit comments

Comments
 (0)