blob: 34e60c107a06f4d07522273715caefab42489a33 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <sys/time.h>
5
6#include <time.h>
7#include "mbtk_ril_api.h"
8static mbtk_ril_handle* info_handle = NULL;
9
10int lynq_get_time_sec(char *time_t)
11{
12 struct timeval tv;
13 gettimeofday(&tv,NULL);
14 sprintf(time_t, "%lld", tv.tv_sec);
15 return 0;
16}
17
18int lynq_imet_get(char *imei_t)
19{
20 info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
21 if(info_handle == NULL)
22 {
23 return -1;
24 }
25
26 int err;
27 err = mbtk_imei_get(info_handle, imei_t);
28 if(err) {
29 // printf("Error : %d\n", err);
30 return -1;
31 } else {
32 // printf("IMEI : %s\n", imei_t);
33 }
34 return 0;
35}
36
37
38int lynq_get_chip_id(char *chip_id)
39{
40 char time[50]={0};
41 char imei[50]={0};
42 int ret = 0;
43
44 lynq_get_time_sec(time);
45 ret = lynq_imet_get(imei);
46
47 if(info_handle != NULL)
48 {
49 int ret_ril = mbtk_ril_close(MBTK_AT_PORT_DEF);
50 if (ret_ril == MBTK_RIL_ERR_SUCCESS)
51 LOGI("deinit info_handle is succuess");
52 else
53 LOGE("deinit info_handle is error(%d)",ret_ril);
54 }
55
56 if(!ret)
57 {
58 sprintf(chip_id,"%s%s",imei, time);
59// printf("%s\n",chip_id );
60 }
61 else{
62 return -1;
63 }
64
65 return 0;
66}
67
68
69