blob: 867c4fd6751d71cbf1e7da3f71a6acedbe693382 [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
114 if(mbtk_info == LYNQ_AIR_PLANE_MODE_OFF)
115 {
116 ql_info = QL_DM_AIR_PLANE_MODE_OFF;
117 }
118
119 if(mbtk_info == LYNQ_AIR_PLANE_MODE_ON)
120 {
121 ql_info = QL_DM_AIR_PLANE_MODE_ON;
122 }
123
124 if(mbtk_info != LYNQ_AIR_PLANE_MODE_OFF && mbtk_info !=LYNQ_AIR_PLANE_MODE_ON)
125 {
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 {
202 LOGI("mbtk_info_handle_free success");
203 return QL_ERR_OK;
204 }
205 }
206 else
207 {
208 LOGE("DM not inited.");
209 return QL_ERR_NOT_INIT;
210 }
211
212}
213
214/*-----------------------------------------------------------------------------------------------*/
215/**
216 @brief get device software version.
217 @param[out] soft_ver Return software version
218 @param[in] soft_ver_len The length of soft_ver
219 @return Whether to successfully get the software version
220 @retval QL_ERR_OK successful
221 @retval QL_ERR_NOT_INIT uninitialized
222 @retval QL_ERR_SERVICE_NOT_READY service is not ready
223 @retval QL_ERR_INVALID_ARG Invalid arguments
224 @retval Other error code defined by ql_type.h
225 */
226/*-----------------------------------------------------------------------------------------------*/
227
228int ql_dm_get_software_version(char *soft_ver, int soft_ver_len)
229{
230
231 int ret = -1;
232 if(soft_ver == NULL || soft_ver_len <= 0)
233 {
234 LOGE("Bad parameters ");
235 return QL_ERR_FAILED;
236 }
237 if(ql_info_handle != NULL)
238 {
239
240 ret = mbtk_version_get(ql_info_handle,soft_ver);
241 if(ret != 0)
242 {
243 LOGE("ql_dm_get_software_version error.");
244 return QL_ERR_FAILED;
245 }
246 }
247 else
248 {
249 mbtk_ril_handle* mbtk_info_handle = NULL;
250 mbtk_info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
251 if(mbtk_info_handle == NULL)
252 {
253 LOGE("mbtk_info_handle_get fail.");
254 return QL_ERR_FAILED;
255 }
256 ret = mbtk_version_get(mbtk_info_handle,soft_ver);
257 if(ret != 0)
258 {
259 LOGE("ql_dm_get_software_version error.");
260
261 }
262 ret = mbtk_ril_close(MBTK_AT_PORT_DEF);
263 if(ret != 0)
264 {
265 LOGE("mbtk_info_handle_free fail.");
266 return QL_ERR_FAILED;
267 }
268
269 }
270 return QL_ERR_OK;
271
272
273}
274
275/*-----------------------------------------------------------------------------------------------*/
276/**
277 @brief get modem state.
278 @details QL_DM_MODEM_STATE_ONLINE,if modem starts normally.
279 @details QL_DM_MODEM_STATE_OFFLINE,in modem starts abnormally.
280 @details QL_DM_MODEM_STATE_UNKNOWN,unknown error.
281 @param[out] modem_state The state of modem
282 @return Whether to successfully get the modem state
283 @retval QL_ERR_OK successful
284 @retval QL_ERR_NOT_INIT uninitialized
285 @retval QL_ERR_SERVICE_NOT_READY service is not ready
286 @retval QL_ERR_INVALID_ARG Invalid arguments
287 @retval Other error code defined by ql_type.h
288 */
289/*-----------------------------------------------------------------------------------------------*/
290int ql_dm_get_modem_state(QL_DM_MODEM_STATE_TYPE_E *modem_state);
291
292/*-----------------------------------------------------------------------------------------------*/
293/**
294 @brief register modem state event.
295 @param[in] cb_func modem state indication callback function
296 @return Whether the modem state event was successfully registered.
297 @retval QL_ERR_OK successful
298 @retval QL_ERR_NOT_INIT uninitialized
299 @retval QL_ERR_SERVICE_NOT_READY service is not ready
300 @retval QL_ERR_INVALID_ARG Invalid arguments
301 @retval Other error code defined by ql_type.h
302 */
303/*-----------------------------------------------------------------------------------------------*/
304
305int ql_dm_set_modem_state_change_ind_cb(ql_dm_modem_state_ind_cb cb_func)
306{
307
308 int ret =-1;
309
310 global_dm_modem_cb = cb_func;
311
312 if(ql_info_handle != NULL)
313 {
314
315 ret = mbtk_radio_state_change_cb_reg(mbtk_modem_state_change_cb);
316 if(ret != 0)
317 {
318 LOGE("call mbtk_radio_state_change_cb_reg failed");
319 return QL_ERR_FAILED;
320 }
321 }
322 else
323 {
324 if(g_md_version_handle == NULL)
325 {
326 g_md_version_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
327 if(g_md_version_handle == NULL)
328 {
329 LOGE("g_md_version_handle get fail.");
330 return QL_ERR_FAILED;
331 }
332 }
333
334 ret = mbtk_radio_state_change_cb_reg(mbtk_modem_state_change_cb);
335 if(ret != 0)
336 {
337
338 ret = mbtk_ril_close(MBTK_AT_PORT_DEF);
339 if(ret < 0)
340 {
341 LOGE("mbtk_info_handle_free fail.");
342 return QL_ERR_FAILED;
343 }
344
345 LOGE("call mbtk_radio_state_change_cb_reg failed");
346 return QL_ERR_FAILED;
347 }
348
349 }
350
351 return QL_ERR_OK;
352}
353
354/*-----------------------------------------------------------------------------------------------*/
355/**
356 @brief get module temperature.
357 @param[out] temperature The current temperature
358 @return Whether to successfully get the temperature
359 @retval QL_ERR_OK successful
360 @retval QL_ERR_NOT_INIT uninitialized
361 @retval QL_ERR_SERVICE_NOT_READY service is not ready
362 @retval QL_ERR_INVALID_ARG Invalid arguments
363 @retval Other error code defined by ql_type.h
364 */
365/*-----------------------------------------------------------------------------------------------*/
366int ql_dm_get_temperature(float *temperature);
367
368
369/*-----------------------------------------------------------------------------------------------*/
370/**
371 @brief get device serial numbers.
372 @param[out] p_info Pointer that point to ql_dm_device_serial_numbers_info_t
373 @return Whether to successfully get the serial numbers
374 @retval QL_ERR_OK successful
375 @retval QL_ERR_NOT_INIT uninitialized
376 @retval QL_ERR_SERVICE_NOT_READY service is not ready
377 @retval QL_ERR_INVALID_ARG Invalid arguments
378 @retval Other error code defined by ql_type.h
379 */
380/*-----------------------------------------------------------------------------------------------*/
381int ql_dm_get_device_serial_numbers(ql_dm_device_serial_numbers_info_t *p_info)
382{
383 int ret = -1;
384 if(ql_info_handle == NULL )
385 {
386 LOGE("DM no init");
387 return QL_ERR_NOT_INIT;
388 }
389
390 ret = mbtk_imei_get(ql_info_handle, p_info->imei);
391 if(ret != 0)
392 {
393 LOGE("Error : %d\n", ret);
394 return QL_ERR_FAILED;
395 }
396 if(strlen(p_info->imei) > 0)
397 {
398 p_info->imei_valid = IMEI_VALID;
399 }
400
401
402 return QL_ERR_OK;
403
404}
405
406/*-----------------------------------------------------------------------------------------------*/
407/**
408 @brief get device firmware revision identification.
409 @param[out] firmware_rev_id Return device firmware revision id
410 @param[in] firmware_rev_id_len The length of firmware_rev_id
411 @return Whether to successfully get the firmware revision id
412 @retval QL_ERR_OK successful
413 @retval QL_ERR_NOT_INIT uninitialized
414 @retval QL_ERR_SERVICE_NOT_READY service is not ready
415 @retval QL_ERR_INVALID_ARG Invalid arguments
416 @retval Other error code defined by ql_type.h
417 */
418/*-----------------------------------------------------------------------------------------------*/
419int ql_dm_get_device_firmware_rev_id(char *firmware_rev_id, int firmware_rev_id_len)
420{
421 int ret = -1;
422
423 if(ql_info_handle == NULL)
424 {
425 LOGE("DM no init");
426 return QL_ERR_NOT_INIT;
427 }
428
429 //ret = mbtk_get_modem_version(ql_info_handle, (void *)firmware_rev_id);
430 //mbtk_v2 do not have function
431 ret = -1;
432 if(ret < 0)
433 {
434 LOGE("get modem version failed");
435 return QL_ERR_FAILED;
436 }
437 return 0;
438}
439
440/*-----------------------------------------------------------------------------------------------*/
441/**
442 @brief get air plane mode.
443 @param[out] p_info Pointer that point to QL_DM_AIR_PLANE_MODE_TYPE_E
444 @return Whether to successfully get the air plane mode
445 @retval QL_ERR_OK successful
446 @retval QL_ERR_NOT_INIT uninitialized
447 @retval QL_ERR_SERVICE_NOT_READY service is not ready
448 @retval QL_ERR_INVALID_ARG Invalid arguments
449 @retval Other error code defined by ql_type.h
450 */
451/*-----------------------------------------------------------------------------------------------*/
452int ql_dm_get_air_plane_mode(QL_DM_AIR_PLANE_MODE_TYPE_E *p_info)
453{
454
455 int ret = -1;
456 mbtk_radio_state_enum tmp_rf;
457 if(ql_info_handle == NULL)
458 {
459 LOGE("DM no init");
460 return QL_ERR_NOT_INIT;
461 }
462 ret = mbtk_radio_state_get(ql_info_handle, &tmp_rf);
463 if (ret != 0)
464 {
465 LOGE("mbtk_radio_state_get fail.");
466 return QL_ERR_FAILED;
467 }
468 if(tmp_rf == LYNQ_AIR_PLANE_MODE_OFF)
469 {
470 *p_info = QL_DM_AIR_PLANE_MODE_OFF;
471 }
472 else if(tmp_rf == LYNQ_AIR_PLANE_MODE_ON)
473 {
474 *p_info = QL_DM_AIR_PLANE_MODE_ON;
475 }
476
477 return 0;
478
479}
480
481/*-----------------------------------------------------------------------------------------------*/
482/**
483 @brief set air plane mode.
484 @param[in] air_plane_mode 1:ON, 2:OFF
485 @return Whether to successfully set the air plane mode
486 @retval QL_ERR_OK successful
487 @retval QL_ERR_NOT_INIT uninitialized
488 @retval QL_ERR_SERVICE_NOT_READY service is not ready
489 @retval QL_ERR_INVALID_ARG Invalid arguments
490 @retval Other error code defined by ql_type.h
491 */
492/*-----------------------------------------------------------------------------------------------*/
493
494
495int ql_dm_set_air_plane_mode(QL_DM_AIR_PLANE_MODE_TYPE_E air_plane_mode)
496{
497 mbtk_radio_state_enum radio = MBTK_RADIO_STATE_MINI_FUNC;
498 int reset = 0;
499 int rf_mode = -1;
500 int ret = -1;
501
502 if(ql_info_handle == NULL)
503 {
504 LOGE("DM no init");
505 return QL_ERR_NOT_INIT;
506 }
507 if(air_plane_mode == QL_DM_AIR_PLANE_MODE_ON)
508 {
509 rf_mode = LYNQ_AIR_PLANE_MODE_ON;
510 }
511
512 if(air_plane_mode == QL_DM_AIR_PLANE_MODE_OFF)
513 {
514 rf_mode = LYNQ_AIR_PLANE_MODE_OFF;
515
516 }
517
518 if (rf_mode != LYNQ_AIR_PLANE_MODE_ON && rf_mode != LYNQ_AIR_PLANE_MODE_OFF)
519 {
520 LOGE("Input mode is error!");
521 return QL_ERR_OP_UNSUPPORTED;
522 }
523
524
525 ret = mbtk_radio_state_set(ql_info_handle, radio, reset);
526 if(ret != 0)
527 {
528 LOGE("ql_dm_set_air_plane_mode failed");
529 }
530 mbtk_send_singnal();
531 return QL_ERR_OK;
532
533
534}
535/*-----------------------------------------------------------------------------------------------*/
536/**
537 @brief register air plane mode event.
538 @param[in] cb_func Air plane mode indication callback function
539 @return Whether the air plane mode event was successfully registered.
540 @retval QL_ERR_OK successful
541 @retval QL_ERR_NOT_INIT uninitialized
542 @retval QL_ERR_SERVICE_NOT_READY service is not ready
543 @retval QL_ERR_INVALID_ARG Invalid arguments
544 @retval Other error code defined by ql_type.h
545 */
546/*-----------------------------------------------------------------------------------------------*/
547
548int ql_dm_set_air_plane_mode_ind_cb(ql_dm_air_plane_mode_ind_cb cb_func)
549{
550 if(ql_info_handle == NULL)
551 {
552 LOGE("No init ");
553 return QL_ERR_NOT_INIT;
554 }
555
556 g_air_plane_mode_cb = cb_func;
557
558 if (!g_thread_running)
559 {
560 g_thread_running = true;
561 if (pthread_create(&g_air_plane_mode_thread, NULL, air_plane_mode_monitor, NULL) != 0)
562 {
563 LOGE("Failed to create air plane mode monitor thread");
564 g_thread_running = false;
565 return QL_ERR_FAILED;
566 }
567 }
568
569 return QL_ERR_OK;
570}
571
572
573/*-----------------------------------------------------------------------------------------------*/
574/**
575 @brief get cpu occupancy.
576 @param[out] cpu_occupancy The percentage of cpu occupancy
577 @return Whether to successfully get the cpu occupancy
578 @retval QL_ERR_OK successful
579 @retval QL_ERR_NOT_INIT uninitialized
580 @retval QL_ERR_SERVICE_NOT_READY service is not ready
581 @retval QL_ERR_INVALID_ARG Invalid arguments
582 @retval Other error code defined by ql_type.h
583 */
584/*-----------------------------------------------------------------------------------------------*/
585int ql_dm_get_cpu_occupancy(float *cpu_occupancy);
586
587
588/*-----------------------------------------------------------------------------------------------*/
589/**
590 @brief get mem usage.
591 @param[out] mem_use The percentage of mem usage
592 @return Whether to successfully get the memory usage
593 @retval QL_ERR_OK successful
594 @retval QL_ERR_NOT_INIT uninitialized
595 @retval QL_ERR_SERVICE_NOT_READY service is not ready
596 @retval QL_ERR_INVALID_ARG Invalid arguments
597 @retval Other error code defined by ql_type.h
598 */
599/*-----------------------------------------------------------------------------------------------*/
600int ql_dm_get_mem_usage(float *mem_use);
601
602
603/*-----------------------------------------------------------------------------------------------*/
604/**
605 @brief get NV item value.
606 @param[in] nv_item_name The NV item name that is either NV item id or NV item path
607 @param[out] nv_item_value The NV value buf of nv_item_name
608 param[in] nv_item_value_len The length of nv_item_value
609 param[out] nv_len The real length of nv_item_name
610 @return Whether to successfully get the NV value
611 @retval QL_ERR_OK successful
612 @retval QL_ERR_NOT_INIT uninitialized
613 @retval QL_ERR_SERVICE_NOT_READY service is not ready
614 @retval QL_ERR_INVALID_ARG Invalid arguments
615 @retval Other error code defined by ql_type.h
616 */
617/*-----------------------------------------------------------------------------------------------*/
618int ql_dm_get_nv_item_value(char *nv_item_name, unsigned char *nv_item_value, int nv_item_value_len,
619 int *nv_len);
620
621/*-----------------------------------------------------------------------------------------------*/
622/**
623 @brief set NV item value.
624 @param[in] nv_item_name The NV item name that is either NV item id or NV item path
625 @param[in] nv_item_value The NV value of nv_item_name
626 @param[in] nv_item_value_len The length of nv_item_value
627 param[out] nv_len The real length of nv_item_name
628 @return Whether to successfully set the NV value
629 @retval QL_ERR_OK successful
630 @retval QL_ERR_NOT_INIT uninitialized
631 @retval QL_ERR_SERVICE_NOT_READY service is not ready
632 @retval QL_ERR_INVALID_ARG Invalid arguments
633 @retval Other error code defined by ql_type.h
634 */
635/*-----------------------------------------------------------------------------------------------*/
636int ql_dm_set_nv_item_value(char *nv_item_name, unsigned char *nv_item_value, int nv_item_value_len,
637 int *nv_len);
638
639
640/*-----------------------------------------------------------------------------------------------*/
641/**
642 @brief set radio on, its function is the same as at+cfun=1.
643 @return Whether to successfully set the radio on
644 @retval QL_ERR_OK successful
645 @retval QL_ERR_NOT_INIT uninitialized
646 @retval QL_ERR_SERVICE_NOT_READY service is not ready
647 @retval QL_ERR_INVALID_ARG Invalid arguments
648 @retval Other error code defined by ql_type.h
649 */
650/*-----------------------------------------------------------------------------------------------*/
651int ql_dm_set_radio_on(void);
652
653/*-----------------------------------------------------------------------------------------------*/
654/**
655 @brief set radio off, its function is the same as at+cfun=0.
656 @return Whether to successfully set the radio off
657 @retval QL_ERR_OK successful
658 @retval QL_ERR_NOT_INIT uninitialized
659 @retval QL_ERR_SERVICE_NOT_READY service is not ready
660 @retval QL_ERR_INVALID_ARG Invalid arguments
661 @retval Other error code defined by ql_type.h
662 */
663/*-----------------------------------------------------------------------------------------------*/
664int ql_dm_set_radio_off(void);
665
666/*-----------------------------------------------------------------------------------------------*/
667/**
668 @brief get modem mem and CPU utilization.
669 @param[out] mem_use The percentage of modem utilization
670 @return Whether to successfully get the modem utilization
671 @retval QL_ERR_OK successful
672 @retval QL_ERR_NOT_INIT uninitialized
673 @retval QL_ERR_SERVICE_NOT_READY service is not ready
674 @retval QL_ERR_INVALID_ARG Invalid arguments
675 @retval Other error code defined by ql_type.h
676 */
677/*-----------------------------------------------------------------------------------------------*/
678int ql_dm_get_modem_cpu_occupancy(float *cpu_occupancy);
679
680/*-----------------------------------------------------------------------------------------------*/
681/**
682 @brief get modem mem utilization.
683 @param[out] mem_use The percentage of modem utilization
684 @return Whether to successfully get the modem utilization
685 @retval QL_ERR_OK successful
686 @retval QL_ERR_NOT_INIT uninitialized
687 @retval QL_ERR_SERVICE_NOT_READY service is not ready
688 @retval QL_ERR_INVALID_ARG Invalid arguments
689 @retval Other error code defined by ql_type.h
690 */
691/*-----------------------------------------------------------------------------------------------*/
692int ql_dm_get_modem_mem_usage(float *mem_use);
693
694/*-----------------------------------------------------------------------------------------------*/
695/**
696 @brief get QOOS enable state
697 @param[out] enable The enable state of QOOS
698 @return Whether to successfully get the QOOS enable state
699 @retval QL_ERR_OK successful
700 @retval QL_ERR_NOT_INIT uninitialized
701 @retval QL_ERR_SERVICE_NOT_READY service is not ready
702 @retval QL_ERR_INVALID_ARG Invalid arguments
703 @retval Other error code defined by ql_type.h
704 */
705/*-----------------------------------------------------------------------------------------------*/
706int ql_dm_get_qoos_enable(char *enable);
707
708/*-----------------------------------------------------------------------------------------------*/
709/**
710 @brief set QOOS enable state
711 @param[in] enable The enable state of QOOS
712 @return Whether to successfully set the QOOS enable state
713 @retval QL_ERR_OK successful
714 @retval QL_ERR_NOT_INIT uninitialized
715 @retval QL_ERR_SERVICE_NOT_READY service is not ready
716 @retval QL_ERR_INVALID_ARG Invalid arguments
717 @retval Other error code defined by ql_type.h
718 */
719/*-----------------------------------------------------------------------------------------------*/
720int ql_dm_set_qoos_enable(char enable);
721
722/*-----------------------------------------------------------------------------------------------*/
723/**
724 @brief get QOOS configuration
725 @param[out] config The configuration of QOOS
726 @return Whether to successfully get the QOOS configuration
727 @retval QL_ERR_OK successful
728 @retval QL_ERR_NOT_INIT uninitialized
729 @retval QL_ERR_SERVICE_NOT_READY service is not ready
730 @retval QL_ERR_INVALID_ARG Invalid arguments
731 @retval Other error code defined by ql_type.h
732 */
733/*-----------------------------------------------------------------------------------------------*/
734//int ql_dm_get_qoos_config(ql_dm_qoos_config_t *config);
735
736/*-----------------------------------------------------------------------------------------------*/
737/**
738 @brief set QOOS configuration
739 @param[in] config The configuration of QOOS
740 @return Whether to successfully set the QOOS configuration
741 @retval QL_ERR_OK successful
742 @retval QL_ERR_NOT_INIT uninitialized
743 @retval QL_ERR_SERVICE_NOT_READY service is not ready
744 @retval QL_ERR_INVALID_ARG Invalid arguments
745 @retval Other error code defined by ql_type.h
746 */
747/*-----------------------------------------------------------------------------------------------*/
748//int ql_dm_set_qoos_config(ql_dm_qoos_config_t config);
749
750/*-----------------------------------------------------------------------------------------------*/
751/**
752 @brief get MSSR(Modem SubSysem Reset) level.
753 @param[out] p_level The MSSR level
754 @return Whether to successfully get the MSSR level
755 @retval QL_ERR_OK successful
756 @retval QL_ERR_NOT_INIT uninitialized
757 @retval QL_ERR_SERVICE_NOT_READY service is not ready
758 @retval QL_ERR_INVALID_ARG Invalid arguments
759 @retval Other error code defined by ql_type.h
760 */
761/*-----------------------------------------------------------------------------------------------*/
762int ql_dm_get_mssr_level(int *p_level);
763
764/*-----------------------------------------------------------------------------------------------*/
765/**
766 @brief set MSSR(Modem SubSysem Reset) level.
767 @param[in] level The MSSR level
768 @return Whether to successfully set the MSSR level
769 @retval QL_ERR_OK successful
770 @retval QL_ERR_NOT_INIT uninitialized
771 @retval QL_ERR_SERVICE_NOT_READY service is not ready
772 @retval QL_ERR_INVALID_ARG Invalid arguments
773 @retval Other error code defined by ql_type.h
774 */
775/*-----------------------------------------------------------------------------------------------*/
776int ql_dm_set_mssr_level(int level);
777
778
779/*-----------------------------------------------------------------------------------------------*/
780/**
781 @brief bind subscription
782 @param[in] sub_type subscription type
783 @return Whether to successfully bind subscription.
784 @retval QL_ERR_OK successful
785 @retval QL_ERR_NOT_INIT uninitialized
786 @retval QL_ERR_SERVICE_NOT_READY service is not ready
787 @retval QL_ERR_INVALID_ARG Invalid arguments
788 @retval Other error code defined by ql_type.h
789 */
790/*-----------------------------------------------------------------------------------------------*/
791int ql_dm_bind_subscription(QL_DM_BIND_SUB_TYPE_E sub_type);
792
793/*-----------------------------------------------------------------------------------------------*/
794/**
795 @brief Registration server error callback. Currently, only if the server exits abnormally,
796 the callback function will be executed, and the error code is QL_ERR_ABORTED;
797 @param[in] cb Callback function
798 @return
799 QL_ERR_OK - successful
800 Other - error code defined by ql_type.h
801 */
802/*-----------------------------------------------------------------------------------------------*/
803int ql_dm_set_service_error_cb(ql_dm_service_error_cb_f cb)
804{
805 int ret = -1;
806 if(ql_info_handle == NULL)
807 {
808 LOGE("DM no init ");
809 return QL_ERR_NOT_INIT;
810
811 }
812 global_dm_error_cb = cb;
813 ret = mbtk_ril_ser_state_change_cb_reg(mbtk_dm_set_service_error_func);
814 if(ret != 0)
815 {
816 LOGE("call mbtk_ril_server_state_change_reg failed");
817 return QL_ERR_FAILED;
818 }
819
820 return QL_ERR_OK;
821}
822/*-----------------------------------------------------------------------------------------------*/
823/**
824 @brief Get module the last time shutdown reason
825 @param[out] shutdown_reason the shutdown reason
826 @return
827 QL_ERR_OK - successful
828 Other - error code defined by ql_type.h
829 */
830/*-----------------------------------------------------------------------------------------------*/
831int ql_dm_get_shutdown_reason(QL_DM_SHUTDOWN_REASON_E *shutdown_reason);
832
833/*-----------------------------------------------------------------------------------------------*/
834/**
835 @brief Get module this time bootup reason
836 @param[out] bootup_reason the bootup reason
837 @return
838 QL_ERR_OK - successful
839 Other - error code defined by ql_type.h
840 */
841/*-----------------------------------------------------------------------------------------------*/
842int ql_dm_get_bootup_reason(QL_DM_BOOT_UP_REASON_E *bootup_reason);
843
844/*-----------------------------------------------------------------------------------------------*/
845/**
846 @brief set oos config
847 @param[out] oos param
848 @return
849 QL_ERR_OK - successful
850 Other - error code defined by ql_type.h
851 */
852/*-----------------------------------------------------------------------------------------------*/
853int ql_dm_set_qoos_config(int p1, int p2, int p3);
854
855
856/*-----------------------------------------------------------------------------------------------*/
857/**
858 @brief get oos config
859 @param[out] oos param
860 @return
861 QL_ERR_OK - successful
862 Other - error code defined by ql_type.h
863 */
864/*-----------------------------------------------------------------------------------------------*/
865int ql_dm_get_qoos_config(int *p1, int *p2, int *p3);
866
867/*-----------------------------------------------------------------------------------------------*/
868/**
869 @brief set oos enable
870 @param[out] oos param
871 @return
872 QL_ERR_OK - successful
873 Other - error code defined by ql_type.h
874 */
875/*-----------------------------------------------------------------------------------------------*/
876int ql_dm_set_qoos_enable(char enable);
877#ifdef __cplusplus
878}
879#endif
880
881
882