blob: d6aabd27965d84eb4f1165e948c65ee60dfe5c5a [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
461 //ret = mbtk_get_modem_version(ql_info_handle, (void *)firmware_rev_id);
462 //mbtk_v2 do not have function
463 ret = -1;
464 if(ret < 0)
465 {
466 LOGE("get modem version failed");
467 return QL_ERR_FAILED;
468 }
469 return 0;
470}
471
472/*-----------------------------------------------------------------------------------------------*/
473/**
474 @brief get air plane mode.
475 @param[out] p_info Pointer that point to QL_DM_AIR_PLANE_MODE_TYPE_E
476 @return Whether to successfully get the air plane mode
477 @retval QL_ERR_OK successful
478 @retval QL_ERR_NOT_INIT uninitialized
479 @retval QL_ERR_SERVICE_NOT_READY service is not ready
480 @retval QL_ERR_INVALID_ARG Invalid arguments
481 @retval Other error code defined by ql_type.h
482 */
483/*-----------------------------------------------------------------------------------------------*/
484int ql_dm_get_air_plane_mode(QL_DM_AIR_PLANE_MODE_TYPE_E *p_info)
485{
486
487 int ret = -1;
488 mbtk_radio_state_enum tmp_rf;
489 if(ql_info_handle == NULL)
490 {
491 LOGE("DM no init");
492 return QL_ERR_NOT_INIT;
493 }
494 ret = mbtk_radio_state_get(ql_info_handle, &tmp_rf);
495 if (ret != 0)
496 {
497 LOGE("mbtk_radio_state_get fail.");
498 return QL_ERR_FAILED;
499 }
l.yang860a8e72025-05-13 01:55:38 -0700500 if(tmp_rf == MBTK_RADIO_STATE_FULL_FUNC )
b.liud440f9f2025-04-18 10:44:31 +0800501 {
502 *p_info = QL_DM_AIR_PLANE_MODE_OFF;
503 }
l.yang860a8e72025-05-13 01:55:38 -0700504 else if(tmp_rf == MBTK_RADIO_STATE_DIS_RF || tmp_rf == MBTK_RADIO_STATE_MINI_FUNC)
b.liud440f9f2025-04-18 10:44:31 +0800505 {
506 *p_info = QL_DM_AIR_PLANE_MODE_ON;
507 }
508
509 return 0;
510
511}
512
513/*-----------------------------------------------------------------------------------------------*/
514/**
515 @brief set air plane mode.
516 @param[in] air_plane_mode 1:ON, 2:OFF
517 @return Whether to successfully set the air plane mode
518 @retval QL_ERR_OK successful
519 @retval QL_ERR_NOT_INIT uninitialized
520 @retval QL_ERR_SERVICE_NOT_READY service is not ready
521 @retval QL_ERR_INVALID_ARG Invalid arguments
522 @retval Other error code defined by ql_type.h
523 */
524/*-----------------------------------------------------------------------------------------------*/
525
526
527int ql_dm_set_air_plane_mode(QL_DM_AIR_PLANE_MODE_TYPE_E air_plane_mode)
528{
l.yang860a8e72025-05-13 01:55:38 -0700529 //mbtk_radio_state_enum radio = MBTK_RADIO_STATE_MINI_FUNC;
b.liud440f9f2025-04-18 10:44:31 +0800530 int reset = 0;
531 int rf_mode = -1;
532 int ret = -1;
533
534 if(ql_info_handle == NULL)
535 {
536 LOGE("DM no init");
537 return QL_ERR_NOT_INIT;
538 }
539 if(air_plane_mode == QL_DM_AIR_PLANE_MODE_ON)
540 {
l.yang860a8e72025-05-13 01:55:38 -0700541 rf_mode = MBTK_RADIO_STATE_DIS_RF;
b.liud440f9f2025-04-18 10:44:31 +0800542 }
543
544 if(air_plane_mode == QL_DM_AIR_PLANE_MODE_OFF)
545 {
546 rf_mode = LYNQ_AIR_PLANE_MODE_OFF;
547
548 }
549
l.yang860a8e72025-05-13 01:55:38 -0700550 if (rf_mode != MBTK_RADIO_STATE_DIS_RF && rf_mode != MBTK_RADIO_STATE_FULL_FUNC)
b.liud440f9f2025-04-18 10:44:31 +0800551 {
552 LOGE("Input mode is error!");
553 return QL_ERR_OP_UNSUPPORTED;
554 }
555
556
l.yang860a8e72025-05-13 01:55:38 -0700557 ret = mbtk_radio_state_set(ql_info_handle, rf_mode, reset);
b.liud440f9f2025-04-18 10:44:31 +0800558 if(ret != 0)
559 {
560 LOGE("ql_dm_set_air_plane_mode failed");
561 }
562 mbtk_send_singnal();
563 return QL_ERR_OK;
564
565
566}
567/*-----------------------------------------------------------------------------------------------*/
568/**
569 @brief register air plane mode event.
570 @param[in] cb_func Air plane mode indication callback function
571 @return Whether the air plane mode event was successfully registered.
572 @retval QL_ERR_OK successful
573 @retval QL_ERR_NOT_INIT uninitialized
574 @retval QL_ERR_SERVICE_NOT_READY service is not ready
575 @retval QL_ERR_INVALID_ARG Invalid arguments
576 @retval Other error code defined by ql_type.h
577 */
578/*-----------------------------------------------------------------------------------------------*/
579
580int ql_dm_set_air_plane_mode_ind_cb(ql_dm_air_plane_mode_ind_cb cb_func)
581{
582 if(ql_info_handle == NULL)
583 {
584 LOGE("No init ");
585 return QL_ERR_NOT_INIT;
586 }
587
588 g_air_plane_mode_cb = cb_func;
589
590 if (!g_thread_running)
591 {
592 g_thread_running = true;
593 if (pthread_create(&g_air_plane_mode_thread, NULL, air_plane_mode_monitor, NULL) != 0)
594 {
595 LOGE("Failed to create air plane mode monitor thread");
596 g_thread_running = false;
597 return QL_ERR_FAILED;
598 }
599 }
600
601 return QL_ERR_OK;
602}
603
604
605/*-----------------------------------------------------------------------------------------------*/
606/**
607 @brief get cpu occupancy.
608 @param[out] cpu_occupancy The percentage of cpu occupancy
609 @return Whether to successfully get the cpu occupancy
610 @retval QL_ERR_OK successful
611 @retval QL_ERR_NOT_INIT uninitialized
612 @retval QL_ERR_SERVICE_NOT_READY service is not ready
613 @retval QL_ERR_INVALID_ARG Invalid arguments
614 @retval Other error code defined by ql_type.h
615 */
616/*-----------------------------------------------------------------------------------------------*/
617int ql_dm_get_cpu_occupancy(float *cpu_occupancy);
618
619
620/*-----------------------------------------------------------------------------------------------*/
621/**
622 @brief get mem usage.
623 @param[out] mem_use The percentage of mem usage
624 @return Whether to successfully get the memory usage
625 @retval QL_ERR_OK successful
626 @retval QL_ERR_NOT_INIT uninitialized
627 @retval QL_ERR_SERVICE_NOT_READY service is not ready
628 @retval QL_ERR_INVALID_ARG Invalid arguments
629 @retval Other error code defined by ql_type.h
630 */
631/*-----------------------------------------------------------------------------------------------*/
632int ql_dm_get_mem_usage(float *mem_use);
633
634
635/*-----------------------------------------------------------------------------------------------*/
636/**
637 @brief get NV item value.
638 @param[in] nv_item_name The NV item name that is either NV item id or NV item path
639 @param[out] nv_item_value The NV value buf of nv_item_name
640 param[in] nv_item_value_len The length of nv_item_value
641 param[out] nv_len The real length of nv_item_name
642 @return Whether to successfully get the NV value
643 @retval QL_ERR_OK successful
644 @retval QL_ERR_NOT_INIT uninitialized
645 @retval QL_ERR_SERVICE_NOT_READY service is not ready
646 @retval QL_ERR_INVALID_ARG Invalid arguments
647 @retval Other error code defined by ql_type.h
648 */
649/*-----------------------------------------------------------------------------------------------*/
650int ql_dm_get_nv_item_value(char *nv_item_name, unsigned char *nv_item_value, int nv_item_value_len,
651 int *nv_len);
652
653/*-----------------------------------------------------------------------------------------------*/
654/**
655 @brief set NV item value.
656 @param[in] nv_item_name The NV item name that is either NV item id or NV item path
657 @param[in] nv_item_value The NV value of nv_item_name
658 @param[in] nv_item_value_len The length of nv_item_value
659 param[out] nv_len The real length of nv_item_name
660 @return Whether to successfully set the NV value
661 @retval QL_ERR_OK successful
662 @retval QL_ERR_NOT_INIT uninitialized
663 @retval QL_ERR_SERVICE_NOT_READY service is not ready
664 @retval QL_ERR_INVALID_ARG Invalid arguments
665 @retval Other error code defined by ql_type.h
666 */
667/*-----------------------------------------------------------------------------------------------*/
668int ql_dm_set_nv_item_value(char *nv_item_name, unsigned char *nv_item_value, int nv_item_value_len,
669 int *nv_len);
670
671
672/*-----------------------------------------------------------------------------------------------*/
673/**
674 @brief set radio on, its function is the same as at+cfun=1.
675 @return Whether to successfully set the radio on
676 @retval QL_ERR_OK successful
677 @retval QL_ERR_NOT_INIT uninitialized
678 @retval QL_ERR_SERVICE_NOT_READY service is not ready
679 @retval QL_ERR_INVALID_ARG Invalid arguments
680 @retval Other error code defined by ql_type.h
681 */
682/*-----------------------------------------------------------------------------------------------*/
683int ql_dm_set_radio_on(void);
684
685/*-----------------------------------------------------------------------------------------------*/
686/**
687 @brief set radio off, its function is the same as at+cfun=0.
688 @return Whether to successfully set the radio off
689 @retval QL_ERR_OK successful
690 @retval QL_ERR_NOT_INIT uninitialized
691 @retval QL_ERR_SERVICE_NOT_READY service is not ready
692 @retval QL_ERR_INVALID_ARG Invalid arguments
693 @retval Other error code defined by ql_type.h
694 */
695/*-----------------------------------------------------------------------------------------------*/
696int ql_dm_set_radio_off(void);
697
698/*-----------------------------------------------------------------------------------------------*/
699/**
700 @brief get modem mem and CPU utilization.
701 @param[out] mem_use The percentage of modem utilization
702 @return Whether to successfully get the modem utilization
703 @retval QL_ERR_OK successful
704 @retval QL_ERR_NOT_INIT uninitialized
705 @retval QL_ERR_SERVICE_NOT_READY service is not ready
706 @retval QL_ERR_INVALID_ARG Invalid arguments
707 @retval Other error code defined by ql_type.h
708 */
709/*-----------------------------------------------------------------------------------------------*/
710int ql_dm_get_modem_cpu_occupancy(float *cpu_occupancy);
711
712/*-----------------------------------------------------------------------------------------------*/
713/**
714 @brief get modem mem utilization.
715 @param[out] mem_use The percentage of modem utilization
716 @return Whether to successfully get the modem utilization
717 @retval QL_ERR_OK successful
718 @retval QL_ERR_NOT_INIT uninitialized
719 @retval QL_ERR_SERVICE_NOT_READY service is not ready
720 @retval QL_ERR_INVALID_ARG Invalid arguments
721 @retval Other error code defined by ql_type.h
722 */
723/*-----------------------------------------------------------------------------------------------*/
724int ql_dm_get_modem_mem_usage(float *mem_use);
725
726/*-----------------------------------------------------------------------------------------------*/
727/**
728 @brief get QOOS enable state
729 @param[out] enable The enable state of QOOS
730 @return Whether to successfully get the QOOS enable state
731 @retval QL_ERR_OK successful
732 @retval QL_ERR_NOT_INIT uninitialized
733 @retval QL_ERR_SERVICE_NOT_READY service is not ready
734 @retval QL_ERR_INVALID_ARG Invalid arguments
735 @retval Other error code defined by ql_type.h
736 */
737/*-----------------------------------------------------------------------------------------------*/
738int ql_dm_get_qoos_enable(char *enable);
739
740/*-----------------------------------------------------------------------------------------------*/
741/**
742 @brief set QOOS enable state
743 @param[in] enable The enable state of QOOS
744 @return Whether to successfully set the QOOS enable state
745 @retval QL_ERR_OK successful
746 @retval QL_ERR_NOT_INIT uninitialized
747 @retval QL_ERR_SERVICE_NOT_READY service is not ready
748 @retval QL_ERR_INVALID_ARG Invalid arguments
749 @retval Other error code defined by ql_type.h
750 */
751/*-----------------------------------------------------------------------------------------------*/
752int ql_dm_set_qoos_enable(char enable);
753
754/*-----------------------------------------------------------------------------------------------*/
755/**
756 @brief get QOOS configuration
757 @param[out] config The configuration of QOOS
758 @return Whether to successfully get the QOOS configuration
759 @retval QL_ERR_OK successful
760 @retval QL_ERR_NOT_INIT uninitialized
761 @retval QL_ERR_SERVICE_NOT_READY service is not ready
762 @retval QL_ERR_INVALID_ARG Invalid arguments
763 @retval Other error code defined by ql_type.h
764 */
765/*-----------------------------------------------------------------------------------------------*/
766//int ql_dm_get_qoos_config(ql_dm_qoos_config_t *config);
767
768/*-----------------------------------------------------------------------------------------------*/
769/**
770 @brief set QOOS configuration
771 @param[in] config The configuration of QOOS
772 @return Whether to successfully set the QOOS configuration
773 @retval QL_ERR_OK successful
774 @retval QL_ERR_NOT_INIT uninitialized
775 @retval QL_ERR_SERVICE_NOT_READY service is not ready
776 @retval QL_ERR_INVALID_ARG Invalid arguments
777 @retval Other error code defined by ql_type.h
778 */
779/*-----------------------------------------------------------------------------------------------*/
780//int ql_dm_set_qoos_config(ql_dm_qoos_config_t config);
781
782/*-----------------------------------------------------------------------------------------------*/
783/**
784 @brief get MSSR(Modem SubSysem Reset) level.
785 @param[out] p_level The MSSR level
786 @return Whether to successfully get the MSSR level
787 @retval QL_ERR_OK successful
788 @retval QL_ERR_NOT_INIT uninitialized
789 @retval QL_ERR_SERVICE_NOT_READY service is not ready
790 @retval QL_ERR_INVALID_ARG Invalid arguments
791 @retval Other error code defined by ql_type.h
792 */
793/*-----------------------------------------------------------------------------------------------*/
794int ql_dm_get_mssr_level(int *p_level);
795
796/*-----------------------------------------------------------------------------------------------*/
797/**
798 @brief set MSSR(Modem SubSysem Reset) level.
799 @param[in] level The MSSR level
800 @return Whether to successfully set the MSSR level
801 @retval QL_ERR_OK successful
802 @retval QL_ERR_NOT_INIT uninitialized
803 @retval QL_ERR_SERVICE_NOT_READY service is not ready
804 @retval QL_ERR_INVALID_ARG Invalid arguments
805 @retval Other error code defined by ql_type.h
806 */
807/*-----------------------------------------------------------------------------------------------*/
808int ql_dm_set_mssr_level(int level);
809
810
811/*-----------------------------------------------------------------------------------------------*/
812/**
813 @brief bind subscription
814 @param[in] sub_type subscription type
815 @return Whether to successfully bind subscription.
816 @retval QL_ERR_OK successful
817 @retval QL_ERR_NOT_INIT uninitialized
818 @retval QL_ERR_SERVICE_NOT_READY service is not ready
819 @retval QL_ERR_INVALID_ARG Invalid arguments
820 @retval Other error code defined by ql_type.h
821 */
822/*-----------------------------------------------------------------------------------------------*/
823int ql_dm_bind_subscription(QL_DM_BIND_SUB_TYPE_E sub_type);
824
825/*-----------------------------------------------------------------------------------------------*/
826/**
827 @brief Registration server error callback. Currently, only if the server exits abnormally,
828 the callback function will be executed, and the error code is QL_ERR_ABORTED;
829 @param[in] cb Callback function
830 @return
831 QL_ERR_OK - successful
832 Other - error code defined by ql_type.h
833 */
834/*-----------------------------------------------------------------------------------------------*/
835int ql_dm_set_service_error_cb(ql_dm_service_error_cb_f cb)
836{
837 int ret = -1;
838 if(ql_info_handle == NULL)
839 {
840 LOGE("DM no init ");
841 return QL_ERR_NOT_INIT;
842
843 }
844 global_dm_error_cb = cb;
845 ret = mbtk_ril_ser_state_change_cb_reg(mbtk_dm_set_service_error_func);
846 if(ret != 0)
847 {
848 LOGE("call mbtk_ril_server_state_change_reg failed");
849 return QL_ERR_FAILED;
850 }
851
852 return QL_ERR_OK;
853}
854/*-----------------------------------------------------------------------------------------------*/
855/**
856 @brief Get module the last time shutdown reason
857 @param[out] shutdown_reason the shutdown reason
858 @return
859 QL_ERR_OK - successful
860 Other - error code defined by ql_type.h
861 */
862/*-----------------------------------------------------------------------------------------------*/
863int ql_dm_get_shutdown_reason(QL_DM_SHUTDOWN_REASON_E *shutdown_reason);
864
865/*-----------------------------------------------------------------------------------------------*/
866/**
867 @brief Get module this time bootup reason
868 @param[out] bootup_reason the bootup reason
869 @return
870 QL_ERR_OK - successful
871 Other - error code defined by ql_type.h
872 */
873/*-----------------------------------------------------------------------------------------------*/
874int ql_dm_get_bootup_reason(QL_DM_BOOT_UP_REASON_E *bootup_reason);
875
876/*-----------------------------------------------------------------------------------------------*/
877/**
878 @brief set oos config
879 @param[out] oos param
880 @return
881 QL_ERR_OK - successful
882 Other - error code defined by ql_type.h
883 */
884/*-----------------------------------------------------------------------------------------------*/
885int ql_dm_set_qoos_config(int p1, int p2, int p3);
886
887
888/*-----------------------------------------------------------------------------------------------*/
889/**
890 @brief get oos config
891 @param[out] oos param
892 @return
893 QL_ERR_OK - successful
894 Other - error code defined by ql_type.h
895 */
896/*-----------------------------------------------------------------------------------------------*/
897int ql_dm_get_qoos_config(int *p1, int *p2, int *p3);
898
899/*-----------------------------------------------------------------------------------------------*/
900/**
901 @brief set oos enable
902 @param[out] oos param
903 @return
904 QL_ERR_OK - successful
905 Other - error code defined by ql_type.h
906 */
907/*-----------------------------------------------------------------------------------------------*/
908int ql_dm_set_qoos_enable(char enable);
909#ifdef __cplusplus
910}
911#endif
912
913
914