FRDM-K64F
Watching serial port output and getting error response from GET
Server logs on heroku show no requests so I'm stuggling to debug..
Thanks for your input on where I'm going wrong
- include "mbed.h"
- include "EthernetInterface.h"
- include "HTTPClient.h"
- include "LM75B.h"
- define HEROKU_API "http://myurl.herokuapp.com"
- define TIMEOUT 500
- define BUFFSIZE 1024
- define ALLOWANCE 30
HTTPClient http;
LM75B tmp(D14,D15);
int main() {
int ret ;
EthernetInterface eth;
static char buff[BUFFSIZE];
char uri[sizeof(HEROKU_API)+10+ALLOWANCE] ;
printf("URI = %s\n", uri);
char header[512];
sprintf(header, "Content-Type: application/x-www-form-urlencoded\r\n") ;
http.setHeader(header) ;
printf("Mbed Device Starting,...\n") ;
ret = eth.init(); Use DHCP
while(1) {
ret = eth.connect();
if(ret == 0)break ;
}
printf("IP = %s\n", eth.getIPAddress());
while (true) {
double val = tmp.read();
printf("Current temperature is: %lf\n", val);
STREAM PROCESSING FOR DATA
char strVal[1024];
sprintf(strVal, "%s/stream/create?name=temperature&unit=farenheit&value=%f",HEROKU_API, val);
printf("GET REQUEST URL: %s\n", strVal);
ret = http.get(uri, buff, BUFFSIZE, TIMEOUT) ;
if (!ret) {
printf("== GET - read %d ==\n", strlen(buff));
printf("Result: %s\n", buff);
break ;
} else {
printf("++ Err = %d - HTTP ret = %d ++\n",
ret, http.getHTTPResponseCode());
}
Thread::wait(5);
}
}
FRDM-K64F
Watching serial port output and getting error response from GET
Server logs on heroku show no requests so I'm stuggling to debug..
Thanks for your input on where I'm going wrong
HTTPClient http; LM75B tmp(D14,D15);
int main() { int ret ; EthernetInterface eth; static char buff[BUFFSIZE];
char uri[sizeof(HEROKU_API)+10+ALLOWANCE] ; printf("URI = %s\n", uri);
char header[512]; sprintf(header, "Content-Type: application/x-www-form-urlencoded\r\n") ;
http.setHeader(header) ;
printf("Mbed Device Starting,...\n") ; ret = eth.init(); Use DHCP while(1) { ret = eth.connect(); if(ret == 0)break ; } printf("IP = %s\n", eth.getIPAddress());
while (true) {
double val = tmp.read(); printf("Current temperature is: %lf\n", val);
STREAM PROCESSING FOR DATA char strVal[1024];
sprintf(strVal, "%s/stream/create?name=temperature&unit=farenheit&value=%f",HEROKU_API, val); printf("GET REQUEST URL: %s\n", strVal);
ret = http.get(uri, buff, BUFFSIZE, TIMEOUT) ; if (!ret) { printf("== GET - read %d ==\n", strlen(buff)); printf("Result: %s\n", buff); break ; } else { printf("++ Err = %d - HTTP ret = %d ++\n", ret, http.getHTTPResponseCode()); }
Thread::wait(5); } }