Skip to content

Commit

Permalink
AP_Scripting: started on web server example
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Dec 4, 2023
1 parent 240ede6 commit 69cbae5
Show file tree
Hide file tree
Showing 2 changed files with 511 additions and 10 deletions.
13 changes: 3 additions & 10 deletions libraries/AP_Scripting/examples/net_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ local MAV_SEVERITY = {EMERGENCY=0, ALERT=1, CRITICAL=2, ERROR=3, WARNING=4, NOTI
PARAM_TABLE_KEY = 46
PARAM_TABLE_PREFIX = "NT_"

-- bind a parameter to a variable given
function bind_param(name)
local p = Parameter()
assert(p:init(name), string.format('could not find %s parameter', name))
return p
end

-- add a parameter and bind it to a variable
function bind_add_param(name, idx, default_value)
assert(param:add_param(PARAM_TABLE_KEY, idx, name, default_value), string.format('could not add param %s', name))
return bind_param(PARAM_TABLE_PREFIX .. name)
return Parameter(PARAM_TABLE_PREFIX .. name)
end

-- Setup Parameters
Expand Down Expand Up @@ -68,15 +61,15 @@ if not sock_udp_echo then
end

if not sock_tcp_in:bind("0.0.0.0", NT_BIND_PORT:get()) then
gcs:send_text(MAV_SEVERITY.ERROR, "net_test: failed to bind to TCP 5001")
gcs:send_text(MAV_SEVERITY.ERROR, string.format("net_test: failed to bind to TCP %u", NT_BIND_PORT:get()))
end

if not sock_tcp_in:listen(1) then
gcs:send_text(MAV_SEVERITY.ERROR, "net_test: failed to listen")
end

if not sock_udp_in:bind("0.0.0.0", NT_BIND_PORT:get()) then
gcs:send_text(MAV_SEVERITY.ERROR, "net_test: failed to bind to UDP 5001")
gcs:send_text(MAV_SEVERITY.ERROR, string.format("net_test: failed to bind to UDP %u", NT_BIND_PORT:get()))
end

--[[
Expand Down
Loading

0 comments on commit 69cbae5

Please sign in to comment.