Example of using the ATT M2X back end. Connect over Ethernet with the WIZnet 5500 chip. This code sends random data to M2X.

Dependencies:   M2XStreamClient WIZnet_Library jsonlite mbed

Fork of M2X_Nucleo411_ESP8266-wifi by AT&T Developer Summit Hackathon 2016

Files at this revision

API Documentation at this revision

Comitter:
mbedAustin
Date:
Fri Dec 11 00:19:45 2015 +0000
Parent:
2:68b759c89fd9
Child:
4:3c1d712dcc48
Commit message:
swapped out ethernet library with ESP8266 wifi library, pre-populated wifi with pin deffinitions for Nucleo 411 board

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
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ESP8266Interface.lib	Fri Dec 11 00:19:45 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ESP8266/code/ESP8266Interface/#03fd9333670d
--- a/EthernetInterface.lib	Sat Aug 29 17:14:53 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#f69b81aa9eb1
--- a/main.cpp	Sat Aug 29 17:14:53 2015 +0000
+++ b/main.cpp	Fri Dec 11 00:19:45 2015 +0000
@@ -1,7 +1,8 @@
 #include "mbed.h"
 #include "FXOS8700Q.h"
 #include "M2XStreamClient.h"
-#include "EthernetInterface.h"
+#include "ESP8266Interface.h"
+#include "TCPSocketConnection.h"
 
 
 #ifndef MAX
@@ -16,21 +17,23 @@
 char streamName[] = "<stream name>"; // Stream you want to push to
 char m2xKey[] = "<m2x api key>"; // Your M2X API Key or Master API Key
 
+/*
+*  ESP8266 Wifi Config
+*/
+ESP8266Interface wifi(D8,D2,D3,"wifi-name","wifi-password",115200); // TX,RX,Reset,SSID,Password,Baud 
+
 int main()
 {
-    // Setup Ethernet
-    printf("Start\r\n");
-    EthernetInterface eth;
-    printf("Init...\r\n");
-    eth.init(); //Use DHCP
-    //eth.init(ip,mask,gateway); //Use Static IP Configuration
-    printf("Connect\r\n");
-    eth.connect();
-    printf("Device IP Address is %s\r\n", eth.getIPAddress());
+    printf("Starting...\r\n");
+
+    // connect to wifi
+    wifi.init(); //Reset
+    wifi.connect(); //Use DHCP
+    printf("IP Address is %s \n\r", wifi.getIPAddress());
 
     // Initialize the M2X client
     Client client;
-    M2XStreamClient m2xClient(&client, m2xKey);
+    M2XStreamClient m2xClient(&client, m2xKey,1,"52.22.150.98");
     int ret;
 
     // Create an accelerometer instance
@@ -57,10 +60,10 @@
 
         // If the maximum title is over 20 degrees, then send
         // data to stream
-        if (maxTilt > 20) {
+        
             ret = m2xClient.updateStreamValue(deviceId, streamName, maxTilt);
             printf("send() returned %d\r\n", ret);
             wait(1.0);
-        }
+        
     }
 }
\ No newline at end of file
--- a/mbed-rtos.lib	Sat Aug 29 17:14:53 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#34e80e862021