Jim Carver
/
mbed-cloud-workshop-connect
Fork for workshops
simple-mbed-cloud-client/README.md@0:6b753f761943, 2018-10-12 (annotated)
- Committer:
- JimCarver
- Date:
- Fri Oct 12 21:22:49 2018 +0000
- Revision:
- 0:6b753f761943
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 0:6b753f761943 | 1 | ## Simple Mbed Cloud Client |
JimCarver | 0:6b753f761943 | 2 | |
JimCarver | 0:6b753f761943 | 3 | A simple way of connecting Mbed OS 5 devices to Mbed Cloud. It's designed to: |
JimCarver | 0:6b753f761943 | 4 | |
JimCarver | 0:6b753f761943 | 5 | * Enable Mbed Cloud Connect and mbed Cloud Update to applications in few lines of code. |
JimCarver | 0:6b753f761943 | 6 | * Run separate from your main application, it does not take over your main loop. |
JimCarver | 0:6b753f761943 | 7 | * Provide LWM2M resources, essentially variables that are automatically synced through Mbed Cloud Connect. |
JimCarver | 0:6b753f761943 | 8 | * Help users avoid doing blocking network operations in interrupt contexts, by automatically defering actions to a separate thread. |
JimCarver | 0:6b753f761943 | 9 | |
JimCarver | 0:6b753f761943 | 10 | This library is a simpler interface to Mbed Cloud Client, making it trivial to expose sensors, actuators and other variables to the cloud. For a full Mbed Cloud CLient API, check our [documentation](https://cloud.mbed.com/docs/current/mbed-cloud-client/index.html). |
JimCarver | 0:6b753f761943 | 11 | |
JimCarver | 0:6b753f761943 | 12 | ### Usage to Connect to Mbed Cloud |
JimCarver | 0:6b753f761943 | 13 | |
JimCarver | 0:6b753f761943 | 14 | 1. Add this library to your Mbed OS project: |
JimCarver | 0:6b753f761943 | 15 | |
JimCarver | 0:6b753f761943 | 16 | ``` |
JimCarver | 0:6b753f761943 | 17 | $ mbed add https://github.com/ARMmbed/simple-mbed-cloud-client |
JimCarver | 0:6b753f761943 | 18 | ``` |
JimCarver | 0:6b753f761943 | 19 | |
JimCarver | 0:6b753f761943 | 20 | 1. Add your Mbed Cloud developer certificate to your project (`mbed_cloud_dev_credentials.c` file). |
JimCarver | 0:6b753f761943 | 21 | |
JimCarver | 0:6b753f761943 | 22 | 1. Reference the library from your main.cpp file, add network and storage drivers; finally initialize the Simple Mbed Cloud Client library. |
JimCarver | 0:6b753f761943 | 23 | |
JimCarver | 0:6b753f761943 | 24 | ```cpp |
JimCarver | 0:6b753f761943 | 25 | #include "simple-mbed-cloud-client.h" |
JimCarver | 0:6b753f761943 | 26 | #include <Block device> |
JimCarver | 0:6b753f761943 | 27 | #include <Filesystem> |
JimCarver | 0:6b753f761943 | 28 | #include <Network> |
JimCarver | 0:6b753f761943 | 29 | |
JimCarver | 0:6b753f761943 | 30 | int main() { |
JimCarver | 0:6b753f761943 | 31 | |
JimCarver | 0:6b753f761943 | 32 | /* Initialize connectivity */ |
JimCarver | 0:6b753f761943 | 33 | <Network> net; |
JimCarver | 0:6b753f761943 | 34 | net.connect(); |
JimCarver | 0:6b753f761943 | 35 | |
JimCarver | 0:6b753f761943 | 36 | /* Initialize storage */ |
JimCarver | 0:6b753f761943 | 37 | <Block device> sd(...); |
JimCarver | 0:6b753f761943 | 38 | <Filesystem> fs("sd", &sd); |
JimCarver | 0:6b753f761943 | 39 | |
JimCarver | 0:6b753f761943 | 40 | /* Initialize Simple Mbed Cloud Client */ |
JimCarver | 0:6b753f761943 | 41 | SimpleMbedCloudClient client(&net, &sd, &fs); |
JimCarver | 0:6b753f761943 | 42 | client.init(); |
JimCarver | 0:6b753f761943 | 43 | |
JimCarver | 0:6b753f761943 | 44 | /* Create resource */ |
JimCarver | 0:6b753f761943 | 45 | MbedCloudClientResource *variable; |
JimCarver | 0:6b753f761943 | 46 | variable = client.create_resource("3201/0/5853", "variable"); |
JimCarver | 0:6b753f761943 | 47 | variable->set_value("assign new value"); |
JimCarver | 0:6b753f761943 | 48 | variable->methods(M2MMethod::GET | M2MMethod::PUT); |
JimCarver | 0:6b753f761943 | 49 | |
JimCarver | 0:6b753f761943 | 50 | } |
JimCarver | 0:6b753f761943 | 51 | ``` |
JimCarver | 0:6b753f761943 | 52 | |
JimCarver | 0:6b753f761943 | 53 | ### Example applications |
JimCarver | 0:6b753f761943 | 54 | |
JimCarver | 0:6b753f761943 | 55 | There are a number of applications that make usage of the Simple Mbed Cloud Client library. |
JimCarver | 0:6b753f761943 | 56 | |
JimCarver | 0:6b753f761943 | 57 | The Mbed Cloud [Quick-Start](https://cloud.mbed.com/quick-start) is an initiative to support Mbed Partner's platforms while delivering a great User Experience to Mbed Developers. |
JimCarver | 0:6b753f761943 | 58 | |
JimCarver | 0:6b753f761943 | 59 | ### Known issues |
JimCarver | 0:6b753f761943 | 60 | |
JimCarver | 0:6b753f761943 | 61 | None |