tizen 5.0 migration
[apps/native/co2-meter.git] / src / capability / capability_airqualitysensor.c
index cf07560..0b4f6c0 100644 (file)
  * limitations under the License.
  */
 
-#include "st_things.h"
+#include "smartthings_resource.h"
 #include "log.h"
 
-static const charPROP_AIRQUALITY = "airQuality";
-static const charPROP_RANGE = "range";
+static const char *PROP_AIRQUALITY = "airQuality";
+static const char *PROP_RANGE = "range";
 static double g_range[2] = { 0, 10000. };
 static size_t g_length = 2;
 int32_t g_co2_sensor_value = 400;
 
 extern int resource_update_co2_sensor_value(void);
 
-bool handle_get_request_on_resource_capability_airqualitysensor(st_things_get_request_message_s* req_msg, st_things_representation_s* resp_rep)
+bool handle_get_request_on_resource_capability_airqualitysensor_main_0(smartthings_payload_h resp_payload, void *user_data)
 {
-       //DBG("Received a GET request on %s\n", req_msg->resource_uri);
+       int error = SMARTTHINGS_RESOURCE_ERROR_NONE;
 
-       if (req_msg->has_property_key(req_msg, PROP_AIRQUALITY)) {
-               g_co2_sensor_value = resource_update_co2_sensor_value();
-               resp_rep->set_int_value(resp_rep, PROP_AIRQUALITY, g_co2_sensor_value);
+       g_co2_sensor_value = resource_update_co2_sensor_value();
+       error = smartthings_payload_set_int(resp_payload, PROP_AIRQUALITY, g_co2_sensor_value);
+       if (error != SMARTTHINGS_RESOURCE_ERROR_NONE) {
+               _E("smartthings_payload_set_int() failed, [%d]", error);
+               return false;
        }
-       if (req_msg->has_property_key(req_msg, PROP_RANGE)) {
-               resp_rep->set_double_array_value(resp_rep, PROP_RANGE, (double*)&g_range, g_length);
+
+       error = smartthings_payload_set_double_array(resp_payload, PROP_RANGE, (double*)&g_range, g_length);
+       if (error != SMARTTHINGS_RESOURCE_ERROR_NONE) {
+               _E("smartthings_payload_set_double_array() failed, [%d]", error);
+               return false;
        }
 
        return true;