How to manually add devices using the onvif client library API?
Manually add devices using the code example below:
// Define an ONVIF_DEVICE variable
ONVIF_DEVICE g_device;
// open log file
log_init("log.txt");
log_set_level(LOG_DBG);
// init system buffer
sys_buf_init(10 * MAX_DEV_NUMS);
// init http message buffer
http_msg_buf_init(10 * MAX_DEV_NUMS);
// init g_device
memset(&g_device, 0, sizeof(g_device));
g_device.binfo.XAddr.https = 0; // If using an HTTPS connection, set it to 1
g_device.binfo.XAddr.port = 8000; // Specify the ONVIF service port of the device
strcpy(g_device.binfo.XAddr.host, "192.168.1.3"); // Specify the IP address of the device
strcpy(g_device.binfo.XAddr.url, "/onvif/device_service");
// set device login information
onvif_SetAuthInfo(&g_device, "admin", "admin");
// set auth method
onvif_SetAuthMethod(&g_device, AuthMethod_UsernameToken);
// set request timeout
onvif_SetReqTimeout(&g_device, 5000);
// Next you can call other API interfaces.
if (!GetSystemDateAndTime(&g_device))
{
printf("%s, GetSystemDateAndTime failed\r\n", g_device.binfo.XAddr.host);
}
if (!GetCapabilities(&g_device))
{
printf("%s, GetCapabilities failed\r\n", g_device.binfo.XAddr.host);
}
if (!GetServices(&g_device))
{
printf("%s, GetServices failed\r\n", g_device.binfo.XAddr.host);
}
if (!GetDeviceInformation(&_device))
{
printf("%s, GetDeviceInformation failed\r\n", g_device.binfo.XAddr.host);
}