Skip to content

Commit 269a812

Browse files
author
Federico Fissore
committedSep 10, 2014
REST api timeouts can now be set using 'option socket_timeout NUMBER' in /etc/config/arduino
1 parent 5fd9888 commit 269a812

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed
 

‎package.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PREFIX=`basename $SOURCE_FOLDER`
1111

1212
cd ..
1313

14-
VERSION=1.4.3
14+
VERSION=1.5.0
1515

1616
tar --transform "s|$PREFIX/|luci-app-arduino-webpanel-$VERSION/|g" -cjv -f luci-app-arduino-webpanel-$VERSION.tar.bz2 \
1717
$PREFIX/www/index.html \

‎usr/lib/lua/luci/controller/arduino/index.lua

+18-6
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ function storage_send_request()
716716
return
717717
end
718718

719+
local uci = luci.model.uci.cursor()
720+
uci:load("arduino")
721+
local socket_timeout = uci:get_first("arduino", "arduino", "socket_timeout", 5)
722+
719723
local sock, code, msg = nixio.connect("127.0.0.1", 5700)
720724
if not sock then
721725
code = code or ""
@@ -724,8 +728,8 @@ function storage_send_request()
724728
return
725729
end
726730

727-
sock:setopt("socket", "sndtimeo", 5)
728-
sock:setopt("socket", "rcvtimeo", 5)
731+
sock:setopt("socket", "sndtimeo", socket_timeout)
732+
sock:setopt("socket", "rcvtimeo", socket_timeout)
729733
sock:setopt("tcp", "nodelay", 1)
730734

731735
local json = require("luci.json")
@@ -831,6 +835,10 @@ function board_plain_socket()
831835

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

838+
local uci = luci.model.uci.cursor()
839+
uci:load("arduino")
840+
local socket_timeout = uci:get_first("arduino", "arduino", "socket_timeout", 5)
841+
834842
local sock, code, msg = nixio.connect("127.0.0.1", 5555)
835843
if not sock then
836844
code = code or ""
@@ -839,8 +847,8 @@ function board_plain_socket()
839847
return
840848
end
841849

842-
sock:setopt("socket", "sndtimeo", 5)
843-
sock:setopt("socket", "rcvtimeo", 5)
850+
sock:setopt("socket", "sndtimeo", socket_timeout)
851+
sock:setopt("socket", "rcvtimeo", socket_timeout)
844852
sock:setopt("tcp", "nodelay", 1)
845853

846854
sock:write(params)
@@ -874,6 +882,10 @@ function build_bridge_mailbox_request()
874882
return
875883
end
876884

885+
local uci = luci.model.uci.cursor()
886+
uci:load("arduino")
887+
local socket_timeout = uci:get_first("arduino", "arduino", "socket_timeout", 5)
888+
877889
local sock, code, msg = nixio.connect("127.0.0.1", 5700)
878890
if not sock then
879891
code = code or ""
@@ -882,8 +894,8 @@ function build_bridge_mailbox_request()
882894
return
883895
end
884896

885-
sock:setopt("socket", "sndtimeo", 5)
886-
sock:setopt("socket", "rcvtimeo", 5)
897+
sock:setopt("socket", "sndtimeo", socket_timeout)
898+
sock:setopt("socket", "rcvtimeo", socket_timeout)
887899
sock:setopt("tcp", "nodelay", 1)
888900

889901
local json = require("luci.json")

0 commit comments

Comments
 (0)
Please sign in to comment.