HTTPClient GET appears to not be firing

15 Oct 2014

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

  1. include "mbed.h"
  1. include "EthernetInterface.h"
  2. include "HTTPClient.h"
  3. include "LM75B.h"
  1. define HEROKU_API "http://myurl.herokuapp.com"
  2. define TIMEOUT 500
  3. define BUFFSIZE 1024
  4. 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); } }