DISCLAIMER: This example application connects to ARM mbed Device Connector, a new web service hosted by ARM. However, at the time of publishing this example, the service may not yet be live or fully ready for use. If the example doesn't work for you, or you are having problems with it, that probably means we haven't yet got the service online. Please look out for mbed Device Connector release announcements in ARM mbed. If, however, you are mbed partner and have your own mbed Device Server setup, you can use this example application just by changing the mbed Device Server address from api.connector.mbed.com
to your own mbed Device Server address.
This document describes briefly the steps required to start using the mbed Client example application on mbed OS. The mbed Client example application demonstrates how to register and read resource values to mbed Device Connector and deregister from it.
- An FRDM-K64F board
- An Ethernet connection to the internet
- An Ethernet cable
- A micro-USB cable
- yotta - to build the example programs.
To set up the environment, you need to do the following:
- Go to mbed Device Connector website and log in with your mbed.org account.
- Configure the mbed Client example program with desired parameters. See mbed Build instructions chapter for more information.
- Build the application with yotta.
- Plug the Ethernet cable to the board.
- Load the application to the FRDM-K64F board.
This example uses IPV4 to communicate with the mbed Device Connector Server. The example program should automatically get an IPV4 address from the router when connected via Ethernet.
If your network does not have DHCP enabled, you have to manually assign a static IP address to the board. We recommend having DHCP enabled to make everything run smoothly.
You can use this example in the following connection modes:
- Non-secure mode
- Certificate mode
The general instructions for both modes are the same. The only difference comes in step 5, when selecting the mode.
- Connect the FRDM-K64F board to the computer with the micro-USB cable. Make sure that you are using the micro-USB port labeled OpenSDA.
- Install yotta. See instructions here.
- Install the necessary toolchains (
arm-none-eabi-gcc
). Refer to the yotta installation instructions (in step 3) to learn how to install the toolchains. - In the command prompt, go to mbed-client-examples directory.
- Select and set the connection mode as instructed below.
- Set up the target device,
yotta target frdm-k64f-gcc
. - In the command prompt, type
yotta build
. The binary filembed-client-examples.bin
will be created in the/build/frdm-k64f-gcc/source/
folder.
- Set the
CONN_MODE
value toM2MSecurity::NoSecurity
. - Set
MBED_SERVER_PORT
to5683
. - Open
sources/security.h
with your code editor to set the registration domain. You must use your mbed developer account username as a domain name. Enter your mbed developer account username as domain inMBED_DOMAIN
. - The endpoint registration name is defined as
MBED_ENDPOINT_NAME
insources/security.h
. You can change it by modifying it with your code editor.
- Set the
CONN_MODE
value toM2MSecurity::Certificate
. - Set
MBED_SERVER_PORT
to5684
. - Go to mbed Device Connector website.
- Navigate to Security credentials under My devices.
- Click GET MY DEVICE SECURITY CREDENTIALS. You will get the needed certificate information as well as the endpoint name and domain.
- Copy the created security credentials to
sources/security.h
.
- Connect the FRDM-K64F board to the internet using an Ethernet cable.
- Connect the FRDM-K64F board to your computer using a micro-USB cable. Make sure that you plug into the micro-USB port labeled OpenSDA, on the bottom of the board.
- Find the binary file named
mbed-client-examples.bin
in the foldermbed-client-examples/build/frdm-k64f-gcc/source/
. Drag and drop the file onto theMBED
drive on your computer. - The board will be programmed when the LED stops flashing. Press the RESET button to run the program.
Ensure that you have flashed the program to your mbed device (see Flashing to target device).
Step 1: Go to mbed Device Connector website.
Step 2: Log in using your mbed account.
Step 3: Click the Connected devices link under My devices to see your registered mbed Client example device.
Step 4: You can send requests to mbed Client device with mbed Device Connector API. To do that, click API Console under mbed Device Connector. Click the URL to create a request. For example: https://api.connector.mbed.com/v1/endpoints/lwm2m-endpoint/Test/0/S?sync=true
creates a GET request to the static /Test/0/S resource.
The /Test/0/S represents the static resource that is a fixed value set in the mbed Client.
The /Test/0/D represents the dynamic resource that can be read by the mbed Device Server. It is linked with the SW2 button on the FRDM board. The value starts from zero and every time you press the SW2 button the node increases the counter value by 1. You can make a CoAP request to the node resources to get the latest value. To do that, click API Console under mbed Device Connector. Click the URL to create a request. For example: https://api.connector.mbed.com/v1/endpoints/lwm2m-endpoint/Test/0/D?sync=true
creates a GET request to the /Test/0/D resource.This returns the latest value of /Test/0/D.
NOTE: In case you are getting error like Server Response : 410(Gone) or other such error, try clearing cache of your browser, logout and login again and then try.
For more information on the mbed Device Connector REST API, see help pages.
Step 5: If you press the SW3 button, the endpoint sends a deregister message to the mbed Device Connector. After a successful deregistration, LED D12 starts blinking indicating that the application has successfully completed the task.