Open main menu

DAVE Developer's Wiki β

Changes

Opening the local web application
This Technical Note (TN for short) illustrates the same application described [[MISC-TN-026:_Automated_test_equipment_(ATE)_monitoring_with_SBCSPG_gateway,_ThingsBoard_IoT,_and_Fledge|here]] with some notable differences:
* The edge device is [[ORCA_SBC|Orca SBC]] instead of SBCSPG gateway.
* Fledge and Fledge GUI were not installed by using <code>apt</code>. They were built on the target instead , even though the Linux distribution is still [[ORCA-TN-001_—_Running_Armbian_Bullseye_(Debian_11)|Debian 11]]. This configuration approach may be more suited for development purposesto address different situations. For instance, think about the case in which you have to develop some new functionalities or test custom north/south plugins. This At large, this set-up allows to develop the plugins code on a PC host running the ''same'' distribution, and to migrate them to the target later on when they are it is already tested and debugged thoroughly.* As the target platform features an HDMI port, Fledge GUI can be displayed locally, too. This solution can be convenient for building products that require alocal display without having to implement a new graphics application. Interestingly, this HDMI port is provided by a LVDS/HDMI bridge that, in turn, is connected to the LVDS native port of the i.MX8M Plus SoC. The display used for this test is [http://www.magedok.com/product02.html?id=157 Magedok T080A 8-inch touchscreen monitor]. ==Building and running Fledge and Fledge GUI==For convenience, <code>sshd</code> was set up in order to access the target remotely over SSH connections. This step is not strictly necessary, but it is recommended because it allows to work more effectively as shown in the rest of the article. Furtehrmore, <code>armbian</code> user was added to the <code>sudoers</code> file as Fledge may require root privileges to execute some operations. As we are working in a development environment, this can be tolerated. Fledge and Fledge GUI were built starting from the <code>develop</code> of their respective GitHub repositories.<pre class="workstation-terminal"> armbian@sbcorca-00a5:~/devel/fledge$ git clone https://github.com/fledge-iot/fledge.git...armbian@sbcorca-00a5:~/devel/fledge$ cd fledgearmbian@sbcorca-00a5:~/devel/fledge/fledge$ makeBuilding Fledge version 2.1.0, DB schema 60...uccessfully built cchardet pyjqInstalling collected packages: pyjwt, pyjq, ifaddr, cchardet, zeroconf, urllib3, multidict, idna, frozenlist, charset-normalizer, certifi, attrs, async-timeout, yarl, requests, aiosignal, requests-toolbelt, aiohttp, aiohttp_corsSuccessfully installed aiohttp-3.8.1 aiohttp_cors-0.7.0 aiosignal-1.3.1 async-timeout-4.0.2 attrs-23.1.0 cchardet-2.1.7 certifi-2022.12.7 charset-normalizer-2.1.1 frozenlist-1.3.3 idna-3.4 ifaddr-0.2.0 multidict-6.0.4 pyjq-2.5.1 pyjwt-1.6.4 requests-2.28.2 requests-toolbelt-0.9.1 urllib3-1.26.15 yarl-1.7.2 zeroconf-0.27.0 [notice] A new release of pip is available: 23.0.1 -> 23.1[notice] To update, run: python3 -m pip install --upgrade piparmbian@sbcorca-00a5:~/devel/fledge/fledge$ export FLEDGE_ROOT=/home/armbian/devel/fledge/fledgearmbian@sbcorca-00a5:~/devel/fledge/fledge$ $FLEDGE_ROOT/scripts/fledge stop ; $FLEDGE_ROOT/scripts/fledge startIt looks like Fledge is not running.Starting Fledge v2.1.0.......Fledge started.</pre><pre class="workstation-terminal"> armbian@sbcorca-00a5:~/devel/fledge$ cd fledge-guiarmbian@sbcorca-00a5:~/devel/fledge/fledge-gui$ yarn install && yarn start --host 0.0.0.0 --port 4200yarn install v1.22.19[1/4] Resolving packages...armbian@sbcorca-00a5:~/devel/fledge$ git clone https://github.com/fledge-iot/fledge-gui.git...Build at: 2023-04-18T16:04:36.723Z - Hash: b7cd6cc33931ce39 - Time: 98000ms ** Angular Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **  ✔ Compiled successfully.</pre>As stated previously, SSH connections are very convenient when it comes to interact with the target platform during the software development. The following screenshot shows, for example, four active connections used to start Fledge, start Fledge GUI, monitor processor load/memory occupation, and monitor system logs.  [[File:ORCA-TN-003-1.png|center|thumb|600x600px|Multiple SSH open connections]]  SSH can also be used to configure VSCode for remote development as illustrated [https://code.visualstudio.com/docs/remote/remote-overview here]. This set-up is very useful to explore/edit source code remotely, for instance. [[File:ORCA-TN-003-2.png|center|thumb|600x600px|VSCode configured for remote development]] On the ThingsBoard IoT platform side, we can verify that data is uploaded from the target as expected: [[File:ORCA-TN-003-3.png|center|thumb|600x600px|Verifying that data is uploaded to the ThingsBoard IoT platform]]==Visualize Fledge GUI on a local display==To visualize the GUI on the local display, we run a web browser configured to operate in kiosk mode.===Installing Weston===First of all, we install [https://wayland.freedesktop.org/ Weston], the compositor required by the browser. <pre class="workstation-terminal"> armbian@sbcorca-00a5:~$ sudo apt updateHit:1 http://deb.debian.org/debian bullseye InRelease...armbian@sbcorca-00a5:~$ sudo apt-get install weston...</pre> Create the file <code>/lib/systemd/system/weston.service</code> with the following contents: ‎<syntaxhighlight>[Unit]Description=Weston wayland compositorAfter=systemd-logind.service # D-Bus is necessary for contacting logind. Logind is required.Wants=dbus.socketAfter=dbus.socketBefore=graphical.target [Service]Type=oneshotEnvironmentFile=/etc/default/westonExecStart=/usr/bin/weston --shell=kiosk-shell.so # The user to run Weston as.User=rootGroup=root # Make sure the working directory is the users home directoryWorkingDirectory=/root/weston # Set up a full user session for the user, required by Weston.PAMName=weston-autologin # A virtual terminal is needed.TTYPath=/dev/tty7TTYReset=yesTTYVHangup=yesTTYVTDisallocate=yes [Install]WantedBy=graphical.target‎</syntaxhighlight> Then execute these commands in order to run it as a service: <pre class="workstation-terminal"> armbian@sbcorca-00a5:~$ sudo touch /etc/default/westonarmbian@sbcorca-00a5:~$ sudo mkdir /root/westonarmbian@sbcorca-00a5:~$ sudo systemctl enable westonCreated symlink /etc/systemd/system/graphical.target.wants/weston.service → /lib/systemd/system/weston.service.armbian@sbcorca-00a5:~$ sudo systemctl start weston</pre> ===Installing Chromium===The browser used for this TN is [https://www.chromium.org/chromium-projects/ Chromium]. To install it, please follow these steps. <pre class="workstation-terminal">armbian@sbcorca-00a5:~$ sudo apt-get install chromiumReading package lists... Done...</pre> Create the file <code>/lib/systemd/system/browser.service</code> with the following contents:<syntaxhighlight>[Unit]Description=Chromium browser serviceAfter=systemd-logind.serviceStartLimitIntervalSec=0Wants=dbus.socketAfter=dbus.socket [Service]Type=simpleRestart=alwaysRestartSec=5User=root PAMName=chromium-autologin ExecStart=/usr/bin/chromium --ozone-platform=wayland --kiosk --no-sandbox https://www.dave.eu [Install]WantedBy=graphical.target</syntaxhighlight> Start it as a service: <pre class="workstation-terminal">armbian@sbcorca-00a5:~$ sudo systemctl enable browserCreated symlink /etc/systemd/system/graphical.target.wants/browser.service → /lib/systemd/system/browser.service.armbian@sbcorca-00a5:~$ sudo systemctl start browser</pre> If everything works as expected, you will see the home page of the DAVE Embedded Systems' website: [[File:ORCA-TN-003-4.png|center|thumb|600x600px]]   ===Opening the local web application===To open the local web application, just replace https://www.dave.eu with http://localhost:4200 in <code>/lib/systemd/system/browser.service</code>. To make the change effective, issue the following commands:<pre class="workstation-terminal">armbian@sbcorca-00a5:~$ sudo systemctl daemon-reloadarmbian@sbcorca-00a5:~$ sudo systemctl restart browser</pre>The home page of Fledge GUI will be displayed: [[File:ORCA-TN-003-5.png|center|thumb|600x600px]]
4,650
edits