Change test makefile.
Change-Id: I27eef2cdb86b220dd03e9be79d5bef7f9303258b
diff --git a/build.sh b/build.sh
index 4fb5275..87667f4 100755
--- a/build.sh
+++ b/build.sh
@@ -127,14 +127,13 @@
file_copy
else
- if [ ! -d out/bin ];then
- mkdir -p out/bin/asr1803
- mkdir -p out/bin/asr1806
- fi
-
if [ ! -d out/lib ];then
mkdir -p out/lib
fi
+
+ if [ ! -d out/bin ];then
+ mkdir -p out/bin
+ fi
build
diff --git a/mbtk/Makefile b/mbtk/Makefile
index 2d3d708..44e3043 100755
--- a/mbtk/Makefile
+++ b/mbtk/Makefile
@@ -9,11 +9,16 @@
DIRS += libql_lib liblynq_lib
# Build bin file.
-DIRS += device_info_generate mbtk_adbd mbtk_rild mbtk_logd
+DIRS += device_info_generate mbtk_adbd mbtk_rild mbtk_logd mbtk_utils
# Build test file.
DIRS += test
+#exclude_dirs := include bin
+#test_dirs := $(shell find test/ -maxdepth 1 -type d)
+#test_dirs := $(basename $(patsubst ./%,%,$(test_dirs)))
+#test_dirs := $(filter-out $(exclude_dirs),$(test_dirs))
+
all:
@echo $(ROOT)
@echo $(CC)
@@ -21,7 +26,7 @@
@for i in $(DIRS); do \
(cd $$i && echo "making $$i" && $(MAKE) ) || exit 1; \
done
- @echo "Success"
+ @echo "Build libs success."
clean:
@for i in $(DIRS); do \
diff --git a/mbtk/mbtk_utils/Makefile b/mbtk/mbtk_utils/Makefile
new file mode 100755
index 0000000..743f28f
--- /dev/null
+++ b/mbtk/mbtk_utils/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../..
+include ../Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/at.c b/mbtk/mbtk_utils/at.c
similarity index 100%
rename from mbtk/test/at.c
rename to mbtk/mbtk_utils/at.c
diff --git a/mbtk/test/device_info.c b/mbtk/mbtk_utils/device_info.c
similarity index 100%
rename from mbtk/test/device_info.c
rename to mbtk/mbtk_utils/device_info.c
diff --git a/mbtk/test/mbtk_mdio.c b/mbtk/mbtk_utils/mbtk_mdio.c
old mode 100644
new mode 100755
similarity index 100%
rename from mbtk/test/mbtk_mdio.c
rename to mbtk/mbtk_utils/mbtk_mdio.c
diff --git a/mbtk/test/mtd_info.c b/mbtk/mbtk_utils/mtd_info.c
similarity index 100%
rename from mbtk/test/mtd_info.c
rename to mbtk/mbtk_utils/mtd_info.c
diff --git a/mbtk/test/Makefile b/mbtk/test/Makefile
index 89ccbdf..28cd0b4 100755
--- a/mbtk/test/Makefile
+++ b/mbtk/test/Makefile
@@ -1,51 +1,24 @@
ROOT = $(shell pwd)/../..
include ../Make.defines
-LOCAL_PATH=$(BUILD_ROOT)/test
+#exclude_dirs := include bin
+#test_dirs := $(shell find . -maxdepth 1 -type d)
+#test_dirs := $(basename $(patsubst ./%,%,$(test_dirs)))
+#test_dirs := $(filter-out $(exclude_dirs),$(test_dirs))
-INC_DIR +=
-
-LIB_DIR +=
-
-LIBS += -lmbtk_lib -llynq_lib -lql_lib -lmbtk_mqtt -laudio-apu -lcutils -ltinyalsa -lacm -lubus -lubox -lmbtk_fota -lmbtk_audio -lmbtk_ril -lmbtk_factory -lmbtk_net -lmbtk_gnss -lmbtk_http -lmbtk_ftp -lmbtk_tcpip \
- -lmbtk_coap
-
-CFLAGS +=
-
-DEFINE +=
-
-MY_FILES_PATH:=$(LOCAL_PATH)
-#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
-
-LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
-ifeq ($(BUILD_PLATFORM), asr1803)
-LOCAL_SRC_FILES += $(wildcard asr1803/*.c) $(wildcard asr1803/*.cpp)
-else
-LOCAL_SRC_FILES += $(wildcard asr1806/*.c) $(wildcard asr1806/*.cpp)
-endif
-
-$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
-
-OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
-BINS = $(patsubst %.o,%,$(OBJS))
-
-all: $(BINS)
-
-$(BINS):$(OBJS)
- @echo " BIN $@"
- $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
-
-%.o:%.c
- $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
-
-%.o:%.cpp
- $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+SUBDIRS := $(wildcard */)
+SUBDIRS_WITH_MAKEFILES := $(foreach dir,$(SUBDIRS),$(if $(wildcard $(dir)Makefile),$(dir),))
+
+all:
+ @echo DIR=$(SUBDIRS_WITH_MAKEFILES)
+ @for dir in $(SUBDIRS_WITH_MAKEFILES); do \
+ echo "Building $$dir"; \
+ $(MAKE) -C $$dir || exit 1; \
+ done
clean:
- rm -f $(OBJS)
+ @echo DIR=$(SUBDIRS_WITH_MAKEFILES)
+ @for i in $(SUBDIRS_WITH_MAKEFILES); do \
+ (cd $$i && echo "Cleaning $$i" && $(MAKE) clean) || exit 1; \
+ done
+ rm -rf $(OUT_DIR)
diff --git a/mbtk/test/asr1803/aiti_audio_test.c b/mbtk/test/asr1803/aiti_audio_test.c
deleted file mode 100755
index 0472c9a..0000000
--- a/mbtk/test/asr1803/aiti_audio_test.c
+++ /dev/null
@@ -1,538 +0,0 @@
-#include "mbtk_type.h"
-#include <fcntl.h>
-#include <stdint.h>
-#include <limits.h>
-#include <termios.h>
-#include <stdarg.h>
-// #include "ql_at.h"
-#include "ql/ql_audio.h"
-// #include "mopen_tts.h"
-
-#define MBTK_AUD_DEMO_WAV "/data/demo.wav"
-
-#define MBTK_AUD_DEMO_WAV1 "/data/demo1.wav"
-
-
-int play_hdl = 0;
-static int record_fd = 0;
-
-
-int Ql_cb_playback(int hdl, int result)
-{
- printf("%s: hdl=%d, result=%d\n\r", __func__, hdl, result);
- if (result == AUD_PLAYER_FINISHED || result == AUD_PLAYER_NODATA)
- {
- printf("%s: play finished\n\r", __func__);
- }
- return 0;
-}
-
-void record_cb_func(int cb_result, char* databuf, unsigned int len)
-{
- int rc;
-
- if(NULL != databuf && len > 0 && record_fd > 0)
- {
- //for debug:save into file
- rc = write(record_fd, databuf, len);
- if (rc < 0) {
- printf("%s: error writing to file!\n", __FUNCTION__);
- } else if (rc < len) {
- printf("%s: wrote less the buffer size!\n", __FUNCTION__);
- }
- }
-}
-
-
-int MBTK_wav_pcm16Le_check(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
- {
- printf("\n%s: cannot read header\n", __FUNCTION__);
- return -1;
- }
-
- printf("hdr.riff_id:%X, hdr.riff_fmt:%X, hdr.fmt_id:%X", hdr.riff_id, hdr.riff_fmt, hdr.fmt_id);
-
- if ((hdr.riff_id != ID_RIFF)
- || (hdr.riff_fmt != ID_WAVE)
- || (hdr.fmt_id != ID_FMT))
- {
- printf("\n%s: is not a riff/wave file\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.audio_format != FORMAT_PCM) || (hdr.fmt_sz != 16)) {
- printf("\n%s: is not pcm format\n", __FUNCTION__);
- return -1;
- }
-
- if (hdr.bits_per_sample != 16) {
- printf("\n%s: is not 16bit per sample\n", __FUNCTION__);
- return -1;
- }
-
- printf("audio_format: %d,num_channels: %d,sample_rate: %d,byte_rate: %d,bits_per_sample: %d data_sz: %d\n",
- hdr.audio_format, hdr.num_channels, hdr.sample_rate, hdr.byte_rate, hdr.bits_per_sample, hdr.data_sz);
-
- return hdr.data_sz;
-}
-
-int MBTK_wav_pcm16Le_set(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- memset(&hdr, 0, sizeof(struct wav_header));
-
- hdr.riff_id = ID_RIFF;
- hdr.riff_fmt = ID_WAVE;
- hdr.fmt_id = ID_FMT;
- hdr.fmt_sz = 16;
- hdr.audio_format = FORMAT_PCM;
- hdr.num_channels = 1;
- hdr.sample_rate = 8000;
- hdr.bits_per_sample = 16;
- hdr.byte_rate = (8000 * 1 * hdr.bits_per_sample) / 8;
- hdr.block_align = (hdr.bits_per_sample * 1) / 8;
- hdr.data_id = ID_DATA;
- hdr.data_sz = 0;
-
- hdr.riff_sz = hdr.data_sz + 44 - 8;
- if (write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- return -1;
- }
-
- return 0;
-}
-
-unsigned char* handle_file1(char *audioFilePath)
-{
- long filesize;
- unsigned char *pcmBuf = NULL;
- FILE *fp = NULL;
- int size;
-
- // 处理文件格式
- fp = fopen(audioFilePath, "rb");
- if (!fp) {
- printf("%s:fopen failed",__func__);
- }
-
- fseek(fp,0,SEEK_END);
- filesize=ftell(fp);
- printf("%s:filesize:%d\n", __func__, filesize);
- fseek(fp,44,SEEK_SET);
- pcmBuf =(unsigned char *)malloc(sizeof(char)*filesize);
- memset(pcmBuf,0,sizeof(char)*filesize);
-// fread(pcmBuf, filesize-44,1, fp);
- fread(pcmBuf, 1, filesize-44, fp);
- fclose(fp);
-
- printf("strlen(pcmBuf):%d\n", strlen(pcmBuf));
-
- return pcmBuf;
-}
-
-void *audio_thread(void *arg)
-{
- printf("audio_thread(1)----------\n");
- Ql_Playback_Samprate_Set(1);
- int play_hdl = 0;
- int fd = 0;
- int ret;
- int file_size =0;
- int file_size1 =0;
- unsigned char *pcmBuf = NULL;
- unsigned char *pcmBuf1 = NULL;
-
- play_hdl = Ql_AudPlayer_Open(NULL, Ql_cb_playback);
- if(0 == play_hdl)
- {
- printf("Ql_AudPlayer_Open fail\n");
- }
-
- fd = open(MBTK_AUD_DEMO_WAV, O_RDWR);
- if (fd <= 0)
- {
- printf("Open fail\n");
- }
-
- int fd1 = open(MBTK_AUD_DEMO_WAV1, O_RDWR);
- printf("fd1:%d\n", fd1);
- if (fd1 <= 0)
- {
- printf("Open fail\n");
- }
-
- file_size = MBTK_wav_pcm16Le_check(fd);
-
- file_size1 = MBTK_wav_pcm16Le_check(fd1);
- printf("file_size:%d, file_size1:%d\n", file_size, file_size1);
-
- pcmBuf = handle_file1(MBTK_AUD_DEMO_WAV);
-
- pcmBuf1 = handle_file1(MBTK_AUD_DEMO_WAV1);
-
- if(file_size > 0 && file_size1 > 0 )
- {
- if(pcmBuf != NULL)
- {
- ret = Ql_AudPlayer_Play(play_hdl, pcmBuf, file_size);
- printf("ret:%d\n", ret);
- }
-
- Ql_Rxgain_Set(3);
- if(pcmBuf1 != NULL)
- {
- ret = Ql_AudPlayer_Play(play_hdl, pcmBuf1, file_size1);
- printf("ret:%d\n", ret);
- }
-
- }
-
- Ql_AudPlayer_Close(play_hdl);
- close(fd);
- close(fd1);
- return 0;
-}
-
-
-void *audio_play_file_thread(void *arg)
-{
- char operator[10];
-
- int fd = open(MBTK_AUD_DEMO_WAV, O_RDWR);
- if (fd <= 0)
- return 0;
-
- 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);
-
- Ql_AudPlayer_PlayFrmFile(play_hdl, fd1, 0);
-
- close(fd);
- close(fd1);
-
- return 0;
-}
-
-
-int aplay_thread(char *audioFilePath)
-{
- int res;
- pthread_t play_thread;
-
- res = pthread_create(&play_thread, NULL, audio_thread, audioFilePath);
- if (res != 0) {
- printf("%s:pthread_create failed",__func__);
- return 0;
- }
-
- return 0;
-}
-
-
-int aplay_file_thread(int play_hdl)
-{
- int res;
- pthread_t play_thread;
- int hdl = play_hdl;
-
- res = pthread_create(&play_thread, NULL, audio_play_file_thread, &hdl);
- if (res != 0) {
- printf("%s:pthread_create failed",__func__);
- return 0;
- }
-
- return 0;
-}
-
-
-
-void aplay(void)
-{
- char operator[10];
- char databuf[1024];
- int opt = 0;
- int fd = 0;
- int size = 0;
- int state;
- int handler = 0;
- int file_size = 0 ;
-
- while(1)
- {
- printf("=========aplay========2\n"
- "\t 0 Open PCM\n"
- "\t 1 Play Stream\n"
- "\t 2 Play file\n"
- "\t 3 Close\n"
- "\t 4 play stream thread\n"
- "\t 5 pause\n"
- "\t 6 repause\n"
- "\t 7 play file thread\n"
- "\t 8 play mp3\n"
- "\t others exit\n\n"
- "operator >> ");
-
- fflush(stdin);
- fgets(operator, sizeof(operator), stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- Ql_Playback_Samprate_Set(1);
- play_hdl = Ql_AudPlayer_Open(NULL, Ql_cb_playback);
- if(0 == play_hdl)
- printf("Ql_AudPlayer_Open fail\n");
-
- printf("\nplay_hdl:%d\n", play_hdl);
- break;
- case 1:
- if(0 == play_hdl)
- continue;
-
- fd = open(MBTK_AUD_DEMO_WAV, O_RDWR);
- if (fd <= 0)
- continue;
-
- file_size = MBTK_wav_pcm16Le_check(fd);
- printf("file_size:%d\n", file_size);
- if(file_size > 0 )
- {
- unsigned char *pcmBuf = NULL;
- char *p1 = pcmBuf;
- pcmBuf = handle_file1(MBTK_AUD_DEMO_WAV);
- if(pcmBuf != NULL)
- {
- if(-1 == Ql_AudPlayer_Play(play_hdl, pcmBuf, file_size))
- printf("\n------\n");
- }
-
- }
-
-// Ql_Rxgain_Set(5);
-
- close(fd);
- break;
- case 2:
- if(0 == play_hdl)
- continue;
-
- fd = open(MBTK_AUD_DEMO_WAV, O_RDWR);
- if (fd <= 0)
- continue;
-
- if(1)
- {
- Ql_AudPlayer_PlayFrmFile(play_hdl, fd, 44);
- }
- else
- {
- printf("aplay file type error\n");
- }
- close(fd);
- break;
- case 3:
- if(0 == play_hdl)
- continue;
- Ql_AudPlayer_Close(play_hdl);
- break;
- case 4:
- aplay_thread(MBTK_AUD_DEMO_WAV);
- break;
- case 5:
- if(0 == play_hdl)
- continue;
- Ql_AudPlayer_Pause(play_hdl);
- break;
- case 6:
- if(0 == play_hdl)
- continue;
- Ql_AudPlayer_Resume(play_hdl);
- break;
- case 7:
- if(0 == play_hdl)
- continue;
- aplay_file_thread(play_hdl);
- break;
- case 8:
- // Ql_Mp3_To_Wav("/data/demo.wav", "/data/mp3demo.mp3", play_hdl);
- Ql_Mp3_To_Play("/data/mp3demo.mp3", play_hdl, 0);
- break;
- default:
- return;
- }
-
- sleep(1);
- }
-
- printf("aplay exit\n");
- return ;
-}
-void arec(void)
-{
- int ret;
- char operator[10];
- int opt;
- int hdl = 0;
-
- while(1)
- {
- printf("=======arec======\n"
- "\t 0 Open PCM\n"
- "\t 1 Start Record\n"
- "\t 2 Get state\n"
- "\t 3 Pause\n"
- "\t 4 Resume\n"
- "\t 5 Stop\n"
- "\t 6 Close\n"
- "\t others exit\n\n"
- "operator >> ");
-
- fflush(stdin);
- fgets(operator, sizeof(operator), stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- Ql_Playback_Samprate_Set(0);
- hdl = Ql_AudRecorder_Open(NULL, record_cb_func);
- if (hdl == 0)
- return ;
- break;
- case 1:
- if(0 == hdl)
- {
- printf("audio is not initialized yet.\n");
- continue;
- }
-
- if(0 != record_fd)
- {
- printf("audio It's already being recorded.\n");
- continue;
- }
- record_fd = open(MBTK_AUD_DEMO_WAV, O_RDWR|O_CREAT|O_TRUNC, 0644);
- if (record_fd <= 0)
- printf("file open error\n");
-
- if(0 == MBTK_wav_pcm16Le_set(record_fd))
- {
- ret = Ql_AudRecorder_StartRecord();
- if(0 != ret)
- {
- printf("audio record error: %d\n", ret);
- close(record_fd);
- record_fd = 0;
- }
- }
- else
- {
- printf("arec set file header error\n");
- close(record_fd);
- record_fd = 0;
- }
- break;
- case 2:
- // printf("arec state : %d\n", state);
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- break;
- case 6:
- Ql_AudRecorder_Close();
- if(record_fd > 0)
- {
- close(record_fd);
- record_fd = 0;
- }
- break;
- default:
- return;
- }
-
- sleep(1);
- }
-
- printf("arec exit\n");
- return ;
-}
-int main(void)
-{
- char operator[10];
- int opt;
-
-// printf("Ql_Mp3_To_Wav()\n");
-// mbtk_audio_mp3_to_wav("/data/demo.wav", "/data/mp3demo.mp3");
- // Ql_Mp3_To_Wav("/data/demo.wav", "/data/mp3demo.mp3");
-
- while(1)
- {
- printf("=========audio main=========\n"
- "\t0 exit\n"
- "\t1 aplay\n"
- "\t2 arec\n"
- "\t3 set speaker Volume\n"
- "\t4 get speaker Volume\n"
- "\t5 set mic Volume\n"
- "\t6 get mic Volume\n"
- "\t7 tts\n"
- "\t8 tone\n"
- "operator: >> ");
-
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- aplay();
- break;
- case 2:
- arec();
- break;
- case 3:
- mbtk_at_rec(NULL);
- break;
- case 4:
- mbtk_at_play(NULL);
- break;
- case 5:
- break;
- case 6:
- break;
- case 7:
- break;
- case 8:
- break;
- default:
- break;
- }
-
- sleep(1);
- }
-
- return 0;
-}
-
-
diff --git a/mbtk/test/asr1803/audio_play_test.c b/mbtk/test/asr1803/audio_play_test.c
deleted file mode 100755
index a954734..0000000
--- a/mbtk/test/asr1803/audio_play_test.c
+++ /dev/null
@@ -1,213 +0,0 @@
-#include "mbtk_type.h"
-#include <fcntl.h>
-#include <stdint.h>
-#include <limits.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include "ql/ql_audio.h"
-
-static pthread_t play_thread_play;
-int play_hdl = 0;
-int handler = 0;
-int fd = -1;
-
-int Ql_cb_playback(int hdl, int result)
-{
- // printf("%s: hdl=%d, result=%d\n\r", __func__, hdl, result);
- if (result == AUD_PLAYER_FINISHED || result == AUD_PLAYER_NODATA)
- {
- printf("%s: play finished\n\r", __func__);
- }
- return 0;
-}
-
-
-void dtmf_cb1(char dtmf)
-{
- printf("%s:%c\n", __FUNCTION__, dtmf);
-}
-
-int MBTK_wav_pcm16Le_check(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
- {
- printf("\n%s: cannot read header\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.riff_id != ID_RIFF)
- || (hdr.riff_fmt != ID_WAVE)
- || (hdr.fmt_id != ID_FMT))
- {
- printf("\n%s: is not a riff/wave file\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.audio_format != FORMAT_PCM) || (hdr.fmt_sz != 16)) {
- printf("\n%s: is not pcm format\n", __FUNCTION__);
- return -1;
- }
-
- if (hdr.bits_per_sample != 16) {
- printf("\n%s: is not 16bit per sample\n", __FUNCTION__);
- return -1;
- }
-
- return 0;
-}
-
-int MBTK_wav_pcm16Le_set(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- memset(&hdr, 0, sizeof(struct wav_header));
-
- hdr.riff_id = ID_RIFF;
- hdr.riff_fmt = ID_WAVE;
- hdr.fmt_id = ID_FMT;
- hdr.fmt_sz = 16;
- hdr.audio_format = FORMAT_PCM;
- hdr.num_channels = 1;
- hdr.sample_rate = 8000;
- hdr.bits_per_sample = 16;
- hdr.byte_rate = (8000 * 1 * hdr.bits_per_sample) / 8;
- hdr.block_align = (hdr.bits_per_sample * 1) / 8;
- hdr.data_id = ID_DATA;
- hdr.data_sz = 0;
-
- hdr.riff_sz = hdr.data_sz + 44 - 8;
- if (write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- return -1;
- }
-
- return 0;
-}
-
-static void audio_play_thread(void *arg)
-{
- Ql_AudPlayer_PlayFrmFile(play_hdl, fd, 0);
-}
-
-
-int main(int argc, char* argv[])
-{
- if(argc != 2) {
- printf("audio_play_test <wav_file>\n");
- return -1;
- }
-
- struct stat st;
- const char *path = (const char *)argv[1];
- // mbtk_log_init("radio", "MBTK_AUDIO");
-
- /* Check and open source file */
- if (access(path, F_OK) || stat(path, &st)) {
- printf("%s: error reading from file %s\n", __FUNCTION__, path);
- return -1;
- }
-
- if (!st.st_size) {
- printf("%s: empty file %s\n", __FUNCTION__, path);
- return -1;
- }
-
- printf("1\n");
- mbtk_audio_ubus_client_init(&handler, dtmf_cb1);
- printf("2\n");
- mbtk_audio_switch_pcm(1);
- printf("3\n");
- mbtk_audio_mode_set(2);
- printf("4\n");
- play_hdl = Ql_AudPlayer_Open(NULL, Ql_cb_playback);
- printf("5\n");
- if(0 == play_hdl) {
- printf("Ql_AudPlayer_Open fail\n");
- return -1;
- }
-
- char cmd[100];
- bool running = TRUE;
- printf("6\n");
- while(running)
- {
- memset(cmd, 0, 100);
- int err;
- printf("1 : Play Other : Exit\n");
- if(fgets(cmd, 100, stdin))
- {
- if(cmd[0] == '\r' || cmd[0] == '\n')
- continue;
- int state = atoi(cmd);
- switch(state){
- case 1:
- {
- if(0 == play_hdl)
- break;
- fd = open(argv[1], O_RDONLY);
- if (fd <= 0) {
- printf("Open file fail.\n");
- goto exit;
- }
-
- mbtk_audio_path_enable(1);
- if(0 == MBTK_wav_pcm16Le_check(fd))
- {
- pthread_attr_t thread_attr;
- pthread_attr_init(&thread_attr);
- if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
- {
- printf("pthread_attr_setdetachstate() fail.\n");
- goto exit;
- }
-
- if (pthread_create(&play_thread_play, NULL, (void *)&audio_play_thread, NULL) < 0) {
- printf("%s: error creating thread_play!\n", __FUNCTION__);
- goto exit;
- }
-
- printf("Start play audio...\n");
- }
- else
- {
- printf("aplay file type error\n");
- goto exit;
- }
- break;
- }
- default:
- {
- if(0 == play_hdl)
- break;
- Ql_AudPlayer_Close(play_hdl);
- running = FALSE;
- break;
- }
- }
- }
- }
-
-exit:
- if(fd > 0) {
- close(fd);
- }
- mbtk_audio_path_enable(0);
-
- mbtk_audio_mode_set(0);
- mbtk_audio_switch_pcm(0);
-
-
- printf("Success exit.\n");
- return 0;
-}
-
diff --git a/mbtk/test/asr1803/audio_test.c b/mbtk/test/asr1803/audio_test.c
deleted file mode 100755
index d8121ee..0000000
--- a/mbtk/test/asr1803/audio_test.c
+++ /dev/null
@@ -1,342 +0,0 @@
-#include "mbtk_type.h"
-#include <fcntl.h>
-#include <stdint.h>
-#include <limits.h>
-#include <termios.h>
-#include <stdarg.h>
-// #include "ql_at.h"
-#include "ql/ql_audio.h"
-// #include "mopen_tts.h"
-
-#define MBTK_AUD_DEMO_WAV "/data/demo.wav"
-
-static int record_fd = 0;
-
-int Ql_cb_playback(int hdl, int result)
-{
- printf("%s: hdl=%d, result=%d\n\r", __func__, hdl, result);
- if (result == AUD_PLAYER_FINISHED || result == AUD_PLAYER_NODATA)
- {
- printf("%s: play finished\n\r", __func__);
- }
- return 0;
-}
-
-void record_cb_func(int cb_result, char* databuf, unsigned int len)
-{
- int rc;
-
- if(NULL != databuf && len > 0 && record_fd > 0)
- {
- //for debug:save into file
- rc = write(record_fd, databuf, len);
- if (rc < 0) {
- printf("%s: error writing to file!\n", __FUNCTION__);
- } else if (rc < len) {
- printf("%s: wrote less the buffer size!\n", __FUNCTION__);
- }
- }
-}
-int MBTK_wav_pcm16Le_check(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
- {
- printf("\n%s: cannot read header\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.riff_id != ID_RIFF)
- || (hdr.riff_fmt != ID_WAVE)
- || (hdr.fmt_id != ID_FMT))
- {
- printf("\n%s: is not a riff/wave file\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.audio_format != FORMAT_PCM) || (hdr.fmt_sz != 16)) {
- printf("\n%s: is not pcm format\n", __FUNCTION__);
- return -1;
- }
-
- if (hdr.bits_per_sample != 16) {
- printf("\n%s: is not 16bit per sample\n", __FUNCTION__);
- return -1;
- }
-
- return 0;
-}
-
-int MBTK_wav_pcm16Le_set(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- memset(&hdr, 0, sizeof(struct wav_header));
-
- hdr.riff_id = ID_RIFF;
- hdr.riff_fmt = ID_WAVE;
- hdr.fmt_id = ID_FMT;
- hdr.fmt_sz = 16;
- hdr.audio_format = FORMAT_PCM;
- hdr.num_channels = 1;
- hdr.sample_rate = 8000;
- hdr.bits_per_sample = 16;
- hdr.byte_rate = (8000 * 1 * hdr.bits_per_sample) / 8;
- hdr.block_align = (hdr.bits_per_sample * 1) / 8;
- hdr.data_id = ID_DATA;
- hdr.data_sz = 0;
-
- hdr.riff_sz = hdr.data_sz + 44 - 8;
- if (write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- return -1;
- }
-
- return 0;
-}
-void aplay(void)
-{
- char operator[10];
- char databuf[1024];
- int opt = 0;
- int fd = 0;
- int size = 0;
- int state;
- int play_hdl = 0;
-
- while(1)
- {
- printf("=========aplay========\n"
- "\t 0 Open PCM\n"
- "\t 1 Play Stream\n"
- "\t 2 Play file\n"
- "\t 3 play mp3\n"
- "\t 4 Close Player\n"
- "\t 5 exit\n"
- "\t others exit\n\n"
- "operator >> ");
-
- fflush(stdin);
- fgets(operator, sizeof(operator), stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- play_hdl = Ql_AudPlayer_Open(NULL, Ql_cb_playback);
- if(0 == play_hdl)
- printf("Ql_AudPlayer_Open fail\n");
- break;
- case 1:
- if(0 == play_hdl)
- continue;
-
- fd = open(MBTK_AUD_DEMO_WAV, O_RDWR);
- if (fd <= 0)
- continue;
-
- if(0 == MBTK_wav_pcm16Le_check(fd))
- {
- memset(databuf, 0, sizeof(databuf));
- while(0 < (size = read(fd, databuf, sizeof(databuf))))
- {
- // Ql_Rxgain_Set(2);
- if(-1 == Ql_AudPlayer_Play(play_hdl, databuf, size))
- break;
- }
- printf("aplay Stream end \n");
- }
-
- close(fd);
- break;
- case 2:
- if(0 == play_hdl)
- continue;
-
- fd = open(MBTK_AUD_DEMO_WAV, O_RDWR);
- if (fd <= 0)
- continue;
-
- if(0 == MBTK_wav_pcm16Le_check(fd))
- {
- Ql_Rxgain_Set(11);
- Ql_AudPlayer_PlayFrmFile(play_hdl, fd, 0);
- }
- else
- {
- printf("aplay file type error\n");
- }
- close(fd);
- break;
- case 3:
- // aplay_thread(MBTK_AUD_DEMO_WAV);
- Ql_Rxgain_Set(11);
- Ql_Mp3_To_Play("/data/mp3demo.mp3", play_hdl, 0);
- break;
- case 4:
- if(0 == play_hdl)
- continue;
- Ql_AudPlayer_Close(play_hdl);
- break;
- case 5:
- default:
- return;
- }
-
- sleep(1);
- }
-
- printf("aplay exit\n");
- return ;
-}
-void arec(void)
-{
- int ret;
- char operator[10];
- int opt;
- int hdl = 0;
-
- while(1)
- {
- printf("=======arec======\n"
- "\t 0 Open PCM\n"
- "\t 1 Start Record\n"
- // "\t 2 Get state\n"
- // "\t 3 Pause\n"
- // "\t 4 Resume\n"
- // "\t 5 Stop\n"
- "\t 2 Stop/Close Recorder\n"
- "\t others exit\n\n"
- "operator >> ");
-
- fflush(stdin);
- fgets(operator, sizeof(operator), stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- hdl = Ql_AudRecorder_Open(NULL, record_cb_func);
- if (hdl == 0)
- return ;
- break;
- case 1:
- if(0 == hdl)
- {
- printf("audio is not initialized yet.\n");
- continue;
- }
-
- if(0 != record_fd)
- {
- printf("audio It's already being recorded.\n");
- continue;
- }
- record_fd = open(MBTK_AUD_DEMO_WAV, O_RDWR|O_CREAT|O_TRUNC, 0644);
- if (record_fd <= 0)
- printf("file open error\n");
-
- if(0 == MBTK_wav_pcm16Le_set(record_fd))
- {
- ret = Ql_AudRecorder_StartRecord();
- if(0 != ret)
- {
- printf("audio record error: %d\n", ret);
- close(record_fd);
- record_fd = 0;
- }
- }
- else
- {
- printf("arec set file header error\n");
- close(record_fd);
- record_fd = 0;
- }
- break;
- case 2:
- Ql_AudRecorder_Close();
- if(record_fd > 0)
- {
- close(record_fd);
- record_fd = 0;
- }
- break;
- case 3:
- // break;
- case 4:
- // break;
- case 5:
- // break;
- case 6:
- // break;
- default:
- return;
- }
-
- sleep(1);
- }
-
- printf("arec exit\n");
- return ;
-}
-int main(void)
-{
- char operator[10];
- int opt;
-
- while(1)
- {
- printf("=========audio main=========\n"
- "\t0 exit\n"
- "\t1 Ql_aplay\n"
- "\t2 Ql_arec\n"
- "\t3 audio record\n"
- "\t4 player stream\n"
- // "\t5 set mic Volume\n"
- // "\t6 get mic Volume\n"
- // "\t7 tts\n"
- // "\t8 tone\n"
- "operator: >> ");
-
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- aplay();
- break;
- case 2:
- arec();
- break;
- case 3:
- mbtk_at_rec(NULL);
- break;
- case 4:
- mbtk_at_play(NULL);
- break;
- case 5:
- break;
- case 6:
- break;
- case 7:
- break;
- case 8:
- break;
- default:
- break;
- }
-
- sleep(1);
- }
-
- return 0;
-}
-
diff --git a/mbtk/test/asr1803/audio_test_yx.c b/mbtk/test/asr1803/audio_test_yx.c
deleted file mode 100755
index dd9aec5..0000000
--- a/mbtk/test/asr1803/audio_test_yx.c
+++ /dev/null
@@ -1,249 +0,0 @@
-#include "mbtk_type.h"
-#include <fcntl.h>
-#include <stdint.h>
-#include <limits.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <pthread.h>
-#include <signal.h>
-#include <sys/stat.h>
-
-#include "ql/ql_audio.h"
-
-int handler = 0;
-int s_play_hdl = -1;
-int s_play_fd = -1;
-static pthread_t play_thread_play;
-
-#define PROMPT_START_RECORD "/bin/start_record_test.wav"
-#define RECORD_FILEPATH "/usrdata/test.wav"
-#define PROMPT_START_PLAY "/bin/start_play_test.wav"
-#define PROMPT_TEST_FINISH "/bin/test_end_test.wav"
-
-#if 1
-void dtmf_cb1(char dtmf)
-{
- printf("%s:%c\n", __FUNCTION__, dtmf);
-}
-#endif
-
-int Ql_cb_playback(int hdl, int result)
-{
- printf("%s: hdl=%d, result=%d\n\r", __func__, hdl, result);
- if (result == AUD_PLAYER_FINISHED || result == AUD_PLAYER_NODATA)
- {
- printf("%s: play finished\n\r", __func__);
- }
- return 0;
-}
-
-int MBTK_wav_pcm16Le_check(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
- {
- printf("\n%s: cannot read header\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.riff_id != ID_RIFF) || (hdr.riff_fmt != ID_WAVE) || (hdr.fmt_id != ID_FMT))
- {
- printf("\n%s: is not a riff/wave file\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.audio_format != FORMAT_PCM) || (hdr.fmt_sz != 16))
- {
- printf("\n%s: is not pcm format\n", __FUNCTION__);
- return -1;
- }
-
- if (hdr.bits_per_sample != 16)
- {
- printf("\n%s: is not 16bit per sample\n", __FUNCTION__);
- return -1;
- }
-
- return 0;
-}
-
-int PLT_Audio_StartPlay(char *filePath, int repeat_value)
-{
- s_play_hdl = Ql_AudPlayer_Open(NULL, Ql_cb_playback);
- if (0 == s_play_hdl) {
- printf("Ql_AudPlayer_Open Failed...\n");
- return -2;
- }
-
- s_play_fd = open(filePath, O_RDWR);
- if (s_play_fd <= 0){
- printf(" Open wavFilePath Failed\n");
- return -3 ;
- }
-
- mbtk_audio_path_enable(1);
- if (0 == MBTK_wav_pcm16Le_check(s_play_fd)) {
- Ql_AudPlayer_PlayFrmFile(s_play_hdl, s_play_fd, 0);
- } else {
- printf("aplay FileType error...\n");
- close(s_play_fd);
- return -4;
- }
- close(s_play_fd);
- mbtk_audio_path_enable(0);
- Ql_AudPlayer_Close(s_play_hdl);
- s_play_hdl = -1;
-
- printf("aplay End...\n");
- return 0;
-}
-
-static void audio_play_thread(void *arg)
-{
- PLT_Audio_StartPlay((char*)arg, 1);
-}
-
-static void sig_handler(int sig)
-{
- if(s_play_hdl > 0) {
- Ql_AudPlayer_Stop(s_play_hdl);
- if (pthread_join(play_thread_play, NULL)) {
- printf("error join play_recorder!\n");
- }
-
- mbtk_audio_mode_set(-2);
- mbtk_audio_switch_pcm(0);
- mbtk_audio_ubus_client_deinit(handler);
- }
-
- printf("Success exit by signal...\n");
- exit(0);
-}
-
-
-int main(int argc, char* argv[])
-{
- if(argc != 2) {
- printf("audio_play_test <wav_file>\n");
- return -1;
- }
-
- struct stat st;
- const char *path = (const char *)argv[1];
- // mbtk_log_init("radio", "MBTK_AUDIO");
-
- /* Check and open source file */
- if (access(path, F_OK) || stat(path, &st)) {
- printf("%s: error reading from file %s\n", __FUNCTION__, path);
- return -1;
- }
-
- if (!st.st_size) {
- printf("%s: empty file %s\n", __FUNCTION__, path);
- return -1;
- }
-
- signal(SIGINT, sig_handler);
- signal(SIGTERM, sig_handler);
- signal(SIGTSTP, sig_handler);
-
- mbtk_audio_ubus_client_init(&handler, dtmf_cb1);
- mbtk_audio_switch_pcm(1);
- mbtk_audio_mode_set(2);
-
- char cmd[100];
- bool running = TRUE;
- while(running)
- {
- memset(cmd, 0, 100);
- int err;
- printf("1 : Play 2 : Pause 3 : Resume 4 : Stop Other : Exit\n");
- if(fgets(cmd, 100, stdin))
- {
- if(cmd[0] == '\r' || cmd[0] == '\n')
- continue;
- int state = atoi(cmd);
- switch(state){
- case 1:
- {
- if(s_play_hdl > 0) {
- break;
- }
- pthread_attr_t thread_attr;
- pthread_attr_init(&thread_attr);
- if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
- {
- printf("pthread_attr_setdetachstate() fail.\n");
- goto exit;
- }
-
- if (pthread_create(&play_thread_play, NULL, (void *)&audio_play_thread, path) < 0) {
- printf("%s: error creating thread_play!\n", __FUNCTION__);
- goto exit;
- }
-
- printf("Start play audio...\n");
- break;
- }
- case 2:
- {
- if(s_play_hdl <= 0) {
- break;
- }
- Ql_AudPlayer_Pause(s_play_hdl);
- printf("Audio pause.\n");
- break;
- }
- case 3:
- {
- if(s_play_hdl <= 0) {
- break;
- }
- Ql_AudPlayer_Resume(s_play_hdl);
- printf("Audio resume.\n");
- break;
- }
- case 4:
- {
- if(s_play_hdl <= 0) {
- break;
- }
- Ql_AudPlayer_Stop(s_play_hdl);
- if (pthread_join(play_thread_play, NULL)) {
- printf("error join play_thread!\n");
- }
- s_play_hdl = -1;
- printf("Audio stop.\n");
- break;
- }
- default:
- {
- running = FALSE;
- if(s_play_hdl <= 0) {
- break;
- }
- Ql_AudPlayer_Stop(s_play_hdl);
- if (pthread_join(play_thread_play, NULL)) {
- printf("error join play_thread!\n");
- }
- }
- }
- }
- }
-
-exit:
-
- mbtk_audio_mode_set(-2);
- mbtk_audio_switch_pcm(0);
- mbtk_audio_ubus_client_deinit(handler);
-
- printf("Success exit.\n");
- return 0;
-}
-
diff --git a/mbtk/test/asr1803/mbtk_audio_set.c b/mbtk/test/asr1803/mbtk_audio_set.c
deleted file mode 100755
index 77ce01a..0000000
--- a/mbtk/test/asr1803/mbtk_audio_set.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "mbtk_audio.h"
-#include <stdlib.h>
-
-static void help(int tag)
-{
- printf("TAG : %d\n", tag);
- printf("./mbtk_gain_set tx_codec/tx_dsp [gain]\n");
- printf("./mbtk_gain_set rx_codec/rx_dsp [gain0] [value1] [gain2] [value3] [gain4] [value5] [gain6] [value7] [gain8] [value9] [value10]\n");
- printf("./mbtk_gain_set reg [addr] [value]\n");
-}
-
-int main(int argc,char *argv[])
-{
- int handler = 0;
-
- if(argc < 3)
- {
- help(0);
- return -1;
- }
-
- if(strcmp(argv[1], "reg") && strcmp(argv[1], "tx_codec")
- && strcmp(argv[1], "tx_dsp") && strcmp(argv[1], "rx_codec")
- && strcmp(argv[1], "rx_dsp")) {
- help(1);
- return -1;
- }
-
- if(strcmp(argv[1], "reg") == 0 && argc != 4) {
- help(2);
- return -1;
- }
-
- if(strcmp(argv[1], "tx_codec") == 0 && argc != 3) {
- help(3);
- return -1;
- }
-
- if(strcmp(argv[1], "tx_dsp") == 0 && argc != 3) {
- help(4);
- return -1;
- }
-
- if(strcmp(argv[1], "rx_codec") == 0 && argc != 13) {
- help(5);
- return -1;
- }
-
- if(strcmp(argv[1], "rx_dsp") == 0 && argc != 13) {
- help(6);
- return -1;
- }
-
- if(mbtk_audio_ubus_client_init(&handler, NULL)) {
- printf("mbtk_audio_ubus_client_init fail.\n");
- return -1;
- }
-
- if(strcmp(argv[1], "tx_codec") == 0 || strcmp(argv[1], "tx_dsp") == 0) {
- unsigned short gain[1];
-
- gain[0] = (unsigned short)strtoul(argv[2], 0, 0);
-
- printf("Type:%s, gain:%d(0x%04x)\n", argv[1], gain[0], gain[0]);
-
- if(strcmp(argv[1], "tx_codec") == 0) {
- mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_TX_CODECGAIN, gain, 1);
- } else {
- mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_TX_DSPGAIN, gain, 1);
- }
- } else if(strcmp(argv[1], "rx_codec") == 0 || strcmp(argv[1], "rx_dsp") == 0) {
- unsigned short gain[11];
-
- printf("Type:%s\n", argv[1]);
-
- int i = 0;
- for(;i < 11; i++) {
- gain[i] = (unsigned short)strtoul(argv[2 + i], 0, 0);
- printf("Gain[%d%%]:%d(0x%04x)\n", i * 10, gain[i], gain[i]);
- }
-
- if(strcmp(argv[1], "rx_codec") == 0) {
- mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_RX_CODECGAIN, gain, 11);
- } else {
- mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_RX_DSPGAIN, gain, 11);
- }
- } else if(strcmp(argv[1], "reg") == 0) {
- int value[2];
- value[0] = (unsigned int)strtoul(argv[2], 0, 0);
- value[1] = (unsigned int)strtoul(argv[3], 0, 0);
- mbtk_audio_ubus_reg_set(value[0], value[1]);
- }
-
- if(mbtk_audio_ubus_client_deinit(handler)) {
- printf("mbtk_audio_ubus_client_init fail.\n");
- return -1;
- }
-
- return 0;
-}
-
diff --git a/mbtk/test/asr1803/mbtk_dtmf_test.c b/mbtk/test/asr1803/mbtk_dtmf_test.c
deleted file mode 100755
index 7dd055f..0000000
--- a/mbtk/test/asr1803/mbtk_dtmf_test.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * \file dtmf_test.c
- * \brief A Documented file.
- *
- * Detailed description
- * \Author: js.wang <js.wang@mobiletek.cn>
- * \Version: 1.0.0
- * \Date: 2022-03-31
- */
-
-/******************************************************************************\
- * Include files
-\******************************************************************************/
-#include <pthread.h>
-#include <time.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <poll.h>
-#include <stdlib.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "mbtk_audio.h"
-
-void dtmf_cb(char dtmf)
-{
- printf("%s:%c\n", __FUNCTION__, dtmf);
-}
-
-void audio_volume_cb(int volume)
-{
- printf("%s:%d\n", __FUNCTION__, volume);
-}
-
-int main(int argc, char *argv[])
-{
- char operator[10];
- int opt;
- mbtk_audio_client_handle_type dtmf_handle;
-
-
- while(1)
- {
- printf("=========audio main=========\n"
- "\t0 exit\n"
- "\t1 audio init\n"
- "\t2 audio get volume\n"
- "\t3 audio set volume\n"
- "\t4 audio deinit\n"
- "operator: >> ");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- mbtk_audio_ubus_client_init(&dtmf_handle, dtmf_cb);
- break;
- case 2:
- mbtk_audio_ubus_volume_get(audio_volume_cb);
- break;
- case 3:
- printf("please input volume (0~100): \n");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- mbtk_audio_ubus_volume_set(opt);
- break;
- case 4:
- mbtk_audio_ubus_client_deinit(dtmf_handle);
- break;
- default:
- break;
- }
- }
-
- return 0;
-}
-
diff --git a/mbtk/test/asr1803/ubus_cli_demo.c b/mbtk/test/asr1803/ubus_cli_demo.c
deleted file mode 100755
index 0b689c9..0000000
--- a/mbtk/test/asr1803/ubus_cli_demo.c
+++ /dev/null
@@ -1,163 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <libubox/blobmsg_json.h>
-#include "libubus.h"
-
-#include "audio_if_parameter.h"
-//#include <include/audio_if.h>
-//#include <include/audio_if_types.h>
-//#include <include/audio_if_ubus.h>
-
-#define LOG(fmt, args...) \
- do{ \
- printf("%s#%d: " fmt "\n", __FUNCTION__, __LINE__, ##args); \
- } while(0)
-
-//User task
-static pthread_t APP_MainLoopTask;
-
-/**********************************************************************\
-* APP Global Variables for uBus
-\**********************************************************************/
-#define AUDIO_UBUS_ID "audio_if"
-#define AUDIO_UBUS_AUDIO_GAIN_SET "audio_gain_set"
-
-static struct ubus_context *APP_ctx = NULL;
-static uint32_t APP_audio_request_id;
-static struct blob_buf audio_cm_b;
-
-
-/**********************************************************************\
-* Function: APP_uBusInit
-* Description: init UBUS context
-* Returns: 0 on success
-\**********************************************************************/
-static int APP_uBusInit(void)
-{
- int rc = 0;
-
- uloop_init();
- APP_ctx = ubus_connect(NULL);
- if (APP_ctx == NULL)
- {
- printf(" %s Failed to connect to ubus!\n", __FUNCTION__);
- return -1;
- }
-
- ubus_add_uloop(APP_ctx);
- // lookup audio_if until success
- while(1)
- {
- rc = ubus_lookup_id(APP_ctx, AUDIO_UBUS_ID, & APP_audio_request_id);
- if (0 != rc)
- {
- printf("%s, Failed to look up(%s), rc=%d\n", __FUNCTION__, AUDIO_UBUS_ID, rc);
- usleep(100000); //100ms
- }
- else
- break;
- }
- printf("%s, ubus_lookup_id(%s) OK\n", __FUNCTION__, AUDIO_UBUS_ID);
- return 0;
-}
-
-static void APP_Audio_GaniSet_cb(struct ubus_request *req, int rc)
-{
- if (req)
- {
- free(req);
- req = NULL;
- }
- printf("%s do nothing, rc=%d\n", __FUNCTION__, rc);
-}
-
-
-/**********************************************************************\
-* Function: APP_Audio_VolumeSet
-* Description: This function is called to send command into audio_if.
-* unsigned int volume(0~100)
-* Returns: 0 on success
-\**********************************************************************/
-static void APP_Audio_GainSet(unsigned char *gain, int gain_num)
-{
- int rc = 0;
- struct ubus_request *req = NULL;
-
- req = (struct ubus_request *)malloc(sizeof(struct ubus_request));
- if (req == NULL)
- {
- printf("leave %s: lack of memory\n", __FUNCTION__);
- return;
- }
- memset(req, 0, sizeof(struct ubus_request));
- blob_buf_init(&audio_cm_b, 0);
-
- char name[20];
- int i = 0;
- for(; i < gain_num; i++) {
- memset(name, 0x0, 20);
- sprintf(name, "volume_gain_%d", i);
- blobmsg_add_u8(&audio_cm_b, name, gain[i]);
- }
-
-#if 1
- if ((rc = ubus_invoke_async(APP_ctx, APP_audio_request_id, AUDIO_UBUS_AUDIO_GAIN_SET, audio_cm_b.head, req)) != UBUS_STATUS_OK)
- {
- free(req);
- printf("%s, ubus_invoke_async volume set failed: %s\n", __FUNCTION__, ubus_strerror(rc));
- }
- else
- {
- printf("%s: ubus_invoke_async success\n", __FUNCTION__);
- req->complete_cb = APP_Audio_GaniSet_cb;
- ubus_complete_request_async(APP_ctx, req);
- }
-#else
- if ((rc = ubus_invoke(APP_ctx, APP_audio_request_id, AUDIO_UBUS_AUDIO_GAIN_SET, audio_cm_b.head, NULL, 0, 0)) != UBUS_STATUS_OK)
- {
- printf("%s, ubus_invoke_async volume set failed: %s\n", __FUNCTION__, ubus_strerror(rc));
- }
- else
- {
- printf("%s: ubus_invoke_async success\n", __FUNCTION__);
- }
- free(req);
-
-#endif
-}
-
-/**********************************************************************\
-* Function: main
-* Description: Main function of this APP.
-* Returns: 0 on success
-\**********************************************************************/
-int main (int argc ,char *argv[])
-{
- pthread_attr_t tattr;
-
- /*Init ubus server*/
- if(APP_uBusInit())
- return -1;
-
-#if 0
- /*Create thread to accept user choice*/
- pthread_attr_init(&tattr);
- pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
- pthread_create(&APP_MainLoopTask, &tattr, (void *)APP_MainLoop, NULL);
-#else
- unsigned char gain[] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xa0};
- APP_Audio_GainSet(gain, sizeof(gain));
-
-#endif
-
- uloop_run();
-
- printf("Here, uloop stopped!!!\n ");
-
- /*unregister uloop*/
- /* thread will get here only if uloop stopped*/
- ubus_free(APP_ctx);
- uloop_done();
- return 0;
-}
-
diff --git a/mbtk/test/asr1803/yx_audio_test.c b/mbtk/test/asr1803/yx_audio_test.c
deleted file mode 100755
index 740f152..0000000
--- a/mbtk/test/asr1803/yx_audio_test.c
+++ /dev/null
@@ -1,285 +0,0 @@
-#include "mbtk_type.h"
-#include <fcntl.h>
-#include <stdint.h>
-#include <limits.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <signal.h>
-// #include "ql_at.h"
-#include "ql/ql_audio.h"
-// #include "mopen_tts.h"
-
-#define MBTK_PLAY_PA_CONTROL 1
-#define MBTK_RECV_PA_CONTROL 1
-
-static int record_fd = -1;
-static int play_hdl = 0;
-static int gpio33_fd = -1;
-static int gpio34_fd = -1;
-
-int Ql_cb_playback(int hdl, int result)
-{
- printf("%s: hdl=%d, result=%d\n\r", __func__, hdl, result);
- if (result == AUD_PLAYER_FINISHED || result == AUD_PLAYER_NODATA)
- {
- printf("%s: play finished\n\r", __func__);
- }
- return 0;
-}
-
-void record_cb_func(int cb_result, char* databuf, unsigned int len)
-{
- int rc;
-
- if(NULL != databuf && len > 0 && record_fd > 0)
- {
- //for debug:save into file
- rc = write(record_fd, databuf, len);
- if (rc < 0) {
- printf("%s: error writing to file!\n", __FUNCTION__);
- } else if (rc < len) {
- printf("%s: wrote less the buffer size!\n", __FUNCTION__);
- }
- }
-}
-
-int MBTK_wav_pcm16Le_check(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
- {
- printf("\n%s: cannot read header\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.riff_id != ID_RIFF)
- || (hdr.riff_fmt != ID_WAVE)
- || (hdr.fmt_id != ID_FMT))
- {
- printf("\n%s: is not a riff/wave file\n", __FUNCTION__);
- return -1;
- }
-
- if ((hdr.audio_format != FORMAT_PCM) || (hdr.fmt_sz != 16)) {
- printf("\n%s: is not pcm format\n", __FUNCTION__);
- return -1;
- }
-
- if (hdr.bits_per_sample != 16) {
- printf("\n%s: is not 16bit per sample\n", __FUNCTION__);
- return -1;
- }
-
- return 0;
-}
-
-static void audio_pa_open()
-{
- if(gpio34_fd > 0) {
- write(gpio34_fd, "1", 1);
- }
-
- if(gpio33_fd > 0) {
- write(gpio33_fd, "0", 1);
- }
-}
-
-static void audio_pa_close()
-{
- if(gpio34_fd > 0) {
- write(gpio34_fd, "0", 1);
- }
-
- if(gpio33_fd > 0) {
- write(gpio33_fd, "1", 1);
- }
-}
-
-int MBTK_wav_pcm16Le_set(int fd)
-{
- struct wav_header hdr;
-
- if (fd <= 0)
- return -1;
-
- memset(&hdr, 0, sizeof(struct wav_header));
-
- hdr.riff_id = ID_RIFF;
- hdr.riff_fmt = ID_WAVE;
- hdr.fmt_id = ID_FMT;
- hdr.fmt_sz = 16;
- hdr.audio_format = FORMAT_PCM;
- hdr.num_channels = 1;
- hdr.sample_rate = 8000;
- hdr.bits_per_sample = 16;
- hdr.byte_rate = (8000 * 1 * hdr.bits_per_sample) / 8;
- hdr.block_align = (hdr.bits_per_sample * 1) / 8;
- hdr.data_id = ID_DATA;
- hdr.data_sz = 0;
-
- hdr.riff_sz = hdr.data_sz + 44 - 8;
- if (write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- return -1;
- }
-
- return 0;
-}
-
-static int play(const char *path)
-{
- int fd = open(path, O_RDONLY);
- if(fd < 0) {
- printf("open(%s) fail:%d\n", path, errno);
- return -1;
- }
-
-#if MBTK_PLAY_PA_CONTROL
- audio_pa_close();
-#endif
-
- play_hdl = Ql_AudPlayer_Open(NULL, Ql_cb_playback);
- if(0 == play_hdl) {
- printf("Ql_AudPlayer_Open fail\n");
- close(fd);
- return -1;
- }
-
- if(MBTK_wav_pcm16Le_check(fd)) {
- printf("MBTK_wav_pcm16Le_check() fail.\n");
- goto fail;
- }
-
-#if MBTK_PLAY_PA_CONTROL
- audio_pa_open();
-#endif
- if(Ql_AudPlayer_PlayFrmFile(play_hdl, fd, 0)) {
- printf("Ql_AudPlayer_PlayFrmFile() fail.\n");
- goto fail;
- }
-
- if(play_hdl) {
-#if MBTK_PLAY_PA_CONTROL
- audio_pa_close();
-#endif
- printf("Play complete.\n");
- Ql_AudPlayer_Close(play_hdl);
-#if MBTK_PLAY_PA_CONTROL
- audio_pa_open();
-#endif
- play_hdl = 0;
- }
- close(fd);
- return 0;
-fail:
- Ql_AudPlayer_Close(play_hdl);
- close(fd);
- return -1;
-}
-
-static int recv(const char *path)
-{
- record_fd = open(path, O_RDWR|O_CREAT|O_TRUNC, 0644);
- if(record_fd < 0) {
- printf("open(%s) fail:%d\n", path, errno);
- return -1;
- }
-#if MBTK_RECV_PA_CONTROL
- audio_pa_close();
-#endif
-
- int hdl = Ql_AudRecorder_Open(NULL, record_cb_func);
- if(0 == hdl) {
- printf("Ql_AudRecorder_Open fail\n");
- close(record_fd);
- record_fd = -1;
- return -1;
- }
-
- if(MBTK_wav_pcm16Le_set(record_fd)) {
- printf("MBTK_wav_pcm16Le_set() fail.\n");
- goto fail;
- }
-#if MBTK_RECV_PA_CONTROL
- audio_pa_open();
-#endif
- if(Ql_AudRecorder_StartRecord()) {
- printf("Ql_AudRecorder_StartRecord() fail.\n");
- goto fail;
- }
- sleep(10);
-#if MBTK_RECV_PA_CONTROL
- audio_pa_close();
-#endif
- Ql_AudRecorder_Close();
-#if MBTK_RECV_PA_CONTROL
- audio_pa_open();
-#endif
- printf("Recorder complete.\n");
- close(record_fd);
- record_fd = -1;
- return 0;
-fail:
- Ql_AudRecorder_Close();
- close(record_fd);
- record_fd = -1;
- return -1;
-}
-
-static void sig_handler(int sig)
-{
- printf("output signal number: %d.\n", sig);
- if(play_hdl) {
- Ql_AudPlayer_Stop(play_hdl);
- }
-}
-
-static void help()
-{
- printf("yx_audio_test play/recv file_name\n");
-}
-
-int main(int argc, char *argv[])
-{
- if(argc != 3) {
- help();
- return -1;
- }
-
- signal(SIGINT, sig_handler);
- signal(SIGTERM, sig_handler);
- signal(SIGTSTP, sig_handler);
- if(access("/sys/class/gpio/gpio33/value", F_OK)) {
- system("echo 33 > /sys/class/gpio/export");
- system("echo out > /sys/class/gpio/gpio33/direction");
- }
- gpio33_fd = open("/sys/class/gpio/gpio33/value", O_RDWR);
-
- if(access("/sys/class/gpio/gpio34/value", F_OK)) {
- system("echo 34 > /sys/class/gpio/export");
- system("echo out > /sys/class/gpio/gpio34/direction");
- }
- gpio34_fd = open("/sys/class/gpio/gpio34/value", O_RDWR);
-
- int ret = -1;
- if(!strcmp(argv[1], "play")) {
- ret = play(argv[2]);
- } else if(!strcmp(argv[1], "recv")) {
- ret = recv(argv[2]);
- } else {
- help();
- }
-
- if(gpio34_fd > 0) {
- close(gpio34_fd);
- }
-
- if(gpio33_fd > 0) {
- close(gpio33_fd);
- }
- return ret;
-}
diff --git a/mbtk/test/liblynq_lib/Makefile b/mbtk/test/liblynq_lib/Makefile
new file mode 100755
index 0000000..55e0360
--- /dev/null
+++ b/mbtk/test/liblynq_lib/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_ril -lmbtk_net -lmbtk_audio -lmbtk_fota -lmbtk_gnss -lmbtk_factory -llynq_lib
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/fota_test.c b/mbtk/test/liblynq_lib/fota_test.c
similarity index 100%
rename from mbtk/test/fota_test.c
rename to mbtk/test/liblynq_lib/fota_test.c
diff --git a/mbtk/test/asr1806/lynq-audio-demo.cpp b/mbtk/test/liblynq_lib/lynq-audio-demo.cpp
similarity index 100%
rename from mbtk/test/asr1806/lynq-audio-demo.cpp
rename to mbtk/test/liblynq_lib/lynq-audio-demo.cpp
diff --git a/mbtk/test/asr1806/lynq_call_test.c b/mbtk/test/liblynq_lib/lynq_call_test.c
similarity index 100%
rename from mbtk/test/asr1806/lynq_call_test.c
rename to mbtk/test/liblynq_lib/lynq_call_test.c
diff --git a/mbtk/test/asr1806/lynq_chip_id.c b/mbtk/test/liblynq_lib/lynq_chip_id.c
similarity index 100%
rename from mbtk/test/asr1806/lynq_chip_id.c
rename to mbtk/test/liblynq_lib/lynq_chip_id.c
diff --git a/mbtk/test/lynq_log_test.c b/mbtk/test/liblynq_lib/lynq_log_test.c
similarity index 100%
rename from mbtk/test/lynq_log_test.c
rename to mbtk/test/liblynq_lib/lynq_log_test.c
diff --git a/mbtk/test/asr1806/lynq_nw_test.c b/mbtk/test/liblynq_lib/lynq_nw_test.c
similarity index 100%
rename from mbtk/test/asr1806/lynq_nw_test.c
rename to mbtk/test/liblynq_lib/lynq_nw_test.c
diff --git a/mbtk/test/asr1806/lynq_qser_sms_test.c b/mbtk/test/liblynq_lib/lynq_qser_sms_test.c
similarity index 100%
rename from mbtk/test/asr1806/lynq_qser_sms_test.c
rename to mbtk/test/liblynq_lib/lynq_qser_sms_test.c
diff --git a/mbtk/test/asr1806/lynq_sleep_test.c b/mbtk/test/liblynq_lib/lynq_sleep_test.c
similarity index 100%
rename from mbtk/test/asr1806/lynq_sleep_test.c
rename to mbtk/test/liblynq_lib/lynq_sleep_test.c
diff --git a/mbtk/test/asr1806/lynq_time_test.c b/mbtk/test/liblynq_lib/lynq_time_test.c
similarity index 100%
rename from mbtk/test/asr1806/lynq_time_test.c
rename to mbtk/test/liblynq_lib/lynq_time_test.c
diff --git a/mbtk/test/asr1806/qser_data_call_test.c b/mbtk/test/liblynq_lib/qser_data_call_test.c
similarity index 100%
rename from mbtk/test/asr1806/qser_data_call_test.c
rename to mbtk/test/liblynq_lib/qser_data_call_test.c
diff --git a/mbtk/test/asr1806/qser_gnss_test.c b/mbtk/test/liblynq_lib/qser_gnss_test.c
old mode 100644
new mode 100755
similarity index 100%
rename from mbtk/test/asr1806/qser_gnss_test.c
rename to mbtk/test/liblynq_lib/qser_gnss_test.c
diff --git a/mbtk/test/asr1806/qser_led_test.c b/mbtk/test/liblynq_lib/qser_led_test.c
old mode 100644
new mode 100755
similarity index 100%
rename from mbtk/test/asr1806/qser_led_test.c
rename to mbtk/test/liblynq_lib/qser_led_test.c
diff --git a/mbtk/test/asr1806/qser_sim_test.c b/mbtk/test/liblynq_lib/qser_sim_test.c
old mode 100644
new mode 100755
similarity index 100%
rename from mbtk/test/asr1806/qser_sim_test.c
rename to mbtk/test/liblynq_lib/qser_sim_test.c
diff --git a/mbtk/test/asr1806/qser_thermal_test.c b/mbtk/test/liblynq_lib/qser_thermal_test.c
old mode 100644
new mode 100755
similarity index 100%
rename from mbtk/test/asr1806/qser_thermal_test.c
rename to mbtk/test/liblynq_lib/qser_thermal_test.c
diff --git a/mbtk/test/asr1806/ring_tele.h b/mbtk/test/liblynq_lib/ring_tele.h
similarity index 100%
rename from mbtk/test/asr1806/ring_tele.h
rename to mbtk/test/liblynq_lib/ring_tele.h
diff --git a/mbtk/test/libmbtk_audio/Makefile b/mbtk/test/libmbtk_audio/Makefile
new file mode 100755
index 0000000..1045e71
--- /dev/null
+++ b/mbtk/test/libmbtk_audio/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_audio
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/asr1806/mbtk_pcm_play_test.c b/mbtk/test/libmbtk_audio/mbtk_pcm_play_test.c
similarity index 100%
rename from mbtk/test/asr1806/mbtk_pcm_play_test.c
rename to mbtk/test/libmbtk_audio/mbtk_pcm_play_test.c
diff --git a/mbtk/test/asr1806/mbtk_pcm_recorder_test.c b/mbtk/test/libmbtk_audio/mbtk_pcm_recorder_test.c
similarity index 100%
rename from mbtk/test/asr1806/mbtk_pcm_recorder_test.c
rename to mbtk/test/libmbtk_audio/mbtk_pcm_recorder_test.c
diff --git a/mbtk/test/asr1806/mbtk_wav_play_test.c b/mbtk/test/libmbtk_audio/mbtk_wav_play_test.c
similarity index 100%
rename from mbtk/test/asr1806/mbtk_wav_play_test.c
rename to mbtk/test/libmbtk_audio/mbtk_wav_play_test.c
diff --git a/mbtk/test/asr1806/mbtk_wav_recorder_test.c b/mbtk/test/libmbtk_audio/mbtk_wav_recorder_test.c
similarity index 100%
rename from mbtk/test/asr1806/mbtk_wav_recorder_test.c
rename to mbtk/test/libmbtk_audio/mbtk_wav_recorder_test.c
diff --git a/mbtk/test/libmbtk_coap/Makefile b/mbtk/test/libmbtk_coap/Makefile
new file mode 100755
index 0000000..28bf46c
--- /dev/null
+++ b/mbtk/test/libmbtk_coap/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_coap
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_coap_test.c b/mbtk/test/libmbtk_coap/mbtk_coap_test.c
similarity index 100%
rename from mbtk/test/mbtk_coap_test.c
rename to mbtk/test/libmbtk_coap/mbtk_coap_test.c
diff --git a/mbtk/test/libmbtk_ecall/Makefile b/mbtk/test/libmbtk_ecall/Makefile
new file mode 100755
index 0000000..28bf46c
--- /dev/null
+++ b/mbtk/test/libmbtk_ecall/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_coap
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/libmbtk_factory/Makefile b/mbtk/test/libmbtk_factory/Makefile
new file mode 100755
index 0000000..d93d8c5
--- /dev/null
+++ b/mbtk/test/libmbtk_factory/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_factory -lmbtk_audio
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_adc_test.c b/mbtk/test/libmbtk_factory/mbtk_adc_test.c
similarity index 100%
rename from mbtk/test/mbtk_adc_test.c
rename to mbtk/test/libmbtk_factory/mbtk_adc_test.c
diff --git a/mbtk/test/libmbtk_fota/Makefile b/mbtk/test/libmbtk_fota/Makefile
new file mode 100755
index 0000000..33a7f43
--- /dev/null
+++ b/mbtk/test/libmbtk_fota/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_fota
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/libmbtk_ftp/Makefile b/mbtk/test/libmbtk_ftp/Makefile
new file mode 100755
index 0000000..d520ad9
--- /dev/null
+++ b/mbtk/test/libmbtk_ftp/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_ftp
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_ftp_test.c b/mbtk/test/libmbtk_ftp/mbtk_ftp_test.c
similarity index 100%
rename from mbtk/test/mbtk_ftp_test.c
rename to mbtk/test/libmbtk_ftp/mbtk_ftp_test.c
diff --git a/mbtk/test/libmbtk_gnss/Makefile b/mbtk/test/libmbtk_gnss/Makefile
new file mode 100755
index 0000000..d520ad9
--- /dev/null
+++ b/mbtk/test/libmbtk_gnss/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_ftp
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/libmbtk_http/Makefile b/mbtk/test/libmbtk_http/Makefile
new file mode 100755
index 0000000..ad42a13
--- /dev/null
+++ b/mbtk/test/libmbtk_http/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_http
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_http_test.c b/mbtk/test/libmbtk_http/mbtk_http_test.c
similarity index 100%
rename from mbtk/test/mbtk_http_test.c
rename to mbtk/test/libmbtk_http/mbtk_http_test.c
diff --git a/mbtk/test/libmbtk_lib/Makefile b/mbtk/test/libmbtk_lib/Makefile
new file mode 100755
index 0000000..844f199
--- /dev/null
+++ b/mbtk/test/libmbtk_lib/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_at_test.c b/mbtk/test/libmbtk_lib/mbtk_at_test.c
similarity index 100%
rename from mbtk/test/mbtk_at_test.c
rename to mbtk/test/libmbtk_lib/mbtk_at_test.c
diff --git a/mbtk/test/libmbtk_mqtt/Makefile b/mbtk/test/libmbtk_mqtt/Makefile
new file mode 100755
index 0000000..4802389
--- /dev/null
+++ b/mbtk/test/libmbtk_mqtt/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_mqtt -lmbtk_http
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_mqtt_aliyun_test.c b/mbtk/test/libmbtk_mqtt/mbtk_mqtt_aliyun_test.c
similarity index 100%
rename from mbtk/test/mbtk_mqtt_aliyun_test.c
rename to mbtk/test/libmbtk_mqtt/mbtk_mqtt_aliyun_test.c
diff --git a/mbtk/test/mbtk_mqtt_test.c b/mbtk/test/libmbtk_mqtt/mbtk_mqtt_test.c
similarity index 100%
rename from mbtk/test/mbtk_mqtt_test.c
rename to mbtk/test/libmbtk_mqtt/mbtk_mqtt_test.c
diff --git a/mbtk/test/libmbtk_net/Makefile b/mbtk/test/libmbtk_net/Makefile
new file mode 100755
index 0000000..d172606
--- /dev/null
+++ b/mbtk/test/libmbtk_net/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_net_control_test.c b/mbtk/test/libmbtk_net/mbtk_net_control_test.c
similarity index 100%
rename from mbtk/test/mbtk_net_control_test.c
rename to mbtk/test/libmbtk_net/mbtk_net_control_test.c
diff --git a/mbtk/test/libmbtk_ril/Makefile b/mbtk/test/libmbtk_ril/Makefile
new file mode 100755
index 0000000..6197845
--- /dev/null
+++ b/mbtk/test/libmbtk_ril/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_ril
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_info_test.c b/mbtk/test/libmbtk_ril/mbtk_info_test.c
similarity index 100%
rename from mbtk/test/mbtk_info_test.c
rename to mbtk/test/libmbtk_ril/mbtk_info_test.c
diff --git a/mbtk/test/libmbtk_tcpip/Makefile b/mbtk/test/libmbtk_tcpip/Makefile
new file mode 100755
index 0000000..0ee33e7
--- /dev/null
+++ b/mbtk/test/libmbtk_tcpip/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_tcpip
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/mbtk_tcpip_test.c b/mbtk/test/libmbtk_tcpip/mbtk_tcpip_test.c
similarity index 100%
rename from mbtk/test/mbtk_tcpip_test.c
rename to mbtk/test/libmbtk_tcpip/mbtk_tcpip_test.c
diff --git a/mbtk/test/tcp_test.c b/mbtk/test/libmbtk_tcpip/tcp_test.c
similarity index 100%
rename from mbtk/test/tcp_test.c
rename to mbtk/test/libmbtk_tcpip/tcp_test.c
diff --git a/mbtk/test/libql_lib/Makefile b/mbtk/test/libql_lib/Makefile
new file mode 100755
index 0000000..3acd13c
--- /dev/null
+++ b/mbtk/test/libql_lib/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_ril -lql_lib -lmbtk_audio -lmbtk_http -lmbtk_fota -lmbtk_factory
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/ql_DSI_ConnectManager_test.c b/mbtk/test/libql_lib/ql_DSI_ConnectManager_test.c
similarity index 100%
rename from mbtk/test/ql_DSI_ConnectManager_test.c
rename to mbtk/test/libql_lib/ql_DSI_ConnectManager_test.c
diff --git a/mbtk/test/ql_adc_test.c b/mbtk/test/libql_lib/ql_adc_test.c
similarity index 100%
rename from mbtk/test/ql_adc_test.c
rename to mbtk/test/libql_lib/ql_adc_test.c
diff --git a/mbtk/test/ql_call_test.c b/mbtk/test/libql_lib/ql_call_test.c
similarity index 100%
rename from mbtk/test/ql_call_test.c
rename to mbtk/test/libql_lib/ql_call_test.c
diff --git a/mbtk/test/ql_dev_test.c b/mbtk/test/libql_lib/ql_dev_test.c
similarity index 100%
rename from mbtk/test/ql_dev_test.c
rename to mbtk/test/libql_lib/ql_dev_test.c
diff --git a/mbtk/test/ql_gpio_test.c b/mbtk/test/libql_lib/ql_gpio_test.c
similarity index 100%
rename from mbtk/test/ql_gpio_test.c
rename to mbtk/test/libql_lib/ql_gpio_test.c
diff --git a/mbtk/test/ql_i2c_test.c b/mbtk/test/libql_lib/ql_i2c_test.c
similarity index 100%
rename from mbtk/test/ql_i2c_test.c
rename to mbtk/test/libql_lib/ql_i2c_test.c
diff --git a/mbtk/test/ql_nw_test.c b/mbtk/test/libql_lib/ql_nw_test.c
similarity index 100%
rename from mbtk/test/ql_nw_test.c
rename to mbtk/test/libql_lib/ql_nw_test.c
diff --git a/mbtk/test/ql_sim_test.c b/mbtk/test/libql_lib/ql_sim_test.c
similarity index 100%
rename from mbtk/test/ql_sim_test.c
rename to mbtk/test/libql_lib/ql_sim_test.c
diff --git a/mbtk/test/ql_sms_test.c b/mbtk/test/libql_lib/ql_sms_test.c
similarity index 100%
rename from mbtk/test/ql_sms_test.c
rename to mbtk/test/libql_lib/ql_sms_test.c
diff --git a/mbtk/test/ql_spi_test.c b/mbtk/test/libql_lib/ql_spi_test.c
similarity index 100%
rename from mbtk/test/ql_spi_test.c
rename to mbtk/test/libql_lib/ql_spi_test.c
diff --git a/mbtk/test/ql_uart_test.c b/mbtk/test/libql_lib/ql_uart_test.c
similarity index 100%
rename from mbtk/test/ql_uart_test.c
rename to mbtk/test/libql_lib/ql_uart_test.c
diff --git a/mbtk/test/ql_voice_test.c b/mbtk/test/libql_lib/ql_voice_test.c
similarity index 100%
rename from mbtk/test/ql_voice_test.c
rename to mbtk/test/libql_lib/ql_voice_test.c
diff --git a/mbtk/test/mbtk_dsp_gain_set.c b/mbtk/test/mbtk_dsp_gain_set.c
deleted file mode 100755
index bae9485..0000000
--- a/mbtk/test/mbtk_dsp_gain_set.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "mbtk_audio_gain.h"
-#include "mbtk_log.h"
-
-static void help()
-{
- printf("./mbtk_dsp_gain_set spk/mic <gain>\n");
-}
-
-int main(int argc, char *argv[])
-{
- if(argc != 3) {
- help();
- return -1;
- }
-
- if(strcmp(argv[1], "spk") && strcmp(argv[1], "mic")) {
- help();
- return -1;
- }
-
- mbtk_log_init("radio", "MBTK_GAIN");
-
- CONFIG_DSPGAIN_Direction dir = CONFIG_DSPGAIN_RX;
- if(!strcmp(argv[1], "mic")) {
- dir = CONFIG_DSPGAIN_TX;
- }
- if(mbtk_dsp_gain_set(dir, atoi(argv[2]))) {
- printf("\nFail.\n");
- } else {
- printf("\nSuccess.\n");
- }
-
- return 0;
-}
-
-
diff --git a/mbtk/test/others/Makefile b/mbtk/test/others/Makefile
new file mode 100755
index 0000000..7dc5e8b
--- /dev/null
+++ b/mbtk/test/others/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -laudio-apu -lcutils -ltinyalsa -lacm -lubus -lubox
+
+CFLAGS +=
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+ @echo " BIN $@"
+ $(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+ $(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/mbtk/test/fb_demo.c b/mbtk/test/others/fb_demo.c
similarity index 100%
rename from mbtk/test/fb_demo.c
rename to mbtk/test/others/fb_demo.c
diff --git a/mbtk/test/framebuffer_demo.c b/mbtk/test/others/framebuffer_demo.c
similarity index 100%
rename from mbtk/test/framebuffer_demo.c
rename to mbtk/test/others/framebuffer_demo.c
diff --git a/mbtk/test/fs_full.c b/mbtk/test/others/fs_full.c
similarity index 100%
rename from mbtk/test/fs_full.c
rename to mbtk/test/others/fs_full.c
diff --git a/mbtk/test/iconv_demo.cc b/mbtk/test/others/iconv_demo.cc
similarity index 100%
rename from mbtk/test/iconv_demo.cc
rename to mbtk/test/others/iconv_demo.cc
diff --git a/mbtk/test/key_ev_demo.c b/mbtk/test/others/key_ev_demo.c
similarity index 100%
rename from mbtk/test/key_ev_demo.c
rename to mbtk/test/others/key_ev_demo.c
diff --git a/mbtk/test/mbtk_spi_write.c b/mbtk/test/others/mbtk_spi_write.c
similarity index 100%
rename from mbtk/test/mbtk_spi_write.c
rename to mbtk/test/others/mbtk_spi_write.c
diff --git a/mbtk/test/partition_write_demo.c b/mbtk/test/others/partition_write_demo.c
similarity index 100%
rename from mbtk/test/partition_write_demo.c
rename to mbtk/test/others/partition_write_demo.c
diff --git a/mbtk/test/polarssl_demo.c b/mbtk/test/others/polarssl_demo.c
similarity index 100%
rename from mbtk/test/polarssl_demo.c
rename to mbtk/test/others/polarssl_demo.c
diff --git a/mbtk/test/touch_ev_demo.c b/mbtk/test/others/touch_ev_demo.c
similarity index 100%
rename from mbtk/test/touch_ev_demo.c
rename to mbtk/test/others/touch_ev_demo.c
diff --git a/mbtk/test/ubus_demo.c b/mbtk/test/others/ubus_demo.c
similarity index 100%
rename from mbtk/test/ubus_demo.c
rename to mbtk/test/others/ubus_demo.c
diff --git a/mbtk/test/usb_check.c b/mbtk/test/others/usb_check.c
similarity index 100%
rename from mbtk/test/usb_check.c
rename to mbtk/test/others/usb_check.c