#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>

#include <time.h>
#include "mbtk_info_api.h"

int lynq_get_time_sec(char *time_t)
{
    struct timeval tv;
    gettimeofday(&tv,NULL);
    sprintf(time_t, "%ld", tv.tv_sec);
    return 0;
}

int lynq_imet_get(char *imei_t)
{
    static mbtk_info_handle_t* info_handle = NULL;
    info_handle = mbtk_info_handle_get();
    if(!info_handle)
    {
        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(!ret)
    {
        sprintf(chip_id,"%s%s",imei, time);
//        printf("%s\n",chip_id );
    }
    else{
        return -1;
    }

    return 0;
}



