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 <smartthings_resource.h>
19 #include <peripheral_io.h>
25 static const char *PROP_ILLUMINANCE = "illuminance";
27 extern int resource_read_illuminance_sensor(uint16_t *out_value);
29 bool handle_get_request_on_resource_capability_illuminancemeasurement_main_0(smartthings_payload_h resp_payload, void *user_data)
31 int ret = PERIPHERAL_ERROR_NONE;
32 int error = SMARTTHINGS_RESOURCE_ERROR_NONE;
35 _D("Received a GET request for Sensor");
37 ret = resource_read_illuminance_sensor(&sensor_data);
38 if (ret != PERIPHERAL_ERROR_NONE) {
39 _E("resource_read_illuminance_sensor() failed, [%d]", ret);
42 error = smartthings_payload_set_int(resp_payload, PROP_ILLUMINANCE, (int)sensor_data);
43 if (error != SMARTTHINGS_RESOURCE_ERROR_NONE)
44 _E("smartthings_payload_set_int() failed, [%d]", error);