修改API框架,兼容1806
Change-Id: Ic68e966a32e4c7ffd7137b3d7ba94e4d813c71b2
diff --git a/config b/config
new file mode 100755
index 0000000..f11605c
--- /dev/null
+++ b/config
@@ -0,0 +1,7 @@
+
+# Custom AF support?
+CONFIG_AT_SUPPORT=n
+
+# MBTK gnss mode (gnss_5311 / gnss_6228)
+CONFIG_MBTK_GNSS_MODE=gnss_5311
+
diff --git a/mbtk/Make.defines b/mbtk/Make.defines
index fbd4cd1..9c17fde 100755
--- a/mbtk/Make.defines
+++ b/mbtk/Make.defines
@@ -95,11 +95,21 @@
endif
endif
endif
-
endif
-# Only for AF custom.
-# DEFINE += -DMBTK_AF_SUPPORT
+MBTK_AT_SUPPORT=$(shell cat $(ROOT)/config | grep CONFIG_AT_SUPPORT | cut -d '=' -f 2)
+$(info MBTK_AT_SUPPORT=$(MBTK_AT_SUPPORT))
+ifeq ($(MBTK_AT_SUPPORT), y)
+DEFINE += -DMBTK_AF_SUPPORT
+endif
+
+MBTK_GNSS_MODE=$(shell cat $(ROOT)/config | grep CONFIG_MBTK_GNSS_MODE | cut -d '=' -f 2)
+$(info MBTK_GNSS_MODE=$(MBTK_GNSS_MODE))
+ifeq ($(MBTK_GNSS_MODE), gnss_6228)
+DEFINE += -DMBTK_GNSS_6228
+else
+DEFINE += -DMBTK_GNSS_5311
+endif
LIB_DIR = \
-L$(OUT_DIR)/lib
diff --git a/mbtk/Makefile b/mbtk/Makefile
index d6ed12d..d8d1d7d 100755
--- a/mbtk/Makefile
+++ b/mbtk/Makefile
@@ -1,7 +1,13 @@
ROOT = $(shell pwd)/..
include Make.defines
-DIRS = mbtk_lib mbtk_mqtt lynq_lib ql_lib mbtk_adbd mbtk_logd mbtk_ril test
+DIRS = mbtk_lib mbtk_mqtt lynq_lib ql_lib qser_lib mbtk_adbd mbtk_logd mbtk_ril
+
+ifeq ($(BUILD_PLATFORM), asr1806)
+DIRS += mbtk_audio_lib
+endif
+
+DIRS += test
all:
@echo $(ROOT)
diff --git a/mbtk/include/lynq/lynq_audio_api.h b/mbtk/include/lynq/lynq_audio_api.h
index 6e709dc..44a3278 100755
--- a/mbtk/include/lynq/lynq_audio_api.h
+++ b/mbtk/include/lynq/lynq_audio_api.h
@@ -5,7 +5,9 @@
*/
#ifndef _LYNQ_AUDIO_API_H
#define _LYNQ_AUDIO_API_H
+#ifdef MBTK_PLATFORM_ASR1803
#include "mbtk_audio.h"
+#endif
//播放音频文件
int lynq_media_play_audio(const char *path);
@@ -32,10 +34,11 @@
//设置麦克风音量
int lynq_set_mic_volume(const int volume);
-
+#ifdef MBTK_PLATFORM_ASR1803
int lynq_audio_ubus_client_init(mbtk_audio_client_handle_type *ph_audio, mbtk_dtmf_cb cb);
int lynq_audio_ubus_client_deinit(mbtk_audio_client_handle_type h_audio);
+#endif
#endif /* _LYNQ_AUDIO_API_H */
diff --git a/mbtk/include/lynq/lynq_call_api.h b/mbtk/include/lynq/lynq_call_api.h
index bdb9ffe..889875f 100755
--- a/mbtk/include/lynq/lynq_call_api.h
+++ b/mbtk/include/lynq/lynq_call_api.h
@@ -3,7 +3,10 @@
* Data : 2022/11/07 16:57:28
* Author : HanZhiyu
*/
+
+#ifdef MBTK_PLATFORM_ASR1803
#include "mbtk_audio.h"
+#endif
typedef enum {
LYNQ_CALL_FAIL_UNOBTAINABLE_NUMBER = 1,
diff --git a/mbtk/include/mbtk/mbtk_alarm.h b/mbtk/include/mbtk/mbtk_alarm.h
new file mode 100755
index 0000000..346a0b9
--- /dev/null
+++ b/mbtk/include/mbtk/mbtk_alarm.h
@@ -0,0 +1,43 @@
+/*
+* mbtk_alarm.h
+* MBTK alarm API.
+*
+* Author : lb
+* Date : 2023/11/17 16:20:43
+*/
+#ifndef _MBTK_ALARM_H
+#define _MBTK_ALARM_H
+
+
+/*===========================================================================
+FUNCTION mbtk_wakealarm_set()
+
+DESCRIPTION:
+ Set sleep wake alarm.
+
+PARAMETERS:
+ time_sec [IN]: Sleep wake-up time in second.
+
+RETURN VALUE:
+ int : Return 0 if success, other for failures.
+
+===========================================================================*/
+int mbtk_wakealarm_set(unsigned long time_sec);
+
+/*===========================================================================
+FUNCTION mbtk_poweralarm_set()
+
+DESCRIPTION:
+ Set shutdown alarm clock.
+
+PARAMETERS:
+ time_sec [IN]: Shutdown wake-up time in second.
+
+RETURN VALUE:
+ int : Return 0 if success, other for failures.
+
+===========================================================================*/
+int mbtk_poweralarm_set(unsigned long time_sec);
+
+
+#endif /* _MBTK_ALARM_H */
diff --git a/mbtk/include/mbtk/mbtk_fs.h b/mbtk/include/mbtk/mbtk_fs.h
deleted file mode 100755
index bc6079e..0000000
--- a/mbtk/include/mbtk/mbtk_fs.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/*************************************************************
- Description:
- MBTK FS Protocol Head File.
- Author:
- LiuBin
- Date:
- 2020/10/28 11:49:19
- *************************************************************/
-#ifndef _MBTK_FS_H
-#define _MBTK_FS_H
-
-#include "mbtk_file.h"
-
-/*************************************************************
- Constants and Macros
- *************************************************************/
-
-#define MBTK_FS_MAX 255
-#define BUFFERSIZE 4096
-
-#define FS_DATA_LEN 4096
-#define FS_NAME_LEN 128
-
-#define SENDBUFF 1024
-
-
-#if 0
-#include <sys/types.h>
-#include <sys/stat.h>
-
-struct stat
-{
- dev_t st_dev; /* ID of device containing file -文件所在设备的ID*/
- ino_t st_ino; /* inode number -inode节点号*/
- mode_t st_mode; /* protection -保护模式?*/
- nlink_t st_nlink; /* number of hard links -链向此文件的连接数(硬连接)*/
- uid_t st_uid; /* user ID of owner -user id*/
- gid_t st_gid; /* group ID of owner - group id*/
- dev_t st_rdev; /* device ID (if special file) -设备号,针对设备文件*/
- off_t st_size; /* total size, in bytes -文件大小,字节为单位*/
- blksize_t st_blksize; /* blocksize for filesystem I/O -系统块的大小*/
- blkcnt_t st_blocks; /* number of blocks allocated -文件所占块数*/
- time_t st_atime; /* time of last access -最近存取时间*/
- time_t st_mtime; /* time of last modification -最近修改时间*/
- time_t st_ctime; /* time of last status change - */
-};
-
-S_ISLNK(st_mode) // 是否是一个连接.
-S_ISREG(st_mode) // 是否是一个常规文件.
-S_ISDIR(st_mode) // 是否是一个目录
-S_ISCHR(st_mode) // 是否是一个字符设备.
-S_ISBLK(st_mode) // 是否是一个块设备
-S_ISFIFO(st_mode) // 是否是一个FIFO文件.
-S_ISSOCK(st_mode) // 是否是一个SOCKET文件
-
-
-S_IFMT 0170000 文件类型的位遮罩
-S_IFSOCK 0140000 scoket
-S_IFLNK 0120000 符号连接
-S_IFREG 0100000 一般文件
-S_IFBLK 0060000 区块装置
-S_IFDIR 0040000 目录
-S_IFCHR 0020000 字符装置
-S_IFIFO 0010000 先进先出
-
-S_ISUID 04000 文件的(set user-id on execution)位
-S_ISGID 02000 文件的(set group-id on execution)位
-S_ISVTX 01000 文件的sticky位
-
-S_IRUSR(S_IREAD) 00400 文件所有者具可读取权限
-S_IWUSR(S_IWRITE)00200 文件所有者具可写入权限
-S_IXUSR(S_IEXEC) 00100 文件所有者具可执行权限
-
-S_IRGRP 00040 用户组具可读取权限
-S_IWGRP 00020 用户组具可写入权限
-S_IXGRP 00010 用户组具可执行权限
-
-S_IROTH 00004 其他用户具可读取权限
-S_IWOTH 00002 其他用户具可写入权限
-S_IXOTH 00001 其他用户具可执行权限
-
-struct statfs{
- long f_type; //文件系统的类型
- long f_bsize; //经优化后的传输块的大小
- long f_blocks; //文件系统数据块总数
- long f_bfree; //可用块数
- long f_bavail; //普通用户能够获得的块数
- long f_files; //文件结点总数
- long f_ffree; //可用文件结点数
- fisd_t f_fsid; //文件系统标识
- long f_namelen; //文件名的最大长度
-}
-
-int statfs(const char *path, struct statfs *buf);
-int fstatfs(int fd, struct statfs *buf);
-
-#endif
-
-//NVM dev lib mnt proc root sys usr www
-//bin etc log overlay rom sbin tmp var fs(新创建目录给用户操作使用)
-
-//默认所有的目录
-#define DFF_DIR_NVM "/NVM"
-#define DFF_DIR_BIN "/bin"
-#define DFF_DIR_DEV "/dev"
-#define DFF_DIR_ETC "/etc"
-#define DFF_DIR_LIB "/lib"
-#define DFF_DIR_LOG "/log"
-#define DFF_DIR_MNT "/mnt"
-#define DFF_DIR_OVERLAY "/overlay"
-#define DFF_DIR_PROC "/proc"
-#define DFF_DIR_ROM "/rom"
-#define DFF_DIR_ROOT "/root"
-#define DFF_DIR_SBIN "/sbin"
-#define DFF_DIR_SYS "/sys"
-#define DFF_DIR_TMP "/tmp"
-#define DFF_DIR_USR "/usr"
-#define DFF_DIR_VAR "/var"
-#define DFF_DIR_WWW "/www"
-
-#define PART_FS_OERLAY "/overlay"
-#define PART_FS "/fs"
-#define PART_FS_ "/fs/"
-#define ROOT_PATH "/"
-
-/*
- //SSL certificate
- 0 - ca.crt
- 1 - client.crt
- 2 - client.key
- //TTS certificate
- 3 - yt31739_63708_info.dat
- 4 - yt32987_62709_info.dat
-*/
-#define FS_CERT_0 "/ca.crt"
-#define FS_CERT_1 "/client.crt"
-#define FS_CERT_2 "/client.key"
-#define FS_CERT_3 "/yt31739_63708_info.dat"
-#define FS_CERT_4 "/yt32987_62709_info.dat"
-
-/*************************************************************
- Definitions:enum,struct,union,class
- *************************************************************/
-typedef enum
-{
- FS_CMD_CONN,
- FS_CMD_LIST, // List Dir and File in current directory.
- FS_CMD_DLST, // List Dir in current directory.
- FS_CMD_FLST, // List File in current directory.
- FS_CMD_PWD, // Get current directory.
- FS_CMD_CWD, // Set current directory.
- FS_CMD_MKD, // Create directory.
- FS_CMD_RMD, // Remove directory.
- FS_CMD_CD, // Go this directory.
- FS_CMD_CREATFILE, // Creat File.
- FS_CMD_SIZE, // Get file size.
- FS_CMD_DELE, // Delete file.
- FS_CMD_RENAME, // Renaming
- FS_CMD_RFILE,
- FS_CMD_WFILE,
- FS_CMD_MEMORY,
- FS_CMD_QUIT
-} mbtk_fs_cmd_enum;
-
-typedef enum
-{
- FS_ERR_NONE = 0,
- FS_ERR_NFNAE = 1,//1 - NEW FILE NAME ALREADY EXIST
- FS_ERR_SFNE = 2,//2 - SOURCE FILE NOT EXIST
- FS_ERR_DBE = 3,//3 - DIRECTORY NOT EXIST
- FS_ERR_IPN = 4,//4 - INVALID PATH NAME
- FS_ERR_IFN = 5,//5 - INVALID FILE NAME
- FS_ERR_EHNEM = 6,//6 - EFS HAVE NO ENOUGH MEMORY
- FS_ERR_FCE = 7,//7 - FILE CREATE ERROR
- FS_ERR_RFE = 8,//8 - READ FILE ERROR
- FS_ERR_WFE = 9,//9 - WRITE FILE ERROR
-} mbtk_fs_err_code;
-
-typedef int mbtk_fs_handle;
-typedef void (*mbtk_fs_data_cb_func)(void *data, uint32 data_len);
-
-typedef struct {
- char *fs_data;
- int fs_data_size;
- char fs_data_name[FS_NAME_LEN];
- int fs_data_mode;
-}mbtk_fs_data_info_t;
-
-
-typedef struct {
- char *fs_data;
- int fs_data_size;
- char fs_data_name[FS_NAME_LEN];
-}mbtk_fs_data_file_t;
-
-typedef struct {
- char *fs_data;
- int fs_data_size;
- int fs_data_certmode;
-}mbtk_fs_data_certmode_t;
-
-
-typedef enum
-{
- fs_type_dir_file = 0,
- fs_type_dir,
- fs_type_file
-} mbtk_fs_type_enum;
-
-typedef struct
-{
- uint8 modify_time[20];
- mbtk_fs_data_cb_func data_cb;
- bool is_download;
- int size_count;
- int size_send;
-} mbtk_fs_file_trans_info_s;
-
-
-typedef struct mbtk_fs_dir_info
-{
- uint8 name[MBTK_FS_MAX + 1];
- bool is_file;
- uint32 size; // Directory is 0
-
- struct mbtk_fs_dir_info *next;
- void (*fs_ls_cb_typedef)(void *file_list_cb);
-} mbtk_fs_dir_file_info_s;
-
-
-typedef struct
-{
- int dir_num;
- int file_num;
- int all_dir_file;
- mbtk_fs_type_enum at_fs_type;
-} mbtk_at_fs_init_parameter;
-
-mbtk_at_fs_init_parameter mbtk_at_fs_par={0};
-
-
-/*************************************************************
- Extern variables
- *************************************************************/
-
-
-/*************************************************************
- Public Function Declaration
- *************************************************************/
-static int fs_cmd_process_mkd(char *path);
-static int fs_cmd_process_cd(char *path);
-static int fs_cmd_process_rename(char *old_path, char *new_path);
-static int fs_cmd_process_copy(char *old_path, char *new_path, int mode);
-static int fs_cmd_process_memory(uint64 *total, uint64 *available);
-static int fs_cmd_process_delfile(char *path);
-static int fs_cmd_process_creatfile(char *path);
-static int fs_cmd_process_loadfile(char *path);
-static int fs_cmd_process_list_all(char *path,mbtk_fs_dir_file_info_s *fs_dir_and_file_list);
-static int fs_cmd_process_list_dir(char *path,mbtk_fs_dir_file_info_s *fs_dir_list);
-static int fs_cmd_process_list_file(char *path,mbtk_fs_dir_file_info_s *fs_file_list);
-
-
-
-#endif /* _MBTK_FS_H */
-
diff --git a/mbtk/include/mbtk/mbtk_gnss.h b/mbtk/include/mbtk/mbtk_gnss_6228.h
similarity index 100%
rename from mbtk/include/mbtk/mbtk_gnss.h
rename to mbtk/include/mbtk/mbtk_gnss_6228.h
diff --git a/mbtk/include/qser/qser_adc.h b/mbtk/include/qser/qser_adc.h
new file mode 100755
index 0000000..faa1cf3
--- /dev/null
+++ b/mbtk/include/qser/qser_adc.h
@@ -0,0 +1,24 @@
+/*
+* qser_adc.h
+*
+* QSER adc header file.
+*
+* Author : lb
+* Date : 2023/11/23 11:03:26
+*/
+#ifndef _QSER_ADC_H
+#define _QSER_ADC_H
+#include "mbtk_type.h"
+
+typedef enum ADC_CHANNEL
+{
+ QADC_NONE = 0, //标志位 0 正常模式
+ ADC0 = 1, //指定 ADC0 通道
+ ADC1 = 2, //指定 ADC1 通道
+ ADC2 = 3, //指定 ADC2 通道
+ QADC_END //枚举结束标志
+} ADC_CHANNEL_E;
+
+int qser_adc_show(ADC_CHANNEL_E qadc);
+
+#endif /* _QSER_ADC_H */
diff --git a/mbtk/include/qser/qser_alarm.h b/mbtk/include/qser/qser_alarm.h
new file mode 100755
index 0000000..1df314a
--- /dev/null
+++ b/mbtk/include/qser/qser_alarm.h
@@ -0,0 +1,23 @@
+/*
+* qser_alarm.h
+*
+* QSER alarm header.
+*
+* Author : lb
+* Date : 2023/11/23 10:45:44
+*/
+#ifndef _QSER_ALARM_H
+#define _QSER_ALARM_H
+#include "mbtk_type.h"
+
+int lynq_set_wakealarm(unsigned long time_sec);
+
+int lynq_set_poweralarm(unsigned long time_sec);
+
+ssize_t wakealarm(char *buffer);
+
+ssize_t poweralarm(char *buffer);
+
+int cancel_wakealarm(void);
+
+#endif /* _QSER_ALARM_H */
diff --git a/mbtk/include/qser/qser_audio.h b/mbtk/include/qser/qser_audio.h
new file mode 100755
index 0000000..8bad8e2
--- /dev/null
+++ b/mbtk/include/qser/qser_audio.h
@@ -0,0 +1,41 @@
+/*
+* qser_audio.h
+*
+* QSER audio header file.
+*
+* Author : lb
+* Date : 2023/11/23 10:52:01
+*/
+#ifndef _QSER_AUDIO_H
+#define _QSER_AUDIO_H
+#include "mbtk_type.h"
+
+typedef void (*_cb_onPlayer)(int);
+
+int qser_AudPlayer_Open(char* device, _cb_onPlayer cb_fun);
+
+int qser_AudPlayer_PlayFrmFile(int hdl, const char *fd, int offset);
+
+int qser_AudPlayer_Pause(int hdl);
+
+int qser_AudPlayer_Resume(int hdl);
+
+void qser_AudPlayer_Stop(int hdl);
+
+void qser_AudPlayer_Close(int hdl);
+
+int qser_AudRecorder_Open(char* device, _cb_onPlayer cb_fun);
+
+int qser_AudRecorder_StartRecord(int hdl, const char *fd, int offset);
+
+int qser_AudRecorder_Pause(void);
+
+int qser_AudRecorder_Resume(void);
+
+void qser_AudRecorder_Stop(void);
+
+void qser_AudRecorder_Close(void);
+
+void qser_Audio_Deinit(void);
+
+#endif /* _QSER_AUDIO_H */
diff --git a/mbtk/include/qser/qser_data_call.h b/mbtk/include/qser/qser_data_call.h
new file mode 100755
index 0000000..fbeddad
--- /dev/null
+++ b/mbtk/include/qser/qser_data_call.h
@@ -0,0 +1,121 @@
+/*
+* qser_data_call.h
+*
+* QSER data call header file.
+*
+* Author : lb
+* Date : 2023/11/23 13:32:37
+*/
+#ifndef _QSER_DATA_CALL_H
+#define _QSER_DATA_CALL_H
+#include "mbtk_type.h"
+
+#define QSER_APN_MAX_LIST 8
+#define QSER_APN_NAME_SIZE 150
+#define QSER_APN_USERNAME_SIZE 127
+#define QSER_APN_PASSWORD_SIZE 127
+
+typedef enum {
+ QSER_DATA_CALL_ERROR_NONE = 0,
+ QSER_DATA_CALL_ERROR_INVALID_PARAMS,
+} qser_data_call_error_e;
+
+typedef enum {
+ QSER_DATA_CALL_TYPE_IPV4 = 0, /*!< IPv4 call. */
+ QSER_DATA_CALL_TYPE_IPV6, /*!< IPv6 call. */
+ QSER_DATA_CALL_TYPE_IPV4V6, /*!< IPv4 and IPv6 call (Only used call start or stop). */
+} qser_data_call_ip_family_e;
+
+typedef enum {
+ QSER_APN_PDP_TYPE_IPV4 = 0,
+ QSER_APN_PDP_TYPE_PPP,
+ QSER_APN_PDP_TYPE_IPV6,
+ QSER_APN_PDP_TYPE_IPV4V6,
+} qser_apn_pdp_type_e;
+
+typedef enum {
+ QSER_APN_AUTH_PROTO_DEFAULT = 0,
+ QSER_APN_AUTH_PROTO_NONE,
+ QSER_APN_AUTH_PROTO_PAP,
+ QSER_APN_AUTH_PROTO_CHAP,
+ QSER_APN_AUTH_PROTO_PAP_CHAP,
+} qser_apn_auth_proto_e;
+
+typedef struct {
+ char profile_idx; /*!< UMTS/CMDA profile ID. */
+ bool reconnect; /*!< Whether to re-dial after disconnecting the network.*/
+ qser_data_call_ip_family_e ip_family; /*!< IP version. */
+ char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
+ char cdma_password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
+} qser_data_call_s;
+
+struct v4_info {
+ char name[16]; /*!< Interface Name. */
+ qser_data_call_state_e state; /*!< The dial status. */
+ bool reconnect; /*!< re-dial flag. */
+ struct v4_address_status addr; /*!< IPv4 IP Address information. */
+ struct pkt_stats stats; /*!< IPv4 statics */
+};
+
+struct v6_info {
+ char name[16]; /*!< Interface Name. */
+ qser_data_call_state_e state; /*!< The dial status. */
+ bool reconnect; /*!< re-dial flag. */
+ struct v6_address_status addr; /*!< IPv6 IP Address information. */
+ struct pkt_stats stats; /*!< IPv6 statics */
+};
+
+typedef struct {
+ char profile_idx; /*!< UMTS/CDMA profile ID. */
+ qser_data_call_ip_family_e ip_family; /*!< IP version. */
+ struct v4_info v4; /*!< IPv4 information */
+ struct v6_info v6; /*!< IPv6 information */
+} qser_data_call_info_s;
+
+typedef struct {
+ unsigned char profile_idx; /*!< UMTS/CDMA profile ID. */
+ qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload exchanged over the airlink when the packet data session is established with this profile. */
+ qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
+ char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN and external packet data network. */
+ char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
+ char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
+ char apn_type[QSER_APN_NAME_SIZE]; /*The primary key of the apn table, cannot insert two apn information with the same apn_type*/
+} qser_apn_info_s;
+
+typedef struct {
+ qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload exchanged over the airlink when the packet data session is established with this profile. */
+ qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
+ char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN and external packet data network. */
+ char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
+ char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
+ char apn_type[QSER_APN_NAME_SIZE]; /*The primary key of the apn table, cannot insert two apn information with the same apn_type*/
+} qser_apn_add_s;
+
+typedef struct {
+ int cnt; /*apn[] 数组中有效 apn 的数目 */
+ qser_apn_info_s apn[QSER_APN_MAX_LIST];
+} qser_apn_info_list_s;
+
+typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state);
+
+int qser_data_call_init(qser_data_call_evt_cb_t evt_cb);
+
+void qser_data_call_destroy(void);
+
+int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err);
+
+int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err);
+
+int qser_data_call_info_get(char profile_idx,qser_data_call_ip_family_e ip_family,qser_data_call_info_s *info,qser_data_call_error_e *err);
+
+int qser_apn_set(qser_apn_info_s *apn);
+
+int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn);
+
+int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx);
+
+int qser_apn_del(unsigned char profile_idx);
+
+int qser_apn_get_list(qser_apn_info_list_s *apn_list);
+
+#endif /* _QSER_DATA_CALL_H */
diff --git a/mbtk/include/qser/qser_fota.h b/mbtk/include/qser/qser_fota.h
new file mode 100755
index 0000000..7425d21
--- /dev/null
+++ b/mbtk/include/qser/qser_fota.h
@@ -0,0 +1,22 @@
+/*
+* qser_fota.h
+*
+* QSER Fota header file.
+*
+* Author : lb
+* Date : 2023/11/23 11:09:33
+*/
+#ifndef _QSER_FOTA_H
+#define _QSER_FOTA_H
+#include "mbtk_type.h"
+
+int lynq_rock_main(int first_run);
+
+int lynq_fota_set_addr_value(char *value,int size);
+
+int lynq_fota_nrestart(void);
+
+int lynq_get_upgrade_status(void);
+
+
+#endif /* _QSER_FOTA_H */
diff --git a/mbtk/include/qser/qser_gnss.h b/mbtk/include/qser/qser_gnss.h
new file mode 100755
index 0000000..6e2827a
--- /dev/null
+++ b/mbtk/include/qser/qser_gnss.h
@@ -0,0 +1,69 @@
+/*
+* qser_gnss.h
+*
+* QSER GNSS header file.
+*
+* Author : lb
+* Date : 2023/11/23 11:13:18
+*/
+#ifndef _QSER_GNSS_H
+#define _QSER_GNSS_H
+#include "mbtk_type.h"
+
+typedef unsigned int Uint_t;
+
+typedef enum
+{
+ E_MT_LOC_MSG_ID_LOCATION_INFO, /**< pv_data = & mopen_location_info_t */
+ E_MT_LOC_MSG_ID_NMEA_INFO, /**< pv_data = & mopen_gnss_nmea_info_t */
+} e_msg_id_t;
+
+typedef void (*gnss_handler_func_t)
+(
+ Uint_t *h_loc,
+ e_msg_id_t e_msg_id, //消息 ID
+ void *pv_data, //消息内容,取决于 ID,如下说明
+ void *context_ptr //用于区分哪个返回的消息
+)/* lynq_AddRxIndMsgHandler_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 */
+
+typedef enum {
+ DELETE_NOTHING = 0, /*不删除数据*/
+ DELETE_EPHEMERIS = 1, /*删除星历*/
+ DELETE_ALMANAC = 2, /*删除历书*/
+ DELETE_POSITION_TIME = 3, /*删除时间和位置信息. */
+ DELETE_UTC = 4, /*删除 UTC 时间*/
+ DELETE_ALL = 5 /*删除所有*/
+} DELETE_AIDING_DATA_TYPE_T;
+
+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_InjectTime (uint32_t h_gnss,LYNQ_INJECT_TIME_INTO_T *time_info);
+
+int qser_Gnss_Delete_Aiding_Data (uint32_t h_gnss,DELETE_AIDING_DATA_TYPE_T flags);
+
+int qser_Gnss_download_tle();
+
+int qser_Gnss_injectEphemeris(uint32_t h_gnss);
+
+#endif /* _QSER_GNSS_H */
diff --git a/mbtk/include/qser/qser_log.h b/mbtk/include/qser/qser_log.h
new file mode 100755
index 0000000..b77736e
--- /dev/null
+++ b/mbtk/include/qser/qser_log.h
@@ -0,0 +1,55 @@
+/*
+* qser_log.h
+*
+* QSER Log Header File.
+*
+* Author : lb
+* Date : 2023/11/23 11:43:21
+*/
+#ifndef _QSER_LOG_H
+#define _QSER_LOG_H
+#include "mbtk_type.h"
+
+typedef enum
+{
+ LOG_VERBOSE = 0,
+ LOG_ERROR,
+ LOG_WARNING,
+ LOG_INFO,
+ LOG_DEBUG,
+ LOG_LEVEL_MAX
+} log_level_enum;
+
+void lynq_log_configuration_init(const char *log_name);
+
+void lynq_log_global_output(log_level_enum Level,const char *format,...);
+
+int lynq_syslog_set_file_size(int value);
+
+int lynq_syslog_get_file_size(void);
+
+int lynq_syslog_set_file_rotate(int value);
+
+int lynq_syslog_get_file_rotate(void);
+
+int lynq_set_log_level(const char * module_name, log_level_enum level);
+
+int lynq_get_log_level(const char * module_name, log_level_enum *level);
+
+int lynq_set_special_log_level(const char * exe_name, const char * module_name, log_level_enum level);
+
+int lynq_get_special_log_level(const char * exe_name, const char * module_name, log_level_enum *level);
+
+int lynq_notify_recalc_log_level(pid_t pid);
+
+void lynq_log_debug(const char *format,...);
+
+void lynq_log_info(const char *format,...);
+
+void lynq_log_warning(const char *format,...);
+
+void lynq_log_error(const char *format,...);
+
+void lynq_log_verbose(const char *format,...);
+
+#endif /* _QSER_LOG_H */
diff --git a/mbtk/include/qser/qser_net_light.h b/mbtk/include/qser/qser_net_light.h
new file mode 100755
index 0000000..d58968d
--- /dev/null
+++ b/mbtk/include/qser/qser_net_light.h
@@ -0,0 +1,17 @@
+/*
+* qser_net_light.h
+*
+* QSER network light control API.
+*
+* Author : lb
+* Date : 2023/11/23 13:09:47
+*/
+#ifndef _QSER_NET_LIGHT_H
+#define _QSER_NET_LIGHT_H
+#include "mbtk_type.h"
+
+int lynq_set_netled_on(int led_mode);
+
+int lynq_set_statusled_on(int led_mode);
+
+#endif /* _QSER_NET_LIGHT_H */
diff --git a/mbtk/include/qser/qser_network.h b/mbtk/include/qser/qser_network.h
new file mode 100755
index 0000000..2bcaa7a
--- /dev/null
+++ b/mbtk/include/qser/qser_network.h
@@ -0,0 +1,301 @@
+/*
+* qser_network.h
+*
+* QSER network API.
+*
+* Author : lb
+* Date : 2023/11/23 13:59:44
+*/
+#ifndef _QSER_NETWORK_H
+#define _QSER_NETWORK_H
+#include "mbtk_type.h"
+
+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. */
+#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 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 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; // (Not Support Now)
+
+/** 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 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_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 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 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. */(Not Support Now)
+ 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. */(Not Support Now)
+ 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. */(Not Support Now)
+ 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. */(Not Support Now)
+}QSER_NW_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_add_rx_msg_handler * 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
+* */
+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
+);
+
+typedef struct
+{
+ /* Configuration parameters for MCM network fast network scan when OOS (out of service)*/
+ char enable; /* 0 or 1*/
+ uint16_t time_interval; /*unit is second, value range: [1,65535], valid when enable equal 1*/
+}QSER_NW_OOS_CONFIG_FAST_SCAN_INFO_T;
+
+typedef struct
+{
+ /* Configuration parameters for MCM network full band network scan when OOS (out of
+ service)*/
+ /*t_min t_step t_num t_max unit is second, value range: all are zero OR all are between[1, 65535], if
+ t_min < t_max, time interval will be t_max*/
+ 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;
+ QSER_NW_OOS_CONFIG_FULL_BAND_SCAN_INFO_T full_band_scan_info;
+ } u;
+}QSER_NW_OOS_CONFIG_INFO_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_get_operator_name(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info);
+
+int qser_nw_get_reg_status(nw_client_handle_type h_nw, QSER_NW_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);
+
+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);
+
+#endif /* _QSER_NETWORK_H */
diff --git a/mbtk/include/qser/qser_sim.h b/mbtk/include/qser/qser_sim.h
new file mode 100755
index 0000000..8b13789
--- /dev/null
+++ b/mbtk/include/qser/qser_sim.h
@@ -0,0 +1 @@
+
diff --git a/mbtk/include/qser/qser_sleep.h b/mbtk/include/qser/qser_sleep.h
new file mode 100755
index 0000000..820ccdb
--- /dev/null
+++ b/mbtk/include/qser/qser_sleep.h
@@ -0,0 +1,23 @@
+/*
+* qser_sleep.h
+*
+* QSER auto sleep API.
+*
+* Author : lb
+* Date : 2023/11/23 13:18:26
+*/
+#ifndef _QSER_SLEEP_H
+#define _QSER_SLEEP_H
+#include "mbtk_type.h"
+
+int qser_autosuspend_enable(char enable);
+
+int qser_wakelock_create(const char* name , size_t len);
+
+int qser_wakelock_lock(int fd);
+
+int qser_wakelock_unlock(int fd);
+
+int qser_wakelock_destroy(int fd);
+
+#endif /* _QSER_SLEEP_H */
diff --git a/mbtk/include/qser/qser_time.h b/mbtk/include/qser/qser_time.h
new file mode 100755
index 0000000..b0429e9
--- /dev/null
+++ b/mbtk/include/qser/qser_time.h
@@ -0,0 +1,36 @@
+/*
+* qser_time.h
+*
+* QSER time header file.
+*
+* Author : lb
+* Date : 2023/11/23 13:26:11
+*/
+#ifndef _QSER_TIME_H
+#define _QSER_TIME_H
+#include "mbtk_type.h"
+
+typedef struct time_source_status
+{
+ int ntp;
+ int nitz;
+ int gnss;
+} time_src_status_s;
+
+int ntp_sync_time(int enable);
+
+int modem_time_enable(int enable);
+
+int gnss_time_enable(int enable);
+
+int user_set_time(char* date, char* time);
+
+int lynq_sync_time_from_rtc(void);
+
+int lynq_get_time_src_status (time_src_status_s * time_src);
+
+int lynq_set_rtc_time(void);
+
+int lynq_get_rtc_time(unsigned long *ulsec);
+
+#endif /* _QSER_TIME_H */
diff --git a/mbtk/lynq_lib/Makefile b/mbtk/lynq_lib/Makefile
index 22a5e03..dcafb24 100755
--- a/mbtk/lynq_lib/Makefile
+++ b/mbtk/lynq_lib/Makefile
@@ -4,7 +4,7 @@
LOCAL_PATH=$(BUILD_ROOT)/lynq_lib
INC_DIR +=
-
+
LIB_DIR +=
LIBS += -llog -lmbtk_lib
@@ -35,7 +35,7 @@
%.o:%.c
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
-
+
%.o:%.cpp
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
diff --git a/mbtk/lynq_lib/src/lynq_audio.c b/mbtk/lynq_lib/src/lynq_audio.c
index 21640ac..f783f5f 100755
--- a/mbtk/lynq_lib/src/lynq_audio.c
+++ b/mbtk/lynq_lib/src/lynq_audio.c
@@ -29,6 +29,9 @@
#include "mbtk_log.h"
#include "mbtk_type.h"
+
+#ifdef MBTK_PLATFORM_ASR1803
+
#include "mbtk_audio.h"
static int rec_fd = 0;
@@ -164,9 +167,13 @@
}
}
}
+#else
+
+#endif
int lynq_media_rec_audio(const char *path)
{
+#ifdef MBTK_PLATFORM_ASR1803
int ret = 0;
char audio_dir[50] ={0};
char audio_wav[10] = {0};
@@ -205,6 +212,10 @@
}
return -1;
+#else
+
+ return -1;
+#endif
}
@@ -212,6 +223,7 @@
//停止录制音频文件
void lynq_media_rec_stop_audio(void)
{
+#ifdef MBTK_PLATFORM_ASR1803
// sleep(10);
mbtk_audio_close(record_hdl);
if(rec_fd > 0)
@@ -219,9 +231,12 @@
close(rec_fd);
rec_fd = 0;
}
- return 0;
+#else
+
+#endif
}
+#ifdef MBTK_PLATFORM_ASR1803
//播放音频文件
int lynq_media_play_audio_thread_handle(void *argv)
{
@@ -260,10 +275,12 @@
mbtk_audio_close(play_hdl);
return 0;
}
+#endif
//创建线程播放音频文件
int lynq_media_play_audio(const char *path)
{
+#ifdef MBTK_PLATFORM_ASR1803
int ret = pthread_create(&paly_thread, NULL, lynq_media_play_audio_thread_handle, (void *)path);
if (ret != 0) {
printf("create thread failed!\n");
@@ -272,12 +289,17 @@
pthread_detach(paly_thread);
return 0;
+#else
+
+ return 0;
+#endif
}
//停止播放音频文件
void lynq_media_stop_audio(void)
{
+#ifdef MBTK_PLATFORM_ASR1803
printf("lynq_media_stop_audio()----\n");
if(play_fd > 0)
{
@@ -290,9 +312,12 @@
play_fd = 0;
}
mbtk_audio_close(play_hdl);
+#else
+
+#endif
}
-
+#ifdef MBTK_PLATFORM_ASR1803
int lynq_audio_ubus_client_init(mbtk_audio_client_handle_type *ph_audio, mbtk_dtmf_cb cb)
{
if(rec_fd > 0 || play_fd > 0)
@@ -312,22 +337,27 @@
}
return mbtk_audio_ubus_client_deinit(h_audio);
}
-
+#endif
int lynq_get_spk_volume(int * volume)
{
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_ubus_volume_get(audio_volume_cb);
*volume = volume_size;
return 0;
+#else
+ return 0;
+#endif
}
int lynq_set_spk_volume(const int volume)
{
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_ubus_volume_set(volume);
return 0;
+#else
+ return 0;
+#endif
}
-
-
-
diff --git a/mbtk/lynq_lib/src/lynq_call_api.c b/mbtk/lynq_lib/src/lynq_call_api.c
index 1645803..ccab09f 100755
--- a/mbtk/lynq_lib/src/lynq_call_api.c
+++ b/mbtk/lynq_lib/src/lynq_call_api.c
@@ -3,7 +3,9 @@
static mbtk_info_handle_t* info_handle = NULL;
int lynq_volume_size = 0;
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_client_handle_type lynq_dtmf_handle;
+#endif
mbtk_call_info_t lynq_reg[5]={0};
int *handle_ptr=null;
void (*incoming_call_cb_p)(int x)=NULL;
@@ -101,16 +103,19 @@
*/
}
-
+#ifdef MBTK_PLATFORM_ASR1803
void lynq_dtmf_cb(char dtmf)
{
printf("%s:%c\n", __FUNCTION__, dtmf);
}
+#endif
int lynq_init_call(int uToken)
{
UNUSED(uToken);
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_ubus_client_init(&lynq_dtmf_handle, lynq_dtmf_cb);
+#endif
if(info_handle == NULL)
{
info_handle = mbtk_info_handle_get();
@@ -400,6 +405,8 @@
}
+
+#ifdef MBTK_PLATFORM_ASR1803
void lynq_audio_volume_cb(int volume)
{
lynq_volume_size = volume;
@@ -413,9 +420,12 @@
printf("%s:%d\n", __FUNCTION__, lynq_volume_size);
}
}
+#endif
int lynq_set_speech_volume(const int volume)
{
+
+#ifdef MBTK_PLATFORM_ASR1803
if(volume <= 0 || volume >= 101)
{
printf("input error\n");
@@ -428,12 +438,21 @@
mbtk_audio_ubus_volume_set(set_volume);
return 0;
}
+#else
+
+ return 0;
+#endif
}
int lynq_get_speech_volume(int * volume)
{
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_ubus_volume_get(lynq_audio_volume_cb);
sleep(1);
*volume = lynq_volume_size;
return 0;
+#else
+
+ return 0;
+#endif
}
\ No newline at end of file
diff --git a/mbtk/lynq_lib/src/lynq_gnss.c b/mbtk/lynq_lib/src/lynq_gnss.c
index b746c31..19c2d42 100755
--- a/mbtk/lynq_lib/src/lynq_gnss.c
+++ b/mbtk/lynq_lib/src/lynq_gnss.c
@@ -23,13 +23,21 @@
#include <termios.h>
#include <sys/ioctl.h>
#include "mbtk_type.h"
-#include "mbtk_gnss.h"
#include "lynq/lynq_gnss.h"
+#ifdef MBTK_GNSS_6228
+#include "mbtk_gnss_6228.h"
+
static mbtk_gnss_client_handle _gnss_handle = 0;
+#else
+
+#endif
+
+
static lynq_gnss_rx_ind_msg_handler_t handler_ptr = NULL;
+#ifdef MBTK_GNSS_6228
void lynq_gnss_handler_function
(
mbtk_gnss_client_handle h_loc,
@@ -149,3 +157,56 @@
mbtk_gnss_firmware_update();
return 0;
}
+#else
+//该函数用于进行GNSS初始化
+int lynq_gnss_init(void)
+{
+
+ return 0;
+}
+
+//该函数用于取消GNSS初始化
+int lynq_gnss_deinit(void)
+{
+
+ return 0;
+}
+
+//该函数用于GNSS回调函数初始化
+
+int lynq_gnss_callback_reg(lynq_gnss_rx_ind_msg_handler_t handlerPtr)
+{
+ UNUSED(handlerPtr);
+
+
+ return 0;
+}
+
+//该函数用于启动GNSS。
+int lynq_gnss_start(void)
+{
+ return 0;
+}
+
+//该函数用于关闭GNSS。
+int lynq_gnss_stop(void)
+{
+ return 0;
+}
+
+
+int lynq_gnss_agps_dataconnopen(void)
+{
+ return 0;
+}
+
+int lynq_gnss_dev_reset(void)
+{
+ return 0;
+}
+
+int lynq_gnss_enable_glonass(void)
+{
+ return 0;
+}
+#endif
\ No newline at end of file
diff --git a/mbtk/mbtk_audio_lib/Makefile b/mbtk/mbtk_audio_lib/Makefile
new file mode 100755
index 0000000..683f271
--- /dev/null
+++ b/mbtk/mbtk_audio_lib/Makefile
@@ -0,0 +1,51 @@
+ROOT = $(shell pwd)/../..
+include ../Make.defines
+
+LOCAL_PATH=$(BUILD_ROOT)/mbtk_audio_lib
+
+INC_DIR += -I$(BUILD_ROOT)/mbtk_lib/inc
+
+LIB_DIR +=
+
+LIBS += -llog -lubus -lubox -lblobmsg_json -lrilutil -lmbtk_lib
+
+CFLAGS += -shared -Wl,-shared,-Bsymbolic
+
+DEFINE +=
+
+MY_FILES_PATH:=$(LOCAL_PATH)/src
+#ifeq ($(CONFIG_MBTK_QL_SUPPORT),y)
+#MY_FILES_PATH += $(LOCAL_PATH)/ql
+#endif
+
+#ifeq ($(CONFIG_MBTK_PLATFORM),linux)
+#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
+#endif
+
+#MY_FILES_SUFFIX:=%.c %.cpp
+#My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
+#MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
+#MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
+
+LOCAL_SRC_FILES = $(wildcard src/*.c) $(wildcard src/*.cpp)
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
+
+dtarget := $(OUT_DIR)/lib/libmbtk_audio_lib.so
+
+all: $(dtarget)
+
+$(dtarget): $(OBJS)
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $(OBJS) -o $@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS) $(dtarget)
+
diff --git a/mbtk/mbtk_audio_lib/src/mbtk_audio.c b/mbtk/mbtk_audio_lib/src/mbtk_audio.c
new file mode 100755
index 0000000..8b13789
--- /dev/null
+++ b/mbtk/mbtk_audio_lib/src/mbtk_audio.c
@@ -0,0 +1 @@
+
diff --git a/mbtk/mbtk_lib/Makefile b/mbtk/mbtk_lib/Makefile
index a3345fc..a92b1d5 100755
--- a/mbtk/mbtk_lib/Makefile
+++ b/mbtk/mbtk_lib/Makefile
@@ -11,7 +11,7 @@
LIBS += -llog -lubus -lubox -lprop2uci -luci -lrilutil \
-lcutils \
-laudio-apu
-
+
ifeq ($(BUILD_PLATFORM), asr1803)
LIBS += -lpolarssl \
-lavcodec \
@@ -50,8 +50,6 @@
src/g711_pcm_convert.c \
src/mbtk_adc.c \
src/mbtk_at.c \
- src/mbtk_audio_alsa.c \
- src/mbtk_audio.c \
src/mbtk_basic_at_wrapper.c \
src/mbtk_bs_position.c \
src/mbtk_coap_api.cpp \
@@ -61,8 +59,6 @@
src/mbtk_file.c \
src/mbtk_ftp_at.c \
src/mbtk_ftp.c \
- src/mbtk_gnss.c \
- src/mbtk_gnss_update.c \
src/mbtk_gpio.c \
src/mbtk_http_base.c \
src/mbtk_http.c \
@@ -85,11 +81,21 @@
src/mbtk_utf.c \
src/mbtk_utils.c \
src/ringbuffer.c
-
+
ifeq ($(BUILD_PLATFORM), asr1803)
LOCAL_SRC_FILES += src/mbtk_mp3_to_wav.c
endif
+ifeq ($(MBTK_GNSS_MODE), gnss_6228)
+LOCAL_SRC_FILES += src/mbtk_gnss_6228.c \
+ src/mbtk_gnss_update.c
+endif
+
+ifeq ($(BUILD_PLATFORM), asr1803)
+LOCAL_SRC_FILES += src/mbtk_audio_alsa.c \
+ src/mbtk_audio.c
+endif
+
OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
$(info OBJS = $(OBJS))
@@ -102,7 +108,7 @@
%.o:%.c
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
-
+
%.o:%.cpp
$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
diff --git a/mbtk/mbtk_lib/src/mbtk_alarm.c b/mbtk/mbtk_lib/src/mbtk_alarm.c
new file mode 100755
index 0000000..d62a7e7
--- /dev/null
+++ b/mbtk/mbtk_lib/src/mbtk_alarm.c
@@ -0,0 +1,41 @@
+#include "mbtk_alarm.h"
+
+/*===========================================================================
+FUNCTION mbtk_wakealarm_set()
+
+DESCRIPTION:
+ Set sleep wake alarm.
+
+PARAMETERS:
+ time_sec [IN]: Sleep wake-up time in second.
+
+RETURN VALUE:
+ int : Return 0 if success, other for failures.
+
+===========================================================================*/
+int mbtk_wakealarm_set(unsigned long time_sec);
+{
+
+ return 0;
+}
+
+/*===========================================================================
+FUNCTION mbtk_poweralarm_set()
+
+DESCRIPTION:
+ Set shutdown alarm clock.
+
+PARAMETERS:
+ time_sec [IN]: Shutdown wake-up time in second.
+
+RETURN VALUE:
+ int : Return 0 if success, other for failures.
+
+===========================================================================*/
+int mbtk_poweralarm_set(unsigned long time_sec)
+{
+
+ return 0;
+}
+
+
diff --git a/mbtk/mbtk_lib/src/mbtk_fs.c b/mbtk/mbtk_lib/src/mbtk_fs.c
deleted file mode 100755
index c884e2e..0000000
--- a/mbtk/mbtk_lib/src/mbtk_fs.c
+++ /dev/null
@@ -1,1707 +0,0 @@
-/*************************************************************
-Description:
- MBTK fs c file.
-Author:
- LiuBin
-Date:
- 2020/4/30 13:51:42
-*************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <linux/msg.h>
-#include <sys/statfs.h>
-#include <sys/vfs.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <math.h>
-#include <errno.h>
-#include <linux/magic.h>
-#include <time.h>
-#include <sys/time.h>
-#include <signal.h>
-#include <pthread.h>
-#include <cutils/properties.h>
-#include "mbtk_type.h"
-#include "mbtk_fs.h"
-
-/*************************************************************
- Constants and Macros
-*************************************************************/
-
-
-/*************************************************************
- Variables:local
-*************************************************************/
-int DEF_DIR_S = 0;
-
-int msgid;
-
-/*************************************************************
- Variables:public
-*************************************************************/
-//mbtk_fs
-struct my_msg //消息队列结构体
-{
- long int my_msg_type;
- char *ptr;
-}mbtk_at_fs_msg;
-
-typedef struct
-{
- char in_dir_file[MBTK_FS_MAX + 1];
- char out_dir_file[MBTK_FS_MAX + 1];
-} mbtk_fs_file_dir_info_s;
-mbtk_fs_file_dir_info_s mbtk_at_fs_par_at={0};
-
-/*************************************************************
- Local Function Declaration
-*************************************************************/
-int mbtk_at_fs_msgid(int *at_msgid);
-void mbtk_at_fs_printf(void *data);
-static bool fs_is_space_char(char ch);
-static bool fs_str_empty(char *str);
-static int read_file_len(char *file);
-static char *GET_PWD();
-static int pwd_def_dir(char* path_dir);
-static int path_pass();
-static int creat_filesystem_def_dir();
-void fs_ls_at_cb_func(void *file_list_cb);
-void fs_ls_at_cb_func_num(void *file_list_cb);
-void mbtk_at_fs_data_cb(void *data, int data_len);
-
-
-/*************************************************************
- Local Function Definitions
-*************************************************************/
-
-/*
-//收
-void mbtk_at_fs_printf()
-{
- int msgid;
- mbtk_at_msg.my_msg_type=3;
- msgid=msgget(12,0666|IPC_CREAT);
- MBTK_FUNC(mbtk_at_msgid)(&msgid);
- //char read_buf[MAXMSG];
- while(1)
- {
- msgrcv(msgid,&mbtk_at_msg,4,mbtk_at_msg.my_msg_type,0);
- if(strncmp(mbtk_at_msg.ptr,"end",3)==0)
- break;
- ATRESP(IND_REQ_HANDLE , ATCI_RESULT_CODE_NULL, 0, mbtk_at_msg.ptr);
- free(mbtk_at_msg.ptr);
- mbtk_at_msg.ptr=NULL;
- }
- msgctl(msgid,IPC_RMID,0);
-}
-*/
-//发
-
-int mbtk_at_fs_msgid(int *at_msgid)
-{
- msgid = *at_msgid;
- return 0;
-}
-
-void mbtk_at_fs_printf(void *data)
-{
- char *ptr = malloc(strlen(data)+1);
- memset(ptr,0,strlen(data)+1);
- memcpy(ptr, data, strlen(data)+1);
- mbtk_at_fs_msg.ptr = ptr;
- mbtk_at_fs_msg.my_msg_type=4;
- msgsnd(msgid,&mbtk_at_fs_msg,sizeof(&mbtk_at_fs_msg),0); //发送数据到缓冲区
-}
-
-
-static bool fs_is_space_char(char ch)
-{
- if(ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n')
- return TRUE;
-
- return FALSE;
-}
-
-static bool fs_str_empty(char *str)
-{
- if(str == NULL || strlen(str) == 0)
- return TRUE;
-
- return FALSE;
-}
-
-static int read_file_len(char* file)
-{
- int size;
- FILE* fp;
-
- fp=fopen(file,"r");
- if(NULL==fp)
- {
- fclose(fp);
- }
- else
- {
- fseek(fp,0,SEEK_END); //将文件读写指针移动到文件尾
- size=ftell(fp); //ftell函数获取从文件尾移动到文件开头的偏移量
- fseek(fp,0,SEEK_SET);//恢复指针位置
- fclose(fp);
- }
- return size;
-}
-
-
-//Gets the current working directory
-static char *GET_PWD()
-{
- char dir_buff[1024] = {0};
- char *dir = NULL;
-
- dir = getcwd(dir_buff,sizeof(dir_buff));
-
- if (dir == NULL)
- {
- LOGE(" Not current working directory errno = [%d]\n",errno);
- }
- //LOGE("getcwd dir=[%s]\n",dir);
-
- return dir;
-}
-
-//Default directory determinations
-static int pwd_def_dir(char* path_dir)
-{
- int ret = 0;
-
- if (strncmp(path_dir,DFF_DIR_NVM,3) == 0 || strncmp(path_dir,DFF_DIR_BIN,3) == 0 || strncmp(path_dir,DFF_DIR_DEV,3) == 0 || \
- strncmp(path_dir,DFF_DIR_ETC,3) == 0 || strncmp(path_dir,DFF_DIR_LIB,3) == 0 || strncmp(path_dir,DFF_DIR_LOG,3) == 0 || \
- strncmp(path_dir,DFF_DIR_MNT,3) == 0 || strncmp(path_dir,DFF_DIR_OVERLAY,3) == 0 || strncmp(path_dir,DFF_DIR_PROC,3) == 0 || \
- strncmp(path_dir,DFF_DIR_ROM,3) == 0 || strncmp(path_dir,DFF_DIR_ROOT,3) == 0 || strncmp(path_dir,DFF_DIR_SBIN,3) == 0 || \
- strncmp(path_dir,DFF_DIR_SYS,3) == 0 || strncmp(path_dir,DFF_DIR_TMP,3) == 0 || strncmp(path_dir,DFF_DIR_USR,3) == 0 || \
- strncmp(path_dir,DFF_DIR_VAR,3) == 0 || strncmp(path_dir,DFF_DIR_WWW,3) == 0 )
- {
- ret = -1;
- LOGE("Enter the default directory \n");
- }
-
- return ret;
-}
-
-//
-static int path_pass()
-{
- int at_fs_ret = 0;
- char *fs_pwd_path = NULL;
- char tmp_path[FS_NAME_LEN] = {0};
-
- fs_pwd_path = GET_PWD();//获取当前路径
-
- strcpy(tmp_path, fs_pwd_path);
-
- if ((at_fs_ret = pwd_def_dir(tmp_path)) == -1)
- return at_fs_ret;
-
- if (strncmp(tmp_path, PART_FS, 3) != 0)
- {
- if (strcmp(tmp_path, ROOT_PATH) == 0)//首次进入,所以不用指定前一个字符匹配,全部匹配
- {
- at_fs_ret = chdir(PART_FS);//首次进入切换路径
- LOGE(">dir == [%s]\n", getcwd(NULL,NULL));
- if(-1 == at_fs_ret)
- {
- LOGE("chdir path error:[%d]\n", errno);
- return at_fs_ret;
- }
- }
- else
- {
- at_fs_ret = -1;
- LOGE("Not specified dir %s\n", tmp_path);
- return at_fs_ret;
- }
- }
-
- return at_fs_ret;
-
-}
-
-
-//创建文件系统的默认操作路径
-static int creat_filesystem_def_dir()
-{
- int ret = 0;
-
- if (DEF_DIR_S == 0)//以全局变量判断是否创建了默认路径
- {
- if (access(PART_FS, F_OK) == 0)
- {
- DEF_DIR_S = 1;
- }
- else
- {
- ret = mkdir(PART_FS, 0766);//创建路径
- if(-1 == ret)
- {
- LOGE("mkdir path error:[%d]\n", errno);
- return ret;
- }
- ret = chdir(PART_FS);//切换路径
- LOGE(">dir == [%s]\n", getcwd(NULL,NULL));
- if(-1 == ret)
- {
- LOGE("chdir path error:[%d]\n", errno);
- return ret;
- }
- DEF_DIR_S = 1;
- }
- }
- else if (DEF_DIR_S == 1)
- {
- ;//不进行处理
- }
- else
- {
- LOGE("mkdir path DEF_DIR_S error:[%d]\n", errno);
- }
-
- return ret;
-}
-
-//拼接传入的路径到默认操作路径
-static int path_redirection(char *in_path, char *out_path)
-{
- int ret = 0, len = 0;
- char *tmp_dir = NULL;
- char def_fs[FS_NAME_LEN] = {0};
-
- len = strlen(in_path);
- if ( len + 5 >= 127 )
- {
- LOGE("in_path len more than error:[%d]\n", errno);
- ret = -1;
- return ret;
- }
-
- strcpy(def_fs, PART_FS);
-
- tmp_dir = strncat(def_fs, in_path, sizeof(def_fs)-1);//先拼接再判断
-
- if (strncmp(PART_FS_, tmp_dir, 4) == 0)
- {
- memcpy(out_path, tmp_dir, MBTK_FS_MAX);
- }
- else
- {
- ret = -1;
- return ret;
- }
-
- memset(def_fs, 0x00, sizeof(def_fs));
-
- return ret;
-}
-
-void fs_ls_at_cb_func(void *file_list_cb)
-{
- char resp_buf[1024 + 1] = {0};
- printf("+MFSLS::\r\n%s\n", ((mbtk_fs_dir_file_info_s *)file_list_cb)->name);
- sprintf(resp_buf, "%s\n",((mbtk_fs_dir_file_info_s *)file_list_cb)->name);
- mbtk_at_fs_printf(resp_buf);
- //ret = ATRESP(30163, 0, 0, resp_buf);
-}
-
-void fs_ls_at_cb_func_num(void *file_list_cb)
-{
- //不进行处理,只走流程
-}
-
-void mbtk_at_fs_data_cb(void *data, int data_len)
-{
- char resp_buf[1024];
- printf("\n=====data_cb data[%s]=====\n=====data_cb data_len[%d]=====\n",data, data_len);
-
- memset(resp_buf,0,1024);
- mbtk_at_fs_printf(resp_buf);
-
- if(data_len > 512)
- {
- memset(resp_buf,0,1024);
- memcpy(resp_buf,data,512);
- mbtk_at_fs_printf(resp_buf);
- memset(resp_buf,0,1024);
- sprintf(resp_buf, "DATA: <%d>", 512);
- mbtk_at_fs_printf(resp_buf);
-
- memset(resp_buf,0,1024);
- sprintf(resp_buf, "+MFSREAD:");
- mbtk_at_fs_printf(resp_buf);
- memset(resp_buf,0,1024);
- memcpy(resp_buf,data+512,data_len-512);
- mbtk_at_fs_printf(resp_buf);
- memset(resp_buf,0,1024);
- sprintf(resp_buf, "DATA: <%d>", data_len-512);
- mbtk_at_fs_printf(resp_buf);
- }
- else
- {
- memset(resp_buf,0,1024);
- memcpy(resp_buf,data,data_len);
- mbtk_at_fs_printf(resp_buf);
-
- memset(resp_buf,0,1024);
- sprintf(resp_buf, "<%d>", data_len);
- mbtk_at_fs_printf(resp_buf);
- }
-
-}
-
-
-//Creating a directory
-static int fs_cmd_process_mkd(char *path)
-{
- int ret = 0;
- char Filepath[MBTK_FS_MAX + 1];
- char Pathtmp[MBTK_FS_MAX + 1];
- char *pDir = NULL;
- struct stat FileStat_t;
-
- memset(Filepath, 0x00, sizeof(Filepath));
- memset(Pathtmp, 0x00, sizeof(Pathtmp));
- memset(&FileStat_t, 0x00, sizeof(FileStat_t));
-
- memcpy(Filepath, path, sizeof(Filepath));
-
- if ((ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
-//后期再看那个合适
-#if 0
- pDir = strtok(Filepath, "/");
- strcat(Pathtmp, "/");
- strcat(Pathtmp, pDir);
- strcat(Pathtmp, "/");
-
- memset(&FileStat_t, 0x00, sizeof(FileStat_t));
- stat(Pathtmp, &FileStat_t);
-
- if(!S_ISDIR(FileStat_t.st_mode))
- {
- ret = mkdir(Pathtmp, 0766);//创建路径
- if(-1 == ret)
- {
- LOGE("mkdir path [%s] error:[%d]\n", __FUNCTION__, errno);
- return ret;
- }
- }
-
- while(NULL != ( pDir=strtok(NULL, "/") ))
- {
- strcat(Pathtmp, pDir);
- strcat(Pathtmp, "/");
-
- memset(&FileStat_t, 0x00, sizeof(FileStat_t));
- stat(Pathtmp, &FileStat_t);
-
- if(!S_ISDIR(FileStat_t.st_mode))
- {
- ret = mkdir(Pathtmp, 0766);//创建文件
- if(-1 == ret)
- {
- LOGE("mkdir path [%s] error:[%d]\n", __FUNCTION__, errno);
- return ret;
- }
- }
- }
-#else
- stat(Pathtmp, &FileStat_t);
-
- if(!S_ISDIR(FileStat_t.st_mode))
- {
- ret = mkdir(Pathtmp, 0766);//创建路径
- if(-1 == ret)
- {
- LOGE("mkdir path error:[%d]\n", errno);
- return ret;
- }
- }
- else
- {
- ret = -1;
- LOGE("not a directory error:[%d]\n", errno);
- return ret;
- }
-
-#endif
-
- return ret;
-}
-
-static int fs_cmd_process_rmkd(char *path)
-{
- int ret = 0;
- char Filepath[MBTK_FS_MAX + 1]={0};
- char Pathtmp[MBTK_FS_MAX + 1]={0};
-
- memcpy(Filepath, path, sizeof(Filepath));
-
- if ((ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- if (access(Pathtmp, F_OK) != 0)
- {
- ret = -1;
- LOGE("File does not exist error:[%d]\n", errno);
- return ret;
- }
-
- //ret = rmdir(Filepath);
- ret = rmdir(Pathtmp);
- if (ret == -1)
- {
- LOGE("rmkdir path error:[%d]\n", errno);
- }
-
- return ret;
-}
-
-static int fs_cmd_process_list_dir(char *path,mbtk_fs_dir_file_info_s *fs_dir_list)
-{
- int ret = 0, count = 0, dir_count = 0, file_count = 0, len_name;
- const char *temp_fs_path = NULL;
- struct dirent *files;
- struct stat FileStat_t;
- DIR *dir;
- mbtk_fs_dir_file_info_s fs_dir_file_t, fs_dir_t, fs_file_t;
- char Filepath[MBTK_FS_MAX + 1];
-
- memset(fs_dir_list, 0x0, sizeof(mbtk_fs_dir_file_info_s)-sizeof(void *));
-
- temp_fs_path = path;
-
- chdir(temp_fs_path);
-
- dir = opendir(temp_fs_path);
-
- if (dir == NULL)
- {
- ret = -1;
- LOGE("Directory cannot be opened!\n");
- return ret;
- }
- while ((files = readdir(dir)) != NULL)
- {
- if(strcmp(files->d_name, ".") == 0 || strcmp(files->d_name, "..") == 0)
- {
- continue;
- }//跳过隐藏文件
-
- memset(&FileStat_t, 0x00, sizeof(FileStat_t));
- memset(&fs_dir_file_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
- memset(&fs_file_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
- memset(&fs_dir_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
-
- len_name = strlen(files->d_name);
- //目录或者文件夹名字长度不能超过256,可以的话这里也可以做出错处理;
- stat(files->d_name,&FileStat_t);
-
- if(S_ISDIR(FileStat_t.st_mode)) //递归调用解析其子目录下的文件夹
- {
- memcpy(fs_dir_t.name, files->d_name, sizeof(len_name));
- dir_count++;
- }
- else
- {
- memcpy(fs_file_t.name, files->d_name, sizeof(len_name));
- file_count++;
- }
-
- memcpy(fs_dir_file_t.name, files->d_name, sizeof(len_name));
- count++;
-
- //每次对一个文件或者目录处理,就加入里面
- (fs_dir_list->fs_ls_cb_typedef)(&fs_dir_t);
- }
- closedir(dir);
-
- //每次显示完成后,把读取的数量传给全局变量方便读取
- //mbtk_at_fs_par.all_dir_file = count;
- mbtk_at_fs_par.dir_num = dir_count;
- //mbtk_at_fs_par.file_num = file_count;
-
- return ret;
-}
-
-static int fs_cmd_process_list_file(char *path,mbtk_fs_dir_file_info_s *fs_file_list)
-{
- int ret = 0, count = 0, dir_count = 0, file_count = 0, len_name;
- const char *temp_fs_path = NULL;
- struct dirent *files;
- struct stat FileStat_t;
- DIR *dir;
- mbtk_fs_dir_file_info_s fs_dir_file_t, fs_dir_t, fs_file_t;
- char Filepath[MBTK_FS_MAX + 1];
-
- memset(fs_file_list, 0x0, sizeof(mbtk_fs_dir_file_info_s)-sizeof(void *));
-
- temp_fs_path = path;
-
- chdir(temp_fs_path);
-
- dir = opendir(temp_fs_path);
-
- if (dir == NULL)
- {
- ret = -1;
- LOGE("Directory cannot be opened!\n");
- return ret;
- }
- while ((files = readdir(dir)) != NULL)
- {
- if(strcmp(files->d_name, ".") == 0 || strcmp(files->d_name, "..") == 0)
- {
- continue;
- }//跳过隐藏文件
-
- memset(&FileStat_t, 0x00, sizeof(FileStat_t));
- memset(&fs_dir_file_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
- memset(&fs_file_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
- memset(&fs_dir_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
-
- len_name = strlen(files->d_name);
- //目录或者文件夹名字长度不能超过256,可以的话这里也可以做出错处理;
- stat(files->d_name,&FileStat_t);
-
- if(S_ISDIR(FileStat_t.st_mode)) //递归调用解析其子目录下的文件夹
- {
- memcpy(fs_dir_t.name, files->d_name, (len_name)+1);
- dir_count++;
- }
- else
- {
- memcpy(fs_file_t.name, files->d_name, (len_name)+1);
- file_count++;
- }
-
- memcpy(fs_dir_file_t.name, files->d_name, (len_name)+1);
- count++;
-
- //每次对一个文件或者目录处理,就加入里面
- (fs_file_list->fs_ls_cb_typedef)(&fs_file_t);
- }
-
- //每次显示完成后,把读取的数量传给全局变量方便读取
- //mbtk_at_fs_par.all_dir_file = count;
- //mbtk_at_fs_par.dir_num = dir_count;
- mbtk_at_fs_par.file_num = file_count;
-
- closedir(dir);
-
- return ret;
-}
-
-static int fs_cmd_process_list_all(char *path,mbtk_fs_dir_file_info_s *fs_dir_and_file_list)
-{
- int ret = 0, count = 0, dir_count = 0, file_count = 0, len_name;
- const char *temp_fs_path = NULL;
- struct dirent *files;
- struct stat FileStat_t;
- DIR *dir;
- mbtk_fs_dir_file_info_s fs_dir_file_t, fs_dir_t, fs_file_t;
- char Filepath[MBTK_FS_MAX + 1];
-
- memset(fs_dir_and_file_list, 0x0, sizeof(mbtk_fs_dir_file_info_s)-sizeof(void *));
-
- temp_fs_path = path;
-
- chdir(temp_fs_path);
-
- dir = opendir(temp_fs_path);
-
- if (dir == NULL)
- {
- ret = -1;
- LOGE("Directory cannot be opened!\n");
- return ret;
- }
- while ((files = readdir(dir)) != NULL)
- {
- if(strcmp(files->d_name, ".") == 0 || strcmp(files->d_name, "..") == 0)
- {
- continue;
- }//跳过隐藏文件
-
- memset(&FileStat_t, 0x00, sizeof(FileStat_t));
- memset(&fs_dir_file_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
- memset(&fs_file_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
- memset(&fs_dir_t, 0x0, sizeof(mbtk_fs_dir_file_info_s));
-
- len_name = strlen(files->d_name);
- //目录或者文件夹名字长度不能超过256,可以的话这里也可以做出错处理;
- stat(files->d_name,&FileStat_t);
-
- if(S_ISDIR(FileStat_t.st_mode)) //递归调用解析其子目录下的文件夹
- {
- memcpy(fs_dir_t.name, files->d_name, (len_name)+1);
- //LOGE("DIR>>>>>>>>>>>>>> [%s]\n", fs_dir_t.name);
- dir_count++;
- }
- else
- {
- memcpy(fs_file_t.name, files->d_name, (len_name)+1);
- //LOGE("FILE>>>>>>>>>>>>>> [%s]\n", fs_file_t.name);
- file_count++;
- }
-
- memcpy(fs_dir_file_t.name, files->d_name, (len_name)+1);
- //LOGE("ALL>>>>>>>>>>>>>> [%s]\n", fs_dir_file_t.name);
- count++;
-
- //每次对一个文件或者目录处理,就加入里面
- (fs_dir_and_file_list->fs_ls_cb_typedef)(&fs_dir_file_t);
- }
-
- //每次显示完成后,把读取的数量传给全局变量方便读取
- mbtk_at_fs_par.all_dir_file = count;
- mbtk_at_fs_par.dir_num = dir_count;
- mbtk_at_fs_par.file_num = file_count;
-
- closedir(dir);
-
- return ret;
-}
-
-static int fs_cmd_process_cd(char *path)
-{
- int ret = 0;
- char buf[1024];
- char Filepath[MBTK_FS_MAX + 1];
- char Pathtmp[MBTK_FS_MAX + 1];
-
- memset(buf, 0x00, sizeof(buf));
- memset(Filepath , 0x00, sizeof(Filepath));
- memset(Pathtmp , 0x00, sizeof(Pathtmp));
-
- memcpy(Filepath, path, sizeof(Filepath));
-
- if ((ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- ret = chdir(Pathtmp);
-
-// ret = chdir(path);
-
- if (ret == -1)
- {
- LOGE("cd path error:[%d]\n", errno);
- }
-
- char *ptr = getcwd(buf, sizeof(buf));
- if (ptr == NULL)
- LOGE("cd path error:[%d]\n", errno);
-
- return ret;
-}
-
-static int fs_cmd_process_rename(char *old_path, char *new_path)
-{
- int ret = 0;
- char tmp_old[MBTK_FS_MAX + 1];
- char tmp_new[MBTK_FS_MAX + 1];
-
- memset(tmp_old , 0x00, sizeof(tmp_old));
- memset(tmp_new , 0x00, sizeof(tmp_new));
-
- if ((ret = path_redirection(old_path, tmp_old)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- if ((ret = path_redirection(new_path, tmp_new)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- ret = rename(tmp_old, tmp_new);
-// ret = rename(old_path, new_path);
-
- if (ret == -1)
- {
- LOGE("rename error:[%d]\n", errno);
- }
-
- return ret;
-}
-
-static int fs_cmd_process_copy(char *old_path, char *new_path, int mode)
-{
- int ret = 0, num = 0;
- int old_fd,new_fd;
- char *tbuf = NULL;
- int tmode = mode;//没有做处理,默认以同步方式
- char tmp_old[MBTK_FS_MAX + 1];
- char tmp_new[MBTK_FS_MAX + 1];
-
- memset(tmp_old , 0x00, sizeof(tmp_old));
- memset(tmp_new , 0x00, sizeof(tmp_new));
-
- if ((ret = path_redirection(old_path, tmp_old)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- if ((ret = path_redirection(new_path, tmp_new)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- if (access(tmp_old, F_OK) != 0) //旧文件必须存在
- {
- ret = -1;
- LOGE("old_file access errn = [%d]\n",errno);
- goto exit;
- }
-
- if (access(tmp_new, F_OK) == 0) //新文件存在,则错误
- {
- ret = -1;
- LOGE("new_file access errn = [%d]\n",errno);
- goto exit;
- }
-
- if ( (old_fd=file_open(tmp_old, O_RDWR)) == -1 )
- {
- LOGE("open old_path error:[%d]\n", errno);
- ret = -1;
- goto exit;
- }
-
- if ( (new_fd=file_open(tmp_new, O_RDWR | O_CREAT)) == -1 )
- {
- LOGE("open new_path error:[%d]\n", errno);
- ret = -1;
- goto exit;
- }
-
- int len = lseek(old_fd,0,SEEK_END);//获取长度
-
- if (len == -1)//获取文件大小时出错
- {
- LOGE("lseek error:[%d]\n", errno);
- ret = -1;
- goto exit;
- }
-
- lseek(old_fd,0,SEEK_SET);//还原指针指到开头处
-
- tbuf = malloc(len + 1);
-
- if (len+1 > BUFFERSIZE)
- LOGE("Out of length\n");
-
- num = file_read(old_fd, tbuf, len);
-
- if (file_write(new_fd, tbuf, len) != num)
- {
- LOGE("The write does not match the read out\n");
- ret = -1;
- goto exit;
- }
-
- fsync(old_fd);
- fsync(new_fd);
-
-exit:
- file_close(old_fd);
- file_close(new_fd);
- free(tbuf);
- return ret;
-}
-
-static int fs_cmd_process_memory(uint64 *total, uint64 *available)
-{
- int ret = 0;
- struct statfs buf;
- uint64 blocksize, totalsize, availablesize, freesize;
-
- ret = statfs(PART_FS_OERLAY, &buf);
- if (ret == -1)
- {
- LOGE("statfs error:[%d]\n", errno);
- }
- else
- {
- blocksize = buf.f_bsize; // 每个block里包含的字节数
- totalsize = blocksize * buf.f_blocks; // 总的字节数,f_blocks为block的数目
- //freesize = buf.f_bfree * blocksize; // 剩余空间的大小
- availablesize = buf.f_bavail * blocksize; // 可用空间大小
-
- *total = totalsize;
- *available = availablesize;
- }
-
- return ret;
-}
-
-static int fs_cmd_process_delfile(char *path)
-{
- int ret = 0;
- char tmp[MBTK_FS_MAX + 1];
-
- memset(tmp , 0x00, sizeof(tmp));
-
- if ((ret = path_redirection(path, tmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- ret = remove(tmp);
-// ret = remove(path);
-
- if (ret == -1)
- {
- LOGE("rm file error:[%d]\n", errno);
- }
-
- return ret;
-}
-
-static int fs_cmd_process_creatfile(char *path)
-{
- int ret = 0 ,fd;
- char tmp[MBTK_FS_MAX + 1];
-
- memset(tmp , 0x00, sizeof(tmp));
-
- if ((ret = path_redirection(path, tmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- return ret;
- }
-
- fd = file_open(tmp, O_RDWR | O_CREAT | O_TRUNC);
- if (fd == -1)
- {
- ret = -1;
- LOGE("creat file error:[%d]\n", errno);
- }
-
- file_close(fd);
-
- return ret;
-}
-
-int mbtk_at_fs_dir(int cmd, char *fs_path)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- switch (cmd)
- {
- case 0:
- {
- at_fs_ret = fs_cmd_process_mkd(fs_path);
- break;
- }
- case 1:
- {
- at_fs_ret = fs_cmd_process_rmkd(fs_path);
- break;
- }
- default:
- {
- LOGE("ERROR cmd \n");
- at_fs_ret = -1;
- break;
- }
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_list_num_get(int32* dir_num, int32* file_num)
-{
- int at_fs_ret = 0;
- mbtk_fs_dir_file_info_s fs_dir_file;
- char tmp_path[FS_NAME_LEN] = {0};
- char *fs_pwd_path = NULL;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- fs_pwd_path = GET_PWD();//获取当前路径
-
- strcpy(tmp_path, fs_pwd_path);
-
- if (at_fs_ret == 0)
- {
- fs_dir_file.fs_ls_cb_typedef = fs_ls_at_cb_func_num;
- at_fs_ret = fs_cmd_process_list_all(tmp_path, &fs_dir_file);
-
- *file_num = mbtk_at_fs_par.file_num;
- *dir_num = mbtk_at_fs_par.dir_num;
- }
- else
- {
- at_fs_ret = -1;
- LOGE("OPEN this dir errno [%s]\n", tmp_path);
- goto exit;
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_list_dir_file_get()
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- char *fs_pwd_path = NULL;
- mbtk_fs_dir_file_info_s fs_dir, fs_file;
- char tmp_path[FS_NAME_LEN] = {0};
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- fs_pwd_path = GET_PWD();//获取当前路径
-
- strcpy(tmp_path, fs_pwd_path);
-
- if ((at_fs_ret = pwd_def_dir(tmp_path)) == -1)
- goto exit;
-
- memset(send_buf, 0x00, sizeof(send_buf));
-
- mbtk_at_fs_printf("+MFSLS: SUBDIRECTORIES:");
- fs_dir.fs_ls_cb_typedef = fs_ls_at_cb_func;
- at_fs_ret = fs_cmd_process_list_dir(tmp_path,&fs_dir);
-
- mbtk_at_fs_printf("+MFSLS: FILES:");
- fs_file.fs_ls_cb_typedef = fs_ls_at_cb_func;
- at_fs_ret = fs_cmd_process_list_file(tmp_path,&fs_file);
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- memset(send_buf, 0x00, sizeof(send_buf));
- return at_fs_ret;
-}
-
-int mbtk_at_fs_list_set(int type)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- char *fs_pwd_path = NULL;
- mbtk_fs_dir_file_info_s fs_dir_file, fs_dir, fs_file;
- char tmp_path[FS_NAME_LEN] = {0};
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- fs_pwd_path = GET_PWD();//获取当前路径
-
- strcpy(tmp_path, fs_pwd_path);
-
- if ((at_fs_ret = pwd_def_dir(tmp_path)) == -1)
- goto exit;
-
- if (tmp_path != NULL)
- {
- LOGE("OPEN this dir [%s]\n", tmp_path);
- }
- else
- {
- at_fs_ret = -1;
- LOGE("OPEN this dir errno [%s]\n", tmp_path);
- goto exit;
- }
- memset(send_buf, 0x00, sizeof(send_buf));
- mbtk_at_fs_par.at_fs_type = type;
-
- switch (mbtk_at_fs_par.at_fs_type)
- {
- case 0://显示目录和文件名称
- {
- mbtk_at_fs_printf("+MFSLS:\n");
- fs_dir_file.fs_ls_cb_typedef = fs_ls_at_cb_func;
- at_fs_ret = fs_cmd_process_list_all(tmp_path, &fs_dir_file);
-
- if(at_fs_ret != 0)
- {
- printf("+MFSLS: FAIL,<%d>\n",at_fs_ret);
- sprintf(send_buf,"+MFSLS: FAIL,<%d>\n",at_fs_ret);
- }
- else
- {
- printf("+MFSLS:SUBDIRECTORIES: %d FILES: %d \r\n", mbtk_at_fs_par.dir_num, mbtk_at_fs_par.file_num);
- sprintf(send_buf,"+MFSLS: SUBDIRECTORIES: %d FILES: %d \n", mbtk_at_fs_par.dir_num, mbtk_at_fs_par.file_num);
- }
- break;
- }
- case 1://显示目录名称
- {
- mbtk_at_fs_printf("+MFSLS:");
- fs_dir.fs_ls_cb_typedef = fs_ls_at_cb_func;
- at_fs_ret = fs_cmd_process_list_dir(tmp_path,&fs_dir);
-
- if(at_fs_ret != 0)
- {
- printf("+MFSLS: FAIL,<%d>\n",at_fs_ret);
- sprintf(send_buf,"+MFSRMDIR: FAIL,<%d>\n",at_fs_ret);
- }
- else
- {
- printf("+MFSLS:SUBDIRECTORIES: %d \r\n", mbtk_at_fs_par.dir_num);
- sprintf(send_buf,"+MFSLS: SUBDIRECTORIES: %d \n", mbtk_at_fs_par.dir_num);
- }
- break;
- }
- case 2://显示文件名称
- {
- mbtk_at_fs_printf("+MFSLS:");
- fs_file.fs_ls_cb_typedef = fs_ls_at_cb_func;
- at_fs_ret = fs_cmd_process_list_file(tmp_path,&fs_file);
-
- if(at_fs_ret != 0)
- {
- printf("+MFSLS: FAIL,<%d>\n",at_fs_ret);
- sprintf(send_buf,"+MFSRMDIR: FAIL,<%d>\n",at_fs_ret);
- }
- else
- {
- printf("+MFSLS:FILES: %d \r\n",mbtk_at_fs_par.file_num);
- sprintf(send_buf,"+MFSLS: FILES: %d \n",mbtk_at_fs_par.file_num);
- }
- break;
- }
- default:
- {
- LOGE("ERROR mbtk_at_fs_par.at_fs_type \n");
- at_fs_ret = -1;
- break;
- }
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- memset(send_buf, 0x00, sizeof(send_buf));
- return at_fs_ret;
-}
-
-int mbtk_at_fs_cd(char *fs_dir)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- at_fs_ret = fs_cmd_process_cd(fs_dir);
-
- if(at_fs_ret == 0)
- {
- sprintf(send_buf,"+MFSCD: %s\r\n",fs_dir);
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_delfile(char *fs_dir_file)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- at_fs_ret = fs_cmd_process_delfile(fs_dir_file);
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_attri(char *fs_file)
-{
- int at_fs_ret = 0, len_size;
- char Filepath[MBTK_FS_MAX + 1]={0};
- char Pathtmp[MBTK_FS_MAX + 1]={0};
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- memcpy(Filepath, fs_file, sizeof(Filepath));
-
- if ((at_fs_ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- goto exit;
- }
-
- if (0 != (access(Pathtmp, F_OK)))
- {
- LOGE("access file is null\n");
- at_fs_ret = -1;
- goto exit;
- }
-
- len_size = read_file_len(Pathtmp);
-
- if(at_fs_ret != 0)
- {
- printf("+MFSATTRI : FAIL,<%d>\n",at_fs_ret);
- sprintf(send_buf,"+MFSATTRI : FAIL,<%d>\n",at_fs_ret);
- goto exit;
- }
- else
- {
- printf("+MFSATTRI: <%d>\n",len_size);
- sprintf(send_buf,"+MFSATTRI: %d\n",len_size);
- goto exit;
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_writefile(mbtk_fs_data_info_t *fs_w_data)
-{
- int at_fs_ret = 0, len_size, fd, write_mode, write_size;
- char get_buf[FS_DATA_LEN];
- char Filepath[MBTK_FS_MAX + 1]={0};
- char Pathtmp[MBTK_FS_MAX + 1]={0};
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- memset(get_buf, 0x00, sizeof(get_buf));
-
- write_size = fs_w_data->fs_data_size;
- memcpy(get_buf, fs_w_data->fs_data, write_size);
- memcpy(Filepath, fs_w_data->fs_data_name, strlen(fs_w_data->fs_data_name));
- write_mode = fs_w_data->fs_data_mode;
-
- if ((at_fs_ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- goto exit;
- }
-
- if (0 != (access(Pathtmp, F_OK)))
- {
- LOGE("access file is null\n");
- at_fs_ret = -1;
- goto exit;
- }
-
- fd=file_open(Pathtmp,O_WRONLY);
- if(-1 == fd)
- {
- LOGE("Write file error\n");
- at_fs_ret = -1;
- file_close(fd);
- goto exit;
- }
- else
- {
- LOGE("Open file SUCCESS\r\n");
-
- if (write_mode == 0)
- { //将文件读写指针移动到文件头
- lseek(fd,0,SEEK_SET);
- }
- else if (write_mode == 1)
- { //将文件读写指针移动到文件尾
- lseek(fd,0,SEEK_END);
- }
- else
- {
- LOGE("write_mode error\n");
- at_fs_ret = -1;
- file_close(fd);
- goto exit;
- }
- //这两步可以加出错处理
- file_write(fd, get_buf, write_size);
- fsync(fd);
- file_close(fd);
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-//int mbtk_at_fs_readfile(void *dir_file, int read_offset, int read_size, char* read_buff)
-int mbtk_at_fs_readfile(void *dir_file, int read_offset, int read_size)
-{
- int at_fs_ret = 0, fd, count = 0,file_size, len_count = 0, len = 0;
- char read_buf[1024];
- char Filepath[MBTK_FS_MAX + 1]={0};
- char Pathtmp[MBTK_FS_MAX + 1]={0};
- char send_buf[1024] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- memset(read_buf, 0x00, sizeof(read_buf));
-
- memcpy(Filepath, dir_file, sizeof(Filepath));
-
- if ((at_fs_ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- goto exit;
- }
-
- if (0 != (access(Pathtmp, F_OK)))
- {
- LOGE("access file is null\n");
- at_fs_ret = -1;
- goto exit;
- }
-
- file_size = read_file_len(Pathtmp);
-
-
- fd = file_open(Pathtmp, O_RDONLY);
- if (fd == -1)
- {
- LOGE("Read file error\n");
- at_fs_ret = -1;
- goto exit;
- }
- else
- {
- LOGE("Open file SUCCESS\r\n");
- if (read_offset >= file_size)
- {
- LOGE("read_offset > file_size \n");
- at_fs_ret = -1;
- goto exit;
- }
-
- lseek(fd,read_offset,SEEK_SET);
-
- //由于at客户端缓存才1k,切片512字节大小传输
- if (read_size > 0)
- {
- if (0 < read_size && read_size <= 512) //单次发生:文件大小-偏移量 < 发送大小
- {
- len = read(fd, read_buf, read_size); //返回实际读取的大小
- LOGE("len = [%d]\n",len);
- if (len > 0)
- {
- //LOGE("read_buff = [%s]\n",read_buf);
- sprintf(send_buf,"+MFSREAD: DATA: %d, %s\n",len, read_buf);
- }
- }
- else if(read_size <= 1024 && read_size > 512) //多次发送:
- {
- len = read(fd, read_buf, read_size);
- count++;
- LOGE("count = [%d]\n",count);
- mbtk_at_fs_data_cb(read_buf, len);
- sprintf(send_buf, "+MFSREAD: DATA: [%d] count: [%d]\r\n",len,count);
- mbtk_at_fs_printf(send_buf);
- memset(send_buf, 0x00, sizeof(send_buf));
- }
- else
- {
- LOGE("read_size errno\n");
- }
- }
- else if (read_size == 0)//全部读取完成
- {
- if ((file_size-read_offset) < 512)
- {
- len = read(fd, read_buf, 1024); //返回实际读取的大小
- LOGE("len = [%d]\n",len);
- if (len > 0)
- {
- //LOGE("read_buff = [%s]\n",read_buf);
- sprintf(send_buf,"+MFSREAD: DATA: %d, %s\n",len, read_buf);
- }
- }
- else
- {
- while((file_size-read_offset) > len_count)
- {
- len = read(fd, read_buf, 1024);
- count++;
- LOGE("count = [%d]\n",count);
- mbtk_at_fs_data_cb(read_buf, len);
- len_count += len;
- sprintf(send_buf, "+MFSREAD: DATA: [%d] count: [%d]\r\n",len_count, count);
- mbtk_at_fs_printf(send_buf);
- memset(send_buf, 0x00, sizeof(send_buf));
- }
- }
- }
- else
- {
- LOGE("read_size errno =[%d]\n",errno);
- }
-
- file_close(fd);
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_rename(char *old_file, char *new_file)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- if (old_file == NULL || new_file == NULL)
- {
- at_fs_ret = -1;
- LOGE("old_file or new_file is null\n");
- goto exit;
- }
-
- at_fs_ret = fs_cmd_process_rename(old_file, new_file);
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_creatfile(char *fs_file)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- at_fs_ret = fs_cmd_process_creatfile(fs_file);
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_memory(uint64 *total_len,uint64 *available_len)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- at_fs_ret = fs_cmd_process_memory(total_len, available_len);
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_copy(char *old_file, char *new_file, int mode)
-{
- int at_fs_ret = 0;
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- if (old_file == NULL || new_file == NULL)
- {
- at_fs_ret = -1;
- LOGE("old_file or new_file is null\n");
- goto exit;
- }
-
- at_fs_ret = fs_cmd_process_copy(old_file, new_file, mode);
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_certload(mbtk_fs_data_certmode_t *certmode)
-{
- int at_fs_ret = 0, fd, cert_mode, write_size;
- char tmp_buf[FS_NAME_LEN];
- char get_buf[FS_DATA_LEN];
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- memset(get_buf, 0x00, sizeof(get_buf));
- memset(tmp_buf, 0x00, sizeof(tmp_buf));
-
- write_size = certmode->fs_data_size;
- memcpy(get_buf, certmode->fs_data, write_size);
- cert_mode = certmode->fs_data_certmode;
-
- switch(cert_mode)
- {
- case 0:
- {
- memcpy(tmp_buf, FS_CERT_0, sizeof(tmp_buf));
- break;
- }
- case 1:
- {
- memcpy(tmp_buf, FS_CERT_1, sizeof(tmp_buf));
- break;
- }
- case 2:
- {
- memcpy(tmp_buf, FS_CERT_2, sizeof(tmp_buf));
- break;
- }
- case 3:
- {
- memcpy(tmp_buf, FS_CERT_3, sizeof(tmp_buf));
- break;
- }
- case 4:
- {
- memcpy(tmp_buf, FS_CERT_4, sizeof(tmp_buf));
- break;
- }
- default:
- {
- LOGE("ERROR cert_mode \n");
- at_fs_ret = -1;
- break;
- }
- }
-
- if (at_fs_ret == -1)
- goto exit;
-
- if (fd = file_open(tmp_buf, O_RDWR | O_CREAT | O_TRUNC) == -1)
- {
- LOGE("Open file is err [%d]\n",errno);
- at_fs_ret = -1;
- goto exit;
- }
- else
- {
- //通过at客户端往里面写数据
- LOGE("Open file SUCCESS\r\n");
- if (lseek(fd,0,SEEK_SET) == -1 )
- {
- LOGE("lseek error = [%d]\n",errno);
- at_fs_ret = -1;
- file_close(fd);
- goto exit;
- }
- //这两步可以加出错处理
- file_write(fd, get_buf, write_size);
- fsync(fd);
- file_close(fd);
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-int mbtk_at_fs_fileload(mbtk_fs_data_file_t *file)
-{
- int at_fs_ret = 0, fd, write_size;
- char get_buf[FS_DATA_LEN];
- char Filepath[MBTK_FS_MAX + 1]={0};
- char Pathtmp[MBTK_FS_MAX + 1]={0};
- char send_buf[SENDBUFF] = {0};
- memset(send_buf, 0x00, sizeof(send_buf));
-
- if ((at_fs_ret = creat_filesystem_def_dir()) == -1)
- {
- LOGE("creat_filesystem_def_dir error:[%d]\n", errno);
- return at_fs_ret;
- }
-
- if ((at_fs_ret = path_pass()) == -1)
- goto exit;
-
- memset(get_buf, 0x00, sizeof(get_buf));
-
- if (file == NULL)
- {
- at_fs_ret = -1;
- LOGE("file is null\n");
- goto exit;
- }
-
- write_size = file->fs_data_size;
- memcpy(get_buf, file->fs_data, write_size);
- memcpy(Filepath, file->fs_data_name, strlen(file->fs_data_name));
-
- if ((at_fs_ret = path_redirection(Filepath, Pathtmp)) == -1)
- {
- LOGE("input path_redirection error:[%d]\n", errno);
- goto exit;
- }
-
- if (fd = file_open(Pathtmp, O_RDWR | O_CREAT | O_TRUNC) == -1)
- {
- LOGE("open file is err [%d]\n",errno);
- }
- else
- {
- //通过at客户端往里面写数据
- LOGE("Open file SUCCESS\r\n");
- if (lseek(fd,0,SEEK_SET) == -1 )
- {
- LOGE("lseek error = [%d]\n",errno);
- at_fs_ret = -1;
- file_close(fd);
- goto exit;
- }
- //这两步可以加出错处理
- file_write(fd, get_buf, write_size);
- fsync(fd);
- file_close(fd);
- }
-
-exit:
- mbtk_at_fs_printf(send_buf);
- mbtk_at_fs_printf("end");
- return at_fs_ret;
-}
-
-
diff --git a/mbtk/mbtk_lib/src/mbtk_gnss.c b/mbtk/mbtk_lib/src/mbtk_gnss_6228.c
similarity index 99%
rename from mbtk/mbtk_lib/src/mbtk_gnss.c
rename to mbtk/mbtk_lib/src/mbtk_gnss_6228.c
index 72c207c..ab53662 100755
--- a/mbtk/mbtk_lib/src/mbtk_gnss.c
+++ b/mbtk/mbtk_lib/src/mbtk_gnss_6228.c
@@ -23,7 +23,7 @@
#include <time.h>
#include <sys/ioctl.h>
#include "mbtk_type.h"
-#include "mbtk_gnss.h"
+#include "mbtk_gnss_6228.h"
#include "mbtk_http.h"
#include "mbtk_log.h"
#include "ringbuffer.h"
@@ -1867,7 +1867,7 @@
set_baudrate(fd, B921600);
ret = sendAPData(fd, "/etc/mbtk/rtm.bin");
-
+
if(0 != ret) {
close(fd);
printf("Gnss update result: %x\n", ret);
@@ -1966,7 +1966,7 @@
case 9:{
ret = mbtk_gnss_set_system_config((uint32)mbtk_gnss_handle,2);//GPS+GLONASS
break;
- }
+ }
default:
break;
}
diff --git a/mbtk/ql_lib/src/ql_audio.c b/mbtk/ql_lib/src/ql_audio.c
index b94db61..184c48f 100755
--- a/mbtk/ql_lib/src/ql_audio.c
+++ b/mbtk/ql_lib/src/ql_audio.c
@@ -1,11 +1,15 @@
#include "ql/ql_audio.h"
#include "mbtk_log.h"
+#ifdef MBTK_PLATFORM_ASR1803
#include "mbtk_audio.h"
static mbtk_audio_handle record_hdl = NULL;
static mbtk_audio_handle player_hdl = NULL;
static _cb_onRecorder record_cb_fun = NULL;
static int Samprate = 8000;
+#else
+
+#endif
/*****************************************************************
* Function: Ql_AudPlayer_Open
@@ -35,8 +39,12 @@
*****************************************************************/
int Ql_AudPlayer_Open(char* device, _cb_onPlayer cb_func)
{
+#ifdef MBTK_PLATFORM_ASR1803
player_hdl = mbtk_audio_open(MBTK_AUTIO_TYPE_OUT, 1, Samprate, cb_func);
return (int)player_hdl;
+#else
+ return 0;
+#endif
}
/*========================================================================
@@ -59,7 +67,11 @@
/*=======================================================================*/
int Ql_AudPlayer_Play(int hdl, unsigned char* pData, unsigned int length)
{
+#ifdef MBTK_PLATFORM_ASR1803
return mbtk_audio_play_stream((void *)hdl, pData, length);
+#else
+ return 0;
+#endif
}
/*========================================================================
@@ -87,7 +99,11 @@
int Ql_AudPlayer_PlayFrmFile(int hdl, int fd, int offset)
{
+#ifdef MBTK_PLATFORM_ASR1803
return mbtk_audio_play_file((void *)hdl, fd, offset);
+#else
+ return 0;
+#endif
}
//
@@ -99,7 +115,11 @@
// Handle received from Ql_AudPlayer_Open().
int Ql_AudPlayer_Pause(int hdl)
{
+#ifdef MBTK_PLATFORM_ASR1803
return mbtk_audio_pause((void *)hdl);
+#else
+ return 0;
+#endif
}
//
@@ -111,7 +131,11 @@
// Handle received from Ql_AudPlayer_Open().
int Ql_AudPlayer_Resume(int hdl)
{
+#ifdef MBTK_PLATFORM_ASR1803
return mbtk_audio_resume((void *)hdl);
+#else
+ return 0;
+#endif
}
//
@@ -123,7 +147,11 @@
// Handle received from Ql_AudPlayer_Open().
void Ql_AudPlayer_Stop(int hdl)
{
- return mbtk_audio_stop((void *)hdl);
+#ifdef MBTK_PLATFORM_ASR1803
+ mbtk_audio_stop((void *)hdl);
+#else
+
+#endif
}
//
@@ -135,7 +163,11 @@
// Handle received from Ql_AudPlayer_Open().
void Ql_AudPlayer_Close(int hdl)
{
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_close((void *)hdl);
+#else
+
+#endif
}
@@ -171,9 +203,14 @@
*****************************************************************/
int Ql_AudRecorder_Open(char* device, _cb_onRecorder cb_fun)
{
+#ifdef MBTK_PLATFORM_ASR1803
record_hdl = mbtk_audio_open(MBTK_AUTIO_TYPE_IN, 1, 8000, NULL);
record_cb_fun = cb_fun;
return (int)record_hdl;
+#else
+ return 0;
+
+#endif
}
//
@@ -188,7 +225,12 @@
// -1 on failure
int Ql_AudRecorder_StartRecord(void)
{
+#ifdef MBTK_PLATFORM_ASR1803
return mbtk_audio_record(record_hdl, record_cb_fun, NULL);
+#else
+ return 0;
+
+#endif
}
//
@@ -228,9 +270,13 @@
// Close recorder, and free the resource
void Ql_AudRecorder_Close(void)
{
+#ifdef MBTK_PLATFORM_ASR1803
mbtk_audio_close(record_hdl);
record_hdl = NULL;
record_cb_fun = NULL;
+#else
+
+#endif
}
//
@@ -364,7 +410,7 @@
int Ql_Rxgain_Set(int value)
{
-
+#ifdef MBTK_PLATFORM_ASR1803
printf("Volume is %d \n",value);
int volume =0;
int handler = 0;
@@ -380,8 +426,11 @@
mbtk_audio_ubus_client_init(&handler, dtmf_cb1);
mbtk_audio_dsp_set(1, volume);
+ return 0;
+#else
- return 0;
+ return 0;
+#endif
}
@@ -395,6 +444,7 @@
*/
int Ql_Playback_Samprate_Set(int samprate)
{
+#ifdef MBTK_PLATFORM_ASR1803
printf("samprate is %d \n",samprate);
if(samprate == 1)
{
@@ -405,24 +455,38 @@
}
return 0;
+#else
+
+ return 0;
+#endif
}
int Ql_Mp3_To_Wav(const char *wavpath, char *mp3path)
{
+#ifdef MBTK_PLATFORM_ASR1803
#ifdef MBTK_MP3_SUPPORT
return mbtk_audio_mp3_to_wav(wavpath, mp3path);
#else
return 0;
#endif
+#else
+
+ return 0;
+#endif
}
int Ql_Mp3_To_Play(char *mp3path, int hdl,int sample_rate)
{
+#ifdef MBTK_PLATFORM_ASR1803
#ifdef MBTK_MP3_SUPPORT
return mbtk_audio_mp3_to_play(mp3path, hdl, sample_rate);
#else
return 0;
#endif
+#else
+
+ return 0;
+#endif
}
//add by grady, 2018-6-2
diff --git a/mbtk/qser_lib/Makefile b/mbtk/qser_lib/Makefile
new file mode 100755
index 0000000..cc7956f
--- /dev/null
+++ b/mbtk/qser_lib/Makefile
@@ -0,0 +1,70 @@
+ROOT = $(shell pwd)/../..
+include ../Make.defines
+
+LOCAL_PATH=$(BUILD_ROOT)/qser_lib
+
+INC_DIR += -I$(BUILD_ROOT)/mbtk_lib/inc
+
+LIB_DIR +=
+
+LIBS += -llog -lubus -lubox -lblobmsg_json -lrilutil -lmbtk_lib
+
+CFLAGS += -shared -Wl,-shared,-Bsymbolic
+
+DEFINE +=
+
+MY_FILES_PATH:=$(LOCAL_PATH)/src
+#ifeq ($(CONFIG_MBTK_QL_SUPPORT),y)
+#MY_FILES_PATH += $(LOCAL_PATH)/ql
+#endif
+
+#ifeq ($(CONFIG_MBTK_PLATFORM),linux)
+#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
+#endif
+
+#MY_FILES_SUFFIX:=%.c %.cpp
+#My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
+#MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
+#MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
+
+#LOCAL_SRC_FILES = $(wildcard src/*.c) $(wildcard src/*.cpp)
+LOCAL_SRC_FILES = src/qser_adc.c \
+ src/qser_alarm.c \
+ src/qser_audio.c \
+ src/qser_fota.c \
+ src/qser_gnss.c \
+ src/qser_gpio.c \
+ src/qser_log.c \
+ src/qser_net_light.c \
+ src/qser_sleep.c \
+ src/qser_time.c
+
+# LOCAL_SRC_FILES += src/qser_data_call.c \
+ src/qser_irq.c \
+ src/qser_network.c \
+ src/qser_sim.c \
+ src/qser_sms.c \
+ src/qser_voice_call.c
+
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
+
+dtarget := $(OUT_DIR)/lib/libqser_lib.so
+
+all: $(dtarget)
+
+$(dtarget): $(OBJS)
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $(OBJS) -o $@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS) $(dtarget)
+
diff --git a/mbtk/qser_lib/src/qser_adc.c b/mbtk/qser_lib/src/qser_adc.c
new file mode 100755
index 0000000..8efeb03
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_adc.c
@@ -0,0 +1,9 @@
+#include "qser/qser_adc.h"
+
+int qser_adc_show(ADC_CHANNEL_E qadc)
+{
+ UNUSED(qadc);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_alarm.c b/mbtk/qser_lib/src/qser_alarm.c
new file mode 100755
index 0000000..537171d
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_alarm.c
@@ -0,0 +1,35 @@
+#include "mbtk_alarm.h"
+#include "qser/qser_alarm.h"
+
+int lynq_set_wakealarm(unsigned long time_sec)
+{
+ UNUSED(time_sec);
+
+ return 0;
+}
+
+int lynq_set_poweralarm(unsigned long time_sec)
+{
+ UNUSED(time_sec);
+
+ return 0;
+}
+
+ssize_t wakealarm(char *buffer)
+{
+ UNUSED(buffer);
+
+ return 0;
+}
+
+ssize_t poweralarm(char *buffer)
+{
+ UNUSED(buffer);
+
+ return 0;
+}
+
+int cancel_wakealarm(void)
+{
+ return 0;
+}
\ No newline at end of file
diff --git a/mbtk/qser_lib/src/qser_audio.c b/mbtk/qser_lib/src/qser_audio.c
new file mode 100755
index 0000000..426dadb
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_audio.c
@@ -0,0 +1,95 @@
+#include "qser/qser_audio.h"
+
+int qser_AudPlayer_Open(char* device, _cb_onPlayer cb_fun)
+{
+ UNUSED(device);
+ UNUSED(cb_fun);
+
+ return 0;
+}
+
+int qser_AudPlayer_PlayFrmFile(int hdl, const char *fd, int offset)
+{
+ UNUSED(hdl);
+ UNUSED(fd);
+ UNUSED(offset);
+
+ return 0;
+}
+
+int qser_AudPlayer_Pause(int hdl)
+{
+ UNUSED(hdl);
+
+ return 0;
+}
+
+int qser_AudPlayer_Resume(int hdl)
+{
+ UNUSED(hdl);
+
+ return 0;
+}
+
+void qser_AudPlayer_Stop(int hdl)
+{
+ UNUSED(hdl);
+
+ return 0;
+}
+
+
+void qser_AudPlayer_Close(int hdl)
+{
+ UNUSED(hdl);
+
+ return 0;
+}
+
+
+int qser_AudRecorder_Open(char* device, _cb_onPlayer cb_fun)
+{
+ UNUSED(device);
+ UNUSED(cb_fun);
+
+
+ return 0;
+}
+
+int qser_AudRecorder_StartRecord(int hdl, const char *fd, int offset)
+{
+ UNUSED(hdl);
+ UNUSED(fd);
+ UNUSED(offset);
+
+
+ return 0;
+}
+
+int qser_AudRecorder_Pause(void)
+{
+
+ return 0;
+}
+
+int qser_AudRecorder_Resume(void)
+{
+
+ return 0;
+}
+
+void qser_AudRecorder_Stop(void)
+{
+
+}
+
+void qser_AudRecorder_Close(void)
+{
+
+}
+
+void qser_Audio_Deinit(void)
+{
+
+}
+
diff --git a/mbtk/qser_lib/src/qser_data_call.c b/mbtk/qser_lib/src/qser_data_call.c
new file mode 100755
index 0000000..e6d07e8
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_data_call.c
@@ -0,0 +1,80 @@
+#include "qser/qser_data_call.h"
+
+
+int qser_data_call_init(qser_data_call_evt_cb_t evt_cb)
+{
+ UNUSED(evt_cb);
+
+ return 0;
+}
+
+void qser_data_call_destroy(void)
+{
+
+}
+
+int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err)
+{
+ UNUSED(data_call);
+ UNUSED(err);
+
+ return 0;
+}
+
+int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err)
+{
+ UNUSED(profile_idx);
+ UNUSED(ip_family);
+ UNUSED(err);
+
+ return 0;
+}
+
+int qser_data_call_info_get(char profile_idx,qser_data_call_ip_family_e ip_family,
+ qser_data_call_info_s *info, qser_data_call_error_e *err)
+{
+ UNUSED(profile_idx);
+ UNUSED(ip_family);
+ UNUSED(info);
+ UNUSED(err);
+
+ return 0;
+}
+
+int qser_apn_set(qser_apn_info_s *apn)
+{
+ UNUSED(apn);
+
+ return 0;
+}
+
+int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn)
+{
+ UNUSED(profile_idx);
+ UNUSED(apn);
+
+ return 0;
+}
+
+int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx)
+{
+ UNUSED(apn);
+ UNUSED(profile_idx);
+
+ return 0;
+}
+
+int qser_apn_del(unsigned char profile_idx)
+{
+ UNUSED(profile_idx);
+
+ return 0;
+}
+
+int qser_apn_get_list(qser_apn_info_list_s *apn_list)
+{
+ UNUSED(apn_list);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_fota.c b/mbtk/qser_lib/src/qser_fota.c
new file mode 100755
index 0000000..43ee6e0
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_fota.c
@@ -0,0 +1,32 @@
+#include "qser/qser_fota.h"
+
+
+int lynq_rock_main(int first_run)
+{
+ UNUSED(first_run);
+
+
+ return 0;
+}
+
+int lynq_fota_set_addr_value(char *value,int size)
+{
+ UNUSED(value);
+ UNUSED(size);
+
+
+ return 0;
+}
+
+int lynq_fota_nrestart(void)
+{
+
+ return 0;
+}
+
+int lynq_get_upgrade_status(void)
+{
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_gnss.c b/mbtk/qser_lib/src/qser_gnss.c
new file mode 100755
index 0000000..d10c800
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_gnss.c
@@ -0,0 +1,79 @@
+#include "qser/qser_gnss.h"
+
+int qser_Gnss_Init (uint32_t *h_gnss)
+{
+ UNUSED(h_gnss);
+
+
+ return 0;
+}
+
+int qser_Gnss_Deinit (uint32_t h_gnss)
+{
+ UNUSED(h_gnss);
+
+
+ return 0;
+}
+
+int qser_AddRxIndMsgHandler (gnss_handler_func_t handler_ptr,uint32_t h_gnss)
+{
+ UNUSED(handler_ptr);
+ UNUSED(h_gnss);
+
+
+ return 0;
+}
+
+int qser_Set_Indications (uint32_t h_gnss,e_msg_id_t type)
+{
+ UNUSED(h_gnss);
+ UNUSED(type);
+
+
+ return 0;
+}
+
+int qser_Gnss_Start (uint32_t h_gnss)
+{
+ UNUSED(h_gnss);
+
+ return 0;
+}
+
+int qser_Gnss_Stop (uint32_t h_gnss)
+{
+ UNUSED(h_gnss);
+
+ return 0;
+}
+
+int qser_Gnss_InjectTime (uint32_t h_gnss,LYNQ_INJECT_TIME_INTO_T *time_info)
+{
+ UNUSED(h_gnss);
+ UNUSED(time_info);
+
+ return 0;
+}
+
+int qser_Gnss_Delete_Aiding_Data (uint32_t h_gnss,DELETE_AIDING_DATA_TYPE_T flags)
+{
+ UNUSED(h_gnss);
+ UNUSED(flags);
+
+ return 0;
+}
+
+int qser_Gnss_download_tle()
+{
+
+ return 0;
+}
+
+int qser_Gnss_injectEphemeris(uint32_t h_gnss)
+{
+ UNUSED(h_gnss);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_gpio.c b/mbtk/qser_lib/src/qser_gpio.c
new file mode 100755
index 0000000..1b1c3de
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_gpio.c
@@ -0,0 +1,61 @@
+#include "mbtk_type.h"
+
+int lynq_gpio_init(int gpio, int direction, int value, int pullsel)
+{
+ UNUSED(gpio);
+ UNUSED(direction);
+ UNUSED(value);
+ UNUSED(pullsel);
+
+ return 0;
+}
+
+int lynq_gpio_deinit(int gpio)
+{
+ UNUSED(gpio);
+
+ return 0;
+}
+
+int lynq_gpio_direction_set(int gpio, int direction)
+{
+ UNUSED(gpio);
+ UNUSED(direction);
+
+ return 0;
+}
+
+
+int lynq_gpio_value_set(int gpio, int value)
+{
+ UNUSED(gpio);
+ UNUSED(value);
+
+ return 0;
+}
+
+int lynq_gpio_value_get(int gpio)
+{
+ UNUSED(gpio);
+
+ return 0;
+}
+
+int lynq_gpio_pullsel_set(int gpio, int pullsel)
+{
+ UNUSED(gpio);
+ UNUSED(pullsel);
+
+ return 0;
+}
+
+
+int lynq_gpio_pullsel_get(int gpio)
+{
+ UNUSED(gpio);
+
+ return 0;
+}
+
+
+
diff --git a/mbtk/qser_lib/src/qser_irq.c b/mbtk/qser_lib/src/qser_irq.c
new file mode 100755
index 0000000..4cf5c15
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_irq.c
@@ -0,0 +1,42 @@
+
+
+int lynq_irq_install(int line, irq_handler irq_test_handler, int trig_type)
+{
+ UNUSED(line);
+ UNUSED(irq_test_handler);
+ UNUSED(trig_type);
+
+ return 0;
+}
+
+int lynq_irq_unstall(int line)
+{
+ UNUSED(line);
+
+ return 0;
+}
+
+int lynq_irq_set_type(int line, int trig_type)
+{
+ UNUSED(line);
+ UNUSED(trig_type);
+
+ return 0;
+}
+
+int lynq_set_wake(int line, int en)
+{
+ UNUSED(line);
+ UNUSED(en);
+
+ return 0;
+}
+
+int lynq_irq_get_wake(int line)
+{
+ UNUSED(line);
+
+ return 0;
+}
+
+
diff --git a/mbtk/qser_lib/src/qser_log.c b/mbtk/qser_lib/src/qser_log.c
new file mode 100755
index 0000000..131e869
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_log.c
@@ -0,0 +1,123 @@
+#include "qser/qser_log.h"
+
+
+void lynq_log_configuration_init(const char *log_name)
+{
+ UNUSED(log_name);
+
+
+}
+
+void lynq_log_global_output(log_level_enum Level,const char *format,...)
+{
+ UNUSED(Level);
+ UNUSED(format);
+
+
+}
+
+int lynq_syslog_set_file_size(int value)
+{
+ UNUSED(value);
+
+ return 0;
+}
+
+int lynq_syslog_get_file_size(void)
+{
+
+ return -1;
+}
+
+int lynq_syslog_set_file_rotate(int value)
+{
+ UNUSED(value);
+
+ return 0;
+}
+
+int lynq_syslog_get_file_rotate(void)
+{
+
+ return 0;
+}
+
+int lynq_set_log_level(const char * module_name, log_level_enum level)
+{
+ UNUSED(module_name);
+ UNUSED(level);
+
+
+ return 0;
+}
+
+int lynq_get_log_level(const char * module_name, log_level_enum *level)
+{
+ UNUSED(module_name);
+ UNUSED(level);
+
+
+ return 0;
+}
+
+int lynq_set_special_log_level(const char * exe_name, const char * module_name, log_level_enum level)
+{
+ UNUSED(exe_name);
+ UNUSED(module_name);
+ UNUSED(level);
+
+
+ return 0;
+}
+
+int lynq_get_special_log_level(const char * exe_name, const char * module_name, log_level_enum *level)
+{
+ UNUSED(exe_name);
+ UNUSED(module_name);
+ UNUSED(level);
+
+
+ return 0;
+}
+
+int lynq_notify_recalc_log_level(pid_t pid)
+{
+ UNUSED(pid);
+
+ return 0;
+}
+
+void lynq_log_debug(const char *format,...)
+{
+ UNUSED(format);
+
+
+}
+
+void lynq_log_info(const char *format,...)
+{
+ UNUSED(format);
+
+
+}
+
+void lynq_log_warning(const char *format,...)
+{
+ UNUSED(format);
+
+
+}
+
+void lynq_log_error(const char *format,...)
+{
+ UNUSED(format);
+
+
+}
+
+void lynq_log_verbose(const char *format,...)
+{
+ UNUSED(format);
+
+
+}
diff --git a/mbtk/qser_lib/src/qser_net_light.c b/mbtk/qser_lib/src/qser_net_light.c
new file mode 100755
index 0000000..9613377
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_net_light.c
@@ -0,0 +1,16 @@
+#include "qser/qser_net_light.h"
+
+int lynq_set_netled_on(int led_mode)
+{
+ UNUSED(led_mode);
+
+ return 0;
+}
+
+int lynq_set_statusled_on(int led_mode)
+{
+ UNUSED(led_mode);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_network.c b/mbtk/qser_lib/src/qser_network.c
new file mode 100755
index 0000000..6892129
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_network.c
@@ -0,0 +1,71 @@
+#include "qser/qser_network.h"
+
+int qser_nw_client_init(nw_client_handle_type *ph_nw)
+{
+ UNUSED(ph_nw);
+
+ return 0;
+}
+
+int qser_nw_client_deinit(nw_client_handle_type h_nw)
+{
+ UNUSED(h_nw);
+
+ return 0;
+}
+
+int qser_nw_set_config(nw_client_handle_type h_nw,QSER_NW_CONFIG_INFO_T *pt_info)
+{
+ UNUSED(h_nw);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_nw_get_operator_name(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info)
+{
+ UNUSED(h_nw);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_nw_get_reg_status(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info)
+{
+ UNUSED(h_nw);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_nw_get_signal_strength(nw_client_handle_type h_nw,QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info)
+{
+ UNUSED(h_nw);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_nw_add_rx_msg_handler (nw_client_handle_type h_nw, QSER_NW_RxMsgHandlerFunc_t handlerPtr)
+{
+ UNUSED(h_nw);
+ UNUSED(handlerPtr);
+
+ return 0;
+}
+
+int qser_nw_set_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
+{
+ UNUSED(h_nw);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_nw_get_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
+{
+ UNUSED(h_nw);
+ UNUSED(pt_info);
+
+ return 0;
+}
\ No newline at end of file
diff --git a/mbtk/qser_lib/src/qser_sim.c b/mbtk/qser_lib/src/qser_sim.c
new file mode 100755
index 0000000..8d5762d
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_sim.c
@@ -0,0 +1,94 @@
+
+int qser_sim_client_init(sim_client_handle_type *ph_sim)
+{
+ UNUSED(ph_sim);
+
+ return 0;
+}
+
+int qser_sim_getimsi(sim_client_handle_type h_sim, QSER_SIM_APP_ID_INFO_T *pt_info,char *imsi,size_t imsiLen)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+ UNUSED(imsi);
+ UNUSED(imsiLen);
+
+ return 0;
+}
+
+int qser_sim_geticcid(sim_client_handle_type h_sim,QSER_SIM_SLOT_ID_TYPE_T simId,char *iccid, size_t iccidLen)
+{
+ UNUSED(h_sim);
+ UNUSED(simId);
+ UNUSED(iccid);
+ UNUSED(iccidLen);
+
+ return 0;
+}
+
+int qser_sim_getphonenumber(sim_client_handle_type h_sim,QSER_SIM_APP_ID_INFO_T *pt_info, char*phone_num, size_t phoneLen)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+ UNUSED(phone_num);
+ UNUSED(phoneLen);
+
+ return 0;
+}
+
+int qser_sim_verifypin(sim_client_handle_type h_sim,QSER_SIM_VERIFY_PIN_INFO_T *pt_info)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_sim_changepin(sim_client_handle_type h_sim,QSER_SIM_CHANGE_PIN_INFO_T *pt_info)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_sim_unblockpin(sim_client_handle_type h_sim, QSER_SIM_UNBLOCK_PIN_INFO_T *pt_info)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_sim_enablepin(sim_client_handle_type h_sim, QSER_SIM_ENABLE_PIN_INFO_T *pt_info)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_sim_disablepin(sim_client_handle_type h_sim, QSER_SIM_DISABLE_PIN_INFO_T *pt_info)
+{
+ UNUSED(h_sim);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+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)
+{
+ UNUSED(h_sim);
+ UNUSED(simId);
+ UNUSED(pt_info);
+
+ return 0;
+}
+
+int qser_sim_client_deinit(sim_client_handle_type h_sim)
+{
+ UNUSED(h_sim);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_sleep.c b/mbtk/qser_lib/src/qser_sleep.c
new file mode 100755
index 0000000..b0cc807
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_sleep.c
@@ -0,0 +1,40 @@
+#include "qser/qser_sleep.h"
+
+int qser_autosuspend_enable(char enable)
+{
+ UNUSED(enable);
+
+ return 0;
+}
+
+int qser_wakelock_create(const char* name , size_t len)
+{
+ UNUSED(name);
+ UNUSED(len);
+
+ return 0;
+}
+
+int qser_wakelock_lock(int fd)
+{
+ UNUSED(fd);
+
+ return 0;
+}
+
+int qser_wakelock_unlock(int fd)
+{
+ UNUSED(fd);
+
+ return 0;
+}
+
+int qser_wakelock_destroy(int fd)
+{
+ UNUSED(fd);
+
+ return 0;
+}
+
+
+
diff --git a/mbtk/qser_lib/src/qser_sms.c b/mbtk/qser_lib/src/qser_sms.c
new file mode 100755
index 0000000..55a8bcf
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_sms.c
@@ -0,0 +1,56 @@
+
+
+int qser_sms_client_init(sms_client_handle_type *ph_sms)
+{
+ UNUSED(ph_sms);
+
+ return 0;
+}
+
+int qser_sms_client_deinit(sms_client_handle_type h_sms)
+{
+ UNUSED(h_sms);
+
+ return 0;
+}
+
+int qser_sms_send_sms(sms_client_handle_type h_sms, QSER_sms_info_t *pt_sms_info)
+{
+ UNUSED(h_sms);
+ UNUSED(pt_sms_info);
+
+ return 0;
+}
+
+int qser_sms_addrxmsghandler(QSER_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr)
+{
+ UNUSED(handlerPtr);
+ UNUSED(contextPtr);
+
+ return 0;
+}
+
+int qser_sms_deletefromstorage(sms_client_handle_type h_sms, QSER_sms_storage_info_t *pt_sms_storage)
+{
+ UNUSED(h_sms);
+ UNUSED(pt_sms_storage);
+
+ return 0;
+}
+
+int qser_sms_getsmscenteraddress( sms_client_handle_type h_sms,QSER_sms_service_center_cfg_t *set_sca_cfg)
+{
+ UNUSED(h_sms);
+ UNUSED(set_sca_cfg);
+
+ return 0;
+}
+
+int qser_sms_setsmscenteraddress( sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *get_sca_cfg)
+{
+ UNUSED(h_sms);
+ UNUSED(get_sca_cfg);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_time.c b/mbtk/qser_lib/src/qser_time.c
new file mode 100755
index 0000000..f6d0cd0
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_time.c
@@ -0,0 +1,57 @@
+#include "qser/qser_time.h"
+
+int ntp_sync_time(int enable)
+{
+ UNUSED(enable);
+
+ return 0;
+}
+
+int modem_time_enable(int enable)
+{
+ UNUSED(enable);
+
+ return 0;
+}
+
+int gnss_time_enable(int enable)
+{
+ UNUSED(enable);
+
+ return 0;
+}
+
+int user_set_time(char* date, char* time)
+{
+ UNUSED(date);
+ UNUSED(time);
+
+ return 0;
+}
+
+int lynq_sync_time_from_rtc(void)
+{
+
+ return 0;
+}
+
+int lynq_get_time_src_status (time_src_status_s * time_src)
+{
+ UNUSED(time_src);
+
+ return 0;
+}
+
+int lynq_set_rtc_time(void)
+{
+
+ return 0;
+}
+
+int lynq_get_rtc_time(unsigned long *ulsec)
+{
+ UNUSED(ulsec);
+
+ return 0;
+}
+
diff --git a/mbtk/qser_lib/src/qser_voice_call.c b/mbtk/qser_lib/src/qser_voice_call.c
new file mode 100755
index 0000000..794f8a4
--- /dev/null
+++ b/mbtk/qser_lib/src/qser_voice_call.c
@@ -0,0 +1,75 @@
+
+
+int qser_voice_call_client_init(voice_client_handle_type *ph_voice)
+{
+ UNUSED(ph_voice);
+
+ return 0;
+}
+
+int qser_voice_call_client_deinit(voice_client_handle_type h_voice)
+{
+ UNUSED(h_voice);
+
+ return 0;
+}
+
+int qser_voice_call_start(voice_client_handle_type h_voice,E_QSER_VCALL_ID_T simId,char * phone_number, int *call_id)
+{
+ UNUSED(h_voice);
+ UNUSED(simId);
+ UNUSED(phone_number);
+ UNUSED(call_id);
+
+ return 0;
+}
+
+
+int qser_voice_call_end (voice_client_handle_type h_voice,int call_id)
+{
+ UNUSED(h_voice);
+ UNUSED(call_id);
+
+ return 0;
+}
+
+
+int qser_voice_call_anser(voice_client_handle_type h_voice,int call_id)
+{
+ UNUSED(h_voice);
+ UNUSED(call_id);
+
+ return 0;
+}
+
+int qser_voice_call_addstatehandler(voice_client_handle_type h_voice,QSER_VoiceCall_StateHandlerFunc_t handlerPtr,void* contextPtr)
+{
+ UNUSED(h_voice);
+ UNUSED(handlerPtr);
+ UNUSED(contextPtr);
+
+ return 0;
+}
+
+int qser_voice_call_removestatehandle(voice_client_handle_type h_voice)
+{
+ UNUSED(h_voice);
+
+ return 0;
+}
+
+int qser_voice_set_speech_volume(const int volume)
+{
+ UNUSED(volume);
+
+ return 0;
+}
+
+int qser_voice_get_speech_volume(int *volume)
+{
+ UNUSED(volume);
+
+ return 0;
+}
+
+
diff --git a/mbtk/test/aiti_audio_test.c b/mbtk/test/aiti_audio_test.c
index c9fa936..4e24440 100755
--- a/mbtk/test/aiti_audio_test.c
+++ b/mbtk/test/aiti_audio_test.c
@@ -7,6 +7,7 @@
// #include "ql_at.h"
#include "ql/ql_audio.h"
// #include "mopen_tts.h"
+#ifdef MBTK_PLATFORM_ASR1803
#define MBTK_AUD_DEMO_WAV "/data/demo.wav"
@@ -125,7 +126,7 @@
if (!fp) {
printf("%s:fopen failed",__func__);
}
-
+
fseek(fp,0,SEEK_END);
filesize=ftell(fp);
printf("%s:filesize:%d\n", __func__, filesize);
@@ -180,7 +181,7 @@
pcmBuf = handle_file1(MBTK_AUD_DEMO_WAV);
pcmBuf1 = handle_file1(MBTK_AUD_DEMO_WAV1);
-
+
if(file_size > 0 && file_size1 > 0 )
{
if(pcmBuf != NULL)
@@ -216,7 +217,7 @@
int fd1 = open(MBTK_AUD_DEMO_WAV1, O_RDWR);
if (fd1 <= 0)
return 0;
-
+
Ql_AudPlayer_PlayFrmFile(play_hdl, fd, 0);
Ql_Rxgain_Set(3);
@@ -534,7 +535,13 @@
return 0;
}
+#else
+int main(int argc, char *argv[])
+{
+ return 0;
+}
+#endif
diff --git a/mbtk/test/audio_test.c b/mbtk/test/audio_test.c
index c7cae08..b811307 100755
--- a/mbtk/test/audio_test.c
+++ b/mbtk/test/audio_test.c
@@ -8,6 +8,8 @@
#include "ql/ql_audio.h"
// #include "mopen_tts.h"
+#ifdef MBTK_PLATFORM_ASR1803
+
#define MBTK_AUD_DEMO_WAV "/data/demo.wav"
static int record_fd = 0;
@@ -339,3 +341,12 @@
return 0;
}
+
+#else
+int main(int argc, char *argv[])
+{
+
+ return 0;
+}
+
+#endif
diff --git a/mbtk/test/fb_demo.c b/mbtk/test/fb_demo.c
new file mode 100755
index 0000000..e160edf
--- /dev/null
+++ b/mbtk/test/fb_demo.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "mbtk_log.h"
+#include "mbtk_type.h"
+
+// RGB565
+#define COLOR_BLACK 0x0000
+#define COLOR_WRITE 0xFFFF
+#define DEV_FB_PATH "/dev/fb0"
+#define SCREEN_WIDTH 320
+#define SCREEN_HEIGTH 240
+
+typedef struct {
+ int left;
+ int top;
+ int width;
+ int heigth;
+} rect_t;
+
+static uint16 fb_buffer[SCREEN_WIDTH * SCREEN_HEIGTH];
+
+static int fb_refresh(int fd)
+{
+ rect_t rect;
+ rect.width = SCREEN_WIDTH / 2;
+ rect.heigth = SCREEN_HEIGTH / 2;
+ rect.left = (SCREEN_WIDTH - rect.width) / 2;
+ rect.top = (SCREEN_HEIGTH - rect.heigth) / 2;
+ // Fill in buffer.
+ int x,y;
+ for(y = 0; y < SCREEN_HEIGTH; y++) {
+ for(x = 0; x < SCREEN_WIDTH; x++) {
+ if(x >= rect.left && x <= rect.left + rect.width
+ && y >= rect.top && y <= rect.top + rect.heigth)
+ {
+ fb_buffer[x * SCREEN_HEIGTH + y] = COLOR_WRITE;
+ } else {
+ fb_buffer[x * SCREEN_HEIGTH + y] = COLOR_BLACK;
+ }
+ }
+ }
+
+ int len = write(fd, fb_buffer, sizeof(fb_buffer));
+ LOGD("Write : %d/%d", len, sizeof(fb_buffer));
+ // Write buffer to framebuffer.
+ if(sizeof(fb_buffer) != len) {
+ LOGE("Write fail:%d", errno);
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ if(access(DEV_FB_PATH, F_OK) != 0) {
+ LOGE("no %s, quit.", DEV_FB_PATH);
+ return -1;
+ }
+
+ int fb_fd = open(DEV_FB_PATH, O_RDWR);
+ if(fb_fd < 0) {
+ LOGE("open() fail:%d", errno);
+ return -1;
+ }
+
+ // Fresh framebuffer
+ while(1) {
+ if(fb_refresh(fb_fd)) {
+ break;
+ }
+
+ usleep(33); // 1000 / 30
+ }
+
+ LOGD("Exit");
+ return 0;
+}
+
+
diff --git a/mbtk/test/mbtk_dtmf_test.c b/mbtk/test/mbtk_dtmf_test.c
index a21464e..472e820 100755
--- a/mbtk/test/mbtk_dtmf_test.c
+++ b/mbtk/test/mbtk_dtmf_test.c
@@ -1,3 +1,5 @@
+#ifdef MBTK_PLATFORM_ASR1803
+
/**
* \file dtmf_test.c
* \brief A Documented file.
@@ -33,6 +35,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
+
#include "mbtk_audio.h"
void dtmf_cb(char dtmf)
@@ -92,3 +95,13 @@
return 0;
}
+#else
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+
+ return 0;
+}
+
+#endif
diff --git a/mbtk/test/partition_write_demo.c b/mbtk/test/partition_write_demo.c
new file mode 100755
index 0000000..762e49c
--- /dev/null
+++ b/mbtk/test/partition_write_demo.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int main(int argc, char *argv[])
+{
+
+#if 1
+ // 100K
+ char buffer[102400];
+ long len = -1;
+ long count = 0;
+ int fd = open("/etc/file.temp", O_CREAT | O_WRONLY | O_TRUNC);
+ if(fd < 0) {
+ printf("Open file error:%d\n", errno);
+ return -1;
+ }
+
+ while((len = write(fd, buffer, sizeof(buffer))) > 0){
+ count += len;
+ printf("write : %d\n", count);
+ //usleep(1000);
+ }
+
+ printf("Write complete,len = %d, errno = %d\n", len, errno);
+
+ close(fd);
+#else
+ // 100K
+ int buffer = 1;
+ long len = -1;
+ long count = 0;
+
+ FILE *file = fopen("/etc/file.temp", "w");
+ if(file == NULL) {
+ printf("Open file error:%d\n", errno);
+ return -1;
+ }
+
+ while((len = fwrite(&buffer, sizeof(int), 1,file)) > 0){
+ buffer++;
+
+ // printf("write : %d\n", buffer);
+ //usleep(1000);
+ }
+
+ printf("Write complete,len = %d, errno = %d\n", len, errno);
+
+ fclose(file);
+#endif
+ return 0;
+}
+
diff --git a/mbtk/test/yx_audio_test.c b/mbtk/test/yx_audio_test.c
index e01e9d9..e72d68a 100755
--- a/mbtk/test/yx_audio_test.c
+++ b/mbtk/test/yx_audio_test.c
@@ -8,6 +8,8 @@
#include "ql/ql_audio.h"
// #include "mopen_tts.h"
+#ifdef MBTK_PLATFORM_ASR1803
+
#define MBTK_AUD_DEMO_WAV "/data/demo.wav"
static int record_fd = 0;
@@ -363,3 +365,12 @@
return 0;
}
+#else
+
+int main(int argc, char *argv[])
+{
+
+ return 0;
+}
+
+#endif