Update LYNQ test
Change-Id: I9e434803f0cce9f24048f2fbc5eed2d26fa33503
diff --git a/mbtk/include/lynq/libpoweralarm.h b/mbtk/include/lynq/libpoweralarm.h
new file mode 100755
index 0000000..4110fba
--- /dev/null
+++ b/mbtk/include/lynq/libpoweralarm.h
@@ -0,0 +1,36 @@
+/*******************************************************
+*
+* @brief: none
+* @details: add libpoweralarm api
+* @author: l.yang
+* @date: 2023.8.21
+* @version: V1.0
+* @copyright:Copyright (c) MobileTek
+*
+*********************************************/
+
+#ifndef _LYNQ_POWERALARM_
+#define _LYNQ_POWERALARM_
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+typedef int (*lynq_wakealarm_add_cb)(unsigned int src_id, int rtc_id);
+int lynq_rtc_service_init(void);
+int lynq_rtc_service_deinit(void);
+ssize_t poweralarm(char *buffer,int src_id);
+ssize_t wakealarm(char *buffer,int src_id,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify );
+ssize_t cancel_wakealarm(int src_id, int rtc_id);
+
+int lynq_set_wakealarm(unsigned long time_sec,int src_id,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify );
+int lynq_set_poweralarm(unsigned long time_sec,int src_id);
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+
diff --git a/mbtk/include/lynq/lynq-adc.h b/mbtk/include/lynq/lynq-adc.h
index 0af4d5d..a0051cc 100755
--- a/mbtk/include/lynq/lynq-adc.h
+++ b/mbtk/include/lynq/lynq-adc.h
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+// #include <sc_bsp.h>
#ifdef __cplusplus
extern "C" {
diff --git a/mbtk/include/lynq/lynq-gpio.h b/mbtk/include/lynq/lynq-gpio.h
index 5af9f50..b5377c5 100755
--- a/mbtk/include/lynq/lynq-gpio.h
+++ b/mbtk/include/lynq/lynq-gpio.h
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//#include <sc_bsp.h>
#ifdef __cplusplus
extern "C" {
diff --git a/mbtk/include/lynq/lynq-qser-autosuspend.h b/mbtk/include/lynq/lynq-qser-autosuspend.h
index 37adfc7..5d4b91d 100755
--- a/mbtk/include/lynq/lynq-qser-autosuspend.h
+++ b/mbtk/include/lynq/lynq-qser-autosuspend.h
@@ -53,6 +53,7 @@
typedef struct
{
char lock_name[MAX_LOCK_NUM][64];
+ int lock_pid[MAX_LOCK_NUM];
} LOCK_TABLE;
int read_lock_table(void);
@@ -63,8 +64,9 @@
int qser_wakelock_lock(int fd);
int qser_wakelock_unlock(int fd);
int qser_wakelock_destroy(int fd);
-int qser_whitelist_get(char* whitelish);
-int qser_whitelist_set(char* whitelish);
+
+int qser_whitelist_set(char *whitelist);
+int qser_whitelist_get(char *whitelist);
#ifdef __cplusplus
diff --git a/mbtk/include/lynq/lynq-qser-fota.h b/mbtk/include/lynq/lynq-qser-fota.h
index 34be9aa..2a8cfd6 100755
--- a/mbtk/include/lynq/lynq-qser-fota.h
+++ b/mbtk/include/lynq/lynq-qser-fota.h
@@ -18,6 +18,7 @@
int lynq_fota_set_addr_value(char *value,int size);
int lynq_fota_nrestart(void);
int lynq_rock_main(int first_run);
+int lynq_read_process(void);
#ifdef __cplusplus
}
diff --git a/mbtk/include/lynq/lynq-qser-usb.h b/mbtk/include/lynq/lynq-qser-usb.h
new file mode 100755
index 0000000..97428d4
--- /dev/null
+++ b/mbtk/include/lynq/lynq-qser-usb.h
@@ -0,0 +1,25 @@
+/*******************************************************
+*
+* @brief: Add usb api
+* @details: add liblynq-qser-usb api
+* @author: wz.wang
+* @date: 2024.2.18
+* @version: V1.0
+* @copyright:Copyright (c) MobileTek
+*
+*********************************************/
+#ifndef LYNQ_QSER_USB
+#define LYNQ_QSER_USB
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int qser_get_usb_usermode_net_state(void);
+int qser_get_usb_usermode_adb_state(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/mbtk/include/lynq/lynq-qser-voice.h b/mbtk/include/lynq/lynq-qser-voice.h
index 8748ae3..668d6ce 100755
--- a/mbtk/include/lynq/lynq-qser-voice.h
+++ b/mbtk/include/lynq/lynq-qser-voice.h
@@ -111,6 +111,8 @@
);
+int qser_voice_set_dtmf(const char callnum);
+
/*
Usage 1 (register callback and wait for new call in, then answer):
1, QSER_Voice_Call_Client_Init
@@ -131,6 +133,83 @@
*/
+#ifdef ECALL_SUPPORT
+
+#define QSER_MSD_MAX_LENGTH 140
+
+typedef enum{
+ E_QSER_VOICE_ECALL_SET_NUMBER = 0, /* Set Number */
+ E_QSER_VOICE_ECALL_SET_URI = 1, /* Set Uri */
+}E_QSER_VOICE_ECALL_SET_TYPE_T;
+
+typedef enum{
+ E_QSER_VOICE_ECALL_CAT_MANUAL = 0, /* Manual Emergency eCall */
+ E_QSER_VOICE_ECALL_CAT_AUTO = 1, /* Automatic Emergency eCall */
+}E_QSER_VOICE_ECALL_CATEGORY_T;
+
+
+typedef enum{
+ E_QSER_VOICE_ECALL_TEST = 0, /* Test eCall */
+ E_QSER_VOICE_ECALL_EMERGENCY = 1, /* Emergency eCall */
+ E_QSER_VOICE_ECALL_RECONFIG = 2, /* Reconfiguration eCall */
+}E_QSER_VOICE_ECALL_VARIANT_T;
+
+typedef enum{
+ E_QSER_VOICE_ECALL_IND_SENDING_START = 1,
+ E_QSER_VOICE_ECALL_IND_SENDING_MSD = 2,
+ E_QSER_VOICE_ECALL_IND_LLACK_RECEIVED = 3,
+ E_QSER_VOICE_ECALL_IND_ALACK_POSITIVE_RECEIVED = 4,
+ E_QSER_VOICE_ECALL_IND_ALACK_CLEARDOWN_RECEIVED = 5,
+ E_QSER_VOICE_ECALL_IND_DAILING = 9,
+ E_QSER_VOICE_ECALL_IND_ALERTING = 10,
+ E_QSER_VOICE_ECALL_IND_ACTIVE = 11,
+ E_QSER_VOICE_ECALL_IND_DISCONNECTED = 12,
+ E_QSER_VOICE_ECALL_IND_IMS_ACTIVE = 13,
+ E_QSER_VOICE_ECALL_IND_IMS_DISCONNECTED = 14,
+ E_QSER_VOICE_ECALL_IND_ABNORMAL_HANGUP=15,
+ E_QSER_VOICE_ECALL_IND_IMS_MSD_ACK = 20,
+ E_QSER_VOICE_ECALL_IND_IMS_UPDATE_MSD = 21,
+ E_QSER_VOICE_ECALL_IND_IMS_IN_BAND_TRANSFER = 22,
+ E_QSER_VOICE_ECALL_IND_IMS_MSD_NACK = 23,
+ E_QSER_VOICE_ECALL_IND_IMS_SRVCC = 24,
+ E_QSER_VOICE_ECALL_IND_ONLY_DEREGISTRATION = 31,
+ E_QSER_VOICE_ECALL_IND_MAY_DEREGISTER = 32,
+ E_QSER_VOICE_ECALL_IND_PSAP_CALLBACK_START = 40,
+ E_QSER_VOICE_ECALL_IND_PSAP_CALLBACK_IMS_UPDATE_MSD = 41,
+ E_QSER_VOICE_ECALL_IND_SENDING_START_IN_VOICE=8000,
+ E_QSER_VOICE_ECALL_IND_T2_TIMER_OUT = 9000,
+ E_QSER_VOICE_ECALL_IND_T5_TIMER_OUT = 9001,
+ E_QSER_VOICE_ECALL_IND_T6_TIMER_OUT = 9002,
+ E_QSER_VOICE_ECALL_IND_T7_TIMER_OUT = 9003,
+ E_QSER_VOICE_ECALL_IND_REDIAL_TIMER_OUT = 9004,
+ E_QSER_VOICE_ECALL_IND_AUTO_ANS_TIMER_OUT = 9005,
+ E_QSER_VOICE_ECALL_IND_AUTO_ANS_IMS_TIMER_OUT = 9006,
+ E_QSER_VOICE_ECALL_IND_UNSPECIFIED = 0xffff,
+}E_QSER_VOICE_ECALL_INDICATION_T;
+
+typedef void (*QSER_ECall_IndHandlerFunc_t)
+(
+ int callid,
+ E_QSER_VOICE_ECALL_INDICATION_T ind,
+ void *contextPtr
+);
+
+int qser_voice_set_test_num(voice_client_handle_type* h_voice,E_QSER_VOICE_ECALL_SET_TYPE_T type, const char *test_num, int test_num_length);
+int qser_voice_fast_ecall(voice_client_handle_type* h_voice,
+ int *call_id,
+ E_QSER_VOICE_ECALL_CATEGORY_T cat,
+ E_QSER_VOICE_ECALL_VARIANT_T variant,
+ const char *addr,
+ int addr_length,
+ const unsigned char *msd_data,
+ int msd_length); //msd_length should <= QSER_MSD_MAX_LENGTH
+int qser_voice_set_msd( int callid, const unsigned char *msd_data, int msd_length); // msd_length should <= QSER_MSD_MAX_LENGTH
+int qser_voice_add_ecall_indhandler(voice_client_handle_type* h_voice,
+ QSER_ECall_IndHandlerFunc_t handlerPtr,
+ void* contextPtr);
+
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/mbtk/include/lynq/lynq-qser-wifi.h b/mbtk/include/lynq/lynq-qser-wifi.h
new file mode 100755
index 0000000..fa021c0
--- /dev/null
+++ b/mbtk/include/lynq/lynq-qser-wifi.h
@@ -0,0 +1,81 @@
+/*******************************************************
+*
+* @brief: Add wifi api
+* @details: add liblynq-qser-wifi api
+* @author: wz.wang
+* @date: 2024.3.15
+* @version: V1.0
+* @copyright:Copyright (c) MobileTek
+*
+*********************************************/
+#ifndef LYNQ_QSER_WIFI
+#define LYNQ_QSER_WIFI
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ LYNQ_WIFI_AP_INDEX_AP0 = 0, /* Index 0 of AP/AP-STA/AP-AP Mode */
+ LYNQ_WIFI_AP_INDEX_AP1 /* Index 1 of AP/AP-STA/AP-AP Mode */
+} lynq_wifi_ap_index_e;
+
+typedef enum
+{
+ LYNQ_WIFI_MODE_MIN = -1,
+ LYNQ_WIFI_MODE_80211B = 0,
+ LYNQ_WIFI_MODE_80211BG,
+ LYNQ_WIFI_MODE_80211BGN,
+ LYNQ_WIFI_MODE_80211A,
+ LYNQ_WIFI_MODE_80211AN,
+ LYNQ_WIFI_MODE_80211AC,
+ LYNQ_WIFI_MODE_80211BGNAX_2G,
+ LYNQ_WIFI_AP_MODE_MAX
+} lynq_wifi_mode_type_e;
+
+typedef enum LYNQ_WIFI_BANDWIDTH_ENUM
+{
+ LYNQ_WIFI_BANDWIDTH_MIN = -1,
+ LYNQ_WIFI_BANDWIDTH_HT20 = 0,
+ LYNQ_WIFI_BANDWIDTH_HT40,
+ LYNQ_WIFI_BANDWIDTH_HT80,
+ LYNQ_WIFI_BANDWIDTH_MAX
+} lynq_wifi_bandwidth_type_e;
+
+typedef enum
+{
+ LYNQ_WIFI_AUTH_MIN = -1,
+ LYNQ_WIFI_AUTH_OPEN = 0,
+ LYNQ_WIFI_AUTH_WPA_PSK,
+ LYNQ_WIFI_AUTH_WPA2_PSK, //AES
+ LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH, //TKIP & AES
+ LYNQ_WIFI_AUTH_WPA3_PSK, //AES
+ LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH, //AES
+ LYNQ_WIFI_AUTH_MAX
+} lynq_wifi_auth_e;
+
+int qser_wifi_enable(void);
+int qser_wifi_disable(void);
+int qser_wifi_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid);
+int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid);
+int qser_wifi_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode);
+int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode);
+int qser_wifi_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth);
+int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth);
+int qser_wifi_ap_channel_set(lynq_wifi_ap_index_e idx, const char *country_code, int channel);
+int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel);
+int qser_wifi_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char * auth_passwd);
+int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char * auth_passwd);
+int qser_wifi_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num);
+int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num);
+int qser_wifi_ap_start(lynq_wifi_ap_index_e idx);
+int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx);
+int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/mbtk/include/lynq/lynq_qser_gnss.h b/mbtk/include/lynq/lynq_qser_gnss.h
new file mode 100755
index 0000000..9eead07
--- /dev/null
+++ b/mbtk/include/lynq/lynq_qser_gnss.h
@@ -0,0 +1,134 @@
+#ifndef __LYNQ_GNSS_H__
+#define __LYNQ_GNSS_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct mbtk_gnss_handle_t
+{
+ int dev_fd;
+ pthread_t uart_pthread;
+ pthread_t gnss_pthread;
+ gnss_handler_func_t gnss_handler_func;
+ int mode; // 0 - stop, 1 - single, 2 - periodic, 3 - start
+ pthread_mutex_t _cond_mutex;
+ int reset_state;
+ int inited;
+ ring_buffer_t ring_buffer;
+ int getap_status;
+ char *rb;
+
+#if TTFF_TEST
+ pthread_t ttff_pid;
+ int location_state;
+#endif
+ /********************
+ save handle's adr
+ phandle = &handle
+ handle = mbtk_gnss_handle
+ *********************/
+ uint32_t *phandle; // handle's adr
+};
+
+typedef struct
+{
+ uint32_t size; /**< Set to the size of mcm_gps_sv_info_t. */
+ int prn; /**< Pseudo-random number for the SV. */
+ float snr; /**< Signal-to-noise ratio. */
+ float elevation; /**< Elevation of the SV in degrees. */
+ float azimuth; /**< Azimuth of the SV in degrees. */
+}QL_LOC_SV_INFO_T; /* Type */
+
+struct login_information /*Used To Stored User Information*/
+{
+ char* host;
+ char* id;
+ char* password;
+};
+
+static struct login_information *login_information_t = NULL;
+
+#define QL_LOC_GPS_SUPPORT_SVS_MAX 32 /** Maximum number of satellites in view. */
+typedef struct
+{
+ uint32_t size; /**< Set to the size of mcm_gps_sv_status_t. */
+ int num_svs; /**< Number of SVs currently visible. */
+ QL_LOC_SV_INFO_T sv_list[QL_LOC_GPS_SUPPORT_SVS_MAX]; /**< Contains an array of SV information. */
+ uint32_t ephemeris_mask; /**< Bitmask indicating which SVs have ephemeris data. */
+ uint32_t almanac_mask; /**< Bitmask indicating which SVs have almanac data. */
+ uint32_t used_in_fix_mask; /**< Bitmask indicating which SVs were used for computing the most recent position fix. */
+}QL_LOC_SV_STATUS_T; /* Type */
+
+typedef enum
+{
+ LYNQ_POS_MODE_STANDALONE = 0, /**< Mode for running GPS standalone (no assistance). */
+ LYNQ_POS_MODE_MS_BASED = 1, /**< AGPS MS-Based mode. */
+ LYNQ_POS_MODE_MS_ASSISTED = 2, /**< AGPS MS-Assisted mode. */
+}LYNQ_POS_MODE_T;
+
+typedef enum
+{
+ LYNQ_POS_RECURRENCE_PERIODIC = 0, /**< Receive GPS fixes on a recurring basis at a specified period. */
+ LYNQ_POS_RECURRENCE_SINGLE = 1, /**< Request a single-shot GPS fix. */
+}LYNQ_POS_RECURRENCE_T;
+
+struct LYNQ_POS_MODE_INFO_T
+{
+ LYNQ_POS_MODE_T mode; /* Position mode. */
+ LYNQ_POS_RECURRENCE_T recurrence; /* Recurrence */
+};
+
+
+#endif
+typedef struct
+{
+ uint32_t year; // 大于1980
+ uint32_t month; // 1-12
+ uint32_t day; // 1-31
+ uint32_t hour; // 0-23
+ uint32_t minute; // 0-59
+ uint32_t second; // 0-59
+ uint32_t millisecond; // 0-999
+}LYNQ_INJECT_TIME_INTO_T; /* Message */
+
+
+typedef enum {
+ LOC_IND_STATUS_INFO_ON,//E_MT_LOC_MSG_ID_STATUS_INFO = 0,
+ LOC_IND_LOCATION_INFO_ON,//E_MT_LOC_MSG_ID_LOCATION_INFO,
+ LOC_IND_SV_INFO_ON,//E_MT_LOC_MSG_ID_SV_INFO,
+ LOC_IND_NMEA_INFO_ON,//E_MT_LOC_MSG_ID_NMEA_INFO,
+ LOC_IND_CAP_INFO_ON,//E_MT_LOC_MSG_ID_CAPABILITIES_INFO,
+ LOC_IND_AGPS_DATA_CONN_CMD_REQ_ON,//E_MT_LOC_MSG_ID_AGPS_STATUS,
+ LOC_IND_NI_NFY_USER_RESP_REQ_ON,//E_MT_LOC_MSG_ID_NI_NOTIFICATION,
+ LOC_IND_XTRA_DATA_REQ_ON,//E_MT_LOC_MSG_ID_XTRA_REPORT_SERVER,
+}msg_t;
+
+typedef enum {
+ DELETE_NOTHING = 0, /**< Delete nothing. */
+ DELETE_EPHEMERIS = 1, /**< Delete ephemeris data. */
+ DELETE_ALMANAC = 2, /**< Delete almanac data. */
+ DELETE_POSITION_TIME = 3, /**< Delete position and time data. */
+ DELETE_UTC = 4, /**< Delete UTC data. */
+ DELETE_ALL = 5, /**< Delete all location data. */
+}DELETE_AIDING_DATA_TYPE_T;
+
+typedef void ( *lynq_atsvc_incb )( const char *input,const int length);
+typedef void ( *lynq_atsvc_outcb )(char *output, int out_max_size, int mode);
+lynq_atsvc_incb lynq_register_gnss(lynq_atsvc_outcb out_cb);
+
+int qser_Gnss_Init(uint32_t *h_gnss);
+int qser_Gnss_Deinit(uint32_t h_gnss);
+int qser_AddRxIndMsgHandler(gnss_handler_func_t handler_ptr,uint32_t h_gnss);
+int qser_Set_Indications(uint32_t h_gnss,e_msg_id_t type);
+int qser_Gnss_Start(uint32_t h_gnss);
+int qser_Gnss_Stop(uint32_t h_gnss);
+int qser_Gnss_Set_Frequency(uint32_t h_gnss, int frequency);
+int qser_Gnss_Delete_Aiding_Data(uint32_t h_gnss,DELETE_AIDING_DATA_TYPE_T flags);
+int qser_Gnss_Server_Configuration(char *host, char *id, char *password);
+int qser_Gnss_InjectTime(uint32_t h_gnss,LYNQ_INJECT_TIME_INTO_T *time_info);
+int qser_firmware_update(uint32_t h_gnss);
+int qser_Gnss_injectEphemeris(uint32_t h_gnss);
+int qser_Gnss_download_tle();
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/mbtk/include/lynq/lynq_qser_network.h b/mbtk/include/lynq/lynq_qser_network.h
index 35d4292..61d68f0 100755
--- a/mbtk/include/lynq/lynq_qser_network.h
+++ b/mbtk/include/lynq/lynq_qser_network.h
@@ -36,6 +36,12 @@
E_QSER_NW_ROAM_STATE_TYPE_T roaming_pref; /**< Roaming preference.*/
}QSER_NW_CONFIG_INFO_T;
+typedef enum
+{
+ E_QSER_NW_IMS_MODE_OFF = 0, /**< close ims. */
+ E_QSER_NW_IMS_MODE_VOLTE_ENABLE = 1, /**< support volte. */
+}E_QSER_NW_IMS_MODE_TYPE_T;
+
/** Configures the OOS (out of service) settings that define the MCM network interface. */
#define QSER_NW_OOS_CFG_TYPE_FAST_SCAN 0x00 /**< fast net scan */
#define QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN 0x01 /**< full band scan */
@@ -68,10 +74,13 @@
//defined for QSER_NW_EventRegister
#define NW_IND_VOICE_REG_EVENT_IND_FLAG (1 << 0) /**< msg format : QSER_NW_VOICE_REG_EVENT_IND_T */
-#define NW_IND_DATA_REG_EVENT_IND_FLAG (1 << 1) /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */
-#define NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG (1 << 2) /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */
+#define NW_IND_DATA_REG_EVENT_IND_FLAG (1 << 1) /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */
+#define NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG (1 << 2) /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */
+//#define NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG (1 << 3) /**< msg format : QL_MCM_NW_CELL_ACCESS_STATE_EVENT_IND_T */
+//#define NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG (1 << 4) /**< msg format : QL_MCM_NW_NITZ_TIME_EVENT_IND_T */
+#define NW_IND_IMS_REG_EVENT_IND_FLAG (1 << 5) /**< msg format : NULL */
-typedef struct
+typedef struct
{
char long_eons[512 + 1]; /**< Long EONS.*/
char short_eons[512 + 1]; /**< Short EONS.*/
@@ -208,8 +217,18 @@
QSER_NW_3GPP2_REG_INFO_T data_registration_details_3gpp2; /**< Data registration details for 3GPP2. */
}QSER_NW_REG_STATUS_INFO_T;
+typedef enum
+{
+ E_QSER_NW_IMS_SERVICE_NONE = 0x0000, /**< Not registered */
+ E_QSER_NW_IMS_SERVICE_REGISTERED = 0x0001, /**< Registered*/
+}E_QSER_NW_IMS_SERVICE_TYPE_T;
-typedef struct
+typedef struct
+{
+ E_QSER_NW_IMS_SERVICE_TYPE_T registration_state; /**< Registration state.*/
+}QSER_NW_IMS_REG_STATUS_INFO_T;
+
+typedef struct
{
int8_t rssi; /**< RSSI in dBm. Indicates received signal strength. A signed value; -125 or lower indicates no signal.*/
}QSER_NW_GSM_SIGNAL_INFO_T;
@@ -379,27 +398,33 @@
int qser_nw_set_config
(
nw_client_handle_type h_nw,
- QSER_NW_CONFIG_INFO_T *pt_info
+ QSER_NW_CONFIG_INFO_T *pt_info
+);
+
+int qser_nw_set_ims_enable
+(
+ nw_client_handle_type h_nw,
+ E_QSER_NW_IMS_MODE_TYPE_T ims_mode
);
int qser_nw_set_oos_config
(
nw_client_handle_type h_nw,
- QSER_NW_OOS_CONFIG_INFO_T *pt_info
+ QSER_NW_OOS_CONFIG_INFO_T *pt_info
);
int qser_nw_get_oos_config
(
nw_client_handle_type h_nw,
- QSER_NW_OOS_CONFIG_INFO_T *pt_info
+ QSER_NW_OOS_CONFIG_INFO_T *pt_info
);
-/*
+
int qser_nw_event_register
(
nw_client_handle_type h_nw,
uint32_t bitmask // bit OR of NW_IND_xxxx_EVENT_ON
);
-*/
+
int qser_nw_get_operator_name
(
nw_client_handle_type h_nw,
@@ -409,7 +434,13 @@
int qser_nw_get_reg_status
(
nw_client_handle_type h_nw,
- QSER_NW_REG_STATUS_INFO_T *pt_info
+ QSER_NW_REG_STATUS_INFO_T *pt_info
+);
+
+int qser_nw_get_ims_reg_status
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_IMS_REG_STATUS_INFO_T *pt_info
);
int qser_nw_get_signal_strength
diff --git a/mbtk/include/lynq/lynq_qser_sim.h b/mbtk/include/lynq/lynq_qser_sim.h
index e1cada7..f49e611 100755
--- a/mbtk/include/lynq/lynq_qser_sim.h
+++ b/mbtk/include/lynq/lynq_qser_sim.h
@@ -183,6 +183,11 @@
QSER_SIM_CARD_ALL_APP_INFO_T card_app_info; /**< Stores all relevant application information. */
}QSER_SIM_CARD_STATUS_INFO_T;
+typedef QSER_SIM_CARD_STATUS_INFO_T* QSER_SIM_MsgRef;
+/* Callback function registered to qser_sms_addrxmsghandler, msgRef contains the detail msg infor */
+typedef void (*QSER_SIM_RxMsgHandlerFunc_t)(QSER_SIM_MsgRef msgRef);
+
+
int qser_sim_client_init(sim_client_handle_type *ph_sim);
int qser_sim_client_deinit(sim_client_handle_type h_sim);
@@ -389,11 +394,9 @@
int
*/
/*=========================================================================*/
-int qser_sim_getimei
-(
- sim_client_handle_type h_sim,
- char *imei
-);
+int qser_sim_getimei(sim_client_handle_type h_sim, char *imei);
+int qser_get_imei_and_sv(sim_client_handle_type h_sim,char *imei, char*sv);
+
/*===========================================================================
@@ -427,10 +430,8 @@
int
*/
/*=========================================================================*/
-int qser_reset_modem
-(
- sim_client_handle_type h_sim
-);
+int qser_reset_modem(sim_client_handle_type h_sim);
+
/*===========================================================================
@@ -445,11 +446,8 @@
int
*/
/*=========================================================================*/
-int qser_get_version
-(
- sim_client_handle_type h_sim,
- char *buf
-);
+int qser_get_version(sim_client_handle_type h_sim, char *buf);
+
/*===========================================================================
@@ -464,10 +462,10 @@
int
*/
/*=========================================================================*/
-int qser_reset_sim
-(
- sim_client_handle_type h_sim
-);
+int qser_reset_sim(sim_client_handle_type h_sim);
+
+int qser_sim_addrxmsghandler(QSER_SIM_RxMsgHandlerFunc_t handlerPtr);
+
#ifdef __cplusplus
}
#endif
diff --git a/mbtk/include/lynq/lynq_qser_sms.h b/mbtk/include/lynq/lynq_qser_sms.h
index b8f2c03..7276fca 100755
--- a/mbtk/include/lynq/lynq_qser_sms.h
+++ b/mbtk/include/lynq/lynq_qser_sms.h
@@ -192,11 +192,7 @@
int qser_sms_client_deinit(sms_client_handle_type h_sms);
/* Delete the SMS specified in the pt_sms_storage */
-int qser_sms_deletefromstorage(sms_client_handle_type h_sms, QSER_sms_storage_info_t *pt_sms_storage);
-
-/* List the SMS sequence numbers specified in pt_sms_storage for deletion
-*/
-int qser_sms_deletefromstoragelist( sms_client_handle_type h_sms, char* del_list);
+int qser_sms_deletefromstorage(sms_client_handle_type h_sms, QSER_sms_storage_info_t *pt_sms_storage);
/* Send sms PDU.
*/
diff --git a/mbtk/include/lynq/lynq_qser_thermal.h b/mbtk/include/lynq/lynq_qser_thermal.h
old mode 100644
new mode 100755
index 5bcc81b..d776dde
--- a/mbtk/include/lynq/lynq_qser_thermal.h
+++ b/mbtk/include/lynq/lynq_qser_thermal.h
@@ -1,12 +1,12 @@
-#ifndef __LYNQ_QSER_THERMAL_H__
-#define __LYNQ_QSER_THERMAL_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int get_thermal_zone(int *numbers, int size);
-#ifdef __cplusplus
-}
-#endif
-#endif
-
+#ifndef _LYNQ_QSER_THERMAL_H_
+#define _LYNQ_QSER_THERMAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define MAX_SIZE 100
+int get_thermal_zone(int *numbers, int size);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/mbtk/include/lynq/lynq_systime.h b/mbtk/include/lynq/lynq_systime.h
index f1d4805..4ea1053 100755
--- a/mbtk/include/lynq/lynq_systime.h
+++ b/mbtk/include/lynq/lynq_systime.h
@@ -14,6 +14,7 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
+#include "lynq_uci.h"
#ifndef _LYNQ_SYSTIME_H_
#define _LYNQ_SYSTIME_H_
diff --git a/mbtk/include/lynq/lynq_uci.h b/mbtk/include/lynq/lynq_uci.h
new file mode 100755
index 0000000..0a08c31
--- /dev/null
+++ b/mbtk/include/lynq/lynq_uci.h
@@ -0,0 +1,38 @@
+#ifndef _LYNQ_UCI_H_
+#define _LYNQ_UCI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <uci.h>
+
+#define LYNQ_UCI_MAX_LEN 128
+#define LYNQ_UCI_SUCCESS 0
+#define LYNQ_UCI_ERROR 1
+#define LYNQ_UCI_FILE "lynq_uci"
+#define LYNQ_UCI_RO_FILE "lynq_uci_ro"
+
+//static struct uci_context * ctx = NULL;
+
+int lynq_del(char *option);
+#if UCI_SUPPORT
+ static int uci_get_value(struct uci_option *o, char *out_buf);
+#endif //uci_support
+int lynq_uci_get(const char *arg, char *out_buf);
+
+int lynq_uci_set(const char *arg);
+
+int lynq_add_section(char *section_type, char *section);
+
+int lynq_set_value(char *section, char *key, char *value);
+
+int lynq_get_value(char *file, char *section, char *key, char *tmp);
+
+
+int lynq_load_config(char *filename);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/mbtk/test/liblynq_lib/fota_test.c b/mbtk/test/liblynq_lib/fota_test.c
deleted file mode 100755
index 0984443..0000000
--- a/mbtk/test/liblynq_lib/fota_test.c
+++ /dev/null
@@ -1,175 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include "lynq-qser-fota.h"
-
-
-
-int fota_cb(int status, int percent)
-{
- printf("status: %d, percent: %d%%\n", status, percent);
- return 0;
-}
-
-int main(void)
-{
- int cmdIdx = 0,i=0;
- int ret = 0;
- int type_path = 0;
- char path[256] = {0};
- char operator[10];
- int opt = 0;
-
-
- while(1)
- {
- printf("=========fota========2\n"
- "\t 0 lynq_fota_set_addr_value\n"
- "\t 1 lynq_rock_main\n"
- "\t 2 lynq_fota_nrestart\n"
- "\t 3 lynq_get_upgrade_status\n"
- "\t 4 Close \n"
- "=========================\n");
-
- fflush(stdin);
- fgets(operator, sizeof(operator), stdin);
- opt = atoi(operator);
-
- switch(opt)
- {
- case 0://"ql_fota_start"
- {
- ret = lynq_fota_set_addr_value("/tmp/updata.bin", 26976256);
- if(ret)
- {
- printf("lynq_fota_set_addr_value failed, ret=%d\n", ret);
- }
-
- break;
- }
- case 1://"ql_fota_start"
- {
- ret = lynq_rock_main(1);
- printf("lynq_rock_main() ret:%d!\n", ret);
-
- break;
- }
- case 2://"ql_fota_start"
- {
- ret = lynq_fota_nrestart();
- printf("lynq_fota_nrestart() ret:%d!\n", ret);
-
- break;
- }
- case 3://"ql_fota_start"
- {
- ret = lynq_get_upgrade_status();
-
- printf("lynq_get_upgrade_status() ret:%d!\n", ret);
-
- break;
- }
- default://"ql_fota_start"
- {
- printf("break\n");
- return 0;
- }
- }
- }
- return 0;
-}
-
-
-int main_1(void)
-{
- int cmdIdx = 0,i=0;
- int ret = 0;
- int type_path = 0;
- char path[256] = {0};
- char operator[10];
- int opt = 0;
-
-
- while(1)
- {
- printf("=========fota========2\n"
- "\t 0 ql_fota_init\n"
- "\t 1 ql_fota_fw_write_by_url\n"
- "\t 2 ql_fota_fw_write\n"
- "\t 3 ql_fota_done\n"
- "\t 4 Close \n"
- "=========================\n");
-
- fflush(stdin);
- fgets(operator, sizeof(operator), stdin);
- opt = atoi(operator);
-
- switch(opt)
- {
- case 0://"ql_fota_start"
- {
- ret = ql_fota_init(fota_cb);
- if(ret)
- {
- printf("ql_fota_init failed, ret=%d\n", ret);
- }
-
- break;
- }
- case 1://"ql_fota_start"
- {
- printf("<** please input url path(http://118.114.239.159:30119/update.bin)**!>\n");
-
- memcpy(path, "http://118.114.239.159:30119/update.bin", strlen("http://118.114.239.159:30119/update.bin"));
- if(!strncasecmp(path, "ftp://", 6) || !strncasecmp(path, "http://", 7) || !strncasecmp(path, "https://", 8)) //url
- {
- ret = ql_fota_fw_write_by_url(path, 3*1024*1024, 10, 600);
- if(ret)
- {
- printf("ql_fota_fw_write_by_url failed, ret=%d\n", ret);
- break;
- }
- }
-
- break;
- }
- case 2://"ql_fota_start"
- {
- printf("<** please input local path( /NVM/updata.bin)>\n");
- ret = ql_fota_fw_write("/NVM/updata.bin", 3*1024*1024);
- if(ret)
- {
- printf("ql_fota_fw_write failed, ret=%d\n", ret);
- }else{
- printf("ql_fota_fw_write success ret £º%\n", ret);
- }
-
- break;
- }
- case 3://"ql_fota_start"
- {
- ret = ql_fota_done(1);
- if(ret)
- {
- printf("ql_fota_done failed, ret=%d\n", ret);
- break;
- }
- else
- {
- printf("download firmware success!\n");
- }
- break;
- }
- default://"ql_fota_start"
- {
- printf("break\n");
- return 0;
- }
- }
- }
- return 0;
-}
-
-
-
diff --git a/mbtk/test/liblynq_lib/lynq-adc-demo.cpp b/mbtk/test/liblynq_lib/lynq-adc-demo.cpp
new file mode 100755
index 0000000..375d7ea
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-adc-demo.cpp
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <lynq/lynq-adc.h>
+
+void handle_adc(const char* adc_name, int adc_type)
+{
+ if (adc_name == NULL)
+ {
+ printf("Error: adc_name is a null pointer\n");
+ return;
+ }
+ int adc_value = qser_adc_show((ADC_CHANNEL_E)adc_type);
+ if (adc_value < 0)
+ {
+ printf("Error: Failed to get the value of %s\n", adc_name);
+ return;
+ }
+ printf("%s value: %d mV\n", adc_name, adc_value);
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc != 2)
+ {
+ printf("Usage: %s <ADC0|ADC1|ADC2>\n", argv[0]);
+ return -1;
+ }
+
+ if (strcmp(argv[1], "ADC0") == 0)
+ {
+ handle_adc("ADC0", ADC0);
+ }
+ else if (strcmp(argv[1], "ADC1") == 0)
+ {
+ handle_adc("ADC1", ADC1);
+ }
+ else if (strcmp(argv[1], "ADC2") == 0)
+ {
+ handle_adc("ADC2", ADC2);
+ }
+ else
+ {
+ printf("Please enter valid parameters: ADC0|ADC1|ADC2\n");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/mbtk/test/liblynq_lib/lynq-audio-demo.cpp b/mbtk/test/liblynq_lib/lynq-audio-demo.cpp
index d97464d..c60480d 100755
--- a/mbtk/test/liblynq_lib/lynq-audio-demo.cpp
+++ b/mbtk/test/liblynq_lib/lynq-audio-demo.cpp
@@ -3,7 +3,8 @@
#include <string.h>
#include <errno.h>
#include "ring_tele.h"
-#include "lynq/lynq-qser-audio.h"
+#include <lynq/lynq-qser-audio.h>
+
static int playback_handle = 1;
diff --git a/mbtk/test/liblynq_lib/lynq-gpio-demo.cpp b/mbtk/test/liblynq_lib/lynq-gpio-demo.cpp
new file mode 100755
index 0000000..fba443f
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-gpio-demo.cpp
@@ -0,0 +1,169 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <lynq/lynq-gpio.h>
+
+static void printUsage(void)
+{
+ printf("-ds [direction] --lynq_gpio_direction_set\n");
+ printf("-vs [value] --lynq_gpio_value_set\n");
+ printf("-ps [pullsel] --lynq_gpio_pullsel_set\n");
+ printf("-vg --lynq_gpio_value_get\n");
+ printf("-pg --lynq_gpio_pullsel_get\n");
+ printf("-quit\n");
+ printf("Please input an cmd:");
+}
+
+
+
+
+int main(int argc,char** argv)
+{
+ int ret;
+ int gpio;
+ int direction;
+ int value;
+ int pullsel;
+ char cmd[16];
+ char *cmd2;
+ char *cmd1;
+
+ if(argc != 2)
+ {
+ printf("wrong input format, please inout lynq-irq-demo <gpio>\n");
+ return -1;
+ }
+ gpio = atoi(argv[1]);
+ printf("gpio is %d\n", gpio);
+ ret = lynq_gpio_init(gpio, 0, 0, 0);
+ if(ret != 0)
+ {
+ printf("lynq_gpio_init fail\n");
+ return -1;
+ }
+ else
+ {
+ printf("lynq_gpio_init success\n");
+ }
+
+ while(1)
+ {
+ printUsage();
+ memset(cmd,0,sizeof(cmd));
+ fgets(cmd, sizeof(cmd), stdin);
+ printf("cmd:%s\n",cmd);
+ cmd1 = strtok(cmd, " ");
+ cmd2 = strtok(NULL, " ");
+ if(strcmp(cmd1,"-ds") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("direction is NULL\n");
+ continue;
+ }
+ direction = atoi(cmd2);
+ ret = lynq_gpio_direction_set(gpio, direction);
+ if(ret != 0)
+ {
+ printf("lynq_gpio_direction_set fail\n");
+ }
+ else
+ {
+ printf("lynq_gpio_direction_set success\n");
+ }
+ }
+
+ else if(strcmp(cmd1,"-vs") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("wake_state is NULL\n");
+ continue;
+ }
+ value = atoi(cmd2);
+ ret = lynq_gpio_value_set(gpio, value);
+ if(ret < 0)
+ {
+ printf("lynq_gpio_value_set fail\n");
+ }
+ else
+ {
+ printf("lynq_gpio_value_set success\n");
+ }
+ }
+
+ else if (strcmp(cmd1,"-ps") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("pullsel is NULL\n");
+ continue;
+ }
+ pullsel = atoi(cmd2);
+ ret = lynq_gpio_pullsel_set(gpio, pullsel);
+ if(ret != 0)
+ {
+ printf("lynq_gpio_pullsel_set fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("lynq_gpio_pullsel_set success\n");
+ }
+ }
+ else if (strcmp(cmd1,"-vg\n") == 0)
+ {
+ ret = lynq_gpio_value_get(gpio);
+ if(ret < 0)
+ {
+ printf("lynq_gpio_value_get fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("lynq_gpio_value_get success\n");
+ printf("ret=%d\n", ret);
+ }
+ }
+ else if(strcmp(cmd1,"-pg\n") == 0)
+ {
+ ret = lynq_gpio_pullsel_get(gpio);
+ if(ret < 0)
+ {
+ printf("lynq_gpio_pullsel_get fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("lynq_gpio_pullsel_get success\n");
+ printf("ret=%d\n", ret);
+ }
+ }
+ else if(strcmp(cmd1,"-quit\n") == 0)
+ {
+ break;
+ }
+ else
+ {
+ printf("wrong input format\n");
+ }
+
+
+ }
+
+
+ ret = lynq_gpio_deinit(gpio);
+ if(ret != 0)
+ {
+ printf("lynq_gpio_deinit fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("lynq_gpio_deinit success\n");
+ }
+
+ return 0;
+
+}
diff --git a/mbtk/test/liblynq_lib/lynq-irq-demo.cc b/mbtk/test/liblynq_lib/lynq-irq-demo.cc
new file mode 100755
index 0000000..eddb286
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-irq-demo.cc
@@ -0,0 +1,159 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <lynq/lynq-irq.h>
+
+
+#define CMD_SET_WAKE "set_wake"
+#define CMD_GET_WAKE "get_wake\n"
+#define CMD_SET_TYPE "set_type"
+#define CMD_GET_TYPE "get_type\n"
+#define CMD_UNINSTALL "uninstall\n"
+#define CMD_QUIT_TEST "quit\n"
+
+int line;
+
+
+static void printUsage(void)
+{
+ printf("Usage:\n");
+ printf("-set_wake <en>\n");
+ printf("-set_type <en>\n");
+ printf("-get_type\n");
+ printf("-get_wake\n");
+ printf("-uninstall\n");
+ printf("-quit\n");
+ printf("Please input an cmd:");
+}
+
+
+static void irq_test_handler(void)
+{
+ int trig_type;
+ trig_type = lynq_irq_get_type(line);
+ printf("this is irq_test_handler\nthis irq is gpio %d,trig_type is %d\n", line_gpio[line], trig_type);
+// return NULL;
+}
+
+
+int main(int argc, char** argv)
+{
+ int ret;
+ int irq;
+ int trig_type;
+ int en;
+ char cmd[16];
+ char *cmd2;
+ char *cmd1;
+
+ if(argc != 3)
+ {
+ printf("wrong input format, please inout lynq-irq-demo <irq_line> <trig_type/wake_state> \n");
+ return -1;
+ }
+ irq = atoi(argv[1]);
+ trig_type = atoi(argv[2]);
+ ret = lynq_irq_install(irq, irq_test_handler, trig_type);
+ if(ret != 0)
+ {
+ printf("lynq_irq_install fail\n");
+ return 0;
+ }
+ else
+ {
+ printf("lynq_irq_install success\n");
+ line = irq;
+ }
+
+ while(1)
+ {
+ printUsage();
+ memset(cmd,0,sizeof(cmd));
+ fgets(cmd, sizeof(cmd), stdin);
+ printf("cmd:%s\n",cmd);
+ cmd1 = strtok(cmd, " ");
+ cmd2 = strtok(NULL, " ");
+ if(strcmp(cmd1, CMD_SET_WAKE) == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("wake_state is NULL\n");
+ break;
+ }
+ en = atoi(cmd2);
+ ret = lynq_irq_set_wake(irq, en);
+ if(ret < 0)
+ {
+ printf("lynq_irq_set_wake fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("lynq_irq_set_wake success\n");
+ printf("ret=%d\n", ret);
+ }
+ }
+ else if(strcmp(cmd1, CMD_GET_WAKE) == 0)
+ {
+ ret = lynq_irq_get_wake(irq);
+ printf("lynq_irq_get_wake ret %d\n", ret);
+ }
+ else if(strcmp(cmd1, CMD_SET_TYPE) == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("trig_type is NULL\n");
+ break;
+ }
+ trig_type = atoi(cmd2);
+ ret = lynq_irq_set_type(line, trig_type);
+ if(ret < 0)
+ {
+ printf("lynq_irq_set_type fail\n");
+ }
+ else
+ {
+ printf("lynq_irq_set_type success\n");
+ }
+ }
+ else if(strcmp(cmd1, CMD_GET_TYPE) == 0)
+ {
+ ret = lynq_irq_get_type(irq);
+ printf("lynq_irq_get_type ret %d\n", ret);
+ }
+ else if(strcmp(cmd1, CMD_UNINSTALL) == 0)
+ {
+ ret = lynq_irq_uninstall(irq);
+ if(ret != 0)
+ {
+ printf("lynq_irq_uninstall fail\n");
+ }
+ else
+ {
+ printf("lynq_irq_uninstall success\n");
+ }
+ }
+ else if(strcmp(cmd1, CMD_QUIT_TEST) == 0)
+ {
+ ret = lynq_irq_uninstall(irq);
+ if(ret != 0)
+ {
+ printf("lynq_irq_uninstall fail\n");
+ }
+ else
+ {
+ printf("lynq_irq_uninstall success\n");
+ }
+ break;
+ }
+ else
+ {
+ printf("wrong input format\n");
+ }
+ }
+
+ return 0;
+}
+
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-autosuspend-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-autosuspend-demo.cpp
new file mode 100755
index 0000000..7100756
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-autosuspend-demo.cpp
@@ -0,0 +1,302 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <lynq/lynq-qser-autosuspend.h>
+
+#define FILE_LOCK_TABLE "/tmp/.lock_table"
+
+#define MAX_LOCK_NUM 128
+
+static void qser_lpm_handler(qser_lpm_edge_t edge_state)
+{
+ printf("this is qser_lpm_handler, edge_state=%d\n", edge_state);
+
+}
+
+static void printUsage(void)
+{
+ printf("-i --qser_lpm_init\n");
+ printf("-d --qser_lpm_deinit\n");
+ printf("-q --quit\n");
+ printf("-e --qser_autosuspend_enable\n");
+ printf("-cl [wakelock name] --qser_wakelock_create \n");
+ printf("-al [wakelock num] --qser_wakelock_lock \n");
+ printf("-rl [wakelock num] --qser_wakelock_unlock \n");
+ printf("-dl [wakelock num] --qser_wakelock_destroy\n");
+ printf("-ws [whitelist num] --qser_whitelist_set\n");
+ printf("-wg --qser_whitelist_get\n");
+ printf("-ccl --check created locks\n");
+ printf("-cll --check lockup locks\n");
+ printf("-cws --check wakeup sources\n");
+ printf("Please input an cmd:");
+}
+
+
+int check_lock(void)
+{
+ int err;
+ int file_fd;
+ int i;
+ int ret;
+ LOCK_TABLE lock_status;
+ file_fd = open(FILE_LOCK_TABLE,O_RDWR);
+ if(file_fd < 0)
+ {
+ err = errno;
+ printf("Error open lock_table file:%s\n", strerror(errno));
+ return -2;
+ }
+
+ memset(&lock_status, 0, sizeof(lock_status));
+ lseek(file_fd,0,SEEK_SET);
+ ret = read(file_fd,(unsigned char *)&lock_status,sizeof(lock_status));
+ if(ret <= 0)
+ {
+ close(file_fd);
+ return -2;
+ }
+ for(i=0;i<MAX_LOCK_NUM;i++)
+ {
+ if(strlen(lock_status.lock_name[i]) != 0)
+ {
+ printf("fd: %d lock_name:%s strlen:%d, pid=%d\n", i, lock_status.lock_name[i], strlen(lock_status.lock_name[i]), lock_status.lock_pid[i]);
+ }
+ }
+
+ close(file_fd);
+ return 0;
+
+}
+
+
+void delete_enter(char *data)
+{
+ char *find = strchr(data, '\n');
+ if(find)
+ *find = '\0';
+ return ;
+}
+
+int main(int argc,char** argv)
+{
+
+ int num;
+ int ret;
+ int len;
+ FILE *fp;
+ char buf[256];
+ char cmd[64];
+ char *cmd2;
+ char *cmd1;
+ char tmp[8];
+ qser_pm_cfg_t *qser_lpm_cfg = NULL;
+ qser_lpm_cfg = (qser_pm_cfg_t *)malloc(sizeof(qser_pm_cfg_t));
+ qser_lpm_cfg->wakeupin.wakeupin_pin = 50;
+ qser_lpm_cfg->wakeupin.wakeupin_edge = E_QL_LPM_FALLING;
+ while(1)
+ {
+ printUsage();
+ memset(cmd,0,sizeof(cmd));
+ fgets(cmd, sizeof(cmd), stdin);
+ cmd1 = strtok(cmd, " ");
+ cmd2 = strtok(NULL, " ");
+ delete_enter(cmd1);
+ printf("cmd1:%s\n", cmd1);
+ if(strcmp(cmd1,"-i") == 0)
+ {
+ ret = qser_lpm_init( qser_lpm_handler, qser_lpm_cfg);
+ if(ret != 0)
+ {
+ printf("lpm init fail\n");
+ break;
+ }
+ else
+ {
+ printf("lpm init success\n");
+ }
+ }
+ else if(strcmp(cmd1,"-e") == 0)
+ {
+ char num='1';
+ ret = qser_autosuspend_enable(num);
+ if(ret != 0)
+ {
+ printf("qser_autosuspend_enable fail\n");
+ }
+ else
+ {
+ printf("qser_autosuspend_enable success\n");
+ }
+ }
+ else if(strcmp(cmd1,"-cl") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("name is null\n");
+ continue;
+ }
+ len = strlen(cmd2);
+ printf("len =%d\n", len);
+ ret = qser_wakelock_create(cmd2, len);
+ if(ret < 0)
+ {
+ printf("wakelock create fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("wakelock create success\n");
+ printf("fd=%d\n", ret);
+ }
+ }
+ else if (strcmp(cmd1,"-al") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("fd is null\n");
+ continue;
+ }
+ num = atoi(cmd2);
+ ret = qser_wakelock_lock(num);
+ if(ret != 0)
+ {
+ printf("wakelock lock fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("wakelock lock success\n");
+ }
+ }
+
+ else if (strcmp(cmd1,"-rl") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("fd is null\n");
+ continue;
+ }
+ num = atoi(cmd2);
+ ret = qser_wakelock_unlock(num);
+ if(ret != 0)
+ {
+ printf("wakelock unlock fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("wakelock unlock success\n");
+ }
+ }
+ else if(strcmp(cmd1,"-dl") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("fd is null\n");
+ continue;
+ }
+ num = atoi(cmd2);
+ ret = qser_wakelock_destroy(num);
+ if(ret != 0)
+ {
+ printf("wakelock destroy fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("wakelock destroy success\n");
+ }
+ }
+ else if(strcmp(cmd1, "-ws") == 0)
+ {
+ if(cmd2 == NULL)
+ {
+ printf("num is null\n");
+ continue;
+ }
+ delete_enter(cmd2);
+ ret = qser_whitelist_set(cmd2);
+ if(ret != 0)
+ {
+ printf("qser_whitlist_set fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("qser_whitlist_set success\n");
+ }
+ }
+ else if(strcmp(cmd1, "-wg") == 0)
+ {
+ ret = qser_whitelist_get(tmp);
+ if(ret != 0)
+ {
+ printf("qser_whitlist_set fail\n");
+ }
+ else
+ {
+ printf("qser_whitlist_set success\n");
+ printf("ret=%d, whilelist state is %s\n", ret, tmp);
+ }
+ }
+ else if(strcmp(cmd1,"-ccl") == 0)
+ {
+ int ret;
+ ret = check_lock();
+ if(ret != 0)
+ {
+ printf("check lock fail\n");
+ printf("ret=%d\n", ret);
+ }
+ else
+ {
+ printf("check lock success\n");
+ }
+ }
+ else if(strcmp(cmd1,"-cll") == 0)
+ {
+ int ret;
+ ret = system("cat /sys/power/wake_lock");
+ if(ret != 0)
+ {
+ printf("check created lock fail\n");
+ }
+ }
+ else if(strcmp(cmd1,"-cws") == 0)
+ {
+ printf("start check active wakeup_sources !!!\n");
+ memset(buf,0,sizeof(buf));
+ fp = popen("cat /sys/kernel/debug/wakeup_sources|sed -e 's/\"^ \"/\"unnamed\"/g' | awk '{print $6 \"\t\" $1}'| grep -v \"^0\" |sort -n \n","r");
+ while(fgets(buf, 255, fp) != NULL)
+ {
+ printf("%s", buf);
+ }
+ pclose(fp);
+ }
+ else if(strcmp(cmd1, "-d") == 0)
+ {
+ ret = qser_lpm_deinit();
+ if(ret != 0)
+ {
+ printf("lpm deinit fail\n");
+ }
+ else
+ {
+ printf("lpm deinit success\n");
+ }
+ }
+ else if(strcmp(cmd1,"-q") == 0)
+ {
+ break;
+ }
+ }
+
+ return 0;
+
+}
diff --git a/mbtk/test/liblynq_lib/lynq-qser-data-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-data-demo.cpp
new file mode 100755
index 0000000..221e25b
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-data-demo.cpp
@@ -0,0 +1,195 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <sys/un.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <lynq/lynq-qser-data.h>
+
+#define MAX_COMMAND_LEN 10
+
+
+void evt_cb(qser_data_call_state_s *state);
+int qser_init_data();
+int qser_deinit_data();
+int data_demo_auto_test(char *apn_name1, char *apn_name2);
+
+qser_data_call_state_s state = {0};
+
+void delete_enter(char data[])
+{
+ char *find = strchr(data, '\n');
+ if(find)
+ *find = '\0';
+ return ;
+}
+void printf_help(void)
+{
+ printf("*******************************User Guide*************************************************\n");
+ printf("usage: lynq-qser-data-demo <apn_name> <apn_type>\n");
+ printf("Example: lynq-qser-data-demo cmwap lynq_apn1\n");
+ printf("*******************************************************************************************\n");
+ return;
+}
+
+/**
+ * @brief qser data call demo entry function.
+ *
+ * @detail This example will take a complete data process
+ * and show you how to call the API in liblynq-qser-data.
+ */
+int main(int argc, char *argv[])
+{
+ int i, ret;
+
+ printf("[%s] [%d] entry !\n", __FUNCTION__, __LINE__);
+ printf("[DATA_DEMO]lynq-qser-data-demo entry !\n");
+
+ if(argc != 3)
+ {
+ printf_help();
+ exit(EXIT_FAILURE);
+ }
+
+ //do initialization
+ ret = qser_data_call_init(evt_cb);
+ if(0 != ret)
+ {
+ printf("initial failed !\n");
+ return -1;
+ }
+
+ data_demo_auto_test(argv[1], argv[2]);
+ qser_data_call_destroy();
+
+ return 0;
+}
+
+//demo示例拨两路apn,一路使用默认apn配置拨号访问公网,另一路建议为私网配置
+int data_demo_auto_test(char *apn_name1, char *apn_type)
+{
+ int ret = 0;
+ char command[MAX_COMMAND_LEN] = {'\0'};
+ bool apn_test1_need_insert = true;
+ unsigned char profile_idx_char1;
+ qser_apn_add_s apn_test1 = {QSER_APN_PDP_TYPE_IPV4V6, QSER_APN_AUTH_PROTO_DEFAULT, NULL, NULL, NULL, NULL};
+ qser_data_call_s apn_normal_datacall;
+ qser_data_call_s apn_test1_datacall;
+ qser_data_call_error_e err = QSER_DATA_CALL_ERROR_NONE;
+
+ memcpy(apn_test1.apn_type,apn_type,QSER_APN_NAME_SIZE);
+ memcpy(apn_test1.apn_name,apn_name1,QSER_APN_NAME_SIZE);
+
+ //1、检查apn是否存在
+ qser_apn_info_list_s apn_list = {0};
+ ret = qser_apn_get_list(&apn_list);
+ if(ret != 0)
+ {
+ printf("\n get apn list error\n");
+ return -1;
+ }
+ for(int i = 0; i < apn_list.cnt; i++)
+ {
+ printf("data_demo_auto_test: pdp_type=%d, auth_proto=%d, apn_name=%s, username=%s, password=%s, apn_type=%s\n"
+ ,apn_list.apn[i].pdp_type, apn_list.apn[i].auth_proto, apn_list.apn[i].apn_name, apn_list.apn[i].username, apn_list.apn[i].password, apn_list.apn[i].apn_type);
+
+ if( apn_list.apn[i].pdp_type == apn_test1.pdp_type
+ && apn_list.apn[i].auth_proto == apn_test1.auth_proto
+ && (strcmp(apn_list.apn[i].apn_name, apn_test1.apn_name) == 0)
+ && (strcmp(apn_list.apn[i].username, apn_test1.username) == 0)
+ && (strcmp(apn_list.apn[i].password, apn_test1.password) == 0)
+ && (strcmp(apn_list.apn[i].apn_type, apn_test1.apn_type) == 0)
+ )
+ {
+ profile_idx_char1 = apn_list.apn[i].profile_idx;
+ apn_test1_need_insert = false;
+ }
+ }
+ //2、若不存在,插入apn
+ if(apn_test1_need_insert)
+ {
+ ret = qser_apn_add(&apn_test1, &profile_idx_char1);
+ if(ret != 0)
+ {
+ printf("\n add apn error\n");
+ return -1;
+ }
+ }
+ //3、拨号
+ apn_normal_datacall.profile_idx = 0;//默认apn profile_idx
+ apn_test1_datacall.profile_idx = profile_idx_char1;
+ //拨号时实际使用的ip_name,userdata,password等配置以apn信息中的为准,不使用datacall中的配置
+ ret = qser_data_call_start(&apn_normal_datacall, &err);//默认apn拨号
+ if(ret != 0)
+ {
+ printf("\nERROR: setup data call fail!!!\n");
+ return -1;
+ }
+
+ ret = qser_data_call_start(&apn_test1_datacall, &err);
+ if(ret != 0)
+ {
+ printf("\nERROR: setup data call fail!!!\n");
+ return -1;
+ }
+
+ printf("\n[DATA_DEMO]Enter --exit to exit data demo\n");
+ while(1)
+ {
+ fgets(command , MAX_COMMAND_LEN, stdin);
+ delete_enter(command);
+ if(strcmp(command,"--exit") == 0)
+ {
+ break;
+ }
+ else
+ {
+ printf("\n[DATA_DEMO]Enter --exit to deactive data call and exit data demo\n");
+ }
+ }
+
+ //4、去激活
+ //去激活时有效入参仅为profile_idx
+ ret = qser_data_call_stop(apn_normal_datacall.profile_idx, apn_normal_datacall.ip_family, &err);
+ if(ret < 0)
+ {
+ printf("\nERROR: deactive data call fail!!!\n");
+ return -1;
+ }
+ ret = qser_data_call_stop(apn_test1_datacall.profile_idx, apn_test1_datacall.ip_family, &err);
+ if(ret < 0)
+ {
+ printf("\nERROR: deactive data call fail!!!\n");
+ return -1;
+ }
+ return 0;
+}
+void evt_cb(qser_data_call_state_s *state)
+{
+ char buf_ip[64] = {0};
+ char buf_gateway[64] = {0};
+ char buf_pri_dns[64] = {0};
+ char buf_sec_dns[64] = {0};
+ printf("DATA_DEMO_CALL_BACK: profile_idx=%d, name=%s, ip_family=%d, state=%d, error=%d\n"
+ , state->profile_idx, state->name, state->ip_family, state->state, state->err);
+ printf("DATA_DEMO_CALL_BACK: v4.ip=%s\n"
+ , inet_ntoa(state->v4.ip));
+ printf("DATA_DEMO_CALL_BACK: v4.gateway=%s\n"
+ , inet_ntoa(state->v4.gateway));
+ printf("DATA_DEMO_CALL_BACK: v4.pri_dns=%s, v4.sec_dns=%s\n"
+ , inet_ntoa(state->v4.pri_dns));
+ printf("DATA_DEMO_CALL_BACK: v4.sec_dns=%s\n"
+ , inet_ntoa(state->v4.sec_dns));
+ inet_ntop(AF_INET6, &(state->v6.ip), buf_ip, sizeof(buf_ip));
+ inet_ntop(AF_INET6, &(state->v6.gateway), buf_gateway, sizeof(buf_gateway));
+ inet_ntop(AF_INET6, &(state->v6.pri_dns), buf_pri_dns, sizeof(buf_pri_dns));
+ inet_ntop(AF_INET6, &(state->v6.sec_dns), buf_sec_dns, sizeof(buf_sec_dns));
+ printf("DATA_DEMO_CALL_BACK: v6.ip=%s, v6.gateway=%s, v6.pri_dns=%s, v6.sec_dns=%s\n"
+ , buf_ip, buf_gateway, buf_pri_dns, buf_sec_dns);
+ //后续对回调函数中返回值的处理建议放在其它线程中进行,避免阻塞在回调函数中影响后续消息上报
+}
diff --git a/mbtk/test/liblynq_lib/lynq-qser-fota-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-fota-demo.cpp
new file mode 100755
index 0000000..de637ec
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-fota-demo.cpp
@@ -0,0 +1,136 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <pthread.h>
+
+int (*lynq_get_upgrade_status)(void);
+int (*lynq_fota_set_addr_value)(char *value,int size);
+int (*lynq_fota_nrestart)(void);
+int (*lynq_rock_main)(int first_run);
+int (*lynq_read_process)(void);
+void *dlHandle_fota = NULL;
+
+void *thread_function_noreboot(void *arg)
+{
+
+ lynq_fota_nrestart();
+ return NULL;
+}
+
+void *thread_function_reboot(void *arg)
+{
+
+ lynq_rock_main(1);
+ return NULL;
+}
+
+
+int main(int argc,char *argv[])
+{
+ int ret = 0;
+ int reboot_flag;
+ char *value = argv[1];
+ printf("Enter main function\n");
+
+ const char *lynqLibPath_fota = "/lib/liblynq-fota.so";
+ dlHandle_fota = dlopen(lynqLibPath_fota, RTLD_NOW);
+ if (dlHandle_fota == NULL)
+ {
+ printf("dlopen dlHandle_fota failed: %s\n", dlerror());
+ return -1;
+ }
+
+ lynq_fota_set_addr_value = (int (*)(char *value,int size))dlsym(dlHandle_fota, "lynq_fota_set_addr_value");
+ if(lynq_fota_set_addr_value == NULL)
+ {
+ printf("lynq fota ser addr value is null\n");
+ return -1;
+ }
+
+ lynq_get_upgrade_status = (int (*)(void))dlsym(dlHandle_fota,"lynq_get_upgrade_status");
+ if(lynq_get_upgrade_status == NULL)
+ {
+ printf("lynq_get_upgrade_status is null\n");
+ return -1;
+ }
+ lynq_fota_nrestart = (int (*)())dlsym(dlHandle_fota,"lynq_fota_nrestart");
+ if(lynq_fota_nrestart == NULL)
+ {
+ printf("lynq_fota_nrestart is null\n");
+ return -1;
+ }
+ lynq_rock_main = (int (*)(int first_run))dlsym(dlHandle_fota,"lynq_rock_main");
+ if(lynq_rock_main == NULL)
+ {
+ printf("lynq_rock_main is null\n");
+ return -1;
+ }
+
+ lynq_read_process = (int (*)(void))dlsym(dlHandle_fota,"lynq_read_process");
+ if(lynq_read_process == NULL)
+ {
+ printf("lynq_read_process is null\n");
+ return -1;
+ }
+
+ ret = lynq_fota_set_addr_value(value,(int )strlen(value));
+ if(ret != 0)
+ {
+ printf("set upgrade package addr failed\n");
+ return -1;
+ }
+ while(1)
+ {
+ printf("Please chose action 0: upgrade done ,not reboot 1: upgrade done ,reboot 2:get upgrade status 3:read fota process \n");
+ scanf("%d",&reboot_flag);
+
+ switch(reboot_flag)
+ {
+ case 0:
+ {
+ pthread_t thread_id_noreboot;
+ int result = pthread_create(&thread_id_noreboot, NULL, thread_function_noreboot, NULL);
+ if (result != 0)
+ {
+ printf("pthread_create failed \n");
+ return -1;;
+ }
+ }
+ break;
+
+ case 1:
+ {
+ pthread_t thread_id_reboot;
+ int result = pthread_create(&thread_id_reboot, NULL, thread_function_reboot, NULL);
+ if (result != 0)
+ {
+ printf("pthread_create failed \n");
+ return -1;;
+ }
+ }
+ break;
+ case 2:
+ printf("Get fota upgrade status \n");
+ ret = lynq_get_upgrade_status();
+ printf("lynq_get_upgrade_status ret is %d\n",ret);
+ break;
+ case 3:
+ printf("get fota upgrade process\n");
+ ret = lynq_read_process();
+ printf("Now upgrade process is %d\n",ret);
+ break;
+ default:
+ printf("please input right flag 0 or 1 or 2 or 3\n");
+ break;
+
+ }
+
+ }
+ return 0;
+
+}
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-gnss-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-gnss-demo.cpp
new file mode 100755
index 0000000..c8fcda2
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-gnss-demo.cpp
@@ -0,0 +1,288 @@
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <termios.h>
+#include <time.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include "lynq-qser-gnss-demo.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+int (*qser_Gnss_Init)(uint32_t *h_gnss);
+int (*qser_Gnss_Deinit)(uint32_t);
+int (*qser_AddRxIndMsgHandler)(gnss_handler_func_t handler_ptr,uint32_t);
+int (*qser_Set_Indications)(uint32_t h_gnss,e_msg_id_t);
+int (*qser_Gnss_Start)(uint32_t h_gnss);
+int (*qser_Gnss_Stop)(uint32_t h_gnss);
+int (*qser_Gnss_Delete_Aiding_Data)(uint32_t,DELETE_AIDING_DATA_TYPE_T);
+int (*qser_Gnss_InjectTime)(uint32_t,LYNQ_INJECT_TIME_INTO_T *time_info);
+int (*qser_Gnss_Server_Configuration)(char *host, char *id, char *password);
+int (*qser_Gnss_download_tle)();
+int (*qser_Gnss_injectEphemeris)(uint32_t);
+int (*qser_Gnss_Set_Frequency)(uint32_t, int);
+void *dlHandle_gnss;
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ int opt = 0;
+ char *lynqLib_gnss = "/lib/liblynq-qser-gnss.so";
+ char dev_file[12] = {0};
+ uint32_t ph_gnss;
+ dlHandle_gnss = dlopen(lynqLib_gnss, RTLD_NOW);
+ while(1)
+ {
+ printf("=========gnss main=========\n");
+ user_help();
+ scanf("%d", &opt);
+ while(getchar()!='\n');
+ switch (opt)
+ {
+ case -1:
+ {
+ printf("main exit\n");
+ return 0;
+ }
+
+ case 1:
+ {
+ qser_Gnss_Init=(int(*)(uint32_t *h_gnss))dlsym(dlHandle_gnss, "qser_Gnss_Init");
+ ret = qser_Gnss_Init(&ph_gnss);
+ if(ret < 0)
+ {
+ printf("mopen_gnss_client_init FAIL.\n");
+ return -1;
+ }
+ printf("mopen_gnss_client_init success , with address=%d\n", ph_gnss);
+ break;
+ }
+ case 2:
+ {
+ qser_Gnss_Deinit=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Deinit");
+ ret =qser_Gnss_Deinit(ph_gnss);
+ if(ret < 0)
+ {
+ printf("mopen_gnss_client_Deinit FAIL.\n");
+ return -1;
+ }
+ printf("mopen_gnss_client_Deinit success \n");
+ break;
+ }
+ case 3:
+ {
+ qser_AddRxIndMsgHandler=(int(*)(gnss_handler_func_t,uint32_t))dlsym(dlHandle_gnss, "qser_AddRxIndMsgHandler");
+ ret = qser_AddRxIndMsgHandler((gnss_handler_func_t)&cb,ph_gnss);
+ if(ret < 0)
+ {
+ printf("lynq_AddRxIndMsgHandler fail\n");
+ qser_Gnss_Deinit(ph_gnss);
+ return -1;
+ }
+ printf("add success\n");
+ break;
+ }
+ case 4:
+ {
+ e_msg_id_t ptr2=E_MT_LOC_MSG_ID_LOCATION_INFO;
+ qser_Set_Indications=(int(*)(uint32_t h_gnss,e_msg_id_t))dlsym(dlHandle_gnss, "qser_Set_Indications");
+ ret = qser_Set_Indications(ph_gnss,ptr2);
+ if(ret < 0)
+ {
+ printf("lynq_Set_LOCATION_INFO fail\n");
+ qser_Gnss_Deinit(ph_gnss);
+ return -1;
+ }
+ printf("set location mode success\n");
+ break;
+ }
+ case 5:
+ {
+ e_msg_id_t ptr4=E_MT_LOC_MSG_ID_NMEA_INFO;
+ qser_Set_Indications=(int(*)(uint32_t h_gnss,e_msg_id_t))dlsym(dlHandle_gnss, "qser_Set_Indications");
+ ret = qser_Set_Indications(ph_gnss,ptr4);
+ if(ret < 0)
+ {
+ printf("lynq_Set_NMEA_INFO fail\n");
+ qser_Gnss_Deinit(ph_gnss);
+ return -1;
+ }
+ printf("set nmea mode success\n");
+ break;
+
+ }
+ case 6:
+ {
+ qser_Gnss_Start=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Start");
+ ret = qser_Gnss_Start(ph_gnss);
+ if(ret < 0)
+ {
+ printf("lynq_Gnss_Start fail\n");
+ return -1;
+ }
+ printf("start success\n");
+ break;
+ }
+ case 7:
+ {
+ qser_Gnss_Stop=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Stop");
+ ret = qser_Gnss_Stop(ph_gnss);
+ if(ret < 0)
+ {
+ printf("lynq_Gnss_Stop fail\n");
+ qser_Gnss_Deinit(ph_gnss);
+ return -1;
+ }
+ printf("stop success\n");
+ break;
+ }
+
+ case 8:
+ {
+ int opt_1;
+ DELETE_AIDING_DATA_TYPE_T ptr;
+ qser_Gnss_Delete_Aiding_Data=(int(*)(uint32_t,DELETE_AIDING_DATA_TYPE_T))dlsym(dlHandle_gnss, "qser_Gnss_Delete_Aiding_Data");
+ printf("=========delete aiding data type=========\n");
+ delete_type();
+ scanf("%d", &opt_1);
+ while(getchar()!='\n');
+ switch(opt_1)
+ {
+ case 0:
+ {
+ ptr = DELETE_NOTHING;//hot
+ break;
+ }
+ case 1:
+ {
+ ptr = DELETE_EPHEMERIS;//warm
+ break;
+ }
+ case 2:
+ {
+ ptr = DELETE_ALMANAC;
+ break;
+ }
+ case 3:
+ {
+ ptr = DELETE_POSITION_TIME;
+ break;
+ }
+ case 4:
+ {
+ ptr = DELETE_UTC;
+ break;
+ }
+ case 5:
+ {
+ ptr = DELETE_ALL;//cold
+ break;
+ }
+ default:
+ {
+ printf("input error\n");
+ return -1;
+ }
+ }
+ ret = qser_Gnss_Delete_Aiding_Data(ph_gnss,ptr);
+ if(ret < 0)
+ {
+ printf("lynq_Gnss_Delete_Aiding_Data %d fail\n",opt_1);
+ qser_Gnss_Deinit(ph_gnss);
+ return -1;
+ }
+ printf("lynq_Gnss_Delete_Aiding_Data %d success\n",opt_1);
+ break;
+ }
+ case 9:
+ {
+ LYNQ_INJECT_TIME_INTO_T time_test;
+ qser_Gnss_InjectTime=(int(*)(uint32_t,LYNQ_INJECT_TIME_INTO_T *time_info))dlsym(dlHandle_gnss, "qser_Gnss_InjectTime");
+ ret = qser_Gnss_InjectTime(ph_gnss,&time_test);
+ if(ret < 0)
+ {
+ printf("qser_Gnss_InjectTime fail\n");
+ qser_Gnss_Deinit(ph_gnss);
+ return -1;
+ }
+ printf("qser_Gnss_InjectTime success\n");
+ break;
+ }
+ case 10:
+ {
+ qser_Gnss_download_tle=(int(*)())dlsym(dlHandle_gnss, "qser_Gnss_download_tle");
+ ret = qser_Gnss_download_tle();
+ if(ret < 0)
+ {
+ printf("qser_Gnss_download_tle fail\n");
+ return -1;
+ }
+ printf("qser_Gnss_download_tle success\n");
+ break;
+ }
+ case 11:
+ {
+ int frequency;
+ qser_Gnss_Set_Frequency=(int(*)(uint32_t, int))dlsym(dlHandle_gnss, "qser_Gnss_Set_Frequency");
+ printf("=========delete aiding data type=========\n");
+ scanf("%d", &frequency);
+ ret = qser_Gnss_Set_Frequency(ph_gnss,frequency);
+ if(ret < 0)
+ {
+ printf("qser_Gnss_Set_Frequency fail\n");
+ return -1;
+ }
+ printf("frequency is %d\n",frequency);
+ printf("qser_Gnss_Set_Frequency success\n");
+ break;
+ }
+ case 12:
+ {
+ int (*qser_Gnss_injectEphemeris)(uint32_t);
+ qser_Gnss_injectEphemeris=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_injectEphemeris");
+ ret = qser_Gnss_injectEphemeris(ph_gnss);
+ if(ret < 0)
+ {
+ printf("qser_Gnss_injectEphemeris fail\n");
+ return -1;
+ }
+ printf("qser_Gnss_injectEphemeri ssuccess\n");
+ break;
+ }
+ case 13:
+ {
+ qser_Gnss_Server_Configuration=(int(*)(char *host, char *id, char *password))dlsym(dlHandle_gnss, "qser_Gnss_Server_Configuration");
+ ret = qser_Gnss_Server_Configuration(NULL,"lcz","123456");
+ if(ret < 0)
+ {
+ printf("qser_Gnss_Server_Configuration fail\n");
+ return -1;
+ }
+ printf("qser_Gnss_Server_Configuration ssuccess\n");
+ break;
+ }
+ default:
+ {
+ printf("input error,please re-enter\n");
+ break;
+ }
+ }
+ }
+ return 0;
+}
+#ifdef __cplusplus
+}
+#endif
diff --git a/mbtk/test/liblynq_lib/lynq-qser-gnss-demo.h b/mbtk/test/liblynq_lib/lynq-qser-gnss-demo.h
new file mode 100755
index 0000000..3dc7552
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-gnss-demo.h
@@ -0,0 +1,132 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+ /**< 0 reserve */
+ E_MT_LOC_MSG_ID_LOCATION_INFO = 1, /**< pv_data = &QL_LOC_LOCATION_INFO_T */
+ /**< 2 reserve */
+ E_MT_LOC_MSG_ID_NMEA_INFO = 3, /**< pv_data = &QL_LOC_NMEA_INFO_T */
+}e_msg_id_t;
+
+#define MOPEN_GNSS_NMEA_MAX_LENGTH 255 /** NMEA string maximum length. */
+typedef struct
+{
+ int64_t timestamp; /**< System Timestamp, marked for when got the nmea data */
+ int length; /**< NMEA string length. */
+ char nmea[MOPEN_GNSS_NMEA_MAX_LENGTH + 1]; /**< NMEA string.*/
+}mopen_gnss_nmea_info_t; /* Message */
+
+struct mopen_location_info_t
+{
+ uint32_t size; /**< Set to the size of mcm_gps_location_t. */
+ int flags; /**< Contains GPS location flags bits. */
+ int position_source; /**< Provider indicator for HYBRID or GPS. */
+ double latitude; /**< Latitude in degrees. */
+ double longitude; /**< Longitude in degrees. */
+ double altitude; /**< Altitude in meters above the WGS 84 reference ellipsoid. */
+ float speed; /**< Speed in meters per second. */
+ float bearing; /**< Heading in degrees. */
+ float accuracy; /**< Expected accuracy in meters. */
+ int64_t timestamp; /**< Timestamp for the location fix in UTC million-second base. */
+ int32_t is_indoor; /**< Location is indoors. */
+ float floor_number; /**< Indicates the floor number. */
+};
+
+/*Instantiate callback function*/
+void cb
+(
+ uint32_t h_loc,
+ e_msg_id_t e_msg_id,
+ void *pv_data,
+ void *context_ptr
+ )
+{
+ printf("e_msg_id=%d\n", e_msg_id);
+ switch(e_msg_id)
+ {
+ case E_MT_LOC_MSG_ID_LOCATION_INFO:
+ {
+ mopen_location_info_t *pt_location = (mopen_location_info_t *)pv_data;
+ printf("**** flag=0x%X, Latitude = %f, Longitude=%f, altitude = %f, speed = %f, timestamp = %lld ****\n",
+ pt_location->flags,
+ pt_location->latitude,
+ pt_location->longitude,
+ pt_location->altitude,
+ pt_location->speed,
+ pt_location->timestamp);
+ break;
+ }
+ case E_MT_LOC_MSG_ID_NMEA_INFO:
+ {
+ mopen_gnss_nmea_info_t *pt_nmea = (mopen_gnss_nmea_info_t *)pv_data;
+
+ printf("**** NMEA info: timestamp=%lld, length=%d, nmea=%s ****\n",
+ pt_nmea->timestamp, pt_nmea->length, pt_nmea->nmea);
+ break;
+ }
+ }
+}
+
+typedef void (*gnss_handler_func_t)
+(
+ uint32_t h_loc,
+ e_msg_id_t e_msg_id,
+ void *pv_data,
+ void *context_ptr
+ );
+
+typedef enum {
+ DELETE_NOTHING = 0, /**< Delete nothing. */
+ DELETE_EPHEMERIS = 1, /**< Delete ephemeris data. */
+ DELETE_ALMANAC = 2, /**< Delete almanac data. */
+ DELETE_POSITION_TIME = 3, /**< Delete position and time data. */
+ DELETE_UTC = 4, /**< Delete UTC data. */
+ DELETE_ALL = 5, /**< Delete all location data. */
+}DELETE_AIDING_DATA_TYPE_T;
+
+typedef struct
+{
+ uint32_t year; // >1980
+ uint32_t month; // 1-12
+ uint32_t day; // 1-31
+ uint32_t hour; // 0-23
+ uint32_t minute; // 0-59
+ uint32_t second; // 0-59
+ uint32_t millisecond; // 0-999
+}LYNQ_INJECT_TIME_INTO_T; /* Message */
+
+
+void user_help(void)
+{
+ printf("\t-1 exit\n"
+ "\t1 gnss init\n"
+ "\t2 gnss deinit \n"
+ "\t3 gnss add handle function\n"
+ "\t4 gnss set single mode\n"
+ "\t5 gnss set get_para_from_nmea mode\n"
+ "\t6 gnss start\n"
+ "\t7 gnss stop\n"
+ "\t8 gnss Delete_Aiding_Data and reset\n"
+ "\t9 gnss injecttime\n"
+ "\t10 gnss download tle\n"
+ "\t11 gnss set frequency\n"
+ "\t12 gnss inject ephemeris\n"
+ "\t13 gnss server_configuration\n"
+ "please input operator: >> ");
+}
+void delete_type(void)
+{
+ printf("\t0 DELETE_NOTHING\n"
+ "\t1 DELETE_EPHEMERIS\n"
+ "\t2 DELETE_ALMANAC\n"
+ "\t3 DELETE_POSITION_TIME \n"
+ "\t4 DELETE_UTC\n"
+ "\t5 DELETE_ALL\n"
+ "please input operator: >> ");
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/mbtk/test/liblynq_lib/lynq-qser-network-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-network-demo.cpp
new file mode 100755
index 0000000..ad38820
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-network-demo.cpp
@@ -0,0 +1,626 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/types.h>
+//#include <pthread.h>
+#include <unistd.h>
+#include "lynq_qser_network.h"
+
+#ifndef LOG_TAG
+#define LOG_TAG "QSER_NETWORK_DEMO"
+#endif
+
+void *handle_network;
+
+int (*qser_nw_client_init_p)(nw_client_handle_type * ph_nw);
+int (*qser_nw_client_deinit_p)(nw_client_handle_type h_nw);
+int (*qser_nw_set_config_p)(nw_client_handle_type h_nw, QSER_NW_CONFIG_INFO_T *pt_info);
+int (*qser_nw_get_operator_name_p)(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info );
+int (*qser_nw_get_reg_status_p)(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info);
+int (*qser_nw_add_rx_msg_handler_p)(nw_client_handle_type h_nw, QSER_NW_RxMsgHandlerFunc_t handlerPtr,void* contextPtr);
+int (*qser_nw_get_signal_strength_p)(nw_client_handle_type h_nw,QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info);
+int (*qser_nw_set_oos_config_p)(nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info);
+int (*qser_nw_get_oos_config_p)(nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info);
+int (*qser_nw_set_rf_mode_p) (nw_client_handle_type h_nw,E_QSER_NW_RF_MODE_TYPE_T rf_mode);
+int (*qser_nw_get_rf_mode_p) (nw_client_handle_type h_nw,E_QSER_NW_RF_MODE_TYPE_T* rf_mode);
+int (*qser_nw_set_ims_enable_p) (nw_client_handle_type h_nw,E_QSER_NW_IMS_MODE_TYPE_T ims_mode);
+int (*qser_nw_get_ims_reg_status_p) (nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info);
+
+
+
+int getFunc()
+{
+ const char *lynq_libpath_network = "/lib/liblynq-qser-network.so";
+
+ handle_network = dlopen(lynq_libpath_network,RTLD_NOW);
+ if(NULL == handle_network)
+ {
+ printf("dlopen lynq_libpath_network fail:%s",dlerror());
+ exit(EXIT_FAILURE);
+ }
+
+ qser_nw_client_init_p = (int (*)(nw_client_handle_type * ph_nw))dlsym(handle_network,"qser_nw_client_init");
+ qser_nw_client_deinit_p = (int (*)(nw_client_handle_type h_nw))dlsym(handle_network,"qser_nw_client_deinit");
+ qser_nw_set_config_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_CONFIG_INFO_T *pt_info))dlsym(handle_network,"qser_nw_set_config");
+ qser_nw_get_operator_name_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info ))dlsym(handle_network,"qser_nw_get_operator_name");
+ qser_nw_get_reg_status_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info))dlsym(handle_network,"qser_nw_get_reg_status");
+ qser_nw_get_signal_strength_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info))dlsym(handle_network,"qser_nw_get_signal_strength");
+ qser_nw_add_rx_msg_handler_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_RxMsgHandlerFunc_t handlerPtr,void* contextPtr))dlsym(handle_network,"qser_nw_add_rx_msg_handler");
+ qser_nw_get_oos_config_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info))dlsym(handle_network,"qser_nw_get_oos_config");
+ qser_nw_set_oos_config_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info))dlsym(handle_network,"qser_nw_set_oos_config");
+ qser_nw_set_rf_mode_p = (int (*)(nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode))dlsym(handle_network,"qser_nw_set_rf_mode");
+ qser_nw_get_rf_mode_p = (int (*)(nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T* rf_mode))dlsym(handle_network,"qser_nw_get_rf_mode");
+ qser_nw_set_ims_enable_p = (int (*)(nw_client_handle_type h_nw, E_QSER_NW_IMS_MODE_TYPE_T ims_mode))dlsym(handle_network,"qser_nw_set_ims_enable");
+ qser_nw_get_ims_reg_status_p = (int (*)(nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info))dlsym(handle_network,"qser_nw_get_ims_reg_status");
+
+ if(qser_nw_client_deinit_p==NULL || qser_nw_client_init_p==NULL || qser_nw_set_config_p ==NULL ||
+ qser_nw_get_operator_name_p == NULL || qser_nw_get_reg_status_p ==NULL || qser_nw_add_rx_msg_handler_p==NULL ||
+ qser_nw_set_rf_mode_p == NULL || qser_nw_get_rf_mode_p == NULL || qser_nw_get_oos_config_p == NULL || qser_nw_set_oos_config_p == NULL ||
+ qser_nw_set_ims_enable_p == NULL || qser_nw_get_ims_reg_status_p == NULL)
+ {
+ printf("get func pointer null");
+ exit(EXIT_FAILURE);
+ }
+ return 0;
+}
+
+static int test_nw(void);
+
+int main(int argc, char const *argv[])
+{
+ printf("--------->[%s,%d] start \n",__FUNCTION__,__LINE__);
+
+ if(getFunc()==0)
+ {
+ test_nw();
+ }
+
+ return 0;
+}
+
+typedef struct
+{
+ int cmdIdx;
+ char *funcName;
+} st_api_test_case;
+
+st_api_test_case at_nw_testlist[] =
+{
+ {0, "qser_nw_client_init"},
+ {1, "qser_nw_set_config"},
+ {2, "qser_nw_get_operator_name"},
+ {3, "qser_nw_get_reg_status"},
+ {4, "qser_nw_add_rx_msg_handler"},
+ {5, "qser_nw_get_signal_strength"},
+ {6, "qser_nw_set_oos_config"},
+ {7, "qser_nw_get_oos_config"},
+ {8, "qser_nw_set_rf_mode"},
+ {9, "qser_nw_get_rf_mode"},
+ {10, "qser_nw_set_ims_enable"},
+ {11, "qser_nw_get_ims_reg_status"},
+ {12, "qser_nw_client_deinit"},
+ {-1, "quit"}
+};
+
+typedef int (*TEST)(void);
+
+typedef struct
+{
+ char *group_name;
+ st_api_test_case *test_cases;
+ TEST pf_test;
+} func_api_test_t;
+
+func_api_test_t t_nw_test = {"nw", at_nw_testlist, test_nw};
+
+void show_group_help(func_api_test_t *pt_test)
+{
+ int i;
+
+ printf("Group Name:%s, Supported test cases:\n", pt_test->group_name);
+ for(i = 0; ; i++)
+ {
+ if(pt_test->test_cases[i].cmdIdx == -1)
+ {
+ break;
+ }
+ printf("%d:\t%s\n", pt_test->test_cases[i].cmdIdx, pt_test->test_cases[i].funcName);
+ }
+}
+
+static nw_client_handle_type h_nw = 0;
+
+char *tech_domain[] = {"NONE", "3GPP", "3GPP2"};
+char *radio_tech[] = {"unknown",
+ "TD_SCDMA", "GSM", "HSPAP", "LTE", "EHRPD", "EVDO_B",
+ "HSPA", "HSUPA", "HSDPA", "EVDO_A", "EVDO_0", "1xRTT",
+ "IS95B", "IS95A", "UMTS", "EDGE", "GPRS", "NONE"};
+
+void nw_event_ind_handler (
+ nw_client_handle_type h_nw,
+ u_int32_t ind_flag,
+ void *ind_msg_buf,
+ u_int32_t ind_msg_len,
+ void *contextPtr)
+{
+ switch(ind_flag) {
+ case NW_IND_VOICE_REG_EVENT_IND_FLAG:
+ {
+ QSER_NW_VOICE_REG_EVENT_IND_T *ind = (QSER_NW_VOICE_REG_EVENT_IND_T*)ind_msg_buf;
+ printf("Recv event indication : VOICE REG EVENT\n");
+
+ if(ind==NULL)
+ {
+ printf("ind is NULL\n");
+ break;
+ }
+
+ if(ind->registration_valid)
+ {
+ printf("voice_registration: \ntech_domain=%s, radio_tech=%s, roaming=%d, registration_state=%d\n",
+ tech_domain[ind->registration.tech_domain],
+ radio_tech[ind->registration.radio_tech],
+ ind->registration.roaming,
+ ind->registration.registration_state);
+ }
+ if(ind->registration_details_3gpp_valid)
+ {
+ printf("voice_registration_details_3gpp: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n",
+ tech_domain[ind->registration_details_3gpp.tech_domain],
+ radio_tech[ind->registration_details_3gpp.radio_tech],
+ ind->registration_details_3gpp.mcc,
+ ind->registration_details_3gpp.mnc,
+ ind->registration_details_3gpp.roaming,
+ ind->registration_details_3gpp.forbidden,
+ ind->registration_details_3gpp.cid,
+ ind->registration_details_3gpp.lac,
+ ind->registration_details_3gpp.psc,
+ ind->registration_details_3gpp.tac);
+ }
+
+ if(ind->registration_details_3gpp2_valid)
+ {
+ printf("voice_registration_details_3gpp2: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, sid=%d, nid=%d, bsid=%d\n",
+ tech_domain[ind->registration_details_3gpp2.tech_domain],
+ radio_tech[ind->registration_details_3gpp2.radio_tech],
+ ind->registration_details_3gpp2.mcc,
+ ind->registration_details_3gpp2.mnc,
+ ind->registration_details_3gpp2.roaming,
+ ind->registration_details_3gpp2.forbidden,
+ ind->registration_details_3gpp2.sid,
+ ind->registration_details_3gpp2.nid,
+ ind->registration_details_3gpp2.bsid);
+ }
+
+ break;
+ }
+ case NW_IND_DATA_REG_EVENT_IND_FLAG:
+ {
+ QSER_NW_DATA_REG_EVENT_IND_T *ind = (QSER_NW_DATA_REG_EVENT_IND_T*)ind_msg_buf;
+
+ printf("Recv event indication : DATA REG EVENT\n");
+
+ if(ind==NULL)
+ {
+ printf("ind is NULL\n");
+ break;
+ }
+
+
+ if(ind->registration_valid)
+ {
+ printf("data_registration: \ntech_domain=%s, radio_tech=%s, roaming=%d, registration_state=%d\n",
+ tech_domain[ind->registration.tech_domain],
+ radio_tech[ind->registration.radio_tech],
+ ind->registration.roaming,
+ ind->registration.registration_state);
+ }
+ if(ind->registration_details_3gpp_valid)
+ {
+ printf("data_registration_details_3gpp: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n",
+ tech_domain[ind->registration_details_3gpp.tech_domain],
+ radio_tech[ind->registration_details_3gpp.radio_tech],
+ ind->registration_details_3gpp.mcc,
+ ind->registration_details_3gpp.mnc,
+ ind->registration_details_3gpp.roaming,
+ ind->registration_details_3gpp.forbidden,
+ ind->registration_details_3gpp.cid,
+ ind->registration_details_3gpp.lac,
+ ind->registration_details_3gpp.psc,
+ ind->registration_details_3gpp.tac);
+ }
+
+ if(ind->registration_details_3gpp2_valid)
+ {
+ printf("data_registration_details_3gpp2: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, prl=%d, css=%d, sid=%d, nid=%d, bsid=%d\n",
+ tech_domain[ind->registration_details_3gpp2.tech_domain],
+ radio_tech[ind->registration_details_3gpp2.radio_tech],
+ ind->registration_details_3gpp2.mcc,
+ ind->registration_details_3gpp2.mnc,
+ ind->registration_details_3gpp2.roaming,
+ ind->registration_details_3gpp2.forbidden,
+ ind->registration_details_3gpp2.inPRL,
+ ind->registration_details_3gpp2.css,
+ ind->registration_details_3gpp2.sid,
+ ind->registration_details_3gpp2.nid,
+ ind->registration_details_3gpp2.bsid);
+ }
+
+ break;
+ }
+ case NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG:
+ {
+ QSER_NW_SINGNAL_EVENT_IND_T *ind = (QSER_NW_SINGNAL_EVENT_IND_T*)ind_msg_buf;
+
+ printf("Recv event indication : SIGNAL STRENGTH EVENT\n");
+
+ if(ind==NULL)
+ {
+ printf("ind is NULL\n");
+ break;
+ }
+
+ if(ind->gsm_sig_info_valid)
+ {
+ printf("gsm_sig_info: rssi=%d\n",
+ ind->gsm_sig_info.rssi);
+ }
+
+ if(ind->wcdma_sig_info_valid)
+ {
+ printf("wcdma_sig_info: rssi=%d, ecio=%d\n",
+ ind->wcdma_sig_info.rssi,
+ ind->wcdma_sig_info.ecio);
+ }
+ if(ind->tdscdma_sig_info_valid)
+ {
+ printf("tdscdma_sig_info: rssi=%d, rscp=%d, ecio=%d, sinr=%d\n",
+ ind->tdscdma_sig_info.rssi,
+ ind->tdscdma_sig_info.rscp,
+ ind->tdscdma_sig_info.ecio,
+ ind->tdscdma_sig_info.sinr);
+ }
+ if(ind->lte_sig_info_valid)
+ {
+ printf("lte_sig_info: rssi=%d, rsrq=%d, rsrp=%d, snr=%d\n",
+ ind->lte_sig_info.rssi,
+ ind->lte_sig_info.rsrq,
+ ind->lte_sig_info.rsrp,
+ ind->lte_sig_info.snr);
+ }
+ if(ind->cdma_sig_info_valid)
+ {
+ printf("cdma_sig_info: rssi=%d, ecio=%d\n",
+ ind->cdma_sig_info.rssi,
+ ind->cdma_sig_info.ecio);
+ }
+ if(ind->hdr_sig_info_valid)
+ {
+ printf("hdr_sig_info: rssi=%d, ecio=%d, sinr=%d, io=%d\n",
+ ind->hdr_sig_info.rssi,
+ ind->hdr_sig_info.ecio,
+ ind->hdr_sig_info.sinr,
+ ind->hdr_sig_info.io);
+ }
+ break;
+ }
+ case NW_IND_IMS_REG_EVENT_IND_FLAG:
+ {
+ printf("Recv event indication : IMS REG EVENT\n");
+
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+static int test_nw(void)
+{
+ int cmdIdx = 0;
+ int ret = 0;
+
+ while(1)
+ {
+ show_group_help(&t_nw_test);
+ printf("please input cmd index(-1 exit): ");
+ ret = scanf("%d", &cmdIdx);
+ if(ret != 1)
+ {
+ char c;
+ while(((c=getchar()) != '\n') && (c != EOF))
+ {
+ ;
+ }
+ continue;
+ }
+ if(cmdIdx == -1)
+ {
+ break;
+ }
+ switch(cmdIdx)
+ {
+ case 0://"qser_nw_client_init"
+ {
+
+ ret = qser_nw_client_init_p(&h_nw);
+ printf("qser_nw_client_init ret = %d\n", ret);
+ break;
+ }
+ case 1://"qser_nw_set_config"
+ {
+ QSER_NW_CONFIG_INFO_T t_info = {0};
+
+ int mask = 0;
+ printf("please input decimal format number, whose hex format is (TDSCDMA | LTE | EVDO | CDMA | WCDMA | GSM) : \n");
+ scanf("%d", &mask);
+ t_info.preferred_nw_mode = mask;
+
+ ret = qser_nw_set_config_p(h_nw, &t_info);
+ printf("qser_nw_set_config ret = %d\n", ret);
+ break;
+ }
+ case 2://"qser_nw_get_operator_name"
+ {
+ QSER_NW_OPERATOR_NAME_INFO_T t_info;
+ ret = qser_nw_get_operator_name_p(h_nw, &t_info);
+ printf("qser_nw_get_operator_name ret = %d, long_eons=%s, short_eons=%s, mcc=%s, mnc=%s\n", ret,
+ t_info.long_eons, t_info.short_eons, t_info.mcc, t_info.mnc);
+ break;
+ }
+ case 3://"qser_nw_get_reg_status"
+ {
+ QSER_NW_REG_STATUS_INFO_T t_info;
+
+ memset(&t_info, 0, sizeof(QSER_NW_REG_STATUS_INFO_T));
+ ret = qser_nw_get_reg_status_p(h_nw, &t_info);
+ printf("qser_nw_get_reg_status ret = %d, detail info:\n", ret);
+ if(t_info.voice_registration_valid)
+ {
+ printf("voice_registration: \ntech_domain=%s, radio_tech=%s, roaming=%d, registration_state=%d\n",
+ tech_domain[t_info.voice_registration.tech_domain],
+ radio_tech[t_info.voice_registration.radio_tech],
+ t_info.voice_registration.roaming,
+ t_info.voice_registration.registration_state);
+ }
+ if(t_info.data_registration_valid)
+ {
+ printf("data_registration: \ntech_domain=%s, radio_tech=%s, roaming=%d, registration_state=%d\n",
+ tech_domain[t_info.data_registration.tech_domain],
+ radio_tech[t_info.data_registration.radio_tech],
+ t_info.data_registration.roaming,
+ t_info.data_registration.registration_state);
+ }
+ if(t_info.voice_registration_details_3gpp_valid)
+ {
+ printf("voice_registration_details_3gpp: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n",
+ tech_domain[t_info.voice_registration_details_3gpp.tech_domain],
+ radio_tech[t_info.voice_registration_details_3gpp.radio_tech],
+ t_info.voice_registration_details_3gpp.mcc,
+ t_info.voice_registration_details_3gpp.mnc,
+ t_info.voice_registration_details_3gpp.roaming,
+ t_info.voice_registration_details_3gpp.forbidden,
+ t_info.voice_registration_details_3gpp.cid,
+ t_info.voice_registration_details_3gpp.lac,
+ t_info.voice_registration_details_3gpp.psc,
+ t_info.voice_registration_details_3gpp.tac);
+ }
+ if(t_info.data_registration_details_3gpp_valid)
+ {
+ printf("data_registration_details_3gpp: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n",
+ tech_domain[t_info.data_registration_details_3gpp.tech_domain],
+ radio_tech[t_info.data_registration_details_3gpp.radio_tech],
+ t_info.data_registration_details_3gpp.mcc,
+ t_info.data_registration_details_3gpp.mnc,
+ t_info.data_registration_details_3gpp.roaming,
+ t_info.data_registration_details_3gpp.forbidden,
+ t_info.data_registration_details_3gpp.cid,
+ t_info.data_registration_details_3gpp.lac,
+ t_info.data_registration_details_3gpp.psc,
+ t_info.data_registration_details_3gpp.tac);
+ }
+
+ if(t_info.voice_registration_details_3gpp2_valid)
+ {
+ printf("voice_registration_details_3gpp2: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, sid=%d, nid=%d, bsid=%d\n",
+ tech_domain[t_info.voice_registration_details_3gpp2.tech_domain],
+ radio_tech[t_info.voice_registration_details_3gpp2.radio_tech],
+ t_info.voice_registration_details_3gpp2.mcc,
+ t_info.voice_registration_details_3gpp2.mnc,
+ t_info.voice_registration_details_3gpp2.roaming,
+ t_info.voice_registration_details_3gpp2.forbidden,
+ t_info.voice_registration_details_3gpp2.sid,
+ t_info.voice_registration_details_3gpp2.nid,
+ t_info.voice_registration_details_3gpp2.bsid);
+ }
+
+ if(t_info.data_registration_details_3gpp2_valid)
+ {
+ printf("data_registration_details_3gpp2: \ntech_domain=%s, radio_tech=%s, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, sid=%d, nid=%d, bsid=%d\n",
+ tech_domain[t_info.data_registration_details_3gpp2.tech_domain],
+ radio_tech[t_info.data_registration_details_3gpp2.radio_tech],
+ t_info.data_registration_details_3gpp2.mcc,
+ t_info.data_registration_details_3gpp2.mnc,
+ t_info.data_registration_details_3gpp2.roaming,
+ t_info.data_registration_details_3gpp2.forbidden,
+ t_info.data_registration_details_3gpp2.sid,
+ t_info.data_registration_details_3gpp2.nid,
+ t_info.data_registration_details_3gpp2.bsid);
+ }
+
+ break;
+ }
+ case 12://"qser_nw_client_deinit"
+ {
+ ret = qser_nw_client_deinit_p(h_nw);
+ printf("qser_nw_client_deinit ret = %d\n", ret);
+ break;
+ }
+ case 4 :
+ {
+ ret = qser_nw_add_rx_msg_handler_p(h_nw, nw_event_ind_handler, NULL);
+ printf("qser_nw_add_rx_msg_handler, ret=%d\n", ret);
+ break;
+ }
+ case 5 :
+ {
+ QSER_NW_SIGNAL_STRENGTH_INFO_T t_info;
+ ret = qser_nw_get_signal_strength_p(h_nw, &t_info);
+ printf("qser_nw_get_signal_strength, ret=%d\n", ret);
+ if(ret==0)
+ {
+ printf("qser_solicited_signal_strength gsm_sig_info_valid = %d\n"
+ " gsm_sig_info.rssi = %d\n"
+ " wcdma _sig_info_valid = %d\n"
+ " wcdma_sig_info.rssi = %d\n"
+ " wcdma_sig_info.ecio = %d\n"
+ " tdscdma_sig_info_valid = %d\n"
+ " lte_sig_info_valid = %d\n"
+ " lte_sig_info.rssi = %d\n"
+ " lte_sig_info.rsrp = %d\n"
+ " lte_sig_info.rsrq = %d\n"
+ " lte_sig_info.snr = %d\n"
+ " cdma_sig_info_valid = %d\n"
+ " hdr_sig_info_valid = %d\n"
+ " nr_sig_info_valid = %d\n"
+ " nr_sig_info.ssRsrp = %d\n"
+ " nr_sig_info.ssRsrq = %d\n"
+ " nr_sig_info.ssSinr = %d\n"
+ " nr_sig_info.csiRsrp = %d\n"
+ " nr_sig_info.csiRsrq = %d\n"
+ " nr_sig_info.csiSinr = %d\n",
+ t_info.gsm_sig_info_valid, t_info.gsm_sig_info.rssi,
+ t_info.wcdma_sig_info_valid, t_info.wcdma_sig_info.rssi, t_info.wcdma_sig_info.ecio,
+ t_info.tdscdma_sig_info_valid,
+ t_info.lte_sig_info_valid, t_info.lte_sig_info.rssi, t_info.lte_sig_info.rsrp, t_info.lte_sig_info.rsrq, t_info.lte_sig_info.snr,
+ t_info.cdma_sig_info_valid,
+ t_info.hdr_sig_info_valid,
+ t_info.nr_sig_info_valid, t_info.nr_sig_info.ssRsrp, t_info.nr_sig_info.ssRsrq, t_info.nr_sig_info.ssSinr,
+ t_info.nr_sig_info.csiRsrp, t_info.nr_sig_info.csiRsrq, t_info.nr_sig_info.csiSinr);
+
+ }
+ break;
+ }
+ case 7 :
+ {
+ QSER_NW_OOS_CONFIG_INFO_T t_info;
+ int type = 0;
+ printf("please input you want query oos config's type (0: fast network scan config; 1: full band network scan config ) : \n");
+ scanf("%d", &type);
+ t_info.type = type;
+ ret = qser_nw_get_oos_config_p(h_nw, &t_info);
+ printf("qser_nw_get_oos_config, ret=%d\n", ret);
+ if(ret==0)
+ {
+ if(t_info.type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
+ {
+ printf("qser_nw_get_oos_config t_min = %d\n"
+ " t_step = %d\n"
+ " t_num = %d\n"
+ " t_max = %d\n",
+ t_info.u.full_band_scan_info.t_min, t_info.u.full_band_scan_info.t_step,
+ t_info.u.full_band_scan_info.t_num, t_info.u.full_band_scan_info.t_max);
+ }
+ else if(t_info.type == QSER_NW_OOS_CFG_TYPE_FAST_SCAN)
+ {
+ printf("qser_nw_get_oos_config enable = %d\n"
+ " time_interval = %d\n",
+ t_info.u.fast_can_info.enable, t_info.u.fast_can_info.time_interval);
+ }
+ else
+ {
+ printf("qser_nw_get_oos_config tyep is %d, ret is ok",t_info.type);
+ }
+
+ }
+ break;
+ }
+ case 6 :
+ {
+ QSER_NW_OOS_CONFIG_INFO_T t_info;
+ int type = 0;
+ printf("please input you want set oos config's type (0: fast network scan config; 1: full band network scan config ) : \n");
+ scanf("%d", &type);
+ t_info.type = type;
+ if(t_info.type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
+ {
+ printf("please input t_min: \n");
+ scanf("%d", &(t_info.u.full_band_scan_info.t_min));
+ printf("please input t_step: \n");
+ scanf("%d", &(t_info.u.full_band_scan_info.t_step));
+ printf("please input t_num: \n");
+ scanf("%d", &(t_info.u.full_band_scan_info.t_num));
+ printf("please input t_max: \n");
+ scanf("%d", &(t_info.u.full_band_scan_info.t_max));
+ ret = qser_nw_set_oos_config_p(h_nw, &t_info);
+ printf("qser_nw_get_oos_config, ret=%d\n", ret);
+ }
+ else if(t_info.type==QSER_NW_OOS_CFG_TYPE_FAST_SCAN)
+ {
+ printf("please input enable: \n");
+ scanf("%d", &(t_info.u.fast_can_info.enable));
+ printf("please input time_interval: \n");
+ scanf("%d", &(t_info.u.fast_can_info.time_interval));
+ ret = qser_nw_set_oos_config_p(h_nw, &t_info);
+ printf("qser_nw_get_oos_config, ret=%d\n", ret);
+ }
+ else
+ {
+ ret = qser_nw_set_oos_config_p(h_nw, &t_info);
+ printf("qser_nw_get_oos_config, ret=%d\n", ret);
+ }
+ break;
+ }
+ case 9://"qser_nw_get_rf_mode"
+ {
+ E_QSER_NW_RF_MODE_TYPE_T rf_mode;
+ ret = qser_nw_get_rf_mode_p(h_nw, &rf_mode);
+ printf("qser_nw_get_rf_mode ret = %d, rf mode=%d\n", ret, rf_mode);
+ break;
+ }
+ case 8://"qser_nw_set_rf_mode"
+ {
+ E_QSER_NW_RF_MODE_TYPE_T rf_mode;
+ printf("please input you want set rf mode (0: cfun 0; 1: cfun 1; 4: flight mode \n");
+ scanf("%d", &rf_mode);
+ ret = qser_nw_set_rf_mode_p(h_nw, rf_mode);
+ printf("qser_nw_set_rf_mode %d ret = %dn",rf_mode, ret);
+ break;
+ }
+ case 10://"qser_nw_set_ims_enable"
+ {
+ E_QSER_NW_IMS_MODE_TYPE_T ims_mode;
+ printf("please input you want set ims mode (0: off; 1: volte enable \n");
+ scanf("%d", &ims_mode);
+ ret = qser_nw_set_ims_enable_p(h_nw, ims_mode);
+ printf("qser_nw_set_ims_enable %d ret = %dn",ims_mode, ret);
+ break;
+ }
+ case 11://"qser_nw_get_ims_reg_status"
+ {
+ QSER_NW_IMS_REG_STATUS_INFO_T t_info;
+ memset(&t_info, 0, sizeof(QSER_NW_IMS_REG_STATUS_INFO_T));
+ ret = qser_nw_get_ims_reg_status_p(h_nw, &t_info);
+ printf("qser_nw_get_ims_reg_status ret = %d, detail info:\n", ret);
+ if(ret == 0)
+ {
+ printf("ims_registration: registration_state=%d\n",
+ t_info.registration_state);
+ }
+ break;
+ }
+ default:
+ {
+ show_group_help(&t_nw_test);
+ }
+ }
+ }
+ return 0;
+}
+
+
+
+
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-sim-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-sim-demo.cpp
new file mode 100755
index 0000000..6ffac93
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-sim-demo.cpp
@@ -0,0 +1,609 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include"lynq-qser-sim-demo.h"
+#include "mbtk_log.h"
+
+
+#define BUF_SIZE 32
+#define BUF_PIN 8
+#define VER_SIZE 128
+
+typedef uint32_t sim_client_handle_type;
+
+sim_client_handle_type ph_sim = 2023;
+sim_client_handle_type h_sim = 2023;
+int flag_init = 0;
+
+int (*qser_sim_client_init)(sim_client_handle_type *ph_sim);
+int (*qser_sim_client_deinit)(sim_client_handle_type h_sim);
+int (*qser_sim_getimsi)(
+ sim_client_handle_type h_sim,
+ QSER_SIM_APP_ID_INFO_T *pt_info, ///< [IN] The SIM identifier info.
+ char *imsi, ///< [OUT] IMSI buffer
+ size_t imsiLen ///< [IN] IMSI buffer length
+);
+
+int (*qser_sim_geticcid)
+(
+ sim_client_handle_type h_sim,
+ QSER_SIM_SLOT_ID_TYPE_T simId, ///< [IN] The SIM identifier.
+ char *iccid, ///< [OUT] ICCID
+ size_t iccidLen ///< [IN] ICCID buffer length
+);
+
+int (*qser_sim_getphonenumber)
+(
+ sim_client_handle_type h_sim,
+ QSER_SIM_APP_ID_INFO_T *pt_info, ///< [IN] The SIM identifier.
+ char *phone_num, ///< [OUT] phone number
+ size_t phoneLen ///< [IN] phone number buffer length
+);
+int (*qser_sim_verifypin)(sim_client_handle_type h_sim, QSER_SIM_VERIFY_PIN_INFO_T *pt_info);
+int (*qser_sim_changepin)(sim_client_handle_type h_sim, QSER_SIM_CHANGE_PIN_INFO_T *pt_info);
+int (*qser_sim_unblockpin)(sim_client_handle_type h_sim, QSER_SIM_UNBLOCK_PIN_INFO_T *pt_info);
+int (*qser_sim_enablepin)(sim_client_handle_type h_sim, QSER_SIM_ENABLE_PIN_INFO_T *pt_info);
+int (*qser_sim_disablepin)(sim_client_handle_type h_sim, QSER_SIM_DISABLE_PIN_INFO_T *pt_info);
+int (*qser_sim_getcardstatus)(sim_client_handle_type h_sim, QSER_SIM_SLOT_ID_TYPE_T simId, QSER_SIM_CARD_STATUS_INFO_T *pt_info);
+int (*qser_sim_getimei)(sim_client_handle_type h_sim, char *imei);
+int (*qser_get_imei_and_sv)(sim_client_handle_type h_sim,char *imei, char*sv);
+int (*qser_reset_modem)(sim_client_handle_type h_sim);
+int (*qser_get_version)(sim_client_handle_type h_sim, char *buf);
+int (*qser_reset_sim)(sim_client_handle_type h_sim);
+int (*qser_sim_addrxmsghandler)(QSER_SIM_RxMsgHandlerFunc_t handlerPtr);
+
+
+typedef struct
+{
+ int cmdIdx;
+ const char *funcName;
+} st_api_test_case;
+
+//for server test
+st_api_test_case at_api_testcases[] =
+{
+ {0, "qser_sim_init"},
+ {1, "qser_get_imsi"},
+ {2, "qser_get_iccid"},
+ {3, "qser_get_phonenumber"},
+ {4, "qser_verify_pin"},
+ {5, "qser_change_pin"},
+ {6, "qser_unlock_pin"},
+ {7, "qser_enable_pin"},
+ {8, "qser_disable_pin"},
+ {9, "qser_get_sim_status"},
+ {10, "qser_get_imei"},
+ {11, "qser_get_imei_and_sv"},
+ {12, "qser_reset_modem"},
+ {13, "qser_get_version"},
+ {14, "qser_reset_sim"},
+ {15, "qser_sim_addrxmsghandler"},
+ {16, "qser_deinit_sim"},
+ {-1, NULL}
+};
+
+void print_help(void)
+{
+ int i;
+ printf("Supported test cases:\n");
+ for(i = 0; ; i++)
+ {
+ if(at_api_testcases[i].cmdIdx == -1)
+ {
+ break;
+ }
+ printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);
+ }
+}
+
+void qser_sim_handler(QSER_SIM_MsgRef msgRef) {
+ printf("[%s-%d] sim, state = 0x%x========\n", __FUNCTION__, __LINE__, msgRef->e_card_state);
+}
+
+int main(int argc, char const *argv[])
+{
+ int cmdIdx = 0;
+ int res = 0;
+
+ mbtk_log_init("radio", "MBTK");
+
+ const char *lynq_libpath_sim = "/lib/liblynq-qser-sim.so";
+ void *dlHandle_sim = dlopen(lynq_libpath_sim, RTLD_NOW);
+ if (dlHandle_sim == NULL)
+ {
+ printf("dlopen dlHandle_sim failed: %s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+
+ print_help();
+ while(1)
+ {
+ printf("\nplease input cmd index(-1 exit): ");
+ scanf("%d", &cmdIdx);
+ if(cmdIdx == -1)
+ {
+ break;
+ }
+
+ switch(cmdIdx)
+ {
+ //"qser_sim_init"
+ case 0:
+ {
+ if(flag_init == 1)
+ {
+ printf("init is already\n");
+ break;
+ }
+ else{
+ //int token;
+ //printf("input token\n");
+ //scanf("%d", &token);
+ qser_sim_client_init = (int(*)(sim_client_handle_type *ph_sim))dlsym(dlHandle_sim,"qser_sim_client_init");
+ if(NULL != qser_sim_client_init)
+ {
+ res = qser_sim_client_init(&ph_sim);
+ if(res == 0)
+ {
+ printf("Run qser_sim_client_init\n");
+ flag_init = 1;
+ }else{
+ printf("qser_sim_client_init error\n");
+ }
+ }else{
+ printf("qser_sim_client_init dlsym error\n");
+ }
+ break;
+ }
+ }
+
+ //"qser_sim_getimsi"
+ case 1:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char imsi[BUF_SIZE] = {0};
+ QSER_SIM_APP_ID_INFO_T pt_info;
+ qser_sim_getimsi = (int(*)(sim_client_handle_type h_sim, QSER_SIM_APP_ID_INFO_T *pt_info, char *imsi, size_t imsiLen))dlsym(dlHandle_sim,"qser_sim_getimsi");
+ if(NULL != qser_sim_getimsi)
+ {
+ res = qser_sim_getimsi(h_sim, &pt_info, imsi, 0);
+ if(res == 0)
+ {
+ printf("imsi is %s!!!\n",imsi);
+ }else{
+ printf("get imsi error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_getimsi dlsym error\n");
+ }
+ }
+ break;
+ }
+
+ //"qser_get_iccid"
+ case 2:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char iccid[BUF_SIZE] = {0};
+ qser_sim_geticcid = (int(*)(sim_client_handle_type h_sim, QSER_SIM_SLOT_ID_TYPE_T simId, char *iccid, size_t iccidLen))dlsym(dlHandle_sim,"qser_sim_geticcid");
+ if(NULL != qser_sim_geticcid)
+ {
+ res = qser_sim_geticcid(h_sim, QSER_SIM_SLOT_ID_1, iccid, 0);
+ if(res == 0)
+ {
+ printf("get iccid success!!! iccid is %s\n",iccid);
+ }else{
+ printf("get iccid error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_geticcid dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_get_phonenumber
+ case 3:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char phonenumber[BUF_SIZE] = "";
+ QSER_SIM_APP_ID_INFO_T pt_info;
+ qser_sim_getphonenumber = (int(*)(sim_client_handle_type h_sim, QSER_SIM_APP_ID_INFO_T *pt_info, char *phone_num, size_t phoneLen))dlsym(dlHandle_sim,"qser_sim_getphonenumber");
+ if(NULL != qser_sim_getphonenumber)
+ {
+ res = qser_sim_getphonenumber(h_sim, &pt_info, phonenumber, 0);
+ if(res == 0)
+ {
+ printf("get phonenumber success!!! phonenumber is %s\n",phonenumber);
+ }else{
+ printf("get phonenumber error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_getphonenumber dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_verify_pin
+ case 4:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char pin[BUF_PIN] = {0};
+ QSER_SIM_VERIFY_PIN_INFO_T pt_info;
+ printf("input pin\n");
+ scanf("%s", pin);
+ strncpy(pt_info.pin_value, pin, BUF_PIN);
+ printf("pin_value = %s , pin = %s\n", pt_info.pin_value, pin);
+
+ qser_sim_verifypin = (int(*)(sim_client_handle_type h_sim, QSER_SIM_VERIFY_PIN_INFO_T *pt_info))dlsym(dlHandle_sim,"qser_sim_verifypin");
+ if(NULL != qser_sim_verifypin)
+ {
+ res = qser_sim_verifypin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("verify pin success!!!\n");
+ }else{
+ printf("verify pin error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_verifypin dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_change_pin
+ case 5:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char old_pin[BUF_PIN] = {0};
+ QSER_SIM_CHANGE_PIN_INFO_T pt_info;
+ printf("input old pin\n");
+ scanf("%s", old_pin);
+ char new_pin[BUF_PIN] = {0};
+ printf("input new pin\n");
+ scanf("%s", new_pin);
+ strncpy(pt_info.old_pin_value, old_pin, BUF_PIN);
+ strncpy(pt_info.new_pin_value, new_pin, BUF_PIN);
+ printf("pt_info.old_pin_value = %s, old_pin = %s\n", pt_info.old_pin_value, old_pin);
+ printf("pt_info.new_pin_value = %s, new_pin = %s\n", pt_info.new_pin_value, new_pin);
+
+ qser_sim_changepin = (int(*)(sim_client_handle_type h_sim, QSER_SIM_CHANGE_PIN_INFO_T *pt_info))dlsym(dlHandle_sim,"qser_sim_changepin");
+ if(NULL != qser_sim_changepin)
+ {
+ res = qser_sim_changepin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("change pin success!!!\n");
+ }else{
+ printf("change pin error, res = %d\n", res);
+ }
+ }else{
+ printf("lynq_change_pin dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_unlock_pin
+ case 6:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char puk[BUF_PIN] = {0};
+ QSER_SIM_UNBLOCK_PIN_INFO_T pt_info;
+ printf("input puk\n");
+ scanf("%s", puk);
+ char new_pin[BUF_PIN] = {0};
+ printf("input new pin\n");
+ scanf("%s", new_pin);
+ memset(pt_info.puk_value, 0, sizeof(pt_info.puk_value));
+ memset(pt_info.new_pin_value, 0, sizeof(pt_info.new_pin_value));
+ strncpy(pt_info.puk_value, puk, BUF_PIN);
+ strncpy(pt_info.new_pin_value, new_pin, BUF_PIN);
+ printf("pt_info.puk_value = %s, puk = %s\n", pt_info.puk_value, puk);
+ printf("pt_info.new_pin_value = %s, new_pin = %s\n", pt_info.new_pin_value, new_pin);
+
+ qser_sim_unblockpin = (int(*)(sim_client_handle_type h_sim, QSER_SIM_UNBLOCK_PIN_INFO_T *pt_info))dlsym(dlHandle_sim,"qser_sim_unblockpin");
+ if(NULL != qser_sim_unblockpin)
+ {
+ res = qser_sim_unblockpin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("unlock pin success!!!\n");
+ }else{
+ printf("unlock pin error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_unblockpin dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_enable_pin
+ case 7:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char pin[BUF_PIN] = {0};
+ QSER_SIM_ENABLE_PIN_INFO_T pt_info;
+ printf("input pin\n");
+ scanf("%s", pin);
+ strncpy(pt_info.pin_value, pin, BUF_PIN);
+
+ qser_sim_enablepin = (int(*)(sim_client_handle_type h_sim, QSER_SIM_ENABLE_PIN_INFO_T *pt_info))dlsym(dlHandle_sim,"qser_sim_enablepin");
+ if(NULL != qser_sim_enablepin)
+ {
+ res = qser_sim_enablepin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("pin enabled!!!\n");
+ }else{
+ printf("pin enable error, res =%d\n", res);
+ }
+ }else{
+ printf("qser_sim_enablepin dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_disable_pin
+ case 8:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char pin[BUF_PIN] = {0};
+ QSER_SIM_ENABLE_PIN_INFO_T pt_info;
+ printf("input pin\n");
+ scanf("%s", pin);
+ strncpy(pt_info.pin_value, pin, BUF_PIN);
+
+ qser_sim_disablepin = (int(*)(sim_client_handle_type h_sim, QSER_SIM_DISABLE_PIN_INFO_T *pt_info))dlsym(dlHandle_sim,"qser_sim_disablepin");
+ if(NULL != qser_sim_disablepin)
+ {
+ res = qser_sim_disablepin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("pin disnabled!!!\n");
+ }else{
+ printf("pin disable error,res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_disablepin dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_get_sim_status
+ case 9:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ QSER_SIM_CARD_STATUS_INFO_T pt_info;
+
+ qser_sim_getcardstatus = (int(*)(sim_client_handle_type h_sim, QSER_SIM_SLOT_ID_TYPE_T simId, QSER_SIM_CARD_STATUS_INFO_T *pt_info))dlsym(dlHandle_sim,"qser_sim_getcardstatus");
+ if(NULL != qser_sim_getcardstatus)
+ {
+ res = qser_sim_getcardstatus(h_sim, QSER_SIM_SLOT_ID_1, &pt_info);
+ if(res == 0)
+ {
+ printf("state is 0x%x !!!\n",pt_info.e_card_state);
+ }else{
+ printf("get imsi error,res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_getcardstatus dlsym error\n");
+ }
+ }
+ break;
+ }
+ //qser_deinit_sim
+ case 10:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char imei[BUF_SIZE]="";
+ qser_sim_getimei = (int(*)(sim_client_handle_type h_sim, char *imei))dlsym(dlHandle_sim,"qser_sim_getimei");
+ if(NULL != qser_sim_getimei)
+ {
+ res = qser_sim_getimei(h_sim, imei);
+ if(res == 0)
+ {
+ printf("get imei success!!!\n");
+ }else{
+ printf("get imei error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_getimei dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
+ //qser_get_imei_and_sv
+ case 11:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char imei[BUF_SIZE]="";
+ char sv[BUF_SIZE]="";
+ qser_get_imei_and_sv = (int(*)(sim_client_handle_type h_sim, char *imei, char *sv))dlsym(dlHandle_sim,"qser_get_imei_and_sv");
+ if(NULL != qser_get_imei_and_sv)
+ {
+ res = qser_get_imei_and_sv(h_sim, imei, sv);
+ if(res == 0)
+ {
+ printf("get imei and sv success!!!\n");
+ }else{
+ printf("get imei and sv error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_get_imei_and_sv dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
+ //qser_reset_modem
+ case 12:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ qser_reset_modem = (int(*)(sim_client_handle_type h_sim))dlsym(dlHandle_sim,"qser_reset_modem");
+ if(NULL != qser_reset_modem)
+ {
+ res = qser_reset_modem(h_sim);
+ if(res == 0)
+ {
+ printf("reset modem success!!!\n");
+ }else{
+ printf("reset modem error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_reset_modem dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
+ //qser_get_version
+ case 13:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ char buf[VER_SIZE]="";
+ qser_get_version = (int(*)(sim_client_handle_type h_sim, char *buf))dlsym(dlHandle_sim,"qser_get_version");
+ if(NULL != qser_get_version)
+ {
+ res = qser_get_version(h_sim, buf);
+ if(res == 0)
+ {
+ printf("get version success!!!\n");
+ }else{
+ printf("get version error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_get_version dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
+ //qser_reset_sim
+ case 14:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ qser_reset_sim = (int(*)(sim_client_handle_type h_sim))dlsym(dlHandle_sim,"qser_reset_sim");
+ if(NULL != qser_reset_sim)
+ {
+ res = qser_reset_sim(h_sim);
+ if(res == 0)
+ {
+ printf("reset sim success!!!\n");
+ }else{
+ printf("reset sim error, res = %d\n", res);
+ }
+ }else{
+ printf("qser_reset_sim dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
+ case 15://qser_sim_addrxmsghandler
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ qser_sim_addrxmsghandler = (int(*)(QSER_SIM_RxMsgHandlerFunc_t handlerPtr))dlsym(dlHandle_sim,"qser_sim_addrxmsghandler");
+ if(NULL != qser_sim_addrxmsghandler)
+ {
+ res = qser_sim_addrxmsghandler(qser_sim_handler);
+ if(res == 0)
+ {
+ printf("sim addrxmsghandler success is!!!\n");
+ }else{
+ printf("sim addrxmsghandler errors, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_addrxmsghandler dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
+ //qser_deinit_sim
+ case 16:
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ qser_sim_client_deinit = (int(*)(sim_client_handle_type h_sim))dlsym(dlHandle_sim,"qser_sim_client_deinit");
+ if(NULL != qser_sim_client_deinit)
+ {
+ res = qser_sim_client_deinit(h_sim);
+ if(res == 0)
+ {
+ printf("sim deinit success is!!!\n");
+ }else{
+ printf("sim deint errors, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_client_deinit dlsym error\n");
+ }
+ }
+ flag_init = 0;
+ break;
+ }
+ default:
+ print_help();
+ break;
+ }
+
+ }
+
+ return 0;
+
+
+}
+
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-sim-demo.h b/mbtk/test/liblynq_lib/lynq-qser-sim-demo.h
new file mode 100755
index 0000000..1a4829b
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-sim-demo.h
@@ -0,0 +1,171 @@
+#define QSER_SIM_IMSI_LEN_MAX 16 /** Maximum length of IMSI data. */
+#define QSER_SIM_ICCID_LEN_MAX 20 /** Maximum length of ICCID data. */
+
+
+typedef enum
+{
+ E_QSER_SUCCESS = 0, /**< Success. */
+ E_QSER_ERROR_BADPARM = 4, /**< Bad parameter. */
+}E_QSER_ERROR_CODE_T;
+
+typedef enum
+{
+ QSER_SIM_SLOT_ID_1 = 0xB01, /**< Identify card in slot 1. */
+ QSER_SIM_SLOT_ID_2 = 0xB02, /**< Identify card in slot 2. */
+}QSER_SIM_SLOT_ID_TYPE_T;
+
+typedef enum
+{
+ QSER_SIM_APP_TYPE_UNKNOWN = 0xB00, /**< Unknown application type */
+ QSER_SIM_APP_TYPE_3GPP = 0xB01, /**< Identify the SIM/USIM application on the card. */
+ QSER_SIM_APP_TYPE_3GPP2 = 0xB02, /**< Identify the RUIM/CSIM application on the card. */
+ QSER_SIM_APP_TYPE_ISIM = 0xB03, /**< Identify the ISIM application on the card. */
+}QSER_SIM_APP_TYPE_T;
+
+typedef struct
+{
+ QSER_SIM_SLOT_ID_TYPE_T e_slot_id; /**< Indicates the slot to be used. */
+ QSER_SIM_APP_TYPE_T e_app; /**< Indicates the type of the application. */
+}QSER_SIM_APP_ID_INFO_T; /* Type */
+
+#define QSER_SIM_PIN_LEN_MAX 8+1 /** Maximum length of PIN data. */
+
+typedef enum
+{
+ QSER_SIM_PIN_ID_1 = 0xB01, /**< Level 1 user verification. */
+ QSER_SIM_PIN_ID_2 = 0xB02, /**< Level 2 user verification. */
+}QSER_SIM_PIN_ID_TYPE_T;
+
+typedef struct
+{
+ QSER_SIM_APP_ID_INFO_T app_info; /**< Application identification information. */
+ QSER_SIM_PIN_ID_TYPE_T pin_id; /**< PIN ID. */
+ uint32_t pin_value_len; /**< Must be set to the number of elements in pin_value. */
+ char pin_value[QSER_SIM_PIN_LEN_MAX]; /* Value of the PIN */
+}QSER_SIM_VERIFY_PIN_INFO_T;
+
+typedef struct
+{
+ QSER_SIM_APP_ID_INFO_T app_info; /**< Application identification information. */
+ QSER_SIM_PIN_ID_TYPE_T pin_id; /**< PIN ID. */
+ uint32_t old_pin_value_len; /**< Must be set to the number of elements in old_pin_value. */
+ char old_pin_value[QSER_SIM_PIN_LEN_MAX]; /**< Value of the old PIN as a sequence of ASCII characters. */
+ uint32_t new_pin_value_len; /**< Must be set to the number of elements in new_pin_value. */
+ char new_pin_value[QSER_SIM_PIN_LEN_MAX]; /**< Value of the new PIN as a sequence of ASCII characters. */
+}QSER_SIM_CHANGE_PIN_INFO_T;
+
+typedef struct
+{
+ QSER_SIM_APP_ID_INFO_T app_info; /**< Application identification information. */
+ QSER_SIM_PIN_ID_TYPE_T pin_id; /**< PIN ID. */
+ uint32_t puk_value_len; /**< Must be set to the number of elements in puk_value. */
+ char puk_value[QSER_SIM_PIN_LEN_MAX]; /**< Value of the PUK as a sequence of ASCII characters. */
+ uint32_t new_pin_value_len; /**< Must be set to the number of elements in new_pin_value. */
+ char new_pin_value[QSER_SIM_PIN_LEN_MAX]; /**< Value of the new PIN as a sequence of ASCII characters. */
+}QSER_SIM_UNBLOCK_PIN_INFO_T;
+
+/** Enables the PIN on an application. */
+typedef QSER_SIM_VERIFY_PIN_INFO_T QSER_SIM_ENABLE_PIN_INFO_T; //Same
+
+/** Disables the PIN of an application, */
+typedef QSER_SIM_VERIFY_PIN_INFO_T QSER_SIM_DISABLE_PIN_INFO_T; //Same
+
+
+typedef enum
+{
+ QSER_SIM_PERSO_FEATURE_TYPE_UNKNOWN = 0xB00, /**< Unknown personalization feature. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP_NETWORK = 0xB01, /**< Featurization based on 3GPP MCC and MNC. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP_NETWORK_SUBSET = 0xB02, /**< Featurization based on 3GPP MCC, MNC, and IMSI digits 6 and 7. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP_SERVICE_PROVIDER = 0xB03, /**< Featurization based on 3GPP MCC, MNC, and GID1. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP_CORPORATE = 0xB04, /**< Featurization based on 3GPP MCC, MNC, GID1, and GID2. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP_SIM = 0xB05, /**< Featurization based on the 3GPP IMSI. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP2_NETWORK_TYPE_1 = 0xB06, /**< Featurization based on 3GPP2 MCC and MNC. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP2_NETWORK_TYPE_2 = 0xB07, /**< Featurization based on 3GPP2 IRM code. */
+ QSER_SIM_PERSO_FEATURE_TYPE_3GPP2_RUIM = 0xB08, /**< Featurization based on 3GPP2 IMSI_M. */
+}QSER_SIM_PERSO_FEATURE_TYPE_T;
+
+typedef enum
+{
+ QSER_SIM_CARD_STATE_UNKNOWN = 0xB01, /**< Card state unknown. */
+ QSER_SIM_CARD_STATE_ABSENT = 0xB02, /**< Card is absent. */
+ QSER_SIM_CARD_STATE_PRESENT = 0xB03, /**< Card is present. */
+ QSER_SIM_CARD_STATE_ERROR_UNKNOWN = 0xB04, /**< Unknown error state. */
+ QSER_SIM_CARD_STATE_ERROR_POWER_DOWN = 0xB05, /**< Power down. */
+ QSER_SIM_CARD_STATE_ERROR_POLL_ERROR = 0xB06, /**< Poll error. */
+ QSER_SIM_CARD_STATE_ERROR_NO_ATR_RECEIVED = 0xB07, /**< Failed to receive an answer to reset. */
+ QSER_SIM_CARD_STATE_ERROR_VOLT_MISMATCH = 0xB08, /**< Voltage mismatch. */
+ QSER_SIM_CARD_STATE_ERROR_PARITY_ERROR = 0xB09, /**< Parity error. */
+ QSER_SIM_CARD_STATE_ERROR_SIM_TECHNICAL_PROBLEMS= 0xB0A, /**< Card returned technical problems. */
+}QSER_SIM_CARD_STATE_TYPE_T; /**< Card state. */
+
+typedef enum
+{
+ QSER_SIM_CARD_TYPE_UNKNOWN = 0xB00, /**< Unidentified card type. */
+ QSER_SIM_CARD_TYPE_ICC = 0xB01, /**< Card of SIM or RUIM type. */
+ QSER_SIM_CARD_TYPE_UICC = 0xB02, /**< Card of USIM or CSIM type. */
+}QSER_SIM_CARD_TYPE_T;
+
+typedef enum
+{
+ QSER_SIM_PROV_STATE_NONE = 0xB00, /**< Nonprovisioning. */
+ QSER_SIM_PROV_STATE_PRI = 0xB01, /**< Primary provisioning subscription. */
+ QSER_SIM_PROV_STATE_SEC = 0xB02, /**< Secondary provisioning subscription. */
+}QSER_SIM_SUBSCRIPTION_TYPE_T;
+
+typedef enum
+{
+ QSER_SIM_APP_STATE_UNKNOWN = 0xB00, /**< Application state unknown. */
+ QSER_SIM_APP_STATE_DETECTED = 0xB01, /**< Detected state. */
+ QSER_SIM_APP_STATE_PIN1_REQ = 0xB02, /**< PIN1 required. */
+ QSER_SIM_APP_STATE_PUK1_REQ = 0xB03, /**< PUK1 required. */
+ QSER_SIM_APP_STATE_INITALIZATING = 0xB04, /**< Initializing. */
+ QSER_SIM_APP_STATE_PERSO_CK_REQ = 0xB05, /**< Personalization control key required. */
+ QSER_SIM_APP_STATE_PERSO_PUK_REQ = 0xB06, /**< Personalization unblock key required. */
+ QSER_SIM_APP_STATE_PERSO_PERMANENTLY_BLOCKED= 0xB07, /**< Personalization is permanently blocked. */
+ QSER_SIM_APP_STATE_PIN1_PERM_BLOCKED = 0xB08, /**< PIN1 is permanently blocked. */
+ QSER_SIM_APP_STATE_ILLEGAL = 0xB09, /**< Illegal application state. */
+ QSER_SIM_APP_STATE_READY = 0xB0A, /**< Application ready state. @newpage */
+}QSER_SIM_APP_STATE_TYPE_T;
+
+typedef enum
+{
+ QSER_SIM_PIN_STATE_UNKNOWN = 0xB01, /**< Unknown PIN state. */
+ QSER_SIM_PIN_STATE_ENABLED_NOT_VERIFIED = 0xB02, /**< PIN required, but has not been verified. */
+ QSER_SIM_PIN_STATE_ENABLED_VERIFIED = 0xB03, /**< PIN required and has been verified. */
+ QSER_SIM_PIN_STATE_DISABLED = 0xB04, /**< PIN not required. */
+ QSER_SIM_PIN_STATE_BLOCKED = 0xB05, /**< PIN verification has failed too many times and is blocked. Recoverable through PUK verification. */
+ QSER_SIM_PIN_STATE_PERMANENTLY_BLOCKED = 0xB06, /**< PUK verification has failed too many times and is not recoverable. */
+}QSER_SIM_PIN_STATE_TYPE_T;
+
+typedef struct
+{
+ QSER_SIM_SUBSCRIPTION_TYPE_T subscription; /**< Type of subscription (i.e., primary, secondary, etc.). */
+ QSER_SIM_APP_STATE_TYPE_T app_state; /**< Current state of the application. */
+ QSER_SIM_PERSO_FEATURE_TYPE_T perso_feature; /**< Current personalization state and feature enabled. */
+ uint8_t perso_retries; /**< Number of personalization retries. */
+ uint8_t perso_unblock_retries; /**< Number of personalization unblock retries. */
+ QSER_SIM_PIN_STATE_TYPE_T pin1_state; /**< Current PIN 1 state. */
+ uint8_t pin1_num_retries; /**< Number of PIN 1 retries. */
+ uint8_t puk1_num_retries; /**< Number of PUK 1 retries. */
+ QSER_SIM_PIN_STATE_TYPE_T pin2_state; /**< Current PIN 2 state. */
+ uint8_t pin2_num_retries; /**< Number of PIN 2 retries. */
+ uint8_t puk2_num_retries; /**< Number of PUK 2 retries. */
+}QSER_SIM_CARD_APP_INFO_T;
+
+typedef struct
+{
+ QSER_SIM_CARD_APP_INFO_T app_3gpp; /**< Stores 3GPP application information. */
+ QSER_SIM_CARD_APP_INFO_T app_3gpp2; /**< Stores 3GPP2 application information. */
+ QSER_SIM_CARD_APP_INFO_T app_isim; /**< Stores ISIM application information. */
+}QSER_SIM_CARD_ALL_APP_INFO_T;
+
+typedef struct
+{
+ QSER_SIM_CARD_STATE_TYPE_T e_card_state;/**< Current card and card error state. */
+ QSER_SIM_CARD_TYPE_T e_card_type; /**< Card type. */
+ QSER_SIM_CARD_ALL_APP_INFO_T card_app_info; /**< Stores all relevant application information. */
+}QSER_SIM_CARD_STATUS_INFO_T;
+typedef QSER_SIM_CARD_STATUS_INFO_T* QSER_SIM_MsgRef;
+/* Callback function registered to qser_sim_addrxmsghandler, msgRef contains the detail msg infor */
+typedef void (*QSER_SIM_RxMsgHandlerFunc_t)(QSER_SIM_MsgRef msgRef);
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-sms-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-sms-demo.cpp
new file mode 100755
index 0000000..975c309
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-sms-demo.cpp
@@ -0,0 +1,186 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <ctype.h>
+
+#include"lynq-qser-sms-demo.h"
+
+
+#define SMS_BUF 64
+#define MSG_BUF 100
+
+int flag_init = 0;
+
+typedef uint32_t sim_client_handle_type;
+sms_client_handle_type ph_sms = 2022;
+sms_client_handle_type h_sms = 2022;
+
+
+int (*qser_sms_client_init)(sms_client_handle_type *ph_sms);
+int (*qser_sms_client_deinit)(sms_client_handle_type h_sms);
+int (*qser_sms_send_sms)(sms_client_handle_type h_sms, QSER_sms_info_t *pt_sms_info);
+int (*qser_sms_addrxmsghandler)(QSER_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr);
+int (*qser_sms_deletefromstorage)(sms_client_handle_type h_sms, QSER_sms_storage_info_t *pt_sms_storage);
+int (*qser_sms_getsmscenteraddress)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *set_sca_cfg);
+//int (*qser_sms_setsmscenteraddress)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *get_sca_cfg);
+
+void qser_sms_handler(QSER_SMS_MsgRef msgRef, void* contextPtr) {
+ printf("[%s-%d] sms handler, msgRef->sms_data = %s,addr =%s\n", __FUNCTION__, __LINE__, msgRef->sms_data, msgRef->src_addr);
+}
+
+bool isNumeric(char *phnum) {
+ int length = strlen(phnum);
+
+ if (length == 0) {
+ return false;
+ }
+
+ if (phnum[0] != '+' && (phnum[0] < '0' || phnum[0] > '9')) {
+ return false;
+ }
+
+ if (phnum[0] == '+' && length < 3) {
+ return false;
+ }
+
+ for (int i = 1; i < length; i++) {
+ if (phnum[i] < '0' || phnum[i] > '9') {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//以下示例默认为所有API 执行都æˆåŠŸçš„æƒ…å†µä¸‹ï¼Œä¾æ¬¡æ‰§è¡ŒåŽç»API
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ //char phnum[SMS_BUF]={0};
+
+ const char *lynq_libpath_sms = "/lib/liblynq-qser-sms.so";
+ void *dlHandle_sms = dlopen(lynq_libpath_sms, RTLD_NOW);
+
+ if (dlHandle_sms == NULL)
+ {
+ printf("dlopen dlHandle_sms failed: %s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+
+ if(argc != 2 || !isNumeric(argv[1]))
+ {
+ printf("[%s][%d] please input correct phnum\n",__FUNCTION__,__LINE__);
+ exit(1);
+ }
+
+ qser_sms_client_init = (int(*)(sms_client_handle_type *ph_sms))dlsym(dlHandle_sms,"qser_sms_client_init");
+ if(NULL != qser_sms_client_init)
+ {
+ ret = qser_sms_client_init(&ph_sms);
+ if(ret == 0)
+ {
+ printf("Run qser_sms_client_init\n");
+ }else{
+ printf("qser_sim_client_init error\n");
+ }
+ }else{
+ printf("qser_sim_client_init dlsym error\n");
+ }
+
+ sleep(2);
+
+ qser_sms_addrxmsghandler = (int(*)(QSER_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr))dlsym(dlHandle_sms,"qser_sms_addrxmsghandler");
+
+ if(NULL != qser_sms_addrxmsghandler)
+ {
+ ret = qser_sms_addrxmsghandler(qser_sms_handler, NULL);
+ if(ret == 0)
+ {
+ printf("qser_sms_addrxmsghandler success");
+ }else{
+ printf("qser_sms_addrxmsghandler error, ret = %d\n", ret);
+ }
+ }else{
+ printf("qser_sms_addrxmsghandler dlsym error\n");
+ }
+
+ QSER_sms_service_center_cfg_t get_sca_cfg;
+ qser_sms_getsmscenteraddress = (int (*)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *get_sca_cfg))dlsym(dlHandle_sms,"qser_sms_getsmscenteraddress");
+ if(NULL != qser_sms_getsmscenteraddress)
+ {
+ ret = qser_sms_getsmscenteraddress(h_sms, &get_sca_cfg);
+ if(ret == 0)
+ {
+ printf("get smsc success,service_center_addr = %s\n",get_sca_cfg.service_center_addr);
+ }else{
+ printf("get smsc error, ret = %d\n", ret);
+ }
+ }else{
+ printf("qser_sms_getsmscenteraddress dlsym error\n");
+ }
+ sleep(1);
+#if 0
+ QSER_sms_service_center_cfg_t set_sca_cfg;
+ memset(set_sca_cfg.service_center_addr, 0, sizeof(set_sca_cfg.service_center_addr));
+ strncpy(set_sca_cfg.service_center_addr, "+8613800230500", 14);//smsc need userchange
+ qser_sms_setsmscenteraddress = (int (*)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *set_sca_cfg))dlsym(dlHandle_sms,"qser_sms_setsmscenteraddress");
+ if(NULL != qser_sms_setsmscenteraddress)
+ {
+ ret = qser_sms_setsmscenteraddress(h_sms, &set_sca_cfg);
+ if(ret == 0)
+ {
+ printf("set smsc success");
+ }else{
+ printf("set smsc error, ret = %d\n", ret);
+ }
+ }else{
+ printf("qser_sms_setsmscenteraddress dlsym error\n");
+ }
+#endif
+ // char telephony_num[SMS_BUF] = {};
+ char msg[MSG_BUF] = {};
+ QSER_sms_info_t pt_sms_info;
+ // sprintf(telephony_num,"10086");//è¯·ç”¨æˆ·åŠ¡å¿…æ›¿æ¢æ¤å·ç ï¼Œéšæ„å‘è¿è¥å•†å‘çŸæ¶ˆæ¯æžæœ‰å¯èƒ½è¢«å°å·ã€‚
+ sprintf(msg,"\"Chello worrld-7bit-mr!./\"");
+ strncpy(pt_sms_info.src_addr, argv[1], SMS_BUF);
+ strncpy(pt_sms_info.sms_data, msg, MSG_BUF);
+ pt_sms_info.format = QSER_SMS_7BIT;
+ // printf("[%s,%d] src_addr=%s, telephony_num = %s\n",__FUNCTION__,__LINE__, pt_sms_info.src_addr, telephony_num);
+ printf("[%s,%d] sms_data=%s, msg = %s\n",__FUNCTION__,__LINE__, pt_sms_info.sms_data, msg);
+
+ qser_sms_send_sms = (int (*)(sms_client_handle_type h_sms, QSER_sms_info_t *pt_sms_info))dlsym(dlHandle_sms,"qser_sms_send_sms");
+ if(NULL != qser_sms_send_sms)
+ {
+ ret = qser_sms_send_sms(h_sms, &pt_sms_info);
+ if(ret == 0)
+ {
+ printf("send sms success");
+ }else{
+ printf("send sms error, ret = %d\n", ret);
+ }
+ }else{
+ printf("qser_sms_send_sms dlsym error\n");
+ }
+
+ sleep(120);//åœ¨æ¤æœŸé—´å‘模组å‘é€çŸæ¶ˆæ¯ï¼Œå³å¯è§¦å‘â€œæŽ¥å—æ–°çŸæ¶ˆæ¯äº‹ä»¶â€ã€‚
+ qser_sms_client_deinit = (int (*)(sms_client_handle_type h_sms))dlsym(dlHandle_sms,"qser_sms_client_deinit");
+ if(NULL != qser_sms_client_deinit)
+ {
+ ret = qser_sms_client_deinit(h_sms);
+ if(ret == 0)
+ {
+ printf("sms deinit success");
+ }else{
+ printf("sms deinit error, ret = %d\n", ret);
+ }
+ }else{
+ printf("qser_sms_client_deinit dlsym error\n");
+ }
+
+}
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-sms-demo.h b/mbtk/test/liblynq_lib/lynq-qser-sms-demo.h
new file mode 100755
index 0000000..500d946
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-sms-demo.h
@@ -0,0 +1,168 @@
+#define MIN_MSM_PARAM_NUM 4
+#define MIN_IMS_MSM_PARAM_NUM 6
+#define MIN_WRITMSM_PARAM_NUM 5
+#define MSG_MAX_LEN 1024
+#define TELEPHONNUM_LEN 64
+#define STORAGSMS_MAX_SIZE 128
+#define SMSC_MAX_LEN 22
+#define SMS_NUM_MAX 255
+
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef uint32_t sms_client_handle_type;
+
+/** Maximum length of an SMS. */
+#define QSER_SMS_MAX_MT_MSG_LENGTH 1440
+
+/** Maximum string length. */
+#define QSER_SMS_MAX_ADDR_LENGTH 252
+
+/** Maximum string length. */
+#define QSER_SMS_MAX_SCA_TYPLENGTH 3
+
+typedef enum
+{
+ QSER_SMS_7BIT = 0,
+ QSER_SMS_8BIT = 1,
+ QSER_SMS_UCS2 = 2,
+ //<2017/12/28-QCM9XOL00004C001-P01-Vicent.Gao, <[SMS] Segment 1==> CharSet to Alpha implementation.>
+ QSER_SMS_IRA = 3,
+ //>2017/12/28-QCM9XOL00004C001-P01-Vicent.Gao
+
+}QSER_SMS_T;
+
+typedef enum
+{
+ QSER_SMS_MO = 0, ///< SMS mobile terminated message.
+ QSER_SMS_MT = 1, ///< SMS mobile originated message.
+ QSER_SMS_BROADCAST_MT = 2 ///< SMS Cell Broadcast message.
+}QSER_SMS_TYPT;
+
+typedef enum
+{
+ QSER_SMS_STORAGTYPNONE = -1, /**< Message no need to store. */
+ QSER_SMS_STORAGTYPUIM = 0, /**< Message store to UIM. */
+ QSER_SMS_STORAGTYPNV = 1, /**< Message store to NV. */
+ QSER_SMS_STORAGTYPDB = 2, /**< Message store to NV. */
+}QSER_SMS_STORAGTYPT;
+
+typedef enum
+{
+ QSER_SMS_MESSAGMODUNKNOWN = -1, /**< Message type CDMA */
+ QSER_SMS_MESSAGMODCDMA = 0, /**< Message type CDMA */
+ QSER_SMS_MESSAGMODGW = 1, /**< Message type GW. */
+}QSER_SMS_MODTYPT;
+
+typedef struct
+ {
+ uint8_t total_segments; /**< The number of long short message*/
+ uint8_t seg_number; /**< Current number.*/
+ uint8_t referencnumber; /**< referencnumber.*/
+}QSER_sms_user_data_head_t;
+
+typedef struct
+{
+ /* If sms is stored, it won't parse, you need read it by yourself */
+ QSER_SMS_STORAGTYPT storage; ///specify where stored this msg
+
+ QSER_SMS_T format;
+ QSER_SMS_TYPT type;
+ char src_addr[QSER_SMS_MAX_ADDR_LENGTH]; ///Telephone number string.
+ int sms_data_len;
+ char sms_data[QSER_SMS_MAX_MT_MSG_LENGTH]; ///SMS content, data format depends on format
+ char timestamp[21]; ///Message time stamp (in text mode). string format: "yy/MM/dd,hh:mm:ss+/-TimeZone"
+ uint8_t user_data_head_valid; //indicate whether long sms. TRUE-long sms; FALSE-short message;
+ QSER_sms_user_data_head_t user_data_head; //long sms user data head info.
+ QSER_SMS_MODTYPT mode; ///specify where stored this msg cdma or gw area
+ uint32_t storage_index; ///storage index, -1 means not store
+} QSER_sms_info_t;
+
+typedef struct
+{
+ QSER_SMS_STORAGTYPT storage;
+ QSER_SMS_MODTYPT mode;
+ uint32_t storage_idx;
+} QSER_sms_storage_info_t;
+
+typedef enum
+{
+ QSER_SMS_UNKNOWN = -1,
+ QSER_SMS_DISCARD = 0x00, /* Incoming messages for this route are discarded by the WMS service without
+ notifying QMI_WMS clients */
+ QSER_SMS_STORAND_NOTIFY = 0x01, /* Incoming messages for this route are stored to the specified device
+ memory, and new message notifications */
+ QSER_SMS_TRANSFER_ONLY = 0x02, /* Incoming messages for this route are transferred to the client, and the
+ client is expected to send ACK to the network */
+ QSER_SMS_TRANSFER_AND_ACK = 0x03, /* Incoming messages for this route are transferred to the client, and ACK is
+ sent to the network */
+}QSER_SMS_RECEPTION_ACTION_TYPT;
+
+#define QSER_WMS_MESSAGLENGTH_MAX 255
+
+typedef enum
+ {
+ QSER_WMS_MESSAGCDMA = 0x00, //- 0x00 -- MESSAGCDMA -- CDMA \n
+ QSER_WMS_MESSAGGW_PP = 0x06, //- 0x06 -- MESSAGGW_PP -- GW_PP
+}QSER_WMS_MESSAGTYPE;
+
+
+typedef struct
+ {
+ QSER_WMS_MESSAGTYPE format;
+ uint32_t raw_messaglen; /**< Must be set to # of elements in raw_message */
+ uint8_t raw_message[QSER_WMS_MESSAGLENGTH_MAX]; /**< Raw message data*/
+}QSER_wms_send_raw_message_data_t;
+
+typedef enum
+{
+ QSER_WMS_TL_CAUSCODADDR_VACANT = 0x00,
+ QSER_WMS_TL_CAUSCODADDR_TRANSLATION_FAILURE = 0x01,
+ QSER_WMS_TL_CAUSCODNETWORK_RESOURCSHORTAGE = 0x02,
+ QSER_WMS_TL_CAUSCODNETWORK_FAILURE = 0x03,
+ QSER_WMS_TL_CAUSCODINVALID_TELESERVICID = 0x04,
+ QSER_WMS_TL_CAUSCODNETWORK_OTHER = 0x05,
+ QSER_WMS_TL_CAUSCODNO_PAGRESPONSE = 0x20,
+ QSER_WMS_TL_CAUSCODDEST_BUSY = 0x21,
+ QSER_WMS_TL_CAUSCODNO_ACK = 0x22,
+ QSER_WMS_TL_CAUSCODDEST_RESOURCSHORTAGE = 0x23,
+ QSER_WMS_TL_CAUSCODSMS_DELIVERY_POSTPONED = 0x24,
+ QSER_WMS_TL_CAUSCODDEST_OUT_OF_SERV = 0x25,
+ QSER_WMS_TL_CAUSCODDEST_NOT_AT_ADDR = 0x26,
+ QSER_WMS_TL_CAUSCODDEST_OTHER = 0x27,
+ QSER_WMS_TL_CAUSCODRADIO_IF_RESOURCSHORTAGE = 0x40,
+ QSER_WMS_TL_CAUSCODRADIO_IF_INCOMPATABILITY = 0x41,
+ QSER_WMS_TL_CAUSCODRADIO_IF_OTHER = 0x42,
+ QSER_WMS_TL_CAUSCODENCODING = 0x60,
+ QSER_WMS_TL_CAUSCODSMS_ORIG_DENIED = 0x61,
+ QSER_WMS_TL_CAUSCODSMS_TERM_DENIED = 0x62,
+ QSER_WMS_TL_CAUSCODSUPP_SERV_NOT_SUPP = 0x63,
+ QSER_WMS_TL_CAUSCODSMS_NOT_SUPP = 0x64,
+ QSER_WMS_TL_CAUSCODMISSING_EXPECTED_PARAM = 0x65,
+ QSER_WMS_TL_CAUSCODMISSING_MAND_PARAM = 0x66,
+ QSER_WMS_TL_CAUSCODUNRECOGNIZED_PARAM_VAL = 0x67,
+ QSER_WMS_TL_CAUSCODUNEXPECTED_PARAM_VAL = 0x68,
+ QSER_WMS_TL_CAUSCODUSER_DATA_SIZERR = 0x69,
+ QSER_WMS_TL_CAUSCODGENERAL_OTHER = 0x6A,
+}QSER_WMS_TL_CAUSCODTYPE;
+
+
+
+typedef struct
+ {
+ uint16_t messagid; /* Message ID */
+ uint8_t causcodvalid; /**< Must be set to true if causcode is being passed */
+ QSER_WMS_TL_CAUSCODTYPE causcode;
+}QSER_wms_raw_send_resp_t;
+
+typedef struct
+ {
+ char service_center_addr[QSER_SMS_MAX_ADDR_LENGTH + 1]; /**< Address of the service center.*/
+ uint8_t service_center_addr_typvalid;
+ char service_center_addr_type[QSER_SMS_MAX_SCA_TYPLENGTH + 1]; /**< 129 if the SMSC address does not start with a "+" characte;
+ 145 if the SMSC address starts with a "+" character*/
+}QSER_sms_service_center_cfg_t;
+
+typedef QSER_sms_info_t QSER_SMS_Msg_t;
+typedef QSER_sms_info_t* QSER_SMS_MsgRef;
+typedef void (*QSER_SMS_RxMsgHandlerFunc_t)(QSER_SMS_MsgRef msgRef, void* contextPtr);
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-thermal-demo.cpp b/mbtk/test/liblynq_lib/lynq-qser-thermal-demo.cpp
new file mode 100755
index 0000000..03a5926
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-thermal-demo.cpp
@@ -0,0 +1,49 @@
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dlfcn.h>
+
+#include"lynq-qser-thermal-demo.h"
+
+
+int (*get_thermal_zone)(int *numbers, int size);
+
+
+int main(int argc, char *argv[]){
+ int numbers[MAX_SIZE];
+ int ret = 0;
+ const char *lynq_libpath_thermal = "/lib/liblynq-qser-thermal.so";
+
+ void *dlHandle_thermal = dlopen(lynq_libpath_thermal, RTLD_NOW);
+ if (dlHandle_thermal == NULL)
+ {
+ printf("dlopen dlHandle_thermal failed: %s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+ get_thermal_zone = (int(*)(int *numbers, int size))dlsym(dlHandle_thermal,"get_thermal_zone");
+ if(NULL != get_thermal_zone)
+ {
+ ret = get_thermal_zone(numbers, MAX_SIZE);
+ if (ret <= 0) {
+ printf("get_thermal_zone error\n");
+ return -1;
+ }
+ }else{
+ printf("get_thermal_zone dlsym error\n");
+ }
+
+ for (int j = 0; j < ret; ++j) {
+ printf("[%s-%d] temp[%d] = %d \n", __func__, __LINE__, j, numbers[j]);
+ }
+
+ return 0;
+}
+
+
+
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-thermal-demo.h b/mbtk/test/liblynq_lib/lynq-qser-thermal-demo.h
new file mode 100755
index 0000000..6366538
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-thermal-demo.h
@@ -0,0 +1,5 @@
+#define MAX_SIZE 100
+#define MAX_LINES 5
+#define MAX_LINE_LENGTH 10
+
+
diff --git a/mbtk/test/liblynq_lib/lynq_call_test.c b/mbtk/test/liblynq_lib/lynq-qser-voice-demo.cpp
similarity index 73%
rename from mbtk/test/liblynq_lib/lynq_call_test.c
rename to mbtk/test/liblynq_lib/lynq-qser-voice-demo.cpp
index 9bb9572..d6ddaf1 100755
--- a/mbtk/test/liblynq_lib/lynq_call_test.c
+++ b/mbtk/test/liblynq_lib/lynq-qser-voice-demo.cpp
@@ -1,377 +1,303 @@
-#include "lynq-qser-voice.h"
-
-#include "mbtk_type.h"
-#include "mbtk_info_api.h"
-#include "mbtk_audio.h"
-
-
-#if 0
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <dlfcn.h>
-#include <stdint.h>
-
-//#include"lynq-qser-voice-demo.h"
-
-typedef struct
-{
- int cmdIdx;
- char *funcName;
-} st_api_test_case;
-
-//for server test
-st_api_test_case at_api_testcases[] =
-{
- {0, "print_help"},
- {1, "qser_voice_call_start"},
- {2, "qser_voice_call_end"},
- {3, "qser_voice_call_answer"},
- {4, "qser_voice_set_speech_volume"},
- {5, "qser_voice_get_speech_volume"},
- {-1, NULL}
-};
-
-
-
-typedef uint32_t voice_client_handle_type;
-
-static pthread_t s_lynq_voice_tid = -1;
-
-
-int (*qser_voice_call_client_init)(voice_client_handle_type *ph_voice);
-int (*qser_voice_call_client_deinit)(voice_client_handle_type );
-int (*qser_voice_call_addstatehandler)(voice_client_handle_type h_voice,
- QSER_VoiceCall_StateHandlerFunc_t handlerPtr,
- void *contextPtr);
-
-int (*qser_voice_call_removestatehandle)(voice_client_handle_type );
-int (*qser_voice_call_start)(voice_client_handle_type h_voice,
- E_QSER_VCALL_ID_T simId,
- char *phone_number, int *call_id);
-
-int (*qser_voice_call_end)(voice_client_handle_type ,int );
-int (*qser_voice_call_answer)(voice_client_handle_type ,int );
-int (*qser_voice_set_speech_volume)(const int volume);
-int (*qser_voice_get_speech_volume)(int *volume);
-
-void *dlHandle_call = NULL;
-
-static void yk_voice_call_cb_func(int call_id,
- char* phone_num,
- qser_voice_call_state_t state,
- void *contextPtr)
-{
- char *call_state[] = {"INCOMING", "DIALING", "ALERTING", "ACTIVE", "HOLDING", "END", "WAITING"};
-
- printf("######### Call id=%d, PhoneNum:%s, event=%s! ######\n", call_id, phone_num, call_state[state]);
-}
-
-void print_help(void)
-{
- int i;
- printf("Supported test cases:\n");
- for(i = 0; ; i++)
- {
- if(at_api_testcases[i].cmdIdx == -1)
- {
- break;
- }
- printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);
- }
-}
-
-int main(int argc, char const *argv[])
-{
- int cmdIdx = 0;
- int ret = 0;
- int voice_call_id = 0;
- voice_client_handle_type h_voice = 0;
-
- //const char *lynqLibPath_Call = "/lib/liblynq-qser-voice.so";
- const char *lynqLibPath_Call = "/lib/liblynq_lib.so";
- dlHandle_call = dlopen(lynqLibPath_Call, RTLD_NOW);
- if (dlHandle_call == NULL)
- {
- printf("dlopen dlHandle_call failed: %s\n", dlerror());
- exit(EXIT_FAILURE);
- }
-
- qser_voice_call_client_init = (int(*)(voice_client_handle_type *ph_voice))dlsym(dlHandle_call, "qser_voice_call_client_init");
- if(qser_voice_call_client_init == NULL)
- {
- printf("qser_voice_call_client_init not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_call_addstatehandler = (int(*)(voice_client_handle_type h_voice,
- QSER_VoiceCall_StateHandlerFunc_t handlerPtr,
- void *contextPtr))dlsym(dlHandle_call,"qser_voice_call_addstatehandler");
- if(qser_voice_call_addstatehandler == NULL)
- {
- printf("qser_voice_call_addstatehandler not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_call_answer = (int(*)(voice_client_handle_type,int ))dlsym(dlHandle_call,"qser_voice_call_answer");
- if(qser_voice_call_answer == NULL)
- {
- printf("qser_voice_call_answer not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_call_start = (int(*)(voice_client_handle_type h_voice,E_QSER_VCALL_ID_T simId,
- char *phone_number, int *call_id))dlsym(dlHandle_call,"qser_voice_call_start");
- if(qser_voice_call_start == NULL)
- {
- printf("qser_voice_call_start not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_call_end = (int(*)(voice_client_handle_type ,int))dlsym(dlHandle_call,"qser_voice_call_end");
- if(qser_voice_call_end == NULL)
- {
- printf("qser_voice_call_end not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
-
- qser_voice_call_client_deinit = (int (*)(voice_client_handle_type h_voice))dlsym(dlHandle_call,"qser_voice_call_client_deinit");
- if(qser_voice_call_client_deinit == NULL)
- {
- printf("qser_voice_call_client_deinit not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_call_removestatehandle = (int (*)(voice_client_handle_type))dlsym(dlHandle_call,"qser_voice_call_removestatehandle");
- if(qser_voice_call_removestatehandle == NULL)
- {
- printf("qser_voice_call_removestatehandle not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_set_speech_volume = (int (*)(const int ))dlsym(dlHandle_call,"qser_voice_set_speech_volume");
- if(qser_voice_set_speech_volume == NULL)
- {
- printf("qser_voice_set_speech_volume not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- qser_voice_get_speech_volume = (int (*)(int* ))dlsym(dlHandle_call,"qser_voice_get_speech_volume");
- if(qser_voice_get_speech_volume == NULL)
- {
- printf("qser_voice_get_speech_volume not defined or exported in %s\n", lynqLibPath_Call);
- return -1;
- }
-
- ret = qser_voice_call_client_init(&h_voice);
- if(ret != 0 )
- {
- printf("qser_voice_call_client_init FAIL\n");
- return -1;
- }
-
- ret = qser_voice_call_addstatehandler(h_voice, yk_voice_call_cb_func, &voice_call_id);
- if(ret != 0)
- {
- printf("qser_voice_call_addstatehandler FAIL\n");
- return -1;
- }
-
-
- print_help();
- while(1)
- {
- printf("\nplease input cmd index(-1 exit): ");
- scanf("%d", &cmdIdx);
- if(cmdIdx == -1)
- {
- break;
- }
-
- switch(cmdIdx)
- {
- //"print_help
- case 0:
- print_help();
- break;
-
- //"qser_voice_call_start"
- case 1:
- {
- char PhoneNum[32] = {0};
-
- printf("please input dest phone number: \n");
- scanf("%s", PhoneNum);
-
- ret = qser_voice_call_start(h_voice, E_QSER_VCALL_EXTERNAL_SLOT_1, PhoneNum, &voice_call_id);
- printf("qser_voice_call_start ret = %d, with voice_call_id=%d\n", ret, voice_call_id);
- break;
- }
-
- //"qser_voice_call_end"
- case 2:
- {
- int call_id = -1;
- printf("please input end call id: \n");
- scanf("%d", &call_id);
- ret = qser_voice_call_end(h_voice, call_id);
- printf(" ret = %d\n", ret);
- break;
- }
-
- //"qser_voice_call_answer"
- case 3:
- {
- int call_id = -1;
- printf(" please input answer call id\n");
- scanf("%d", &call_id);
- ret = qser_voice_call_answer(h_voice, call_id);
- printf(" ret = %d\n", ret);
- break;
- }
- case 4:
- {
- int volume = 0;
- printf("Please set speech volume:0-5 level\n");
- scanf("%d",&volume);
- ret = qser_voice_set_speech_volume(volume);
- printf("ret is %d\n",ret);
- break;
-
- }
-
- case 5:
- {
- int volume = -1;
- printf("Enter get speech volume\n");
- ret = qser_voice_get_speech_volume(&volume);
- printf("ret is %d,get volume is %d\n",ret,volume);
- break;
-
- }
- default:
- print_help();
- break;
- }
-
- }
- ret = qser_voice_call_removestatehandle(h_voice);
- if(ret != 0 && ret != 1)
- {
- printf("qser_voice_call_removestatehandle FAIL!!!\n");
- return -1;
- }
- printf("qser_voice_call_removestatehandle ret = %d\n", ret);
-
-
- ret = qser_voice_call_client_deinit(h_voice);
- if(ret != 0)
- {
- printf("qser_voice_call_client_deinit FAIL\n");
- return -1;
- }
- printf("qser_voice_call_client_deinit ret = %d, with h_voice=%d\n", ret, h_voice);
-
- return 0;
-}
-
-
-#else
-
-static void yk_voice_call_cb_func(int call_id,
- char* phone_num,
- qser_voice_call_state_t state,
- void *contextPtr)
-{
- char *call_state[] = {"INCOMING", "DIALING", "ALERTING", "ACTIVE", "HOLDING", "END", "WAITING"};
-
- printf("######### Call id=%d, PhoneNum:%s, event=%s! ######\n", call_id, phone_num, call_state[state]);
-}
-
-int main(int argc, char *argv[])
-{
- char operator[10];
- int opt;
- int lv_voll = 0;
- voice_client_handle_type handle = -1;
- int voice_call_id = 0;
- mbtk_log_init("radio", "CALL_TEST");
-
- while(1)
- {
- printf("=========call main=========\n"
- "\t0 exit\n"
- "\t1 call init\n"
- "\t2 call add register handle\n"
- "\t3 call start\n"
- "\t4 call end\n"
- "\t5 call answer\n"
- "\t6 call remove register handle\n"
- "\t7 call set volume level 0-5\n"
- "\t8 call get volume\n"
- "\t9 call deinit\n"
- "operator: >> \n");
-
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- qser_voice_call_client_init(&handle);
- printf("test>>: handle = %d\n",handle);
- break;
- case 2:
- qser_voice_call_addstatehandler(handle, yk_voice_call_cb_func, &voice_call_id);
- break;
- case 3:
- qser_voice_call_start(handle, E_QSER_VCALL_EXTERNAL_SLOT_1, "18981904623", &voice_call_id);//被叫电话
- break;
- case 4:
- qser_voice_call_end(handle, voice_call_id);
- break;
- case 5:
- qser_voice_call_anser(handle, voice_call_id);
- break;
- case 6:
- qser_voice_call_removestatehandle(handle);
- break;
- case 7:
- {
- printf("Pleas set volume level(0-5)>>>>\n");
- memset(operator, 0x00, sizeof(operator));
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- //def level 3
- lv_voll = atoi(operator);
- if (lv_voll >= 0 && lv_voll <= 5)
- qser_voice_set_speech_volume(lv_voll);
- else
- printf("set volume level(0-5) ERR\n");
- }
- break;
- case 8:
- qser_voice_get_speech_volume(&lv_voll);
- printf("volume level = %d\n",lv_voll);
- break;
- case 9:
- qser_voice_call_client_deinit(handle);
- break;
- default:
- break;
- }
-
- }
-
- return 0;
-}
-
-#endif
-
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include"lynq-qser-voice-demo.h"
+
+typedef struct
+{
+ int cmdIdx;
+ char *funcName;
+} st_api_test_case;
+
+//for server test
+st_api_test_case at_api_testcases[] =
+{
+ {0, "print_help"},
+ {1, "qser_voice_call_start"},
+ {2, "qser_voice_call_end"},
+ {3, "qser_voice_call_answer"},
+ {4, "qser_voice_set_speech_volume"},
+ {5, "qser_voice_get_speech_volume"},
+ {6, "qser_voice_set_dtmf"},
+ {-1, NULL}
+};
+
+
+
+typedef uint32_t voice_client_handle_type;
+
+
+int (*qser_voice_call_client_init)(voice_client_handle_type *ph_voice);
+int (*qser_voice_call_client_deinit)(voice_client_handle_type );
+int (*qser_voice_call_addstatehandler)(voice_client_handle_type h_voice,
+ QSER_VoiceCall_StateHandlerFunc_t handlerPtr,
+ void *contextPtr);
+
+int (*qser_voice_call_removestatehandle)(voice_client_handle_type );
+int (*qser_voice_call_start)(voice_client_handle_type h_voice,
+ E_QSER_VCALL_ID_T simId,
+ char *phone_number, int *call_id);
+
+int (*qser_voice_call_end)(voice_client_handle_type ,int );
+int (*qser_voice_call_answer)(voice_client_handle_type ,int );
+int (*qser_voice_set_speech_volume)(const int volume);
+int (*qser_voice_get_speech_volume)(int *volume);
+int (*qser_voice_set_dtmf)(const char callnum);
+
+void *dlHandle_call = NULL;
+
+static void yk_voice_call_cb_func(int call_id,
+ char* phone_num,
+ qser_voice_call_state_t state,
+ void *contextPtr)
+{
+ char *call_state[] = {"INCOMING", "DIALING", "ALERTING", "ACTIVE", "HOLDING", "END", "WAITING"};
+
+ printf("######### Call id=%d, PhoneNum:%s, event=%s! ######\n", call_id, phone_num, call_state[state]);
+}
+
+void print_help(void)
+{
+ int i;
+ printf("Supported test cases:\n");
+ for(i = 0; ; i++)
+ {
+ if(at_api_testcases[i].cmdIdx == -1)
+ {
+ break;
+ }
+ printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);
+ }
+}
+
+int main(int argc, char const *argv[])
+{
+ int cmdIdx = 0;
+ int ret = 0;
+ int voice_call_id = 0;
+ voice_client_handle_type h_voice = 0;
+
+ const char *lynqLibPath_Call = "/lib/liblynq-qser-voice.so";
+ dlHandle_call = dlopen(lynqLibPath_Call, RTLD_NOW);
+ if (dlHandle_call == NULL)
+ {
+ printf("dlopen dlHandle_call failed: %s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+
+ qser_voice_call_client_init = (int(*)(voice_client_handle_type *ph_voice))dlsym(dlHandle_call, "qser_voice_call_client_init");
+ if(qser_voice_call_client_init == NULL)
+ {
+ printf("qser_voice_call_client_init not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_call_addstatehandler = (int(*)(voice_client_handle_type h_voice,
+ QSER_VoiceCall_StateHandlerFunc_t handlerPtr,
+ void *contextPtr))dlsym(dlHandle_call,"qser_voice_call_addstatehandler");
+ if(qser_voice_call_addstatehandler == NULL)
+ {
+ printf("qser_voice_call_addstatehandler not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_call_answer = (int(*)(voice_client_handle_type,int ))dlsym(dlHandle_call,"qser_voice_call_answer");
+ if(qser_voice_call_answer == NULL)
+ {
+ printf("qser_voice_call_answer not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_call_start = (int(*)(voice_client_handle_type h_voice,E_QSER_VCALL_ID_T simId,
+ char *phone_number, int *call_id))dlsym(dlHandle_call,"qser_voice_call_start");
+ if(qser_voice_call_start == NULL)
+ {
+ printf("qser_voice_call_start not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_call_end = (int(*)(voice_client_handle_type ,int))dlsym(dlHandle_call,"qser_voice_call_end");
+ if(qser_voice_call_end == NULL)
+ {
+ printf("qser_voice_call_end not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+
+ qser_voice_call_client_deinit = (int (*)(voice_client_handle_type h_voice))dlsym(dlHandle_call,"qser_voice_call_client_deinit");
+ if(qser_voice_call_client_deinit == NULL)
+ {
+ printf("qser_voice_call_client_deinit not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_call_removestatehandle = (int (*)(voice_client_handle_type))dlsym(dlHandle_call,"qser_voice_call_removestatehandle");
+ if(qser_voice_call_removestatehandle == NULL)
+ {
+ printf("qser_voice_call_removestatehandle not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_set_speech_volume = (int (*)(const int ))dlsym(dlHandle_call,"qser_voice_set_speech_volume");
+ if(qser_voice_set_speech_volume == NULL)
+ {
+ printf("qser_voice_set_speech_volume not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_get_speech_volume = (int (*)(int* ))dlsym(dlHandle_call,"qser_voice_get_speech_volume");
+ if(qser_voice_get_speech_volume == NULL)
+ {
+ printf("qser_voice_get_speech_volume not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ qser_voice_set_dtmf = (int (*)(const char ))dlsym(dlHandle_call,"qser_voice_set_dtmf");
+ if(qser_voice_set_dtmf == NULL)
+ {
+ printf("qser_voice_set_dtmf not defined or exported in %s\n", lynqLibPath_Call);
+ return -1;
+ }
+
+ ret = qser_voice_call_client_init(&h_voice);
+ if(ret != 0 )
+ {
+ printf("qser_voice_call_client_init FAIL\n");
+ return -1;
+ }
+
+ ret = qser_voice_call_addstatehandler(h_voice, yk_voice_call_cb_func, &voice_call_id);
+ if(ret != 0)
+ {
+ printf("qser_voice_call_addstatehandler FAIL\n");
+ return -1;
+ }
+
+
+ print_help();
+ while(1)
+ {
+ printf("\nplease input cmd index(-1 exit): ");
+ scanf("%d", &cmdIdx);
+ if(cmdIdx == -1)
+ {
+ break;
+ }
+
+ switch(cmdIdx)
+ {
+ //"print_help
+ case 0:
+ print_help();
+ break;
+
+ //"qser_voice_call_start"
+ case 1:
+ {
+ char PhoneNum[32] = {0};
+
+ printf("please input dest phone number: \n");
+ scanf("%s", PhoneNum);
+
+ ret = qser_voice_call_start(h_voice, E_QSER_VCALL_EXTERNAL_SLOT_1, PhoneNum, &voice_call_id);
+ printf("qser_voice_call_start ret = %d, with voice_call_id=%d\n", ret, voice_call_id);
+ break;
+ }
+
+ //"qser_voice_call_end"
+ case 2:
+ {
+ int call_id = -1;
+ printf("please input end call id: \n");
+ scanf("%d", &call_id);
+ ret = qser_voice_call_end(h_voice, call_id);
+ printf(" ret = %d\n", ret);
+ break;
+ }
+
+ //"qser_voice_call_answer"
+ case 3:
+ {
+ int call_id = -1;
+ printf(" please input answer call id\n");
+ scanf("%d", &call_id);
+ ret = qser_voice_call_answer(h_voice, call_id);
+ printf(" ret = %d\n", ret);
+ break;
+ }
+
+ case 4:
+ {
+ int volume = 0;
+ printf("Please set speech volume:0-5 level\n");
+ scanf("%d",&volume);
+ ret = qser_voice_set_speech_volume(volume);
+ printf("ret is %d\n",ret);
+ break;
+
+ }
+
+ case 5:
+ {
+ int volume = -1;
+ printf("Enter get speech volume\n");
+ ret = qser_voice_get_speech_volume(&volume);
+ printf("ret is %d,get volume is %d\n",ret,volume);
+ break;
+
+ }
+ case 6:
+ {
+
+ int ret;
+ char inputChar;
+
+ printf("Enter set dtmf\n");
+ scanf(" %c", &inputChar);
+ printf("inputChar is %c\n", inputChar);
+ ret = qser_voice_set_dtmf(inputChar);
+
+ if (ret != 0)
+ {
+ printf("qser set voice dtmf failed\n");
+ return -1;
+ }
+ break;
+ }
+
+ default:
+ print_help();
+ break;
+ }
+
+ }
+
+ ret = qser_voice_call_removestatehandle(h_voice);
+ if(ret != 0 && ret != 1)
+ {
+ printf("qser_voice_call_removestatehandle FAIL!!!\n");
+ return -1;
+ }
+ printf("qser_voice_call_removestatehandle ret = %d\n", ret);
+
+
+ ret = qser_voice_call_client_deinit(h_voice);
+ if(ret != 0)
+ {
+ printf("qser_voice_call_client_deinit FAIL\n");
+ return -1;
+ }
+ printf("qser_voice_call_client_deinit ret = %d, with h_voice=%d\n", ret, h_voice);
+
+ return 0;
+
+
+}
+
+
diff --git a/mbtk/test/liblynq_lib/lynq-qser-voice-demo.h b/mbtk/test/liblynq_lib/lynq-qser-voice-demo.h
new file mode 100755
index 0000000..79977b9
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-qser-voice-demo.h
@@ -0,0 +1,31 @@
+typedef enum
+{
+ E_QSER_VOICE_CALL_STATE_INCOMING = 0x0000, /**< MT incoming; CC setup. */
+ E_QSER_VOICE_CALL_STATE_DIALING = 0x0001, /**< Dialing state. */
+ E_QSER_VOICE_CALL_STATE_ALERTING = 0x0002, /**< MT call waiting; MO alterting. */
+ E_QSER_VOICE_CALL_STATE_ACTIVE = 0x0003, /**< Call is active. */
+ E_QSER_VOICE_CALL_STATE_HOLDING = 0x0004, /**< Call is on hold. */
+ E_QSER_VOICE_CALL_STATE_END = 0x0005, /**< Call is disconnected. */
+ E_QSER_VOICE_CALL_STATE_WAITING = 0x0006, /**< Call is waiting. */
+}qser_voice_call_state_t;
+
+typedef enum
+{
+ E_QSER_VCALL_EXTERNAL_SLOT_1,
+ E_QSER_VCALL_EXTERNAL_SLOT_2,
+ E_QSER_VCALL_EMBEDDED,
+ E_QSER_VCALL_REMOTE,
+ E_QSER_VCALL_ID_MAX
+}E_QSER_VCALL_ID_T;
+
+
+typedef qser_voice_call_state_t E_QSER_VOICE_CALL_STATE_T;
+
+typedef void (*QSER_VoiceCall_StateHandlerFunc_t)
+(
+ int caLOCAL_C_INCLUDESll_id,
+ char* phone_num,
+ E_QSER_VOICE_CALL_STATE_T state,
+ void *contextPtr
+);
+
diff --git a/mbtk/test/liblynq_lib/lynq-usb-demo.cc b/mbtk/test/liblynq_lib/lynq-usb-demo.cc
new file mode 100755
index 0000000..2ba3d35
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-usb-demo.cc
@@ -0,0 +1,53 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <sys/socket.h>
+#include <semaphore.h>
+#include <linux/netlink.h>
+
+#include <lynq/lynq-qser-usb.h>
+
+sem_t usbplug_sem;
+void do_get_adb_state(int nargs, char **argv)
+{
+
+ int ret = 0;
+
+ ret = qser_get_usb_usermode_adb_state();
+ if (ret < 0)
+ {
+ printf("get adb state fail,ret:%d \n", ret);
+ return;
+ }
+
+ printf("adb state:%d, %s\n", ret, ((ret == 0) ? "off" : "on"));
+}
+
+void do_get_net_state(int nargs, char **argv)
+{
+
+ int ret = 0;
+
+ ret = qser_get_usb_usermode_net_state();
+ if (ret < 0)
+ {
+ printf("get net state fail,ret:%d \n", ret);
+ return;
+ }
+
+ printf("net state:%d, %s\n", ret, ((ret == 0) ? "off" : "on"));
+}
+
+int main(int argc, char *argv[])
+{
+ sem_init(&usbplug_sem, 0, 0);
+ do_get_adb_state(argc, argv);
+ do_get_net_state(argc, argv);
+ sem_post(&usbplug_sem);
+ return 0;
+}
\ No newline at end of file
diff --git a/mbtk/test/liblynq_lib/lynq-wifi-demo.cc b/mbtk/test/liblynq_lib/lynq-wifi-demo.cc
new file mode 100755
index 0000000..edbfac1
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq-wifi-demo.cc
@@ -0,0 +1,76 @@
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <syslog.h>
+#include <pthread.h>
+
+#include <lynq/lynq-qser-wifi.h>
+
+int main(int argc, char *argv[])
+{
+ if (argc == 2 )
+ {
+ if(strcmp(argv[1], "0") == 0){
+ qser_wifi_enable(); //enable wifi
+ qser_wifi_ap_stop(LYNQ_WIFI_AP_INDEX_AP0); //Disable ap mode for wlan0
+ qser_wifi_disable(); //Turn off WiFi
+ }
+ else if(strcmp(argv[1], "1") == 0){
+ char pw[65] = {0};
+ sprintf(pw, "lynq123456");
+ qser_wifi_enable(); //enable wifi
+ qser_wifi_ap_ssid_set(LYNQ_WIFI_AP_INDEX_AP0,"hello"); //Set the ssid of wlan0 to hello
+ qser_wifi_ap_max_sta_set(LYNQ_WIFI_AP_INDEX_AP0,22); //Example Set the maximum number of connections to 22
+ qser_wifi_ap_channel_set(LYNQ_WIFI_AP_INDEX_AP0,"CN",13); //Set the country code to CN and channel to 13
+ qser_wifi_ap_mode_set(LYNQ_WIFI_AP_INDEX_AP0,LYNQ_WIFI_MODE_80211BGN); //Set the working protocol mode of wlan0 to 80211BGN
+ qser_wifi_ap_auth_set(LYNQ_WIFI_AP_INDEX_AP0,LYNQ_WIFI_AUTH_WPA2_PSK,pw); //Set the authentication of wlan0 to wpa2 and the password to lynq123456
+ qser_wifi_ap_start(LYNQ_WIFI_AP_INDEX_AP0); //Set the ap mode of wlan0
+ }
+ else if(strcmp(argv[1], "2") == 0){
+ char pw[65] = {0};
+ char ssid[33] = {0};
+ char country_code[12] = {0};
+ int channel, max_sta_num;
+ lynq_wifi_mode_type_e mode;
+ lynq_wifi_auth_e auth_mode;
+ lynq_wifi_bandwidth_type_e bandwidth;
+ int ret = -1;
+ qser_wifi_enable(); //enable wifi
+ ret = qser_wifi_ap_ssid_get(LYNQ_WIFI_AP_INDEX_AP0,ssid); //Gets the ssid of wlan0
+ printf("[lynq-wifi-demo] ssid=%s ret = %d\n",ssid, ret);
+ ret = qser_wifi_ap_max_sta_get(LYNQ_WIFI_AP_INDEX_AP0,&max_sta_num); //Gets the maximum sta number for wlan0
+ printf("[lynq-wifi-demo] max_sta_num = %d ret = %d\n",max_sta_num, ret);
+ ret = qser_wifi_ap_mode_get(LYNQ_WIFI_AP_INDEX_AP0,&mode); //Gets the working protocol mode for wlan0
+ printf("[lynq-wifi-demo] mode = %d ret = %d\n",mode, ret);
+ ret = qser_wifi_ap_auth_get(LYNQ_WIFI_AP_INDEX_AP0,&auth_mode,pw); //Get wlan0's password security authentication and password
+ printf("[lynq-wifi-demo] pw = %s auth_mode = %d ret = %d\n",pw, auth_mode, ret);
+ ret = qser_wifi_ap_channel_get(LYNQ_WIFI_AP_INDEX_AP0,country_code,&channel); //Get the country code and channel of wlan0
+ printf("[lynq-wifi-demo] country_code = %s channel = %d ret = %d\n",country_code, channel, ret);
+ ret = qser_wifi_ap_bandwidth_get(LYNQ_WIFI_AP_INDEX_AP0,&bandwidth); //Gets the bandwidth of wlan0
+ printf("[lynq-wifi-demo] bandwidth = %d ret = %d\n",bandwidth, ret);
+ }
+ else{
+ printf(" [lynq-wifi-demo]Parameter error, please re-enter\n");
+ }
+ }
+ else
+ {
+ printf("[lynq-wifi-demo]Please enter one of the parameters 0,1,2\n");
+ printf(" [lynq-wifi-demo]2: View information such as ssid, password, and channel in ap mode\n");
+ printf(" [lynq-wifi-demo]1: initializes wifi and enables and sets ap mode\n");
+ printf(" [lynq-wifi-demo]0: indicates off.\n");
+ return 0;
+ }
+
+ return 0;
+}
+
diff --git a/mbtk/test/liblynq_lib/lynq_led-demo.c b/mbtk/test/liblynq_lib/lynq_led-demo.c
new file mode 100755
index 0000000..3aa4dfa
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq_led-demo.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <strings.h>
+#include<stdlib.h>
+#include "lynq/lynq_uci.h"
+
+
+
+
+int main(int argc, const char *argv[])
+{
+ int ret = 0;
+ ret = lynq_set_netled_on(atoi(argv[1]));
+ if(ret){
+ printf("[%s-%d] lynq_set_netled_on error\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ ret = lynq_set_statusled_on(atoi(argv[1]));
+ if(ret){
+ printf("[%s-%d] lynq_set_statusled_on error\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/mbtk/test/liblynq_lib/lynq_nw_test.c b/mbtk/test/liblynq_lib/lynq_nw_test.c
deleted file mode 100755
index 82cd6d8..0000000
--- a/mbtk/test/liblynq_lib/lynq_nw_test.c
+++ /dev/null
@@ -1,265 +0,0 @@
-#include "lynq_qser_network.h"
-#include "mbtk_type.h"
-#include "mbtk_info_api.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-char *tech_domain[] = {"NONE", "3GPP", "3GPP2"};
-char *radio_tech[] = {"unknown",
- "TD_SCDMA", "GSM", "HSPAP", "LTE", "EHRPD", "EVDO_B",
- "HSPA", "HSUPA", "HSDPA", "EVDO_A", "EVDO_0", "1xRTT",
- "IS95B", "IS95A", "UMTS", "EDGE", "GPRS", "NONE"};
-
-void nw_event_ind_handler (
- nw_client_handle_type h_nw,
- u_int32_t ind_flag,
- void *ind_msg_buf,
- u_int32_t ind_msg_len,
- void *contextPtr)
-{
- uint8 *net_data = NULL;
-
- net_data = (uint8*)ind_msg_buf;
-
- if(ind_msg_buf && ind_msg_len > 0)//无处理原始数据传输过来
- {
- if(*net_data == 0)
- { // CS
- printf("CS:act=%d, mode=%d\n", *(net_data + 1), *(net_data + 2));
- }
- else
- { // PS
- printf("PS[%s]:act=%d, mode=%d\n", *(net_data + 3) == 0 ? "GSM/WCDMA" : "LTE", *(net_data + 1), *(net_data + 2));
- }
- }
- else
- {
- printf("NET_CB : NULL");
- }
-
-}
-
-
-int main(int argc, char *argv[])
-{
- char operator[10];
- int opt;
- int lv_voll = 0;
- nw_client_handle_type handle = -1;
- mbtk_log_init("radio", "NW_TEST");
-
- while(1)
- {
- printf("=========network main=========\n"
- "\t0 exit\n"
- "\t1 network init\n"
- "\t2 network add rx msg handle\n"
- "\t3 network band set config\n"
- "\t4 network get operator name\n"
- "\t5 network get reg status\n"
- "\t6 network get signal strength\n"
- "\t7 network set oos config\n"
- "\t8 network get oos config\n"
- "\t9 network set rf config\n"
- "\t10 network get rf config\n"
- "\t11 network deinit\n"
- "operator: >> ");
-
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- qser_nw_client_init(&handle);
- break;
- case 2:
- qser_nw_add_rx_msg_handler(handle, nw_event_ind_handler, NULL);
- break;
- case 3:
- {
- //漫游开关现在不支持,所以就不用配置
- printf("please input \n"
- "\t1:GSM \n"
- "\t2:WCDMA \n"
- "\t4:CDMA \n"
- "\t8:EVDO \n"
- "\t16:LTE \n"
- "\t32:TDSCDMA \n"
- );
- memset(operator,0x00, sizeof(operator));
- fgets(operator, sizeof(operator)-1, stdin);
- fflush(stdin);
- opt = atoi(operator);
- QSER_NW_CONFIG_INFO_T t_info;
- switch(opt)
- {
- case 1:
- t_info.preferred_nw_mode = QSER_NW_MODE_GSM;//2G
- break;
- case 2:
- t_info.preferred_nw_mode = QSER_NW_MODE_WCDMA;//3G
- break;
- case 4:
- t_info.preferred_nw_mode = QSER_NW_MODE_CDMA;//3G
- break;
- case 8:
- t_info.preferred_nw_mode = QSER_NW_MODE_EVDO;//3G
- break;
- case 16:
- t_info.preferred_nw_mode = QSER_NW_MODE_LTE;//4G
- break;
- case 32:
- t_info.preferred_nw_mode = QSER_NW_MODE_TDSCDMA;//3G
- break;
- default:
- t_info.preferred_nw_mode = QSER_NW_MODE_LTE;//4G
- break;
- }
- qser_nw_set_config(handle, &t_info);
- }
- break;
- case 4:
- {
- QSER_NW_OPERATOR_NAME_INFO_T t_info;
- int err = qser_nw_get_operator_name(handle, &t_info);
- if(err)
- {
- printf("Error : %d\n", err);
- } else
- {
- printf("Operator : %s, %s, %s, %s\n", t_info.long_eons, t_info.short_eons, t_info.mcc, t_info.mnc);
- }
- }
- break;
- case 5:
- {
- QSER_NW_REG_STATUS_INFO_T reg;
- int err = qser_nw_get_reg_status(handle, ®);
- if(err)
- {
- printf("Error : %d\n", err);
- }
- else
- {
- if(reg.voice_registration_details_3gpp_valid)
- {
- printf("voice_registration_details_3gpp: tech_domain=%d, radio_tech=%d, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n",
- reg.voice_registration_details_3gpp.tech_domain,
- reg.voice_registration_details_3gpp.radio_tech,
- reg.voice_registration_details_3gpp.mcc,
- reg.voice_registration_details_3gpp.mnc,
- reg.voice_registration_details_3gpp.roaming,
- reg.voice_registration_details_3gpp.forbidden,
- reg.voice_registration_details_3gpp.cid,
- reg.voice_registration_details_3gpp.lac,
- reg.voice_registration_details_3gpp.psc,
- reg.voice_registration_details_3gpp.tac);
- }
- if(reg.data_registration_details_3gpp_valid)
- {
- printf("data_registration_details_3gpp: tech_domain=%d, radio_tech=%d, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n",
- reg.data_registration_details_3gpp.tech_domain,
- reg.data_registration_details_3gpp.radio_tech,
- reg.data_registration_details_3gpp.mcc,
- reg.data_registration_details_3gpp.mnc,
- reg.data_registration_details_3gpp.roaming,
- reg.data_registration_details_3gpp.forbidden,
- reg.data_registration_details_3gpp.cid,
- reg.data_registration_details_3gpp.lac,
- reg.data_registration_details_3gpp.psc,
- reg.data_registration_details_3gpp.tac);
- }
- //printf("Data Reg: radio_tech = %d, lac = %x, cid = %x\n", reg.data_registration_details_3gpp.radio_tech, reg.data_registration_details_3gpp.lac, reg.data_registration_details_3gpp.cid);
- //printf("Voice Reg: radio_tech = %d, lac = %x, cid = %x\n", reg.voice_registration_details_3gpp.radio_tech, reg.voice_registration_details_3gpp.lac, reg.voice_registration_details_3gpp.cid);
- }
- }
- break;
- case 6:
- {
- QSER_NW_SIGNAL_STRENGTH_INFO_T sig;
- int err = qser_nw_get_signal_strength(handle, &sig);
- if(err)
- {
- printf("Error : %d\n", err);
- }
- else
- {
- if (sig.gsm_sig_info_valid == TRUE)
- printf("Signal GSM: rssi = %d\n", sig.gsm_sig_info.rssi);
- else if (sig.lte_sig_info_valid == TRUE)
- printf("Signal LTE: rssi = %d, rsrp = %d, rsrq = %d, snr = %d\n", sig.lte_sig_info.rssi , sig.lte_sig_info.rsrp, sig.lte_sig_info.rsrq, sig.lte_sig_info.snr);
- else if (sig.wcdma_sig_info_valid == TRUE)
- printf("Signal UTRAN: rssi = %d, ecio = %d\n", sig.wcdma_sig_info.rssi , sig.wcdma_sig_info.ecio);
- else
- printf("Signal type not supported \n");
- }
- }
- break;
- case 7:
- {
- QSER_NW_OOS_CONFIG_INFO_T pt_info_s;
- memset(&pt_info_s, 0x00, sizeof(QSER_NW_OOS_CONFIG_INFO_T));
- /*取值范围0-255,设置时间自定义
- phase 1 5次 次数无法更改,这五次都是以10秒为一次的间隔搜网
- phase 2 5次 次数无法更改,这五次都是以15秒为一次的间隔搜网
- phase 3 不限制次数的秒数设置,第三阶段不限制次数以20秒为一次的间隔搜网
- 如果要关闭OOS配置,则把min step max 全部配置为0即可
- */
- pt_info_s.type = QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN;//平台提供自定义配置搜网时间间隔
- {
- pt_info_s.u.full_band_scan_info.t_min = 10;//phase 1
- pt_info_s.u.full_band_scan_info.t_step = 15;//phase 2
- pt_info_s.u.full_band_scan_info.t_num = 0;//可以不配置,并没有使用
- pt_info_s.u.full_band_scan_info.t_max = 20;//phase 3
- }
- printf("set OOS %d %d %d \n",pt_info_s.u.full_band_scan_info.t_min, pt_info_s.u.full_band_scan_info.t_step, pt_info_s.u.full_band_scan_info.t_max);
- //pt_info_s.type = QSER_NW_OOS_CFG_TYPE_FAST_SCAN;平台本身有历史频点优先处理的逻辑(无接口不需要我们进行处理)
- qser_nw_set_oos_config(handle, &pt_info_s);
- }
- break;
- case 8:
- {
- QSER_NW_OOS_CONFIG_INFO_T pt_info_g;
- qser_nw_get_oos_config(handle, &pt_info_g);
- if (pt_info_g.type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
- printf("TYPE: %d min: %d setp: %d max: %d\n", pt_info_g.type, pt_info_g.u.full_band_scan_info.t_min, pt_info_g.u.full_band_scan_info.t_step, pt_info_g.u.full_band_scan_info.t_max);
- else
- printf("type not supported \n");
- }
- break;
- case 9:
- {
- printf("please input 0 or 1 or 4: \n");
- memset(operator,0x00, sizeof(operator));
- fgets(operator, sizeof(operator)-1, stdin);
- fflush(stdin);
- opt = atoi(operator);
- printf("rf_mode: [%d]\n",opt);
- qser_nw_set_rf_mode(handle, opt);
- }
- break;
- case 10:
- {
- int rf_t;
- qser_nw_get_rf_mode(handle, &rf_t);
- printf(">>>rf_mode = [%d]\n",rf_t);
- }
- break;
- case 11:
- qser_nw_client_deinit(handle);
- break;
- default:
- break;
- }
-
- }
-
- return 0;
-}
-
diff --git a/mbtk/test/liblynq_lib/lynq_qser_network.h b/mbtk/test/liblynq_lib/lynq_qser_network.h
new file mode 100755
index 0000000..56e2ce0
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq_qser_network.h
@@ -0,0 +1,475 @@
+/**
+ *@file QSER_nw.h
+ *@date 2018-02-22
+ *@author
+ *@brief
+ */
+#ifndef __LYNQ_QSER_NETWORK_H__
+#define __LYNQ_QSER_NETWORK_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef uint32_t nw_client_handle_type;
+
+
+#define QSER_NW_MODE_NONE 0x00 /**< No network. */
+#define QSER_NW_MODE_GSM 0x01 /**< Include GSM networks. */
+#define QSER_NW_MODE_WCDMA 0x02 /**< Include WCDMA networks. */
+#define QSER_NW_MODE_CDMA 0x04 /**< Include CDMA networks. */
+#define QSER_NW_MODE_EVDO 0x08 /**< Include EVDO networks. */
+#define QSER_NW_MODE_LTE 0x10 /**< Include LTE networks. */
+#define QSER_NW_MODE_TDSCDMA 0x20 /**< Include TDSCDMA networks. */
+
+typedef enum
+{
+ E_QSER_NW_ROAM_STATE_OFF = 0, /**< None, or roaming indicator off. */
+ E_QSER_NW_ROAM_STATE_ON = 1 /**< Roaming indicator on. */
+}E_QSER_NW_ROAM_STATE_TYPE_T;
+
+/** Configures the settings that define the MCM network interface. */
+typedef struct
+{
+ /* Configuration parameters for MCM network registration Network registration details Technology dependent network registration details */
+ uint64_t preferred_nw_mode; /**< Preferred network mode for connections; a bitmask of QSER_NW_MODE_xxxx.*/
+ E_QSER_NW_ROAM_STATE_TYPE_T roaming_pref; /**< Roaming preference.*/
+}QSER_NW_CONFIG_INFO_T;
+
+typedef enum
+{
+ E_QSER_NW_IMS_MODE_OFF = 0, /**< close ims. */
+ E_QSER_NW_IMS_MODE_VOLTE_ENABLE = 1, /**< support volte. */
+}E_QSER_NW_IMS_MODE_TYPE_T;
+
+/** Configures the OOS (out of service) settings that define the MCM network interface. */
+#define QSER_NW_OOS_CFG_TYPE_FAST_SCAN 0x00 /**< fast net scan */
+#define QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN 0x01 /**< full band scan */
+
+typedef struct
+{
+ /* Configuration parameters for MCM network fast network scan when OOS (out of service)*/
+ char enable;
+ uint16_t time_interval;
+}QSER_NW_OOS_CONFIG_FAST_SCAN_INFO_T;
+
+typedef struct
+{
+ /* Configuration parameters for MCM network full band network scan when OOS (out of service)*/
+ int t_min;
+ int t_step;
+ int t_num;
+ int t_max;
+}QSER_NW_OOS_CONFIG_FULL_BAND_SCAN_INFO_T;
+
+
+typedef struct
+{
+ char type; /**< QSER_NW_OOS_CFG_TYPE_xxxx.*/
+ union {
+ QSER_NW_OOS_CONFIG_FAST_SCAN_INFO_T fast_can_info; // 00
+ QSER_NW_OOS_CONFIG_FULL_BAND_SCAN_INFO_T full_band_scan_info; // 01
+ } u;
+}QSER_NW_OOS_CONFIG_INFO_T;
+
+//defined for QSER_NW_EventRegister
+#define NW_IND_VOICE_REG_EVENT_IND_FLAG (1 << 0) /**< msg format : QSER_NW_VOICE_REG_EVENT_IND_T */
+#define NW_IND_DATA_REG_EVENT_IND_FLAG (1 << 1) /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */
+#define NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG (1 << 2) /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */
+//#define NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG (1 << 3) /**< msg format : QL_MCM_NW_CELL_ACCESS_STATE_EVENT_IND_T */
+//#define NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG (1 << 4) /**< msg format : QL_MCM_NW_NITZ_TIME_EVENT_IND_T */
+#define NW_IND_IMS_REG_EVENT_IND_FLAG (1 << 5) /**< msg format : NULL */
+
+typedef struct
+{
+ char long_eons[512 + 1]; /**< Long EONS.*/
+ char short_eons[512 + 1]; /**< Short EONS.*/
+ char mcc[3 + 1]; /**< Mobile country code.*/
+ char mnc[3 + 1]; /**< Mobile network code.*/
+}QSER_NW_OPERATOR_NAME_INFO_T;
+
+typedef enum
+{
+ E_QSER_NW_RADIO_TECH_TD_SCDMA = 1,
+ E_QSER_NW_RADIO_TECH_GSM = 2, /**< GSM; only supports voice. */
+ E_QSER_NW_RADIO_TECH_HSPAP = 3, /**< HSPA+. */
+ E_QSER_NW_RADIO_TECH_LTE = 4, /**< LTE. */
+ E_QSER_NW_RADIO_TECH_EHRPD = 5, /**< EHRPD. */
+ E_QSER_NW_RADIO_TECH_EVDO_B = 6, /**< EVDO B. */
+ E_QSER_NW_RADIO_TECH_HSPA = 7, /**< HSPA. */
+ E_QSER_NW_RADIO_TECH_HSUPA = 8, /**< HSUPA. */
+ E_QSER_NW_RADIO_TECH_HSDPA = 9, /**< HSDPA. */
+ E_QSER_NW_RADIO_TECH_EVDO_A = 10, /**< EVDO A. */
+ E_QSER_NW_RADIO_TECH_EVDO_0 = 11, /**< EVDO 0. */
+ E_QSER_NW_RADIO_TECH_1xRTT = 12, /**< 1xRTT. */
+ E_QSER_NW_RADIO_TECH_IS95B = 13, /**< IS95B. */
+ E_QSER_NW_RADIO_TECH_IS95A = 14, /**< IS95A. */
+ E_QSER_NW_RADIO_TECH_UMTS = 15, /**< UMTS. */
+ E_QSER_NW_RADIO_TECH_EDGE = 16, /**< EDGE. */
+ E_QSER_NW_RADIO_TECH_GPRS = 17, /**< GPRS. */
+ E_QSER_NW_RADIO_TECH_NONE = 18 /**< No technology selected. */
+}E_QSER_NW_RADIO_TECH_TYPE_T;
+
+
+typedef enum
+{
+ E_QSER_NW_TECH_DOMAIN_NONE = 0, /**< None. */
+ E_QSER_NW_TECH_DOMAIN_3GPP = 1, /**< 3GPP. */
+ E_QSER_NW_TECH_DOMAIN_3GPP2 = 2, /**< 3GPP2. */
+}E_QSER_NW_TECH_DOMAIN_TYPE_T;
+
+typedef enum
+{
+ E_QSER_NW_IMSI_UNKNOWN_HLR_DENY_REASON = 1, /**< IMSI unknown in HLR. */
+ E_QSER_NW_ILLEGAL_MS_DENY_REASON = 2, /**< Illegal MS. */
+ E_QSER_NW_IMSI_UNKNOWN_VLR_DENY_REASON = 3, /**< IMSI unknown in VLR. */
+ E_QSER_NW_IMEI_NOT_ACCEPTED_DENY_REASON = 4, /**< IMEI not accepted. */
+ E_QSER_NW_ILLEGAL_ME_DENY_REASON = 5, /**< Illegal ME. */
+ E_QSER_NW_PLMN_NOT_ALLOWED_DENY_REASON = 6, /**< PLMN not allowed. */
+ E_QSER_NW_LA_NOT_ALLOWED_DENY_REASON = 7, /**< Location area not allowed. */
+ E_QSER_NW_ROAMING_NOT_ALLOWED_LA_DENY_REASON = 8, /**< Roaming not allowed in this location area. */
+ E_QSER_NW_NO_SUITABLE_CELLS_LA_DENY_REASON = 9, /**< No suitable cells in location area. */
+ E_QSER_NW_NETWORK_FAILURE_DENY_REASON = 10, /**< Network failure. */
+ E_QSER_NW_MAC_FAILURE_DENY_REASON = 11, /**< MAC failure. */
+ E_QSER_NW_SYNCH_FAILURE_DENY_REASON = 12, /**< Sync failure. */
+ E_QSER_NW_CONGESTION_DENY_REASON = 13, /**< Congestion. */
+ E_QSER_NW_GSM_AUTHENTICATION_UNACCEPTABLE_DENY_REASON = 14, /**< GSM authentication unacceptable. */
+ E_QSER_NW_NOT_AUTHORIZED_CSG_DENY_REASON = 15, /**< Not authorized in this CSG. */
+ E_QSER_NW_SERVICE_OPTION_NOT_SUPPORTED_DENY_REASON = 16, /**< Service option not supported. */
+ E_QSER_NW_REQ_SERVICE_OPTION_NOT_SUBSCRIBED_DENY_REASON = 17, /**< Requested service option not subscribed. */
+ E_QSER_NW_CALL_CANNOT_BE_IDENTIFIED_DENY_REASON = 18, /**< Call cannot be identified. */
+ E_QSER_NW_SEMANTICALLY_INCORRECT_MSG_DENY_REASON = 19, /**< Semantically incorrect message. */
+ E_QSER_NW_INVALID_MANDATORY_INFO_DENY_REASON = 20, /**< Invalid mandatory information. */
+ E_QSER_NW_MSG_TYPE_NON_EXISTENT_DENY_REASON = 21, /**< Message type non-existent or not implemented. */
+ E_QSER_NW_INFO_ELEMENT_NON_EXISTENT_DENY_REASON = 22, /**< Message type not compatible with the protocol state. */
+ E_QSER_NW_CONDITIONAL_IE_ERR_DENY_REASON = 23, /**< Conditional IE error. */
+ E_QSER_NW_MSG_INCOMPATIBLE_PROTOCOL_STATE_DENY_REASON = 24, /**< Message not compatible with the protocol state. */
+ E_QSER_NW_PROTOCOL_ERROR_DENY_REASON = 25, /**< Unspecified protocol error. */
+}E_QSER_NW_DENY_REASON_TYPE_T;
+
+
+typedef enum
+{
+ E_QSER_NW_SERVICE_NONE = 0x0000, /**< Not registered or no data. */
+ E_QSER_NW_SERVICE_LIMITED = 0x0001, /**< Registered; emergency service only. */
+ E_QSER_NW_SERVICE_FULL = 0x0002, /**< Registered, full service. */
+}E_QSER_NW_SERVICE_TYPE_T;
+
+typedef struct
+{
+ E_QSER_NW_TECH_DOMAIN_TYPE_T tech_domain; /**< Technology, used to determine the structure type tech: 0 -- None, 1 -- 3GPP, 2 -- 3GPP2.*/
+ E_QSER_NW_RADIO_TECH_TYPE_T radio_tech; /**< Radio technology; see #nw_radio_tech_t_v01.*/
+ E_QSER_NW_ROAM_STATE_TYPE_T roaming; /**< 0 -- Off, 1 -- Roaming (3GPP2 has extended values).*/
+ E_QSER_NW_DENY_REASON_TYPE_T deny_reason; /**< Set when registration state is #nw_deny_reason_t_v01.*/
+ E_QSER_NW_SERVICE_TYPE_T registration_state; /**< Registration state.*/
+}QSER_NW_COMMON_REG_INFO_T;
+
+
+typedef struct
+{
+ E_QSER_NW_TECH_DOMAIN_TYPE_T tech_domain; /**< Technology, used to determine the structure type tech: 0 -- None, 1 -- 3GPP, 2 -- 3GPP2.*/
+ E_QSER_NW_RADIO_TECH_TYPE_T radio_tech; /**< Radio technology; see #nw_radio_tech_t_v01.*/
+ char mcc[3+1]; /**< Mobile country code.*/
+ char mnc[3+1]; /**< Mobile network code.*/
+ E_QSER_NW_ROAM_STATE_TYPE_T roaming; /**< 0 -- Off, 1 -- Roaming (3GPP2 has extended values).*/
+ uint8_t forbidden; /**< Forbidden: 0 -- No, 1 -- Yes.*/
+ uint32_t cid; /**< Cell ID for the registered 3GPP system.*/
+ uint16_t lac; /**< Locatin area code for the registered 3GPP system.*/
+ uint16_t psc; /**< Primary scrambling code (WCDMA only); 0 -- None.*/
+ uint16_t tac; /**< Tracking area code information for LTE.*/
+}QSER_NW_3GPP_REG_INFO_T;
+
+
+typedef struct
+{
+ E_QSER_NW_TECH_DOMAIN_TYPE_T tech_domain; /**< Technology, used to determine structure type tech: 0 -- None, 1 -- 3GPP, 2 -- 3GPP2.*/
+ E_QSER_NW_RADIO_TECH_TYPE_T radio_tech; /**< Radio technology; see #nw_radio_tech_t_v01.*/
+ char mcc[3+1]; /**< Mobile country code.*/
+ char mnc[3+1]; /**< Mobile network code.*/
+ E_QSER_NW_ROAM_STATE_TYPE_T roaming; /**< Roaming status; see #nw_roam_state_t_v01.*/
+ uint8_t forbidden; /**< Forbidden: 0 -- No, 1 -- Yes.*/
+ uint8_t inPRL; /**< 0 -- Not in PRL, 1 -- In PRL.*/
+ uint8_t css; /**< Concurrent services supported: 0 -- No, 1 -- Yes.*/
+ uint16_t sid; /**< CDMA system ID.*/
+ uint16_t nid; /**< CDMA network ID.*/
+ uint16_t bsid; /**< Base station ID. @newpagetable */
+}QSER_NW_3GPP2_REG_INFO_T;
+
+/** Gets the status associated with the connection of \<id\>. */
+typedef struct
+{
+ uint8_t voice_registration_valid; /**< Must be set to TRUE if voice_registration is being passed. */
+ QSER_NW_COMMON_REG_INFO_T voice_registration; /**< Voice registration. */
+
+ uint8_t data_registration_valid; /**< Must be set to TRUE if data_registration is being passed. */
+ QSER_NW_COMMON_REG_INFO_T data_registration; /**< Data registration. */
+
+ uint8_t voice_registration_details_3gpp_valid; /**< Must be set to TRUE if voice_registration_details_3gpp is being passed. */
+ QSER_NW_3GPP_REG_INFO_T voice_registration_details_3gpp; /**< Voice registration details for 3GPP. */
+
+ uint8_t data_registration_details_3gpp_valid; /**< Must be set to TRUE if data_registration_details_3gpp is being passed. */
+ QSER_NW_3GPP_REG_INFO_T data_registration_details_3gpp; /**< Data registration details for 3GPP. */
+
+ uint8_t voice_registration_details_3gpp2_valid; /**< Must be set to TRUE if voice_registration_details_3gpp2 is being passed. */
+ QSER_NW_3GPP2_REG_INFO_T voice_registration_details_3gpp2; /**< Voice registration details for 3GPP2. */
+
+ uint8_t data_registration_details_3gpp2_valid; /**< Must be set to TRUE if data_registration_details_3gpp2 is being passed. */
+ QSER_NW_3GPP2_REG_INFO_T data_registration_details_3gpp2; /**< Data registration details for 3GPP2. */
+}QSER_NW_REG_STATUS_INFO_T;
+
+typedef enum
+{
+ E_QSER_NW_IMS_SERVICE_NONE = 0x0000, /**< Not registered */
+ E_QSER_NW_IMS_SERVICE_REGISTERED = 0x0001, /**< Registered*/
+}E_QSER_NW_IMS_SERVICE_TYPE_T;
+
+typedef struct
+{
+ E_QSER_NW_IMS_SERVICE_TYPE_T registration_state; /**< Registration state.*/
+}QSER_NW_IMS_REG_STATUS_INFO_T;
+
+typedef struct
+{
+ int8_t rssi; /**< RSSI in dBm. Indicates received signal strength. A signed value; -125 or lower indicates no signal.*/
+}QSER_NW_GSM_SIGNAL_INFO_T;
+
+
+typedef struct
+{
+ int8_t rssi; /**< RSSI in dBm. Indicates forward link pilot Ec. A signed value; -125 or lower indicates no signal.*/
+ int16_t ecio; /**< Ec/Io value representing negative 0.5 dB increments, e.g., 2 equals -1 dbm.*/
+}QSER_NW_WCDMA_SIGNAL_INFO_T;
+
+typedef struct
+{
+ int8_t rssi; /**< RSSI in dBm. Indicates forward link pilot Ec. a signed value; -125 or lower indicates no signal.*/
+ int8_t rscp; /**< RSCP in dBm.*/
+ int16_t ecio; /**< Ec/Io value representing negative 0.5 dB increments, e.g., 2 equals -1 dbm.*/
+ int8_t sinr; /**< Measured SINR in dB. @newpagetable */
+}QSER_NW_TDSCDMA_SIGNAL_INFO_T;
+
+typedef struct
+{
+ int8_t rssi; /**< RSSI in dBm. Indicates forward link pilot Ec. A signed value; -125 or lower indicates no signal.*/
+ int8_t rsrq; /**< RSRQ value in dB (signed integer value), as measured by L1. Range: -3 to -20 (-3 equals -3 dB, -20 equals -20 dB).*/
+ int16_t rsrp; /**< Current RSRP in dBm, as measured by L1. Range: -44 to -140 (-44 equals -44 dBm, -140 equals -140 dBm).*/
+ int16_t snr; /**< SNR level as a scaled integer in units of 0.1 dB; e.g., -16 dB has a value of -160 and 24.6 dB has a value of 246.*/
+}QSER_NW_LTE_SIGNAL_INFO_T;
+
+typedef struct
+{
+ int8_t rssi; /**< RSSI in dBm. Indicates forward link pilot Power (AGC) + Ec/Io. A signed value; -125 or lower indicates no signal.*/
+ int16_t ecio; /**< Ec/Io value representing negative 0.5 dB increments, e.g., 2 equals -1 dbm.*/
+}QSER_NW_CDMA_SIGNAL_INFO_T;
+
+typedef struct
+{
+ int8_t rssi; /**< RSSI in dBm. Indicates forward link pilot Power (AGC) + Ec/Io. A signed value; -125 or lower indicates no signal.*/
+ int16_t ecio; /**< Ec/Io value representing negative 0.5 dB increments, e.g., 2 equals -1 dbm.*/
+ int8_t sinr; /**< SINR level.*/
+ int32_t io; /**< Received IO in dBm. */
+}QSER_NW_HDR_SIGNAL_INFO_T;
+
+typedef struct
+{
+ int16_t ssRsrp; /* SS(Synchronization Signal) reference signal received power, multipled by -1.
+ * Reference: 3GPP TS 38.215.
+ * Range [44, 140], INT_MAX means invalid/unreported.*/
+ int16_t ssRsrq; /* SS reference signal received quality, multipled by -1.
+ * Reference: 3GPP TS 38.215.
+ * Range [3, 20], INT_MAX means invalid/unreported.*/
+ int16_t ssSinr; /* SS signal-to-noise and interference ratio.
+ * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
+ * Range [-23, 40], INT_MAX means invalid/unreported.*/
+ int16_t csiRsrp; /* CSI reference signal received power, multipled by -1.
+ * Reference: 3GPP TS 38.215.
+ * Range [44, 140], INT_MAX means invalid/unreported.*/
+ int16_t csiRsrq; /* CSI reference signal received quality, multipled by -1.
+ * Reference: 3GPP TS 38.215.
+ * Range [3, 20], INT_MAX means invalid/unreported.*/
+ int16_t csiSinr; /* CSI signal-to-noise and interference ratio.
+ * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
+ * Range [-23, 40], INT_MAX means invalid/unreported.*/
+}QSER_NW_NR_SIGNAL_INFO_T;
+
+
+/** Gets signal strength information. */
+typedef struct
+{
+ uint8_t gsm_sig_info_valid; /**< Must be set to TRUE if gsm_sig_info is being passed. */
+ QSER_NW_GSM_SIGNAL_INFO_T gsm_sig_info; /**< GSM signal information. */
+ uint8_t wcdma_sig_info_valid; /**< Must be set to TRUE if wcdma_sig_info is being passed. */
+ QSER_NW_WCDMA_SIGNAL_INFO_T wcdma_sig_info; /**< WCDMA signal information. */
+ uint8_t tdscdma_sig_info_valid; /**< Must be set to TRUE if tdscdma_sig_info is being passed. */
+ QSER_NW_TDSCDMA_SIGNAL_INFO_T tdscdma_sig_info; /**< TDSCDMA signal information. */
+ uint8_t lte_sig_info_valid; /**< Must be set to TRUE if lte_sig_info is being passed. */
+ QSER_NW_LTE_SIGNAL_INFO_T lte_sig_info; /**< LTE signal information. */
+ uint8_t cdma_sig_info_valid; /**< Must be set to TRUE if cdma_sig_info is being passed. */
+ QSER_NW_CDMA_SIGNAL_INFO_T cdma_sig_info; /**< CDMA signal information. */
+ uint8_t hdr_sig_info_valid; /**< Must be set to TRUE if hdr_sig_info is being passed. */
+ QSER_NW_HDR_SIGNAL_INFO_T hdr_sig_info; /**< HDR signal information. */
+ uint8_t nr_sig_info_valid;
+ QSER_NW_NR_SIGNAL_INFO_T nr_sig_info;
+}QSER_NW_SIGNAL_STRENGTH_INFO_T;
+
+
+
+
+
+/* @bridef Callback function registered to QSER_NW_AddRxMsgHandler
+ * map of ind_flag and ind_msg_buf as bellow :
+ * NW_IND_VOICE_REG_EVENT_IND_FLAG : QSER_NW_VOICE_REG_EVENT_IND_T
+ * NW_IND_DATA_REG_EVENT_IND_FLAG : QSER_NW_DATA_REG_EVENT_IND_T
+ * NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG : QSER_NW_SINGNAL_EVENT_IND_T
+ * NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG : QSER_NW_CELL_ACCESS_STATE_EVENT_IND_T
+ * NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG : QSER_NW_NITZ_TIME_EVENT_IND_T
+ * NW_IND_IMS_REG_EVENT_IND_FLAG : NULL
+ * */
+typedef void (*QSER_NW_RxMsgHandlerFunc_t)(
+ nw_client_handle_type h_nw,
+ uint32_t ind_flag,
+ void *ind_msg_buf,
+ uint32_t ind_msg_len,
+ void *contextPtr
+);
+
+
+/** Indication message; Indication for the corresponding registered event flag NW_IND_VOICE_REG_EVENT_IND_FLAG */
+typedef struct {
+
+ uint8_t registration_valid; /**< Must be set to TRUE if voice_registration is being passed. */
+ QSER_NW_COMMON_REG_INFO_T registration; /**< Voice registration. */
+
+ uint8_t registration_details_3gpp_valid; /**< Must be set to TRUE if voice_registration_details_3gpp is being passed. */
+ QSER_NW_3GPP_REG_INFO_T registration_details_3gpp; /**< Voice registration details for 3GPP. */
+
+ uint8_t registration_details_3gpp2_valid; /**< Must be set to TRUE if voice_registration_details_3gpp2 is being passed. */
+ QSER_NW_3GPP2_REG_INFO_T registration_details_3gpp2; /**< Voice registration details for 3GPP2. */
+}QSER_NW_VOICE_REG_EVENT_IND_T;
+
+/** Indication message; Indication for the corresponding registered event flag NW_IND_DATA_REG_EVENT_IND_FLAG */
+typedef struct {
+
+ uint8_t registration_valid; /**< Must be set to TRUE if data_registration is being passed. */
+ QSER_NW_COMMON_REG_INFO_T registration; /**< Data registration. */
+
+ uint8_t registration_details_3gpp_valid; /**< Must be set to TRUE if data_registration_details_3gpp is being passed. */
+ QSER_NW_3GPP_REG_INFO_T registration_details_3gpp; /**< Data registration details for 3GPP. */
+
+ uint8_t registration_details_3gpp2_valid; /**< Must be set to TRUE if data_registration_details_3gpp2 is being passed. */
+ QSER_NW_3GPP2_REG_INFO_T registration_details_3gpp2; /**< Data registration details for 3GPP2. */
+}QSER_NW_DATA_REG_EVENT_IND_T;
+
+
+/** Indication message; Indication for the corresponding registered event flag NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG */
+typedef struct {
+ uint8_t gsm_sig_info_valid; /**< Must be set to TRUE if gsm_sig_info is being passed. */
+ QSER_NW_GSM_SIGNAL_INFO_T gsm_sig_info; /**< GSM singal information. */
+
+ uint8_t wcdma_sig_info_valid; /**< Must be set to TRUE if wcdma_sig_info is being passed. */
+ QSER_NW_WCDMA_SIGNAL_INFO_T wcdma_sig_info; /**< WCDMA singal information. */
+
+ uint8_t tdscdma_sig_info_valid; /**< Must be set to TRUE if tdscdma_sig_info is being passed. */
+ QSER_NW_TDSCDMA_SIGNAL_INFO_T tdscdma_sig_info; /**< TDSCDMA singal information. */
+
+ uint8_t lte_sig_info_valid; /**< Must be set to TRUE if lte_sig_info is being passed. */
+ QSER_NW_LTE_SIGNAL_INFO_T lte_sig_info; /**< LTE singal information. */
+
+ uint8_t cdma_sig_info_valid; /**< Must be set to TRUE if cdma_sig_info is being passed. */
+ QSER_NW_CDMA_SIGNAL_INFO_T cdma_sig_info; /**< CDMA singal information. */
+
+ uint8_t hdr_sig_info_valid; /**< Must be set to TRUE if hdr_sig_info is being passed. */
+ QSER_NW_HDR_SIGNAL_INFO_T hdr_sig_info; /**< HDR singal information. */
+
+ uint8_t nr_sig_info_valid;
+ QSER_NW_NR_SIGNAL_INFO_T nr_sig_info;
+}QSER_NW_SINGNAL_EVENT_IND_T;
+
+typedef enum
+{
+ E_QSER_NW_RF_MODE_CFUN_0 = 0, /**< CFUN 0. */
+ E_QSER_NW_RF_MODE_CFUN_1 = 1, /**< CFUN 1. */
+ E_QSER_NW_RF_MODE_FLIGHT = 4, /**< Flight Mode, CFUN 4. */
+}E_QSER_NW_RF_MODE_TYPE_T;
+
+int qser_nw_client_init(nw_client_handle_type *ph_nw);
+
+int qser_nw_client_deinit(nw_client_handle_type h_nw);
+
+int qser_nw_set_config
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_CONFIG_INFO_T *pt_info
+);
+
+int qser_nw_set_ims_enable
+(
+ nw_client_handle_type h_nw,
+ E_QSER_NW_IMS_MODE_TYPE_T ims_mode
+);
+
+int qser_nw_set_oos_config
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_OOS_CONFIG_INFO_T *pt_info
+);
+
+int qser_nw_get_oos_config
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_OOS_CONFIG_INFO_T *pt_info
+);
+
+int qser_nw_event_register
+(
+ nw_client_handle_type h_nw,
+ uint32_t bitmask // bit OR of NW_IND_xxxx_EVENT_ON
+);
+
+int qser_nw_get_operator_name
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_OPERATOR_NAME_INFO_T *pt_info //You should malloc this or may cause stack overflow
+);
+
+int qser_nw_get_reg_status
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_REG_STATUS_INFO_T *pt_info
+);
+
+int qser_nw_get_ims_reg_status
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_IMS_REG_STATUS_INFO_T *pt_info
+);
+
+int qser_nw_get_signal_strength
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info
+);
+
+int qser_nw_add_rx_msg_handler
+(
+ nw_client_handle_type h_nw,
+ QSER_NW_RxMsgHandlerFunc_t handlerPtr,
+ void* contextPtr
+);
+
+int qser_nw_set_rf_mode
+(
+ nw_client_handle_type h_nw,
+ E_QSER_NW_RF_MODE_TYPE_T rf_mode
+);
+
+int qser_nw_get_rf_mode
+(
+ nw_client_handle_type h_nw,
+ E_QSER_NW_RF_MODE_TYPE_T *rf_mode
+);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif//__QSER_NW_H__
diff --git a/mbtk/test/liblynq_lib/lynq_systime_demo.cpp b/mbtk/test/liblynq_lib/lynq_systime_demo.cpp
new file mode 100755
index 0000000..a600884
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq_systime_demo.cpp
@@ -0,0 +1,274 @@
+/**@File lynq-systime-demo.cpp
+ *
+ * @Brief As a example for liblynq-systime.
+ *
+ * @Author sj.zhang
+ *
+ * @Date 2023-08-15
+ *
+ * @Version V1.0
+ *
+ * @copyright Copyright (c) MobileTek
+ */
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+
+typedef struct time_source_status
+{
+ int ntp;
+ int nitz;
+ int gnss;
+} time_src_status_s;
+
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+int (*lynq_sync_time_from_rtc)(void);
+int (*lynq_set_rtc_time)(void);
+int (*lynq_get_rtc_time)(unsigned long *ulsec);
+
+#endif
+void *dlHandle_systime = NULL;
+int (*modem_time_enable)(int enable);
+int (*gnss_time_enable)(int enable);
+int (*ntp_sync_time)(int enable);
+int (*user_set_time)(char *date, char *time);
+int (*lynq_get_time_src_status)(time_src_status_s *time_src);
+int (*get_sync_time_result)();
+
+
+int lynq_ntp_sync_demo(int argc, char *argv[])
+{
+ int ret = -1;
+ if (argc != 3)
+ {
+ printf("Parameter number wrong !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ntp_sync_time = (int (*)(int enable))dlsym(dlHandle_systime, "ntp_sync_time");
+ if (NULL == ntp_sync_time)
+ {
+ fprintf(stderr, "Failed to dlsym function ntp_sync_time : %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = ntp_sync_time(atoi(argv[2]));
+ switch (ret)
+ {
+ case 0:
+ printf("set success!\n");
+ break;
+ case 1:
+ printf("NTP_ALREADY_ENABLE!\n");
+ break;
+ case 2:
+ printf("NTP_ALREADY_DISENABLE!\n");
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
+int lynq_modem_sync_demo(int argc, char *argv[])
+{
+ int ret = -1;
+ if (argc != 3)
+ {
+ printf("Parameter number wrong !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ modem_time_enable = (int (*)(int enable))dlsym(dlHandle_systime, "modem_time_enable");
+ if (NULL == modem_time_enable)
+ {
+ fprintf(stderr, "Failed to dlsym function modem_time_enable: %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = modem_time_enable(atoi(argv[2]));
+ printf("ret = %d\n", ret);
+ if (ret != 0 && ret != 4)
+ {
+ printf("modem_time_enable failed !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ return 0;
+}
+
+int lynq_gnss_sync_demo(int argc, char *argv[])
+{
+ int ret = -1;
+ if (argc != 3)
+ {
+ printf("Parameter number wrong !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ gnss_time_enable = (int (*)(int enable))dlsym(dlHandle_systime, "gnss_time_enable");
+ if (NULL == gnss_time_enable)
+ {
+ fprintf(stderr, "Failed to dlsym function gnss_time_enable: %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = gnss_time_enable(atoi(argv[2]));
+ printf("ret = %d\n", ret);
+ if (ret != 0 && ret != 4)
+ {
+ printf("gnss_time_enable failed !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ return ret;
+}
+
+int lynq_user_set_time_demo(int argc, char *argv[])
+{
+ int ret = -1;
+ if (argc != 4)
+ {
+ printf("Parameter number wrong !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ user_set_time = (int (*)(char *date, char *time))dlsym(dlHandle_systime, "user_set_time");
+ if (NULL == user_set_time)
+ {
+ fprintf(stderr, "Failed to dlsym function user_set_time: %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = user_set_time(argv[2], argv[3]);
+ return ret;
+}
+
+int lynq_get_time_src_status_demo(int arg_c, char *arg_v[])
+{
+ lynq_get_time_src_status = (int (*)(time_src_status_s *time_src))dlsym(dlHandle_systime, "lynq_get_time_src_status");
+ if (NULL == lynq_get_time_src_status)
+ {
+ fprintf(stderr, "Failed to dlsym function lynq_get_time_src_status : %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ time_src_status_s time_src = {0};
+ lynq_get_time_src_status(&time_src);
+ printf("time source status are :\nntp=%d\nnitz=%d\ngnss=%d\n", time_src.ntp, time_src.nitz, time_src.gnss);
+ return 0;
+}
+
+int lynq_get_sync_status_demo(int arg_c, char *arg_v[])
+{
+ get_sync_time_result = (int (*)(void))dlsym(dlHandle_systime, "get_sync_time_result");
+ int ret = 0;
+ if(NULL == get_sync_time_result)
+ {
+ printf("Failed to dlsym function get_sync_time_result: %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = get_sync_time_result();
+ printf("get_sync_time_result = %d\n",ret);
+ dlclose(dlHandle_systime);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = -1;
+ char *cmd = argv[1];
+ printf("enter lynq_systime_demo \n");
+ dlHandle_systime = dlopen("/lib/liblynq-systime.so", RTLD_NOW);
+ if (!dlHandle_systime)
+ {
+ fprintf(stderr, "Failed to load library: %s\n", dlerror());
+ return 1;
+ }
+
+ if (cmd == NULL)
+ {
+ printf("No command received!\n");
+ dlclose(dlHandle_systime);
+ return 1;
+ }
+ else if (strcmp(cmd, "ntp") == 0)
+ {
+ ret = lynq_ntp_sync_demo(argc, argv);
+ }
+ else if (strcmp(cmd, "nitz") == 0)
+ {
+ ret = lynq_modem_sync_demo(argc, argv);
+ }
+ else if (strcmp(cmd, "gnss") == 0)
+ {
+ ret = lynq_gnss_sync_demo(argc, argv);
+ }
+ else if (strcmp(cmd, "user") == 0)
+ {
+ ret = lynq_user_set_time_demo(argc, argv);
+ }
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+ else if (strcmp(cmd, "sync_rtc") == 0)
+ {
+ lynq_sync_time_from_rtc = (int (*)(void))dlsym(dlHandle_systime, "lynq_sync_time_from_rtc");
+ if (NULL == lynq_sync_time_from_rtc)
+ {
+ fprintf(stderr, "Failed to dlsym function lynq_sync_time_from_rtc : %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = lynq_sync_time_from_rtc();
+ }
+ else if (strcmp(cmd, "rtc_set") == 0)
+ {
+ lynq_set_rtc_time = (int (*)(void))dlsym(dlHandle_systime, "lynq_set_rtc_time");
+ if (NULL == lynq_set_rtc_time)
+ {
+ fprintf(stderr, "Failed to dlsym function lynq_set_rtc_time : %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ ret = lynq_set_rtc_time();
+ }
+ else if (strcmp(cmd, "rtc_get") == 0)
+ {
+ lynq_get_rtc_time = (int (*)(unsigned long *ulsec))dlsym(dlHandle_systime, "lynq_get_rtc_time");
+ if (NULL == lynq_get_rtc_time)
+ {
+ fprintf(stderr, "Failed to dlsym function lynq_get_rtc_time : %s\n", dlerror());
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ unsigned long time_ret;
+ ret = lynq_get_rtc_time(&time_ret);
+ time_t tp = (time_t)time_ret;
+ char *rtc_time = ctime(&tp);
+ printf("rtc_time seconds = %lu\n", time_ret);
+ printf("rtc time = %s\n", rtc_time);
+ }
+#endif
+ else if (strcmp(cmd, "src_status") == 0)
+ {
+ ret = lynq_get_time_src_status_demo(argc, argv);
+ }
+ else if (strcmp(cmd,"sync_status") == 0)
+ {
+ ret = lynq_get_sync_status_demo(argc, argv);
+ }
+ else
+ {
+ printf("command wrong !\n");
+ dlclose(dlHandle_systime);
+ return -1;
+ }
+ if (0 != ret)
+ {
+ printf("ret = %d\n Command execution failure.\n", ret);
+ }
+ dlclose(dlHandle_systime);
+ return ret;
+}
diff --git a/mbtk/test/liblynq_lib/poweralarm-demo.cpp b/mbtk/test/liblynq_lib/poweralarm-demo.cpp
new file mode 100755
index 0000000..0bca3bb
--- /dev/null
+++ b/mbtk/test/liblynq_lib/poweralarm-demo.cpp
@@ -0,0 +1,304 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdint.h>
+
+
+#define INIT_SUCCESS 0
+#define RTC_DEINIT -1
+typedef struct
+{
+ int cmdIdx;
+ char *funcName;
+} st_api_test_case;
+
+
+//for server test
+st_api_test_case at_api_testcases[] =
+{
+ {0, "print_help"},
+ {1, "lynq_rtc_service_init"},
+ {2, "poweralarm"},
+ {3, "wakealarm"},
+ {4, "cancel_wakealarm"},
+ {5, "lynq_set_poweralarm"},
+ {6, "lynq_set_wakealarm"},
+ {7, "lynq_rtc_service_deinit"},
+ {-1, NULL}
+};
+
+ int init_flag = -1;
+ int src_id = -1;
+ void *dlHandle_poweralarm = NULL;
+
+typedef int (*lynq_wakealarm_add_cb)(unsigned int src_id, int rtc_id);
+
+int (*lynq_rtc_service_init)(void);
+int (*lynq_rtc_service_deinit)(void);
+int (*poweralarm)(char *buffer,int src_id);
+int (*wakealarm)(char *buffer,int srcid,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify);
+int (*cancel_wakealarm)(int src_id,int rtc_id);
+int (*lynq_set_poweralarm)(unsigned long time_sec,int src_id);
+int (*lynq_set_wakealarm)(unsigned long time_sec,int srcid,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify);
+
+
+
+void print_help(void)
+{
+ int i;
+ printf("Supported test cases:\n");
+ for(i = 0; ; i++)
+ {
+ if(at_api_testcases[i].cmdIdx == -1)
+ {
+ break;
+ }
+ printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);
+ }
+}
+
+int lynq_wakealarm_add_callback(unsigned int src_id, int rtc_id)
+{
+ printf("wake alarm callback test \n");
+ return 0;
+}
+
+
+int main(int argc,char *argv[])
+{
+
+ int cmdIdx = 0;
+ printf("Enter main function\n");
+
+ const char *dlHandle_Path_poweralarm = "/lib/libpoweralarm.so";
+ dlHandle_poweralarm = dlopen(dlHandle_Path_poweralarm, RTLD_NOW);
+ if (dlHandle_poweralarm == NULL)
+ {
+ printf("dlopen dlHandle_fota failed: %s\n", dlerror());
+ return -1;
+ }
+
+ poweralarm = (int (*)(char *buffer,int src_ids))dlsym(dlHandle_poweralarm, "poweralarm");
+ if(poweralarm == NULL)
+ {
+ printf("poweralarm is null\n");
+ return -1;
+ }
+
+ wakealarm = (int (*)(char *buffer,int srcid,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify))dlsym(dlHandle_poweralarm, "wakealarm");
+ if(wakealarm == NULL)
+ {
+ printf("wakealarm is null\n");
+ return -1;
+ }
+ lynq_set_poweralarm = (int (*)(unsigned long,int src_id))dlsym(dlHandle_poweralarm,"lynq_set_poweralarm");
+ if(lynq_set_poweralarm == NULL)
+ {
+ printf("lynq_set_poweralarm is null\n");
+ return -1;
+ }
+ lynq_set_wakealarm = (int (*)(unsigned long,int srcid,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify))dlsym(dlHandle_poweralarm,"lynq_set_wakealarm");
+ if(lynq_set_wakealarm == NULL)
+ {
+ printf("lynq_set_wakealarm is null\n");
+ return -1;
+ }
+
+ cancel_wakealarm = (int (*)(int src_id,int rtc_id))dlsym(dlHandle_poweralarm, "cancel_wakealarm");
+ if(cancel_wakealarm == NULL)
+ {
+ printf("cancel_wakealarm is null\n");
+ return -1;
+ }
+
+ lynq_rtc_service_init = (int(*)())dlsym(dlHandle_poweralarm,"lynq_rtc_service_init");
+ if(lynq_rtc_service_init == NULL)
+ {
+ printf("lynq_rtc_service_init is null\n");
+ return -1;
+ }
+
+ lynq_rtc_service_deinit = (int (*)())dlsym(dlHandle_poweralarm,"lynq_rtc_service_deinit");
+ if(lynq_rtc_service_deinit == NULL)
+ {
+ printf("lynq_rtc_service_deinit is null \n");
+ return -1;
+ }
+
+ print_help();
+ while(1)
+ {
+
+ printf("\nplease input cmd index(-1 exit): ");
+ scanf("%d", &cmdIdx);
+ if(cmdIdx == -1)
+ {
+ break;
+ }
+ switch(cmdIdx)
+ {
+ case 0:
+ print_help();
+ break;
+ case 1:
+ {
+ src_id = lynq_rtc_service_init();
+ if(src_id <= 0)
+ {
+
+ printf("RTC service init failed ");
+ return -1;
+ }
+ else
+ {
+ init_flag = INIT_SUCCESS;
+ }
+
+ break;
+ }
+ case 2:
+ {
+
+ if(init_flag != INIT_SUCCESS)
+ {
+ printf("*****ERROR must init rtc service ,Please reselect *******\n ");
+ }
+ else
+ {
+ int ret = 0;
+ char tmp_time[32] = {0};
+ printf("Set poweralarm time,e.g: 60 (seconds)\n");
+ scanf("%s",tmp_time);
+ ret = poweralarm(tmp_time,src_id);
+ if(ret != 0)
+ {
+ printf("set poweralarm failed\n");
+ return -1;
+ }
+ }
+ break;
+ }
+ case 3:
+ {
+ if(init_flag != INIT_SUCCESS)
+ {
+ printf("*****ERROR must init rtc service ,Please reselect *******\n ");
+ }
+ else
+ {
+ int ret = 0;
+ char tmp_time[32]={0};
+ int rtc_id = 0;
+ printf("Set wakealarm time ,e.g: 60 1 (seconds)\n");
+ scanf("%s%d",tmp_time,&rtc_id);
+
+ ret = wakealarm(tmp_time,src_id,rtc_id,lynq_wakealarm_add_callback);
+ if(ret != 0)
+ {
+ printf("set wakealarm failed\n");
+ return -1;
+ }
+ }
+ break;
+ }
+ case 4:
+ {
+ if(init_flag != INIT_SUCCESS)
+ {
+ printf("*****ERROR must init rtc service ,Please reselect *******\n ");
+ }
+ else
+ {
+ int ret = 0;
+ int rtc_id = 0;
+ printf("Please input you want cancel rtc timer rtc id\n");
+ scanf("%d",&rtc_id);
+ ret = cancel_wakealarm(src_id,rtc_id);
+ if(ret != 0)
+ {
+ printf("Cancel_wakealarm failed!!!");
+ return -1;
+ }
+ }
+ break;
+ }
+ case 5:
+ {
+ if(init_flag != INIT_SUCCESS)
+ {
+ printf("*****ERROR must init rtc service ,Please reselect *******\n ");
+ }
+ else
+ {
+ int ret = 0;
+ unsigned long time_sec = 0;
+ printf("Input time_sec you want poweralarm,e.g: 60 (seconds)\n");
+ scanf("%lu",&time_sec);
+ ret =lynq_set_poweralarm(time_sec,src_id);
+ printf("ret is %d\n",ret);
+ if(ret != 0)
+ {
+ printf("lynq_set_poweralarm failed\n");
+ return -1;
+ }
+ }
+ break;
+ }
+ case 6:
+ {
+ if(init_flag != INIT_SUCCESS)
+ {
+ printf("*****ERROR must init rtc service ,Please reselect *******\n ");
+ }
+ else
+ {
+ int ret = 0;
+ unsigned long time_sec = 0;
+ int rtc_id;
+ printf("Input time_sec you want wakealarm,e.g:60 1(seconds)\n");
+ scanf("%lu%d",&time_sec,&rtc_id);
+ ret =lynq_set_wakealarm(time_sec,src_id,rtc_id,lynq_wakealarm_add_callback);
+ if(ret != 0)
+ {
+ printf("lynq_set_wakealarm failed\n");
+ return -1;
+ }
+ }
+ break;
+ }
+ case 7:
+ {
+ if(init_flag != INIT_SUCCESS)
+ {
+ printf("*****ERROR must init rtc service ,Please reselect *******\n ");
+ }
+ else
+ {
+ int ret = -1;
+ printf("rtc servce deinit !!!!!!!!!!!!");
+ ret = lynq_rtc_service_deinit();
+ if(ret != 0)
+ {
+ printf("lynq rtc service deinit failed \n");
+ return -1;
+ }
+ else
+ {
+ init_flag = RTC_DEINIT;
+ }
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ return 0;
+
+}
+
diff --git a/mbtk/test/liblynq_lib/qser_sim_test.c b/mbtk/test/liblynq_lib/qser_sim_test.c
index cae4530..d6478c4 100755
--- a/mbtk/test/liblynq_lib/qser_sim_test.c
+++ b/mbtk/test/liblynq_lib/qser_sim_test.c
@@ -18,304 +18,420 @@
sim_client_handle_type ph_sim = 2023;
sim_client_handle_type h_sim = 2023;
+int flag_init = 0;
+typedef struct
+{
+ int cmdIdx;
+ const char *funcName;
+} st_api_test_case;
+
+//for server test
+st_api_test_case at_api_testcases[] =
+{
+ {0, "qser_sim_init"},
+ {1, "qser_get_imsi"},
+ {2, "qser_get_iccid"},
+ {3, "qser_get_phonenumber"},
+ {4, "qser_verify_pin"},
+ {5, "qser_change_pin"},
+ {6, "qser_unlock_pin"},
+ {7, "qser_enable_pin"},
+ {8, "qser_disable_pin"},
+ {9, "qser_get_sim_status"},
+ {10, "qser_get_imei"},
+ {11, "qser_get_imei_and_sv"},
+ {12, "qser_reset_modem"},
+ {13, "qser_get_version"},
+ {14, "qser_reset_sim"},
+ {15, "qser_deinit_sim"},
+ {-1, NULL}
+};
+
+void print_help(void)
+{
+ int i;
+ printf("Supported test cases:\n");
+ for(i = 0; ; i++)
+ {
+ if(at_api_testcases[i].cmdIdx == -1)
+ {
+ break;
+ }
+ printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);
+ }
+}
int main(int argc, char const *argv[])
{
- printf("=========sim main=========\n"
- "\t0 qser_sim_init\n"
- "\t1 qser_get_imsi\n"
- "\t2 qser_get_iccid\n"
- "\t3 qser_get_phonenumber\n"
- "\t4 qser_verify_pin\n"
- "\t5 qser_change_pin\n"
- "\t6 qser_unlock_pin\n"
- "\t7 qser_enable_pin\n"
- "\t8 qser_disable_pin\n"
- "\t9 qser_get_sim_status\n"
- "\t10 qser_get_imei\n"
- "\t11 qser_get_imei_and_sv\n"
- "\t12 qser_reset_modem\n"
- "\t13 qser_get_version\n"
- "\t14 qser_reset_sim\n"
- "\t15 qser_deinit_sim\n"
- "\t16 exit\n");
+ int cmdIdx = 0;
+ int res = 0;
+ print_help();
while(1)
{
- int cmdIdx = -1;
- int res = -1;
-
- printf("operator: >> \n");
-
+ printf("\nplease input cmd index(-1 exit): ");
scanf("%d", &cmdIdx);
- fflush(stdin);
+ if(cmdIdx == -1)
+ {
+ break;
+ }
switch(cmdIdx)
{
//"qser_sim_init"
case 0:
{
- //int token;
- //printf("input token\n");
- //scanf("%d", &token);
- res = qser_sim_client_init(&h_sim);
- if(res == 0)
+ if(flag_init == 1)
{
- printf("Run qser_sim_client_init\n");
- }else{
- printf("qser_sim_client_init error\n");
+ printf("init is already\n");
+ break;
+ }
+ else{
+ //int token;
+ //printf("input token\n");
+ //scanf("%d", &token);
+ res = qser_sim_client_init(&h_sim);
+ if(res == 0)
+ {
+ printf("Run qser_sim_client_init\n");
+ flag_init = 1;
+ }else{
+ printf("qser_sim_client_init error\n");
+ }
+
+ break;
}
}
- break;
+
//"qser_sim_getimsi"
case 1:
{
- char imsi[BUF_SIZE] = {0};
- QSER_SIM_APP_ID_INFO_T pt_info;
- res = qser_sim_getimsi(h_sim, &pt_info, imsi, BUF_SIZE);
- if(res == 0)
- {
- printf("imsi is %s!!!\n",imsi);
- }else{
- printf("get imsi error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char imsi[BUF_SIZE] = {0};
+ QSER_SIM_APP_ID_INFO_T pt_info;
+ res = qser_sim_getimsi(h_sim, &pt_info, imsi, 32);
+ if(res == 0)
+ {
+ printf("imsi is %s!!!\n",imsi);
+ }else{
+ printf("get imsi error, res = %d\n", res);
+ }
+ }
+ break;
}
- break;
+
//"qser_get_iccid"
case 2:
{
- char iccid[BUF_SIZE] = {0};
- res = qser_sim_geticcid(h_sim, QSER_SIM_SLOT_ID_1, iccid, BUF_SIZE);
- if(res == 0)
- {
- printf("get iccid success!!! iccid is %s\n",iccid);
- }else{
- printf("get iccid error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char iccid[BUF_SIZE] = {0};
+ res = qser_sim_geticcid(h_sim, QSER_SIM_SLOT_ID_1, iccid, 32);
+ if(res == 0)
+ {
+ printf("get iccid success!!! iccid is %s\n",iccid);
+ }else{
+ printf("get iccid error, res = %d\n", res);
+ }
+ }
+ break;
}
- break;
//qser_get_phonenumber
case 3:
{
- char phonenumber[BUF_SIZE] = "";
- QSER_SIM_APP_ID_INFO_T pt_info;
- res = qser_sim_getphonenumber(h_sim, &pt_info, phonenumber, BUF_SIZE);
- if(res == 0)
- {
- printf("get phonenumber success!!! phonenumber is %s\n",phonenumber);
- }else{
- printf("get phonenumber error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
- }
- break;
- //qser_verify_pin
+ else{
+ char phonenumber[BUF_SIZE] = "";
+ QSER_SIM_APP_ID_INFO_T pt_info;
+ res = qser_sim_getphonenumber(h_sim, &pt_info, phonenumber, 32);
+ if(res == 0)
+ {
+ printf("get phonenumber success!!! phonenumber is %s\n",phonenumber);
+ }else{
+ printf("get phonenumber error, res = %d\n", res);
+ }
+ }
+ break;
+ }
+ //qser_verify_pin
case 4:
{
- char pin[BUF_PIN] = {0};
- QSER_SIM_VERIFY_PIN_INFO_T pt_info;
- printf("input pin\n");
- scanf("%s", pin);
- strncpy(pt_info.pin_value, pin, BUF_PIN);
- printf("pin_value = %s , pin = %s\n", pt_info.pin_value, pin);
- pt_info.pin_value_len = strlen(pt_info.pin_value);
-
- res = qser_sim_verifypin(h_sim, &pt_info);
- if(res == 0)
- {
- printf("verify pin success!!!\n");
- }else{
- printf("verify pin error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char pin[BUF_PIN] = {0};
+ QSER_SIM_VERIFY_PIN_INFO_T pt_info;
+ printf("input pin\n");
+ scanf("%s", pin);
+ strncpy(pt_info.pin_value, pin, BUF_PIN);
+ printf("pin_value = %s , pin = %s\n", pt_info.pin_value, pin);
+ pt_info.pin_value_len = strlen(pt_info.pin_value);
+
+ res = qser_sim_verifypin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("verify pin success!!!\n");
+ }else{
+ printf("verify pin error, res = %d\n", res);
+ }
+
+ }
+ break;
}
- break;
//qser_change_pin
case 5:
{
- char old_pin[BUF_PIN] = {0};
- QSER_SIM_CHANGE_PIN_INFO_T pt_info;
- printf("input old pin\n");
- scanf("%s", old_pin);
- char new_pin[BUF_PIN] = {0};
- printf("input new pin\n");
- scanf("%s", new_pin);
- strncpy(pt_info.old_pin_value, old_pin, BUF_PIN);
- strncpy(pt_info.new_pin_value, new_pin, BUF_PIN);
- printf("pt_info.old_pin_value = %s, old_pin = %s\n", pt_info.old_pin_value, old_pin);
- printf("pt_info.new_pin_value = %s, new_pin = %s\n", pt_info.new_pin_value, new_pin);
- pt_info.old_pin_value_len = strlen(pt_info.old_pin_value);
- pt_info.new_pin_value_len = strlen(pt_info.new_pin_value);
-
- res = qser_sim_changepin(h_sim, &pt_info);
- if(res == 0)
- {
- printf("change pin success!!!\n");
- }else{
- printf("change pin error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char old_pin[BUF_PIN] = {0};
+ QSER_SIM_CHANGE_PIN_INFO_T pt_info;
+ printf("input old pin\n");
+ scanf("%s", old_pin);
+ char new_pin[BUF_PIN] = {0};
+ printf("input new pin\n");
+ scanf("%s", new_pin);
+ strncpy(pt_info.old_pin_value, old_pin, BUF_PIN);
+ strncpy(pt_info.new_pin_value, new_pin, BUF_PIN);
+ printf("pt_info.old_pin_value = %s, old_pin = %s\n", pt_info.old_pin_value, old_pin);
+ printf("pt_info.new_pin_value = %s, new_pin = %s\n", pt_info.new_pin_value, new_pin);
+ pt_info.old_pin_value_len = strlen(pt_info.old_pin_value);
+ pt_info.new_pin_value_len = strlen(pt_info.new_pin_value);
+
+ res = qser_sim_changepin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("change pin success!!!\n");
+ }else{
+ printf("change pin error, res = %d\n", res);
+ }
+ }
+ break;
}
- break;
//qser_unlock_pin
case 6:
{
- char puk[BUF_PIN] = {0};
- QSER_SIM_UNBLOCK_PIN_INFO_T pt_info;
- printf("input puk\n");
- scanf("%s", puk);
- char new_pin[BUF_PIN] = {0};
- printf("input new pin\n");
- scanf("%s", new_pin);
-
- strncpy(pt_info.puk_value, puk, BUF_PIN);
- strncpy(pt_info.new_pin_value, new_pin, BUF_PIN);
- printf("pt_info.puk_value = %s, puk = %s\n", pt_info.puk_value, puk);
- printf("pt_info.new_pin_value = %s, new_pin = %s\n", pt_info.new_pin_value, new_pin);
- pt_info.new_pin_value_len = strlen(pt_info.new_pin_value);
- pt_info.puk_value_len = strlen(pt_info.puk_value);
-
- res = qser_sim_unblockpin(h_sim, &pt_info);
- if(res == 0)
- {
- printf("unlock pin success!!!\n");
- }else{
- printf("unlock pin error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char puk[BUF_PIN] = {0};
+ QSER_SIM_UNBLOCK_PIN_INFO_T pt_info;
+ printf("input puk\n");
+ scanf("%s", puk);
+ char new_pin[BUF_PIN] = {0};
+ printf("input new pin\n");
+ scanf("%s", new_pin);
+
+ strncpy(pt_info.puk_value, puk, BUF_PIN);
+ strncpy(pt_info.new_pin_value, new_pin, BUF_PIN);
+ printf("pt_info.puk_value = %s, puk = %s\n", pt_info.puk_value, puk);
+ printf("pt_info.new_pin_value = %s, new_pin = %s\n", pt_info.new_pin_value, new_pin);
+ pt_info.new_pin_value_len = strlen(pt_info.new_pin_value);
+ pt_info.puk_value_len = strlen(pt_info.puk_value);
+
+ res = qser_sim_unblockpin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("unlock pin success!!!\n");
+ }else{
+ printf("unlock pin error, res = %d\n", res);
+ }
+ }
+ break;
}
- break;
//qser_enable_pin
case 7:
- {
- char pin[BUF_PIN] = {0};
- QSER_SIM_ENABLE_PIN_INFO_T pt_info;
- printf("input pin\n");
- scanf("%s", pin);
- strncpy(pt_info.pin_value, pin, BUF_PIN);
- pt_info.pin_value_len = strlen(pt_info.pin_value);
-
- res = qser_sim_enablepin(h_sim, &pt_info);
- if(res == 0)
- {
- printf("pin enabled!!!\n");
- }else{
- printf("pin enable error, res =%d\n", res);
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char pin[BUF_PIN] = {0};
+ QSER_SIM_ENABLE_PIN_INFO_T pt_info;
+ printf("input pin\n");
+ scanf("%s", pin);
+ strncpy(pt_info.pin_value, pin, BUF_PIN);
+ pt_info.pin_value_len = strlen(pt_info.pin_value);
+
+ res = qser_sim_enablepin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("pin enabled!!!\n");
+ }else{
+ printf("pin enable error, res =%d\n", res);
+ }
+ }
+ break;
}
- break;
//qser_disable_pin
case 8:
{
- char pin[BUF_PIN] = {0};
- QSER_SIM_ENABLE_PIN_INFO_T pt_info;
- printf("input pin\n");
- scanf("%s", pin);
- strncpy(pt_info.pin_value, pin, BUF_PIN);
- pt_info.pin_value_len = strlen(pt_info.pin_value);
-
- res = qser_sim_disablepin(h_sim, &pt_info);
- if(res == 0)
- {
- printf("pin disnabled!!!\n");
- }else{
- printf("pin disable error,res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char pin[BUF_PIN] = {0};
+ QSER_SIM_ENABLE_PIN_INFO_T pt_info;
+ printf("input pin\n");
+ scanf("%s", pin);
+ strncpy(pt_info.pin_value, pin, BUF_PIN);
+ pt_info.pin_value_len = strlen(pt_info.pin_value);
+
+ res = qser_sim_disablepin(h_sim, &pt_info);
+ if(res == 0)
+ {
+ printf("pin disnabled!!!\n");
+ }else{
+ printf("pin disable error,res = %d\n", res);
+ }
+ }
+ break;
}
- break;
- //qser_get_sim_status
+ //qser_get_sim_status
case 9:
{
- QSER_SIM_CARD_STATUS_INFO_T pt_info;
-
- res = qser_sim_getcardstatus(h_sim, QSER_SIM_SLOT_ID_1, &pt_info);
- if(res == 0)
- {
- printf("state is %d !!!\n",pt_info.e_card_state);
- }else{
- printf("get imsi error,res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ QSER_SIM_CARD_STATUS_INFO_T pt_info;
+
+ res = qser_sim_getcardstatus(h_sim, QSER_SIM_SLOT_ID_1, &pt_info);
+ if(res == 0)
+ {
+ printf("state is %d !!!\n",pt_info.e_card_state);
+ }else{
+ printf("get imsi error,res = %d\n", res);
+ }
+ }
+ break;
}
- break;
//qser_get_imei
case 10:
{
- char imei[BUF_SIZE]="";
- res = qser_sim_getimei(h_sim, imei);
- if(res == 0)
- {
- printf("get imei success!!! imei = %s\n", imei);
- }else{
- printf("get imei error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ char imei[BUF_SIZE]="";
+ res = qser_sim_getimei(h_sim, imei);
+ if(res == 0)
+ {
+ printf("get imei success!!! imei = %s\n", imei);
+ }else{
+ printf("get imei error, res = %d\n", res);
+ }
+ }
+ //flag_init = 0;
+ break;
}
- break;
//qser_get_imei_and_sv
case 11:
{
char imei[BUF_SIZE]="";
char sv[BUF_SIZE]="";
- res = qser_get_imei_and_sv(h_sim, imei, sv);
- if(res == 0)
- {
- printf("get imei and sv success!!!imei = %s sv = %s\n", imei, sv);
- }else{
- printf("get imei and sv error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ res = qser_get_imei_and_sv(h_sim, imei, sv);
+ if(res == 0)
+ {
+ printf("get imei and sv success!!!imei = %s sv = %s\n", imei, sv);
+ }else{
+ printf("get imei and sv error, res = %d\n", res);
+ }
+ }
+ //flag_init = 0;
+ break;
}
- break;
//qser_reset_modem
case 12:
{
- res = qser_reset_modem(h_sim);
- if(res == 0)
- {
- printf("reset modem success!!!\n");
- }else{
- printf("reset modem error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ res = qser_reset_modem(h_sim);
+ if(res == 0)
+ {
+ printf("reset modem success!!!\n");
+ }else{
+ printf("reset modem error, res = %d\n", res);
+ }
+ }
+ //flag_init = 0;
+ break;
}
- break;
//qser_get_version
case 13:
{
char buf[VER_SIZE]="";
-
- res = qser_get_version(h_sim, buf);
- if(res == 0)
- {
- printf("get version success!!! ver = %s\n", buf);
- }else{
- printf("get version error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ res = qser_get_version(h_sim, buf);
+ if(res == 0)
+ {
+ printf("get version success!!! ver = %s\n", buf);
+ }else{
+ printf("get version error, res = %d\n", res);
+ }
+ }
+ //flag_init = 0;
+ break;
}
- break;
//qser_reset_sim
case 14:
{
- res = qser_reset_sim(h_sim);
- if(res == 0)
- {
- printf("reset sim success!!!\n");
- }else{
- printf("reset sim error, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ res = qser_reset_sim(h_sim);
+ if(res == 0)
+ {
+ printf("reset sim success!!!\n");
+ }else{
+ printf("reset sim error, res = %d\n", res);
+ }
+ }
+ //flag_init = 0;
+ break;
}
- break;
//qser_deinit_sim
case 15:
{
- res = qser_sim_client_deinit(h_sim);
- if(res == 0)
- {
- printf("sim deinit success is!!!\n");
- }else{
- printf("sim deint errors, res = %d\n", res);
+ if(flag_init == 0){
+ printf("must init first\n");
}
+ else{
+ res = qser_sim_client_deinit(h_sim);
+ if(res == 0)
+ {
+ printf("sim deinit success is!!!\n");
+ }else{
+ printf("sim deint errors, res = %d\n", res);
+ }
+ }
+ flag_init = 0;
+ break;
}
- break;
- case 16:
- printf("main exit\n");
- return 0;
- default :
+ default:
+ print_help();
break;
}