Development and examples
This document shows where to find the examples and the source code for Edge Core. Using the example, you can start testing how Edge Core works.
Your computer must have the GNU Compiler Collection (GCC) and the build tools for your target installed.
To install the minimal set of tools for building in Ubuntu 16.04 Linux:
$ apt update && apt install \ build-essential cmake make git libc6-dev
To connect Edge Core to Device Management, you need a Device Management account and a developer certificate. Read more about developer certificate provisioning.
You need to download the
mbed_cloud_dev_credentials.c source code file. Copy the file to the
config directory in the Edge Core sources to have it built into the application. You need to set the developer mode for the build.
When building Edge Core in the
BYOC mode (using your own CA), you need to inject the certificate information as a CBOR file with the command line argument
-c|--cbor-config. To convert the developer certificate to CBOR format use the
edge-tool help application. Refer to the tool help in the source code on how to do this.
The actual Edge Core code is in its own repository. Clone the repository and initialize the submodules as follows:
$ git clone https://github.com/ARMmbed/mbed-edge $ cd mbed-edge $ git submodule init $ git submodule update --recursive
See the instructions for compiling, configuring and running the code in the
README. When you run the code, your gateway device connects to Device Management.
The Edge Core example repository contains different protocol translator examples. To see and test how the protocol translator works, clone the repository and initialize the submodules as follows:
$ git clone https://github.com/ARMmbed/mbed-edge-examples $ cd mbed-edge-examples $ git submodule init $ git submodule update --recursive
See the instructions for compiling, configuring and running the examples in the
README. When you run the code, your protocol translated device connects to Device Management.
To see how to use the APIs, refer to the Edge Doxygen API documentation.
View device details in Device Management Portal
Now, that your devices are connected to Device Management, you can discover the connected devices in Device Management Portal.
To see the connected devices in Device Management Portal:
- Log in to Device Management Portal.
- Click Device directory.
- Select Registered only to see currently registered devices.
- In the Device type drop-down list:
- Select Gateways to see Edge devices.
- To see the devices connected to a gateway, you can expand the tree view by clicking the small triangle in front of the Device ID.
- Select Gateway connected devices to see Edge mediated devices.
- Select Gateways to see Edge devices.
To see the details of a specific gateway device or device connected to a gateway, click the Device ID, and the details pane appears, showing a few details. If the gateway has a specified location property (note that this is not related to the LwM2M location resource), then there is a toggle button to show the location of the device on a map.
The remaining information is divided into tabs for:
- Details: it shows different IDs, execution mode, dates for bootstrapping, creation and modification, the trusted certificate and also enables you to renew the certificate. You can also see additional info on the gateway by clicking the View gateway link.
- Attributes: it enables you to add, modify and delete custom attributes and shows you the values of the current device attributes.
- Resources: it lists all the resources of the gateway or devices connected to it. Here you can click the Resources to see their actual values.
- Events log: it lists all the event messages related to the selected device.
Managing devices using Device Management Portal
Using Device Management Portal, you can delete or grant secure access to gateway devices or devices connected to a gateway:
- Select one or more devices.
- Click Actions.
- Select the action you want to execute on the selected devices.
You can also add, modify or delete custom attributes of a device.
To add a custom attribute:
- Click on a Device ID.
- In the new pane, open the Attributes tab.
- Click the Add button.
- Type the attribute name and value to the fields and click Save.
To edit or delete the attributes:
- Select the attributes in the list.
- Click Actions.
- Select the action you want to execute on the attributes.
Edge Core and Protocol Translator API both log to the standard output. To preserve the logs, redirect the standard output to a file or logger process. You can rotate the log file based on file size or time, according to your preference. Make sure that you do not run out of disk space, because that is fatal to the system operation.
Auto-restart for Edge Core and protocol translators
When you have production devices running Edge Core and one or more protocol translators, always be prepared for software issues. If either of the components crashes for any reason, all operations stop.
To recover from such situations configure your system to auto-restart Edge Core and the protocol translator, or reboot the whole system.
The exact configuration depends on your Linux distribution, more specifically, which system service you use (such as SysVinit, BusyBox, Systemd).
Configure your distribution
For production devices, ensure that your Linux distribution is configured correctly. Read the security documentation and make the required changes.