20181227_jeffrey - silenceuncrio/diary GitHub Wiki

0910

昨天下班前的 M300 develop branch 已經 build 好了

mfgtool 燒錄

0945

login 成功後我會故意發送一次 /cgi-bin/syslog.cgi?act=gen_log

因為實驗得知這樣會讓 iweb 重啟

目前為了實驗方便我都會另外開一個 iweb listen port 3000

root@Cellular Router:/tmp/www/app/feature# ps aux | grep iweb
root      1746  0.0  0.4  10620  2328 pts/5    Ss+  10:25   0:00 iweb -p 80 -d /www
root      1747  0.3  0.4  10620  2528 pts/6    Ss+  10:25   0:00 iweb -p 443 -d /www -s
root      5647  0.1  0.3  10620  2016 ?        S    10:26   0:00 iweb -p 3000 -d /tmp/www/
root      7497  0.0  0.0   1768   320 ttymxc0  S+   10:26   0:00 grep iweb

browser 打開 http://192.168.1.1:3000 然後 login

神奇的事情發生了

root@Cellular Router:/tmp/www/app/feature# ps aux | grep iweb
root      5647  0.5  0.5  10720  2788 ?        S    10:26   0:00 iweb -p 3000 -d /tmp/www/
root     10734  0.8  0.5  10620  3028 pts/8    Ss+  10:27   0:00 iweb -p 443 -d /www -s
root     10736  0.1  0.4  10620  2376 pts/9    Ss+  10:27   0:00 iweb -p 80 -d /www
root     12396  0.0  0.0   1768   320 ttymxc0  S+   10:28   0:00 grep iweb

我覺得一開始被 icos 帶起來的 iweb 肯定哪邊有問題

看來修改 login.js 想要測試發送 /cgi-bin/syslog.cgi?act=gen_log 讓 iweb 掛掉

還不能另外開 3000 port 的 iweb 試

1000

用下面的 code 作第一次開機完的 login 實驗

    var login_ok = function() {

        console.log('login_ok');

        ////////////////////////////////////////////////////////////////////////////////////////////////
        // workaround
        // use following action to let iweb be killed once at the first time after power on
        icos.syslog.gen_log()
        .then( function(result) {
            // iweb reborn already
            console.log("iweb reborn already, icos.syslog.gen_log() pass");
        }, function(error) {
            // if iweb be killed at the first time
            console.log("icos.syslog.gen_log() fail");
            console.log("re-invoke login_ok() after 1 second to see if iweb reborn");
            $timeout(login_ok, 1000);
        });

        return;

        ...

}

test 01

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 02

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 03

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 04

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 05

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 06

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 07

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 08

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 09

login_ok
icos.syslog.gen_log() fail
re-invoke login_ok() after 1 second to see if iweb reborn
login_ok
iweb reborn already, icos.syslog.gen_log() pass

test 10

login_ok
iweb reborn already, icos.syslog.gen_log() pass

出現了

一次成功的 case

不過 icos.syslog.gen_log() 花了 3.65 秒才有回應

1040

根據這 10 次的測試結果

我來重構一下流程

試著用 $timeout() 去串

1125

login.js 已經重構好了

commit e3feb5ec5ea0d584f11a9415a0e42e899ef663cd
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Thu Dec 27 11:25:11 2018 +0800

    refactoring login.js

 proscend/prosrc/www/app/feature/login.js | 175 +++++++++++++++++++------------
 1 file changed, 110 insertions(+), 65 deletions(-)

再來就可以很方便的卡入一個流程

問看看完成過 wizard 了沒

如果沒有那就重導到 wizard

1300

先為了 wizard 作一個 CGI wizard.cgi 幫忙實現以下功能

  • wizard.cgi?act=status
    • 回應到底 wizard 做完了沒
    • 方便 login.js 決定是否要重導到 wizard 頁面
  • wizard.cgi?act=finish
    • 幫忙在 device 作個記號表示 wizard 已經完成
    • 那麼下次 wizard.cgi?act=status 便會回應說 做完了
  • wizard.cgi?act=reset
    • 幫忙清除 device wizard 已經完成的記號
    • 應該跟 we ui 的 firmware upgrade 整再一起

1325

目前 login 之後已經能依據 wizard.cgi?act=status 的結果來決定是否要重導至 wizard page

commit 3759f9420309d4c2042b1f50562c8f89441986dc
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Thu Dec 27 13:21:04 2018 +0800

    add CGI 'wizard.cgi' to help 'login.js' to decide whether to redirect to wizard or not:
    - wizard.cgi?act=status
      - answer whether wizard finished or not
    - wizard.cgi?act=finish
      - set the wizard finished
    - wizard.cgi?act=reset
      - set the wizard not finished

 proscend/prosrc/webcgi/Makefile                  |  2 +
 proscend/prosrc/webcgi/wizard.c                  | 89 ++++++++++++++++++++++++
 proscend/prosrc/www/app/feature/login.js         | 34 ++++++++-
 proscend/prosrc/www/app/services/icos.service.js | 12 ++++
 4 files changed, 134 insertions(+), 3 deletions(-)

1350

wizard 再來是比較苦工的 review 頁面

1415

發現問題

如果目前的 URL 已經是 wizard 了 - http://192.168.1.1/#/wizard

那去 refresh 該 URL 的時候版面會變成 wizard mode 的 layout

作了以下的修改即可修復該問題

app.controller.js

@@ -75,8 +75,8 @@ function appController($scope, $http, $timeout, $translate, $location, $template
     vm.wizard_mode = false;

     $scope.$on('$routeChangeStart', function(event, next, current) {
-        if (typeof current != 'undefined') {
-            share.data.originalPath = current.originalPath;
+^M
+        if (next !== undefined) {^M
             if (next.originalPath === '/wizard') {
                 vm.wizard_mode = true;
             } else {
@@ -84,6 +84,10 @@ function appController($scope, $http, $timeout, $translate, $location, $template
             }
         }

+        if (current !== undefined) {^M
+            share.data.originalPath = current.originalPath;^M
+        }^M
+^M
         // clear out $templateCache in AngularJS
         $templateCache.removeAll();
     });

趕緊上 code

commit 1827164c41be9cb19705dc7733fd66e750ee9eab
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Thu Dec 27 14:18:09 2018 +0800

    solve the problem about refresh the URL 'http://192.168.1.1/#/wizard', then the layout will be non wizard mode

 proscend/prosrc/www/app/app.controller.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

1440

review setting step 先用 <pre> 擋著先

commit 03a2c4f7fc734fd65d52d5bee3f597fbbe6da176
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Thu Dec 27 14:39:25 2018 +0800

    use '<pre>' to display the 'Review Setting' step at wizard:
    - latter we will use table to show them

 proscend/prosrc/www/app/feature/wizard.html | 78 +++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

這樣我就可以專注的把整個流程先實作完

先來作 apply 的部分

⚠️ **GitHub.com Fallback** ⚠️