blob: ddf304c8c9fb0a0503bf0fb6fca7b012f18adb66 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_dm.h
4 @brief device management API
5*/
6/*-----------------------------------------------------------------------------------------------*/
7
8/*-------------------------------------------------------------------------------------------------
9 Copyright (c) 2019 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
10 Quectel Wireless Solution Proprietary and Confidential.
11-------------------------------------------------------------------------------------------------*/
12
13/*-------------------------------------------------------------------------------------------------
14 EDIT HISTORY
15 This section contains comments describing changes made to the file.
16 Notice that changes are listed in reverse chronological order.
17 $Header: $
18 when who what, where, why
19 -------- --- ----------------------------------------------------------
20 20200316 stan.li Optimize the ql_dm_get_modem_state interface
21 20191224 stan.li Add radio on/off API
22 20190625 stan.li Created .
23-------------------------------------------------------------------------------------------------*/
24
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31#include <stdio.h>
32#include <stdbool.h>
33#include <pthread.h>
34
35#include "mbtk_ril_api.h"
36#include "ql_type.h"
37#include "ql_dm.h"
38
39
40
41#define LYNQ_AIR_PLANE_MODE_ON 4 //at+cfun = 4
42#define LYNQ_AIR_PLANE_MODE_OFF 1 // at+cfun = 1
43
44
45#define MBTK_RILD_ERR -1
46#define IMEI_VALID 1
47
48static mbtk_ril_handle* ql_info_handle = NULL;
49static mbtk_ril_handle* g_md_version_handle = NULL;
50
51static ql_dm_air_plane_mode_ind_cb g_air_plane_mode_cb = NULL;
52static ql_dm_service_error_cb_f global_dm_error_cb = NULL;
53static ql_dm_modem_state_ind_cb global_dm_modem_cb = NULL;
54
55
56static pthread_t g_air_plane_mode_thread;
57static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
58static pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER;
59static bool g_thread_running = false;
60
61
62static void mbtk_send_singnal()
63{
64 pthread_mutex_lock(&g_mutex);
65 pthread_cond_signal(&g_cond);
66 pthread_mutex_unlock(&g_mutex);
67
68}
69
70static void mbtk_dm_set_service_error_func(const void* data,int data_len)
71{
72 if(data !=NULL && data_len == sizeof(int))
73 {
74 const int *state = (const int*)(data);
75 if(*state)
76 {
77 if(global_dm_error_cb)
78 {
79 global_dm_error_cb(MBTK_RILD_ERR);
80 }
81
82 }
83 }
84
85}
86
87static void mbtk_modem_state_change_cb(const void* data, int data_len)
88{
89 uint8 *ptr = (uint8*)data;
90 if(global_dm_modem_cb)
91 {
92 global_dm_modem_cb(*ptr);
93 }
94
95}
96
97void* air_plane_mode_monitor(void* arg)
98{
99 int ql_info = 0;
100 int ret = -1;
101 mbtk_radio_state_enum mbtk_info;
102
103 while (g_thread_running)
104 {
105 pthread_mutex_lock(&g_mutex);
106 pthread_cond_wait(&g_cond, &g_mutex);
107 ret = mbtk_radio_state_get(ql_info_handle, &mbtk_info);
108 if (ret != 0)
109 {
110 LOGE("mbtk_radio_state_get fail.");
111 return NULL;
112 }
113
l.yang860a8e72025-05-13 01:55:38 -0700114 if(mbtk_info == MBTK_RADIO_STATE_FULL_FUNC)
b.liud440f9f2025-04-18 10:44:31 +0800115 {
116 ql_info = QL_DM_AIR_PLANE_MODE_OFF;
117 }
118
l.yang860a8e72025-05-13 01:55:38 -0700119 if(mbtk_info == MBTK_RADIO_STATE_DIS_RF)
b.liud440f9f2025-04-18 10:44:31 +0800120 {
121 ql_info = QL_DM_AIR_PLANE_MODE_ON;
122 }
123
l.yang860a8e72025-05-13 01:55:38 -0700124 if(mbtk_info != MBTK_RADIO_STATE_FULL_FUNC && mbtk_info !=MBTK_RADIO_STATE_DIS_RF)
b.liud440f9f2025-04-18 10:44:31 +0800125 {
126
127 ql_info = QL_DM_AIR_PLANE_MODE_UNKNOWN;
128 }
129
130 if(g_air_plane_mode_cb)
131 {
132
133 g_air_plane_mode_cb(ql_info);
134 }
135
136 pthread_mutex_unlock(&g_mutex);
137 }
138
139 return NULL;
140}
141
142/*-----------------------------------------------------------------------------------------------*/
143/**
144 @brief Initialize DM service.
145 @note You must call this function before other functions can be used in this module.
146 @return Whether the DM service was successfully intialized.
147 @retval QL_ERR_OK successful.
148 @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry.
149 @retval Other error code defined by ql_type.h.
150 */
151/*-----------------------------------------------------------------------------------------------*/
152
153int ql_dm_init(void)
154{
155
156 if(ql_info_handle == NULL)
157 {
158
159 mbtk_log_init("syslog", "QL_DM");
160
161 ql_info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
162 if(ql_info_handle)
163 {
164
165 return QL_ERR_OK;
166 }
167 else
168 {
169 LOGE("mbtk_info_handle_get() fail.");
170 return QL_ERR_FAILED;
171 }
172
173 }
174 else
175 {
176 LOGE("No need init again");
177 return QL_ERR_FAILED;
178 }
179}
180
181/*-----------------------------------------------------------------------------------------------*/
182/**
183 @brief Denitialize DM service.
184 @return Whether the DM service was successfully deintialized.
185 @retval QL_ERR_OK successful.
186 @retval Other error code defined by ql_type.h.
187 */
188/*-----------------------------------------------------------------------------------------------*/
189int ql_dm_deinit(void)
190{
191 if(ql_info_handle)
192 {
193
194 int ret = mbtk_ril_close(MBTK_AT_PORT_DEF);
195 if(ret != 0)
196 {
197 LOGE("mbtk_info_handle_free fail.");
198 return QL_ERR_FAILED;
199 }
200 else
201 {
l.yang860a8e72025-05-13 01:55:38 -0700202 ql_info_handle = NULL;
b.liud440f9f2025-04-18 10:44:31 +0800203 LOGI("mbtk_info_handle_free success");
204 return QL_ERR_OK;
205 }
206 }
207 else
208 {
209 LOGE("DM not inited.");
210 return QL_ERR_NOT_INIT;
211 }
212
213}
214
215/*-----------------------------------------------------------------------------------------------*/
216/**
217 @brief get device software version.
218 @param[out] soft_ver Return software version
219 @param[in] soft_ver_len The length of soft_ver
220 @return Whether to successfully get the software version
221 @retval QL_ERR_OK successful
222 @retval QL_ERR_NOT_INIT uninitialized
223 @retval QL_ERR_SERVICE_NOT_READY service is not ready
224 @retval QL_ERR_INVALID_ARG Invalid arguments
225 @retval Other error code defined by ql_type.h
226 */
227/*-----------------------------------------------------------------------------------------------*/
228
229int ql_dm_get_software_version(char *soft_ver, int soft_ver_len)
230{
231
232 int ret = -1;
233 if(soft_ver == NULL || soft_ver_len <= 0)
234 {
235 LOGE("Bad parameters ");
236 return QL_ERR_FAILED;
237 }
238 if(ql_info_handle != NULL)
239 {
240
241 ret = mbtk_version_get(ql_info_handle,soft_ver);
242 if(ret != 0)
243 {
244 LOGE("ql_dm_get_software_version error.");
245 return QL_ERR_FAILED;
246 }
247 }
248 else
249 {
250 mbtk_ril_handle* mbtk_info_handle = NULL;
251 mbtk_info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
252 if(mbtk_info_handle == NULL)
253 {
254 LOGE("mbtk_info_handle_get fail.");
255 return QL_ERR_FAILED;
256 }
257 ret = mbtk_version_get(mbtk_info_handle,soft_ver);
258 if(ret != 0)
259 {
260 LOGE("ql_dm_get_software_version error.");
261
262 }
263 ret = mbtk_ril_close(MBTK_AT_PORT_DEF);
264 if(ret != 0)
265 {
266 LOGE("mbtk_info_handle_free fail.");
267 return QL_ERR_FAILED;
268 }
269
270 }
271 return QL_ERR_OK;
272
273
274}
275
276/*-----------------------------------------------------------------------------------------------*/
277/**
278 @brief get modem state.
279 @details QL_DM_MODEM_STATE_ONLINE,if modem starts normally.
280 @details QL_DM_MODEM_STATE_OFFLINE,in modem starts abnormally.
281 @details QL_DM_MODEM_STATE_UNKNOWN,unknown error.
282 @param[out] modem_state The state of modem
283 @return Whether to successfully get the modem state
284 @retval QL_ERR_OK successful
285 @retval QL_ERR_NOT_INIT uninitialized
286 @retval QL_ERR_SERVICE_NOT_READY service is not ready
287 @retval QL_ERR_INVALID_ARG Invalid arguments
288 @retval Other error code defined by ql_type.h
289 */
290/*-----------------------------------------------------------------------------------------------*/
l.yang860a8e72025-05-13 01:55:38 -0700291int ql_dm_get_modem_state(QL_DM_MODEM_STATE_TYPE_E *modem_state)
292{
293 int ret = -1;
294 mbtk_radio_state_enum tmp_rf;
295 if(ql_info_handle == NULL)
296 {
297 LOGE("DM no init");
298 return QL_ERR_NOT_INIT;
299 }
300 ret = mbtk_radio_state_get(ql_info_handle, &tmp_rf);
301 if (ret != 0)
302 {
303 LOGE("mbtk_radio_state_get fail.");
304 return QL_ERR_FAILED;
305 }
306
307 if(tmp_rf == 0 )
308 {
309 *modem_state = QL_DM_MODEM_STATE_OFFLINE;
310 }
311 else if(tmp_rf == 1)
312 {
313 *modem_state = QL_DM_MODEM_STATE_ONLINE;
314 }
315 else
316 {
317 *modem_state = QL_DM_MODEM_STATE_UNKNOWN;
318 }
319
320 return QL_ERR_OK;
321
322}
b.liud440f9f2025-04-18 10:44:31 +0800323
324/*-----------------------------------------------------------------------------------------------*/
325/**
326 @brief register modem state event.
327 @param[in] cb_func modem state indication callback function
328 @return Whether the modem state event was successfully registered.
329 @retval QL_ERR_OK successful
330 @retval QL_ERR_NOT_INIT uninitialized
331 @retval QL_ERR_SERVICE_NOT_READY service is not ready
332 @retval QL_ERR_INVALID_ARG Invalid arguments
333 @retval Other error code defined by ql_type.h
334 */
335/*-----------------------------------------------------------------------------------------------*/
336
337int ql_dm_set_modem_state_change_ind_cb(ql_dm_modem_state_ind_cb cb_func)
338{
339
340 int ret =-1;
341
342 global_dm_modem_cb = cb_func;
343
344 if(ql_info_handle != NULL)
345 {
346
347 ret = mbtk_radio_state_change_cb_reg(mbtk_modem_state_change_cb);
348 if(ret != 0)
349 {
350 LOGE("call mbtk_radio_state_change_cb_reg failed");
351 return QL_ERR_FAILED;
352 }
353 }
354 else
355 {
356 if(g_md_version_handle == NULL)
357 {
358 g_md_version_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
359 if(g_md_version_handle == NULL)
360 {
361 LOGE("g_md_version_handle get fail.");
362 return QL_ERR_FAILED;
363 }
364 }
365
366 ret = mbtk_radio_state_change_cb_reg(mbtk_modem_state_change_cb);
367 if(ret != 0)
368 {
369
370 ret = mbtk_ril_close(MBTK_AT_PORT_DEF);
371 if(ret < 0)
372 {
373 LOGE("mbtk_info_handle_free fail.");
374 return QL_ERR_FAILED;
375 }
376
377 LOGE("call mbtk_radio_state_change_cb_reg failed");
378 return QL_ERR_FAILED;
379 }
380
381 }
382
383 return QL_ERR_OK;
384}
385
386/*-----------------------------------------------------------------------------------------------*/
387/**
388 @brief get module temperature.
389 @param[out] temperature The current temperature
390 @return Whether to successfully get the temperature
391 @retval QL_ERR_OK successful
392 @retval QL_ERR_NOT_INIT uninitialized
393 @retval QL_ERR_SERVICE_NOT_READY service is not ready
394 @retval QL_ERR_INVALID_ARG Invalid arguments
395 @retval Other error code defined by ql_type.h
396 */
397/*-----------------------------------------------------------------------------------------------*/
398int ql_dm_get_temperature(float *temperature);
399
400
401/*-----------------------------------------------------------------------------------------------*/
402/**
403 @brief get device serial numbers.
404 @param[out] p_info Pointer that point to ql_dm_device_serial_numbers_info_t
405 @return Whether to successfully get the serial numbers
406 @retval QL_ERR_OK successful
407 @retval QL_ERR_NOT_INIT uninitialized
408 @retval QL_ERR_SERVICE_NOT_READY service is not ready
409 @retval QL_ERR_INVALID_ARG Invalid arguments
410 @retval Other error code defined by ql_type.h
411 */
412/*-----------------------------------------------------------------------------------------------*/
413int ql_dm_get_device_serial_numbers(ql_dm_device_serial_numbers_info_t *p_info)
414{
415 int ret = -1;
416 if(ql_info_handle == NULL )
417 {
418 LOGE("DM no init");
419 return QL_ERR_NOT_INIT;
420 }
421
422 ret = mbtk_imei_get(ql_info_handle, p_info->imei);
423 if(ret != 0)
424 {
425 LOGE("Error : %d\n", ret);
426 return QL_ERR_FAILED;
427 }
428 if(strlen(p_info->imei) > 0)
429 {
430 p_info->imei_valid = IMEI_VALID;
431 }
432
433
434 return QL_ERR_OK;
435
436}
437
438/*-----------------------------------------------------------------------------------------------*/
439/**
440 @brief get device firmware revision identification.
441 @param[out] firmware_rev_id Return device firmware revision id
442 @param[in] firmware_rev_id_len The length of firmware_rev_id
443 @return Whether to successfully get the firmware revision id
444 @retval QL_ERR_OK successful
445 @retval QL_ERR_NOT_INIT uninitialized
446 @retval QL_ERR_SERVICE_NOT_READY service is not ready
447 @retval QL_ERR_INVALID_ARG Invalid arguments
448 @retval Other error code defined by ql_type.h
449 */
450/*-----------------------------------------------------------------------------------------------*/
451int ql_dm_get_device_firmware_rev_id(char *firmware_rev_id, int firmware_rev_id_len)
452{
453 int ret = -1;
454
455 if(ql_info_handle == NULL)
456 {
457 LOGE("DM no init");
458 return QL_ERR_NOT_INIT;
459 }
460
l.yang15056cf2025-05-13 03:20:32 -0700461 ret = mbtk_get_modem_version(ql_info_handle, (void *)firmware_rev_id);
b.liud440f9f2025-04-18 10:44:31 +0800462 //mbtk_v2 do not have function
b.liud440f9f2025-04-18 10:44:31 +0800463 if(ret < 0)
464 {
465 LOGE("get modem version failed");
466 return QL_ERR_FAILED;
467 }
468 return 0;
469}
470
471/*-----------------------------------------------------------------------------------------------*/
472/**
473 @brief get air plane mode.
474 @param[out] p_info Pointer that point to QL_DM_AIR_PLANE_MODE_TYPE_E
475 @return Whether to successfully get the air plane mode
476 @retval QL_ERR_OK successful
477 @retval QL_ERR_NOT_INIT uninitialized
478 @retval QL_ERR_SERVICE_NOT_READY service is not ready
479 @retval QL_ERR_INVALID_ARG Invalid arguments
480 @retval Other error code defined by ql_type.h
481 */
482/*-----------------------------------------------------------------------------------------------*/
483int ql_dm_get_air_plane_mode(QL_DM_AIR_PLANE_MODE_TYPE_E *p_info)
484{
485
486 int ret = -1;
487 mbtk_radio_state_enum tmp_rf;
488 if(ql_info_handle == NULL)
489 {
490 LOGE("DM no init");
491 return QL_ERR_NOT_INIT;
492 }
493 ret = mbtk_radio_state_get(ql_info_handle, &tmp_rf);
494 if (ret != 0)
495 {
496 LOGE("mbtk_radio_state_get fail.");
497 return QL_ERR_FAILED;
498 }
l.yang860a8e72025-05-13 01:55:38 -0700499 if(tmp_rf == MBTK_RADIO_STATE_FULL_FUNC )
b.liud440f9f2025-04-18 10:44:31 +0800500 {
501 *p_info = QL_DM_AIR_PLANE_MODE_OFF;
502 }
l.yang860a8e72025-05-13 01:55:38 -0700503 else if(tmp_rf == MBTK_RADIO_STATE_DIS_RF || tmp_rf == MBTK_RADIO_STATE_MINI_FUNC)
b.liud440f9f2025-04-18 10:44:31 +0800504 {
505 *p_info = QL_DM_AIR_PLANE_MODE_ON;
506 }
507
508 return 0;
509
510}
511
512/*-----------------------------------------------------------------------------------------------*/
513/**
514 @brief set air plane mode.
515 @param[in] air_plane_mode 1:ON, 2:OFF
516 @return Whether to successfully set the air plane mode
517 @retval QL_ERR_OK successful
518 @retval QL_ERR_NOT_INIT uninitialized
519 @retval QL_ERR_SERVICE_NOT_READY service is not ready
520 @retval QL_ERR_INVALID_ARG Invalid arguments
521 @retval Other error code defined by ql_type.h
522 */
523/*-----------------------------------------------------------------------------------------------*/
524
525
526int ql_dm_set_air_plane_mode(QL_DM_AIR_PLANE_MODE_TYPE_E air_plane_mode)
527{
l.yang860a8e72025-05-13 01:55:38 -0700528 //mbtk_radio_state_enum radio = MBTK_RADIO_STATE_MINI_FUNC;
b.liud440f9f2025-04-18 10:44:31 +0800529 int reset = 0;
530 int rf_mode = -1;
531 int ret = -1;
532
533 if(ql_info_handle == NULL)
534 {
535 LOGE("DM no init");
536 return QL_ERR_NOT_INIT;
537 }
538 if(air_plane_mode == QL_DM_AIR_PLANE_MODE_ON)
539 {
l.yang860a8e72025-05-13 01:55:38 -0700540 rf_mode = MBTK_RADIO_STATE_DIS_RF;
b.liud440f9f2025-04-18 10:44:31 +0800541 }
542
543 if(air_plane_mode == QL_DM_AIR_PLANE_MODE_OFF)
544 {
545 rf_mode = LYNQ_AIR_PLANE_MODE_OFF;
546
547 }
548
l.yang860a8e72025-05-13 01:55:38 -0700549 if (rf_mode != MBTK_RADIO_STATE_DIS_RF && rf_mode != MBTK_RADIO_STATE_FULL_FUNC)
b.liud440f9f2025-04-18 10:44:31 +0800550 {
551 LOGE("Input mode is error!");
552 return QL_ERR_OP_UNSUPPORTED;
553 }
554
555
l.yang860a8e72025-05-13 01:55:38 -0700556 ret = mbtk_radio_state_set(ql_info_handle, rf_mode, reset);
b.liud440f9f2025-04-18 10:44:31 +0800557 if(ret != 0)
558 {
559 LOGE("ql_dm_set_air_plane_mode failed");
560 }
561 mbtk_send_singnal();
562 return QL_ERR_OK;
563
564
565}
566/*-----------------------------------------------------------------------------------------------*/
567/**
568 @brief register air plane mode event.
569 @param[in] cb_func Air plane mode indication callback function
570 @return Whether the air plane mode event was successfully registered.
571 @retval QL_ERR_OK successful
572 @retval QL_ERR_NOT_INIT uninitialized
573 @retval QL_ERR_SERVICE_NOT_READY service is not ready
574 @retval QL_ERR_INVALID_ARG Invalid arguments
575 @retval Other error code defined by ql_type.h
576 */
577/*-----------------------------------------------------------------------------------------------*/
578
579int ql_dm_set_air_plane_mode_ind_cb(ql_dm_air_plane_mode_ind_cb cb_func)
580{
581 if(ql_info_handle == NULL)
582 {
583 LOGE("No init ");
584 return QL_ERR_NOT_INIT;
585 }
586
587 g_air_plane_mode_cb = cb_func;
588
589 if (!g_thread_running)
590 {
591 g_thread_running = true;
592 if (pthread_create(&g_air_plane_mode_thread, NULL, air_plane_mode_monitor, NULL) != 0)
593 {
594 LOGE("Failed to create air plane mode monitor thread");
595 g_thread_running = false;
596 return QL_ERR_FAILED;
597 }
598 }
599
600 return QL_ERR_OK;
601}
602
603
604/*-----------------------------------------------------------------------------------------------*/
605/**
606 @brief get cpu occupancy.
607 @param[out] cpu_occupancy The percentage of cpu occupancy
608 @return Whether to successfully get the cpu occupancy
609 @retval QL_ERR_OK successful
610 @retval QL_ERR_NOT_INIT uninitialized
611 @retval QL_ERR_SERVICE_NOT_READY service is not ready
612 @retval QL_ERR_INVALID_ARG Invalid arguments
613 @retval Other error code defined by ql_type.h
614 */
615/*-----------------------------------------------------------------------------------------------*/
616int ql_dm_get_cpu_occupancy(float *cpu_occupancy);
617
618
619/*-----------------------------------------------------------------------------------------------*/
620/**
621 @brief get mem usage.
622 @param[out] mem_use The percentage of mem usage
623 @return Whether to successfully get the memory usage
624 @retval QL_ERR_OK successful
625 @retval QL_ERR_NOT_INIT uninitialized
626 @retval QL_ERR_SERVICE_NOT_READY service is not ready
627 @retval QL_ERR_INVALID_ARG Invalid arguments
628 @retval Other error code defined by ql_type.h
629 */
630/*-----------------------------------------------------------------------------------------------*/
631int ql_dm_get_mem_usage(float *mem_use);
632
633
634/*-----------------------------------------------------------------------------------------------*/
635/**
636 @brief get NV item value.
637 @param[in] nv_item_name The NV item name that is either NV item id or NV item path
638 @param[out] nv_item_value The NV value buf of nv_item_name
639 param[in] nv_item_value_len The length of nv_item_value
640 param[out] nv_len The real length of nv_item_name
641 @return Whether to successfully get the NV value
642 @retval QL_ERR_OK successful
643 @retval QL_ERR_NOT_INIT uninitialized
644 @retval QL_ERR_SERVICE_NOT_READY service is not ready
645 @retval QL_ERR_INVALID_ARG Invalid arguments
646 @retval Other error code defined by ql_type.h
647 */
648/*-----------------------------------------------------------------------------------------------*/
649int ql_dm_get_nv_item_value(char *nv_item_name, unsigned char *nv_item_value, int nv_item_value_len,
650 int *nv_len);
651
652/*-----------------------------------------------------------------------------------------------*/
653/**
654 @brief set NV item value.
655 @param[in] nv_item_name The NV item name that is either NV item id or NV item path
656 @param[in] nv_item_value The NV value of nv_item_name
657 @param[in] nv_item_value_len The length of nv_item_value
658 param[out] nv_len The real length of nv_item_name
659 @return Whether to successfully set the NV value
660 @retval QL_ERR_OK successful
661 @retval QL_ERR_NOT_INIT uninitialized
662 @retval QL_ERR_SERVICE_NOT_READY service is not ready
663 @retval QL_ERR_INVALID_ARG Invalid arguments
664 @retval Other error code defined by ql_type.h
665 */
666/*-----------------------------------------------------------------------------------------------*/
667int ql_dm_set_nv_item_value(char *nv_item_name, unsigned char *nv_item_value, int nv_item_value_len,
668 int *nv_len);
669
670
671/*-----------------------------------------------------------------------------------------------*/
672/**
673 @brief set radio on, its function is the same as at+cfun=1.
674 @return Whether to successfully set the radio on
675 @retval QL_ERR_OK successful
676 @retval QL_ERR_NOT_INIT uninitialized
677 @retval QL_ERR_SERVICE_NOT_READY service is not ready
678 @retval QL_ERR_INVALID_ARG Invalid arguments
679 @retval Other error code defined by ql_type.h
680 */
681/*-----------------------------------------------------------------------------------------------*/
682int ql_dm_set_radio_on(void);
683
684/*-----------------------------------------------------------------------------------------------*/
685/**
686 @brief set radio off, its function is the same as at+cfun=0.
687 @return Whether to successfully set the radio off
688 @retval QL_ERR_OK successful
689 @retval QL_ERR_NOT_INIT uninitialized
690 @retval QL_ERR_SERVICE_NOT_READY service is not ready
691 @retval QL_ERR_INVALID_ARG Invalid arguments
692 @retval Other error code defined by ql_type.h
693 */
694/*-----------------------------------------------------------------------------------------------*/
695int ql_dm_set_radio_off(void);
696
697/*-----------------------------------------------------------------------------------------------*/
698/**
699 @brief get modem mem and CPU utilization.
700 @param[out] mem_use The percentage of modem utilization
701 @return Whether to successfully get the modem utilization
702 @retval QL_ERR_OK successful
703 @retval QL_ERR_NOT_INIT uninitialized
704 @retval QL_ERR_SERVICE_NOT_READY service is not ready
705 @retval QL_ERR_INVALID_ARG Invalid arguments
706 @retval Other error code defined by ql_type.h
707 */
708/*-----------------------------------------------------------------------------------------------*/
709int ql_dm_get_modem_cpu_occupancy(float *cpu_occupancy);
710
711/*-----------------------------------------------------------------------------------------------*/
712/**
713 @brief get modem mem utilization.
714 @param[out] mem_use The percentage of modem utilization
715 @return Whether to successfully get the modem utilization
716 @retval QL_ERR_OK successful
717 @retval QL_ERR_NOT_INIT uninitialized
718 @retval QL_ERR_SERVICE_NOT_READY service is not ready
719 @retval QL_ERR_INVALID_ARG Invalid arguments
720 @retval Other error code defined by ql_type.h
721 */
722/*-----------------------------------------------------------------------------------------------*/
723int ql_dm_get_modem_mem_usage(float *mem_use);
724
725/*-----------------------------------------------------------------------------------------------*/
726/**
727 @brief get QOOS enable state
728 @param[out] enable The enable state of QOOS
729 @return Whether to successfully get the QOOS enable state
730 @retval QL_ERR_OK successful
731 @retval QL_ERR_NOT_INIT uninitialized
732 @retval QL_ERR_SERVICE_NOT_READY service is not ready
733 @retval QL_ERR_INVALID_ARG Invalid arguments
734 @retval Other error code defined by ql_type.h
735 */
736/*-----------------------------------------------------------------------------------------------*/
737int ql_dm_get_qoos_enable(char *enable);
738
739/*-----------------------------------------------------------------------------------------------*/
740/**
741 @brief set QOOS enable state
742 @param[in] enable The enable state of QOOS
743 @return Whether to successfully set the QOOS enable state
744 @retval QL_ERR_OK successful
745 @retval QL_ERR_NOT_INIT uninitialized
746 @retval QL_ERR_SERVICE_NOT_READY service is not ready
747 @retval QL_ERR_INVALID_ARG Invalid arguments
748 @retval Other error code defined by ql_type.h
749 */
750/*-----------------------------------------------------------------------------------------------*/
751int ql_dm_set_qoos_enable(char enable);
752
753/*-----------------------------------------------------------------------------------------------*/
754/**
755 @brief get QOOS configuration
756 @param[out] config The configuration of QOOS
757 @return Whether to successfully get the QOOS configuration
758 @retval QL_ERR_OK successful
759 @retval QL_ERR_NOT_INIT uninitialized
760 @retval QL_ERR_SERVICE_NOT_READY service is not ready
761 @retval QL_ERR_INVALID_ARG Invalid arguments
762 @retval Other error code defined by ql_type.h
763 */
764/*-----------------------------------------------------------------------------------------------*/
765//int ql_dm_get_qoos_config(ql_dm_qoos_config_t *config);
766
767/*-----------------------------------------------------------------------------------------------*/
768/**
769 @brief set QOOS configuration
770 @param[in] config The configuration of QOOS
771 @return Whether to successfully set the QOOS configuration
772 @retval QL_ERR_OK successful
773 @retval QL_ERR_NOT_INIT uninitialized
774 @retval QL_ERR_SERVICE_NOT_READY service is not ready
775 @retval QL_ERR_INVALID_ARG Invalid arguments
776 @retval Other error code defined by ql_type.h
777 */
778/*-----------------------------------------------------------------------------------------------*/
779//int ql_dm_set_qoos_config(ql_dm_qoos_config_t config);
780
781/*-----------------------------------------------------------------------------------------------*/
782/**
783 @brief get MSSR(Modem SubSysem Reset) level.
784 @param[out] p_level The MSSR level
785 @return Whether to successfully get the MSSR level
786 @retval QL_ERR_OK successful
787 @retval QL_ERR_NOT_INIT uninitialized
788 @retval QL_ERR_SERVICE_NOT_READY service is not ready
789 @retval QL_ERR_INVALID_ARG Invalid arguments
790 @retval Other error code defined by ql_type.h
791 */
792/*-----------------------------------------------------------------------------------------------*/
793int ql_dm_get_mssr_level(int *p_level);
794
795/*-----------------------------------------------------------------------------------------------*/
796/**
797 @brief set MSSR(Modem SubSysem Reset) level.
798 @param[in] level The MSSR level
799 @return Whether to successfully set the MSSR level
800 @retval QL_ERR_OK successful
801 @retval QL_ERR_NOT_INIT uninitialized
802 @retval QL_ERR_SERVICE_NOT_READY service is not ready
803 @retval QL_ERR_INVALID_ARG Invalid arguments
804 @retval Other error code defined by ql_type.h
805 */
806/*-----------------------------------------------------------------------------------------------*/
807int ql_dm_set_mssr_level(int level);
808
809
810/*-----------------------------------------------------------------------------------------------*/
811/**
812 @brief bind subscription
813 @param[in] sub_type subscription type
814 @return Whether to successfully bind subscription.
815 @retval QL_ERR_OK successful
816 @retval QL_ERR_NOT_INIT uninitialized
817 @retval QL_ERR_SERVICE_NOT_READY service is not ready
818 @retval QL_ERR_INVALID_ARG Invalid arguments
819 @retval Other error code defined by ql_type.h
820 */
821/*-----------------------------------------------------------------------------------------------*/
822int ql_dm_bind_subscription(QL_DM_BIND_SUB_TYPE_E sub_type);
823
824/*-----------------------------------------------------------------------------------------------*/
825/**
826 @brief Registration server error callback. Currently, only if the server exits abnormally,
827 the callback function will be executed, and the error code is QL_ERR_ABORTED;
828 @param[in] cb Callback function
829 @return
830 QL_ERR_OK - successful
831 Other - error code defined by ql_type.h
832 */
833/*-----------------------------------------------------------------------------------------------*/
834int ql_dm_set_service_error_cb(ql_dm_service_error_cb_f cb)
835{
836 int ret = -1;
837 if(ql_info_handle == NULL)
838 {
839 LOGE("DM no init ");
840 return QL_ERR_NOT_INIT;
841
842 }
843 global_dm_error_cb = cb;
844 ret = mbtk_ril_ser_state_change_cb_reg(mbtk_dm_set_service_error_func);
845 if(ret != 0)
846 {
847 LOGE("call mbtk_ril_server_state_change_reg failed");
848 return QL_ERR_FAILED;
849 }
850
851 return QL_ERR_OK;
852}
853/*-----------------------------------------------------------------------------------------------*/
854/**
855 @brief Get module the last time shutdown reason
856 @param[out] shutdown_reason the shutdown reason
857 @return
858 QL_ERR_OK - successful
859 Other - error code defined by ql_type.h
860 */
861/*-----------------------------------------------------------------------------------------------*/
862int ql_dm_get_shutdown_reason(QL_DM_SHUTDOWN_REASON_E *shutdown_reason);
863
864/*-----------------------------------------------------------------------------------------------*/
865/**
866 @brief Get module this time bootup reason
867 @param[out] bootup_reason the bootup reason
868 @return
869 QL_ERR_OK - successful
870 Other - error code defined by ql_type.h
871 */
872/*-----------------------------------------------------------------------------------------------*/
873int ql_dm_get_bootup_reason(QL_DM_BOOT_UP_REASON_E *bootup_reason);
874
875/*-----------------------------------------------------------------------------------------------*/
876/**
877 @brief set oos config
878 @param[out] oos param
879 @return
880 QL_ERR_OK - successful
881 Other - error code defined by ql_type.h
882 */
883/*-----------------------------------------------------------------------------------------------*/
884int ql_dm_set_qoos_config(int p1, int p2, int p3);
885
886
887/*-----------------------------------------------------------------------------------------------*/
888/**
889 @brief get oos config
890 @param[out] oos param
891 @return
892 QL_ERR_OK - successful
893 Other - error code defined by ql_type.h
894 */
895/*-----------------------------------------------------------------------------------------------*/
896int ql_dm_get_qoos_config(int *p1, int *p2, int *p3);
897
898/*-----------------------------------------------------------------------------------------------*/
899/**
900 @brief set oos enable
901 @param[out] oos param
902 @return
903 QL_ERR_OK - successful
904 Other - error code defined by ql_type.h
905 */
906/*-----------------------------------------------------------------------------------------------*/
907int ql_dm_set_qoos_enable(char enable);
908#ifdef __cplusplus
909}
910#endif
911
912
913