Skip to content

Commit

Permalink
REST api timeouts can now be set using 'option socket_timeout NUMBER'…
Browse files Browse the repository at this point in the history
… in /etc/config/arduino
  • Loading branch information
Federico Fissore committed Sep 10, 2014
1 parent 5fd9888 commit 269a812
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PREFIX=`basename $SOURCE_FOLDER`

cd ..

VERSION=1.4.3
VERSION=1.5.0

tar --transform "s|$PREFIX/|luci-app-arduino-webpanel-$VERSION/|g" -cjv -f luci-app-arduino-webpanel-$VERSION.tar.bz2 \
$PREFIX/www/index.html \
Expand Down
24 changes: 18 additions & 6 deletions usr/lib/lua/luci/controller/arduino/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,10 @@ function storage_send_request()
return
end

local uci = luci.model.uci.cursor()
uci:load("arduino")
local socket_timeout = uci:get_first("arduino", "arduino", "socket_timeout", 5)

local sock, code, msg = nixio.connect("127.0.0.1", 5700)
if not sock then
code = code or ""
Expand All @@ -724,8 +728,8 @@ function storage_send_request()
return
end

sock:setopt("socket", "sndtimeo", 5)
sock:setopt("socket", "rcvtimeo", 5)
sock:setopt("socket", "sndtimeo", socket_timeout)
sock:setopt("socket", "rcvtimeo", socket_timeout)
sock:setopt("tcp", "nodelay", 1)

local json = require("luci.json")
Expand Down Expand Up @@ -831,6 +835,10 @@ function board_plain_socket()

params = table.concat(params, "/")

local uci = luci.model.uci.cursor()
uci:load("arduino")
local socket_timeout = uci:get_first("arduino", "arduino", "socket_timeout", 5)

local sock, code, msg = nixio.connect("127.0.0.1", 5555)
if not sock then
code = code or ""
Expand All @@ -839,8 +847,8 @@ function board_plain_socket()
return
end

sock:setopt("socket", "sndtimeo", 5)
sock:setopt("socket", "rcvtimeo", 5)
sock:setopt("socket", "sndtimeo", socket_timeout)
sock:setopt("socket", "rcvtimeo", socket_timeout)
sock:setopt("tcp", "nodelay", 1)

sock:write(params)
Expand Down Expand Up @@ -874,6 +882,10 @@ function build_bridge_mailbox_request()
return
end

local uci = luci.model.uci.cursor()
uci:load("arduino")
local socket_timeout = uci:get_first("arduino", "arduino", "socket_timeout", 5)

local sock, code, msg = nixio.connect("127.0.0.1", 5700)
if not sock then
code = code or ""
Expand All @@ -882,8 +894,8 @@ function build_bridge_mailbox_request()
return
end

sock:setopt("socket", "sndtimeo", 5)
sock:setopt("socket", "rcvtimeo", 5)
sock:setopt("socket", "sndtimeo", socket_timeout)
sock:setopt("socket", "rcvtimeo", socket_timeout)
sock:setopt("tcp", "nodelay", 1)

local json = require("luci.json")
Expand Down

0 comments on commit 269a812

Please sign in to comment.