b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <sys/time.h> |
| 5 | |
| 6 | #include <time.h> |
| 7 | #include "mbtk_info_api.h" |
| 8 | |
| 9 | int lynq_get_time_sec(char *time_t) |
| 10 | { |
| 11 | struct timeval tv; |
| 12 | gettimeofday(&tv,NULL); |
| 13 | sprintf(time_t, "%lld", tv.tv_sec); |
| 14 | return 0; |
| 15 | } |
| 16 | |
| 17 | int lynq_imet_get(char *imei_t) |
| 18 | { |
| 19 | static mbtk_info_handle_t* info_handle = NULL; |
| 20 | info_handle = mbtk_info_handle_get(); |
| 21 | if(!info_handle) |
| 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 | |
| 38 | int lynq_get_chip_id(char *chip_id) |
| 39 | { |
| 40 | char time[50]={0}; |
| 41 | char imei[50]={0}; |
| 42 | int ret = 0; |
| 43 | lynq_get_time_sec(time); |
| 44 | ret = lynq_imet_get(imei); |
| 45 | if(!ret) |
| 46 | { |
| 47 | sprintf(chip_id,"%s%s",imei, time); |
| 48 | // printf("%s\n",chip_id ); |
| 49 | } |
| 50 | else{ |
| 51 | return -1; |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | |