Example program for simple-mbed-client, connecting a device to mbed Device Connector.

Dependencies:   simple-mbed-client

Fork of simple-mbed-client-example by Jan Jongboom

This is an example on how to connect to mbed Device Connector using simple-mbed-client. It can connect over Ethernet, WiFi (using an ESP8266 module or an ODIN board), Thread and 6LoWPAN.

After cloning this repository update `mbed_app.json` to reflect your connectivity method. For docs on configuring connectivity, see easy-connect.

End to end example

For an end-to-end example of using Simple mbed Client to connect devices to mbed Device Connector see Building an internet connected lighting system.

Entropy (or lack thereof)

On all platforms except the K64F and K22F the library is compiled without TLS entropy sources. This means that your code is inherently unsafe and should not be deployed to any production systems. To enable entropy, remove the MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY macros from mbed_app.json.

Files at this revision

API Documentation at this revision

Comitter:
geky
Date:
Thu Mar 03 19:26:28 2016 +0000
Parent:
10:1280c4c21987
Child:
12:31e60c8bb7f6
Commit message:
Adopted the NetworkSocketAPI

Changed in this revision

ESP8266Interface.lib Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.lib Show diff for this revision Revisions of this file
NetworkSocketAPI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-client-classic.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ESP8266Interface.lib	Thu Mar 03 19:26:28 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#42441dd2093e
--- a/EthernetInterface.lib	Fri Feb 19 17:50:40 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#4d7bff17a592
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetworkSocketAPI.lib	Thu Mar 03 19:26:28 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#543799d6472e
--- a/main.cpp	Fri Feb 19 17:50:40 2016 +0000
+++ b/main.cpp	Thu Mar 03 19:26:28 2016 +0000
@@ -24,6 +24,10 @@
 #include "ns_trace.h"
 
 #include "mbed.h"
+#include "rtos.h"
+
+#include "ESP8266Interface.h"
+#include "mbed-client-classic/m2mnetwork.h"
 
 
 Serial output(USBTX, USBRX);
@@ -292,14 +296,15 @@
     int                 _value;
 };
 
-EthernetInterface eth;
 // Instantiate the class which implements
 // LWM2M Client API
 MbedClient mbed_client;
+ESP8266Interface esp(D1, D0);
+M2MNetwork network(&esp);
 
 // Set up Hardware interrupt button.
-InterruptIn obs_button(OBS_BUTTON);
-InterruptIn unreg_button(UNREG_BUTTON);
+InterruptIn obs_button(SW2);
+InterruptIn unreg_button(SW3);
 
 // Network interaction must be performed outside of interrupt context
 Semaphore updates(0);
@@ -317,7 +322,7 @@
 
 // Status indication
 Ticker status_ticker;
-DigitalOut status_led(LED_GREEN);
+DigitalOut status_led(LED1);
 void blinky() { status_led = !status_led; }
 
 
@@ -333,11 +338,10 @@
 
     // This sets up the network interface configuration which will be used
     // by LWM2M Client API to communicate with mbed Device server.
-    eth.init(); //Use DHCP
-    eth.connect();
+    esp.connect("Sniffer", "Sandcastle");
 
     //lwipv4_socket_init();
-    output.printf("IP address %s\r\n", eth.getIPAddress());
+    output.printf("IP address %s\r\n", esp.getIPAddress());
 
     // On press of SW3 button on K64F board, example application
     // will call unregister API towards mbed Device Server
--- a/mbed-client-classic.lib	Fri Feb 19 17:50:40 2016 +0000
+++ b/mbed-client-classic.lib	Thu Mar 03 19:26:28 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/sandbox/code/mbed-client-classic/#907e7fcb1d48
+http://developer.mbed.org/teams/sandbox/code/mbed-client-classic/#babbe7026a0c