Local Discovery

3 minutes read
Edit on GitHub

This guide will walk you through the process of discovering, on-boarding, controlling your secure OCF Device using plgd/client-application on your PC.

Note

Before you proceed to run the client application, ensure that Docker is already installed on your computer.

To run the client application, execute the following command in your terminal:

SOURCE Copy
Copied
        docker run --rm -it -e NUM_DEVICES=1 -p 8080:8080 ghcr.io/plgd-dev/client-application:latest
    

The Docker image also comes with a virtual device that can be discovered on the local network. By setting the value of NUM_DEVICES, you can specify the number of virtual devices to be discovered on the local network. If you wish to modify the client application’s configuration, mount the config.yaml file to the Docker container at the path /plgd/config.yaml. The logs of the client application can be found in the /tmp/client-application.log file within the Docker container.

Note

The Cloud Server must be running on your Raspberry Pi or on some other machine on your local network.

Firstly, download the latest version of the client application from here for your operating system. Below is an example of how to download and run the client application for Linux:

SOURCE Copy
Copied
        curl https://github.com/plgd-dev/client-application/releases/download/v0.5.0/client-application_0.5.0_linux_amd64.tar.gz --output client-application_0.5.0_linux_amd64.tar.gz
tar -xzf client-application_0.5.0_linux_amd64.tar.gz
cd client-application_0.5.0_linux_amd64
./client-application
    

The Client Application is now running on your PC. The application has opened a port for access from a browser via http://localhost:8080. By running the client application, the client application will automatically create a config.yaml file and www directory in the current directory.

Note

To onboard devices to the try.plgd.cloud, use the config.yaml file. To read more about how to change the config.yaml, continue here.

By default, the client application will ask you to set Subject ID and Key for the first time. The Subject ID is the unique identifier of the client-application, and the Key is the password for communication with the devices. The Subject ID and Key will be used to authenticate the device. After pressing the Initialize button, the client application will store the Subject ID and Key in the config.yaml file.

After initializing the client application, the discovery of devices on the local network will start automatically. The client application will discover all devices on the local network and display the list of devices on the web page. The Discover button appends new devices to the list of devices. To remove old devices, please click the Flush Cache button and then Discover.

Click on an unowned device to open the device section. After that, just click the Own button. After that, the Subject ID with Key becomes the owner of the device.

Note

The device needs to support the OCF Secure Specification without oscore. For iotivity-lite, it needs to be compiled with the -DOC_SECURE_ENABLED=ON -DOC_OSCORE_ENABLED=OFF cmake flag.

To reset ownership of the OCF device, click on Disown button.

Once a device is owned, it can be on-boarded to the hub. To onboard a device to the hub, click on the Onboard button. If the hub configuration is set in the config.yaml file, the device will be onboarded to the hub automatically. Otherwise, you will need to fill out the modal window with the onboard configuration of the hub. To obtain the configuration of the hub, open the hub UI and click on the + Device button, then enter the device ID. You can then copy the configuration from the hub modal window to the client application modal window. After that, the device will be onboarded to the hub.

Note

To be onboarded to the hub, the device must support the OCF Device to Cloud Services Specification. For iotivity-lite, it needs to be compiled with the -DOC_CLOUD_ENABLED=ON CMake flag.

To off-board the device from the hub, click on the Offboard button. After that, the device will be off-boarded from the hub.

To update or retrieve a resource of the device, locate the resource in the list of discovered devices and click on its name. This will open a modal window displaying the resource’s details, including its value, resource type, and attributes.

To update the resource, modify the value field and click the Update button. To retrieve the resource, click the Retrieve button.

Feb 3, 2023

Get started

plgd makes it simpler to build a successful IoT initiative – to create a proof of concept, evaluate, optimize, and scale.

Get Started Illustration Get Started Illustration