Please note: this repository is deprecated and is no longer actively maintained.
However, there is a new reference example as part of Arm's Mbed Cloud offering and the application code is available via Mbed Cloud Client Example repository.
This document describes how to start using the mbed Client example application on Linux. The mbed Client example application demonstrates how to register to mbed Device Connector, read resource values and deregister from it.
Note: This example is targeted for building, compiling, and running on the Linux platform only.
64 bit Ubuntu/XUbuntu OS desktop environment.
Install yotta and all necessary toolchains. See instructions here.
You may need to open UDP port 5683 or 5684 in your computer's firewall for mbed Device Connector to communicate with this example application.
If you are running Ubuntu on a virtual machine, you should change your computer's Connection Settings from NAT Firewall
to Bridged
. Otherwise, incoming UDP packets may start dropping after a few minutes.
To run the example:
Go to the mbed Device Connector website and log in with your mbed.org account.
Clone this example into your local computer.
Configure the mbed Client example program as needed. See the Running and build instructions chapter for more information.
Build the application with yotta. See the Running and build instructions chapter for more information.
This example works in secure Certificate mode.
You can also connect in different socket mode. To select the binding mode for the socket, change SOCKET_MODE
between M2MInterface::UDP
and M2MInterface::TCP
. The instructions further in this document remain te same irrespective of the socket mode you select.
First, made sure you have installed yotta and all necessary toolchains. See instructions here.
In the command prompt, go to mbed-client-linux-example.
Set up the application with correct Certificate and Domain:
A. Go to the mbed Device Connector website.
B. Go to My devices -> Security credentials.
C. Click GET MY DEVICE SECURITY CREDENTIALS. You will get the needed certificate information as well as the endpoint name and domain.
D. Copy the security credentials to source/security.h
.
In the command prompt, type yotta target x86-linux-native
to set up the target device.
In the command prompt, type yotta build
. The executable file will be created in the folder build/x86-linux-native/source/
.
In the folder mbed-client-linux-example/build/x86-linux-native/source/
, find the executable file mbed-client-linux-example
.
To run the executable from the command line, type ./mbed-client-linux-example
.
The program begins execution and starts registration with mbed Device Connector. The console displays Registering endpoint and when the registration is successful it displays Registered.
After a successful registration, the program will automatically start incrementing one of the resource values every 10 seconds, displaying Resource Value /Test/0/D :
Start Wireshark on the computer where your example application is running.
Select your Ethernet interface, usually Local Area Connection.
Click Start.
Select Filter in the toolbar and add a filter to correspond to the UDP port that you are using (5684 for secure). Activate the filter and press Enter.
Run your example application from the command line.
Note: If you are running mbed DS on the same host as the example application you have to select the loopback interface in Wireshark.
Ensure that you have the example application running on your Linux environment (see Running the mbed Client Linux example).
Go to the mbed Device Connector website.
Log in using your mbed account.
Go to My devices -> Connected devices to see your registered mbed Client example device.
You can send a CoAP request to the mbed Client device with the mbed Device Connector API. To do that:
Go to mbed Device Connector -> API Console.
Click the URL to create a request. For example: https://api.connector.mbed.com/endpoints/<MBED_ENDPOINT_NAME>/Test/0/S
creates a GET request to the static /Test/0/S resource.
For more information on the mbed Device Connector REST API, see help pages.
To stop and deregister the mbed Client example, you need to interrupt the program by pressing CTRL+C. This sends an unregister message to mbed DS. The console displays Unregistering endpoint. After a successful deregistration, the console displays Unregistration done --> exiting and terminates the program. Also, the endpoint disappears from the Connected devices list on the mbed Device Connector web UI.