Custom Build
Warning
This is not the recommended method of deploying the service. To use the default images, see here.
Follow this guide to make custom configurations and build the device service image from the source.
Get the Source Code
-
Clone the device-onvif-camera repository.
git clone https://github.com/edgexfoundry/device-onvif-camera.git
-
Navigate into the directory
cd device-onvif-camera
Configuration
Configure the Pre-Defined Devices
Configuring pre-defined devices will allow the service to automatically provision them into core-metadata. Create a list of devices with the appropriate information as outlined below.
-
Make a copy of the
camera.toml.example
:
cp ./cmd/res/devices/camera.toml.example ./cmd/res/devices/camera.toml
-
Open the
cmd/res/devices/camera.toml
file using your preferred text editor and update theAddress
andPort
fields to match the IP address of the Camera and port used for ONVIF services:[[DeviceList]] Name = "Camera001" # Modify as desired ProfileName = "onvif-camera" # Default profile Description = "onvif conformant camera" # Modify as desired [DeviceList.Protocols] [DeviceList.Protocols.Onvif] Address = "191.168.86.34" # Set to your camera IP address Port = "2020" # Set to the port your camera uses SecretPath = "credentials001" [DeviceList.Protocols.CustomMetadata] CommonName = "Outdoor camera"
Sample: Snippet from camera.toml
-
Optionally, modify the
Name
andDescription
fields to more easily identify the camera. TheName
is the camera name used when using ONVIF Device Service Rest APIs. TheDescription
is simply a more detailed explanation of the camera. -
You can also optionally configure the
CustomMetadata
with custom fields and values to store any extra information you would like. -
To add more pre-defined devices, copy the above configuration and edit to match your extra devices.
Configure the Device Service
-
Open the
./cmd/res/configuration.toml
file using your preferred text editor -
Make sure
secret path
is set to matchSecretPath
incamera.toml
. In the sample below, it is"credentials001"
. If you have multiple cameras, make sure the secret paths match. -
Under
secretName
, setusername
andpassword
to your camera credentials. If you have multiple cameras copy theWritable.InsecureSecrets
section and edit to include the new information.
[Writable]
[Writable.InsecureSecrets.credentials001]
secretName = "credentials001"
[Writable.InsecureSecrets.credentials001.SecretData]
username = "<Credentials 1 username>"
password = "<Credentials 1 password>"
mode = "usernametoken" # assign "digest" | "usernametoken" | "both" | "none"
[Writable.InsecureSecrets.credentials002]
secretName = "credentials002"
[Writable.InsecureSecrets.credentials002.SecretData]
username = "<Credentials 1 password>"
password = "<Credentials 2 password>"
mode = "usernametoken" # assign "digest" | "usernametoken" | "both" | "none"
Sample: Snippet from configuration.toml
Additional Configuration Options
For optional configurations, see here.
Build the Docker Image
-
In the
device-onvif-camera
directory, run make docker:make docker
[Optional] Build with NATS Messaging
Currently, the NATS Messaging capability (NATS MessageBus) is opt-in at build time. This means that the published Docker image and Snaps do not include the NATS messaging capability. To build the docker image using NATS, run make docker-nats:See Compose Buildermake docker-nats
nat-bus
option to generate compose file for NATS and local dev images. -
Verify the ONVIF Device Service Docker image was successfully created:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE edgexfoundry-holding/device-onvif-camera 0.0.0-dev 75684e673feb 6 weeks ago 21.3MB
-
Navigate to
edgex-compose
and enter thecompose-builder
directory.
bash cd edgex-compose/compose-builder
-
Update
.env
file to add the registry and image version variable for device-onvif-camera: Add the following registry and version information:DEVICE_ONVIFCAM_VERSION=0.0.0-dev
-
Update the
add-device-onvif-camera.yml
to point to the local image.services: device-onvif-camera: image: edgexfoundry/device-onvif-camera:${DEVICE_ONVIFCAM_VERSION}
Additional Configuration
Here is some information on how to specially configure parts of the service beyond the provided defaults.
Configure the Device Profiles
The device profile contains general information about the camera and includes all of the device resources and commands that the device resources can use to manage the cameras. The default ../cmd/res/camera.yaml
contains all possible resources a camera could implement. Enable and disable supported resources in this file, or create an entirely new profile. It is important to set up the device profile to match the capabilities of the camera. Information on the resources supported by specific cameras can be found here. Learn more about device profiles in EdgeX here.
name: "onvif-camera" # general information about the profile
manufacturer: "Generic"
model: "Generic ONVIF"
labels:
- "onvif"
description: "EdgeX device profile for ONVIF-compliant IP camera."
deviceResources:
# Network Configuration
- name: "Hostname" # an example of a resource with get/set values
isHidden: false
description: "Camera Hostname"
attributes:
service: "Device"
getFunction: "GetHostname"
setFunction: "SetHostname"
properties:
valueType: "Object"
readWrite: "RW"
Sample: Snippet from camera.yaml
Configure the Provision Watchers
The provision watcher sets up parameters for EdgeX to automatically add devices to core-metadata. They can be configured to look for certain features, as well as block features. The default provision watcher is sufficient unless you plan on having multiple different cameras with different profiles and resources. Learn more about provision watchers here.
{
"name":"Generic-Onvif-Provision-Watcher",
"identifiers":{ // Use the identifiers to filter through specific features of the protocol
"Address": ".",
"Manufacturer": "Intel", // example of a feature to allow through
"Model": "DFI6256TE"
},
"blockingIdentifiers":{
},
"serviceName": "device-onvif-camera",
"profileName": "onvif-camera",
"adminState":"UNLOCKED"
}
Sample: Snippet from generic.provision.watcher.json