临时提交,功能未完善
authorSnickerSun <snickersun@163.com>
Sun, 27 Oct 2024 08:23:28 +0000 (16:23 +0800)
committerSnickerSun <snickersun@163.com>
Sun, 27 Oct 2024 08:23:28 +0000 (16:23 +0800)
34 files changed:
CMakeLists.txt
Setting.ini [new file with mode: 0644]
at_data.cpp
debug/at_data.obj [new file with mode: 0644]
debug/custom.obj [new file with mode: 0644]
debug/factory_tool.exe [new file with mode: 0644]
debug/factory_tool.ilk [new file with mode: 0644]
debug/factory_tool.pdb [new file with mode: 0644]
debug/factory_tool.vc.pdb [new file with mode: 0644]
debug/main.obj [new file with mode: 0644]
debug/mainwindow.obj [new file with mode: 0644]
debug/moc_custom.obj [new file with mode: 0644]
debug/moc_mainwindow.obj [new file with mode: 0644]
debug/mythread.obj [new file with mode: 0644]
debug/result_thread.obj [new file with mode: 0644]
debug/wrtm_class.obj [new file with mode: 0644]
factory_tool.pro
header.h
mainwindow.cpp
mainwindow.ui
mythread.h
readme.txt
release/at_data.obj [new file with mode: 0644]
release/custom.obj [new file with mode: 0644]
release/factory_tool.exe [new file with mode: 0644]
release/main.obj [new file with mode: 0644]
release/mainwindow.obj [new file with mode: 0644]
release/moc_custom.obj [new file with mode: 0644]
release/moc_mainwindow.obj [new file with mode: 0644]
release/mythread.obj [new file with mode: 0644]
release/result_thread.obj [new file with mode: 0644]
release/wrtm_class.obj [new file with mode: 0644]
uapi_main.h [deleted file]
wrtm_class.cpp

index 041dcc3..b893ae5 100644 (file)
@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.5)\r
 \r
-project(untitled LANGUAGES CXX)\r
+project(LANGUAGES CXX)\r
 \r
 set(CMAKE_INCLUDE_CURRENT_DIR ON)\r
 \r
@@ -27,9 +27,9 @@ set(RC_ICONS windows.ico)
 find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)\r
 \r
 set(TS_FILES untitled_zh_CN.ts)\r
-include_directories(${CMAKE_SOURCE_DIR}/src)\r
+include_directories(${CMAKE_SOURCE_DIR})\r
 if(ANDROID)\r
-  add_library(untitled SHARED\r
+  add_library(SHARED\r
     main.cpp\r
     mainwindow.cpp\r
     mainwindow.h\r
@@ -37,7 +37,7 @@ if(ANDROID)
     ${TS_FILES}\r
   )\r
 else()\r
-  add_executable(untitled\r
+  add_executable(\r
     WIN32\r
     main.cpp\r
     mainwindow.cpp\r
@@ -58,10 +58,10 @@ else()
   )\r
 endif()\r
 \r
-target_link_libraries(untitled PRIVATE\r
+target_link_libraries( PRIVATE\r
                       Qt5::Widgets\r
                       ${CMAKE_SOURCE_DIR}/lib/libwireless_tools.dll)\r
-target_link_libraries(untitled PRIVATE\r
+target_link_libraries( PRIVATE\r
                       Qt5::Widgets\r
                       ${CMAKE_SOURCE_DIR}/lib/libsecurec.a)\r
 \r
diff --git a/Setting.ini b/Setting.ini
new file mode 100644 (file)
index 0000000..e3f6e21
--- /dev/null
@@ -0,0 +1,22 @@
+[Uart_setting]\r
+uart_com=COM41\r
+uart_baud=18\r
+spp_addr=\r
+\r
+[Download_Setting]\r
+download_board_path=/user/\r
+download_local_path=\r
+\r
+[Upload_Setting]\r
+upload_board_path=\r
+upload_local_path=\r
+\r
+[At_Setting]\r
+at_mediamusicplay=\r
+at_mediaaudiorecord=\r
+at_fsrm=\r
+at_delay_ms=\r
+at_spp_addr=\r
+custom_module_id=\r
+custom_cmd_id=\r
+custom_payload=\r
index 993d64d..1d76e0d 100644 (file)
@@ -92,15 +92,16 @@ QString At_Process::at_get_ble_format(at_mode_board mode,QString br_switch,QStri
 \r
 bool At_Process::at_send_cmd_board(at_mode_board mode,QString format)\r
 {\r
-    char *buf=nullptr;\r
+//    char *buf=nullptr;\r
     uint32_t buf_len=0;\r
     bool ret=false;\r
     QString str=at_get_cmd_board(mode);\r
     str+=format;\r
     str+="\r\n";\r
-    buf = (char *)str.toStdString().c_str();\r
+    std::string bufstr = str.toStdString();\r
+    const char* buf = bufstr.c_str();\r
     buf_len = strlen(buf);\r
-    if(uapi_uart_tx_data(buf, buf_len)){\r
+    if(uapi_uart_tx_data((void*)buf, buf_len)){\r
         ret=true;\r
     }\r
     return ret;\r
diff --git a/debug/at_data.obj b/debug/at_data.obj
new file mode 100644 (file)
index 0000000..2b32fa7
Binary files /dev/null and b/debug/at_data.obj differ
diff --git a/debug/custom.obj b/debug/custom.obj
new file mode 100644 (file)
index 0000000..1df2882
Binary files /dev/null and b/debug/custom.obj differ
diff --git a/debug/factory_tool.exe b/debug/factory_tool.exe
new file mode 100644 (file)
index 0000000..9e8ace8
Binary files /dev/null and b/debug/factory_tool.exe differ
diff --git a/debug/factory_tool.ilk b/debug/factory_tool.ilk
new file mode 100644 (file)
index 0000000..b647048
Binary files /dev/null and b/debug/factory_tool.ilk differ
diff --git a/debug/factory_tool.pdb b/debug/factory_tool.pdb
new file mode 100644 (file)
index 0000000..c21528e
Binary files /dev/null and b/debug/factory_tool.pdb differ
diff --git a/debug/factory_tool.vc.pdb b/debug/factory_tool.vc.pdb
new file mode 100644 (file)
index 0000000..192ebff
Binary files /dev/null and b/debug/factory_tool.vc.pdb differ
diff --git a/debug/main.obj b/debug/main.obj
new file mode 100644 (file)
index 0000000..c684f34
Binary files /dev/null and b/debug/main.obj differ
diff --git a/debug/mainwindow.obj b/debug/mainwindow.obj
new file mode 100644 (file)
index 0000000..3fe4735
Binary files /dev/null and b/debug/mainwindow.obj differ
diff --git a/debug/moc_custom.obj b/debug/moc_custom.obj
new file mode 100644 (file)
index 0000000..7bf1955
Binary files /dev/null and b/debug/moc_custom.obj differ
diff --git a/debug/moc_mainwindow.obj b/debug/moc_mainwindow.obj
new file mode 100644 (file)
index 0000000..a37458f
Binary files /dev/null and b/debug/moc_mainwindow.obj differ
diff --git a/debug/mythread.obj b/debug/mythread.obj
new file mode 100644 (file)
index 0000000..74e3a86
Binary files /dev/null and b/debug/mythread.obj differ
diff --git a/debug/result_thread.obj b/debug/result_thread.obj
new file mode 100644 (file)
index 0000000..5cedc10
Binary files /dev/null and b/debug/result_thread.obj differ
diff --git a/debug/wrtm_class.obj b/debug/wrtm_class.obj
new file mode 100644 (file)
index 0000000..dd9534d
Binary files /dev/null and b/debug/wrtm_class.obj differ
index a3cfb75..4b23984 100644 (file)
@@ -34,6 +34,7 @@ HEADERS  += mainwindow.h \
 FORMS    += mainwindow.ui\r
 \r
 DISTFILES += \\r
+    CMakeLists.txt \\r
     readme.txt \\r
     untitled_zh_CN.ts\r
 \r
index 1e240a8..e70123a 100644 (file)
--- a/header.h
+++ b/header.h
@@ -34,6 +34,8 @@ uapi_errcode uapi_uart_tx_data(void *buf, uint32_t buf_len); // uart TX 发送
 uapi_errcode uapi_uart_set_rts_dtr(int rts_flag, int dtr_flag); // uart 设置rts和dtr开关\r
 uapi_errcode uapi_uart_callback_register(uart_rx_function callback); // uart 注册回调函数\r
 uapi_errcode uapi_uart_close(void); // 关闭uart口\r
+uapi_errcode uapi_uart_set_currentMode(int mode); //0 SERIALPORT(单板) 1 BLUETOOTH(整机)\r
+\r
 \r
 uapi_errcode uapi_at_send(uint8_t module_id, uint8_t cmd_id, uint8_t *pkt, uint32_t pkt_size, at_result_callback callback); // at命令发送接口,module_id及cmd_id请参考《Sparta 产线 测试指南》10.2章\r
 uapi_errcode uapi_file_download(char* board_file_path, char* local_file_path, transmit_result_hook handler); // 文件下载接口,参数分别为板端文件地址(详细到文件后缀),pc端存储路径(详细到文件夹),传输结果回调函数\r
index 3b0cacc..0ccf2cf 100644 (file)
@@ -209,17 +209,19 @@ void MainWindow::uart_open(QString com,QString com_baud)
        if(ui->stkw_stage->currentIndex() == PAGE_COMPLETE){\r
             ui->tbw_stage_complete->setEnabled(true);\r
             ui->pbtn_spp_connect->setEnabled(true);\r
+//            uapi_uart_set_currentMode(1);\r
        }else if(ui->stkw_stage->currentIndex() == PAGE_BOARD){\r
            ui->tbw_stage_board->setEnabled(true);\r
+//           uapi_uart_set_currentMode(0);\r
        }\r
 \r
        ui->pbtn_open_uart->setText("关闭串口");\r
-//       ui_display("open uart success.\r\n",false);\r
+       ui_display("open uart success.\r\n",false);\r
        if(!ui->pbtn_open_uart->isChecked()){\r
            ui->pbtn_open_uart->setChecked(true);\r
        }\r
     } else {\r
-//            ui_display("open uart fail.\r\n",false,false);\r
+            ui_display("open uart fail.\r\n",false);\r
             QMessageBox::warning(this, tr("SerialPort"), tr("Open SerialPort failed"), QMessageBox::Ok);\r
             ui->pbtn_open_uart->setChecked(false);\r
     }\r
@@ -251,8 +253,8 @@ void MainWindow::uart_close()
 void MainWindow::uart_send_data()\r
 {\r
     QString str;\r
-    char *buf = nullptr;\r
     int buf_len = 0;\r
+    char* buf = nullptr;\r
     if(ui->stkw_stage->currentIndex() == PAGE_COMPLETE){\r
         str = ui->tedit_input_data->toPlainText();\r
     }else{\r
@@ -265,15 +267,20 @@ void MainWindow::uart_send_data()
         buf_len = hex_bytes.size();\r
         buf = hex_bytes.data();\r
         str=str.toUpper();\r
+        uapi_uart_tx_data(buf, buf_len);\r
     } else {\r
         if ((ui->stkw_stage->currentIndex() == PAGE_COMPLETE &&ui->ckbox_word_wrap->isChecked())||\r
                 (ui->stkw_stage->currentIndex() ==PAGE_BOARD && ui->ckbox_word_wrap_board->isChecked())) {\r
             str+="\r\n";\r
         }\r
-        buf = (char *)str.toStdString().c_str();\r
+        std::string bufstr = str.toStdString();\r
+        buf =(char*) bufstr.c_str();\r
         buf_len = strlen(buf);\r
+        uapi_uart_tx_data(buf, buf_len);\r
     }\r
-    uapi_uart_tx_data(buf, buf_len);\r
+\r
+\r
+\r
     ui_display(str,false);\r
 }\r
 \r
@@ -407,6 +414,7 @@ void MainWindow::spp_connected_callback()
     }\r
     if (dongle_is_connected == true) {\r
         ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(0, 255, 64);}");\r
+        uapi_uart_set_currentMode(1);//设置整机模式,通过蓝牙透传指令\r
     } else {\r
         ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(255, 0, 0);}");\r
     }\r
@@ -535,7 +543,10 @@ void MainWindow::transmit_fromboard_getfilelist()
         return;\r
     }\r
     ui->cbox_fromborad_filelist->clear();\r
-    char *buf = (char *)str.toStdString().c_str();\r
+\r
+    std::string bufstr = str.toStdString();\r
+    char* buf =(char*) bufstr.c_str();\r
+\r
     int ret = uapi_ls_send(buf, strlen(buf), ls_callback);\r
     if (ret == FAIL) {\r
         QMessageBox::warning(this, tr("ls"), tr("ls fail!\r\n"), QMessageBox::Ok);\r
@@ -570,8 +581,10 @@ void MainWindow::transmit_fromboard_download()
     }\r
     str_file_path.append(str_file_name);\r
     std::string buf_temp = str_file_path.toStdString();\r
+//    QByteArray buf_temp  = str_file_path.toUtf8() ;\r
     char *str_file_buff = (char *)buf_temp.c_str();\r
     std::string buf_temp2 = str_savepath.toStdString();\r
+//    QByteArray buf_temp2  = str_file_path.toUtf8();\r
     char *str_save_buff = (char *)buf_temp2.c_str();\r
     int ret = uapi_file_download(str_file_buff, str_save_buff, transmit_callback);\r
     if (ret == FAIL) {\r
@@ -604,8 +617,13 @@ void MainWindow::transmit_fromboard_delete()
         str_file_path.append("/");\r
     }\r
     str_file_path.append(str_file_name);\r
-    char *str_file_buff = (char *)str_file_path.toStdString().c_str();\r
-    int ret = uapi_file_delete(str_file_buff, strlen(str_file_buff)); // ls\r
+\r
+    std::string bufstr = str_file_path.toStdString();\r
+    char* str_file_buff =(char*) bufstr.c_str();\r
+\r
+//    char *str_file_buff = (char *)str_file_path.toUtf8().data();//.toStdString().c_str();\r
+    int buflen = strlen(str_file_buff);\r
+    int ret = uapi_file_delete(str_file_buff, buflen); // ls\r
     if (ret == FAIL) {\r
         QMessageBox::warning(this, tr("delete"), tr("delete file fail!\r\n"), QMessageBox::Ok);\r
     }\r
@@ -640,8 +658,15 @@ void MainWindow::transmit_toboard_upload()
         QMessageBox::warning(this, tr("File Path"), tr("File Path Empty!"), QMessageBox::Ok);\r
         return;\r
     }\r
-    char *buf_board_file_path = (char *)board_file_path.toStdString().c_str();\r
-    char *buf_local_file_path = (char *)local_file_path.toStdString().c_str();\r
+\r
+    std::string bufboard_file_path = board_file_path.toStdString();\r
+    char* buf_board_file_path =(char*) bufboard_file_path.c_str();\r
+\r
+    std::string buflocal_file_path = local_file_path.toStdString();\r
+    char* buf_local_file_path =(char*) buflocal_file_path.c_str();\r
+\r
+//    char *buf_board_file_path = (char *)board_file_path.toUtf8().data();//.toStdString().c_str();\r
+//    char *buf_local_file_path = (char *)local_file_path.toUtf8().data();//.toStdString().c_str();\r
     int ret = uapi_file_upload(buf_board_file_path, buf_local_file_path, transmit_callback);\r
     if (ret == FAIL) {\r
         QMessageBox::warning(this, tr("Upload"), tr("文件上传启动失败!\r\n"), QMessageBox::Ok);\r
index 84ece13..0eaae6b 100644 (file)
@@ -21,7 +21,7 @@
    <string>Factory_Tools</string>\r
   </property>\r
   <property name="windowIcon">\r
-   <iconset resource="Demoqrc.qrc">\r
+   <iconset>\r
     <normaloff>:/icon/windows.ico</normaloff>:/icon/windows.ico</iconset>\r
   </property>\r
   <property name="windowOpacity">\r
        <cursorShape>ArrowCursor</cursorShape>\r
       </property>\r
       <property name="currentIndex">\r
-       <number>0</number>\r
+       <number>3</number>\r
       </property>\r
       <widget class="QWidget" name="tab_complete_debug">\r
        <attribute name="title">\r
    <header location="global">custom.h</header>\r
   </customwidget>\r
  </customwidgets>\r
- <resources>\r
-  <include location="Demoqrc.qrc"/>\r
- </resources>\r
+ <resources/>\r
  <connections>\r
   <connection>\r
    <sender>pbtn_open_uart</sender>\r
index 20bce24..72164a8 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef MYTHREAD_H\r
 #define MYTHREAD_H\r
-\r
+#include <atomic>\r
 #include <QWaitCondition.h>\r
 #include <QMutex>\r
 #include <QThread>\r
@@ -27,7 +27,7 @@ class MyThread : public QThread
     QMutex m_lock_stop;\r
     volatile bool stopped;\r
     QMutex m_lock_Pause;\r
-    std::atomic_bool pauseFlag;\r
+    std::atomic<bool> pauseFlag;\r
     QWaitCondition condition;\r
 };\r
 #endif // MYTHREAD_H\r
index 15e8891..096c091 100644 (file)
@@ -1 +1,66 @@
-本软件使用QT库进行UI界面设计。
\ No newline at end of file
+main.cpp示例如下\r
+________________________________________________________________________________________________________________________________________\r
+#include <iostream>\r
+#include "interface.h"\r
+#include "info.h"\r
+#include "windows.h"\r
+#include "Library_global.h"\r
+using namespace std;\r
+\r
+class MyInfo : public uapi::Info\r
+{\r
+public:\r
+    MyInfo(){};\r
+    ~MyInfo(){};\r
+    void onReadEvent(int eventType, void *data) override\r
+    {\r
+        cout<<"eventType = "<<eventType<<endl;\r
+    }\r
+};\r
+\r
+\r
+int main()\r
+{\r
+    MyInfo info;\r
+    Interface *handle = new Interface();\r
+    handle->InfoEventConnect(&info);\r
+    handle->SetCurrentMode(uapi::MODE_BLUETOOTH);\r
+\r
+// 串口配置\r
+    char *com = "COM11";\r
+    handle->SerialPortOpen(com, 921600);\r
+\r
+// 设置为整机段\r
+    handle->SetCurrentMode(uapi::MODE_BLUETOOTH);\r
+\r
+// 发送STACKINFO命令\r
+        handle->AtMessageSend(8,0x0d,NULL,0);\r
+\r
+// 获取文件列表\r
+    char ls_tx[] = "/user/";\r
+    handle->FileGetList(ls_tx, strlen(ls_tx));\r
+\r
+    char board_delete_path[] = "/user/test.mp3";\r
+    handle->FileDelete(board_delete_path, strlen(board_delete_path));\r
+\r
+// 上传文件\r
+    Sleep(1000);\r
+        char local_path[] = "C:/Users/y30032013/Desktop/music.mp3";\r
+    char board_path[] = "/user/music.mp3";\r
+    handle->FileUpload(board_path, local_path);\r
+    Sleep(3000);\r
+    handle->FileTransmitStop();\r
+\r
+// 下载文件\r
+        Sleep(1000);\r
+    handle->FileGetList(ls_tx, strlen(ls_tx));\r
+    Sleep(3000);\r
+    char name[] = "/user/music.mp3";\r
+    char pc_path[] = "C:/Users/y30032013/Desktop/bin/";\r
+    handle->FileDownload(name, pc_path);\r
+\r
+    while (1) {\r
+       Sleep(100);\r
+    }\r
+}\r
+________________________________________________________________________________________________________________________________________\r
diff --git a/release/at_data.obj b/release/at_data.obj
new file mode 100644 (file)
index 0000000..1329fb2
Binary files /dev/null and b/release/at_data.obj differ
diff --git a/release/custom.obj b/release/custom.obj
new file mode 100644 (file)
index 0000000..64b0a6b
Binary files /dev/null and b/release/custom.obj differ
diff --git a/release/factory_tool.exe b/release/factory_tool.exe
new file mode 100644 (file)
index 0000000..efac356
Binary files /dev/null and b/release/factory_tool.exe differ
diff --git a/release/main.obj b/release/main.obj
new file mode 100644 (file)
index 0000000..7961d78
Binary files /dev/null and b/release/main.obj differ
diff --git a/release/mainwindow.obj b/release/mainwindow.obj
new file mode 100644 (file)
index 0000000..b0b1b11
Binary files /dev/null and b/release/mainwindow.obj differ
diff --git a/release/moc_custom.obj b/release/moc_custom.obj
new file mode 100644 (file)
index 0000000..39b4657
Binary files /dev/null and b/release/moc_custom.obj differ
diff --git a/release/moc_mainwindow.obj b/release/moc_mainwindow.obj
new file mode 100644 (file)
index 0000000..7e546a7
Binary files /dev/null and b/release/moc_mainwindow.obj differ
diff --git a/release/mythread.obj b/release/mythread.obj
new file mode 100644 (file)
index 0000000..c14deb3
Binary files /dev/null and b/release/mythread.obj differ
diff --git a/release/result_thread.obj b/release/result_thread.obj
new file mode 100644 (file)
index 0000000..1c15396
Binary files /dev/null and b/release/result_thread.obj differ
diff --git a/release/wrtm_class.obj b/release/wrtm_class.obj
new file mode 100644 (file)
index 0000000..c6011e2
Binary files /dev/null and b/release/wrtm_class.obj differ
diff --git a/uapi_main.h b/uapi_main.h
deleted file mode 100644 (file)
index fc584ac..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef UAPI_MAIN_H
-#define UAPI_MAIN_H
-
-typedef enum {
-    FAIL = 0x0,
-    SUCC = 0x1,
-} uapi_errcode;
-
-typedef struct {
-    uint32_t total_size; // 当前传输文件总大小
-    uint32_t transmited_size; // 当前文件已传输大小
-} uapi_transmit_progress;
-
-typedef struct {
-    uint16_t sn; // 序号
-    uint8_t name_len; // 文件(夹)名长度
-    uint8_t is_dir; // 是否是文件夹
-    uint32_t file_size; // 文件大小
-    uint8_t name[0xFF]; // 文件(夹)名
-} uapi_ls_info_t;
-
-typedef uint32_t (*uart_rx_function)(void *buf, uint32_t len); //  uart RX 回调函数
-typedef uint32_t (*at_result_callback)(void *buf, uint32_t len); // AT 命令返回值回调函数,入参buf包括 mould_id + cmd_id + payload
-typedef uint32_t (*transmit_ls_result)(uint32_t size, uapi_ls_info_t *buff); // transmit get list回调函数,入参 size 为文件(夹)的数量,buff 为文件(夹)的信息
-typedef uint32_t (*transmit_result_hook)(bool is_finished, uintptr_t usr_data); // 传输结果回调函数,is_finished 为传输结束标志,usr_data 预留接口,目前为NULL
-
-uapi_errcode uapi_uart_open(const char *com,  uint32_t baud); // 打开uart口, com 格式为 "\\\\.\\COM47", baud 为波特率
-uapi_errcode uapi_uart_tx_data(void *buf, uint32_t buf_len); // uart TX 发送数据buf
-uapi_errcode uapi_uart_set_rts_dtr(int rts_flag, int dtr_flag); // uart 设置rts和dtr开关
-uapi_errcode uapi_uart_callback_register(uart_rx_function callback); // uart 注册回调函数
-uapi_errcode uapi_uart_close(void); // 关闭uart口
-
-uapi_errcode uapi_at_send(uint8_t module_id, uint8_t cmd_id, uint8_t *pkt, uint32_t pkt_size, at_result_callback callback); // at命令发送接口,module_id及cmd_id请参考《Sparta 产线 测试指南》10.2章
-uapi_errcode uapi_file_download(char* board_file_path, char* local_file_path, transmit_result_hook handler); // 文件下载接口,参数分别为板端文件地址(详细到文件后缀),pc端存储路径(详细到文件夹),传输结果回调函数
-uapi_errcode uapi_file_upload(char* board_file_path,char* local_file_path, transmit_result_hook handler); // 文件上传接口,参数分别为板端文件地址(详细到文件后缀),pc端存储路径(详细到文件后缀),传输结果回调函数
-uapi_errcode uapi_ls_send(char *path, uint32_t path_len, transmit_ls_result callback); // 查询文件列表接口,参数为板端文件路径(详细到文件夹),路径长度,get list回调函数
-uapi_errcode uapi_file_delete(char *board_file_path, uint32_t board_file_path_len); // 删除指定文件接口,参数为板端文件地址(详细到文件后缀),文件路径长度
-uapi_errcode uapi_file_transmit_stop(void); // 停止文件下载接口
-uapi_errcode uapi_transmit_process(uapi_transmit_progress *data); // 获取文件传输进度,入参 data 更新为正在传输的文件的总大小和已传输大小
-#endif
index b73a591..2f23908 100644 (file)
@@ -4,8 +4,15 @@
 #include "info.h"\r
 #include "windows.h"\r
 #include "Library_global.h"\r
+#include "qdebug.h"\r
 using namespace std;\r
 \r
+static uart_rx_function g_uart_rx_callback=NULL;\r
+static at_result_callback g_at_result_callback=NULL;\r
+static transmit_ls_result g_ls_result_callback=NULL;\r
+static transmit_result_hook g_result_hook_callback=NULL;\r
+\r
+\r
 class MyInfo : public uapi::Info\r
 {\r
 public:\r
@@ -13,18 +20,36 @@ public:
     ~MyInfo(){};\r
     void onReadEvent(int eventType, void *data) override\r
     {\r
+        uapi::SerialPortReceiveData *precvdata = NULL;\r
+        uapi::TransmitResult *ptransResult = NULL;\r
+        uapi::FileListResult *flistResult = NULL;\r
+        uapi::AtReceiveData *atrecvdata = NULL;\r
+\r
         switch(eventType)\r
         {\r
             case uapi::INFO_SERIALPORT:\r
-\r
+                precvdata=(uapi::SerialPortReceiveData*)data;\r
+                qDebug()<<"INFO_SERIALPORT "<< precvdata->data;\r
+                if(g_uart_rx_callback)\r
+                    g_uart_rx_callback(precvdata->data,precvdata->dataLength);\r
                 break;\r
             case uapi::INFO_FILE_TRANSMIT_RESULT:\r
-//                uapi::TransmitResult *ptransResult = (uapi::TransmitResult*)data;\r
-//                out<<"TransmitResult = "<<ptransResult->finishResult;\r
+                ptransResult = (uapi::TransmitResult*)data;\r
+                qDebug()<<"INFO_FILE_TRANSMIT_RESULT "<< ptransResult->finishResult;\r
+                if(g_result_hook_callback)\r
+                    g_result_hook_callback(ptransResult->finishResult,NULL);\r
                 break;\r
             case uapi::INFO_FILE_LIST_RESULT:\r
+                flistResult=(uapi::FileListResult*)data;\r
+                qDebug()<<"INFO_FILE_LIST_RESULT "<< flistResult->lsInfo->name;\r
+                if(g_ls_result_callback)\r
+                    g_ls_result_callback(flistResult->lsInfoNumber,(uapi_ls_info_t *)flistResult->lsInfo);\r
                 break;\r
             case uapi::INFO_AT_RECEIVE:\r
+                atrecvdata=(uapi::AtReceiveData*)data;\r
+                qDebug()<<"INFO_AT_RECEIVE "<< atrecvdata->data;\r
+                if(g_at_result_callback)\r
+                    g_at_result_callback(atrecvdata->data,atrecvdata->dataLength);\r
                 break;\r
         }\r
 \r
@@ -32,65 +57,94 @@ public:
 };\r
 static  MyInfo info;\r
 static Interface *handle= new Interface();\r
-uapi_errcode uapi_init_wrtm_class(void)\r
+uapi_errcode uapi_uart_set_currentMode(int mode)\r
 {\r
-    handle->InfoEventConnect(&info);\r
-    handle->SetCurrentMode(uapi::MODE_BLUETOOTH);\r
+    if (mode == 0)\r
+        handle->SetCurrentMode(uapi::MODE_SERIALPORT);\r
+    else\r
+        handle->SetCurrentMode(uapi::MODE_BLUETOOTH);\r
     return SUCC;\r
 }\r
-\r
 uapi_errcode uapi_uart_open(const char *com,  uint32_t baud) // 打开uart口, com 格式为 "\\\\.\\COM47", baud 为波特率\r
 {\r
-    return SUCC;\r
+    handle->InfoEventConnect(&info);\r
+    handle->SetCurrentMode(uapi::MODE_SERIALPORT);\r
+    int ret= handle->SerialPortOpen(com,baud);\r
+    if (ret == 0)\r
+        return SUCC;\r
+    else\r
+        return FAIL;\r
 }\r
 uapi_errcode uapi_uart_tx_data(void *buf, uint32_t buf_len) // uart TX 发送数据buf\r
 {\r
+    qDebug()<<"tx:"<<QString((char *)buf);\r
+    handle->SerialPortWrite((unsigned char *)buf,buf_len);\r
     return SUCC;\r
 }\r
 uapi_errcode uapi_uart_set_rts_dtr(int rts_flag, int dtr_flag) // uart 设置rts和dtr开关\r
 {\r
+//    handle->SetCurrentMode(uapi::MODE_SERIALPORT);\r
+    handle->SerialPortSetRtsDtr(rts_flag,dtr_flag);\r
     return SUCC;\r
 }\r
 uapi_errcode uapi_uart_callback_register(uart_rx_function callback) // uart 注册回调函数\r
 {\r
+    g_uart_rx_callback = callback;\r
     return SUCC;\r
 }\r
 uapi_errcode uapi_uart_close(void)// 关闭uart口\r
 {\r
+\r
+    handle->SerialPortClose();\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_at_send(uint8_t module_id, uint8_t cmd_id, uint8_t *pkt, uint32_t pkt_size, at_result_callback callback) // at命令发送接口,module_id及cmd_id请参考《Sparta 产线 测试指南》10.2章\r
 {\r
+     g_at_result_callback = callback;\r
+\r
+    handle->AtMessageSend(module_id,cmd_id,pkt,pkt_size);\r
+\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_file_download(char* board_file_path, char* local_file_path, transmit_result_hook handler) // 文件下载接口,参数分别为板端文件地址(详细到文件后缀),pc端存储路径(详细到文件夹),传输结果回调函数\r
 {\r
+    g_result_hook_callback = handler;\r
+    handle->FileDownload(board_file_path,local_file_path);\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_file_upload(char* board_file_path,char* local_file_path, transmit_result_hook handler)// 文件上传接口,参数分别为板端文件地址(详细到文件后缀),pc端存储路径(详细到文件后缀),传输结果回调函数\r
 {\r
+    g_result_hook_callback = handler;\r
+    handle->FileUpload(board_file_path,local_file_path);\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_ls_send(char *path, uint32_t path_len, transmit_ls_result callback)// 查询文件列表接口,参数为板端文件路径(详细到文件夹),路径长度,get list回调函数\r
 {\r
+    g_ls_result_callback = callback;\r
+    qDebug()<<"uapi_ls_send  "<<path;\r
+    handle->FileGetList(path,path_len);\r
+\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_file_delete(char *board_file_path, uint32_t board_file_path_len) // 删除指定文件接口,参数为板端文件地址(详细到文件后缀),文件路径长度\r
 {\r
+    handle->FileDelete(board_file_path,board_file_path_len);\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_file_transmit_stop(void)// 停止文件下载接口\r
 {\r
+    handle->FileTransmitStop();\r
     return SUCC;\r
 }\r
 \r
 uapi_errcode uapi_transmit_process(uapi_transmit_progress *data) // 获取文件传输进度,入参 data 更新为正在传输的文件的总大小和已传输大小\r
 {\r
+    handle->FileTransmitProgress((uapi::FileTransmitDataCount*)data);\r
     return SUCC;\r
 }\r