mbed Custom GATT

This example shows you how to write an mbed program that toggles a LED on the Nordic Semiconductor nRF51 DK using a mobile application.

Source code

The mbed source code for this example is found at the mbed.org web site. There you will also find a tutorial for the mbed program.

The source code for the mobile application is provided with the Evothings Studio download. You can browse the HTML/JS code online at the Evothings GitHub repository.

The file index.html contains the HTML markup and the file app.js contains the application logic.

What you need

This example runs in Evothings Viewer on Android or iOS.

An iOS device or an Android device with support for Bluetooth 4.0 (which includes BLE) is required. For Android, version 4.3 or later is needed.

You need the Nordic Semiconductor nRF51 DK or a another mbed compatible device (we have tested this example with the nRF51).

Building the mbed program

Source code and information about the mbed program is available at the mbed.org web site.

Summary of how to build and install the mbed program:

  • Log in to the online mbed IDE at: mbed.org (sign up if you don't have an account).
  • Go to the Nordic nRF51 platform page.
  • Click "Add to your mbed Compiler".
  • Go to the page for the example program.
  • Click "Import this program", this will open the mbed online compiler/IDE.
  • When you have finished importing the program, click the "Compile" button in the mbed IDE.
  • You will now be prompted to download the compiled program.
  • Next step is to install the downloaded program on the nRF51 board.
  • Install the Segger J-Link drivers.
  • Connect the Nordic board to your computer using USB - it should mount as a drive.
  • Drag the compiled program file to the Nordic board - your program now runs on the board.
  • You may see messages saying that the device was not disconnected properly, that is because it automatically unmounts and mounts again. You should not have to worry about any such messages. If you experience problems try to unplug the board and plug in again to mount and restart the program.

Also check out the mbed quick start video on YouTube.

Related information is available in this tutorial for Nordic Semiconductor nRF51 DK.

How to run the mobile app

Follow these steps to run the mobile app for this example:

  • Run Evothings Workbench on your desktop/laptop computer.
  • Run Evothings Viewer on an iOS or Android mobile device and connect to the Workbench.
  • Launch the example "mbed Custom GATT" from the Workbench window.
  • Follow on-screen instructions in the app. Note that the device name in the text field must match the name set in the mbed program. Otherwise the app won't be able to find the board.
  • Tap connect, and when connected use Toggle LED to turn on and off the LED.