This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

API Control camera Vivotek
#5
(02.10.2024, 11:52)admin Wrote: Run this script as resident. Change host variable to your camera IP and auth variable to access credentials in username:password format. Make sure that Basic auth mode (not digest) is set on your camera. Then post what you get in LM Logs when running this script.
Code:
local json = require('json')
local socket = require('socket')
local mime = require('mime')

local host = '192.168.1.1'
local auth = 'user:password'

local sock = socket.tcp()
sock:settimeout(15)

local res, err = sock:connect(host, 80)

if not res then
  sock:close()
  log('connect failed', err)
  os.sleep(5)
  return
end

local function init()
  local crlf = '\r\n'

  sock:send(
    'GET /FR/events/live/json?heartbeat=10 HTTP/1.1' .. crlf ..
    'Host: ' .. host .. crlf ..
    'Authorization: Basic ' .. mime.b64(auth) .. crlf .. crlf
  )
end

local function parse(resp)
  resp = json.pdecode(resp)
  log(resp)
end

init()
local pat, len = nil, nil

while true do
  res, err = sock:receive(pat)
  log('rx', pat, res, err)

  if err then
    sock:close()
    log('receive error', err)
    break
  end

  if type(pat) == 'number' then
    pcall(parse, res)
    pat, len = nil, nil
  elseif #res == 0 then
    pat = len
  elseif not len then
    len = res:match('Content%-Length: (%d+)')
    len = tonumber(len)
  end
end
Thanks for the reply.
I am sending the log again as attached file.
Please help me.

Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
API Control camera Vivotek - by luanpt - 29.09.2024, 12:06
RE: API Control camera Vivotek - by admin - 30.09.2024, 07:43
RE: API Control camera Vivotek - by luanpt - 01.10.2024, 02:13
RE: API Control camera Vivotek - by admin - 02.10.2024, 11:52
RE: API Control camera Vivotek - by luanpt - 05.10.2024, 05:32
RE: API Control camera Vivotek - by admin - 07.10.2024, 06:33
RE: API Control camera Vivotek - by luanpt - 10.10.2024, 10:01
RE: API Control camera Vivotek - by admin - 10.10.2024, 13:04
RE: API Control camera Vivotek - by luanpt - 12.10.2024, 05:09

Forum Jump: