AT&T M2X example featuring FRDM-K64F and Seed Grove Wifi to stream the Accelerometer X, Y, Z-axis values
Dependencies: ESP8266Interface FXOS8700Q M2XStreamClient jsonlite mbed
Fork of frdm-k64F_Wifi_M2X_Acc by
Diff: main.cpp
- Revision:
- 3:694a1a67b156
- Parent:
- 2:68b759c89fd9
- Child:
- 4:3c1d712dcc48
--- 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