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