Habilitar Modo Online via API 1º
Para habilitar o Modo Online via API deverá ser realizado primeiramente a request apontando o servidor de envio de eventos e após realizado a requisição para configuração dos parametros de keep alive (Habilitar Modo Online via API 2º).
Requisição - GET
http://192.168.1.201/cgi-bin/configManager.cgi?action=setConfig&PictureHttpUpload.Enable=true&PictureHttpUpload.UploadServerList[0].Address=192.168.1.200&PictureHttpUpload.UploadServerList[0].Port=3000&PictureHttpUpload.UploadServerList[0].Uploadpath=/notification
param | type | description |
---|---|---|
setConfig * | String | Comando para cadastrar configuração |
Enable * | Number | Habilita/Desabilita o servidor de envio |
Address * | Number | Endereço do Servidor |
Port * | Number | Porta do Servidor |
Uploadpath * | Number | Path do Servidor, exemplo "/notification" |
Importante: Verifique sempre as configurações de rede do seu produto, como Endereço de IP e Gateway, para garantir que o mesmo esteja acessível na rede.
Exemplo de Retorno - text/plain
OK
Exemplos
def config_online_mode(self, enable, server_address, port, path_event, device_mode, enable_keepalive, interval_keepalive, path_keepalive, timeout_keepalive, timeout_response) -> bool:
try:
url_server_config = "http://{}/cgi-bin/configManager.cgi?action=setConfig&PictureHttpUpload.Enable={}&PictureHttpUpload.UploadServerList[0].Address={}&PictureHttpUpload.UploadServerList[0].Port={}&PictureHttpUpload.UploadServerList[0].Uploadpath={}".format(
str(self.ip),
str(enable),
str(server_address),
str(port),
str(path_event),
)
url_keepalive_config = "http://{}/cgi-bin/configManager.cgi?action=setConfig&Intelbras_ModeCfg.DeviceMode={}&Intelbras_ModeCfg.KeepAlive.Enable={}&Intelbras_ModeCfg.KeepAlive.Interval={}&Intelbras_ModeCfg.KeepAlive.Path={}&Intelbras_ModeCfg.KeepAlive.TimeOut={}&Intelbras_ModeCfg.RemoteCheckTimeout={}".format(
str(self.ip),
str(device_mode),
str(enable_keepalive),
str(interval_keepalive),
str(path_keepalive),
str(timeout_keepalive),
str(timeout_response),
)
rval_events = requests.get(url_server_config, auth=self.digest_auth, stream=True, timeout=20, verify=False) # noqa
rval_keepalive = requests.get(url_keepalive_config, auth=self.digest_auth, stream=True, timeout=20, verify=False) # noqa
if rval_events.status_code != 200 or rval_keepalive.status_code != 200:
raise Exception()
return str(rval.text)
except Exception:
raise Exception("ERROR - During Set Online Mode - ")
Habilitar Modo Online via API 2º
Requisição - GET
http://192.168.1.201/cgi-bin/configManager.cgi?action=setConfig&Intelbras_ModeCfg.DeviceMode=2&Intelbras_ModeCfg.KeepAlive.Enable=true&Intelbras_ModeCfg.KeepAlive.Interval=120&Intelbras_ModeCfg.KeepAlive.Path=/keepalive&Intelbras_ModeCfg.KeepAlive.TimeOut=2000&Intelbras_ModeCfg.RemoteCheckTimeout=5
param | type | description |
---|---|---|
setConfig * | String | Comando para cadastrar configuração |
DeviceMode * | Number | Modo de operação, padrão 2 para Modo Online |
Enable * | Number | Habilita/Desabilitar o KeepAlive, por padrão deverá sempre ser habilitado. |
Interval * | Number | Intervalo de requisições do Keep Alive, medido em Segundos. Recomenda-se o valor 10 |
Path * | Number | Path do Servidor, exemplo "/notification" |
TimeOut * | String | Tempo limite para o servidor responder o keep alive, recomendado 2000 |
Exemplo de Retorno - text/plain
OK
Exemplos
def config_online_mode(self, enable, server_address, port, path_event, device_mode, enable_keepalive, interval_keepalive, path_keepalive, timeout_keepalive, timeout_response) -> bool:
try:
url_server_config = "http://{}/cgi-bin/configManager.cgi?action=setConfig&PictureHttpUpload.Enable={}&PictureHttpUpload.UploadServerList[0].Address={}&PictureHttpUpload.UploadServerList[0].Port={}&PictureHttpUpload.UploadServerList[0].Uploadpath={}".format(
str(self.ip),
str(enable),
str(server_address),
str(port),
str(path_event),
)
url_keepalive_config = "http://{}/cgi-bin/configManager.cgi?action=setConfig&Intelbras_ModeCfg.DeviceMode={}&Intelbras_ModeCfg.KeepAlive.Enable={}&Intelbras_ModeCfg.KeepAlive.Interval={}&Intelbras_ModeCfg.KeepAlive.Path={}&Intelbras_ModeCfg.KeepAlive.TimeOut={}&Intelbras_ModeCfg.RemoteCheckTimeout={}".format(
str(self.ip),
str(device_mode),
str(enable_keepalive),
str(interval_keepalive),
str(path_keepalive),
str(timeout_keepalive),
str(timeout_response),
)
rval_events = requests.get(url_server_config, auth=self.digest_auth, stream=True, timeout=20, verify=False) # noqa
rval_keepalive = requests.get(url_keepalive_config, auth=self.digest_auth, stream=True, timeout=20, verify=False) # noqa
if rval_events.status_code != 200 or rval_keepalive.status_code != 200:
raise Exception()
return str(rval.text)
except Exception:
raise Exception("ERROR - During Set Online Mode - ")