Contains demonstrator code to connect the mbed FRDM-K64F devices to the Datavenue Live Objects SaaS platform.

Dependencies:   MQTTPacket

Committer:
jhamel
Date:
Tue Apr 04 16:29:57 2017 +0200
Revision:
3:56af709c24e1
Parent:
0:a46886781dee
Use CA from Symantec/VeriSign, and fix TLS issue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhamel 0:a46886781dee 1 LiveObjects Iot Device Demonstrator : Green House
jhamel 0:a46886781dee 2 ===================================
jhamel 0:a46886781dee 3
jhamel 0:a46886781dee 4 This is the Live Objects IoT device demonstrator, running on FRDM-K64F board.
jhamel 0:a46886781dee 5
jhamel 0:a46886781dee 6 The application:
jhamel 0:a46886781dee 7
jhamel 0:a46886781dee 8 1. Connects to network with Ethernet (using DHCP)
jhamel 0:a46886781dee 9 1. Connects to the [Datavenue Live Objects Plaftorm](https://liveobjects.orange-business.com/doc/html/lo_manual.html), using:
jhamel 0:a46886781dee 10 * an optional secure connection (TLS)
jhamel 0:a46886781dee 11 * the LiveObjects mode: [Json+Device](https://liveobjects.orange-business.com/doc/html/lo_manual.html#MQTT_MODE_DEVICE)
jhamel 0:a46886781dee 12 1. Publishs
jhamel 0:a46886781dee 13 * the [current Status/Info](https://liveobjects.orange-business.com/doc/html/lo_manual.html#MQTT_DEV_INFO).
jhamel 0:a46886781dee 14 * the [current Configuration Parameters](https://liveobjects.orange-business.com/doc/html/lo_manual.html#MQTT_DEV_CFG)
jhamel 0:a46886781dee 15 1. Subscribes to LiveObjects topics to receive notifications:
jhamel 0:a46886781dee 16 * Configuration Parameters update request
jhamel 0:a46886781dee 17 * Command request
jhamel 0:a46886781dee 18 1. then it waits for an event
jhamel 0:a46886781dee 19 * either from LiveObjects platform to :
jhamel 0:a46886781dee 20 * Update "Configuration Parameters"
jhamel 0:a46886781dee 21 * Process a command
jhamel 0:a46886781dee 22 * or from sensor and buttons :
jhamel 0:a46886781dee 23 * Publish "Collected Data"
jhamel 0:a46886781dee 24
jhamel 0:a46886781dee 25 * if the connection is lost, restart at step 2
jhamel 0:a46886781dee 26
jhamel 0:a46886781dee 27
jhamel 0:a46886781dee 28 See [Datavenue Live Objects - complete guide](http://liveobjects.orange-business.com/doc/html/lo_manual.html)
jhamel 0:a46886781dee 29
jhamel 0:a46886781dee 30
jhamel 0:a46886781dee 31 ## Required hardware
jhamel 0:a46886781dee 32
jhamel 0:a46886781dee 33 * [FRDM-K64F](http://developer.mbed.org/platforms/frdm-k64f/) board.
jhamel 0:a46886781dee 34 * 1 micro-USB cable.
jhamel 0:a46886781dee 35 * Ethernet cable and connection to the internet.
jhamel 0:a46886781dee 36
jhamel 0:a46886781dee 37
jhamel 0:a46886781dee 38 ## Required software
jhamel 0:a46886781dee 39
jhamel 0:a46886781dee 40 * [mbed-cli](https://github.com/ARMmbed/mbed-cli) - to build the example programs.
jhamel 0:a46886781dee 41 To learn how to build mbed OS applications with mbed-cli,
jhamel 0:a46886781dee 42 see [the user guide](https://github.com/ARMmbed/mbed-cli/blob/master/README.md).
jhamel 0:a46886781dee 43 * [GCC ARM Embedded Toolchain](https://launchpad.net/gcc-arm-embedded/): Use [5-2015-q4-major](https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major)
jhamel 0:a46886781dee 44 * [Python 2.7](https://www.python.org/downloads/): use [Python 2.7.12 2016-06-25](https://www.python.org/downloads/release/python-2712/)
jhamel 0:a46886781dee 45 * [Serial port monitor](https://developer.mbed.org/handbook/SerialPC#host-interface-and-terminal-applications).
jhamel 0:a46886781dee 46 * [LiveObjects account](http://liveobjects.orange-business.com)
jhamel 0:a46886781dee 47
jhamel 0:a46886781dee 48
jhamel 0:a46886781dee 49 ## Brief install (Windows)
jhamel 0:a46886781dee 50 ```
jhamel 0:a46886781dee 51
jhamel 0:a46886781dee 52 # Install Python 2.7.12 (for example in C:\Python27)
jhamel 0:a46886781dee 53 # Update your environment variable PATH to add "C:\Python27;C:\Python27\Scripts"
jhamel 0:a46886781dee 54
jhamel 0:a46886781dee 55
jhamel 0:a46886781dee 56 # Install GCC ARM embeded tool chain
jhamel 0:a46886781dee 57
jhamel 0:a46886781dee 58
jhamel 0:a46886781dee 59 # Install mbed-cli
jhamel 0:a46886781dee 60 git clone https://github.com/ARMmbed/mbed-cli
jhamel 0:a46886781dee 61 cd mbed-cli
jhamel 0:a46886781dee 62 python setup.py install
jhamel 0:a46886781dee 63
jhamel 0:a46886781dee 64 mbed config --global GCC_ARM_PATH "C:\Program Files (x86)\GNU Tools ARM Embedded\5.2 2015q4\bin"
jhamel 0:a46886781dee 65
jhamel 0:a46886781dee 66 ```
jhamel 0:a46886781dee 67
jhamel 0:a46886781dee 68 ## Application setup
jhamel 0:a46886781dee 69
jhamel 0:a46886781dee 70 To configure the sample application, please:
jhamel 0:a46886781dee 71
jhamel 0:a46886781dee 72 1. [Setup Ethernet](#ethernet-settings).
jhamel 0:a46886781dee 73 1. [Get the LiveObjects API key](#liveobjects-api-key).
jhamel 0:a46886781dee 74 1. [Create and update the user defintions](#liveobjects-header-file).
jhamel 0:a46886781dee 75
jhamel 0:a46886781dee 76 ### Ethernet settings
jhamel 0:a46886781dee 77
jhamel 0:a46886781dee 78 The sample application only uses an Ethernet connection (with DHCP server).
jhamel 0:a46886781dee 79
jhamel 0:a46886781dee 80 So you need:
jhamel 0:a46886781dee 81
jhamel 0:a46886781dee 82 - An Ethernet cable.
jhamel 0:a46886781dee 83 - An Ethernet connection to the internet.
jhamel 0:a46886781dee 84
jhamel 0:a46886781dee 85
jhamel 0:a46886781dee 86 ### LiveObjects API Key
jhamel 0:a46886781dee 87
jhamel 0:a46886781dee 88
jhamel 0:a46886781dee 89 Visit [IoT Soft Box powered by Datavenue](https://liveobjects.orange-business.com/v2/#/sdk)
jhamel 0:a46886781dee 90
jhamel 0:a46886781dee 91 1. You need to request the creation of a developper account.
jhamel 0:a46886781dee 92 1. Then, with your LiveObjects user identifier, login to the [Live Objects portal](https://liveobjects.orange-business.com/#/login).
jhamel 0:a46886781dee 93 1. Go in 'Configuration - API key' tab, and add a new API key.
jhamel 0:a46886781dee 94 **Don't forget to copy this API key value** in a local and secure place during this operation.
jhamel 0:a46886781dee 95
jhamel 0:a46886781dee 96
jhamel 0:a46886781dee 97 ### LiveObjects header file
jhamel 0:a46886781dee 98
jhamel 0:a46886781dee 99 Copy the template header file **liveobjects_dev_params.h.txt** in the new header file **liveobjects_dev_params.h** if it does not exist.
jhamel 0:a46886781dee 100
jhamel 0:a46886781dee 101 Edit this header file to update some values, in particular the **LiveObjects API key**.
jhamel 0:a46886781dee 102
jhamel 0:a46886781dee 103
jhamel 0:a46886781dee 104 ## Terminal Emulator
jhamel 0:a46886781dee 105
jhamel 0:a46886781dee 106 Visit [Serial port monitor](https://developer.mbed.org/handbook/SerialPC#host-interface-and-terminal-applications).
jhamel 0:a46886781dee 107
jhamel 0:a46886781dee 108 Serial Port settings:
jhamel 0:a46886781dee 109
jhamel 0:a46886781dee 110 * Rate: 9600 baud
jhamel 0:a46886781dee 111 * Data: 8 bits
jhamel 0:a46886781dee 112 * Parity : None
jhamel 0:a46886781dee 113 * Stop : 1 stop bit
jhamel 0:a46886781dee 114 * Flow Ctrl: None
jhamel 0:a46886781dee 115
jhamel 0:a46886781dee 116
jhamel 0:a46886781dee 117
jhamel 0:a46886781dee 118 ## Building this example
jhamel 0:a46886781dee 119
jhamel 0:a46886781dee 120
jhamel 0:a46886781dee 121 To build the example application:
jhamel 0:a46886781dee 122
jhamel 0:a46886781dee 123 1. Clone this repository. Note that you need to have rights to access to this repository.
jhamel 0:a46886781dee 124 1. Open a command line tool and navigate to the project’s directory.
jhamel 0:a46886781dee 125 1. Execute the `mbed config root .` command
jhamel 0:a46886781dee 126 1. Update all sources using the `mbed update` command. This command installs packages: mbed-os, MQTTPacket, iotsoftbox-mqtt, and jsmn)
jhamel 0:a46886781dee 127 1. [Configure](#application-setup) the client application.
jhamel 0:a46886781dee 128 1. Build the application by selecting the hardware board and build the toolchain using the command `mbed compile -m K64F -t GCC_ARM`. mbed-cli builds a binary file under the project’s `.build` directory.
jhamel 0:a46886781dee 129 1. Plug the Ethernet cable into the board if you are using Ethernet mode.
jhamel 0:a46886781dee 130 1. Plug the micro-USB cable into the **OpenSDA** port. The board is listed as a mass-storage device.
jhamel 0:a46886781dee 131 1. Drag and drop the binary file (in `.build/K64F/GCC_ARM/`) to the board to flash the application.
jhamel 0:a46886781dee 132 1. The board is automatically programmed with the new binary. A flashing LED on it indicates that it is still working. When the LED stops blinking, the board is ready to work.
jhamel 0:a46886781dee 133 1. Start the terminal emulator on serial port : mbed Serial Port (COM..). See [Terminal emulator](#terminal-emulator).
jhamel 0:a46886781dee 134 1. Press the **RESET** button on the board to run the program.
jhamel 0:a46886781dee 135 1. And continue to the [application control](#application-control) chapter.
jhamel 0:a46886781dee 136
jhamel 0:a46886781dee 137
jhamel 0:a46886781dee 138
jhamel 0:a46886781dee 139 ## Application Monitoring
jhamel 0:a46886781dee 140
jhamel 0:a46886781dee 141 ### Serial Terminal
jhamel 0:a46886781dee 142
jhamel 0:a46886781dee 143 The serial port is used by embedded sample application:
jhamel 0:a46886781dee 144
jhamel 0:a46886781dee 145 * output: to print debug/trace messages.
jhamel 0:a46886781dee 146 * input: to do some very simple operations by typing only one character.
jhamel 0:a46886781dee 147 Type 'h' to display the help menu.
jhamel 0:a46886781dee 148
jhamel 0:a46886781dee 149
jhamel 0:a46886781dee 150 ### Live Objects Portal
jhamel 0:a46886781dee 151
jhamel 0:a46886781dee 152 Using your Live Objects user account, go to [Live Objects Portal](https://liveobjects.orange-business.com/#/login).
jhamel 0:a46886781dee 153
jhamel 0:a46886781dee 154
jhamel 0:a46886781dee 155 ### Demo Application
jhamel 0:a46886781dee 156
jhamel 0:a46886781dee 157
jhamel 0:a46886781dee 158