return 0;
}
-int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_s sensor_data)
+int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_s *sensor_data)
{
const char n_id[] = "SensorPiID";
const char n_motion[] = "Motion";
retv_if(Json_h.is_begin == false, -1);
retv_if(Json_h.is_end == true, -1);
retv_if(sensorpi_id == NULL, -1);
+ retv_if(sensor_data == NULL, -1);
/* JSON structure :
{
Vibration: boolean,
CO2: double,
SoundLevel: int,
- SensorEnabled: [PIR, ],
+ SensorEnabled: [Motion, ],
Hash: string,
}
*/
- _I("id : %s, value : %d", sensorpi_id, sensor_data.pir);
+ _I("id : %s, value : %d", sensorpi_id, sensor_data->motion);
json_builder_begin_object(Json_h.builder);
json_builder_set_member_name(Json_h.builder, n_id);
json_builder_add_string_value(Json_h.builder, sensorpi_id);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_MOTION) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) {
json_builder_set_member_name(Json_h.builder, n_motion);
- json_builder_add_int_value(Json_h.builder, sensor_data.pir);
+ json_builder_add_int_value(Json_h.builder, sensor_data->motion);
}
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_FLAME) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) {
json_builder_set_member_name(Json_h.builder, n_flame);
- json_builder_add_int_value(Json_h.builder, sensor_data.flame);
+ json_builder_add_int_value(Json_h.builder, sensor_data->flame);
}
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) {
json_builder_set_member_name(Json_h.builder, n_hum);
- json_builder_add_double_value(Json_h.builder, sensor_data.humidity);
+ json_builder_add_double_value(Json_h.builder, sensor_data->humidity);
}
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) {
json_builder_set_member_name(Json_h.builder, n_temp);
- json_builder_add_double_value(Json_h.builder, sensor_data.temperature);
+ json_builder_add_double_value(Json_h.builder, sensor_data->temperature);
}
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_VIB) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) {
json_builder_set_member_name(Json_h.builder, n_vib);
- json_builder_add_int_value(Json_h.builder, sensor_data.virbration);
+ json_builder_add_int_value(Json_h.builder, sensor_data->virbration);
}
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_CO2) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) {
json_builder_set_member_name(Json_h.builder, n_co2);
- json_builder_add_double_value(Json_h.builder, sensor_data.co2);
+ json_builder_add_double_value(Json_h.builder, sensor_data->co2);
}
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_SOUND) {
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) {
json_builder_set_member_name(Json_h.builder, n_sound);
- json_builder_add_int_value(Json_h.builder, sensor_data.soundlevel);
+ json_builder_add_int_value(Json_h.builder, sensor_data->soundlevel);
}
json_builder_set_member_name(Json_h.builder, n_e_sensor);
json_builder_begin_array(Json_h.builder);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_MOTION)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION)
json_builder_add_string_value(Json_h.builder, n_motion);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_FLAME)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME)
json_builder_add_string_value(Json_h.builder, n_flame);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY)
json_builder_add_string_value(Json_h.builder, n_hum);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE)
json_builder_add_string_value(Json_h.builder, n_temp);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_VIB)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB)
json_builder_add_string_value(Json_h.builder, n_vib);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_CO2)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2)
json_builder_add_string_value(Json_h.builder, n_co2);
- if(sensor_data.enabled_sensor & WEB_UTIL_SENSOR_SOUND)
+ if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND)
json_builder_add_string_value(Json_h.builder, n_sound);
json_builder_end_array(Json_h.builder);
- if(sensor_data.hash) {
+ if(sensor_data->hash) {
json_builder_set_member_name(Json_h.builder, n_hash);
- json_builder_add_string_value(Json_h.builder, sensor_data.hash);
+ json_builder_add_string_value(Json_h.builder, sensor_data->hash);
}
json_builder_end_object(Json_h.builder);