|
31 | 31 | pushbutton RelayOffButton
|
32 | 32 | pushbutton RelayOnButton
|
33 | 33 | pushbutton SaveWidgetDataButton
|
34 |
| - pushbutton SelectHostButton |
35 | 34 | pushbutton OKButton
|
36 | 35 | pushbutton CancelButton
|
37 | 36 | lineinput LineInput
|
|
67 | 66 | add ClearSystemButton to LeftPanel
|
68 | 67 |
|
69 | 68 | create ScanDevicesButton text `Scan for devices`
|
70 |
| - on click ScanDevicesButton go to ScanNetworkClick |
| 69 | + on click ScanDevicesButton go to ScanForDevicesClick |
71 | 70 | add ScanDevicesButton to LeftPanel
|
72 | 71 |
|
73 | 72 | create UpdateDeviceButton text `Update device`
|
@@ -275,8 +274,11 @@ Start:
|
275 | 274 | begin
|
276 | 275 | clear RBRFlag
|
277 | 276 | gosub to GetAccessPoints
|
| 277 | + put `Select SSID` into Title |
278 | 278 | put `Select the home router for this system` into Prompt
|
279 | 279 | gosub to SelectSSIDFromList
|
| 280 | + if Item is empty go to Start |
| 281 | + set property `host-ssid` of Config to Item |
280 | 282 | if Config does not have property `host-password` gosub to GetHostPassword
|
281 | 283 | set property `host-password` of Config to ReturnValue
|
282 | 284 | end
|
@@ -372,8 +374,37 @@ ClearSystemClick:
|
372 | 374 | end
|
373 | 375 | stop
|
374 | 376 |
|
375 |
| -ScanNetworkClick: |
376 |
| - log `Scan the network for new devices` |
| 377 | +ScanForDevicesClick: |
| 378 | + put system `nmcli device wifi list` into SystemCallResult |
| 379 | + log SystemCallResult |
| 380 | + split SystemCallResult |
| 381 | + put json `[]` into List |
| 382 | + put 1 into N |
| 383 | + while N is less than the elements of SystemCallResult |
| 384 | + begin |
| 385 | + index SystemCallResult to N |
| 386 | + put SystemCallResult into SSID |
| 387 | + if left 1 of SSID is `*` begin end |
| 388 | + else |
| 389 | + begin |
| 390 | + put trim SSID into SSID |
| 391 | + put the position of ` ` in SSID into P |
| 392 | + put from P of SSID into SSID |
| 393 | + put trim SSID into SSID |
| 394 | + put the position of ` ` in SSID into P |
| 395 | + put left P of SSID into SSID |
| 396 | + if left 7 of SSID is `RBR-Now` |
| 397 | + begin |
| 398 | + append SSID to List |
| 399 | + end |
| 400 | + end |
| 401 | + increment N |
| 402 | + end |
| 403 | +! log `SSIDs: ` cat List |
| 404 | + put `Select Device` into Title |
| 405 | + put `Select the new device` into Prompt |
| 406 | + gosub to SelectSSIDFromList |
| 407 | + log `Selected ` cat Item |
377 | 408 | stop
|
378 | 409 |
|
379 | 410 | MasterDeviceClick:
|
@@ -514,20 +545,27 @@ SelectSSIDFromList:
|
514 | 545 | add element N of List to ListBox
|
515 | 546 | increment N
|
516 | 547 | end
|
517 |
| - add ListBox to Layout |
518 |
| - on select ListBox put the current item in ListBox into Item |
519 |
| - create SelectHostButton text `Select` |
520 |
| - on click SelectHostButton |
| 548 | + on select ListBox |
521 | 549 | begin
|
522 |
| - set property `host-ssid` of Config to Item |
| 550 | + put the current item in ListBox into Item |
523 | 551 | put Item cat ` Selected ` into StatusMessage
|
524 | 552 | gosub to Idle
|
525 | 553 | close Dialog
|
526 | 554 | return
|
527 | 555 | end
|
| 556 | + add ListBox to Layout |
528 | 557 | add stretch to Layout
|
529 |
| - add SelectHostButton to Layout |
530 |
| - create Dialog title `Host SSID` layout Layout size 250 200 |
| 558 | + create HLayout type QHBoxLayout |
| 559 | + create CancelButton text `Cancel` |
| 560 | + on click CancelButton |
| 561 | + begin |
| 562 | + put empty into Item |
| 563 | + close Dialog |
| 564 | + return |
| 565 | + end |
| 566 | + add CancelButton to HLayout |
| 567 | + add HLayout to Layout |
| 568 | + create Dialog title Title layout Layout size 250 200 |
531 | 569 | center Dialog on Window
|
532 | 570 | show Dialog
|
533 | 571 | stop
|
@@ -584,8 +622,11 @@ ConnectToHost:
|
584 | 622 | gosub to Working
|
585 | 623 | put system `nmcli dev wifi connect ` cat SSID cat ` password ` cat Password into SystemCallResult
|
586 | 624 | split SystemCallResult on ` `
|
587 |
| - index SystemCallResult to 2 |
588 |
| - if SystemCallResult is `successfully` go to OK |
| 625 | + if the elements of SystemCallResult is greater than 2 |
| 626 | + begin |
| 627 | + index SystemCallResult to 2 |
| 628 | + if SystemCallResult is `successfully` go to OK |
| 629 | + end |
589 | 630 | put `Failed to connect to ` cat SSID into StatusMessage
|
590 | 631 | gosub to Idle
|
591 | 632 | log StatusMessage
|
|
0 commit comments