[Feature][T108][task-view-1499] change gsw .h file
Only Configure: No
Affected branch: GSW_V1453
Affected module: libgsw
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no
Change-Id: I678871907e2be939e6673ee09bfed88992013348
diff --git a/mbtk/include/gsw/gsw_at.h b/mbtk/include/gsw/gsw_at.h
deleted file mode 100755
index 5d9c486..0000000
--- a/mbtk/include/gsw/gsw_at.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @brief AT registered callback function
- * @param [in] const char *input:atcmd command
- * @param [out] char *output:A cache of output command execution results
- * @param [in] out_max_size:Output cache size
- * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
- */
-typedef void(*AT_CALLBACK)(char input[],char output[],int out_max_size);
-
-typedef enum
-{
- soc_max = 0,
- cpu0,
- cpu1,
- cpu2,
- cpu3,
- gpu0,
- gpu1,
- dramc,
- mmsys,
- md_5g,
- md_4g,
- md_3g,
- soc_dram_ntc,
- pa_5g,
- pa_4g,
- rf_ntc,
- pmic,
- pmic_vcore,
- pmic_vpro,
- pmic_vgpu=19,
-}ZONE_NUM;
-
-
-
-
-
-/**
-* @brief Registration interface of AT
-* @param [in] const char *atcmd
-* @param [in] AT_CALLBACK func
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_reg_atcmd(const char *atcmd,AT_CALLBACK func);
-
-/**
- * @brief Initializes the at module in the sdk
- * @param [in/out] None
- * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
- */
-int32_t gsw_sdk_at_init(void);
-
-/**
-* @brief get temperature of specify zone
-* @param [in] ZONE_NUM num
-* @param [out] int *temp
-* @retval RET_SUCCESS\RET_NORMAL_FAIL
-*/
-int32_t gsw_get_modem_temperture(ZONE_NUM num,int32_t *temp);
-
diff --git a/mbtk/include/gsw/gsw_at_interface.h b/mbtk/include/gsw/gsw_at_interface.h
new file mode 100755
index 0000000..2e604f9
--- /dev/null
+++ b/mbtk/include/gsw/gsw_at_interface.h
@@ -0,0 +1,96 @@
+/**
+* @file : gsw_at_interface.h
+* @brief : atCmd and cpu
+* @date : 2022-12-09
+* @author : qinzhijiao6791
+* @version : v1.0
+* @copyright Copyright(C) 2022,Gosuncnwelink
+*/
+#ifndef __GSW_AT_INTERFACE__H__
+#define __GSW_AT_INTERFACE__H__
+
+/*********************************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stddef.h>
+#include "gsw_hal_errcode.h"
+
+#define GSW_AT_SUCCESS GSW_HAL_SUCCESS
+#define GSW_AT_ERROR GSW_HAL_NORMAL_FAIL
+
+typedef enum{
+ soc_max=0,
+ cpu0,
+ cpu1,
+ cpu2,
+ cpu3,
+ gpu0,
+ gpu1,
+ dramc,
+ mmsys,
+ md_5g,
+ md_4g,
+ md_3g,
+ soc_dram_ntc,
+ pa_5g,
+ pa_4g,
+ rf_ntc,
+ pmic,
+ pmic_vcore,
+ pmic_vpro,
+ pmic_vgpu=19,
+ }ZONE_NUM;
+
+/**
+ * @brief at_callback
+ * @param [in] input whole atcmd
+ * @param [in] out_max_size atcmd result maxlenth
+ * @param [out] output atcmd result
+ * @retval
+ */
+typedef void(*LYNQ_AT_CALLBACK)(char input[],char output[],int out_max_size);
+
+/**
+ * @brief register at api, E02 and E06 unused
+ * @param [in] atcmd register part atcmd
+ * @param [in] func at_callback
+ * @retval 0: success
+ * @retval other: failed
+ */
+int gsw_reg_atcmd(const char *atcmd,LYNQ_AT_CALLBACK func);
+
+/**
+ * @brief at_init and modem-temp_init, E02 and E06 unused
+ * @param
+ * @retval 0: success
+ * @retval other: failed
+ */
+int gsw_sdk_at_init(void);
+
+/**
+ * @brief get modem temperture, E02 and E06 unused
+ * @param [in] num ZONE_NUM
+ * @param [out] temp ZONE_NUM_TEMP
+ * @retval 0: LYNQ_THM_OK
+ * @retval -1: THM_OPEN_ERROR
+ * @retval -2: THM_READ_ERROR
+ * @retval -3: THM_ACCESS_ERROR
+ * @retval -4: ERROR_DEVICE
+ */
+int gsw_get_modem_temperture(ZONE_NUM num,int *temp);
+
+/**
+ * @brief sent AT Command and wait result
+ * @param [in] atcmd: at command
+ * @param [out] resp: at result
+ * @param [in] resp_len: length of result
+ * @param [in] timeout_ms: wait timeout millisecond
+ * @retval 0: success
+ * @retval other: failed
+ */
+int gsw_at_cmd_send(const char* atcmd, char* resp, uint32_t resp_len, int64_t timeout_ms);
+
+#endif //__GSW_AT_INTERFACE__H_
diff --git a/mbtk/include/gsw/gsw_data.h b/mbtk/include/gsw/gsw_data.h
deleted file mode 100755
index 3449035..0000000
--- a/mbtk/include/gsw/gsw_data.h
+++ /dev/null
@@ -1,167 +0,0 @@
-#include <stdint.h>
-//gsw include
-
-
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1
-#define GSW_HAL_MEM_INVAILD -2
-#define GSW_NW_OPERATION_NAME_LEN 128
-#define GSW_NW_PLMN_LEN 6
-#define GSW_NW_MCC_LEN 3
-#define GSW_NW_MNC_LEN 3
-#define GSW_NW_PARA_MAX_LEN 128
-#define GSW_MCC_MAX_LEN 16
-#define GSW_MNC_MAX_LEN 16
-#define GSW_APN_CHANNEL_MAX 10
-#define GSW_POXY_ADDR_MAX_LEN 64
-#define GSW_PDP_TYPE_MAX_LEN 16
-#define GSW_APN_MAX_LEN 65
-#define GSW_APN_ID_MAX_LEN 32
-#define GSW_APN_TYPE_MAX_LEN 50
-#define GSW_USR_MAX_LEN 16
-#define GSW_PWD_MAX_LEN 16
-#define GSW_AUTH_TYPE_MAX_LEN 50
-#define GSW_PROTOCO_MAX_LEN 64
-#define GSW_CARRIER_ID_MAX_LEN 64
-#define GSW_IFACE_NAME_MAX_LEN 50
-#define GSW_PDP_ADDR_MAX_LEN 64
-#define GSW_DNS_ADDR_MAX_LEN 64
-#define GSW_GETWAYS_ADDR_MAX_LEN 64
-#define GSW_RSP_MAX_LEN 256
-
-typedef struct {
- int handle; /**< data connection handle*/
- int cid; /**< data connection cid*/
- int state; /**< data connection state*/
- int fail_cause; /**< data connection fail cause*/
- char *type; /**< data connection type*/
- char *ifname; /**< ifname*/
-
- char *v4_ip; /**< ipv4 address*/
- char *v4_pdns; /**< ipv4 pdns address*/
- char *v4_sdns; /**< ipv4 sdns address*/
- char *v4_gw; /**< ipv4 gateway address*/
-
- char *v6_ip; /**< ipv6 address*/
- char *v6_pdns; /**< ipv6 gateway address*/
- char *v6_sdns; /**< ipv6 gateway address*/
-}Wan_State_ind_s;
-
-typedef struct {
- char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address */
- char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/
- char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/
- char gw[GSW_GETWAYS_ADDR_MAX_LEN]; /**< gate way address*/
-}V4_Addr_s;
-
-typedef struct {
- char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address*/
- char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/
- char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/
-}V6_Addr_s;
-
-typedef struct {
- int handle; /**< data connection handle*/
-
- /* req info */
- char mcc[GSW_MCC_MAX_LEN]; /**< apn mcc value*/
- char mnc[GSW_MNC_MAX_LEN]; /**< apn mnc value*/
- char apnid[GSW_APN_ID_MAX_LEN]; /**< apn id*/
- char apn[GSW_APN_MAX_LEN]; /**< apn name*/
- char apnType[GSW_APN_TYPE_MAX_LEN]; /**< apn type ipv4 ipv4v6 ipv6*/
- char usr[GSW_USR_MAX_LEN]; /**< apn usr name*/
- char pwd[GSW_PWD_MAX_LEN]; /**< apn password*/
- char authType[GSW_AUTH_TYPE_MAX_LEN]; /**< apn auth type*/
- char normalProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco*/
- char roamingProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco roaming*/
- char carrier[GSW_CARRIER_ID_MAX_LEN]; /**< carrier id*/
-
- /* rsp */
- int cid; /**< data connection cid for mdm sdk*/
- int active; /**< pdn context active state: 2,actived; other,not active */
- char ifname[GSW_IFACE_NAME_MAX_LEN]; /**< if name of current datalink */
- int type; /**< data connection type*/
- V4_Addr_s v4; /**< ipv4 addr*/
- V6_Addr_s v6; /**< ipv6 addr*/
- int mtu; /**< mtu value*/
-
- char out[GSW_RSP_MAX_LEN]; /**< sdk return value*/
-}Link_Info_s;
-
-typedef struct
-{
- uint64_t tx_pkts; /* the number of packet sent*/
- uint64_t tx_bytes; /* the number of packet sent bytes */
- uint64_t tx_dropped_pkts; /* the number of packet dropped by sent*/
- uint64_t rx_pkts; /* the number of packet received*/
- uint64_t rx_bytes; /* the number of packet receivedbytes */
- uint64_t rx_dropped_pkts; /* the number of packet dropped by received*/
-}gsw_data_pkt_stats;
-
-
-typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState);
-
-/**
- * @brief datacall sdk init
- * @param [in] evt_cb callback function for data connection state change event
- * call back;
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb);
-
-
-/**
- * @brief data_call sdk deinit
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_deinit(void);
-
-/**
- * @brief set apn parameters for data call
- * @param [in/out] LinkInf apn info for pub or private datacall
- * inlcude apn name mcc mnc, passwork apnid type cid etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_set_apn(Link_Info_s *LinkInf);
-
-
-/**
- * @brief set apn parameters for data call
- * @param [in] linkid data connetion link number
- * @param [in/out] LinkInf link info req: apn info for pub or private datacall
- * inlcude apn name mcc mnc, passwork apnid etc
- * resp: data call link state ipaddress type etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf);
-
-
-/**
- * @brief set apn parameters for data call
- * @param [in] linkid
- * @param [in/out] LinkInf link info req: apn info for pub or private datacall
- * inlcude apn name mcc mnc, passwork apnid etc
- * resp: data call link state ipaddress type etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf);
-
-
-
-/*
- * @brief get mobile operator name
- @param [in] linkid apn id
- @param [out] data_pkt obtian actual data call network card data traffic
- @retval 0: success
- @retval 0: other: fail
- */
-int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt);
-
-
-
diff --git a/mbtk/include/gsw/gsw_hwpin_interface.h b/mbtk/include/gsw/gsw_hwpin_interface.h
new file mode 100644
index 0000000..cfceb4b
--- /dev/null
+++ b/mbtk/include/gsw/gsw_hwpin_interface.h
@@ -0,0 +1,184 @@
+/**
+* @file : gsw_hwpin_interface.h
+* @brief : Gpio and mcu ctrl
+* @date : 2022-07-05
+* @author : Wind
+* @version : v1.0
+* @copyright Copyright(C) 2022,Geely
+*/
+#ifndef __GSW_HW_PIN_INTERFACE__H__
+#define __GSW_HW_PIN_INTERFACE__H__
+#include "gsw_hal_errcode.h"
+#include <stdbool.h>
+
+#define GSW_HAL_USB_SUCCESS (0x0001)
+
+/**
+ * @brief hardware reset mcu only
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_mcu_reset(void);
+
+/**
+ * @brief hold mcu boot pin then reset to bootmode
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_mcu_enter_bootmode(void);
+
+/**
+ * @brief release mcu boot pin then reset to normalMode
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_mcu_exit_bootmode(void);
+
+/**
+ * @brief hardware reset soc and mcu
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_tcam_reset(void);
+
+/**
+ * @brief keep soc power
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_soc_power_keep(void);
+
+/**
+ * @brief release soc power
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_soc_power_release(void);
+
+/**
+ * @brief wakeup mcu through gpio
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_soc_wakeup_mcu(void);
+
+/**
+ * @brief soc wakeup mcu gpio output low
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_soc_wakeup_mcu_gpio_set_low(void);
+
+/**
+ * @brief get usb is connected or not
+ * @param
+ * @retval 1: connected
+ * @retval 0: disconnected
+ * @retval other: failed
+ */
+int gsw_hwpin_is_usb_connected(void);
+
+/**
+ * @brief set red led ON
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_led_red_on(void);
+
+/**
+ * @brief set red led OFF
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_led_red_off(void);
+
+/**
+ * @brief set red led blink
+ * @param [in] delay_on: on time ms
+ * @param [in] delay_off: off time ms
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_led_red_blink(int delay_on, int delay_off);
+
+/**
+ * @brief set green led ON
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_led_green_on(void);
+
+/**
+ * @brief set green led OFF
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_led_green_off(void);
+
+/**
+ * @brief set green led blink
+ * @param [in] delay_on: on time ms
+ * @param [in] delay_off: off time ms
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_led_green_blink(int delay_on, int delay_off);
+
+/**
+ * @brief Get health status of EMMC.
+ * @param [out] written_mbytes: Mega-Bytes have been written.
+ * @param [out] health: value of EMMC health.
+ * @retval 0: success
+ * @retval other: fail
+*/
+int gsw_hwpin_get_emmc_health(int* written_mbytes, int* health);
+
+/**
+ * @brief Get readonly status of EMMC.
+ * @param
+ * @retval true: readonly happened; false: normal
+ * @retval other: fail
+*/
+bool gsw_hwpin_check_emmc_readonly(void);
+
+/**
+ * @brief factory test control led
+ * @param [in] aging_flag: ture/false
+ * @param [in] delay_on: on time ms
+ * @param [in] delay_off: off time ms
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_hwpin_factorytest_ctrl_led(bool aging_flag, int delay_on, int delay_off);
+
+/**
+ * @brief MUTE test.
+ * @param [in] value: TRUE or FALSE.
+ * @retval 0: success
+ * @retval other: fail
+*/
+int gsw_hwpin_mute_test(int value);
+
+/**
+ * @brief fstrim emmc.
+ * @param [in] emmc_path: example "/media"
+ * @retval 0: success
+ * @retval other: fail
+*/
+
+int gsw_hwpin_fstrim_emmc(const char *emmc_path);
+
+
+#endif
diff --git a/mbtk/include/gsw/gsw_nw.h b/mbtk/include/gsw/gsw_nw.h
deleted file mode 100755
index 7399146..0000000
--- a/mbtk/include/gsw/gsw_nw.h
+++ /dev/null
@@ -1,762 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdio.h>
-
-//gsw include
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1
-#define GSW_HAL_MEM_INVAILD -2
-#define GSW_NW_OPERATION_NAME_LEN 128
-#define GSW_NW_PLMN_LEN 6
-#define GSW_NW_MCC_LEN 3
-#define GSW_NW_MNC_LEN 3
-#define GSW_NW_PARA_MAX_LEN 128
-#define GSW_MCC_MAX_LEN 16
-#define GSW_MNC_MAX_LEN 16
-#define GSW_APN_CHANNEL_MAX 10
-#define GSW_POXY_ADDR_MAX_LEN 64
-#define GSW_PDP_TYPE_MAX_LEN 16
-#define GSW_APN_MAX_LEN 65
-#define GSW_APN_ID_MAX_LEN 32
-#define GSW_APN_TYPE_MAX_LEN 50
-#define GSW_USR_MAX_LEN 16
-#define GSW_PWD_MAX_LEN 16
-#define GSW_AUTH_TYPE_MAX_LEN 50
-#define GSW_PROTOCO_MAX_LEN 64
-#define GSW_CARRIER_ID_MAX_LEN 64
-#define GSW_IFACE_NAME_MAX_LEN 50
-#define GSW_PDP_ADDR_MAX_LEN 64
-#define GSW_DNS_ADDR_MAX_LEN 64
-#define GSW_GETWAYS_ADDR_MAX_LEN 64
-#define GSW_RSP_MAX_LEN 256
-#define GSW_PLMN_LIST_MAX_LEN 64
-#define MAX_CELL_EXT_INFO (5)
-
-
-
-typedef enum service_domain
-{
- GSW_SRV_DOMAIN_NO_SVC = 0x0, /**< no service */
- GSW_SRV_DOMAIN_CS_ONLY = 0x1, /**< cs only */
- GSW_SRV_DOMAIN_PS_ONLY = 0x2, /**< ps only */
- GSW_SRV_DOMAIN_CS_PS = 0x3, /**< reg all in service */
-} GSW_SERVICE_DOMAIN_E;
-
-typedef enum gsw_network_reg_state
-{
- GSW_NETWORK_REG_NOT_REGISTERED = 0x0, /**< no service */
- GSW_NETWORK_REG_REGISTERED = 0x1, /**< reg in service home */
- GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING = 0x2, /**< searching network */
- GSW_NETWORK_REG_REGISTRATION_DENIED = 0x3, /**< network denny device */
- GSW_NETWORK_REG_REGISTRATION_UNKNOWN = 0x4, /**< unknown state */
- GSW_NETWORK_REG_REGISTRATION_ROAMING = 0x5, /**< roaming state in service */
- GSW_NETWORK_REG_LIMITED_SERVICE = 0x6, /**< limited service */
-} GSW_NW_REG_STATE_E;
-
-typedef enum gsw_network_radio_interface
-{
- GSW_NETWORK_RADIO_NO_SVC = 0x0, /**< radio state no service */
- GSW_NETWORK_RADIO_CDMA_1X = 0x1, /**< cdma 1x */
- GSW_NETWORK_RADIO_CDMA_1XEVDO = 0x2, /**< cdma evdo */
- GSW_NETWORK_RADIO_AMPS = 0x3, /**< amps gsm 2g*/
- GSW_NETWORK_RADIO_GSM = 0x4, /**< gsm */
- GSW_NETWORK_RADIO_UMTS = 0x5, /**< umts wcdma*/
- GSW_NETWORK_RADIO_LTE = 0x6, /**< LTE 4G */
- GSW_NETWORK_RADIO_TDSCDMA = 0x7, /**< TDS 3G*/
- GSW_NETWORK_RADIO_NR5G = 0x8, /**< NR 5G*/
-} GSW_NW_RADIO_ACCESS_TECH_E;
-
-
-typedef enum gsw_network_roaming_state
-{
- GSW_NETWORK_ROAMING_OFF = 0x0, /**< roaming off */
- GSW_NETWORK_ROAMING_ON = 0x1, /**< roaming on*/
-} GSW_NW_ROAMING_STATE_E;
-
-typedef enum oprate_mode
-{
- GSW_OP_MODE_LPM = 0, /**< radio state off*/
- GSW_OP_MODE_ONLINE = 1, /**< radio state on*/
- GSW_OP_MODE_FTM = 2, /**< radio state ftm*/
- GSW_OP_MODE_OFFLINE = 3, /**< radio state offline*/
-} OPERATE_MODE_E;
-
-typedef enum prefer_mode
-{
- GSW_PREFER_MODE_GSW = 1, /**<2G only*/
- GSW_PREFER_MODE_WCDMA = 2, /**< 3G only*/
- GSW_PREFER_MODE_WCDMA_GSM = 3, /**< 3G/2G*/
- GSW_PREFER_MODE_LTE = 4, /**< 4G only*/
- GSW_PREFER_MODE_NR5G = 5, /**< 5G only*/
- GSW_PREFER_MODE_NR5G_LTE = 8, /**< 5G/4G*/
- GSW_PREFER_MODE_LTE_WCDMA_GSM = 9, /**< 4G/3G/2G*/
- GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM = 32, /**< 5G/4G/3G/2G*/
-} PREFER_MODE_E;
-
-typedef enum gsw_hal_nw_mode_state_type
-{
- GSW_MODEM_STATE_UNKNOWN = 0,
- GSW_MODEM_STATE_ONLINE,
- GSW_MODEM_STATE_OFFLINE,
- GSW_SDK_STATE_SERVICE_DOWN,
- GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启
- GSW_SDK_STATE_GPS_DOWN,
- GSW_SDK_STATE_GPS_UP,
-} gsw_mode_state_e;
-
-
-typedef struct
-{
- GSW_NW_RADIO_ACCESS_TECH_E rej_rat; /**< current network radio tech*/
- GSW_SERVICE_DOMAIN_E rej_domain; /**< reject code from ps or cs*/
- int rej_cause; /**< reject code number*/
-} GSW_NW_REJ_CAUSE_E;
-
-typedef struct
-{
- int32_t gw_sig_valid; /**< 1 valid,1 invalid*/
- int32_t rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
- int32_t wcdma_sig_valid;/**< 1 valid,0 invalid*/
- int32_t rscp; /**< The Received Signal Code Power in dBm multipled by -1.
- * Range : 25 to 120
- * INT_MAX: 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 25.123, section 9.1.1.1 */
- int32_t ecno; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied
- * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
- * will be 125.*/
- int32_t lte_sig_valid;/**< 1 valid,0 invalid*/
- int32_t rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1.
- * Range: 44 to 140 dBm
- * INT_MAX: 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 36.133 9.1.4 */
- int32_t rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1.
- * Range: 20 to 3 dB.
- * INT_MAX: 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 36.133 9.1.7 */
- int32_t rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units.
- * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
- * INT_MAX : 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 36.101 8.1.1 */
- int32_t nr_sig_valid;/**<1 valid,0 invalid*/
- int32_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.*/
- int32_t ssRsrq; /**< SS reference signal received quality, multipled by -1.
- * Reference: 3GPP TS 38.215.
- * Range [3, 20], INT_MAX means invalid/unreported.*/
- int32_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.*/
- int32_t csiRsrp; /**< CSI reference signal received power, multipled by -1.
- * Reference: 3GPP TS 38.215.
- * Range [44, 140], INT_MAX means invalid/unreported.*/
- int32_t csiRsrq; /**< CSI reference signal received quality, multipled by -1.
- * Reference: 3GPP TS 38.215.
- * Range [3, 20], INT_MAX means invalid/unreported.*/
- int32_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.*/
-} signalStrength_t;
-
-typedef struct
-{
- GSW_NW_REG_STATE_E reg_state; /**< network cs regstate*/
- GSW_NW_REG_STATE_E ps_state; /**< network ps regstate*/
- GSW_NW_RADIO_ACCESS_TECH_E reg_rat; /**< current radio state*/
- GSW_SERVICE_DOMAIN_E srv_domain; /**< current cs or ps state*/
- GSW_NW_ROAMING_STATE_E roaming_ind; /**< roaming state*/
- char reg_plmn[GSW_NW_PLMN_LEN + 1]; /**< current cell plmn*/
- char operator_name[GSW_NW_OPERATION_NAME_LEN + 1]; /**< operator name*/
- char cell_id[128]; /**< cell id*/
- char tac[128]; /**< cell tac*/
- char lac[128]; /**< cell lac*/
- int sid; /**< cell sid cdma*/
- int nid; /**< cell nid cdma*/
-} GSW_NW_SERVING_INFO;
-
-
-typedef struct
-{
- char long_eons[128]; /* Full name of the operator*/
- char short_eons[128]; /* Shor name of the operator*/
- char mcc[4]; /* Mobile country code*/
- char mnc[4]; /* Mobile network code*/
-}gsw_mobile_operator_name;
-
-
-typedef struct
-{
- unsigned char cell_id_valid;
- unsigned char pci_valid;
- unsigned char psc_valid;
- unsigned char band_valid;
- unsigned char arfcn_valid;
- unsigned char rssi_valid;
- unsigned char rsrp_valid;
- unsigned char rsrq_valid;
- unsigned char sinr_valid;
- unsigned char rscp_valid;
- unsigned char ecio_valid;
- GSW_NW_RADIO_ACCESS_TECH_E rat;
- unsigned int cell_id;
- int pci;
- int psc;
- int band;
- int arfcn;
- int rssi;
- int rsrp;
- int rsrq;
- int sinr;
- int rscp;
- int ecio;
- char mcc[5];
- char mnc[5];
-} GSW_NW_CELL_EXT_INFO;
-
-typedef struct
-{
- GSW_NW_RADIO_ACCESS_TECH_E rat; /**< current radio state*/
-
- unsigned char mcc_valid;
- char mcc[5];
-
- unsigned char mnc_valid;
- char mnc[5];
-
- unsigned char cell_id_valid;
- unsigned int cell_id; /**< cell id*/
-
- unsigned char pci_valid;
- int pci; /**<physical cell id*/
-
- unsigned char psc_valid;
- int psc; /*wcdma primary scramble code*/
-
- unsigned char nrarfcn_valid;
- int nrarfcn; /*nr cell freq*/
-
- unsigned char earfcn_valid;
- int earfcn; /*lte cell freq*/
-
- unsigned char uarfcn_valid;
- int uarfcn; /*wcdma cell freq*/
-
- unsigned char arfcn_valid;
- int arfcn; /*gsw cell freq*/
-
- unsigned char tac_valid;
- unsigned int tac; /**< cell tac*/
-
- unsigned char lac_valid;
- unsigned int lac; /**< cell lac*/
-
- unsigned char sid_valid;
- int sid; /**< cell sid cdma*/
-
- unsigned char nid_valid;
- int nid; /**< cell nid cdma*/
-
- unsigned char lteMode_valid;
- int lteMode; /*tdd 0, fdd 1*/
-
- unsigned char rssi_valid;
- int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
-
- unsigned char rscp_valid;
- int rscp; /**< The Received Signal Code Power in dBm multipled by -1.
- * Range : 25 to 120
- * INT_MAX: 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 25.123, section 9.1.1.1 */
-
- unsigned char ecio_valid;
- int ecio; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied
- * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
- * will be 125.*/
-
- unsigned char rsrp_valid;
- int rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1.
- * Range: 44 to 140 dBm
- * INT_MAX: 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 36.133 9.1.4 */
-
- unsigned char rsrq_valid;
- int rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1.
- * Range: 20 to 3 dB.
- * INT_MAX: 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 36.133 9.1.7 */
-
- unsigned char rssnr_valid;
- int rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units.
- * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
- * INT_MAX : 0x7FFFFFFF denotes invalid value.
- * Reference: 3GPP TS 36.101 8.1.1 */
-
- unsigned char band_valid;
- int band;
-
- unsigned char bler_valid;
- int bler; /*bit error rate*/
-
- GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO]; /* Used to hold neighborhood information for service cells. */
-} GSW_NW_CELL_INFO;
-
-typedef struct {
- char mcc[GSW_MCC_MAX_LEN];
- char mnc[GSW_MNC_MAX_LEN];
-} gsw_nw_plmn_t;
-
-
-typedef struct {
- int plmn_list_len;
- gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN];
-} gsw_nw_plmn_list_t;
-
-typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info);
-typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info);
-typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause);
-typedef void (* GSW_NW_AirplaneModeHandlePtr)(int32_t airplane_mode);
-typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state);
-
-
-/*--------------------------------------------------------------------------------------------------------------------*/
-/* Data call */
-/*--------------------------------------------------------------------------------------------------------------------*/
-#define GSW_MCC_MAX_LEN 16
-#define GSW_MNC_MAX_LEN 16
-#define GSW_APN_CHANNEL_MAX 10
-#define GSW_POXY_ADDR_MAX_LEN 64
-#define GSW_PDP_TYPE_MAX_LEN 16
-#define GSW_APN_MAX_LEN 65
-#define GSW_APN_ID_MAX_LEN 32
-#define GSW_APN_TYPE_MAX_LEN 50
-#define GSW_USR_MAX_LEN 16
-#define GSW_PWD_MAX_LEN 16
-#define GSW_AUTH_TYPE_MAX_LEN 50
-#define GSW_PROTOCO_MAX_LEN 64
-#define GSW_CARRIER_ID_MAX_LEN 64
-#define GSW_IFACE_NAME_MAX_LEN 50
-#define GSW_PDP_ADDR_MAX_LEN 64
-#define GSW_DNS_ADDR_MAX_LEN 64
-#define GSW_GETWAYS_ADDR_MAX_LEN 64
-#define GSW_RSP_MAX_LEN 256
-
-typedef struct {
- int handle; /**< data connection handle*/
- int cid; /**< data connection cid*/
- int state; /**< data connection state*/
- int fail_cause; /**< data connection fail cause*/
- char *type; /**< data connection type*/
- char *ifname; /**< ifname*/
-
- char *v4_ip; /**< ipv4 address*/
- char *v4_pdns; /**< ipv4 pdns address*/
- char *v4_sdns; /**< ipv4 sdns address*/
- char *v4_gw; /**< ipv4 gateway address*/
-
- char *v6_ip; /**< ipv6 address*/
- char *v6_pdns; /**< ipv6 gateway address*/
- char *v6_sdns; /**< ipv6 gateway address*/
-}Wan_State_ind_s;
-
-typedef struct {
- char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address */
- char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/
- char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/
- char gw[GSW_GETWAYS_ADDR_MAX_LEN]; /**< gate way address*/
-}V4_Addr_s;
-
-typedef struct {
- char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address*/
- char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/
- char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/
-}V6_Addr_s;
-
-typedef struct {
- int handle; /**< data connection handle*/
-
- /* req info */
- char mcc[GSW_MCC_MAX_LEN]; /**< apn mcc value*/
- char mnc[GSW_MNC_MAX_LEN]; /**< apn mnc value*/
- char apnid[GSW_APN_ID_MAX_LEN]; /**< apn id*/
- char apn[GSW_APN_MAX_LEN]; /**< apn name*/
- char apnType[GSW_APN_TYPE_MAX_LEN]; /**< apn type ipv4 ipv4v6 ipv6*/
- char usr[GSW_USR_MAX_LEN]; /**< apn usr name*/
- char pwd[GSW_PWD_MAX_LEN]; /**< apn password*/
- char authType[GSW_AUTH_TYPE_MAX_LEN]; /**< apn auth type*/
- char normalProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco*/
- char roamingProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco roaming*/
- char carrier[GSW_CARRIER_ID_MAX_LEN]; /**< carrier id*/
-
- /* rsp */
- int cid; /**< data connection cid for mdm sdk*/
- int active; /**< pdn context active state: 2,actived; other,not active */
- char ifname[GSW_IFACE_NAME_MAX_LEN]; /**< if name of current datalink */
- int type; /**< data connection type*/
- V4_Addr_s v4; /**< ipv4 addr*/
- V6_Addr_s v6; /**< ipv6 addr*/
- int mtu; /**< mtu value*/
-
- char out[GSW_RSP_MAX_LEN]; /**< sdk return value*/
-}Link_Info_s;
-
-typedef struct
-{
- uint64_t tx_pkts; /* the number of packet sent*/
- uint64_t tx_bytes; /* the number of packet sent bytes */
- uint64_t tx_dropped_pkts; /* the number of packet dropped by sent*/
- uint64_t rx_pkts; /* the number of packet received*/
- uint64_t rx_bytes; /* the number of packet receivedbytes */
- uint64_t rx_dropped_pkts; /* the number of packet dropped by received*/
-}gsw_data_pkt_stats;
-
-
-typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState);
-
-
-/*--------------------------------------------------------------------------------------------------------------------*/
-/* sim */
-/*--------------------------------------------------------------------------------------------------------------------*/
-
-typedef enum sim_status
-{
- SIM_STATUS_ABSENT = 0, /**< sim absent*/
- SIM_STATUS_PRESENT = 1, /**< sim present mtk as ready*/
- SIM_STATUS_ERROR = 2, /**< sim error*/
- SIM_STATUS_READY = 3, /**< sim state ready mtk no this value*/
- SIM_STATUS_PIN = 4, /**< pinlock status*/
-} sim_status_e_type;
-
-
-
-/**
- * @brief SDK interface to call back serving info
- * @param [in] handle_ptr
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_reg_serving_info_callback(GSW_NW_ServingInfoHandlePtr handle_ptr);
-
-/**
- * @brief SDK interface to call back sig info
- * @param [in] handle_ptr
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_reg_sig_info_callback(GSW_NW_SigInfoHandlePtr handle_ptr);
-
-/**
- * @brief SDK interface to call back rej cause
- * @param [in] handle_ptr
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr);
-
-/**
- * @brief network sdk init
- * @param [in] token usr id define by who use
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_nw_sdk_init(int token);
-
-/**
- * @brief network sdk deinit
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_nw_sdk_deinit(void);
-
-/**
- * @brief get current network reg info
- * @param [out] serving_info struct for network info
- * include regstate ps_state opreator name mcc mcn etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_nwinfo(GSW_NW_SERVING_INFO *serving_info);
-
-/**
- * @brief get current network type
- * @param [out] netype as GSW_NW_RADIO_ACCESS_TECH_E type
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_netype(int32_t *netype);
-
-/**
- * @brief get radio opmode, as open and close airplane mode
- * @param [out] op_mode 1 is radio on, 0 is radio off
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_opmode(int *op_mode);
-
-/**
- * @brief set radio opmode, as open and close airplane mode
- * @param [in] op_mode 1 is radio on, 0 is radio off
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_opmode(int32_t op_mode);
-
-/**
- * @brief get network mode preference of mdm search network scale
- * @param [out] mode_pref net_work pref mode:
- * enum prefer_mode
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_mode_preference(int32_t *mode_pref);
-
-/**
- * @brief set network mode preference of mdm search network scale
- * @param [in] mode_pref net_work pref mode:
- * enum prefer_mode
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_mode_preference(int32_t mode_pref);
-
-/**
- * @brief get signal csq value
- * @param [out] csq_value csq of signalstrengh 0 - 31, 99 invalid
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sig_info(int32_t *csq_value);
-
-/**
- * @brief set nework power mode, for tcam enter standby or exit standby
- * @param [in] mode TRUE(1) when enter standby, FALSE(0) after wake up
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_network_set_power_mode(int8_t mode);
-
-/**
- * @brief convert rsrp rscp rssi to csq value.
- * @param [in] netType signal radio tech 2 means 2G 3 mens 3G,4 is 4G,5 is 5G
- * @param [in] sigvalue input signal_strength for different nettype
- * rsrp for 4G/5G, rscp for 3G, rssi for 2G
-
- * @retval csq
- * @retval other: fail
- */
-int gsw_sigInfo_to_csq(int32_t netType, int32_t sigValue);
-
-/*
- * @brief get PLMNs from the FPLMN list
- * @param [inout] plmn_list:
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
-
-/*
- * @brief add PLMNs from the plmn_list to the FPLMN list
- * @param [in] plmn_list:
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_add_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
-
-/*
- * @brief Remove PLMNs from the plmn_list from the FPLMN list
- * @param [in] plmn_list:
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_remove_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
-
-/*
- * @brief clear FPLMN list
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_clear_forbidden_networks(void);
-
-
-
-/*
- * @brief get mobile operator name
- @param [out] nw_operator_name_infos get the long and short operator name info
- @retval 0: success
- @retval 0: other: fail
- */
-int gsw_get_mobile_operator_name(gsw_mobile_operator_name *nw_operator_name_infos);
-
-
-
-/*
- * @brief set modem status event callback
- @param [in] handle_ptr callback function address
- @retval 0: success
- @retval 0: other: fail
- */
-int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr);
-
-
-/*
- * @brief get current serving cell info
- * @param cell_info: [out] struct for current cell info
- * include earfcn mcc mnc pci psc tac lac etc.
- * @return int: 0 is success, other failed
- */
-int gsw_get_cell_info(GSW_NW_CELL_INFO *cell_info);
-
-/**
- * @brief datacall sdk init
- * @param [in] evt_cb callback function for data connection state change event
- * call back;
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb);
-
-
-/**
- * @brief data_call sdk deinit
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_deinit(void);
-
-/**
- * @brief set apn parameters for data call
- * @param [in/out] LinkInf apn info for pub or private datacall
- * inlcude apn name mcc mnc, passwork apnid type cid etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_set_apn(Link_Info_s *LinkInf);
-
-
-/**
- * @brief set apn parameters for data call
- * @param [in] linkid data connetion link number
- * @param [in/out] LinkInf link info req: apn info for pub or private datacall
- * inlcude apn name mcc mnc, passwork apnid etc
- * resp: data call link state ipaddress type etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf);
-
-
-/**
- * @brief set apn parameters for data call
- * @param [in] linkid
- * @param [in/out] LinkInf link info req: apn info for pub or private datacall
- * inlcude apn name mcc mnc, passwork apnid etc
- * resp: data call link state ipaddress type etc
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf);
-
-
-
-/*
- * @brief get mobile operator name
- @param [in] linkid apn id
- @param [out] data_pkt obtian actual data call network card data traffic
- @retval 0: success
- @retval 0: other: fail
- */
-int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt);
-
-
-/**
- * @brief sim sdk init
- * @param [in] token usr id define by who use
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sim_sdk_init(int32_t token);
-
-
-/**
- * @brief sim sdk deinit
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sim_sdk_deinit(void);
-
-/**
- * @brief get sim state
- * @param [out] sim_state sim status as sim_status_e_type
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_status(int32_t *sim_state);
-
-/**
- * @brief get iccid function
- * @param [in] len iccid length,max is 20
- * @param [out] iccid return iccid from this func
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_iccid(int32_t len, int8_t *iccid);
-
-/**
- * @brief get imsi function
- * @param [in] len imsi length,max is 20
- * @param [out] iccid return imsi from this func
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_imsi(int32_t len, int8_t *imsi);
-
-/**
- * @brief get sim msisdn function
- * @param [in] len msisdn length,max is 20
- * @param [out] msisdn msisdn length,max is 20
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_msisdn(int32_t len, int8_t *msisdn);
-
-/**
- * @brief get imei function
- * @param [in] len imei length,max is 20
- * @param [out] imei return imei from this func
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_imei(int32_t len, int8_t *imei);
-
-/**
- * @brief set sim power down
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_sim_power_down(void);
-
-/**
- * @brief set sim power up
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_sim_power_up(void);
-
-/**
- * @brief reset modem stack only, notice: after use this method, all ril sdk
- * need restart by app, means network, sim, sms, data need deinit then init!
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_reset_modem(void);
-
-
-
diff --git a/mbtk/include/gsw/gsw_oem_rw_interface.h b/mbtk/include/gsw/gsw_oem_rw_interface.h
index 51aadcd..751da92 100755
--- a/mbtk/include/gsw/gsw_oem_rw_interface.h
+++ b/mbtk/include/gsw/gsw_oem_rw_interface.h
@@ -31,21 +31,20 @@
/**
* @brief Read data from spec block of flash
- * @param [in] unsigned int
+ * @param [in] unsigned int:block_id value range[1-5]
* @param [out] void *
- * @param [out] unsigned int *
- * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
- */
+ * @param [out] unsigned int *:len, it must be less than (256 * 1024 - 8)bytes
+ * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
+*/
int gsw_oem_read_data_ext(unsigned int block_id, void *data, unsigned int *len);
/**
* @brief Write data to spec block of flash
- * @param [in] unsigned int
+ * @param [in] unsigned int:block_id, value range[1-5]
* @param [in] void *
- * @param [in] unsigned int
+ * @param [in] unsigned int:len, it must be less than (256 * 1024 - 8)bytes
* @retval 0: success
* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
*/
int gsw_oem_write_data_ext(unsigned int block_id, void *data, unsigned int len);
#endif /*GSW_RTC_INTERFACE_H*/
-
diff --git a/mbtk/include/gsw/gsw_passwd.h b/mbtk/include/gsw/gsw_passwd.h
deleted file mode 100755
index c46e8b2..0000000
--- a/mbtk/include/gsw/gsw_passwd.h
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-#include <string.h>
-#include <stdio.h>
-
-
-int gsw_set_passwd(char *username, char *passwd);
diff --git a/mbtk/include/gsw/gsw_pm.h b/mbtk/include/gsw/gsw_pm.h
deleted file mode 100755
index 9ff11cc..0000000
--- a/mbtk/include/gsw/gsw_pm.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
-* @brief Modem wakeup callback
-* @param [in]int32_t wakeup_in
-* @retval void
-*/
-
-/* 0 -- Falling, Means wakeupin falling to wakeup the module, or wakeupout falling to wakeup mcu. */
-/* 1 -- Rising, Means wakeupin rising to wakeup the module, or wakeupout rising to wakeup mcu. */
-typedef void (*GSW_PM_WAKEUPCALLBACK)(int32_t wakeup_in);
-
-
-/**
-* @brief Enable autosleep
-* @param void
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_autosleep_enable(void);
-
-/**
-* @brief Disable autosleep
-* @param void
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_autosleep_disenable(void);
-
-/**
-* @brief Init power manager module
-* @param [in]GSW_PM_WAKEUPCALLBACKHandler wakeup_callback
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_pm_sdk_init(GSW_PM_WAKEUPCALLBACK wakeup_callback);
-
-
-
-/**
-* @brief Release wake lock, enter sleep
-* @param [in]int32_t wakeup_in
-* @retval int
-*/
-int32_t gsw_pm_enter_sleep(const char *gsw_wakelock_name);
-
-/**
-* @brief Creat wakeup lock
-* @param [in]int32_t wakeup_in
-* @retval int
-*/
-int32_t gsw_pm_exit_sleep(const char *gsw_wakelock_name);
-
-/**
-* @brief Module log disk drop, used when restarting or hibernating
-* @param [in]void
-* @retval void
-*/
-void gsw_modem_log_sync(void);
\ No newline at end of file
diff --git a/mbtk/include/gsw/gsw_pm_interface.h b/mbtk/include/gsw/gsw_pm_interface.h
new file mode 100755
index 0000000..0cd640a
--- /dev/null
+++ b/mbtk/include/gsw/gsw_pm_interface.h
@@ -0,0 +1,75 @@
+/**
+* @file : gsw_pm_interface.h
+* @brief : sleep and wakeup
+* @date :
+* @author : wind
+* @version : v1.0
+* @copyright
+*/
+#ifndef _GSW_PMYKSDK_H
+#define _GSW_PMYKSDK_H
+
+#include "gsw_hal_errcode.h"
+
+#define GSW_PM_SUCCESS GSW_HAL_SUCCESS
+#define GSW_PM_FAIL GSW_HAL_NORMAL_FAIL
+
+typedef enum
+{
+ GSW_PM_LPM_FALLING = 0, /**< falling edge,modem go to sleep*/
+ GSW_PM_LPM_RISING = 1, /**< rising edge,modem exit sleep*/
+}GSW_PM_WAKEUP_IN_STATUS_T;
+
+/**
+ * @brief when modem wakeup callback
+ * @param [in] int wakeup_in IO state, 0:sleep,1:exit sleep
+ * @retval 0: success
+ * @retval other: fail
+ */
+typedef void (* gsw_pm_wakeup_handler)(int);
+
+/**
+ * @brief lpm sdk init
+ * @param [in] gswPmCallBack modem wakeup callback
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gswPmSDKInit(gsw_pm_wakeup_handler gswPmCallBack);
+
+/**
+ * @brief enable system autosleep
+ * @details E02 and E06 unused
+ *
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gswAutoSleepEnable(void);
+
+/**
+ * @brief disable system autosleep
+ * @details E02 and E06 unused
+ *
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gswAutoSleepDisable(void);
+
+/**
+ * @brief release system sleeplock then canbe sleep
+ * @param
+ * @retval void
+ */
+void gswPMStartSleep(void);
+
+/**
+ * @brief keep system sleeplock to avoid sleep
+ * @param
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gswPMStopSleep(void);
+
+#endif
+
diff --git a/mbtk/include/gsw/gsw_sim.h b/mbtk/include/gsw/gsw_sim.h
deleted file mode 100755
index 5e19211..0000000
--- a/mbtk/include/gsw/gsw_sim.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdio.h>
-//gsw include
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1
-#define GSW_HAL_MEM_INVAILD -2
-#define GSW_SIM_ICCID_LENGTH 20+1
-#define GSW_SIM_IMSI_LENGTH 20+1
-#define GSW_SIM_MSISDN_LENGTH 20+1
-#define GSW_SIM_IMEI_LENGTH 20+1
-
-typedef enum sim_status
-{
- SIM_STATUS_ABSENT = 0, /**< sim absent*/
- SIM_STATUS_PRESENT = 1, /**< sim present mtk as ready*/
- SIM_STATUS_ERROR = 2, /**< sim error*/
- SIM_STATUS_READY = 3, /**< sim state ready mtk no this value*/
- SIM_STATUS_PIN = 4, /**< pinlock status*/
-} sim_status_e_type;
-
-
-
-/**
- * @brief sim sdk init
- * @param [in] token usr id define by who use
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sim_sdk_init(int32_t token);
-
-
-/**
- * @brief sim sdk deinit
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sim_sdk_deinit(void);
-
-/**
- * @brief get sim state
- * @param [out] sim_state sim status as sim_status_e_type
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_status(int32_t *sim_state);
-
-/**
- * @brief get iccid function
- * @param [in] len iccid length,max is 20
- * @param [out] iccid return iccid from this func
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_iccid(int32_t len, int8_t *iccid);
-
-/**
- * @brief get imsi function
- * @param [in] len imsi length,max is 20
- * @param [out] iccid return imsi from this func
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_imsi(int32_t len, int8_t *imsi);
-
-/**
- * @brief get sim msisdn function
- * @param [in] len msisdn length,max is 20
- * @param [out] msisdn msisdn length,max is 20
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_sim_msisdn(int32_t len, int8_t *msisdn);
-
-/**
- * @brief get imei function
- * @param [in] len imei length,max is 20
- * @param [out] imei return imei from this func
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_imei(int32_t len, int8_t *imei);
-
-/**
- * @brief set sim power down
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_sim_power_down(void);
-
-/**
- * @brief set sim power up
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_sim_power_up(void);
-
-/**
- * @brief reset modem stack only, notice: after use this method, all ril sdk
- * need restart by app, means network, sim, sms, data need deinit then init!
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_reset_modem(void);
-
diff --git a/mbtk/include/gsw/gsw_sms.h b/mbtk/include/gsw/gsw_sms.h
deleted file mode 100755
index c35fc7b..0000000
--- a/mbtk/include/gsw/gsw_sms.h
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdbool.h>
-
-#define GSW_HAL_SMS_ADDRESS_LEN 16
-#define GSW_HAL_SMS_RECV_CONT_MAX 1024
-#define GSW_HAL_SMS_CONTENT_LEN 1024
-
-
-// gsw include
-
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1
-#define GSW_HAL_MEM_INVAILD -2
-
-typedef enum gsw_hal_sms_state
-{
- GSW_SMS_FULL_FLG, /**< sms full flag*/
- GSW_SMS_RECEIVED_FLG, /**<recv new sms flag*/
-} gsw_hal_sms_state_e;
-
-typedef enum gsw_hal_sms_format
-{
- SMS_FORMAT_GSM_7BIT = 0, /**< 7bit econde*/
- SMS_FORMAT_BINARY_DATA = 1, /**< 8bit binary encode*/
- SMS_FORMAT_UCS2 = 2, /**< ucs2 encode*/
-} gsw_hal_sms_format_e;
-
-typedef struct gsw_hal_sms_date
-{
- uint8_t year[5]; /**< year of date*/
- uint8_t month[3]; /**< month of date*/
- uint8_t day[3]; /**< day of date*/
- uint8_t hour[3]; /**< hour of time*/
- uint8_t minutes[3]; /**< minute of time*/
- uint8_t seconds[3]; /**< second of time*/
- uint8_t timezone[4]; /**< timezone*/
-} gsw_hal_sms_date_s;
-
-typedef struct gsw_hal_sms_msg_type
-{
- int8_t src_num[GSW_HAL_SMS_ADDRESS_LEN+1]; /**< sms phone num send msg*/
- int8_t dest_num[GSW_HAL_SMS_ADDRESS_LEN + 1]; /**< sms phone num recv msg*/
- gsw_hal_sms_format_e content_encode; /**< sms content is 7bit or 8bit or Ucs2 encode*/
- uint32_t content_len; /**< sms content size*/
- int8_t content[GSW_HAL_SMS_RECV_CONT_MAX + 1]; /**< sms content*/
- gsw_hal_sms_date_s date; /**< message time*/
-} gsw_hal_sms_msg_type_s;
-
-typedef void (* GSW_HAL_SMS_CALLBACK_FUN)(gsw_hal_sms_state_e state, gsw_hal_sms_msg_type_s *report_info);
-
-/**
- * @brief SDK interface to call back sms messages
- * @param [in] handle_ptr
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sms_reg_callback(GSW_HAL_SMS_CALLBACK_FUN handle_ptr);
-
-/**
- * @brief sms sdk init
- * @param [in] token
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sms_sdk_init(int32_t token);
-
-/**
- * @brief sms sdk deinit
- * @param
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_sms_sdk_deinit(void);
-
-/**
- * @brief send sms fuction *
- * @param [in] phone_num dest phone num send sms
- * @param [in] char_set encode format for sms 0 7bit 1 binary 2 usc2
- * @param [in] msg sms content
- * @param [in] msg_len send sms length,max is 1024
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_send_sms(int8_t *phone_num, int32_t char_set, int8_t *msg, int32_t msg_len);
-
-/**
- * @brief get smsc fuction *
- * @param [in] len input buf len for smsc,max is 32
- * @param [out] smsc address for smsc get from this func *
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_get_smsc_address(int32_t len, int8_t *smsc);
-
-/**
- * @brief set smsc fuction
- * @param [out] smsc string value for smsc,max length is 32 *
- * @retval 0: success
- * @retval other: fail
- */
-int gsw_set_smsc_address(const int8_t *smsc);
\ No newline at end of file
diff --git a/mbtk/include/gsw/gsw_uart.h b/mbtk/include/gsw/gsw_uart.h
deleted file mode 100755
index 137b80f..0000000
--- a/mbtk/include/gsw/gsw_uart.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1 //表示失败(通用性)
-#define GSW_HAL_MEM_INVAILD -2 //表示入参地址为NULL
-
-
-typedef enum{
- GSW_HAL_BAUDRATE_1200=1200,
- GSW_HAL_BAUDRATE_1800=1800,
- GSW_HAL_BAUDRATE_4800=4800,
- GSW_HAL_BAUDRATE_9600=9600,
- GSW_HAL_BAUDRATE_19200=19200,
- GSW_HAL_BAUDRATE_38400=38400,
- GSW_HAL_BAUDRATE_57600=57600,
- GSW_HAL_BAUDRATE_115200=115200,
- GSW_HAL_BAUDRATE_230400=230400,
- GSW_HAL_BAUDRATE_460800=460800,
- GSW_HAL_BAUDRATE_500000=500000,
- GSW_HAL_BAUDRATE_576000=576000,
- GSW_HAL_BAUDRATE_921600=921600
-}gsw_hal_uart_baudrate;
-
-
-/**
-* @brief uart open
-* @param [in]int8_t *port
-* @param [in]gsw_hal_uart_baudrate baudrate
-* @param [in]uint32_t bits
-* @param [in]int8_t parity
-* @param [in]uint32_t stop
-* @retval int GSW_HAL_FAIL:fail other:success
-*/
-int32_t gsw_uart_open_ex(int8_t *port, gsw_hal_uart_baudrate baudrate, uint32_t bits, int8_t parity, uint32_t stop);
-
-/**
-* @brief uart flush
-* @param [in]int32_t fd
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_uart_flush(int32_t fd);
-
-/**
-* @brief uart close
-* @param [in]int32_t fd
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_uart_close(int32_t fd);
-
-/**
-* @brief uart write
-* @param [in]int32_t fd
-* @param [in]const uint8_t *buffer
-* @param [in]uint32_t len
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_uart_write(int32_t fd, const uint8_t *buffer, uint32_t len);
-
-/**
-* @brief uart read
-* @param [in]int32_t fd
-* @param [out]uint8_t *buffer
-* @param [in]uint32_t len
-* @param [in]int32_t timout_ms
-* @retval GSW_HAL_FAIL:fail 0~len:success
-*/
-int32_t gsw_uart_read(int32_t fd, uint8_t *buffer, uint32_t len, int32_t timeout_ms);
-
-/**
-* @brief uart ioctl
-* @param [in]int32_t fd
-* @param [in]uint32_t cmd
-* @param [in]void * pvalue
-* @retval GSW_HAL_FAIL:fail 0~len:success
-*/
-int32_t gsw_uart_ioctl(int32_t fd, uint32_t cmd, void *pvalue);
-
diff --git a/mbtk/include/gsw/gsw_uart_interface.h b/mbtk/include/gsw/gsw_uart_interface.h
new file mode 100755
index 0000000..037e8cc
--- /dev/null
+++ b/mbtk/include/gsw/gsw_uart_interface.h
@@ -0,0 +1,66 @@
+/**
+* @file : gsw_uart_interface.h
+* @brief : soc uart api
+* @date :
+* @author :
+* @version : v1.0
+* @copyright Copyright(C) 2022,Gosuncnwelink
+*/
+#ifndef __GSW_UART_INTERFACE__H__
+#define __GSW_UART_INTERFACE__H__
+#include "gsw_hal_errcode.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+/**
+ * @brief uart open
+ * @param [in] baudrate: baud rate of the UART frame
+ * @param [in] bits: bit of UART the frame
+ * @param [in] parity: parity of the UART frame
+ * @param [in] stop: stop bit of the UART frame
+ * @retval the UART handle
+ * @retval -1: fail
+ */
+int gsw_uart_open(unsigned int baudrate, unsigned int bits, char parity, unsigned int stop);
+
+/**
+ * @brief uart flush
+ * @param [in] fd: the gsw_uart_open return handle of UART
+ * @retval void
+ */
+void gsw_uart_flush(int fd);
+
+/**
+ * @brief uart close
+ * @param [in] fd: the gsw_uart_open return handle of UART
+ * @retval void
+ */
+void gsw_uart_close(int fd);
+
+/**
+ * @brief uart write
+ * @param [in] fd: the gsw_uart_open return handle of UART
+ * @param [in] buffer: the user send the data of UART
+ * @param [in] len: the user send the data length of UART
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_uart_write(int fd, const unsigned char *buffer, int len);
+
+/**
+ * @brief uart read
+ * @param [in] fd: the gsw_uart_open return handle of UART
+ * @param [out] buffer: the user read the data of UART
+ * @param [in] len: the user need read the data length of UART
+ * @param [in] timeout_ms: read data MAX timeout;ms
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_uart_read(int fd, unsigned char *buffer, int len,int timeout_ms);
+
+#if defined(__cplusplus)
+}
+#endif
+#endif
+
diff --git a/mbtk/include/gsw/gsw_usb.h b/mbtk/include/gsw/gsw_usb.h
deleted file mode 100755
index f125419..0000000
--- a/mbtk/include/gsw/gsw_usb.h
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-#include <string.h>
-#include <stdio.h>
-#include <stdbool.h>
-
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1 //表示失败
-
-
-typedef enum{
- EN_GSW_USB_SWITCH_CLOSE=0,
- EN_GSW_USB_SWITCH_OPEN,
- EN_GSW_USB_SWITCH_MAX,
-}EN_GSW_USB_SWITCH_TYPE;
-
-/**
-* @brief Power failure Save usb switch
-* @param [in] EN_GSW_USB_SWITCH_TYPE type:open or close type
-* @retval GSW_HAL_SUCCESS is success\other is fail
-*/
-int32_t gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type);
-
-/**
-* @brief usb switch is not saved after power failure
-* @param [in] EN_GSW_USB_SWITCH_TYPE type:open or close type
-* @retval GSW_HAL_SUCCESS is success\other is fail
-*/
-int32_t gsw_usb_tempporary_switch(EN_GSW_USB_SWITCH_TYPE type);
diff --git a/mbtk/include/gsw/gsw_usb_interface.h b/mbtk/include/gsw/gsw_usb_interface.h
new file mode 100755
index 0000000..e063fac
--- /dev/null
+++ b/mbtk/include/gsw/gsw_usb_interface.h
@@ -0,0 +1,44 @@
+/**
+* @file : gsw_usb_interface.h
+* @brief : sdk interface
+* @date : 2024-09-11
+* @author : liugang
+* @version : v1.0
+* @copyright Copyright(C) 2024,Gosuncnwelink
+*/
+#ifndef __GSW_USB_INTERFACE__H__
+#define __GSW_USB_INTERFACE__H__
+
+/*********************************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stddef.h>
+#include "gsw_hal_errcode.h"
+
+typedef enum
+{
+ EN_GSW_USB_SWITCH_CLOSE=0,
+ EN_GSW_USB_SWITCH_OPEN,
+ EN_GSW_USB_SWITCH_MAX
+}EN_GSW_USB_SWITCH_TYPE;
+
+/**
+ * @brief permanent switch usb
+ * @param [in] type switch status
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type);
+
+/**
+ * @brief temporary switch usb
+ * @param [in] type switch status
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_usb_temporary_switch(EN_GSW_USB_SWITCH_TYPE type);
+
+#endif //__GSW_USB_INTERFACE__H__
diff --git a/mbtk/include/gsw/gsw_voice.h b/mbtk/include/gsw/gsw_voice.h
deleted file mode 100755
index 78a659b..0000000
--- a/mbtk/include/gsw/gsw_voice.h
+++ /dev/null
@@ -1,128 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdio.h>
-
-// GSW includes
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1
-#define GSW_HAL_MEM_INVAILD -2
-
-
-typedef int CallHandle;
-typedef enum {
- GSW_VOICE_CALL_HOLDING = 0,
- GSW_VOICE_CALL_DIALING,
- GSW_VOICE_CALL_ALERTING,
- GSW_VOICE_CALL_CONNECTED,
- GSW_VOICE_CALL_INCOMING,
- GSW_VOICE_CALL_WAITING,
- GSW_VOICE_CALL_END,
-}VoiceCallState;
-
-typedef enum{
- GSW_AUDIO_MODE_CODEC = 0,
- GSW_AUDIO_MODE_RTP = 1,
-}AudioMode;
-
-typedef enum {
- GSW_RTP_CLIENT = 0,
- GSW_RTP_SERVER,
-}RTPMode;
-
-typedef void (*CallStateInd)(CallHandle, VoiceCallState);
-
-/**
-* @brief init voice sdk,and register the status indicated callback function
-* @param [in] CallStateInd ind: status indicated callback function
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_sdk_init(CallStateInd ind);
-
-
-/**
-* @brief set speaker_volume
-* @param [in] int32_t volume:1(Min)-7(Max)
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_set_speaker_volume(int32_t volume);
-
-/**
-* @brief start a voice call
-* @param [in] char *callNumber
-* @param [out] CallHandle *handle
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_normal_voice_start(CallHandle *handle, const char *callNumber);
-
-/**
-* @brief answer a voice call
-* @param [in] CallHandle handle
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_answer(CallHandle handle);
-
-/**
-* @brief hangup a voice call
-* @param [in] CallHandle handle
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_hangup(CallHandle handle);
-
-
-/**
-* @brief set auto answer mode
-* @param [in] int32_t mode:0-1, 0:NO(close auto answer), 1:YES(auto answer)
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_set_auto_answer_mode(int32_t mode);
-
-/**
-* @brief set audio mode
-* @param [in] AudioMode audioMode
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_set_audio_mode(AudioMode audioMode);
-
-/**
-* @brief set rtp ip address of remote
-* @param [in] char *ip :ip address
-* @param [in] int32_t len: length
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_set_remote_rtp_ip(const char *ip, int32_t len);
-
-/**
-* @brief set rtp mode and port
-* @param [in] RTPMode rtpMode: rtp mode
-* @param [in] int32_t port:rtp port
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_set_rtp_port(RTPMode rtpMode, int32_t port);
-
-/**
-* @brief set rtp mode and port
-* @param [in] int32_t clockRate: clock rate
-* @param [in] int32_t channel:channel
-* @param [in] int32_t latency:latency
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_set_rtp_param(int32_t clockRate, int32_t channel, int32_t latency);
-
-/**
-* @brief get current call end reason
-* @param [in] CallHandle handle
-* @param [out] None
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
-*/
-int32_t gsw_voice_get_current_call_end_reason(CallHandle handle);
diff --git a/mbtk/include/gsw/gsw_voice_interface.h b/mbtk/include/gsw/gsw_voice_interface.h
new file mode 100755
index 0000000..4ba5b30
--- /dev/null
+++ b/mbtk/include/gsw/gsw_voice_interface.h
@@ -0,0 +1,246 @@
+/**
+* @file : gsw_voice_interface.h
+* @brief : voice mic and rtp
+* @date : 2022-06-29
+* @author :
+* @version : v1.0
+* @copyright copyright Copyright (c) 2022 www.gosuncn.com
+*/
+#ifndef GSW_VOICE_INTERFACE_H
+#define GSW_VOICE_INTERFACE_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "gsw_hal_errcode.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define INVALID_CALL_HANDLE (-1)
+#define GSW_VOICE_SUCCESS GSW_HAL_SUCCESS
+#define GSW_VOICE_ERROR GSW_HAL_NORMAL_FAIL
+#define ERR_FAILED GSW_HAL_NORMAL_FAIL
+#define ERR_SUCCESS GSW_HAL_SUCCESS
+
+#define GSW_VOICE_MAX_SPEAKER_VOLUME (7)
+#define GSW_VOICE_MIN_SPEAKER_VOLUME (1)
+#define GSW_VOICE_MAX_MIC_VOLUME (7)
+#define GSW_VOICE_MIN_MIC_VOLUME (1)
+
+typedef int CallHandle;
+
+typedef enum {
+ GSW_VOICE_CALL_HOLDING = 0, /**< holding */
+ GSW_VOICE_CALL_DIALING, /**< dialing */
+ GSW_VOICE_CALL_ALERTING, /**< alerting */
+ GSW_VOICE_CALL_CONNECTED, /**< connected */
+ GSW_VOICE_CALL_INCOMING, /**< incoming */
+ GSW_VOICE_CALL_WAITING, /**< waiting */
+ GSW_VOICE_CALL_END, /**< call end */
+} VoiceCallState;
+
+typedef enum {
+ GSW_AUDIO_MODE_CODEC = 0, /**< Codec */
+ GSW_AUDIO_MODE_RTP = 1, /**< RTP */
+} AudioMode;
+
+typedef enum {
+ GSW_RTP_CLIENT = 0, /**< rtp client */
+ GSW_RTP_SERVER, /**< rtp server */
+} RTPMode;
+
+typedef void (*CallStateInd)(CallHandle, VoiceCallState);
+
+/**
+ * @brief voice sdk init function
+ * @param [in] ind callback function to handle new voice call state
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_sdk_init(CallStateInd ind);
+
+/**
+ * @brief voice sdk deinit function
+ * @retval 0: success
+ * @retval other: fail
+ */
+void gsw_voice_sdk_deinit(void);
+
+/**
+ * @brief normal voice start
+ * @param [in] handle
+ * @param [in] callNumber
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_normal_voice_start(CallHandle *handle, const char *callNumber);
+
+/**
+ * @brief hangup voice
+ * @param [in] handle
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_hangup(CallHandle handle);
+
+/**
+ * @brief answer voice
+ * @param [in] handle
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_answer(CallHandle handle);
+
+/**
+ * @brief auto answer mode
+ * @param [in] mode: ture/false
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_auto_answer_mode(int32_t mode);
+
+/**
+ * @brief get current call state
+ * @param [in] handle
+ * @param [in] state
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_current_call_state(CallHandle handle, VoiceCallState *state);
+
+/**
+ * @brief get speaker volume
+ * @param [out] volume: 0 ~ 7
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_speaker_volume(int32_t *volume);
+
+/**
+ * @brief set speaker volume
+ * @param [in] volume: 0 ~ 7
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_speaker_volume(int32_t volume);
+
+/**
+ * @brief set mic volume
+ * @param [out] volume: 0 ~ 7
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_mic_volume(int32_t *volume);
+
+/**
+ * @brief set mic volume
+ * @param [in] volume: 0 ~ 7
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_mic_volume(int32_t volume);
+
+/**
+ * @brief set audio mode.
+ * @details mode change from GSW_AUDIO_MODE_RTP to GSW_AUDIO_MODE_CODEC, should close RTP immediately and change to codec mode.
+ * change from GSW_AUDIO_MODE_CODEC to GSW_AUDIO_MODE_RTP, should close codec immediately and change to RTP mode.
+ *
+ * @param [in] audioMode
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_audio_mode(AudioMode audioMode);
+
+/**
+ * @brief get audio mode
+ * @param [out] audioMode
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_audio_mode(AudioMode *audioMode);
+
+/**
+ * @brief set rtp ip
+ * @param [in] ip rtp ip
+ * @param [in] len rtp ip length
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_remote_rtp_ip(const char *ip, int32_t len);
+
+/**
+ * @brief get rtp ip
+ * @param [out] ip rtp ip
+ * @param [out] len rtp ip length
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_remote_rtp_ip(char *ip, int32_t len);
+
+/**
+ * @brief set rtp port
+ * @param [in] RTPMode rtp mode
+ * @param [in] port rtp port
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_rtp_port(RTPMode rtpMode, int32_t port);
+
+/**
+ * @brief get rtp port
+ * @param [out] RTPMode rtp mode
+ * @param [out] port rtp port
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_rtp_port(RTPMode rtpMode, int32_t *port);
+
+/**
+ * @brief set rtp port
+ * @param [in] clockRate rtp clock rate
+ * @param [in] channel rtp channel
+ * @param [in] latency rtp latency
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_rtp_param(int32_t clockRate, int32_t channel, int32_t latency);
+
+/**
+ * @brief get rtp param
+ * @param [out] clockRate rtp clock rate
+ * @param [out] channel rtp channel
+ * @param [out] latency rtp latency
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_rtp_param(int32_t *clockRate, int32_t *channel, int32_t *latency);
+
+/**
+ * @brief set rtp vlan
+ * @param [in] interfaceName network interface name
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_set_rtp_vlan_info(const char *interfaceName);
+
+/**
+ * @brief get rtp vlan
+ * @param [out] interfaceName network interface name
+ * @param [out] len network interface name length
+ * @retval 0: success
+ * @retval other: fail
+ */
+int32_t gsw_voice_get_rtp_vlan_info(char *interfaceName, uint32_t len);
+
+/**
+ * @brief get current call end reason
+ * @param [in] handle
+ * @retval call_end_reason
+ */
+int32_t gsw_voice_get_current_call_end_reason(CallHandle handle);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* GSW_VOICE_INTERFACE_H */
diff --git a/mbtk/libgsw_lib/gsw_at.c b/mbtk/libgsw_lib/gsw_at_interface.c
similarity index 96%
rename from mbtk/libgsw_lib/gsw_at.c
rename to mbtk/libgsw_lib/gsw_at_interface.c
index 6fe12e9..2f48b47 100755
--- a/mbtk/libgsw_lib/gsw_at.c
+++ b/mbtk/libgsw_lib/gsw_at_interface.c
@@ -13,8 +13,7 @@
#include <stdint.h>
#include <dlfcn.h>
#include <stdbool.h>
-#include "gsw_at.h"
-
+#include "gsw_at_interface.h"
#ifndef LOG_ERR_LEVEL
#define LOG_ERR_LEVEL 3 /* error conditions */
#endif
@@ -104,8 +103,6 @@
} while(0)
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1 //表示失败(通用性)
#define GSW_HAL_MEM_INVAILD -2 //表示入参地址为NULL
#define OUT_MAX_SIZE 1024
@@ -132,7 +129,7 @@
char buffer_at[OUT_MAX_SIZE] = {0};
struct sockaddr_in addr_serv;
struct sockaddr_un addr_server;
-AT_CALLBACK tmp = NULL;
+LYNQ_AT_CALLBACK tmp = NULL;
static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
socklen_t len;
bool connect_state = false;
@@ -312,17 +309,17 @@
* @param callback Type:[IN]
* @return int
*/
-int32_t gsw_reg_atcmd(const char *atcmd,AT_CALLBACK func)
+int32_t gsw_reg_atcmd(const char *atcmd,LYNQ_AT_CALLBACK func)
{
if(NULL == atcmd || NULL == func)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
dlHandle_at = dlopen(lynqLib_at, RTLD_NOW);
fun_ptr_log = (mbtk_log)dlsym(dlHandle_at, "mbtk_log");
if(fun_ptr_log == NULL || dlHandle_at == NULL)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
memcpy(buffer_at, atcmd, strlen(atcmd));
tmp = func;
@@ -332,7 +329,7 @@
if(ret != 0)
{
LOGE("lynq_connect_service_start start failed\n");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
LOGD("lynq_connect_service_start success ret:%d\n",ret);
return GSW_HAL_SUCCESS;
diff --git a/mbtk/libgsw_lib/gsw_gpio.c b/mbtk/libgsw_lib/gsw_hwpin_interface.c
similarity index 89%
rename from mbtk/libgsw_lib/gsw_gpio.c
rename to mbtk/libgsw_lib/gsw_hwpin_interface.c
index 231ddd3..9837b97 100755
--- a/mbtk/libgsw_lib/gsw_gpio.c
+++ b/mbtk/libgsw_lib/gsw_hwpin_interface.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <dlfcn.h>
-#include "gsw_gpio.h"
+#include "gsw_hwpin_interface.h"
#ifndef LOG_ERR_LEVEL
#define LOG_ERR_LEVEL 3 /* error conditions */
@@ -98,12 +98,29 @@
} while(0)
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1 //表示失败(通用性)
#define GSW_HAL_MEM_INVAILD -2 //表示入参地址为NULL
-
#define wakeout 117
+typedef enum{
+ GSW_HAL_PINDIR_IN,
+ GSW_HAL_PINDIR_OUT,
+}gsw_hal_pinDirection;
+
+typedef enum{
+ GSW_HAL_LEVEL_LOW,
+ GSW_HAL_LEVEL_HIGH,
+}gsw_hal_pinLevel;
+
+typedef enum{
+ GSW_HAL_PULL_NULL,
+ GSW_HAL_PULL_DOWN,
+ GSW_HAL_PULL_UP,
+}gsw_hal_pinPullSel;
+
+typedef enum{
+ GSW_HAL_USB_DISCONNECTED,
+ GSW_HAL_USB_CONNECTED,
+}gsw_hal_usbStatus;
typedef void (*mbtk_log)(int level, const char *format,...);
static mbtk_log fun_ptr_log = NULL;
void *dlHandle_gpio = NULL;
@@ -125,7 +142,7 @@
fun_ptr_log = (mbtk_log)dlsym(dlHandle_gpio, "mbtk_log");
if(fun_ptr_log == NULL || dlHandle_gpio == NULL)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
}
return GSW_HAL_SUCCESS;
@@ -204,7 +221,7 @@
char direction[10] = {0};
memset(buffer,0,128);
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (gpio_check(gpioNum) == -1)
{
@@ -231,7 +248,7 @@
LOGE("Set gpio[%d] direct fail.", gpioNum);
close(file);
gpio_unexport(gpioNum);
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
close(file);
gpio_unexport(gpioNum);
@@ -247,7 +264,7 @@
memset(path,0,128);
memset(buffer,0,50);
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (gpio_check(gpioNum) == -1)
{
@@ -267,7 +284,7 @@
LOGE("Get gpio[%d] value fail", gpioNum);
close(file);
gpio_unexport(gpioNum);
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
close(file);
gpio_unexport(gpioNum);
@@ -281,7 +298,7 @@
int result =-1;
memset(buffer,0,50);
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (gpio_check(gpioNum) == -1)
{
@@ -306,7 +323,7 @@
LOGE("Set gpio[%d] value fail err =%d.", gpioNum, errno);
close(file);
gpio_unexport(gpioNum);
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
close(file);
gpio_unexport(gpioNum);
@@ -317,7 +334,7 @@
int32_t gsw_gpio_Init(uint32_t gpioNum, gsw_hal_pinDirection dir, gsw_hal_pinLevel level, gsw_hal_pinPullSel pullsel)
{
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (dir != 1 && dir != 0)
{
@@ -328,29 +345,29 @@
if (level != 1 && level != 0)
{
LOGE("[lynq_gpio_init] value fail.");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
if(gpio_export(gpioNum))
{
LOGE("[lynq_gpio_init]gpio_export fail.");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
if(gsw_gpio_SetDirection(gpioNum, dir))
{
LOGE("[lynq_gpio_init]gpio_direct_set fail.");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
if(dir == 1 && (gsw_gpio_SetLevel(gpioNum, level) != 0))
{
LOGE("[lynq_gpio_init]gpio_value_set fail.");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
return GSW_HAL_SUCCESS;
}
-gsw_hal_usbStatus gsw_hwpin_is_usb_connected(void)
+int gsw_hwpin_is_usb_connected(void)
{
FILE *fp;
char cmd[128] = {0};
@@ -358,7 +375,7 @@
//char *CONNECTED = "configured";
char *DISCONNECTED = "not attached";
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
sprintf(cmd,"cat /sys/devices/platform/soc/d4200000.axi/c0000000.usb/udc/c0000000.usb/state");
fp=popen(cmd, "r");
@@ -373,9 +390,9 @@
int32_t gsw_setWakeupLevel(gsw_hal_pinLevel level)
{
- if (gsw_gpio_SetLevel(wakeout, level) == GSW_HAL_FAIL)
+ if (gsw_gpio_SetLevel(wakeout, level) == GSW_HAL_NORMAL_FAIL)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
return GSW_HAL_SUCCESS;
}
diff --git a/mbtk/libgsw_lib/gsw_pm.c b/mbtk/libgsw_lib/gsw_pm_interface.c
similarity index 88%
rename from mbtk/libgsw_lib/gsw_pm.c
rename to mbtk/libgsw_lib/gsw_pm_interface.c
index 9a28e71..25acf7a 100755
--- a/mbtk/libgsw_lib/gsw_pm.c
+++ b/mbtk/libgsw_lib/gsw_pm_interface.c
@@ -13,7 +13,7 @@
#include <sys/ioctl.h>
#include <dlfcn.h>
#include <stdint.h>
-#include "gsw_pm.h"
+#include "gsw_pm_interface.h"
#ifndef LOG_ERR_LEVEL
#define LOG_ERR_LEVEL 3 /* error conditions */
@@ -104,11 +104,10 @@
} while(0)
-#define GSW_HAL_SUCCESS 0
-#define GSW_HAL_FAIL -1 //表示失败(通用性)
+
#define GSW_HAL_MEM_INVAILD -2 //表示入参地址为NULL
#define LOCK_MAX_SIZE 129
-
+typedef void (*GSW_PM_WAKEUPCALLBACK)(int32_t wakeup_in);
typedef void (*mbtk_lpm_handler_t)(int32_t wakeup_in);
typedef void (*mbtk_log)(int level, const char *format,...);
@@ -135,7 +134,7 @@
/**
* @brief Enable autosleep
* @param void
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
+* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
*/
static int handle()
@@ -146,7 +145,7 @@
fun_ptr_log = (mbtk_log)dlsym(dlHandle_sleep, "mbtk_log");
if(fun_ptr_log == NULL || dlHandle_sleep == NULL)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
}
return GSW_HAL_SUCCESS;
@@ -156,7 +155,7 @@
{
int ret;
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
mbtk_autosuspend_enable=(int(*)(char))dlsym(dlHandle_sleep, "mbtk_autosuspend_enable");
ret = mbtk_autosuspend_enable(1);
if(ret < 0)
@@ -164,7 +163,7 @@
LOGE("mbtk_autosuspend_enable FAIL.\n");
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
@@ -174,13 +173,13 @@
/**
* @brief Disable autosleep
* @param void
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
+* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
*/
int32_t gsw_autosleep_disenable(void)
{
int ret;
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
mbtk_autosuspend_enable=(int(*)(char))dlsym(dlHandle_sleep, "mbtk_autosuspend_enable");
ret = mbtk_autosuspend_enable(0);
if(ret < 0)
@@ -188,7 +187,7 @@
LOGE("mbtk_autosuspend_enable FAIL.\n");
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
@@ -198,13 +197,13 @@
/**
* @brief Init power manager module
* @param [in]GSW_PM_WAKEUPCALLBACKHandler wakeup_callback
-* @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL
+* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
*/
int32_t gsw_pm_sdk_init(GSW_PM_WAKEUPCALLBACK wakeup_callback)
{
int ret;
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
mbtk_lpm_init=(int(*)(mbtk_lpm_handler_t))dlsym(dlHandle_sleep, "mbtk_lpm_init");
ret = mbtk_lpm_init((mbtk_lpm_handler_t)wakeup_callback);
if(ret < 0)
@@ -212,7 +211,7 @@
LOGE("mbtk_lpm_init FAIL.\n");
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
return GSW_HAL_SUCCESS;
}
@@ -227,9 +226,9 @@
int ret;
int i;
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (gsw_wakelock_name == NULL)
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
for(i=0 ;i<LOCK_MAX_SIZE;i++)
{
if(lock_name[i].name != NULL && strcmp(lock_name[i].name, gsw_wakelock_name) == 0)
@@ -241,7 +240,7 @@
if (i >= LOCK_MAX_SIZE)
{
LOGE("mbtk_wakelock_lock not create.\n");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
mbtk_wakelock_unlock=(int(*)(int))dlsym(dlHandle_sleep, "mbtk_wakelock_unlock");
@@ -251,7 +250,7 @@
LOGE("mbtk_wakelock_unlock FAIL.\n");
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
mbtk_wakelock_destroy=(int(*)(int))dlsym(dlHandle_sleep, "mbtk_wakelock_destroy");
@@ -261,7 +260,7 @@
LOGE("mbtk_wakelock_destroy FAIL.\n");
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
if (lock_name[i].name != NULL)
{
@@ -285,17 +284,16 @@
int ret;
int i;
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (gsw_wakelock_name == NULL)
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
mbtk_wakelock_create=(int(*)(const char* name , size_t))dlsym(dlHandle_sleep, "mbtk_wakelock_create");
lock_fd = mbtk_wakelock_create(gsw_wakelock_name, strlen(gsw_wakelock_name));
if(lock_fd < 0)
{
LOGE("mbtk_wakelock_create FAIL.\n");
- dlclose(dlHandle_sleep);
- dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ ret = GSW_HAL_NORMAL_FAIL;
+ goto end;
}
mbtk_wakelock_lock=(int(*)(int))dlsym(dlHandle_sleep, "mbtk_wakelock_lock");
@@ -303,27 +301,34 @@
if(ret < 0)
{
LOGE("mbtk_wakelock_lock FAIL.\n");
- dlclose(dlHandle_sleep);
- dlHandle_sleep = NULL;
- return GSW_HAL_FAIL;
+ ret = GSW_HAL_NORMAL_FAIL;
+ goto end;
}
for(i=0 ;i<LOCK_MAX_SIZE;i++)
{
if(lock_name[i].name == NULL)
break;
}
+ if(i == LOCK_MAX_SIZE)
+ {
+ LOGE("mbtk_wakelock_lock not space FAIL.\n");
+ ret = GSW_HAL_NORMAL_FAIL;
+ goto end;
+ }
lock_name[i].name = malloc(strlen(gsw_wakelock_name)+1);
if (lock_name[i].name == NULL)
{
LOGE("mbtk_wakelock_lock remeber FAIL.\n");
- return GSW_HAL_FAIL;
+ ret = GSW_HAL_NORMAL_FAIL;
+ goto end;
}
memcpy(lock_name[i].name, gsw_wakelock_name, strlen(gsw_wakelock_name)+1);
lock_name[i].fd = lock_fd;
-
+ ret = GSW_HAL_SUCCESS;
+end:
dlclose(dlHandle_sleep);
dlHandle_sleep = NULL;
- return GSW_HAL_SUCCESS;
+ return ret;
}
/**
diff --git a/mbtk/libgsw_lib/gsw_uart.c b/mbtk/libgsw_lib/gsw_uart_interface.c
similarity index 82%
rename from mbtk/libgsw_lib/gsw_uart.c
rename to mbtk/libgsw_lib/gsw_uart_interface.c
index 718ca47..0544d16 100755
--- a/mbtk/libgsw_lib/gsw_uart.c
+++ b/mbtk/libgsw_lib/gsw_uart_interface.c
@@ -11,7 +11,7 @@
#include <sys/ioctl.h>
#include <dlfcn.h>
-#include "gsw_uart.h"
+#include "gsw_uart_interface.h"
#ifndef LOG_ERR_LEVEL
#define LOG_ERR_LEVEL 3 /* error conditions */
@@ -107,6 +107,23 @@
void *dlHandle_uart = NULL;
char *lynqLib_uart = "/lib/libmbtk_lib.so";
+typedef enum
+{
+ GSW_HAL_BAUDRATE_1200=1200,
+ GSW_HAL_BAUDRATE_1800=1800,
+ GSW_HAL_BAUDRATE_4800=4800,
+ GSW_HAL_BAUDRATE_9600=9600,
+ GSW_HAL_BAUDRATE_19200=19200,
+ GSW_HAL_BAUDRATE_38400=38400,
+ GSW_HAL_BAUDRATE_57600=57600,
+ GSW_HAL_BAUDRATE_115200=115200,
+ GSW_HAL_BAUDRATE_230400=230400,
+ GSW_HAL_BAUDRATE_460800=460800,
+ GSW_HAL_BAUDRATE_500000=500000,
+ GSW_HAL_BAUDRATE_576000=576000,
+ GSW_HAL_BAUDRATE_921600=921600
+}gsw_hal_uart_baudrate;
+
static int handle()
{
if(dlHandle_uart == NULL || fun_ptr_log == NULL)
@@ -115,7 +132,7 @@
fun_ptr_log = (mbtk_log)dlsym(dlHandle_uart, "mbtk_log");
if(fun_ptr_log == NULL || dlHandle_uart == NULL)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
}
return GSW_HAL_SUCCESS;
@@ -127,7 +144,7 @@
int32_t gsw_uart_open_ex(int8_t *port, gsw_hal_uart_baudrate baudrate, uint32_t bits, int8_t parity, uint32_t stop)
{
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
int fd = -1;
if((fd = open((const char *)port, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0)
{
@@ -230,19 +247,19 @@
switch(bits)
{
- case CS5:
+ case 5:
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag |= CS5;
break;
- case CS6:
+ case 6:
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag |= CS6;
break;
- case CS7:
+ case 7:
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag |= CS7;
break;
- case CS8:
+ case 8:
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag |= CS8;
break;
@@ -259,15 +276,18 @@
switch (parity)
{
- case '1':// 奇校验
+ case 'O':
+ case 'o':// 奇校验
newtio.c_cflag |= PARENB;
newtio.c_cflag |= PARODD;
break;
- case '2':// 偶校验
+ case 'E':
+ case 'e':// 偶校验
newtio.c_cflag |= PARENB;
newtio.c_cflag &= ~PARODD;
break;
- case '0':// 无奇偶校验
+ case 'N':
+ case 'n':// 无奇偶校验
newtio.c_cflag &= ~PARENB;
break;
default:
@@ -283,25 +303,33 @@
return fd;
}
-int32_t gsw_uart_flush(int32_t fd)
+void gsw_uart_flush(int fd)
{
if (tcflush(fd, TCIOFLUSH) < 0)
{
- return GSW_HAL_FAIL;
+ LOGE("flush fail\n");
+ //return GSW_HAL_NORMAL_FAIL;
}
- return GSW_HAL_SUCCESS;
+ else
+ LOGD("flush success\n");
+ //return GSW_HAL_SUCCESS;
}
-int32_t gsw_uart_read(int32_t fd, uint8_t *buffer, uint32_t len, int32_t timeout_ms)
+int gsw_uart_read(int fd, unsigned char *buffer, int len, int timeout_ms)
{
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
+ if(len <= 0 || timeout_ms < -1)
+ {
+ LOGE("timeout_ms = %d, len = %d; timeout_ms needs to be greater than -1 and len needs to be greater than 0!\n",timeout_ms, len);
+ return GSW_HAL_NORMAL_FAIL;
+ }
int flags = fcntl(fd, F_GETFL); // 获取当前状态标志
if (flags == -1)
{
perror("fcntl get");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
struct termios newtio;
@@ -316,12 +344,12 @@
newtio.c_cc[VMIN] = 0;
newtio.c_cc[VTIME] = 0;
}
- else if (timeout_ms == 1)
+ else if (timeout_ms == -1)
{
flags &= ~O_NONBLOCK; // 清除非阻塞标志
fcntl(fd, F_SETFL, flags);
newtio.c_cc[VMIN] = 1;
- newtio.c_cc[VTIME] = timeout_ms/100;
+ newtio.c_cc[VTIME] = 0;
}
else
{
@@ -344,18 +372,18 @@
if(errno == EAGAIN || errno == EWOULDBLOCK)
return 0;
else
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
return data_len;
}
-int32_t gsw_uart_write(int32_t fd, const uint8_t *buffer, uint32_t len)
+int gsw_uart_write(int fd, const unsigned char *buffer, int len)
{
//gsw_uart_flush(fd);
if (write(fd, buffer, len) < 0)
{
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
return GSW_HAL_SUCCESS;
}
@@ -363,16 +391,16 @@
int32_t gsw_uart_ioctl(int32_t fd, uint32_t cmd, void *pvalue)
{
if (handle())
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
if (fd < 0 || pvalue == NULL)
{
LOGE("Invalid file descriptor");
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
if (ioctl(fd, cmd, pvalue) < 0)
{
LOGE("Could not set DCB,error:%d, %s\n",errno, strerror(errno));
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
}
return GSW_HAL_SUCCESS;
}
@@ -380,12 +408,25 @@
-int32_t gsw_uart_close(int32_t fd)
+void gsw_uart_close(int fd)
{
if (fd <= 0)
- return GSW_HAL_FAIL;
- //gsw_uart_flush(fd);
- close(fd);
- return GSW_HAL_SUCCESS;
+ LOGE("fd = %d fail\n",fd);
+ //return GSW_HAL_NORMAL_FAIL;
+ else
+ {
+ //gsw_uart_flush(fd);
+ int ret = close(fd);
+ if(ret < 0)
+ {
+ LOGE("close fail ret = %d\n",ret);
+ }
+ else
+ {
+ LOGI("close success ret = %d\n",ret);
+ }
+ }
+
+ //return GSW_HAL_SUCCESS;
}
diff --git a/mbtk/libgsw_lib/gsw_voice.c b/mbtk/libgsw_lib/gsw_voice.c
index c6e5ac3..454c722 100755
--- a/mbtk/libgsw_lib/gsw_voice.c
+++ b/mbtk/libgsw_lib/gsw_voice.c
@@ -1,4 +1,4 @@
-#include "gsw/gsw_voice.h"
+#include "gsw_voice_interface.h"
#include <dlfcn.h>
#include <pthread.h>
diff --git a/mbtk/libgsw_lib/libgsw_passwd.c b/mbtk/libgsw_lib/libgsw_passwd.c
index ef3fdda..90c95d9 100755
--- a/mbtk/libgsw_lib/libgsw_passwd.c
+++ b/mbtk/libgsw_lib/libgsw_passwd.c
@@ -11,10 +11,6 @@
#include <sys/ioctl.h>
#include <dlfcn.h>
-
-#include "gsw_passwd.h"
-
-
int gsw_set_passwd(char *username, char *passwd)
{
int ret;
diff --git a/mbtk/libgsw_lib/libgsw_usb.c b/mbtk/libgsw_lib/libgsw_usb_interface.c
similarity index 78%
rename from mbtk/libgsw_lib/libgsw_usb.c
rename to mbtk/libgsw_lib/libgsw_usb_interface.c
index 400fcb2..1b912bd 100755
--- a/mbtk/libgsw_lib/libgsw_usb.c
+++ b/mbtk/libgsw_lib/libgsw_usb_interface.c
@@ -12,29 +12,29 @@
#include <dlfcn.h>
-#include "gsw_usb.h"
+#include "gsw_usb_interface.h"
#define TMP_USB_RESTART "/sbin/tmp_usb_init"
#define USB_OPEN 3300
#define USB_CLOSE 3329
-int32_t gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type)
+int gsw_usb_permanent_switch(EN_GSW_USB_SWITCH_TYPE type)
{
int ret;
char cmd[256];
if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
sprintf(cmd, "setprop persist.mbtk.usb_pid %d && %s %d &", type?USB_OPEN:USB_CLOSE, TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
ret = system(cmd);
return ret;
}
-int32_t gsw_usb_tempporary_switch(EN_GSW_USB_SWITCH_TYPE type)
+int gsw_usb_tempporary_switch(EN_GSW_USB_SWITCH_TYPE type)
{
int ret;
char cmd[256];
if(type != EN_GSW_USB_SWITCH_OPEN && type != EN_GSW_USB_SWITCH_CLOSE)
- return GSW_HAL_FAIL;
+ return GSW_HAL_NORMAL_FAIL;
sprintf(cmd, "%s %d &", TMP_USB_RESTART, type?USB_OPEN:USB_CLOSE);
ret = system(cmd);
return ret;