Difference between revisions of "AIMLinux/AddOn/DeviceOn"

From ESS-WIKI
Jump to: navigation, search
 
(53 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
= <span style="color:#0070c0">DeviceOn</span> =
 
= <span style="color:#0070c0">DeviceOn</span> =
  
This section describes the information about DeviceOn on RISC platform.
+
This section describes the information about How to install the DeviceOn on RISC platform.
  
== <span style="color:#0070c0">Requirements for Build Environment</span> ==
+
== <span style="color:#0070c0">Get the following required files from PM or AE members&nbsp;</span> ==
  
To cross-compile DeviceOn agent, you have to install dependencies into SDK toolchain.
+
*'''WISE-Agent'''
 +
**EX:&nbsp;wise-agent-Poky_3.0.4-imx8-1.4.31.0.run
 +
*'''CreateAccount'''
 +
**EX:&nbsp;createaccount_2020_04_10_a59cbe72.tar.gz
 +
*'''Service-SD'''K
 +
**EX:&nbsp;Service-SDK_Release_20200421_fsl_imx8_yocto_3f5ea785.tar.gz
 +
*'''SUSI-IoT'''
 +
**EX: SusiIoT_Release_2021_08_31_Poky_3.0.4-imx8_x64_16490.tar.gz
 +
*'''SUSI 4.0'''
 +
**EX:&nbsp;SUSI4.0_Release_2021_10_29_Poky_3.0.4-imx8_x64_16557.tar.gz
  
Please refer to '''[https://github.com/ADVANTECH-Corp/meta-advantech2/blob/aim20-rocko-sumo/meta-WISE-PaaS/recipes-core/packagegroups/packagegroup-wise-paas.bb packagegroup-wise-paas.bb]''' and '''[https://github.com/ADVANTECH-Corp/meta-advantech2/blob/aim20-rocko-sumo/meta-WISE-PaaS/recipes-core/images/sdk.inc sdk.inc]''' for details. These two files are used on '''Yocto '''to generate suitable image & toolchain for DeviceOn.
+
== <span style="color:#0070c0">Bundle Mechanism</span> ==
 +
 
 +
Install the DeviceOn function on a specific BSP official release with related DeviceOn packages enabled.
 +
 
 +
== <span style="color:#0070c0">DeviceOn Installation</span> ==
 +
 
 +
=== '''1. Install&nbsp;WISE-Agent''' ===
 +
 
 +
./wise-agent-Poky_xxx.run
 +
 
 +
During the installation, do not configure at this moment.
 +
 
 +
* Setup Agent [y/n](default:n): '''<span style="color:#DD0000">y</span>'''
 +
* Do you want to configure RMM Agent now? [y/n](default: y) '''<span style="color:#DD0000">n</span>'''
 +
* Do you want to start RMM Agent now? [y/n](default: y) '''<span style="color:#DD0000">n</span>'''
 +
 
 +
=== '''2. Install CreateAccount''' ===
 +
 
 +
Get CreateAccount program and install with npm.
 +
 
 +
​tar -zxvf createaccount_xxx.tar.gz
 +
cd createaccount
 +
cp -a * /usr/local/AgentService/
 +
 
 +
=== '''3. Set up Zero-Config service''' ===
 +
 
 +
==== '''[System V]''' ====
 +
 
 +
Create the "zero-config" file, and the&nbsp;content of zero-config:
 +
 
 +
#!/bin/sh
 +
 +
SERVICE_PATH="/usr/local/AgentService/"
 +
SERVICE_PROGRAM="node index.js"
 +
 +
# Source function library.
 +
. /etc/init.d/functions
 +
 +
case "$1" in
 +
    start)
 +
        echo -n "Starting CreateAccount: "
 +
        cd $SERVICE_PATH
 +
        $SERVICE_PROGRAM > /dev/null 2>&1
 +
        RETVAL=$?
 +
        if [ $RETVAL -eq 0 ]; then
 +
            echo "OK"
 +
        else
 +
            echo "Failure"
 +
        fi
 +
        &nbsp;;;
 +
    *)
 +
        echo "Usage: $0 {start}"
 +
        exit 1
 +
        &nbsp;;;
 +
esac
 +
 +
exit 0
  
For '''Debian/Ubuntu''', you can refer to '''[https://github.com/ADVANTECH-Rockchip/linux_rootfs_adv/blob/rk3399_linux_v210/mk-adv.sh mk-adv.sh]''' which we use to build rootfs for RK platform.
+
Set up the zero-config file:
  
== <span style="color:#0070c0">Build Instruction</span> ==
+
cp zero-config /etc/init.d
 +
chown root:root /etc/init.d/zero-config
 +
chmod 0750 /etc/init.d/zero-config
 +
update-rc.d -f zero-config remove
 +
update-rc.d zero-config defaults 99 20
  
Make sure you have set up SDK toolchain environment, before start building RMM EI agent.
+
==== '''[System D]''' ====
  
For RK platforms, you have to set up chroot environment instead of SDK toolchain.
+
Create the "zero-config.service" file, and the&nbsp;content of zero-config.service:
  
  <span style="color:#00AA00"># Get source</span>
+
  [Unit]
  git clone [http://advgitlab.eastasia.cloudapp.azure.com/EI-PaaS-RMM/RMM-EI-Agent.git http://advgitlab.eastasia.cloudapp.azure.com/EI-PaaS-RMM/RMM-EI-Agent.git]
+
Description=CreatAccount
  cd RMM-EI-Agent
+
After=saagent.service
 +
 +
  [Service]
 +
  User=root
 +
Group=root
 
   
 
   
  <span style="color:#00AA00"># Choose one for your platform</span>
+
  Type=idle
  source risc-env fsl imx6 yocto 2.1
+
  WorkingDirectory=/usr/local/AgentService/
  source risc-env fsl imx8 yocto
+
  ExecStartPre=/bin/sleep 10
  source risc-env qualcomm dragon yocto
+
  ExecStart=/usr/bin/node /usr/local/AgentService/index.js
source risc-env ti am335x yocto 2.4
 
source risc-env rk 3399 debian
 
source risc-env rk 3288 debian
 
 
   
 
   
  <span style="color:#00AA00"># Build</span>
+
  [Install]
  make clean
+
WantedBy=multi-user.target
  cd build/Standard
+
 
  ./autobuild.sh
+
Set up the zero-config.service file:
 +
 
 +
cp zero-config.service /etc/systemd/system
 +
chown root:root /etc/systemd/system/zero-config.service
 +
chmod 750 /etc/systemd/system/zero-config.service
 +
systemctl enable zero-config.service
 +
 
 +
=== '''4.&nbsp;Install Service-SDK''' ===
 +
 
 +
tar -zxvf Service-SDK_Release_xxx.tar.gz
 +
cp -a Service-SDK/.libs/libEIServiceSDK.so* /usr/lib/
 +
 
 +
=== '''5.&nbsp;Install&nbsp;SUSI-IoT''' ===
 +
 
 +
tar -zxvf SusiIoT_Release_xxx.tar.gz
 +
cd release/library
 +
sudo ./install.sh
 +
 
 +
=== '''6. Install&nbsp;SUSI 4.0''' ===
 +
 
 +
  tar -zxvf SUSI4.0_Release_xxx.tar.gz
 +
  cd SUSI4.x.x/Driver
 +
  sudo ./install.sh
 +
 
 +
''PS. Please make sure the owner of files above are ''''root:root''''.''
  
After build process is complete, you can get the installer (.run) and tarball files in '''Wrapped/''' folder.
+
== <span style="color:#0070c0">First Boot</span> ==
  
$ ls Wrapped/
+
Connect the internet and during the first boot procedure, the /usr/local/AgentService/agent_config.xml will be updated by saagent service firstly. The MAC address is used as an unique device id for DeviceOn.
wise-agent-Poky_2.1.1 imx6-1.2.14.0-binary.tar.gz
 
wise-agent-Poky_2.1.1 imx6-1.2.14.0.run
 
wise-agent-Poky_2.1.1 imx6-1.2.14.0.run.tar.gz
 
  
In addition, you can check the output binaries&nbsp;in '''Release/AgentService/''' folder as well.
+
<DeviceName>imx6dlubc220a1</DeviceName>
 +
<DevID>00000001-0000-0000-0000-00049F0130E0</DevID>
 +
<SN>00049F0130E0</SN>
 +
<UserName>00049F0130E0@advtrial.net</UserName>
  
== <span style="color:#0070c0">Bundle Mechanism</span> ==
+
Then, zero-config service will register this account to the server. Once successful, the agent_config.xml will be updated again with corresponding credentials.
 +
 
 +
<CredentialURL>[https://deviceonapp.wise-paas.com/rmm/v1/iothub/credential https://deviceonapp.wise-paas.com/rmm/v1/iothub/credential]</CredentialURL>
 +
<IoTKey>10da34e72025c137618bb4d4aefff18d</IoTKey>
 +
 
 +
These procedures are automatically complete during first booting up. Users only need to power up device and connect with network.
  
 
== <span style="color:#0070c0">Connect to Server</span> ==
 
== <span style="color:#0070c0">Connect to Server</span> ==
  
Once you are ready to boot devices with DeviceOn, connect to [https://deviceonapp.wise-paas.com/#/deviceon/DeviceQRCode DeviceQRCode] website and input the MAC address of your device.
+
On PC or cellular phone, connect to '''[https://deviceonapp.wise-paas.com/#/DeviceQRCode DeviceQRCode]''' website and input the MAC address of your target device.
  
If your devices have multiple Ethernet interfaces, use the following commands to confirm the associated MAC address.
+
If your target device has multiple Ethernet interfaces, use the following command to confirm the associated MAC.
  
 
  $ cat /usr/local/AgentService/agent_config.xml | grep SN
 
  $ cat /usr/local/AgentService/agent_config.xml | grep SN
 
     <SN>00049F0130E0</SN>
 
     <SN>00049F0130E0</SN>
 +
 +
Follow the steps to connect to DeviceOn server
  
 
1. Click the button to generate QR code
 
1. Click the button to generate QR code
Line 60: Line 161:
 
[[File:Deviceon qrcode.png|800px|deviceon_qrcode]]
 
[[File:Deviceon qrcode.png|800px|deviceon_qrcode]]
  
The QR code will re-direct to DeviceOn home page. Then, enjoy it!
+
The QR code will re-direct to DeviceOn home page. Enjoy it!
  
 
[[File:Deviceon home.png|800px|deviceon_home]]
 
[[File:Deviceon home.png|800px|deviceon_home]]
Line 66: Line 167:
  
  
 +
If the '''[https://deviceonapp.wise-paas.com/#/DeviceQRCode DeviceQRCode]''' website appear the mac address does not exist, the&nbsp;mac account may have expired (six month trial period) or&nbsp;'''you&nbsp;can check the &lt;IoTKey&gt; exist or not in the /usr/local/AgentService/agent_config.xml'''.
  
 +
'''''If the&nbsp;&lt;IoTKey&gt; is empty, please connect the internet and reboot the device agai''n'''.
  
= <span style="color:#0070c0">Additional Modules</span> =
+
[[File:Deviceon mac.png|800px|Deviceon_mac]]
 
 
This section describes how to build & deploy additional plug-in for DeviceOn.
 
 
 
== <span style="color:#0070c0">OTA Handler</span> ==
 
 
 
== <span style="color:#0070c0">Service-SDK</span> ==
 
 
 
== <span style="color:#0070c0">SUSI 4.0 & SUSI-IoT</span> ==
 
  
== <span style="color:#0070c0">OPC-UA</span> ==
+
== <span style="color:#0070c0">DeviceOn logs and check the connection</span> ==
 +
You can go to the /usr/local/AgentService/logs and check the log file:
  
== <span style="color:#0070c0">Modbus Handler</span> ==
+
04-01 07:35:11.306 1687 [WiseAgent] Agent Credential: mqtt,efcc749121b5ecd182f58aa1649457eb_created,2265409aaecb11bf79a7c16473af5c47,deviceonapp.wise-paas.com,1883,false
[[Category:Editor]]
+
04-01 07:35:11.306 1687 [WiseAgent] Connecting to broker: deviceonapp.wise-paas.com
 +
04-01 07:35:11.389 1740 [WiseAgent] Broker connected!

Latest revision as of 09:21, 1 April 2022

DeviceOn

This section describes the information about How to install the DeviceOn on RISC platform.

Get the following required files from PM or AE members 

  • WISE-Agent
    • EX: wise-agent-Poky_3.0.4-imx8-1.4.31.0.run
  • CreateAccount
    • EX: createaccount_2020_04_10_a59cbe72.tar.gz
  • Service-SDK
    • EX: Service-SDK_Release_20200421_fsl_imx8_yocto_3f5ea785.tar.gz
  • SUSI-IoT
    • EX: SusiIoT_Release_2021_08_31_Poky_3.0.4-imx8_x64_16490.tar.gz
  • SUSI 4.0
    • EX: SUSI4.0_Release_2021_10_29_Poky_3.0.4-imx8_x64_16557.tar.gz

Bundle Mechanism

Install the DeviceOn function on a specific BSP official release with related DeviceOn packages enabled.

DeviceOn Installation

1. Install WISE-Agent

./wise-agent-Poky_xxx.run

During the installation, do not configure at this moment.

* Setup Agent [y/n](default:n): y
* Do you want to configure RMM Agent now? [y/n](default: y) n
* Do you want to start RMM Agent now? [y/n](default: y) n

2. Install CreateAccount

Get CreateAccount program and install with npm.

​tar -zxvf createaccount_xxx.tar.gz
cd createaccount
cp -a * /usr/local/AgentService/

3. Set up Zero-Config service

[System V]

Create the "zero-config" file, and the content of zero-config:

#!/bin/sh

SERVICE_PATH="/usr/local/AgentService/"
SERVICE_PROGRAM="node index.js"

# Source function library.
. /etc/init.d/functions 

case "$1" in
    start)
        echo -n "Starting CreateAccount: "
        cd $SERVICE_PATH
        $SERVICE_PROGRAM > /dev/null 2>&1
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
            echo "OK"
        else
            echo "Failure"
        fi
        ;;
    *)
        echo "Usage: $0 {start}"
        exit 1
        ;;
esac

exit 0

Set up the zero-config file:

cp zero-config /etc/init.d
chown root:root /etc/init.d/zero-config
chmod 0750 /etc/init.d/zero-config
update-rc.d -f zero-config remove
update-rc.d zero-config defaults 99 20

[System D]

Create the "zero-config.service" file, and the content of zero-config.service:

[Unit]
Description=CreatAccount
After=saagent.service

[Service]
User=root
Group=root

Type=idle
WorkingDirectory=/usr/local/AgentService/
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/node /usr/local/AgentService/index.js

[Install]
WantedBy=multi-user.target

Set up the zero-config.service file:

cp zero-config.service /etc/systemd/system
chown root:root /etc/systemd/system/zero-config.service
chmod 750 /etc/systemd/system/zero-config.service
systemctl enable zero-config.service

4. Install Service-SDK

tar -zxvf Service-SDK_Release_xxx.tar.gz
cp -a Service-SDK/.libs/libEIServiceSDK.so* /usr/lib/

5. Install SUSI-IoT

tar -zxvf SusiIoT_Release_xxx.tar.gz
cd release/library
sudo ./install.sh

6. Install SUSI 4.0

tar -zxvf SUSI4.0_Release_xxx.tar.gz
cd SUSI4.x.x/Driver
sudo ./install.sh

PS. Please make sure the owner of files above are 'root:root'.

First Boot

Connect the internet and during the first boot procedure, the /usr/local/AgentService/agent_config.xml will be updated by saagent service firstly. The MAC address is used as an unique device id for DeviceOn.

<DeviceName>imx6dlubc220a1</DeviceName>
<DevID>00000001-0000-0000-0000-00049F0130E0</DevID>
<SN>00049F0130E0</SN>
<UserName>00049F0130E0@advtrial.net</UserName>

Then, zero-config service will register this account to the server. Once successful, the agent_config.xml will be updated again with corresponding credentials.

<CredentialURL>https://deviceonapp.wise-paas.com/rmm/v1/iothub/credential</CredentialURL>
<IoTKey>10da34e72025c137618bb4d4aefff18d</IoTKey>

These procedures are automatically complete during first booting up. Users only need to power up device and connect with network.

Connect to Server

On PC or cellular phone, connect to DeviceQRCode website and input the MAC address of your target device.

If your target device has multiple Ethernet interfaces, use the following command to confirm the associated MAC.

$ cat /usr/local/AgentService/agent_config.xml | grep SN
   <SN>00049F0130E0</SN>

Follow the steps to connect to DeviceOn server

1. Click the button to generate QR code

2. Click the QR code or scan it with camera

deviceon_qrcode

The QR code will re-direct to DeviceOn home page. Enjoy it!

deviceon_home


If the DeviceQRCode website appear the mac address does not exist, the mac account may have expired (six month trial period) or you can check the <IoTKey> exist or not in the /usr/local/AgentService/agent_config.xml.

If the <IoTKey> is empty, please connect the internet and reboot the device again.

Deviceon_mac

DeviceOn logs and check the connection

You can go to the /usr/local/AgentService/logs and check the log file:

04-01 07:35:11.306 1687 [WiseAgent] Agent Credential: mqtt,efcc749121b5ecd182f58aa1649457eb_created,2265409aaecb11bf79a7c16473af5c47,deviceonapp.wise-paas.com,1883,false
04-01 07:35:11.306 1687 [WiseAgent] Connecting to broker: deviceonapp.wise-paas.com
04-01 07:35:11.389 1740 [WiseAgent] Broker connected!