2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "st_things.h"
20 static const char* PROP_AIRQUALITY = "airQuality";
21 static const char* PROP_RANGE = "range";
22 static double g_range[2] = { 0, 10000. };
23 static size_t g_length = 2;
24 int32_t g_co2_sensor_value = 400;
26 extern int resource_update_co2_sensor_value(void);
28 bool handle_get_request_on_resource_capability_airqualitysensor(st_things_get_request_message_s* req_msg, st_things_representation_s* resp_rep)
30 //DBG("Received a GET request on %s\n", req_msg->resource_uri);
32 if (req_msg->has_property_key(req_msg, PROP_AIRQUALITY)) {
33 g_co2_sensor_value = resource_update_co2_sensor_value();
34 resp_rep->set_int_value(resp_rep, PROP_AIRQUALITY, g_co2_sensor_value);
36 if (req_msg->has_property_key(req_msg, PROP_RANGE)) {
37 resp_rep->set_double_array_value(resp_rep, PROP_RANGE, (double*)&g_range, g_length);