xively / xively_arduino

A library for Arduino to make it easier to talk to Xively™
https://xively.com/dev/libraries/
101 stars 67 forks source link

Feed with multiple float values returns HTTP 400 #19

Closed jrossouw closed 10 years ago

jrossouw commented 10 years ago

Hi,

I have found an issue with the Arduino Xively library.

I compiled the MultipleDatastreamUpload example - and that works as expected with a float, buffer and string stream.

If I change the buffer stream to a float stream as well, then the example fails with an HTTP 400 error, with the response body having:

{"title":"JSON Parser Error","errors":"JSON doesn't appear to be a hash"}

The only changes to the example are:

XivelyDatastream datastreams[] = { XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT), XivelyDatastream(bufferId, strlen(bufferId), DATASTREAM_FLOAT), XivelyDatastream(stringId, DATASTREAM_STRING) };

datastreams[1].setFloat(millis()/10.0f); Serial.print("Setting buffer value to:\n "); Serial.println(datastreams[1].getFloat());

I am having this same issue in another application I wrote - where sending one float stream in a feed works, but as soon as I add a 2nd float stream then it fails with this same error.

jrossouw commented 10 years ago

I found the root cause. I was using this library with the Teensy (3.1) and the teensy libraries had a bug in the Print::printFloat method which calculated the size incorrectly. It is not an issue with the Xively library.