blob: c4056d55764e4c8f00cf00c872f68d7e6c728c90 [file] [log] [blame]
#if 1
#include "mbtk_type.h"
#include "mbtk_log.h"
#include "lynq_qser_thermal.h"
#include "mbtk_ril_api.h"
/****************************DEFINE***************************************/
#define QSER_RESULT_FAIL -1
#define QSER_RESULT_SUCCESS 0
/****************************DEFINE***************************************/
/****************************VARIABLE***************************************/
static mbtk_ril_handle* qser_info_handle = NULL;
/****************************VARIABLE***************************************/
/******************************FUNC*****************************************/
static int qser_thermal_client_init(void)
{
qser_info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
if (qser_info_handle == NULL)
{
LOGE("[qser_led] qser_info_handle fail.");
return QSER_RESULT_FAIL;
}
else
{
LOGI("[qser_led] qser_info_handle success.");
return QSER_RESULT_SUCCESS;
}
}
static int qser_thermal_client_deinit(void)
{
if(qser_info_handle != NULL)
{
int ret_ril = mbtk_ril_close(MBTK_AT_PORT_DEF);
if (ret_ril == MBTK_RIL_ERR_SUCCESS)
{
LOGI("deinit qser_info_handle is succuess");
return QSER_RESULT_SUCCESS;
}
else
{
LOGE("deinit qser_info_handle is error(%d)",ret_ril);
return QSER_RESULT_FAIL;
}
}
return QSER_RESULT_SUCCESS;
}
/******************************FUNC*****************************************/
/****************************API***************************************/
int get_thermal_zone(int *numbers, int size)
{
if(numbers == NULL || size < 6)
{
LOGE("[qser_thermal]: numbers is NULL! || size < 6! ");
return QSER_RESULT_FAIL;
}
int ret = 0;
int thermal = -1;
int thermal_num = 0;
int temp = 0;
ret = qser_thermal_client_init();
if(ret != QSER_RESULT_SUCCESS)
{
LOGE("[qser_thermal]qser_led_client_init fail.");
return QSER_RESULT_FAIL;
}
ret = mbtk_temp_get(qser_info_handle, 0, &temp);
thermal = temp;
if(ret != QSER_RESULT_SUCCESS)
{
LOGE("[qser_thermal]mbtk_temp_get fail.");
qser_thermal_client_deinit();
return QSER_RESULT_FAIL;
}
qser_thermal_client_deinit();
numbers[thermal_num++] = thermal;
for(; thermal_num < size; thermal_num++)
{
numbers[thermal_num] = 0;
}
return 6;
}
/****************************API***************************************/
#endif