b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 1 | #if 1 |
| 2 | #include "mbtk_type.h" |
| 3 | #include "mbtk_log.h" |
| 4 | #include "lynq_qser_thermal.h" |
| 5 | #include "mbtk_ril_api.h" |
| 6 | |
| 7 | /****************************DEFINE***************************************/ |
| 8 | #define QSER_RESULT_FAIL -1 |
| 9 | #define QSER_RESULT_SUCCESS 0 |
| 10 | /****************************DEFINE***************************************/ |
| 11 | |
| 12 | /****************************VARIABLE***************************************/ |
| 13 | static mbtk_ril_handle* qser_info_handle = NULL; |
| 14 | |
| 15 | /****************************VARIABLE***************************************/ |
| 16 | |
| 17 | |
| 18 | /******************************FUNC*****************************************/ |
| 19 | static int qser_thermal_client_init(void) |
| 20 | { |
| 21 | qser_info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF); |
| 22 | |
| 23 | if (qser_info_handle == NULL) |
| 24 | { |
| 25 | LOGE("[qser_led] qser_info_handle fail."); |
| 26 | return QSER_RESULT_FAIL; |
| 27 | } |
| 28 | else |
| 29 | { |
| 30 | LOGI("[qser_led] qser_info_handle success."); |
| 31 | return QSER_RESULT_SUCCESS; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | static int qser_thermal_client_deinit(void) |
| 36 | { |
| 37 | if(qser_info_handle != NULL) |
| 38 | { |
| 39 | int ret_ril = mbtk_ril_close(MBTK_AT_PORT_DEF); |
| 40 | if (ret_ril == MBTK_RIL_ERR_SUCCESS) |
| 41 | { |
| 42 | LOGI("deinit qser_info_handle is succuess"); |
| 43 | return QSER_RESULT_SUCCESS; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | LOGE("deinit qser_info_handle is error(%d)",ret_ril); |
| 48 | return QSER_RESULT_FAIL; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return QSER_RESULT_SUCCESS; |
| 53 | } |
| 54 | |
| 55 | /******************************FUNC*****************************************/ |
| 56 | |
| 57 | /****************************API***************************************/ |
| 58 | int get_thermal_zone(int *numbers, int size) |
| 59 | { |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 60 | if(numbers == NULL || size < 6) |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 61 | { |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 62 | LOGE("[qser_thermal]: numbers is NULL! || size < 6! "); |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 63 | return QSER_RESULT_FAIL; |
| 64 | } |
| 65 | |
| 66 | int ret = 0; |
| 67 | int thermal = -1; |
| 68 | int thermal_num = 0; |
| 69 | int temp = 0; |
| 70 | |
| 71 | ret = qser_thermal_client_init(); |
| 72 | if(ret != QSER_RESULT_SUCCESS) |
| 73 | { |
| 74 | LOGE("[qser_thermal]qser_led_client_init fail."); |
| 75 | return QSER_RESULT_FAIL; |
| 76 | } |
| 77 | |
| 78 | ret = mbtk_temp_get(qser_info_handle, 0, &temp); |
| 79 | thermal = temp; |
| 80 | if(ret != QSER_RESULT_SUCCESS) |
| 81 | { |
| 82 | LOGE("[qser_thermal]mbtk_temp_get fail."); |
| 83 | qser_thermal_client_deinit(); |
| 84 | return QSER_RESULT_FAIL; |
| 85 | } |
| 86 | |
| 87 | qser_thermal_client_deinit(); |
| 88 | numbers[thermal_num++] = thermal; |
| 89 | for(; thermal_num < size; thermal_num++) |
| 90 | { |
| 91 | numbers[thermal_num] = 0; |
| 92 | } |
| 93 | |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 94 | return 6; |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 95 | } |
| 96 | /****************************API***************************************/ |
| 97 | |
| 98 | #endif |