ONVIF Camera Discovery
ONVIF Camera discovery provides the ability to automatically scan the network, identify what cameras are running, and automatically onboard the devices to the Edge Xpert platform.
This automatic discovery process greatly reduces the effort in allowing ONVIF cameras to be onboarded quickly and easily.
Create a local docker-compose file
Create a local docker-compose file to override the default Edge Xpert image and its settings.
This example uses two ONVIF simulator instances, which runs with ports 10000 and 10001.
The configuration shown below will automatically discover and onboard all ONVIF cameras to the platform. These devices are given names relating to the Vendor Name and Device Instance so they can be easily recognized.
version: '3.7'
x-common-env-variables: &security-common-variables
EDGEX_SECURITY_SECRET_STORE: "true"
EDGEXPERT_LICENSE_PATH: /edgexpert/licenses/
x-logging: &default-logging
driver: "json-file"
options:
max-size: "10mb"
max-file: "5"
services:
device-onvif-camera-host:
image: iotechsys/edgexpert-device-onvif-camera:2.3
command: /device-onvif-camera ${EDGEXPERT_USE_CONSUL:-}
container_name: device-onvif-camera
hostname: device-onvif-camera
network_mode: host
user: 2002:2001
read_only: true
restart: always
environment:
<<: *security-common-variables
SERVICE_HOST: 172.17.0.1
MESSAGEQUEUE_HOST: <MQTT_BROKER_HOST>
CLIENTS_CORE_DATA_HOST: <CORE_DATA_HOST>
CLIENTS_CORE_METADATA_HOST: <CORE_METADATA_HOST>
XRTCONTROL_MQTTBROKERINFO_HOST: <MQTT_BROKER_HOST>
SECRETSTORE_HOST: <VAULT_HOST>
SECRETSTORE_PORT: '8200'
APPCUSTOM_DEFAULTSECRETPATH: MyCredential
APPCUSTOM_DISCOVERYMODE: both
APPCUSTOM_DISCOVERYETHERNETINTERFACE: en0
APPCUSTOM_DISCOVERYSUBNETS: "192.168.56.0/24,192.168.12.0/24"
volumes:
- /etc/localtime:/etc/localtime:ro
- license-data:/edgexpert/licenses/:ro
- /tmp/edgex/secrets/device-onvif-camera:/tmp/edgex/secrets/device-onvif-camera:ro,z
depends_on:
- consul
- core-metadata
logging: *default-logging
Note
- Use the host network so that discovery messages can be sent over UDP to cameras
- Since we cannot use the
host
andedgex-network
at the same time, we must define another ONVIF Camera device service in the docker-compose file - Enable the secure mode by setting
EDGEX_SECURITY_SECRET_STORE
totrue
, then you can post secret data via the REST API of the device service - Please replace the
APPCUSTOM_DISCOVERYETHERNETINTERFACE
andAPPCUSTOM_DISCOVERYSUBNETS
to meet your environment - Please refer to CLI Service Ports to get the values for
<MQTT_BROKER_HOST>
,<CORE_DATA_HOST>
,<CORE_METADATA_HOST>
and<VAULT_HOST>
.
APPCUSTOM_DEFAULTSECRETPATH
indicates the default secret path, refer to ONVIF user auth page to find more instructionsAPPCUSTOM_DISCOVERYMODE
indicates mode used to discovery devices on the network, available values arenetscan
,multicast
andboth
, default isboth
APPCUSTOM_DISCOVERYETHERNETINTERFACE
indicates the target EthernetInterface for multicast discoveringAPPCUSTOM_DISCOVERYSUBNETS
indicates the network segments used when discovery is scanning for devices. It is a list of IPv4 subnets in CIDR(Classless Inter-Domain Routing) format (X.X.X.X/Y) and separated by commas ex: "192.168.1.0/24,10.0.0.0/24"
Deploy Edge Xpert with the ONVIF Camera Device Service
Use the following command to deploy the required services:
edgexpert up --secret xpert-manager device-onvif-camera-host
After deploying Edge Xpert, post the secrets into the secret store via the REST API of the device service:
curl --request POST 'http://172.17.0.1:59985/api/v2/secret' \
--header 'Content-Type: application/json' \
--data-raw '{
"apiVersion":"v2",
"path": "MyCredential",
"secretData":[
{
"key":"username",
"value":"admin"
},
{
"key":"password",
"value":"admin"
},
{
"key":"mode",
"value":"usernametoken"
}
]
}'
Query the discovered devices
The ONVIF Camera Device Service will trigger discovery when the service starts up and the two devices should be discovered. The default is that the discovery process runs every hour.
This can be controlled, as below:
DEVICE_DISCOVERY_ENABLED: 'true'
DEVICE_DISCOVERY_INTERVAL: '30m'
You can use seconds (s), minutes (m), hours (h), and so forth.
The discovery and onboarding of the devices can be easily verified by using the Edge Xpert Manager UI at http://localhost:9090
.