Logic Machine Forum
AXIS D2050-VE Radar control - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: AXIS D2050-VE Radar control (/showthread.php?tid=2633)



AXIS D2050-VE Radar control - LKBA - 08.05.2020

Hello!

I have this axis product in one project.
These radars are great for perimeter protection as they help to reduce fake triggers from IP cameras.
Also, when linked with PTZ cameras - they control PTZ to accurately track intruders with zoomed-in vision.

Everything would be fine, but PTZ tracking service is running on windows machine and i would like to control from LM when this service is available.
I thought that disabling radar while not needed would be easier task than stopping service on windows machine.

I need to HTTP POST JSON data with digest auth, and don't know how to assemble this request. 
I successfully did it with basic auth, but i need digest, as 'radar autotracking for PTZ' needs this level of authorization.

Could someone help me?

Basic auth code is here:
Code:
function post(url, body)
  local ltn12 = require('ltn12')
  local http = require('socket.http')
  local sink = {}

  local res, err = http.request({
    url = url,
    method = 'POST',
    headers = {
      ['Authorization'] = 'Basic '..(mime.b64('<username>:<password>')),
      ['Content-Length'] = #body,
      ['Content-Type'] = 'application/json',
    },
    sink = ltn12.sink.table(sink),
    source = ltn12.source.string(body),
  })

  if res then
    return table.concat(sink)
  else
    return nil, err
  end
end

require('json')

url = 'http://<IPADDRESS>/axis-cgi/radar/control.cgi'
body = json.encode({ apiVersion = '1.3',context =  '<client context>',method = 'setEnabled',params = {enabled = false}})
--res, err = post(url, body)
--log(res, err)
I need this to work with digest.

Thanks!


RE: AXIS D2050-VE Radar control - Erwin van der Zwart - 09.05.2020

Try digest code from this post:

https://forum.logicmachine.net/showthrea...64#pid9364

BR,

Erwin


RE: AXIS D2050-VE Radar control - LKBA - 11.05.2020

(09.05.2020, 09:22)Erwin van der Zwart Wrote: Try digest code from this post:

https://forum.logicmachine.net/showthrea...64#pid9364

BR,

Erwin
Thank You, I tried this, but cannot manage on how to change method to POST and add json body to it Sad
If i change method it tells me i'm giving wrong credentials.