Example program for simple-mbed-client, connecting a device to mbed Device Connector.
Dependencies: simple-mbed-client
Fork of simple-mbed-client-example by
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.
Revision 12:31e60c8bb7f6, committed 2016-03-07
- Comitter:
- geky
- Date:
- Mon Mar 07 22:11:37 2016 +0000
- Parent:
- 11:341c9f62028b
- Child:
- 13:d4da5e6aa952
- Commit message:
- Added LWIPInterface
Changed in this revision
--- a/ESP8266Interface.lib Thu Mar 03 19:26:28 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#42441dd2093e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LWIPInterface.lib Mon Mar 07 22:11:37 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/NetworkSocketAPI/code/LWIPInterface/#ebba105e893b
--- a/main.cpp Thu Mar 03 19:26:28 2016 +0000
+++ b/main.cpp Mon Mar 07 22:11:37 2016 +0000
@@ -26,7 +26,7 @@
#include "mbed.h"
#include "rtos.h"
-#include "ESP8266Interface.h"
+#include "LWIPInterface.h"
#include "mbed-client-classic/m2mnetwork.h"
@@ -299,8 +299,8 @@
// Instantiate the class which implements
// LWM2M Client API
MbedClient mbed_client;
-ESP8266Interface esp(D1, D0);
-M2MNetwork network(&esp);
+LWIPInterface lwip;
+M2MNetwork network(&lwip);
// Set up Hardware interrupt button.
InterruptIn obs_button(SW2);
@@ -338,10 +338,10 @@
// This sets up the network interface configuration which will be used
// by LWM2M Client API to communicate with mbed Device server.
- esp.connect("Sniffer", "Sandcastle");
+ lwip.connect();
//lwipv4_socket_init();
- output.printf("IP address %s\r\n", esp.getIPAddress());
+ output.printf("IP address %s\r\n", lwip.getIPAddress());
// On press of SW3 button on K64F board, example application
// will call unregister API towards mbed Device Server
--- a/mbed-client-classic.lib Thu Mar 03 19:26:28 2016 +0000 +++ b/mbed-client-classic.lib Mon Mar 07 22:11:37 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/sandbox/code/mbed-client-classic/#babbe7026a0c +http://developer.mbed.org/teams/sandbox/code/mbed-client-classic/#774e507fc261
--- a/mbed-rtos.lib Thu Mar 03 19:26:28 2016 +0000 +++ b/mbed-rtos.lib Mon Mar 07 22:11:37 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#07314541bd12 +http://mbed.org/users/mbed_official/code/mbed-rtos/#dfc27975e193
--- a/security.h Thu Mar 03 19:26:28 2016 +0000 +++ b/security.h Mon Mar 07 22:11:37 2016 +0000 @@ -1,111 +1,1 @@ - - -/* - - * Copyright (c) 2015 ARM Limited. All rights reserved. - - * SPDX-License-Identifier: Apache-2.0 - - * Licensed under the Apache License, Version 2.0 (the License); you may - - * not use this file except in compliance with the License. - - * You may obtain a copy of the License at - - * - - * http://www.apache.org/licenses/LICENSE-2.0 - - * - - * Unless required by applicable law or agreed to in writing, software - - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - * See the License for the specific language governing permissions and - - * limitations under the License. - - */ - -#ifndef __SECURITY_H__ - -#define __SECURITY_H__ - - - -#include <inttypes.h> - - - -#define MBED_DOMAIN "d2f49a23-a3a6-4335-bcf4-01db9f945d3d" - -#define MBED_ENDPOINT_NAME "4887c197-73de-4314-aec1-43da301d6dca" - - - -const uint8_t SERVER_CERT[] = "-----BEGIN CERTIFICATE-----\r\n" - -"MIIBmDCCAT6gAwIBAgIEVUCA0jAKBggqhkjOPQQDAjBLMQswCQYDVQQGEwJGSTEN\r\n" - -"MAsGA1UEBwwET3VsdTEMMAoGA1UECgwDQVJNMQwwCgYDVQQLDANJb1QxETAPBgNV\r\n" - -"BAMMCEFSTSBtYmVkMB4XDTE1MDQyOTA2NTc0OFoXDTE4MDQyOTA2NTc0OFowSzEL\r\n" - -"MAkGA1UEBhMCRkkxDTALBgNVBAcMBE91bHUxDDAKBgNVBAoMA0FSTTEMMAoGA1UE\r\n" - -"CwwDSW9UMREwDwYDVQQDDAhBUk0gbWJlZDBZMBMGByqGSM49AgEGCCqGSM49AwEH\r\n" - -"A0IABLuAyLSk0mA3awgFR5mw2RHth47tRUO44q/RdzFZnLsAsd18Esxd5LCpcT9w\r\n" - -"0tvNfBv4xJxGw0wcYrPDDb8/rjujEDAOMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0E\r\n" - -"AwIDSAAwRQIhAPAonEAkwixlJiyYRQQWpXtkMZax+VlEiS201BG0PpAzAiBh2RsD\r\n" - -"NxLKWwf4O7D6JasGBYf9+ZLwl0iaRjTjytO+Kw==\r\n" - -"-----END CERTIFICATE-----\r\n"; - - - -const uint8_t CERT[] = "-----BEGIN CERTIFICATE-----\r\n" - -"MIIBzzCCAXOgAwIBAgIEQ1vjEzAMBggqhkjOPQQDAgUAMDkxCzAJBgNVBAYTAkZ\r\n" - -"JMQwwCgYDVQQKDANBUk0xHDAaBgNVBAMME21iZWQtY29ubmVjdG9yLTIwMTYwHh\r\n" - -"cNMTYwMjE4MTU1MzE2WhcNMTYxMjMxMDYwMDAwWjCBoTFSMFAGA1UEAxNJZDJmN\r\n" - -"DlhMjMtYTNhNi00MzM1LWJjZjQtMDFkYjlmOTQ1ZDNkLzQ4ODdjMTk3LTczZGUt\r\n" - -"NDMxNC1hZWMxLTQzZGEzMDFkNmRjYTEMMAoGA1UECxMDQVJNMRIwEAYDVQQKEwl\r\n" - -"tYmVkIHVzZXIxDTALBgNVBAcTBE91bHUxDTALBgNVBAgTBE91bHUxCzAJBgNVBA\r\n" - -"YTAkZJMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEFQ9YDafewRZTCS8SjsHg\r\n" - -"mE1/Kn0+2V49SiQ7cePEgsoRxEFe9ZxaStozgQC/FyPU6oFCfPmZn5FzEcTUQFl\r\n" - -"2jAMBggqhkjOPQQDAgUAA0gAMEUCIQC4yg0mkwD12KD0Gmr/X3IgpbGkGiDSp2C\r\n" - -"Z1VegqjbW5wIgA9p4jN/KZHNF40XtOj6rXHFG9bfNrGY62/ceg3KYwl8=\r\n" - -"-----END CERTIFICATE-----\r\n"; - - - -const uint8_t KEY[] = "-----BEGIN PRIVATE KEY-----\r\n" - -"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgrSBl+5yOid5hB64l\r\n" - -"Ak3+H0mjeXzx63R36P20SFHQpBqhRANCAAQQVD1gNp97BFlMJLxKOweCYTX8qfT7\r\n" - -"ZXj1KJDtx48SCyhHEQV71nFpK2jOBAL8XI9TqgUJ8+ZmfkXMRxNRAWXa\r\n" - -"-----END PRIVATE KEY-----\r\n"; - - - -#endif //__SECURITY_H__ +#error "You need to get credentials from connector.mbed.com and paste them in this security.h file" \ No newline at end of file
