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 23:16f397924e3d, committed 2016-08-23
- Comitter:
- Jan Jongboom
- Date:
- Tue Aug 23 16:02:01 2016 +0200
- Parent:
- 22:acadaa153699
- Child:
- 24:0a61ee19cf5b
- Commit message:
- Update to latest mbed-os and easy-connect
Changed in this revision
--- a/easy-connect.lib Mon Aug 15 12:06:37 2016 +0200 +++ b/easy-connect.lib Tue Aug 23 16:02:01 2016 +0200 @@ -1,1 +1,1 @@ -https://github.com/armmbed/easy-connect/#0dc426db510ec4f4c73bc14a75a9de181dae6868 +https://github.com/armmbed/easy-connect/#c2b63f8793187dfd8e4264149540e21fccb12b9a
--- a/main.cpp Mon Aug 15 12:06:37 2016 +0200
+++ b/main.cpp Tue Aug 23 16:02:01 2016 +0200
@@ -6,9 +6,9 @@
Serial pc(USBTX, USBRX);
SimpleMbedClient client;
-DigitalOut led(LED_RED);
-DigitalOut blinkLed(LED_GREEN);
-InterruptIn btn(SW3);
+DigitalOut led(LED1);
+DigitalOut blinkLed(LED2);
+InterruptIn btn(PTA1);
Semaphore updates(0);
void patternUpdated(string v) {
@@ -52,12 +52,14 @@
client.define_function("led/0/play", &play);
- NetworkInterface* network = easy_connect();
+ NetworkInterface* network = easy_connect(true);
if (!network) {
return 1;
}
- bool setup = client.setup(network);
+ struct MbedClientOptions opts = client.get_default_options();
+ opts.ServerAddress = MBED_SERVER_ADDRESS;
+ bool setup = client.setup(opts, network);
if (!setup) {
printf("Client setup failed\n");
return 1;
--- a/mbed-os.lib Mon Aug 15 12:06:37 2016 +0200 +++ b/mbed-os.lib Tue Aug 23 16:02:01 2016 +0200 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#685096eb11af42db747273415aa1d5e2ad94f2ab +https://github.com/ARMmbed/mbed-os/#862db41be3159b31fea590c2a4e58acd1c675a9f
--- a/mbed_app.json Mon Aug 15 12:06:37 2016 +0200
+++ b/mbed_app.json Tue Aug 23 16:02:01 2016 +0200
@@ -1,16 +1,30 @@
{
"config": {
"network-interface":{
- "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
+ "help": "options are ETHERNET,WIFI_ESP8266,MESH_LOWPAN_ND,MESH_THREAD",
"value": "ETHERNET"
},
- "wifi-ssid": {
- "help": "WiFi SSID",
+ "esp8266-tx": {
+ "help": "Pin used as TX (connects to ESP8266 RX)",
+ "value": "PTD3"
+ },
+ "esp8266-rx": {
+ "help": "Pin used as RX (connects to ESP8266 TX)",
+ "value": "PTD2"
+ },
+ "esp8266-ssid": {
"value": "\"SSID\""
},
- "wifi-password": {
- "help": "WiFi Password",
+ "esp8266-password": {
"value": "\"Password\""
+ },
+ "esp8266-debug": {
+ "value": true
+ }
+ },
+ "target_overrides": {
+ "*": {
+ "target.features_add": ["IPV4", "IPV6"]
}
}
}
