Skip to content

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

  1. Clone the device-onvif-camera repository.

    git clone https://github.com/edgexfoundry/device-onvif-camera.git
    

  2. 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.

  1. Make a copy of the camera.toml.example:

    cp ./cmd/res/devices/camera.toml.example ./cmd/res/devices/camera.toml
    

  2. Open the cmd/res/devices/camera.toml file using your preferred text editor and update the Address and Port 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

  3. Optionally, modify the Name and Description fields to more easily identify the camera. The Name is the camera name used when using ONVIF Device Service Rest APIs. The Description is simply a more detailed explanation of the camera.

  4. You can also optionally configure the CustomMetadata with custom fields and values to store any extra information you would like.

  5. To add more pre-defined devices, copy the above configuration and edit to match your extra devices.

Configure the Device Service

  1. Open the ./cmd/res/configuration.toml file using your preferred text editor

  2. Make sure secret path is set to match SecretPath in camera.toml. In the sample below, it is "credentials001". If you have multiple cameras, make sure the secret paths match.

  3. Under secretName, set username and password to your camera credentials. If you have multiple cameras copy the Writable.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

  1. 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:
    make docker-nats
    
    See Compose Builder nat-bus option to generate compose file for NATS and local dev images.

  2. 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
    

  3. Navigate to edgex-compose and enter the compose-builder directory.
    bash cd edgex-compose/compose-builder

  4. 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
    

  5. 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

Next Steps

Deploy and Run the Service>

License

Apache-1.0