#include <stdbool.h>
#include <unistd.h>
#include <dlfcn.h>
#include <time.h>
#include "gsw_nw_interface.h"

#define MBTK_BUFF_TEMP_SIZE_32  32
#define MBTK_ERR_OK             0
#define MBTK_ERR_FAIL             -1
#define GSW_SIM_ICCID_LENGTH 15+1 
#define GSW_SIM_IMSI_LENGTH 15+1 
#define GSW_SIM_MSISDN_LENGTH 15+1

//mbtk include
typedef unsigned int uint32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
typedef struct
{
    int client_fd;
    pthread_t read_thread_id;
    int exit_fd[2];
    bool is_waitting;
    pthread_cond_t cond;
    pthread_mutex_t mutex;

    pthread_mutex_t send_mutex;

    // Temp response data.
    uint16 info_err;
    uint16 data_len;
    void *data;

    //mbtk wyq for server_ready_status add start
    char server_ready_status;
    //mbtk wyq for server_ready_status add end

    mbtk_info_callback_func net_state_cb;
    mbtk_info_callback_func call_state_cb;
    mbtk_info_callback_func sms_state_cb;
    mbtk_info_callback_func radio_state_cb;
    mbtk_info_callback_func sim_state_cb;
    mbtk_info_callback_func pdp_state_cb;
    //add signal by xr
    mbtk_info_callback_func signal_state_cb;
} mbtk_info_handle_t;

typedef enum {
    MBTK_SIM_ABSENT = 0,
    MBTK_SIM_NOT_READY = 1,
    MBTK_SIM_READY = 2,
    MBTK_SIM_PIN = 3,
    MBTK_SIM_PUK = 4,
    MBTK_SIM_NETWORK_PERSONALIZATION = 5
} mbtk_sim_state_enum;

typedef enum
{
    MBTK_DEV_MODEM_MIN_FUN,                                   //Modem 最小功能
    MBTK_DEV_MODEM_FULL_FUN,                                  //Modem 全功能
    MBTK_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS = 3,           //Modem 禁用射频接收电路
    MBTK_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS,  //Modem禁用射频发射和接收电路
    MBTK_DEV_MODEM_DISABLE_SIM,                               //Modem 禁用(U)SIM 卡
    MBTK_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE,           //Modem 完全禁用辅助接收
}MBTK_DEV_MODEM_FUNCTION;

typedef struct
{
    MBTK_DEV_MODEM_FUNCTION fun;
    int rst;
} mbtk_modem_info_t;

//api

static mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
#define lib_mbtk_path "/lib/libmbtk_lib.so"

static int sim_init_flag = 0;
mbtk_info_handle_t*       sim_info_handle = NULL;
static int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
int (*mbtk_sim_state_get)(mbtk_info_handle_t* handle, mbtk_sim_state_enum *sim_state);
int (*mbtk_imsi_get)(mbtk_info_handle_t* handle, void *imsi);
int (*mbtk_iccid_get)(mbtk_info_handle_t* handle, void *iccid);
int (*mbtk_phone_number_get)(mbtk_info_handle_t* handle, void *phone_number);
int (*mbtk_set_modem_fun)(mbtk_info_handle_t* handle, mbtk_modem_info_t *info);
int (*mbtk_sim_power_set)(int power);
static void (*mbtk_log)(int level, const char *format, ...);
static void (*mbtk_log_init)(char *path, char *tag);

#ifndef LOG_ERR_LEVEL
#define LOG_ERR_LEVEL  3      /* error conditions */
#endif
#ifndef LOG_WARN_LEVEL
#define LOG_WARN_LEVEL 4   /* warning conditions */
#endif
#ifndef LOG_INFO_LEVEL
#define LOG_INFO_LEVEL 6      /* informational */
#endif
#ifndef LOG_DEBUG_LEVEL
#define LOG_DEBUG_LEVEL 7     /* debug-level messages */
#endif
#ifndef LOG_VERBOSE_LEVEL
#define LOG_VERBOSE_LEVEL 8
#endif

#define GSW_SIM "[HAL][GSW_SIM]"

#define LOGV(fmt, args ...) \
    do{ \
        char *file_ptr_1001 = __FILE__; \
        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
        char line_1001[10] = {0}; \
        sprintf(line_1001, "%d", __LINE__); \
        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
            if(*ptr_1001 == '/') \
                 break; \
            ptr_1001--; \
        } \
        mbtk_log(LOG_VERBOSE_LEVEL, "%s#%s: "GSW_SIM"" fmt, ptr_1001 + 1, line_1001, ##args); \
    } while(0)

#define LOGI(fmt, args...) \
    do{ \
        char *file_ptr_1001 = __FILE__; \
        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
        char line_1001[10] = {0}; \
        sprintf(line_1001, "%d", __LINE__); \
        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
            if(*ptr_1001 == '/') \
                 break; \
            ptr_1001--; \
        } \
        mbtk_log(LOG_INFO_LEVEL, "%s#%s: "GSW_SIM"" fmt, ptr_1001 + 1, line_1001, ##args); \
    } while(0)

#define LOGD(fmt, args...) \
    do{ \
        char *file_ptr_1001 = __FILE__; \
        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
        char line_1001[10] = {0}; \
        sprintf(line_1001, "%d", __LINE__); \
        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
            if(*ptr_1001 == '/') \
                 break; \
            ptr_1001--; \
        } \
        mbtk_log(LOG_DEBUG_LEVEL, "%s#%s: "GSW_SIM"" fmt, ptr_1001 + 1, line_1001, ##args); \
    } while(0)

#define LOGW(fmt, args...) \
    do{ \
        char *file_ptr_1001 = __FILE__; \
        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
        char line_1001[10] = {0}; \
        sprintf(line_1001, "%d", __LINE__); \
        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
            if(*ptr_1001 == '/') \
                 break; \
            ptr_1001--; \
        } \
        mbtk_log(LOG_WARN_LEVEL, "%s#%s: "GSW_SIM"" fmt, ptr_1001 + 1, line_1001, ##args); \
    } while(0)

#define LOGE(fmt, args...) \
    do{ \
		char *file_ptr_1001 = __FILE__; \
        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
        char line_1001[10] = {0}; \
        sprintf(line_1001, "%d", __LINE__); \
        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
            if(*ptr_1001 == '/') \
                 break; \
            ptr_1001--; \
        } \
        mbtk_log(LOG_ERR_LEVEL, "%s#%s: "GSW_SIM"" fmt, ptr_1001 + 1, line_1001, ##args); \
    } while(0)




static void *dlHandle_mbtk;


static int gsw_sim_api_import()
{
    dlHandle_mbtk = dlopen(lib_mbtk_path, RTLD_NOW);
    if (dlHandle_mbtk == NULL) 
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_log_init = (void (*)(char *path, char *tag))dlsym(dlHandle_mbtk, "mbtk_log_init");
    if (mbtk_log_init == NULL) 
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_log = (void (*)(int level, const char *format, ...))dlsym(dlHandle_mbtk, "mbtk_log");
    if (mbtk_log == NULL) 
    {
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_info_handle_get = (mbtk_info_handle_t* (*)(void))dlsym(dlHandle_mbtk, "mbtk_info_handle_get");
    if (mbtk_info_handle_get == NULL) 
    {
        LOGE("mbtk_info_handle_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_info_handle_free = (int (*)(mbtk_info_handle_t** handle))dlsym(dlHandle_mbtk, "mbtk_info_handle_free");
    if (mbtk_info_handle_free == NULL) 
    {
        LOGE("mbtk_info_handle_free dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_imsi_get = (int (*)(mbtk_info_handle_t* handle, void *imsi))dlsym(dlHandle_mbtk, "mbtk_imsi_get");
    if (mbtk_imsi_get == NULL) 
    {
        LOGE("mbtk_imsi_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_iccid_get = (int (*)(mbtk_info_handle_t* handle, void *iccid))dlsym(dlHandle_mbtk, "mbtk_iccid_get");
    if (mbtk_iccid_get == NULL) 
    {
        LOGE("mbtk_iccid_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_phone_number_get = (int (*)(mbtk_info_handle_t* handle, void *phone_number))dlsym(dlHandle_mbtk, "mbtk_phone_number_get");
    if (mbtk_phone_number_get == NULL) 
    {
        LOGE("mbtk_phone_number_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

   
    mbtk_sim_state_get = (int (*)(mbtk_info_handle_t* handle, mbtk_sim_state_enum *sim_state))dlsym(dlHandle_mbtk, "mbtk_sim_state_get");
    if (mbtk_sim_state_get == NULL) 
    {
        LOGE("mbtk_sim_state_get dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_set_modem_fun = (int (*)(mbtk_info_handle_t* handle, mbtk_modem_info_t *info))dlsym(dlHandle_mbtk, "mbtk_set_modem_fun");
    if (mbtk_set_modem_fun == NULL) 
    {
        LOGE("mbtk_set_modem_fun dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_sim_power_set = (int (*)(int power))dlsym(dlHandle_mbtk, "mbtk_sim_power_set");
    if (mbtk_sim_power_set == NULL)
    {
        LOGE("mbtk_sim_power_set dlsym fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    LOGD("gsw_sim_api_import end\n");
    return GSW_HAL_SUCCESS;
}

/**
 * @brief sim sdk init
 * @param  [in] token usr id define by who use
 * @retval 0: success
 * @retval other: fail
 */
int gsw_sim_sdk_init(int32_t token)
{
    int ret = GSW_HAL_NORMAL_FAIL;

    if(sim_init_flag == 1 && sim_info_handle != NULL)
    {
        return GSW_HAL_SUCCESS;
    }

    ret = gsw_sim_api_import();
    if(ret != GSW_HAL_SUCCESS)
    {
        if(mbtk_log != NULL)
        {
            LOGE("gsw_sim_import fail\n");
        }
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_log_init("syslog", "MBTK_RIL");

    sim_info_handle = mbtk_info_handle_get();
    if(sim_info_handle == NULL)
    {
        LOGE("mbtk_info_handle_get fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    sim_init_flag = 1;
    return GSW_HAL_SUCCESS;
}


/**
 * @brief sim sdk deinit
 * @param 
 * @retval 0: success
 * @retval other: fail
 */
int gsw_sim_sdk_deinit(void)
{
    int ret = -1;

    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_info_handle_free(&sim_info_handle);
    if(ret != GSW_HAL_SUCCESS)
    {
        LOGE("mbtk_info_handle_free fail\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    sim_init_flag = 0;
    sim_info_handle = NULL;
    dlclose(dlHandle_mbtk);

    return GSW_HAL_SUCCESS;

}


/**
 * @brief get sim state
 * @param  [out] sim_state sim status as sim_status_e_type
 * @retval 0: success
 * @retval other: fail
 */
int gsw_get_sim_status(int *sim_state)
{
    printf("gsw_get_sim_status enter\n");
    int ret = -1;

    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_sim_state_enum sim = MBTK_SIM_ABSENT;

    LOGD("mbtk_get_sim_status start\n");
    ret = mbtk_sim_state_get(sim_info_handle, &sim);
    if(ret)
    {
        LOGE("[gsw_get_sim_status] mbtk_sim_state_get fail [err = %d].", ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    else
    {
        LOGD("[gsw_get_sim_status] sim = %d\n", sim);
        switch (sim)
        {
            case MBTK_SIM_ABSENT:
            {
                *sim_state = SIM_STATUS_ABSENT;
                break;
            }
            case MBTK_SIM_NOT_READY:
            {
                *sim_state = SIM_STATUS_ERROR;// not SIM_STATUS_PRESENT, changed for gsw requirement, hq at 250606
                break;
            }
                
            case MBTK_SIM_READY:
            {
                *sim_state = SIM_STATUS_PRESENT;// not SIM_STATUS_READY, changed for gsw requirement, hq at 250606
                break;
            }
                
            case MBTK_SIM_PIN:
            {
                *sim_state = SIM_STATUS_PIN;
                break;
            }

            case MBTK_SIM_PUK:
            {
                break;
            }

            case MBTK_SIM_NETWORK_PERSONALIZATION:
            {
                break;
            }
        
        }
    }

    return GSW_HAL_SUCCESS;
}

/**
 * @brief get iccid function
 * @param  [in] len iccid length,max is 20
 * @param  [out] iccid return iccid from this func
 * @retval 0: success
 * @retval other: fail
 */
int gsw_get_sim_iccid(int len, char *iccid)
{
    int ret = -1;

    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    if(iccid == NULL)
    {
        LOGE("iccid is NULL.");
        return GSW_HAL_ARG_INVALID;
    }

    if(len < GSW_SIM_ICCID_LENGTH)
    {
        LOGE("iccid len is too short,len = %d\n", len);
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_iccid_get(sim_info_handle, (void *)iccid);
    if(ret != MBTK_ERR_OK)
    {
        LOGE("[gsw_sim] mbtk_iccid_get fail [err = %d].", ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}

/**
 * @brief get imsi function
 * @param  [in] len imsi length,max is 20
 * @param  [out] iccid return imsi from this func
 * @retval 0: success
 * @retval other: fail
 */
int gsw_get_sim_imsi(int len, char *imsi)
{
    int ret = -1;

    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    if(imsi == NULL)
    {
        LOGE("imsi is NULL.");
        return GSW_HAL_ARG_INVALID;
    }

    if(len < GSW_SIM_IMSI_LENGTH)
    {
        LOGE("imsi len is too short,len = %d\n", len);
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_imsi_get(sim_info_handle, (void *)imsi);
    if(ret != MBTK_ERR_OK)
    {
        LOGE("[gsw_sim] mbtk_imsi_get fail [err = %d].", ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}

/**
 * @brief get sim msisdn function
 * @param  [in] len msisdn length,max is 20
 * @param  [out] msisdn msisdn length,max is 20
 * @retval 0: success
 * @retval other: fail
 */
int gsw_get_sim_msisdn(int len, char *msisdn)
{
    int ret = -1;

    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    if(msisdn == NULL)
    {
        printf("msisdn is NULL.");
        return GSW_HAL_ARG_INVALID;
    }

    if(len < GSW_SIM_MSISDN_LENGTH)
    {
        printf("msisdn len is too short,len = %d\n", len);
        return GSW_HAL_NORMAL_FAIL;
    }

    ret = mbtk_phone_number_get(sim_info_handle, (void *)msisdn);
    if(ret != MBTK_ERR_OK)
    {
        LOGE("[gsw_sim] mbtk_phone_number_get fail [err = %d].", ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}

/**
 * @brief set sim power down
 * @param  
 * @retval 0: success
 * @retval other: fail
 */
int gsw_set_sim_power_down(void)
{
    int ret = -1;
    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_modem_info_t info;
    info.fun = MBTK_DEV_MODEM_DISABLE_SIM;
    info.rst = 0;

    ret = mbtk_set_modem_fun(sim_info_handle, &info);
    if(ret)
    {
        LOGE("mbtk_set_modem_fun() fail [err = %d].", ret);
        return GSW_HAL_NORMAL_FAIL;
    }

    return GSW_HAL_SUCCESS;
}



/**
 * @brief set sim power up
 * @param 
 * @retval 0: success
 * @retval other: fail
 */
int gsw_set_sim_power_up(void)
{
    int ret = -1;
    if(sim_init_flag == 0 || sim_info_handle == NULL)
    {
        printf("sim sdk has been deinit\n");
        return GSW_HAL_NORMAL_FAIL;
    }

    mbtk_modem_info_t info;
    info.fun = MBTK_DEV_MODEM_FULL_FUN;
    info.rst = 0;

    ret = mbtk_set_modem_fun(sim_info_handle, &info);
    if(ret)
    {
        LOGE("mbtk_set_modem_fun() fail [err = %d].", ret);
        return GSW_HAL_NORMAL_FAIL;
    }
    
    return GSW_HAL_SUCCESS;
}
