Simple Mbed Cloud client application using features of K64F including Wi-Fi and SD Card

Fork of mbed-cloud-connect-example-ethernet by NXP

Configuration

  • Put ESP-WROOM-02 shield
  • Put Mbed Application Shield
  • Edit the text in the main.cpp

#define WIFI_SSID "SSID"
#define WIFI_PSWD "PASSWORD"
  • Download and replace your developer certificate from Mbed Cloud portal from the menu [Mbed Cloud] - [Certificate]

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Tue Jul 03 02:54:58 2018 +0000
Parent:
17:0a894bf1f5f2
Child:
19:999d13f83602
Commit message:
Initial commit

Changed in this revision

esp8266-driver.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_cloud_dev_credentials.c Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/esp8266-driver.lib	Tue Jul 03 02:54:58 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/esp8266-driver/#77c5ef4bab81a5151ad949447e7452edd98a90b7
--- a/main.cpp	Fri May 18 21:28:25 2018 +0000
+++ b/main.cpp	Tue Jul 03 02:54:58 2018 +0000
@@ -20,7 +20,10 @@
 #include "simple-mbed-cloud-client.h"
 #include "SDBlockDevice.h"
 #include "FATFileSystem.h"
-#include "EthernetInterface.h"
+#include "ESP8266Interface.h"
+
+#define WIFI_SSID "SSID"
+#define WIFI_PSWD "PASSWORD"
 
 // An event queue is a very useful structure to debounce information between contexts (e.g. ISR and normal threads)
 // This is great because things such as network operations are illegal in ISR, so updating a resource in a button's fall() function is not allowed
@@ -34,6 +37,8 @@
 /* K64 & K66 */
 SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
 FATFileSystem fs("sd", &sd);
+ESP8266Interface net(D1, D0);
+
 
 // Declaring pointers for access to Mbed Cloud Client resources outside of main()
 MbedCloudClientResource *button_res;
@@ -106,11 +111,10 @@
 
 int main(void) {
     printf("Starting Simple Mbed Cloud Client example\n");
-    printf("Connecting to the network using Ethernet...\n");
+    printf("Connecting to the network using Wi-Fi...\n");
 
     // Connect to the internet (DHCP is expected to be on)
-    EthernetInterface net;
-    nsapi_error_t status = net.connect();
+    nsapi_error_t status = net.connect(WIFI_SSID, WIFI_PSWD, NSAPI_SECURITY_WPA_WPA2);
 
     if (status != 0) {
         printf("Connecting to the network failed %d!\n", status);
--- a/mbed_cloud_dev_credentials.c	Fri May 18 21:28:25 2018 +0000
+++ b/mbed_cloud_dev_credentials.c	Tue Jul 03 02:54:58 2018 +0000
@@ -15,39 +15,39 @@
  */
 #ifndef __MBED_CLOUD_DEV_CREDENTIALS_H__
 #define __MBED_CLOUD_DEV_CREDENTIALS_H__
-
+ 
 #if MBED_CONF_APP_DEVELOPER_MODE == 1
 #error "Replace mbed_cloud_dev_credentials.c with your own developer cert."
 #endif
-
+ 
 #include <inttypes.h>
-
+ 
 const char MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME[] = "";
 const char MBED_CLOUD_DEV_ACCOUNT_ID[] = "";
 const char MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI[] = "";
-
+ 
 const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE[] =
 { 0x0 };
-
+ 
 const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE[] =
 { 0x0 };
-
+ 
 const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY[] =
 { 0x0 };
-
+ 
 const char MBED_CLOUD_DEV_MANUFACTURER[] = "dev_manufacturer";
-
+ 
 const char MBED_CLOUD_DEV_MODEL_NUMBER[] = "dev_model_num";
-
+ 
 const char MBED_CLOUD_DEV_SERIAL_NUMBER[] = "0";
-
+ 
 const char MBED_CLOUD_DEV_DEVICE_TYPE[] = "dev_device_type";
-
+ 
 const char MBED_CLOUD_DEV_HARDWARE_VERSION[] = "dev_hardware_version";
-
+ 
 const uint32_t MBED_CLOUD_DEV_MEMORY_TOTAL_KB = 0;
 const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE);
 const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE);
 const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY);
-
+ 
 #endif //__MBED_CLOUD_DEV_CREDENTIALS_H__