05.10.2018, 20:27 (This post was last modified: 05.10.2018, 20:35 by buuuudzik.)
My client has on his house HIKVision cameras and I am so impressed about its quality and also modern webserver and API. But it is fresh software so I must update my scripts to support such cameras. I found that I cannot download an image in same way as before in BCS cameras. I have right path: http://username:password@ip_address:port/ISAPI/Streaming/channels/102/picture
and it's work perfectly on webbrowser but unfortunately not in script.
This is my script:
Code:
require('socket.http')
local image1 = socket.http.request('http://username:password@ip_address:port/ISAPI/Streaming/channels/102/picture')
log(#image1)
And it logs that length of image1 is nil.
I've found this specification: http://down.dipol.com.pl/Cctv/-Hikvision...ervice.pdf
I've had similar differences when I've tried get image from old BCS camera and new HIK by Postman app and I've figured out that on HIK cameras autentification must be set to Digest Auth. How can I do it in Lua?
05.10.2018, 21:41 (This post was last modified: 05.10.2018, 21:47 by buuuudzik.)
Also I see that there is possibility to download uptodate list or have connection with camera and get notified when new event occured but it is not so easy to me. In node js all would be easy but how use this function in Lua?
This means that you need to use digest auth here as well. Considering the code complexity, writing any examples without access to the real device is like shooting in the dark, sorry.
(10.10.2018, 10:22)admin Wrote: This means that you need to use digest auth here as well. Considering the code complexity, writing any examples without access to the real device is like shooting in the dark, sorry.
Thanks for your efforts. I can give you an access to the real device via private message.
Try this, change IP, port, user and pass as needed. If this works correctly, you should get xml payloads in Logs tab, otherwise errors will go to Alerts tab.
Code:
require('socket')
md5sum = require('encdec').md5
host = '192.168.1.2'
port = 80
user = 'username'
pass = 'password'
uri = '/ISAPI/Event/notification/alertStream'
function getheader(resp, header)
local st, en
header = header .. '="'
st = resp:find(header)
if st then
en = resp:find('"', st + #header)
if en then
return resp:sub(st + #header, en - 1)
end
end
end
function makedigestheader(headers)
local digest = {}
for _, header in ipairs(headers) do
if not header.unquote then
header[ 2 ] = '"' .. header[ 2 ] .. '"'
end
while true do
line, err = sock:receive('*l')
if line then
if line:find(cl, 1, true) then
len = tonumber(line:sub(#cl + 1))
if len then
sock:receive('*l') -- skip empty line
data, err = sock:receive(len)
if data then
log(data)
else
alert('data receive failed: ' .. tostring(err))
end
end
end
else
alert('line receive failed: ' .. tostring(err))
break
end
end
28.05.2020, 14:40 (This post was last modified: 28.05.2020, 14:45 by Alberto.ricof.)
Hello,
I rescue this thread to see if anyone can help me,
How can I find the values in the XML data that the string returns? specifically what I need are the ones marked in yellow in the attached screenshot. These records are only sent if: <statisticalMethods> realTime </statisticalMethods>