Websoket with server inside Android HMI Ltouch

In 2018 eight out of ten people have a smartphone, so it is a great achievement to share data acquired by our Android HMI Ltouch
(such as the measure of a temperature) over a wireless network and look at it with a web browser.

Let’s see how using an Ltouch 7, there are only 2 steps:

Step 1
Install an http server to provide the webpage with measures; in our tests we used Http Server by Tautvydas Andrikys, it is very interesting
because it can support php after the installation of Server for PHP by the same author. Once installed these apks, tap “server address and port” to set
an http port ,default is 8000, you can change but do not use privileged ports (ports below 1024 , see for example ), then choose ip address to answer on each ip assigned to the Ltouch.

Enable php support:

CGI setting -> enable com.esminis.server.php (Server for PHP)

Finally enable start on boot.

Copy webpage index2.html to /mnt/sdcard/htdocs/public :
adb push index2.html /mnt/sdcard/htdocs/public
Copy configuration files for php server php.ini to /mnt/sdcard/www/config :
adb push index2.html /mnt/sdcard/www/config
Copy configuration files for http server: certificate.cert / certificate.key / httpd.conf to: /mnt/sdcard/htdocs/config
adb push certificate.cert /mnt/sdcard/htdocs/config
adb push certificate.key /mnt/sdcard/htdocs/config
adb push http.conf /mnt/sdcard/htdocs/config

Reboot touch.

However you can use any http server.
Enable hotspot in the settings of Ltouch: settings -> more -> portable hotspot , here we can setup wifi parameters : network name and
password, then tap on portable hotspot to enable it

Step 2
install the apk available in the download area; it’s a simple app which uses modbus library by Biemme to read the measure of a temperature
provided by an external device and connected to the rs485 port of the touch

Now using your pc or smartphone, you can connect to the wifi network just created: open a browser and type
in the address bar, note that you must use the port set in the http server in the address, we are using 8000, if you set another value use that
instead of 8000.

Moreover, the duo webpage/application allow us to handle input/output pins handled by Android kernel on the side of Ltouch, the ones provided
by expansion boards are handled with modbus calls and are excluded.

Source codes are available in our download area