| #include <stdio.h> |
| #include <stdlib.h> |
| #include <unistd.h> |
| #include <sys/time.h> |
| |
| #include <time.h> |
| #include "mbtk_ril_api.h" |
| static mbtk_ril_handle* info_handle = NULL; |
| |
| int lynq_get_time_sec(char *time_t) |
| { |
| struct timeval tv; |
| gettimeofday(&tv,NULL); |
| sprintf(time_t, "%lld", tv.tv_sec); |
| return 0; |
| } |
| |
| int lynq_imet_get(char *imei_t) |
| { |
| info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF); |
| if(info_handle == NULL) |
| { |
| return -1; |
| } |
| |
| int err; |
| err = mbtk_imei_get(info_handle, imei_t); |
| if(err) { |
| // printf("Error : %d\n", err); |
| return -1; |
| } else { |
| // printf("IMEI : %s\n", imei_t); |
| } |
| return 0; |
| } |
| |
| |
| int lynq_get_chip_id(char *chip_id) |
| { |
| char time[50]={0}; |
| char imei[50]={0}; |
| int ret = 0; |
| |
| lynq_get_time_sec(time); |
| ret = lynq_imet_get(imei); |
| |
| if(info_handle != NULL) |
| { |
| int ret_ril = mbtk_ril_close(MBTK_AT_PORT_DEF); |
| if (ret_ril == MBTK_RIL_ERR_SUCCESS) |
| LOGI("deinit info_handle is succuess"); |
| else |
| LOGE("deinit info_handle is error(%d)",ret_ril); |
| } |
| |
| if(!ret) |
| { |
| sprintf(chip_id,"%s%s",imei, time); |
| // printf("%s\n",chip_id ); |
| } |
| else{ |
| return -1; |
| } |
| |
| return 0; |
| } |
| |
| |
| |