- //TODO: Consider; is it better to give both tv_sec and tv_usec to the client seperately, instead of combining here?
- //NOTE: Must always use doubles; floats get rounded!
- double time = buffer[i].time_stamp.tv_sec + 1e-6*(buffer[i].time_stamp.tv_usec);
- FCGI_JSONValue("[%f, %f]", time, buffer[i].value);
- if (i+1 < amount_read)
- FCGI_JSONValue(",");
+ FCGI_BeginJSON(context, status);
+ FCGI_JSONPair(key, value); // should spit back sensor ID
+ //Log(LOGDEBUG, "Call Sensor_Query...");
+ int amount_read = Sensor_Query(sensor, buffer, SENSOR_QUERYBUFSIZ);
+ //Log(LOGDEBUG, "Read %d DataPoints", amount_read);
+ //Log(LOGDEBUG, "Produce JSON response");
+ FCGI_JSONKey("data");
+ FCGI_JSONValue("[");
+ for (int i = 0; i < amount_read; ++i)
+ {
+ //TODO: Consider; is it better to give both tv_sec and tv_usec to the client seperately, instead of combining here?
+
+ FCGI_JSONValue("[%f, %f]", buffer[i].time_stamp, buffer[i].value);
+ if (i+1 < amount_read)
+ FCGI_JSONValue(",");
+ }
+ FCGI_JSONValue("]");
+ //Log(LOGDEBUG, "Done producing JSON response");
+ FCGI_EndJSON();
+ break;