* \#include <device/display.h> \n
* \#include <device/haptic.h> \n
* \#include <device/led.h> \n
- * \#include <device/power.h>
- * \#include <device/ir.h>
+ * \#include <device/power.h> \n
+ * \#include <device/ir.h> \n
+ * \#include <device/temperature.h> \n
*
* @section CAPI_SYSTEM_DEVICE_MODULE_OVERVIEW Overview
* The DEVICE API provides functions to control devices or to get status of devices.
* - LED
* - Power
* - IR
+ * - Temperature
*/
/**
*
*/
+/**
+ * @ingroup CAPI_SYSTEM_DEVICE_MODULE
+ * @defgroup CAPI_SYSTEM_DEVICE_THERMAL_MODULE Thermal
+ * @brief The Temperature API provides functions to get information about the temperature.
+ *
+ * @section CAPI_SYSTEM_DEVICE_THERMAL_MODULE_HEADER Required Header
+ * \#include <device/temperature.h> \n
+ *
+ * @section CAPI_SYSTEM_DEVICE_THERMAL_MODULE_OVERVIEW Overview
+ * The Temperature API provides the way to get the current thermal value such as Application Processor, Communication Processor and Battery.
+ *
+ * @section CAPI_SYSTEM_DEVICE_THERMAL_MODULE_OVERVIEW Related Features
+ * This API is related with the following features:\n
+ * - %http://tizen.org/feature/thermistor.ap\n
+ * - %http://tizen.org/feature/thermistor.cp\n
+ * - %http://tizen.org/feature/thermistor.battery\n
+ *
+ * It is recommended to use features in your application for reliability.\n
+ *
+ * You can check if the device supports the related features for this API by using System Information, and control your application's actions accordingly.\n
+ *
+ * To ensure your application is running only on devices with specific features, please define the features in your manifest file using the manifest editor in the SDK.
+ *
+ * More details on using features in your application can be found in the <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>feature element description</b></a>.
+ *
+ *
+ */
+
#endif /* __TIZEN_SYSTEM_DEVICE_DOC_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SYSTEM_TEMPERATURE_H__
+#define __TIZEN_SYSTEM_TEMPERATURE_H__
+
+
+#include <stdbool.h>
+#include <device-error.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_DEVICE_THERMAL_MODULE
+ * @{
+ */
+
+
+/**
+ * @brief Enumeration for the device temperature.
+ * @since_tizen 5.5
+ */
+typedef enum
+{
+ DEVICE_THERMAL_AP, /**< Temperature for Application Processor */
+ DEVICE_THERMAL_CP, /**< Temperature for Communication Processor */
+ DEVICE_THERMAL_BATTERY, /**< Temperature for Battery */
+} device_thermal_e;
+
+
+/**
+ * @brief Gets the temperature value.
+ * @since_tizen 5.5
+ * @param[in] type The index of the device
+ * @param[out] temp The temperature value in degrees Celsius
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_thermal_get_temperature(device_thermal_e type, int *temp);
+
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __TIZEN_SYSTEM_TEMPERATURE_H__ */
#define DEVICED_PATH_IR DEVICED_OBJECT_PATH"/Ir"
#define DEVICED_INTERFACE_IR DEVICED_INTERFACE_NAME".ir"
+/* Thermal service: operatioins about temperature */
+#define DEVICED_PATH_TEMPERATURE DEVICED_OBJECT_PATH"/Temperature"
+#define DEVICED_INTERFACE_TEMPERATURE DEVICED_INTERFACE_NAME".temperature"
+
struct dbus_int {
int *list;
int size;
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <glib.h>
+#include <system_info.h>
+#include "common.h"
+#include "dbus.h"
+#include "temperature.h"
+
+#define METHOD_GET_TEMPERATURE "GetTemperature"
+
+#define THERMAL_AP_FEATURE "http://tizen.org/feature/thermistor.ap"
+#define THERMAL_CP_FEATURE "http://tizen.org/feature/thermistor.cp"
+#define THERMAL_BATTERY_FEATURE "http://tizen.org/feature/thermistor.battery"
+
+static int is_temperature_supported(device_thermal_e type)
+{
+ int ret = 0;
+ bool thermal_avail;
+
+ if (type == DEVICE_THERMAL_AP)
+ ret = system_info_get_platform_bool(THERMAL_AP_FEATURE, &thermal_avail);
+ else if (type == DEVICE_THERMAL_CP)
+ ret = system_info_get_platform_bool(THERMAL_CP_FEATURE, &thermal_avail);
+ else
+ ret = system_info_get_platform_bool(THERMAL_BATTERY_FEATURE, &thermal_avail);
+ if (ret < 0) {
+ _E("Failed to get value of temp feature : %d", ret);
+ return false;
+ } else if (ret == 0 && !thermal_avail) {
+ _D("Temperature is not supported");
+ return false;
+ } else
+ return true;
+}
+
+int device_thermal_get_temperature(device_thermal_e type, int *temp)
+{
+ char *arr[1];
+ char str_val[32];
+ int ret;
+
+ if (type > DEVICE_THERMAL_BATTERY)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = is_temperature_supported(type);
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
+ snprintf(str_val, sizeof(str_val), "%d", type);
+ arr[0] = str_val;
+
+ ret = dbus_method_sync(DEVICED_BUS_NAME,
+ DEVICED_PATH_TEMPERATURE,
+ DEVICED_INTERFACE_TEMPERATURE,
+ METHOD_GET_TEMPERATURE, "i", arr);
+ if (ret < 0)
+ return errno_to_device_error(ret);
+
+ *temp = ret;
+ return DEVICE_ERROR_NONE;
+}
+