// Error occured; FCGI_RejectJSON already called
return;
}
- else if (id < 0 || id >= NUMSENSORS)
+
-
+ // Error checking on sensor id
+ if (id < 0 || id >= NUMSENSORS)
{
- FCGI_RejectJSON(context, "Invalid sensor id specified");
+ FCGI_RejectJSON(context, "Invalid sensor id");
return;
}
-
- // Get Sensor and format
Sensor * s = g_sensors+id;
- DataFormat format = JSON;
-
- // Check if format type was specified
- if (FCGI_RECEIVED(values[FORMAT].flags))
- {
- if (strcmp(fmt_str, "json") == 0)
- format = JSON;
- else if (strcmp(fmt_str, "tsv") == 0)
- format = TSV;
- else
- {
- FCGI_RejectJSON(context, "Unknown format type specified.");
- return;
- }
- }
+
+ DataFormat format = Data_GetFormat(&(values[FORMAT]));
// Begin response
Sensor_BeginResponse(context, id, format);