I'm using Openwrt ( CHAOS CALMER (15.05.1, r48532)) router with Arduino connected via USB FTDI adapter.
Serial port is /dev/ttyUSB0
Arduino code prints some data in Serial.
I need print this data on web page.
For this I copied Diagnostic view from menu Network into index.lua in /usr/lib/lua/luci/controller/admin
entry({"admin", "logout"}, call("action_logout"), _("Logout"), 90)
-- my test menu
entry({"admin", "test"}, template("admin_test/index"), _("Test"), 140)
So now my new menu element Test located right after the Logout menu.
Also I added stopwatch timer code.
Here is the code of my view /usr/lib/lua/luci/view/admin_test: https://pastebin.com/NQmhaPET
Also I added some simple code in /usr/lib/lua/luci/controller/admin/network.lua so when I press button Send it runs my lua script /root/send
page = entry({"admin", "network", "diag_send"}, call("diag_send"), nil)
page.leaf = true
........
function diag_send(addr)
diag_command("/root/send %q 2>&1", addr)
end
It works as expected when I open it in Chrome or Firefox on Windows. I press Send, lua script stars, and timer starts show seconds, when script received answer from Arduino it prints it to output and the data show as AJAX response.
But if I'm opening it in my Android phone in mobile Chrome or Firefox - it runs my lua script twice which leads to broke output data.
I can see it in system console - when I pressed button Send, it starts my script, and after 4-5 seconds it starts this script second time.
The issue is reproduced on different phones.
Please advice how to fix it...