From: SnickerSun Date: Sun, 10 Nov 2024 20:51:24 +0000 (+0800) Subject: 中间版本 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=6207d4198978ef0f6fe799ef186899208a4d4b7f;p=mirrors%2Ffactory_tool.git 中间版本 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b893ae5..fc23893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ set(RC_ICONS windows.ico) find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED) set(TS_FILES untitled_zh_CN.ts) -include_directories(${CMAKE_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) if(ANDROID) add_library(SHARED main.cpp @@ -45,24 +45,18 @@ else() mainwindow.ui mythread.h mythread.cpp - custom.h - custom.cpp Demoqrc.qrc demopng.rc - at_data.cpp - at_data.h result_thread.cpp result_thread.h - common.h ${TS_FILES} ) endif() target_link_libraries( PRIVATE Qt5::Widgets - ${CMAKE_SOURCE_DIR}/lib/libwireless_tools.dll) -target_link_libraries( PRIVATE - Qt5::Widgets - ${CMAKE_SOURCE_DIR}/lib/libsecurec.a) + Qt5::SerialPort + ) + qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) diff --git a/factory_tool.pro b/HiBTMacWriteTool.pro similarity index 64% rename from factory_tool.pro rename to HiBTMacWriteTool.pro index 4b23984..15bd036 100644 --- a/factory_tool.pro +++ b/HiBTMacWriteTool.pro @@ -4,34 +4,37 @@ # #------------------------------------------------- -QT += core gui +QT += core gui sql serialport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -TARGET = factory_tool +TARGET = HiBTMacWriteTool TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ - at_data.cpp \ - custom.cpp \ mythread.cpp \ result_thread.cpp \ - wrtm_class.cpp + custom.cpp \ + sqldbmanager.cpp \ + settings.cpp \ + dialogsettings.cpp HEADERS += mainwindow.h \ - Library_global.h \ - at_data.h \ - common.h \ - custom.h \ - info.h \ - interface.h \ mythread.h \ result_thread.h \ - header.h + common.h \ + custom.h \ + sqldbmanager.h \ + settings.h \ + dialogsettings.h + +#HEADERS += ui_mac_settings.h \ +# ui_mainwindow.h -FORMS += mainwindow.ui +FORMS += mainwindow.ui \ + mac_settings.ui DISTFILES += \ CMakeLists.txt \ @@ -43,8 +46,8 @@ DEPENDPATH += $$PWD/. LIBS += -L$$PWD/lib/ -LIBS += libsecurec.a -LIBS += -ldiag + + LIBS += -lAdvapi32 diff --git a/dialogsettings.cpp b/dialogsettings.cpp new file mode 100644 index 0000000..b9f402b --- /dev/null +++ b/dialogsettings.cpp @@ -0,0 +1,58 @@ +#include "dialogsettings.h" +#include +#include "settings.h" +DialogSettings::DialogSettings():g_dialogSettings(new Ui::Dialog()) +{ + g_dialogSettings->setupUi(this); + update_view(); +} + +void DialogSettings::accept() +{ + qDebug()<<"accept "; +// this->close(); + settings::getInstance().create_new_database(); + this->done(1); +} + +void DialogSettings::reject() +{ + qDebug()<<"reject"; +// this->close(); + this->done(0); +} + +void DialogSettings::update_view() +{ + qDebug()<<"update_view"; + QString prefix=g_dialogSettings->lineedit_prefix->text(); + QString mac_start=g_dialogSettings->lineedit_mac_start->text(); + QString mac_count=g_dialogSettings->lineedit_mac_count->text(); + bool num_is_ok=true; + QString status=""; + if (mac_start.length() != 6 ) + { + qDebug()<< "mac_start != 6"; + status.append("mac地址开始长度只能为6!\n"); + num_is_ok = false; + } + if (prefix.length() != 6) + { + qDebug()<< "prefix != 6"; + status.append("mac地址固定头长度只能为6!\n"); + num_is_ok = false; + } + if (num_is_ok == true) + { + int ret = settings::getInstance().mac_config(prefix,mac_count,mac_start); + qDebug()<< "save settings ret "<label_mac_status->setText(status); + +} diff --git a/dialogsettings.h b/dialogsettings.h new file mode 100644 index 0000000..853aecf --- /dev/null +++ b/dialogsettings.h @@ -0,0 +1,25 @@ +#ifndef DIALOGSETTINGS_H +#define DIALOGSETTINGS_H + +#include "ui_mac_settings.h" +#include "settings.h" +QT_BEGIN_NAMESPACE +namespace Ui { +class Dialog; +} +QT_END_NAMESPACE +class DialogSettings : public QDialog +{ + Q_OBJECT +public: + DialogSettings(); + +private slots: + void accept(); + void reject(); + void update_view(); +private: + Ui::Dialog *g_dialogSettings; +}; + +#endif // DIALOGSETTINGS_H diff --git a/mac_settings.ui b/mac_settings.ui new file mode 100644 index 0000000..db2950e --- /dev/null +++ b/mac_settings.ui @@ -0,0 +1,280 @@ + + + Dialog + + + + 0 + 0 + 506 + 400 + + + + Dialog + + + + + 130 + 340 + 341 + 32 + + + + Qt::LeftToRight + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + + 30 + 98 + 304 + 32 + + + + + 0 + 0 + + + + + Arial + 14 + + + + 蓝牙地址开始: + + + + + + 30 + 10 + 304 + 32 + + + + + 0 + 0 + + + + + Arial + 14 + + + + 蓝牙Mac地址Prefix: + + + + + + 30 + 139 + 441 + 38 + + + + + Arial + 14 + + + + 01012D + + + + + + 30 + 51 + 441 + 38 + + + + + Arial + 14 + + + + 281106 + + + + + + 30 + 227 + 441 + 38 + + + + + Arial + 14 + + + + 1000 + + + + + + 30 + 186 + 304 + 32 + + + + + 0 + 0 + + + + + Arial + 14 + + + + 蓝牙地址个数 + + + + + + 30 + 270 + 441 + 61 + + + + + 0 + 0 + + + + + Arial + 14 + + + + 28110601012D 至 2811060287CD + 共 100000 个地址 + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + lineedit_prefix + textChanged(QString) + Dialog + update_view() + + + 250 + 69 + + + 252 + 199 + + + + + lineedit_mac_start + textChanged(QString) + Dialog + update_view() + + + 250 + 157 + + + 252 + 199 + + + + + lineedit_mac_count + textChanged(QString) + Dialog + update_view() + + + 250 + 245 + + + 252 + 199 + + + + + + update_view() + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 0ccf2cf..0d0b57f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,17 +1,54 @@ #include "mainwindow.h" -#include "./ui_mainwindow.h" +#include "ui_mainwindow.h" +#include "dialogsettings.h" +#include // 初始化线程、状态寄存器、配置信息 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); - result_thread = new Result_Thread(this); - result_thread->start(); - result_thread->pause(); - at_handler = new At_Process(this); + serialport1 = new QSerialPort(); + serialport2 = new QSerialPort(); + serialport3 = new QSerialPort(); + serialport4 = new QSerialPort(); + result_thread1 = new Result_Thread(this,1); + result_thread2 = new Result_Thread(this,2); + result_thread3 = new Result_Thread(this,3); + result_thread4 = new Result_Thread(this,4); + result_thread1->start(); + result_thread1->pause(); + result_thread2->start(); + result_thread2->pause(); + result_thread3->start(); + result_thread3->pause(); + result_thread4->start(); + result_thread4->pause(); ui_setting_read(); - at_set_bt_format(); + connect(serialport1, &QSerialPort::readyRead, this, &MainWindow::readData1); +} +void MainWindow::readData1() +{ + const QByteArray data = serialport1->readAll(); + qDebug()<putData(data); +} +void MainWindow::readData2() +{ + const QByteArray data = serialport2->readAll(); + qDebug()<putData(data); +} +void MainWindow::readData3() +{ + const QByteArray data = serialport3->readAll(); + qDebug()<putData(data); +} +void MainWindow::readData4() +{ + const QByteArray data = serialport4->readAll(); + qDebug()<putData(data); } - // 结束线程 MainWindow::~MainWindow() { @@ -24,22 +61,24 @@ MainWindow::~MainWindow() spp_connected_handle = NULL; } ui_setting_save(); - result_thread->stop(); - result_thread->wait(); - if (transmit_timer_handle != NULL) { - transmit_timer_handle->stop(); - transmit_timer_handle = NULL; - } - if (ui->pbtn_open_uart->isChecked()) { - if (uapi_uart_close() == TRUE) { - } - } - delete result_thread; - delete at_handler; + result_thread1->stop(); + result_thread1->wait(); + result_thread2->stop(); + result_thread2->wait(); + result_thread3->stop(); + result_thread3->wait(); + result_thread4->stop(); + result_thread4->wait(); + + + delete result_thread1; + delete result_thread2; + delete result_thread3; + delete result_thread4; delete ui; } -void MainWindow::ui_display(QString str,bool inOrOut) +void MainWindow::ui_display1(QString str,bool inOrOut) { // QTime Time= QTime::currentTime();//获取系统当前的时间 // QString str_time = Time.toString("[hh:mm:ss ");//格式化时间 @@ -59,47 +98,67 @@ void MainWindow::ui_display(QString str,bool inOrOut) ui->txtb_dispaly->insertPlainText(str); ui->txtb_dispaly->moveCursor(QTextCursor::End); } - -void MainWindow::ui_tab_mainwindow_complete() +void MainWindow::ui_display2(QString str,bool inOrOut) { - if (ui->stkw_stage->currentIndex() == PAGE_COMPLETE) { - ui->action_complete->setChecked(true); - return; - } - ui->stkw_stage->setCurrentIndex(PAGE_COMPLETE); - ui->ledit_spp_addr->setEnabled(true); - ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(255, 0, 0);}"); - if (spp_connected_handle != NULL) { - spp_connected_handle->start(1500); - } - if (ui->action_board->isChecked()) { - ui->action_board->setChecked(false); - } - if(ui->pbtn_open_uart->isChecked()){ - uart_close(); +// QTime Time= QTime::currentTime();//获取系统当前的时间 +// QString str_time = Time.toString("[hh:mm:ss ");//格式化时间 + ui->txtb_dispaly_2->moveCursor(QTextCursor::End); + if(inOrOut){ + ui->txtb_dispaly_2->setTextColor(QColor(127, 255, 0)); + }else{ + ui->txtb_dispaly_2->setTextColor(Qt::red); } +// if(inOrOut){ +// str_time.append("IN] : "); +// }else{ +// str_time.append("OUT] : "); +// } +// str.prepend(str_time); +// str+="\r\n"; + ui->txtb_dispaly_2->insertPlainText(str); + ui->txtb_dispaly_2->moveCursor(QTextCursor::End); } -void MainWindow::ui_tab_mainwindow_board() +void MainWindow::ui_display3(QString str,bool inOrOut) { - if (ui->stkw_stage->currentIndex() == PAGE_BOARD) { - ui->action_board->setChecked(true); - return; - } - ui->stkw_stage->setCurrentIndex(PAGE_BOARD); - ui->ledit_spp_addr->setEnabled(false); - ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(240, 240, 240);}"); - if (spp_connected_handle != NULL) { - spp_connected_handle->stop(); - } - dongle_is_connected = false; - if (ui->action_complete->isChecked()) { - ui->action_complete->setChecked(false); +// QTime Time= QTime::currentTime();//获取系统当前的时间 +// QString str_time = Time.toString("[hh:mm:ss ");//格式化时间 + ui->txtb_dispaly_3->moveCursor(QTextCursor::End); + if(inOrOut){ + ui->txtb_dispaly_3->setTextColor(QColor(127, 255, 0)); + }else{ + ui->txtb_dispaly_3->setTextColor(Qt::red); } - if(ui->pbtn_open_uart->isChecked()){ - uart_close(); +// if(inOrOut){ +// str_time.append("IN] : "); +// }else{ +// str_time.append("OUT] : "); +// } +// str.prepend(str_time); +// str+="\r\n"; + ui->txtb_dispaly_3->insertPlainText(str); + ui->txtb_dispaly_3->moveCursor(QTextCursor::End); +} +void MainWindow::ui_display4(QString str,bool inOrOut) +{ +// QTime Time= QTime::currentTime();//获取系统当前的时间 +// QString str_time = Time.toString("[hh:mm:ss ");//格式化时间 + ui->txtb_dispaly_4->moveCursor(QTextCursor::End); + if(inOrOut){ + ui->txtb_dispaly_4->setTextColor(QColor(127, 255, 0)); + }else{ + ui->txtb_dispaly_4->setTextColor(Qt::red); } - +// if(inOrOut){ +// str_time.append("IN] : "); +// }else{ +// str_time.append("OUT] : "); +// } +// str.prepend(str_time); +// str+="\r\n"; + ui->txtb_dispaly_4->insertPlainText(str); + ui->txtb_dispaly_4->moveCursor(QTextCursor::End); } + void MainWindow::ui_save_windows() { QString fname = QFileDialog::getExistingDirectory(this, "请选择文件"); @@ -120,36 +179,11 @@ void MainWindow::ui_setting_save() // 写入第一组数据 settings->beginGroup("Uart_setting"); - settings->setValue("uart_com", ui->cbox_uart_com_select->currentText()); + settings->setValue("uart_com", ui->cbox_uart_com_select_1->currentText()); settings->setValue("uart_baud", ui->cbox_uart_baud_select->currentIndex()); - settings->setValue("spp_addr", ui->ledit_spp_addr->text()); +// settings->setValue("spp_addr", ui->ledit_spp_addr->text()); settings->sync(); settings->endGroup(); - // 写入第二组数据 - settings->beginGroup("Download_Setting"); - settings->setValue("download_board_path", ui->ledit_formboad_bordpath->text()); - settings->setValue("download_local_path", ui->ledit_frombord_savefilepath->text()); - settings->sync(); - settings->endGroup(); - - settings->beginGroup("Upload_Setting"); - settings->setValue("upload_board_path", ui->ledit_toboard_boardpath->text()); - settings->setValue("upload_local_path", ui->ledit_toboard_filepath->text()); - settings->sync(); - settings->endGroup(); - - settings->beginGroup("At_Setting"); - settings->setValue("at_mediamusicplay", ui->ledit_at_mediamusicplay->text()); - settings->setValue("at_mediaaudiorecord", ui->ledit_at_mediaaudiorecord->text()); - settings->setValue("at_fsrm", ui->ledit_at_fsrm->text()); - settings->setValue("at_delay_ms", ui->ledit_delay_ms->text()); - settings->setValue("at_spp_addr", ui->ledit_dongle_mac->text()); - settings->setValue("custom_module_id", ui->ledit_at_custom_moduleId->text()); - settings->setValue("custom_cmd_id", ui->ledit_at_custom_CmdId->text()); - settings->setValue("custom_payload", ui->ledit_at_custom_Payload->text()); - settings->sync(); - settings->endGroup(); - delete settings; settings = nullptr; } @@ -158,38 +192,51 @@ void MainWindow::ui_setting_read() { uart_com_select(); QSettings *settings = new QSettings("Setting.ini", QSettings::IniFormat); - ui->cbox_uart_com_select->ChangeItem(settings->value("Uart_setting/uart_com").toString()); + ui->cbox_uart_com_select_1->ChangeItem(settings->value("Uart_setting/uart_com").toString()); ui->cbox_uart_baud_select->setCurrentIndex(settings->value("Uart_setting/uart_baud").toInt()); - ui->ledit_spp_addr->setText(settings->value("Uart_setting/spp_addr").toString()); - ui->tbw_stage_complete->setEnabled(true); - ui->ledit_formboad_bordpath->setText(settings->value("Download_Setting/download_board_path").toString()); - ui->ledit_frombord_savefilepath->setText(settings->value("Download_Setting/download_local_path").toString()); - ui->ledit_toboard_boardpath->setText(settings->value("Upload_Setting/upload_board_path").toString()); - ui->ledit_toboard_filepath->setText(settings->value("Upload_Setting/upload_local_path").toString()); - ui->ledit_at_mediamusicplay->setText(settings->value("At_Setting/at_mediamusicplay").toString()); - ui->ledit_at_mediaaudiorecord->setText(settings->value("At_Setting/at_mediaaudiorecord").toString()); - ui->ledit_at_fsrm->setText(settings->value("At_Setting/at_fsrm").toString()); - ui->ledit_delay_ms->setText(settings->value("At_Setting/at_delay_ms").toString()); - ui->ledit_dongle_mac->setText(settings->value("At_Setting/at_spp_addr").toString()); - ui->ledit_at_custom_moduleId->setText(settings->value("At_Setting/custom_module_id").toString()); - ui->ledit_at_custom_CmdId->setText(settings->value("At_Setting/custom_cmd_id").toString()); - ui->ledit_at_custom_Payload->setText(settings->value("At_Setting/custom_payload").toString()); - ui->tbw_stage_complete->setEnabled(false); - ui->ledit_btlo_channel->setText("0"); - ui->ledit_btpwr_powerchip->setText("2"); } /* --------------------------------uart操作--------------------------- */ -void MainWindow::uart_process() +void MainWindow::uart_process1() { - if (ui->pbtn_open_uart->isChecked()) { - QString str_com = ui->cbox_uart_com_select->currentText(); +// if (ui->pbtn_open_uart->isChecked()) { + QString str_com = ui->cbox_uart_com_select_1->currentText(); QString str_uart_baud = ui->cbox_uart_baud_select->currentText(); - uart_open(str_com,str_uart_baud); - } else { - uart_close(); - } +// uart_open(str_com,str_uart_baud); +// } else { +// uart_close(); +// } +} +void MainWindow::uart_process2() +{ +// if (ui->pbtn_open_uart->isChecked()) { + QString str_com = ui->cbox_uart_com_select_1->currentText(); + QString str_uart_baud = ui->cbox_uart_baud_select->currentText(); +// uart_open(str_com,str_uart_baud); +// } else { +// uart_close(); +// } +} +void MainWindow::uart_process3() +{ +// if (ui->pbtn_open_uart->isChecked()) { + QString str_com = ui->cbox_uart_com_select_1->currentText(); + QString str_uart_baud = ui->cbox_uart_baud_select->currentText(); +// uart_open(str_com,str_uart_baud); +// } else { +// uart_close(); +// } +} +void MainWindow::uart_process4() +{ +// if (ui->pbtn_open_uart->isChecked()) { + QString str_com = ui->cbox_uart_com_select_1->currentText(); + QString str_uart_baud = ui->cbox_uart_baud_select->currentText(); +// uart_open(str_com,str_uart_baud); +// } else { +// uart_close(); +// } } void MainWindow::uart_open(QString com,QString com_baud) { @@ -202,6 +249,7 @@ void MainWindow::uart_open(QString com,QString com_baud) } else { (void)sprintf_s(buf, "\\\\.\\COM%d", comNumber); } + #if 0 if (uapi_uart_open(buf, band)) { uapi_uart_callback_register(uart_callback); result_thread->resume(); @@ -214,7 +262,6 @@ void MainWindow::uart_open(QString com,QString com_baud) ui->tbw_stage_board->setEnabled(true); // uapi_uart_set_currentMode(0); } - ui->pbtn_open_uart->setText("关闭串口"); ui_display("open uart success.\r\n",false); if(!ui->pbtn_open_uart->isChecked()){ @@ -225,9 +272,12 @@ void MainWindow::uart_open(QString com,QString com_baud) QMessageBox::warning(this, tr("SerialPort"), tr("Open SerialPort failed"), QMessageBox::Ok); ui->pbtn_open_uart->setChecked(false); } + #endif + } void MainWindow::uart_close() { + #if 0 if (uapi_uart_close() == TRUE) { result_thread->pause(); // ui_display("close uart success.\r\n",false); @@ -249,106 +299,160 @@ void MainWindow::uart_close() } else { // ui_display("close uart fail.\r\n",false); } + #endif } -void MainWindow::uart_send_data() +void MainWindow::uart_send_data1(QString cmd) { QString str; int buf_len = 0; char* buf = nullptr; - if(ui->stkw_stage->currentIndex() == PAGE_COMPLETE){ - str = ui->tedit_input_data->toPlainText(); - }else{ - str = ui->tedit_input_data_board->toPlainText(); - } - uapi_uart_callback_register(uart_callback); - if (ui->ckbox_hex_send->isChecked()) { - QByteArray array = str.toLatin1(); - QByteArray hex_bytes = QByteArray::fromHex(array.data()); - buf_len = hex_bytes.size(); - buf = hex_bytes.data(); - str=str.toUpper(); - uapi_uart_tx_data(buf, buf_len); - } else { - if ((ui->stkw_stage->currentIndex() == PAGE_COMPLETE &&ui->ckbox_word_wrap->isChecked())|| - (ui->stkw_stage->currentIndex() ==PAGE_BOARD && ui->ckbox_word_wrap_board->isChecked())) { - str+="\r\n"; - } - std::string bufstr = str.toStdString(); - buf =(char*) bufstr.c_str(); - buf_len = strlen(buf); - uapi_uart_tx_data(buf, buf_len); - } +// if(ui->stkw_stage->currentIndex() == PAGE_COMPLETE){ +// str = ui->tedit_input_data->toPlainText(); +// }else{ +// str = ui->tedit_input_data_board->toPlainText(); +// } + ui_display1(str,false); +} +void MainWindow::uart_send_data2(QString cmd) +{ +} +void MainWindow::uart_send_data3(QString cmd) +{ - ui_display(str,false); } +void MainWindow::uart_send_data4(QString cmd) +{ +} // uart收到的数据进行回显到显示栏 -void MainWindow::uart_rx_dispaly(int buf_len, u8Piont buf) +void MainWindow::uart_rx_dispaly1(int buf_len, u8Piont buf) { uart_rx_flag = true; if (uart_rx_Ignoring_display) { QString str((char *)buf); if(str.contains("ADDR")){ - ui->ledit_dongle_mac->setText(str.mid(str.indexOf("=",0)+1,12)); +// ui->ledit_dongle_mac->setText(str.mid(str.indexOf("=",0)+1,12)); } return; } QString str; QByteArray data((const char*)buf, buf_len); - if (ui->ckbox_Hex_Display->isChecked()) { - for (int i = 0; i < data.size(); i++) { - str += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); - } - str=str.toUpper(); - } else { - for (int i = 0; i < data.size(); i++) { - str += QString(data.at(i)); - } - } - ui_display(str,true); +// if (ui->ckbox_Hex_Display->isChecked()) { +// for (int i = 0; i < data.size(); i++) { +// str += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); +// } +// str=str.toUpper(); +// } else { +// for (int i = 0; i < data.size(); i++) { +// str += QString(data.at(i)); +// } +// } + ui_display1(str,true); free(buf); } -void MainWindow::uart_check_dtr_rts() +void MainWindow::uart_rx_dispaly2(int buf_len, u8Piont buf) { - bool rts = false, dtr = false; - if (ui->ckbox_rts->isChecked()) { - rts = true; + uart_rx_flag = true; + if (uart_rx_Ignoring_display) { + QString str((char *)buf); + if(str.contains("ADDR")){ +// ui->ledit_dongle_mac->setText(str.mid(str.indexOf("=",0)+1,12)); + } + return; } - if (ui->ckbox_dtr->isChecked()) { - dtr = true; + QString str; + QByteArray data((const char*)buf, buf_len); +// if (ui->ckbox_Hex_Display->isChecked()) { +// for (int i = 0; i < data.size(); i++) { +// str += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); +// } +// str=str.toUpper(); +// } else { +// for (int i = 0; i < data.size(); i++) { +// str += QString(data.at(i)); +// } +// } + ui_display2(str,true); + free(buf); +} +void MainWindow::uart_rx_dispaly3(int buf_len, u8Piont buf) +{ + uart_rx_flag = true; + if (uart_rx_Ignoring_display) { + QString str((char *)buf); + if(str.contains("ADDR")){ +// ui->ledit_dongle_mac->setText(str.mid(str.indexOf("=",0)+1,12)); + } + return; } - if (uapi_uart_set_rts_dtr(rts, dtr) == TRUE) { -// ui_display("set rts dtr success.\r\n",false); + QString str; + QByteArray data((const char*)buf, buf_len); +// if (ui->ckbox_Hex_Display->isChecked()) { +// for (int i = 0; i < data.size(); i++) { +// str += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); +// } +// str=str.toUpper(); +// } else { +// for (int i = 0; i < data.size(); i++) { +// str += QString(data.at(i)); +// } +// } + ui_display3(str,true); + free(buf); +} +void MainWindow::uart_rx_dispaly4(int buf_len, u8Piont buf) +{ + uart_rx_flag = true; + if (uart_rx_Ignoring_display) { + QString str((char *)buf); + if(str.contains("ADDR")){ +// ui->ledit_dongle_mac->setText(str.mid(str.indexOf("=",0)+1,12)); + } + return; } + QString str; + QByteArray data((const char*)buf, buf_len); +// if (ui->ckbox_Hex_Display->isChecked()) { +// for (int i = 0; i < data.size(); i++) { +// str += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); +// } +// str=str.toUpper(); +// } else { +// for (int i = 0; i < data.size(); i++) { +// str += QString(data.at(i)); +// } +// } + ui_display4(str,true); + free(buf); } void MainWindow::uart_com_select() { - ui->cbox_uart_com_select->clear(); + ui->cbox_uart_com_select_1->clear(); QStringList strlist = uart_get_enable_comm_or_port(); qSort(strlist.begin(), strlist.end(),[](const QString& s1, const QString& s2){ QString a1=s1;QString a2=s2; return a1.replace("COM","").toInt() < a2.replace("COM","").toInt(); }); - ui->cbox_uart_com_select->addItems(strlist); + ui->cbox_uart_com_select_1->addItems(strlist); } void MainWindow::uart_com_switch(QString com) { QString str_uart_baud = ui->cbox_uart_baud_select->currentText(); - if(ui->pbtn_open_uart->isChecked()){ - uart_close(); - uart_open(com,str_uart_baud); - } +// if(ui->pbtn_open_uart->isChecked()){ +// uart_close(); +// uart_open(com,str_uart_baud); +// } } void MainWindow::uart_baud_switch(QString baud) { - QString str_com = ui->cbox_uart_com_select->currentText(); - if(ui->pbtn_open_uart->isChecked()){ - uart_close(); - uart_open(str_com,baud); - } + QString str_com = ui->cbox_uart_com_select_1->currentText(); +// if(ui->pbtn_open_uart->isChecked()){ +// uart_close(); +// uart_open(str_com,baud); +// } } // nIndex为索引号 bValue选择返回值为key还是value,默认为value QString MainWindow::uart_get_comm_or_port(int nIndex, bool bValue) @@ -389,6 +493,11 @@ QString MainWindow::uart_get_comm_or_port(int nIndex, bool bValue) } return strCommRet; } +void MainWindow::openLogfolder() +{ + QString path = QCoreApplication::applicationDirPath(); + QDesktopServices::openUrl( QUrl::fromLocalFile( path ) ); +} QStringList MainWindow::uart_get_enable_comm_or_port() { @@ -406,40 +515,52 @@ QStringList MainWindow::uart_get_enable_comm_or_port() /* ------------------------------------------------------------------- */ void MainWindow::spp_connected_callback() { - at_handler->at_send_cmd_string(MODULE_MCU,MCU_CMD_CHECK_CONNECTED,NULL); +// at_handler->at_send_cmd_string(MODULE_MCU,MCU_CMD_CHECK_CONNECTED,NULL); dongle_connected_times++; if (dongle_connected_times > 5) { - ui_display("Dongle has been disconnected.\r\n",false); + ui_display1("Dongle has been disconnected.\r\n",false); dongle_is_connected = false; } if (dongle_is_connected == true) { - ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(0, 255, 64);}"); - uapi_uart_set_currentMode(1);//设置整机模式,通过蓝牙透传指令 +// ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(0, 255, 64);}"); +// uapi_uart_set_currentMode(1);//设置整机模式,通过蓝牙透传指令 } else { - ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(255, 0, 0);}"); +// ui->connected_flag->setStyleSheet("QPushButton{background-color: rgb(255, 0, 0);}"); } } +void MainWindow::spp_timer_callback2() +{ -void MainWindow::spp_timer_callback() +} +void MainWindow::spp_timer_callback3() +{ + +} +void MainWindow::spp_timer_callback4() +{ + +} + +void MainWindow::spp_timer_callback1() { bool final_ret = false; if (dongle_try_count > 5) { - ui_display("\r\nNo device, check the dongle is connected.\r\n",false); + ui_display1("\r\nNo device, check the dongle is connected.\r\n",false); final_ret = true; } if (uart_rx_flag == false) { - at_handler->at_send_cmd_string(MODULE_MCU,MCU_CMD_CHECK_CONNECTED,NULL); +// at_handler->at_send_cmd_string(MODULE_MCU,MCU_CMD_CHECK_CONNECTED,NULL); dongle_try_count++; } else if (spp_try_count % 3 == 0) { // 每3次重新发送一次连接AT命令 - QString str = ui->ledit_spp_addr->text(); - at_handler->at_send_cmd_board(DONGLE_MODE_SPPCONN,str); +// QString str = ui->ledit_spp_addr->text(); +// at_handler->at_send_cmd_board(DONGLE_MODE_SPPCONN,str); } else if (spp_try_count > 10) { // 循环10次还有数据上报则表示连接失败 - ui_display("\r\nconnect fail.\r\n",false); + ui_display1("\r\nconnect fail.\r\n",false); final_ret = true; } if (dongle_is_connected == true) { final_ret = true; - ui_display("\r\nDongle has been connected.\r\n",false); + ui_display1("\r\nDongle has been connected.\r\n",false); if (spp_connected_handle == NULL) { spp_connected_handle = new QTimer(this); connect(spp_connected_handle, SIGNAL(timeout()), this, SLOT(spp_connected_callback())); @@ -447,639 +568,72 @@ void MainWindow::spp_timer_callback() } } if (final_ret == false) { - at_handler->at_send_cmd_board(DONGLE_MODE_AT,NULL); +// at_handler->at_send_cmd_board(DONGLE_MODE_AT,NULL); spp_try_count++; uart_rx_flag = false; - ui_display(".",false); + ui_display1(".",false); } else { spp_timer_handle->stop(); spp_timer_handle = NULL; uart_rx_Ignoring_display = false; - ui->pbtn_spp_connect->setEnabled(true); - } -} - -void MainWindow::spp_connect() -{ - uart_rx_Ignoring_display = true; - dongle_is_connected = false; - dongle_try_count = 0; - spp_try_count = 0; - uapi_uart_callback_register(uart_callback); - at_handler->at_send_cmd_board(DONGLE_MODE_ADDR,NULL); - ui_display("spp connectting...",false); - spp_timer_handle = new QTimer(this); - connect(spp_timer_handle, SIGNAL(timeout()), this, SLOT(spp_timer_callback())); - // spp查询定时器周期为1500ms - spp_timer_handle->start(1500); - ui->pbtn_spp_connect->setEnabled(false); -} - -/* ------------------------------------------------------------------------ */ -/* -------------------------业务处理部分------------------------------------- */ - -void MainWindow::transmit_ls_rx_diaplay(int transmit_ls_size, vPiont transmit_ls_buff) -{ - if(transmit_ls_size>0){ - ui_display("文件名 大小\r\n",true); - } - uapi_ls_info_t *transmit_ls_buff_temp = (uapi_ls_info_t *)transmit_ls_buff; - for (int i = 0; i < transmit_ls_size; i++) { - QString strName = QString::fromUtf8((char *)(transmit_ls_buff_temp[i].name)); - QString strFileLen = QString::number(transmit_ls_buff_temp[i].file_size,10); - if (transmit_ls_buff_temp[i].is_dir) { - strName.append("/"); - } - ui_display(strName+" "+strFileLen+"\r\n",true); - ui->cbox_fromborad_filelist->addItem(strName,strFileLen); +// ui->pbtn_spp_connect->setEnabled(true); } - free(transmit_ls_buff); } - -void MainWindow::transmit_rx_display(bool transmit_result_flag) +void MainWindow::spp_connect_1() { - uint32_t total_size=0; - uint32_t current_size=0; - transmit_get_data_count(&total_size,¤t_size); - uint32_t value = transmit_result_flag ? total_size : 0; - if (transmit_timer_handle) { - transmit_timer_handle->stop(); - transmit_timer_handle = NULL; - } - if (transmit_download_or_upload == TRANSMIT_UPLOAD) { - ui->pbar_toboard->setValue(value); - ui->pbtn_toboard_Upload->setEnabled(true); - } - if (transmit_download_or_upload == TRANSMIT_DOWNLOAD) { - ui->pbar_fromboard->setValue(value); - ui->pbtn_fromboard_download->setEnabled(true); - } - if (transmit_result_flag) { - ui_display("download or upload file success.\r\n",false); - } else { - ui_display("download or upload file fail.\r\n",false); - } - transmit_download_or_upload = TRANSMIT_IDLE; - ui->pbtn_fromboard_delete->setEnabled(true); - ui->pbtn_fromboard_getfilelist->setEnabled(true); -} - -void MainWindow::transmit_fromboard_name_change() -{ - ui->cbox_fromborad_filelist->clear(); -} + qDebug()<ui->cbox_uart_baud_select->currentText(); + qDebug()<ui->cbox_uart_com_select_1->currentText(); -void MainWindow::transmit_fromboard_selectfilepath() -{ - QString fname = QFileDialog::getExistingDirectory(this, "请选择文件"); - ui->ledit_frombord_savefilepath->setText(fname); +// this->serialport1->setBaudRate() +ui_display1("connect com1 ",false); } - -void MainWindow::transmit_fromboard_getfilelist() +void MainWindow::spp_connect_2() { - QString str = ui->ledit_formboad_bordpath->text(); - if (str.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("文件路径为空!"), QMessageBox::Ok); - return; - } - ui->cbox_fromborad_filelist->clear(); - - std::string bufstr = str.toStdString(); - char* buf =(char*) bufstr.c_str(); + ui_display2("connect com1 ",false); - int ret = uapi_ls_send(buf, strlen(buf), ls_callback); - if (ret == FAIL) { - QMessageBox::warning(this, tr("ls"), tr("ls fail!\r\n"), QMessageBox::Ok); - } - tansmit_fromborad_borad_list.push_back(str); - QCompleter *com = new QCompleter(tansmit_fromborad_borad_list, this); - com->setCaseSensitivity(Qt::CaseInsensitive); - delete ui->ledit_formboad_bordpath->completer(); - ui->ledit_formboad_bordpath->setCompleter(com); } - -void MainWindow::transmit_fromboard_download() +void MainWindow::spp_connect_3() { - QString str_savepath = ui->ledit_frombord_savefilepath->text(); - QString str_file_path = ui->ledit_formboad_bordpath->text(); - QString str_file_name = ui->cbox_fromborad_filelist->currentText(); - if (str_savepath.isEmpty() || str_file_path.isEmpty() || str_file_name.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("文件路径为空!"), QMessageBox::Ok); - return; - } - if (str_file_name.contains("/")) { - QMessageBox::warning(this, tr("Board File Name"), tr("请选择正确的文件!"), QMessageBox::Ok); - return; - } - qDebug()<cbox_fromborad_filelist->currentData().toInt(); - if(ui->cbox_fromborad_filelist->currentData().toInt()==0){ - QMessageBox::warning(this, tr("Board File Name"), tr("filesize 0"), QMessageBox::Ok); - return; - } - if(!str_file_path.endsWith("/")){ - str_file_path.append("/"); - } - str_file_path.append(str_file_name); - std::string buf_temp = str_file_path.toStdString(); -// QByteArray buf_temp = str_file_path.toUtf8() ; - char *str_file_buff = (char *)buf_temp.c_str(); - std::string buf_temp2 = str_savepath.toStdString(); -// QByteArray buf_temp2 = str_file_path.toUtf8(); - char *str_save_buff = (char *)buf_temp2.c_str(); - int ret = uapi_file_download(str_file_buff, str_save_buff, transmit_callback); - if (ret == FAIL) { - QMessageBox::warning(this, tr("Downloade"), tr("文件下载启动失败!"), QMessageBox::Ok); - return; - } - transmit_progress_start(); - transmit_download_or_upload = TRANSMIT_DOWNLOAD; - transmit_fromborad_local_list.push_back(str_savepath); - QCompleter *com = new QCompleter(transmit_fromborad_local_list, this); - com->setCaseSensitivity(Qt::CaseInsensitive); - delete ui->ledit_frombord_savefilepath->completer(); - ui->ledit_frombord_savefilepath->setCompleter(com); - ui->pbtn_fromboard_download->setEnabled(false); - ui->pbtn_fromboard_delete->setEnabled(false); - ui->pbtn_fromboard_getfilelist->setEnabled(false); -} - -void MainWindow::transmit_fromboard_delete() -{ - QString str_file_path = ui->ledit_formboad_bordpath->text(); - QString str_file_name = ui->cbox_fromborad_filelist->currentText(); - if (str_file_path.isEmpty() || str_file_name.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("文件路径为空!"), QMessageBox::Ok); - return; - } - if (str_file_name.contains("/")) { - str_file_name.chop(1); - } else { - str_file_path.append("/"); - } - str_file_path.append(str_file_name); - - std::string bufstr = str_file_path.toStdString(); - char* str_file_buff =(char*) bufstr.c_str(); - -// char *str_file_buff = (char *)str_file_path.toUtf8().data();//.toStdString().c_str(); - int buflen = strlen(str_file_buff); - int ret = uapi_file_delete(str_file_buff, buflen); // ls - if (ret == FAIL) { - QMessageBox::warning(this, tr("delete"), tr("delete file fail!\r\n"), QMessageBox::Ok); - } - ui->cbox_fromborad_filelist->removeItem(ui->cbox_fromborad_filelist->currentIndex()); -} - -void MainWindow::transmit_fromboard_stop() -{ - if (transmit_timer_handle) { - transmit_timer_handle->stop(); - transmit_timer_handle = NULL; - } - transmit_download_or_upload = TRANSMIT_IDLE; - ui->pbar_fromboard->setValue(0); - ui->pbtn_fromboard_download->setEnabled(true); - ui->pbtn_fromboard_delete->setEnabled(true); - ui->pbtn_fromboard_getfilelist->setEnabled(true); - uapi_file_transmit_stop(); -} + ui_display3("connect com1 ",false); -void MainWindow::transmit_toboard_choosefile() -{ - QString fname = QFileDialog::getOpenFileName(this, "请选择文件"); - ui->ledit_toboard_filepath->setText(fname); } - -void MainWindow::transmit_toboard_upload() +void MainWindow::spp_connect_4() { - QString board_file_path = ui->ledit_toboard_boardpath->text(); - QString local_file_path = ui->ledit_toboard_filepath->text(); - if (board_file_path.isEmpty() || local_file_path.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("File Path Empty!"), QMessageBox::Ok); - return; - } - - std::string bufboard_file_path = board_file_path.toStdString(); - char* buf_board_file_path =(char*) bufboard_file_path.c_str(); - - std::string buflocal_file_path = local_file_path.toStdString(); - char* buf_local_file_path =(char*) buflocal_file_path.c_str(); + ui_display4("connect com1 ",false); -// char *buf_board_file_path = (char *)board_file_path.toUtf8().data();//.toStdString().c_str(); -// char *buf_local_file_path = (char *)local_file_path.toUtf8().data();//.toStdString().c_str(); - int ret = uapi_file_upload(buf_board_file_path, buf_local_file_path, transmit_callback); - if (ret == FAIL) { - QMessageBox::warning(this, tr("Upload"), tr("文件上传启动失败!\r\n"), QMessageBox::Ok); - return; - } - transmit_progress_start(); - transmit_download_or_upload = TRANSMIT_UPLOAD; - transmit_toboard_local_list.push_back(local_file_path); - transmit_toboard_borad_list.push_back(board_file_path); - QCompleter *com1 = new QCompleter(transmit_toboard_local_list, this); - com1->setCaseSensitivity(Qt::CaseInsensitive); - delete ui->ledit_toboard_filepath->completer(); - ui->ledit_toboard_filepath->setCompleter(com1); - QCompleter *com2 = new QCompleter(transmit_toboard_borad_list, this); - com2->setCaseSensitivity(Qt::CaseInsensitive); - delete ui->ledit_toboard_boardpath->completer(); - ui->ledit_toboard_boardpath->setCompleter(com2); - ui->pbtn_toboard_Upload->setEnabled(false); } -void MainWindow::transmit_toboard_stop() +void MainWindow::spp_connect_all() { - if (transmit_timer_handle) { - transmit_timer_handle->stop(); - transmit_timer_handle = NULL; - } - transmit_download_or_upload = TRANSMIT_IDLE; - ui->pbar_toboard->setValue(0); - ui->pbtn_toboard_Upload->setEnabled(true); - uapi_file_transmit_stop(); + uart_rx_Ignoring_display = true; + dongle_is_connected = false; + dongle_try_count = 0; + spp_try_count = 0; +// uapi_uart_callback_register(uart_callback); +// at_handler->at_send_cmd_board(DONGLE_MODE_ADDR,NULL); + ui_display1("spp connectting...",false); + spp_timer_handle = new QTimer(this); + connect(spp_timer_handle, SIGNAL(timeout()), this, SLOT(spp_timer_callback())); + // spp查询定时器周期为1500ms + spp_timer_handle->start(1500); +// ui->pbtn_spp_connect->setEnabled(false); } -void MainWindow::transmit_update_progress() -{ - uint32_t total_size=0; - uint32_t current_size=0; - transmit_get_data_count(&total_size,¤t_size); - if (transmit_download_or_upload == TRANSMIT_UPLOAD) { - ui->pbar_toboard->setMaximum(total_size); - ui->pbar_toboard->setValue(current_size); - } - if (transmit_download_or_upload == TRANSMIT_DOWNLOAD) { - ui->pbar_fromboard->setMaximum(total_size); - ui->pbar_fromboard->setValue(current_size); - } -} -void MainWindow::transmit_progress_start() -{ - transmit_timer_handle = new QTimer(this); - connect(transmit_timer_handle, SIGNAL(timeout()), this, SLOT(transmit_update_progress())); - // 进度条更新时间为60ms - transmit_timer_handle->start(60); -} void MainWindow::at_check_send_status(bool flag) { if(flag){ - ui_display("at cmd send success.\r\n",false); + ui_display1("at cmd send success.\r\n",false); }else{ QMessageBox::warning(this, tr("AT"), tr("AT send fail!\r\n"), QMessageBox::Ok); - ui_display("at cmd send fail.\r\n",false); - } -} - -void MainWindow::dongle_suspend() -{ - if(ui->stkw_stage->currentIndex() == PAGE_COMPLETE){ - ui->tbw_stage_complete->setEnabled(false); - ui->pbtn_spp_connect->setEnabled(true); - }else if(ui->stkw_stage->currentIndex() == PAGE_BOARD){ - ui->tbw_stage_board->setEnabled(false); - } -} - -void MainWindow::dongle_resume() -{ - if(ui->stkw_stage->currentIndex() == PAGE_COMPLETE){ - ui->tbw_stage_complete->setEnabled(true); - ui->pbtn_spp_connect->setEnabled(true); - }else if(ui->stkw_stage->currentIndex() == PAGE_BOARD){ - ui->tbw_stage_board->setEnabled(true); - } -} - -void MainWindow::at_rx_display(int at_buf_len, u8Piont at_buf) -{ - Q_UNUSED(at_buf_len); - at_module_id at_module_id_temp; - at_cmd_id at_cmd_id_temp; - at_handler->at_get_id(&at_module_id_temp, &at_cmd_id_temp); - if (at_buf[0] == MODULE_BT && at_buf[1] == BT_CMD_RX_RESULT) { // 耦合测试RxCount - uint32_t rx_count = at_buf[2] + (at_buf[3] << 8); - ui->ledit_display_rx_count->setText(QString::number(rx_count)); - } else if (at_buf[0] == MODULE_MCU && at_buf[1] == MCU_CMD_CHECK_CONNECTED) { // Dongle是否已连接 - dongle_is_connected = true; - dongle_connected_times = 0; - dongle_resume(); - } else if (at_buf[0] == MODULE_MCU && at_buf[1] == MCU_CMD_RETURN_VALUE) { - for (int i = 0; i < 40; i++) { - qDebug("buf[%d] is %d.\r\n", i, at_buf[i]); - } - ui_display("cmd executed " + (QString)(at_buf[2] == 0 ? "Succ!" : "Fail!") + "\r\n",false); - if (at_buf[3] != 0) { - QByteArray data((const char*)&at_buf[4], at_buf[3]); - ui_display(QString(data),false); - } - } else if (at_buf[0] == at_module_id_temp && at_buf[1] == at_cmd_id_temp) { - ui_display("at receive success.\r\n",false); - } else { - ui_display("at receive fail.\r\n",false); - } - free(at_buf); -} - -void MainWindow::at_stackinfo_send() -{ - at_check_send_status(at_handler->at_send_cmd_string(MODULE_MCU,MCU_CMD_STACKINFO,NULL)); -} - -void MainWindow::at_fsrm_send() -{ - QString str = ui->ledit_at_fsrm->text(); - if (str.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("文件路径为空!"), QMessageBox::Ok); - return; - } - at_check_send_status(at_handler->at_send_cmd_string(MODULE_MCU,MCU_CMD_FSRM,str)); -} - -void MainWindow::at_mediamusicplay_send() -{ - uint8_t media_buf_cmd[2] = {0x00, 0x00}; - QString str = ui->ledit_at_mediamusicplay->text(); - if (str.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("文件路径为空!"), QMessageBox::Ok); - return; - } - QString media_sub_str; - QByteArray data((const char*)media_buf_cmd, 2); - for (int i = 0; i < data.size(); i++) { - media_sub_str += QString(data.at(i)); - } - str.prepend(media_sub_str); - at_check_send_status(at_handler->at_send_cmd_string(MODULE_AUDIO,AUDIO_CMD,str)); -} - -void MainWindow::at_mediamusicstop_send() -{ - uint8_t media_buf_cmd[2] = {0x00, 0x03}; - QString media_sub_str; - QByteArray data((const char*)media_buf_cmd, 2); - for (int i = 0; i < data.size(); i++) { - media_sub_str += QString(data.at(i)); - } - at_check_send_status(at_handler->at_send_cmd_string(MODULE_AUDIO,AUDIO_CMD,media_sub_str)); -} - -void MainWindow::at_mediaaudiorecord_send() -{ - uint8_t media_buf_cmd[2] = {0x01, 0x00}; - QString str = ui->ledit_at_mediaaudiorecord->text(); - if (str.isEmpty()) { - QMessageBox::warning(this, tr("File Path"), tr("文件路径为空!"), QMessageBox::Ok); - return; - } - QString media_sub_str; - QByteArray data((const char*)media_buf_cmd, 2); - for (int i = 0; i < data.size(); i++) { - media_sub_str += QString(data.at(i)); - } - str.prepend(media_sub_str); - at_check_send_status(at_handler->at_send_cmd_string(MODULE_AUDIO,AUDIO_CMD,str)); -} - -/* ----------------------- 耦合测试设置 ------------------------------------------------- */ -void MainWindow::at_bt_delay_ms_complete() -{ - QString str = ui->ledit_delay_ms->text(); - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_DELAY_MS,str)); -} - -void MainWindow::at_set_dongle_addr_complete() -{ - QString str = ui->ledit_dongle_mac->text(); - if (str.isEmpty() || str.size() != 12) { - QMessageBox::warning(this, tr("File Path"), tr("MAC地址为空!"), QMessageBox::Ok); - return; - } - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_DONGLE_MAC,str)); -} -void MainWindow::at_set_bt_format() -{ - ui->ledit_br_rx_channel_complete->setValidator(new MyValidator(0,78,this)); - ui->ledit_br_tx_channel_complete->setValidator(new MyValidator(0,78,this)); - ui->ledit_ble_rx_channel_complete->setValidator(new MyValidator(0,39,this)); - ui->ledit_ble_tx_channel_complete->setValidator(new MyValidator(0,39,this)); - ui->ledit_br_rx_PayloadLen_complete->setValidator(new MyValidator(0,27,this)); - ui->ledit_br_tx_PayloadLen_complete->setValidator(new MyValidator(0,27,this)); - ui->ledit_ble_tx_PayloadLen_complete->setValidator(new MyValidator(0,255,this)); - - ui->ledit_br_rx_channel_board->setValidator(new MyValidator(0,78,this)); - ui->ledit_br_tx_channel_board->setValidator(new MyValidator(0,78,this)); - ui->ledit_ble_rx_channel_board->setValidator(new MyValidator(0,39,this)); - ui->ledit_ble_tx_channel_board->setValidator(new MyValidator(0,39,this)); - ui->ledit_br_rx_PayloadLen_board->setValidator(new MyValidator(0,27,this)); - ui->ledit_br_tx_PayloadLen_board->setValidator(new MyValidator(0,27,this)); - ui->ledit_ble_tx_PayloadLen_board->setValidator(new MyValidator(0,255,this)); - ui->ledit_btlo_channel->setValidator(new MyValidator(0,78,this)); -} - -void MainWindow::at_check_bt_len(int packtype_index) -{ - QComboBox *cbox = qobject_cast(sender()); - int len=at_handler->at_get_packet_len(packtype_index); - QString name = cbox->objectName(); - if(name == "cbox_br_tx_PacketType_complete"){ - const MyValidator *validator=(MyValidator *)ui->ledit_br_tx_PayloadLen_complete->validator(); - delete validator; - ui->ledit_br_tx_PayloadLen_complete->setPlaceholderText("Length(0-"+QString::number(len)+")"); - ui->ledit_br_tx_PayloadLen_complete->setValidator(new MyValidator(0,len,this)); - }else if(name == "cbox_br_rx_PacketType_complete"){ - const MyValidator *validator=(MyValidator *)ui->ledit_br_rx_PayloadLen_complete->validator(); - delete validator; - ui->ledit_br_rx_PayloadLen_complete->setPlaceholderText("Length(0-"+QString::number(len)+")"); - ui->ledit_br_rx_PayloadLen_complete->setValidator(new MyValidator(0,len,this)); - }else if(name == "cbox_br_tx_PacketType_board"){ - const MyValidator *validator=(MyValidator *)ui->ledit_br_tx_PayloadLen_board->validator(); - delete validator; - ui->ledit_br_tx_PayloadLen_board->setPlaceholderText("Length(0-"+QString::number(len)+")"); - ui->ledit_br_tx_PayloadLen_board->setValidator(new MyValidator(0,len,this)); - }else if(name == "cbox_br_rx_PacketType_board"){ - const MyValidator *validator=(MyValidator *)ui->ledit_br_rx_PayloadLen_board->validator(); - delete validator; - ui->ledit_br_rx_PayloadLen_board->setPlaceholderText("Length(0-"+QString::number(len)+")"); - ui->ledit_br_rx_PayloadLen_board->setValidator(new MyValidator(0,len,this)); - } -} - -/* -----------------------耦合测试-整机段------------------------------------------------ */ -void MainWindow::at_get_rx_count_complete() -{ - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_GET_RX, NULL)); -} - -void MainWindow::at_bt_tx_complete() -{ - QString br_tx_switch = ui->cbox_br_tx_on_or_off_complete->currentText(); - QString channel = ui->ledit_br_tx_channel_complete->text(); - int packet_type_index = ui->cbox_br_tx_PacketType_complete->currentIndex(); - QString payload_len = ui->ledit_br_tx_PayloadLen_complete->text(); - int pattern_type_index = ui->cbox_br_tx_pattern_type_complete->currentIndex(); - QString format=at_handler->at_get_br_format(BT_MODE_BR_TX,br_tx_switch,channel,packet_type_index,payload_len,pattern_type_index); - if(format==NULL){ - QMessageBox::warning(this, tr("AT"), tr("length错误!"), QMessageBox::Ok); - } - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_BR_TX,format)); - dongle_is_connected = false; - dongle_suspend(); -} - -void MainWindow::at_bt_rx_complete() -{ - QString br_tx_switch = ui->cbox_br_tx_on_or_off_complete->currentText(); - QString channel = ui->ledit_br_rx_channel_complete->text(); - int packet_type_index = ui->cbox_br_rx_PacketType_complete->currentIndex(); - QString payload_len = ui->ledit_br_rx_PayloadLen_complete->text(); - int pattern_type_index = ui->cbox_br_rx_pattern_type_complete->currentIndex(); - QString format=at_handler->at_get_br_format(BT_MODE_BR_RX,br_tx_switch,channel,packet_type_index,payload_len,pattern_type_index); - if(format==NULL){ - QMessageBox::warning(this, tr("AT"), tr("length错误!"), QMessageBox::Ok); + ui_display1("at cmd send fail.\r\n",false); } - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_BR_RX,format)); - dongle_is_connected = false; - dongle_suspend(); } -void MainWindow::at_ble_tx_complete() +void MainWindow::ui_open_mac_config() { - QString br_tx_switch = ui->cbox_ble_tx_on_or_off_complete->currentText(); - QString channel = ui->ledit_ble_tx_channel_complete->text(); - int pattern_type_index = ui->cbox_ble_tx_pattern_type_complete->currentIndex(); - QString payload_len = ui->ledit_ble_tx_PayloadLen_complete->text(); - int phy_type_index = ui->cbox_ble_tx_PacketType_complete->currentIndex(); - QString format=at_handler->at_get_ble_format(BT_MODE_BLE_TX,br_tx_switch,channel,pattern_type_index,payload_len,phy_type_index); - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_BLE_TX,format)); - dongle_is_connected = false; - dongle_suspend(); -} + DialogSettings *diag=new DialogSettings(); -void MainWindow::at_ble_rx_complete() -{ - QString br_tx_switch = ui->cbox_ble_rx_on_or_off_complete->currentText(); - QString channel = ui->ledit_ble_rx_channel_complete->text(); - int phy_type_index = ui->cbox_ble_rx_PacketType_complete->currentIndex(); - QString format=at_handler->at_get_ble_format(BT_MODE_BLE_RX,br_tx_switch,channel,0,0,phy_type_index); - at_check_send_status(at_handler->at_send_cmd_string(MODULE_BT,BT_CMD_BLE_RX,format)); - dongle_is_connected = false; - dongle_suspend(); -} + diag->show(); -void MainWindow::at_custom_send() -{ - QString moduleId = ui->ledit_at_custom_moduleId->text(); - QString cmdId = ui->ledit_at_custom_CmdId->text(); - QString payload = ui->ledit_at_custom_Payload->text(); - bool ok; - at_check_send_status(at_handler->at_send_cmd_string((at_module_id)moduleId.toUInt(&ok,16),(at_cmd_id)cmdId.toUInt(&ok,16),payload)); -} -/* -----------------------传导测试-单板段------------------------------------------------ */ -void MainWindow::at_bt_tx_board() -{ - QString br_tx_switch = ui->cbox_br_tx_on_or_off_board->currentText(); - if (br_tx_switch.contains("ON") && bt_test_switch == true) { - QMessageBox::warning(this, tr("操作错误"), tr("应先关闭射频测试项!"), QMessageBox::Ok); - } - bt_test_switch = br_tx_switch.contains("ON") ? true : false; - QString channel = ui->ledit_br_tx_channel_board->text(); - int packet_type_index = ui->cbox_br_tx_PacketType_board->currentIndex(); - QString payload_len = ui->ledit_br_tx_PayloadLen_board->text(); - int pattern_type_index = ui->cbox_br_tx_pattern_type_board->currentIndex(); - QString format=at_handler->at_get_br_format(BT_MODE_BR_TX,br_tx_switch,channel,packet_type_index,payload_len,pattern_type_index); - if(format==NULL){ - QMessageBox::warning(this, tr("AT"), tr("length错误!"), QMessageBox::Ok); - } - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BR_TX,format)); -} -void MainWindow::at_bt_rx_board() -{ - QString br_rx_switch = ui->cbox_br_rx_on_or_off_board->currentText(); - if (br_rx_switch.contains("ON") && bt_test_switch == true) { - QMessageBox::warning(this, tr("操作错误"), tr("应先关闭射频测试项!"), QMessageBox::Ok); - } - bt_test_switch = br_rx_switch.contains("ON") ? true : false; - QString channel = ui->ledit_br_rx_channel_board->text(); - int packet_type_index = ui->cbox_br_rx_PacketType_board->currentIndex(); - QString payload_len = ui->ledit_br_rx_PayloadLen_board->text(); - int pattern_type_index = ui->cbox_br_rx_pattern_type_board->currentIndex(); - QString format=at_handler->at_get_br_format(BT_MODE_BR_RX,br_rx_switch,channel,packet_type_index,payload_len,pattern_type_index); - if(format==NULL){ - QMessageBox::warning(this, tr("AT"), tr("length错误!"), QMessageBox::Ok); - } - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BR_RX,format)); -} -void MainWindow::at_ble_tx_board() -{ - QString ble_tx_switch = ui->cbox_ble_tx_on_or_off_board->currentText(); - if (ble_tx_switch.contains("ON") && bt_test_switch == true) { - QMessageBox::warning(this, tr("操作错误"), tr("应先关闭射频测试项!"), QMessageBox::Ok); - } - bt_test_switch = ble_tx_switch.contains("ON") ? true : false; - QString channel = ui->ledit_ble_tx_channel_board->text(); - int pattern_type_index = ui->cbox_ble_tx_pattern_type_board->currentIndex(); - QString payload_len = ui->ledit_ble_tx_PayloadLen_board->text(); - int phy_type_index = ui->cbox_ble_tx_PacketType_board->currentIndex(); - QString format=at_handler->at_get_ble_format(BT_MODE_BLE_TX,ble_tx_switch,channel,pattern_type_index,payload_len,phy_type_index); - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BLE_TX,format)); -} -void MainWindow::at_ble_rx_board() -{ - QString ble_rx_switch = ui->cbox_ble_rx_on_or_off_board->currentText(); - if (ble_rx_switch.contains("ON") && bt_test_switch == true) { - QMessageBox::warning(this, tr("操作错误"), tr("应先关闭射频测试项!"), QMessageBox::Ok); - } - bt_test_switch = ble_rx_switch.contains("ON") ? true : false; - QString channel = ui->ledit_ble_rx_channel_board->text(); - int phy_type_index = ui->cbox_ble_rx_PacketType_board->currentIndex(); - QString format=at_handler->at_get_ble_format(BT_MODE_BLE_RX,ble_rx_switch,channel,0,0,phy_type_index); - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BLE_RX,format)); -} - -void MainWindow::at_bt_dutmode_board() -{ - QString bt_dutmode_switch = ui->cbox_btdutmode_on_or_off_board->currentText(); - if (bt_dutmode_switch.contains("ON") && bt_test_switch == true) { - QMessageBox::warning(this, tr("操作错误"), tr("应先关闭射频测试项!"), QMessageBox::Ok); - } - bt_test_switch = bt_dutmode_switch.contains("ON") ? true : false; - QString format=at_handler->at_get_switch_format(bt_dutmode_switch); - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BTDUTMODE,format)); -} -void MainWindow::at_bt_btlo_board() -{ - QString format; - format += ui->ledit_btlo_channel->text()+","; - format += "7,"; - if(ui->cbox_btlo_on_or_off_board->currentText().contains("ON")){ - format+="1"; - }else{ - format+="2"; - } - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BTLO,format)); -} - -void MainWindow::at_bt_btpwr_board() -{ - QString format; - format += ui->ledit_btpwr_powerchip->text()+","; - if(ui->cbox_btpwr_on_or_off_board->currentText().contains("ON")){ - format+="1"; - }else{ - format+="0"; - } - at_check_send_status(at_handler->at_send_cmd_board(BT_MODE_BTPWR,format)); -} - -void MainWindow::at_bt_wakeup() -{ - QString format= "012345678901234567890123456789"; - at_check_send_status(at_handler->at_send_cmd_board(MODE_MAX,format)); -} - -void MainWindow::at_bt_sleep() -{ - QString format= "AT^RMVO"; - at_check_send_status(at_handler->at_send_cmd_board(MODE_MAX,format)); } /* ----------------------------------------------------------------------------------- */ diff --git a/mainwindow.h b/mainwindow.h index 8a58b37..781207a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -2,19 +2,23 @@ #define MAINWINDOW_H #include -#include #include #include #include #include #include -#include "header.h" #include "result_thread.h" -#include "common.h" -#include "at_data.h" #include "QFileDialog" #include "QMessageBox" #include "QTime" +#include "common.h" +#include +#include +#include + +#include "sqldbmanager.h" + +#include "settings.h" #define COM_NUMBER 10 @@ -34,8 +38,18 @@ public: private: Ui::MainWindow *ui; + /* ------------------------uart------------------------------- */ - Result_Thread *result_thread; + Result_Thread *result_thread1; + Result_Thread *result_thread2; + Result_Thread *result_thread3; + Result_Thread *result_thread4; + + QSerialPort *serialport1; + QSerialPort *serialport2; + QSerialPort *serialport3; + QSerialPort *serialport4; + // 是否忽略uart数据,不回显 bool uart_rx_Ignoring_display {false}; // 是否有uart通路数据上报 @@ -52,20 +66,6 @@ private: int dongle_try_count {0}; int spp_try_count {0}; - /* -----------------------transmit---------------------------- */ - QStringList transmit_fromborad_local_list; - QStringList tansmit_fromborad_borad_list; - QStringList transmit_toboard_local_list; - QStringList transmit_toboard_borad_list; - typedef enum{ - TRANSMIT_IDLE, - TRANSMIT_DOWNLOAD, - TRANSMIT_UPLOAD, - }transmit_mode; - // download is 1,uplaod is 2 - transmit_mode transmit_download_or_upload {TRANSMIT_IDLE}; - QTimer *transmit_timer_handle {NULL}; - void transmit_progress_start(); /* -------------------------UI------------------------------- */ enum ui_page{ PAGE_COMPLETE, @@ -73,73 +73,54 @@ private: }; void ui_setting_save(); void ui_setting_read(); - void ui_display(QString str,bool inOrOut); - /* -------------------------AT------------------------------- */ - At_Process *at_handler; + void ui_display1(QString str,bool inOrOut); + void ui_display2(QString str,bool inOrOut); + void ui_display3(QString str,bool inOrOut); + void ui_display4(QString str,bool inOrOut); void at_check_send_status(bool flag); - void at_set_bt_format(); - bool bt_test_switch {false}; + + + void uart_send_data1(QString cmd); + void uart_send_data2(QString cmd); + void uart_send_data3(QString cmd); + void uart_send_data4(QString cmd); /* ------------------------end------------------------------ */ private slots: /* --------------------------UI------------------------------ */ - void ui_tab_mainwindow_complete(); - void ui_tab_mainwindow_board(); void ui_save_windows(); /* -------------------------uart----------------------------- */ - void uart_process(); - void uart_send_data(); - void uart_rx_dispaly(int buf_len, u8Piont buf); - void uart_check_dtr_rts(); + void uart_process1(); + void uart_process2(); + void uart_process3(); + void uart_process4(); + void readData1(); + void readData2(); + void readData3(); + void readData4(); + void uart_rx_dispaly1(int buf_len, u8Piont buf); + void uart_rx_dispaly2(int buf_len, u8Piont buf); + void uart_rx_dispaly3(int buf_len, u8Piont buf); + void uart_rx_dispaly4(int buf_len, u8Piont buf); void uart_com_select(); void uart_com_switch(QString com); void uart_baud_switch(QString baud); /* -------------------------spp------------------------------- */ - void spp_connect(); - void spp_timer_callback(); + void spp_connect_all(); + void spp_connect_1(); + void spp_connect_2(); + void spp_connect_3(); + void spp_connect_4(); + void spp_timer_callback1(); + void spp_timer_callback2(); + void spp_timer_callback3(); + void spp_timer_callback4(); + void spp_connected_callback(); - void dongle_suspend(); - void dongle_resume(); - /* -----------------------at/transmit---------------------------- */ - void at_rx_display(int at_buf_len, u8Piont at_buf); - void at_stackinfo_send(); - void at_fsrm_send(); - void at_mediamusicplay_send(); - void at_mediamusicstop_send(); - void at_mediaaudiorecord_send(); - void at_custom_send(); - void transmit_ls_rx_diaplay(int transmit_ls_size, vPiont transmit_ls_buff); - void transmit_rx_display(bool transmit_result_flag); - void transmit_update_progress(); - void transmit_fromboard_name_change(); - void transmit_fromboard_selectfilepath(); - void transmit_fromboard_getfilelist(); - void transmit_fromboard_download(); - void transmit_fromboard_delete(); - void transmit_fromboard_stop(); - void transmit_toboard_choosefile(); - void transmit_toboard_upload(); - void transmit_toboard_stop(); - /* ----------------------- 耦合测试设置 --------------------------- */ - void at_set_dongle_addr_complete(); - void at_bt_delay_ms_complete(); - void at_check_bt_len(int packtype_index); - /* -----------------------耦合测试-整机段-------------------------- */ - void at_get_rx_count_complete(); - void at_bt_tx_complete(); // BT长发(非信令) - void at_bt_rx_complete(); // BT长收(非信令) - void at_ble_tx_complete(); // BLE长发(非信令) - void at_ble_rx_complete(); // BLE长收(非信令) - /* -----------------------传导测试-单板段-------------------------- */ - void at_bt_tx_board(); // BT长发(非信令) - void at_bt_rx_board(); // BT长收(非信令) - void at_ble_tx_board(); // BLE长发(非信令) - void at_ble_rx_board(); // BLE长收(非信令) - void at_bt_dutmode_board(); - void at_bt_btlo_board(); - void at_bt_btpwr_board(); - void at_bt_wakeup(); - void at_bt_sleep(); + /* -------------------------cfg------------------------------- */ + void ui_open_mac_config(); + /* ------------------------------------------------------------- */ + void openLogfolder(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 0eaae6b..17eba52 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 890 - 707 + 1354 + 694 @@ -18,7 +18,7 @@ - Factory_Tools + BTMacWriteTool V1.0 @@ -31,2489 +31,34 @@ Qt::LeftToRight - + - 0 - 0 - 631 - 371 - - - - - Times New Roman - 10 - - - - true - - - QTextBrowser{background-color:rgb(26, 26, 26); - color:rgb(127, 255, 0)} - - - Qt::ScrollBarAlwaysOn - - - Qt::TextBrowserInteraction - - - - - - 0 - 370 - 891 - 311 + 1040 + 10 + 306 + 621 - 黑体 - 50 - false + Arial + 14 - - 0 - - - - - false - - - - 0 - 0 - 891 - 291 - - - - - 0 - 0 - - - - - 黑体 - 12 - 50 - false - - - - ArrowCursor - - - 3 - - - - Debug - - - - - 0 - 0 - 771 - 261 - - - - - - - 790 - 30 - 75 - 23 - - - - - Times New Roman - 10 - 50 - false - - - - 发送 - - - - - - 790 - 83 - 75 - 23 - - - - - Times New Roman - 10 - 50 - false - - - - 清除发送 - - - - - - 789 - 157 - 88 - 16 - - - - - Times New Roman - 10 - 50 - false - - - - 加回车换行 - - - false - - - - - - To Board - - - - - 20 - 210 - 831 - 23 - - - - 0 - - - false - - - - - - 20 - 20 - 831 - 161 - - - - - Times New Roman - 10 - 50 - false - - - - Upload File - - - - - 10 - 40 - 121 - 21 - - - - - Times New Roman - 10 - 50 - false - - - - Local File Path: - - - - - - 10 - 100 - 121 - 20 - - - - - Times New Roman - 10 - 50 - false - - - - Board File Path: - - - - - - 730 - 100 - 75 - 23 - - - - - Times New Roman - 10 - 50 - false - - - - stop - - - - - - 140 - 100 - 471 - 20 - - - - - - - 640 - 40 - 161 - 23 - - - - - Times New Roman - 10 - 50 - false - - - - Choose File - - - - - - 640 - 100 - 75 - 23 - - - - - Times New Roman - 10 - 50 - false - - - - Upload - - - false - - - - - - 140 - 40 - 471 - 20 - - - - - - - - From Board - - - - - 20 - 20 - 701 - 71 - - - - - Times New Roman - 10 - 50 - false - - - - File Storage - - - - - 10 - 30 - 121 - 21 - - - - - Times New Roman - 10 - 50 - false - - - - Local File Path: - - - - - - 140 - 30 - 421 - 20 - - - - - - - 580 - 30 - 91 - 23 - - - - - Times New Roman - 10 - 50 - false - - - - .... - - - - - - - 20 - 110 - 701 - 101 - - - - - Times New Roman - 10 - 50 - false - - - - File Selector - - - - - 40 - 20 - 71 - 20 - - - - - Times New Roman - 10 - 50 - false - - - - File Path: - - - - - - 140 - 20 - 531 - 20 - - - - - - - 140 - 60 - 411 - 22 - - - - - - - 570 - 60 - 101 - 23 - - - - - Times New Roman - 9 - 50 - false - - - - Get file List - - - - - - 40 - 60 - 71 - 20 - - - - - Times New Roman - 10 - 50 - false - - - - File Name: - - - - - - 290 - 130 - 75 - 23 - - - - PushButton - - - - - - - 20 - 220 - 711 - 20 - - - - 0 - - - - - - 760 - 20 - 95 - 201 - - - - - - - - Times New Roman - 10 - 50 - false - - - - Download - - - false - - - - - - - - Times New Roman - 10 - 50 - false - - - - Delete - - - - - - - - Times New Roman - 10 - 50 - false - - - - Stop - - - - - - - - - AT命令 - - - - - 0 - 0 - 891 - 271 - - - - - 黑体 - 10 - 50 - false - - - - QTabWidget::West - - - QTabWidget::Triangular - - - 0 - - - Qt::ElideNone - - - - MCU - - - - - 20 - 10 - 831 - 211 - - - - Debug - - - - - 20 - 30 - 791 - 31 - - - - - 10 - - - - - StackInfo - - - - - - - 待开发 - - - - - - - 待开发 - - - - - - - 待开发 - - - - - - - 待开发 - - - - - - - - - 20 - 90 - 371 - 30 - - - - - - - - - - FSRM - - - - - - - - - 20 - 150 - 731 - 25 - - - - - - - 发送 - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 30 - 20 - - - - - - - - - 黑体 - 8 - 50 - false - - - - module id - - - - - - - - 黑体 - 8 - 50 - false - - - - cmd id - - - - - - - payload - - - - - - - - - - MEDIA - - - - - 20 - 10 - 821 - 161 - - - - Media - - - - - 20 - 30 - 591 - 32 - - - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - - - Music Play - - - - - - - Music Stop - - - - - - - - - 20 - 80 - 591 - 32 - - - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - - - Audio Record - - - - - - - - - - BT - - - - - 20 - 10 - 821 - 111 - - - - 耦合测试设置 - - - - - 20 - 40 - 671 - 25 - - - - - - - - 0 - 0 - - - - 延时时间 - - - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ms - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - DongleMAC - - - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - 耦合测试 - - - - - 20 - 10 - 831 - 121 - - - - BR EDR - - - - - 20 - 20 - 761 - 81 - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - DH1 - - - - - DH3 - - - - - DH5 - - - - - 2-DH1 - - - - - 2-DH3 - - - - - 2-DH5 - - - - - 3-DH1 - - - - - 3-DH3 - - - - - 3-DH5 - - - - - - - - Length(0-27) - - - - - - - - 0 - 0 - - - - - ON - - - - - - - - - 0 - 0 - - - - - 10101010 - - - - - PRBS9 - - - - - 11110000 - - - - - - - - - 0 - 0 - - - - BR RX - - - - - - - - 0 - 0 - - - - 0 - - - - ON - - - - - - - - - 0 - 0 - - - - BR TX - - - - - - - - 0 - 0 - - - - - - - true - - - QLineEdit::Normal - - - Channel(0-78) - - - Qt::LogicalMoveStyle - - - false - - - - - - - - 0 - 0 - - - - - - - Channel(0-78) - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - DH1 - - - - - DH3 - - - - - DH5 - - - - - 2-DH1 - - - - - 2-DH3 - - - - - 2-DH5 - - - - - 3-DH1 - - - - - 3-DH3 - - - - - 3-DH5 - - - - - - - - - 0 - 0 - - - - - 10101010 - - - - - PRBS9 - - - - - 11110000 - - - - - - - - Length(0-27) - - - - - - - - - - 20 - 140 - 831 - 111 - - - - BLE - - - - - 20 - 70 - 461 - 26 - - - - - 3 - - - - - - 0 - 0 - - - - - ON - - - - - - - - Channel(0-39) - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - BLE 1M - - - - - BLE 2M - - - - - - - - - 0 - 0 - - - - BLE RX - - - - - - - - - 20 - 21 - 761 - 25 - - - - - - - - 0 - 0 - - - - BLE TX - - - - - - - - 0 - 0 - - - - - ON - - - - - - - - Channel(0-39) - - - - - - - - 0 - 0 - - - - - 10101010 - - - - - PRBS9 - - - - - 11110000 - - - - - - - - Length(0-255) - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - BLE 1M - - - - - BLE 2M - - - - - - - - - - 560 - 70 - 221 - 25 - - - - - - - 获取RX Count - - - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - false - - - - 0 - 0 - 911 - 291 - - - - - 黑体 - 12 - 50 - false - - - - 2 - - - - Debug - - - - - 0 - 0 - 771 - 261 - - - - - - - 790 - 30 - 75 - 23 - - - - - 黑体 - 10 - 50 - false - - - - 发送 - - - - - - 790 - 83 - 75 - 23 - - - - - 黑体 - 10 - 50 - false - - - - 清除发送 - - - - - - 789 - 157 - 88 - 16 - - - - - 黑体 - 10 - 50 - false - - - - 加回车换行 - - - false - - - - - - MCU - - - - - BT - - - - - 0 - 0 - 911 - 281 - - - - - 黑体 - 10 - 50 - false - - - - QTabWidget::West - - - QTabWidget::Triangular - - - 2 - - - Qt::ElideNone - - - false - - - - 非信令测试 - - - - - 20 - 140 - 831 - 111 - - - - BLE - - - - - 20 - 20 - 761 - 25 - - - - - - - - 0 - 0 - - - - BLE TX - - - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - - - - Channel(0-39) - - - - - - - - 0 - 0 - - - - - 10101010 - - - - - PRBS9 - - - - - 11110000 - - - - - - - - Length(0-255) - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - BLE 1M - - - - - BLE 2M - - - - - - - - - - 20 - 69 - 461 - 26 - - - - - 3 - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - Channel(0-39) - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - BLE 1M - - - - - BLE 2M - - - - - - - - - 0 - 0 - - - - BLE RX - - - - - - - - - - 20 - 10 - 831 - 121 - - - - BR EDR - - - - - 20 - 20 - 761 - 81 - - - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - - 0 - 0 - - - - - 10101010 - - - - - PRBS9 - - - - - 11110000 - - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - DH1 - - - - - DH3 - - - - - DH5 - - - - - 2-DH1 - - - - - 2-DH3 - - - - - 2-DH5 - - - - - 3-DH1 - - - - - 3-DH3 - - - - - 3-DH5 - - - - - - - - - 0 - 0 - - - - - - - Channel(0-78) - - - - - - - - 0 - 0 - - - - - 10101010 - - - - - PRBS9 - - - - - 11110000 - - - - - - - - - 0 - 0 - - - - BR RX - - - - - - - Length(0-27) - - - - - - - - 0 - 0 - - - - 0 - - - - ON - - - - - OFF - - - - - - - - Length(0-27) - - - - - - - - 0 - 0 - - - - BR TX - - - - - - - - 0 - 0 - - - - Qt::DefaultContextMenu - - - - DH1 - - - - - DH3 - - - - - DH5 - - - - - 2-DH1 - - - - - 2-DH3 - - - - - 2-DH5 - - - - - 3-DH1 - - - - - 3-DH3 - - - - - 3-DH5 - - - - - - - - - 0 - 0 - - - - - - - Channel(0-78) - - - - - - - - - - 信令测试 - - - - - 20 - 10 - 831 - 111 - - - - 信令 - - - - - 20 - 30 - 371 - 29 - - - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 0 - 0 - - - - BTDUTMODE - - - - - - - - 0 - 0 - - - - 信令测试: - - - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - Qt::Horizontal - - - - 30 - 20 - - - - - - - - - - - 其他 - - - - - 20 - 20 - 791 - 121 - - - - 单音测试与功率调整 - - - - - 30 - 40 - 731 - 25 - - - - - 10 - - - - - channel(0-78) - - - - - - - - 0 - 0 - - - - 功率调整 - - - - - - - - 0 - 0 - - - - 单音测试 - - - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - power chip(2-14) - - - - - - - - - - 20 - 140 - 791 - 111 - - - - BT_UART - - - - - 30 - 40 - 75 - 23 - - - - 唤醒 - - - - - - 150 - 40 - 75 - 23 - - - - 睡眠 - - - - - - - - - - - - - 650 - 0 - 224 - 389 - - - - - 5 - - - 20 - - - 5 - - - 20 - - - 20 - - + + - + 0 0 - 黑体 - 9 + Arial + 14 50 false @@ -2525,10 +70,10 @@ false - 115200 + 500000 - 6 + 11 true @@ -2630,1217 +175,707 @@ - - + + + + true + - + 0 0 - 黑体 - 9 + Arial + 14 50 false - - + + 全部开始写地址 - - MAC地址 + + false - - - - - 0 - 0 - - - - 串口操作 + + + + true - - - - - + 0 0 - 黑体 - 9 + Arial + 14 50 false - RTS - - - - - - - - 0 - 0 - - - - - 黑体 - 9 - 50 - false - + 设置Mac地址 - - 保存窗口 + + false - - - - - 0 - 0 - - + + - 黑体 - 9 - 50 - false + Arial + 14 - - DTR + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:14pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'黑体'; font-size:9pt;">28110601012D 至</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'黑体'; font-size:9pt;">2811060287CD</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'黑体'; font-size:9pt;">共 100000 地址</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'黑体'; font-size:9pt;">截止:2024-11-1</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'黑体'; font-size:9pt;">已成功写入 0 地址</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'黑体'; font-size:9pt;">还剩余 1000 地址</span></p></body></html> - - - - - 0 - 0 - - + + - 黑体 - 9 - 50 - false + Arial + 14 - 16进制显示 - - - - - - - - 0 - 0 - - - - - 黑体 - 9 - 50 - false - - - - 打开串口 - - - true - - - false - - - false - - - false - - - - - - - false - - - - 0 - 0 - - - - - 黑体 - 9 - 50 - false - - - - 连接设备 - - - false - - - - - - - - 0 - 0 - - - - - 黑体 - 9 - 50 - false - - - - 16进制发送 - - - - - - - - 0 - 0 - - - - - 黑体 - 9 - 50 - false - - - - - COM1 - - - - - - - - - 0 - 0 - - - - - 黑体 - 9 - 50 - false - - - - 清除接收 - - - - - - - - 20 - 20 - - - - QPushButton{background-color: rgb(255, 0, 0);} - - - + 打开日志路径 - - - - - 0 - 0 - 890 - 22 - - - - - 黑体 - 12 - 50 - false - - - + + + + 0 + 10 + 1032 + 621 + + - 12 + Arial + 14 - - 菜单 + + Qt::Horizontal - - - - - - - - - true - - - true - - - - - true - - - true - - - 整机 - - - - 黑体 - 12 - - - - - - true - - - false - - - 单板 - - - - 12 - - - - - - dongle调试 - - - - 12 - - - - - - - MyComboBox - QComboBox -
custom.h
- - mouse_clicked(bool) - -
- - MyLineEdit - QLineEdit -
custom.h
-
-
- - - - pbtn_open_uart - clicked() - MainWindow - uart_process() - - - 849 - 154 - - - 838 - 261 - - - - - pbtn_clear_display - clicked() - txtb_dispaly - clear() - - - 849 - 293 - - - 614 - 380 - - - - - ckbox_dtr - stateChanged(int) - MainWindow - uart_check_dtr_rts() - - - 815 - 334 - - - 882 - 371 - - - - - ckbox_rts - stateChanged(int) - MainWindow - uart_check_dtr_rts() - - - 711 - 334 - - - 758 - 373 - - - - - cbox_uart_com_select - mouse_clicked(bool) - MainWindow - uart_com_select() - - - 719 - 61 - - - 888 - 100 - - - - - pbtn_spp_connect - clicked() - MainWindow - spp_connect() - - - 811 - 245 - - - 888 - 267 - - - - - pbtn_toboard_stop - clicked() - MainWindow - transmit_toboard_stop() - - - 810 - 559 - - - 739 - 294 - - - - - pbtn_toboard_Upload - clicked() - MainWindow - transmit_toboard_upload() - - - 715 - 559 - - - 665 - 296 - - - - - pbtn_fromboard_getfilelist - clicked() - MainWindow - transmit_fromboard_getfilelist() - - - 670 - 609 - - - 654 - 408 - - - - - pbtn_send_data - clicked() - MainWindow - uart_send_data() - - - 844 - 469 - - - 865 - 411 - - - - - pbtn_fromboard_download - clicked() - MainWindow - transmit_fromboard_download() - - - 830 - 489 - - - 849 - 420 - - - - - pbtn_fromboard_selectfilepath - clicked() - MainWindow - transmit_fromboard_selectfilepath() - - - 665 - 489 - - - 673 - 417 - - - - - pbtn_clear_senddata - clicked() - tedit_input_data - clear() - - - 866 - 522 - - - 700 - 591 - - - - - pbtn_fromboard_stop - clicked() - MainWindow - transmit_fromboard_stop() - - - 855 - 605 - - - 676 - 315 - - - - - pbtn_fromboard_delete - clicked() - MainWindow - transmit_fromboard_delete() - - - 855 - 547 - - - 671 - 351 - - - - - ledit_formboad_bordpath - textEdited(QString) - MainWindow - transmit_fromboard_name_change() - - - 499 - 566 - - - 688 - 273 - - - - - pbtn_toboard_choosefile - clicked() - MainWindow - transmit_toboard_choosefile() - - - 736 - 499 - - - 660 - 343 - - - - - action_complete - triggered(bool) - MainWindow - ui_tab_mainwindow_complete() - - - -1 - -1 - - - 468 - 363 - - - - - action_board - triggered(bool) - MainWindow - ui_tab_mainwindow_board() - - - -1 - -1 - - - 539 - 363 - - - - - pbtn_board - clicked() - tedit_input_data_board - clear() - - - 822 - 522 - - - 767 - 568 - - - - - pbtn_send_data_board - clicked() - MainWindow - uart_send_data() - - - 842 - 469 - - - 888 - 484 - - - - - pbtn_at_mediaaudiorecord - clicked() - MainWindow - at_mediaaudiorecord_send() - - - 646 - 535 - - - 643 - 285 - - - - - pbtn_at_stackinfo - clicked() - MainWindow - at_stackinfo_send() - - - 160 - 485 - - - 654 - 412 - - - - - pbtn_at_fsrm - clicked() - MainWindow - at_fsrm_send() - - - 428 - 544 - - - 655 - 254 - - - - - pbtn_at_mediamusicstop - clicked() - MainWindow - at_mediamusicstop_send() - - - 646 - 485 - - - 656 - 381 - - - - - pbtn_at_mediamusicplay - clicked() - MainWindow - at_mediamusicplay_send() - - - 545 - 485 - - - 654 - 330 - - - - - pbtn_br_tx_complete - clicked() - MainWindow - at_bt_tx_complete() - - - 156 - 481 - - - 636 - 372 - - - - - pbtn_br_rx_complete - clicked() - MainWindow - at_bt_rx_complete() - - - 156 - 519 - - - 637 - 335 - - - - - pbtn_ble_tx_complete - clicked() - MainWindow - at_ble_tx_complete() - - - 149 - 603 - - - 639 - 361 - - - - - pbtn_ble_rx_complete - clicked() - MainWindow - at_ble_rx_complete() - - - 141 - 652 - - - 444 - 354 - - - - - pbtn_br_tx_board - clicked() - MainWindow - at_bt_tx_board() - - - 156 - 481 - - - 639 - 325 - - - - - pbtn_br_rx_board - clicked() - MainWindow - at_bt_rx_board() - - - 156 - 519 - - - 646 - 169 - - - - - pbtn_btdutmode_board - clicked() - MainWindow - at_bt_dutmode_board() - - - 265 - 484 - - - 646 - 210 - - - - - pbtn_ble_tx_board - clicked() - MainWindow - at_ble_tx_board() - - - 139 - 581 - - - 633 - 248 - - - - - pbtn_ble_rx_board - clicked() - MainWindow - at_ble_rx_board() - - - 139 - 630 - - - 643 - 204 - - - - - pbtn_get_rx_count - clicked() - MainWindow - at_get_rx_count_complete() - - - 674 - 652 - - - 647 - 134 - - - - - pbtn_delay_time - clicked() - MainWindow - at_bt_delay_ms_complete() - - - 134 - 492 - - - 637 - 161 - - - + + + + Arial + 14 + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + + + MAC地址 + + + + + + + true + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + 开始写地址 + + + false + + + + + + + + Arial + 14 + + + + true + + + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} + + + 1 + + + Qt::ScrollBarAlwaysOn + + + Qt::TextBrowserInteraction + + + + + + + + + Arial + 14 + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + + + MAC地址 + + + + + + + true + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + 开始写地址 + + + false + + + + + + + + Arial + 14 + + + + true + + + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} + + + Qt::ScrollBarAlwaysOn + + + Qt::TextBrowserInteraction + + + + + + + + + Arial + 14 + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + + + MAC地址 + + + + + + + true + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + 开始写地址 + + + false + + + + + + + + Arial + 14 + + + + true + + + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} + + + Qt::ScrollBarAlwaysOn + + + Qt::TextBrowserInteraction + + + + + + + + + Arial + 14 + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + + + MAC地址 + + + + + + + true + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + 开始写地址 + + + false + + + + + + + + Arial + 14 + + + + true + + + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} + + + Qt::ScrollBarAlwaysOn + + + Qt::TextBrowserInteraction + + + + + +
+ splitter + verticalLayoutWidget_2 +
+ + + true + + + true + + +
+ + + MyComboBox + QComboBox +
custom.h
+ + mouse_clicked(bool) + +
+
+ + - pbtn_donglemac + pbtn_spp_reconnect_1 clicked() MainWindow - at_set_dongle_addr_complete() + spp_connect_1() - 581 - 492 - - - 653 + 126 126 - - - - cbox_uart_com_select - activated(QString) - MainWindow - uart_com_switch(QString) - - - 702 - 55 - - - 764 - 76 - - - - - cbox_uart_baud_select - activated(QString) - MainWindow - uart_baud_switch(QString) - - - 712 - 103 - - - 744 - 133 - - - - - cbox_br_tx_PacketType_complete - activated(int) - MainWindow - at_check_bt_len(int) - - - 514 - 479 - - - 649 - 73 - - - - - cbox_br_rx_PacketType_complete - activated(int) - MainWindow - at_check_bt_len(int) - - - 514 - 517 - - - 647 - 55 - - - - - cbox_br_tx_PacketType_board - activated(int) - MainWindow - at_check_bt_len(int) - - - 514 - 479 - - - 639 - 116 - - - - - cbox_br_rx_PacketType_board - activated(int) - MainWindow - at_check_bt_len(int) - - - 514 - 517 - - 638 - 85 + 676 + 346 - pushButton + pbtn_spp_reconnect_2 clicked() MainWindow - ui_save_windows() + spp_connect_2() - 702 - 285 + 386 + 126 - 647 - 236 + 676 + 346 - pbtn_btlo_board + pbtn_spp_reconnect_3 clicked() MainWindow - at_bt_btlo_board() + spp_connect_3() - 144 - 502 + 645 + 126 - 642 - 200 + 676 + 346 - pbtn_btpwr_board + pbtn_spp_reconnect_4 clicked() MainWindow - at_bt_btpwr_board() + spp_connect_4() - 589 - 502 + 905 + 126 - 684 - 304 + 676 + 346 - pbtn_at_custom_send + pbtn_spp_connect_all clicked() MainWindow - at_custom_send() + spp_connect_all() - 169 - 602 + 1192 + 79 - 661 - 190 + 676 + 346 - pushButton_3 + pushButton_open_mac_config clicked() MainWindow - at_bt_wakeup() + ui_open_mac_config() - 122 - 615 + 1192 + 126 - 957 - 601 + 676 + 346 - pushButton_4 + pushButton_openlogfolder clicked() MainWindow - at_bt_sleep() + openLogfolder() - 244 - 615 + 1192 + 608 - 970 - 548 + 676 + 346 - transmit_toboard_choosefile() - uart_send_data() - uart_process() - check_word_wrap() - check_hex_display() - at_stackinfo_send() - uart_check_dtr_rts() - uart_com_select() - transmit_fromboard_selectfilepath() - transmit_fromboard_getfilelist() - transmit_fromboard_download() - transmit_toboard_upload() - transmit_toboard_stop() - transmit_fromboard_delete() - transmit_fromboard_stop() - spp_connect() - transmit_fromboard_name_change() - at_fsrm_send() - at_mediamusicplay_send() - at_mediamusicstop_send() - at_mediaaudiorecord_send() - ui_tab_mainwindow_complete() - ui_tab_mainwindow_board() - at_bt_tx_complete() - at_bt_rx_complete() - at_ble_tx_complete() - at_ble_rx_complete() - at_bt_rx_board() - at_bt_tx_board() - at_ble_tx_board() - at_ble_rx_board() - at_bt_dutmode_board() - at_bt_delay_ms_complete() - at_set_dongle_addr_complete() - at_get_rx_count_complete() - uart_com_switch(QString) - uart_baud_switch(QString) - at_check_bt_len(int) - ui_save_windows() - at_bt_btlo_board() - at_bt_btpwr_board() - at_custom_send() - at_bt_wakeup() - at_bt_sleep() + ui_open_mac_config() + uart_process1() + readData1() + readData2() + readData3() + readData4() + uart_rx_dispaly1(int,uint8_t*) + spp_connect_1() + spp_connect_2() + spp_connect_3() + spp_connect_4() + spp_timer_callback1() + spp_connect_all() + uart_process2() + uart_process3() + uart_process4() + openLogfolder() + spp_timer_callback2() + spp_timer_callback3() + spp_timer_callback4() + uart_rx_dispaly2(int,uint8_t*) + uart_rx_dispaly3(int,uint8_t*) + uart_rx_dispaly4(int,uint8_t*) diff --git a/mythread.h b/mythread.h index 72164a8..464a50a 100644 --- a/mythread.h +++ b/mythread.h @@ -4,9 +4,9 @@ #include #include #include -#include #include #include +#include "common.h" /*-----------------------rx回调函数线程-------------------------------*/ // 当回调函数执行时,会唤醒此线程。 根据回调函数返回值执行对应函数。 class MyThread : public QThread diff --git a/result_thread.cpp b/result_thread.cpp index 57db951..f94f123 100644 --- a/result_thread.cpp +++ b/result_thread.cpp @@ -1,14 +1,25 @@ #include "result_thread.h" +#include "common.h" +struct result_info g_result_info1={0,NULL,0}; +QMutex g_result_thread_mlock1; +QWaitCondition g_result_thread_condition1; -struct result_info g_result_info={0,NULL,0,NULL,false,NONE_DATA,0,NULL}; -QMutex g_result_thread_mlock; -QWaitCondition g_result_thread_condition; +struct result_info g_result_info2={0,NULL,0}; +QMutex g_result_thread_mlock2; +QWaitCondition g_result_thread_condition2; +struct result_info g_result_info3={0,NULL,0}; +QMutex g_result_thread_mlock3; +QWaitCondition g_result_thread_condition3; +struct result_info g_result_info4={0,NULL,0}; +QMutex g_result_thread_mlock4; +QWaitCondition g_result_thread_condition4; -Result_Thread::Result_Thread(QObject *parent) +Result_Thread::Result_Thread(QObject *parent,uint8_t _port_index) { obj=parent; + port_index = _port_index; } Result_Thread::~Result_Thread() @@ -18,85 +29,91 @@ Result_Thread::~Result_Thread() // 给 UI 线程发送消息 void Result_Thread::process() { - g_result_thread_mlock.lock(); - g_result_thread_condition.wait(&g_result_thread_mlock, MLOCK_TIMEOUT); - switch (g_result_info.result_thread_flag) { + + struct result_info *g_result_info=nullptr; + QMutex *g_result_thread_mlock=nullptr; + QWaitCondition *g_result_thread_condition=nullptr; + + switch(port_index) + { + case 1: + g_result_info = &g_result_info1; + g_result_thread_mlock = &g_result_thread_mlock1; + g_result_thread_condition = &g_result_thread_condition1; + break; + case 2: + g_result_info = &g_result_info2; + g_result_thread_mlock = &g_result_thread_mlock2; + g_result_thread_condition = &g_result_thread_condition2; + break; + case 3: + g_result_info = &g_result_info3; + g_result_thread_mlock = &g_result_thread_mlock3; + g_result_thread_condition = &g_result_thread_condition3; + break; + case 4: + g_result_info = &g_result_info4; + g_result_thread_mlock = &g_result_thread_mlock4; + g_result_thread_condition = &g_result_thread_condition4; + break; + default: + return ; + } + + g_result_thread_mlock->lock(); + g_result_thread_condition->wait(g_result_thread_mlock, MLOCK_TIMEOUT); + switch (g_result_info->result_thread_flag) { case UART_RX_DATA: - QMetaObject::invokeMethod(obj, "uart_rx_dispaly", Q_ARG(int, g_result_info.uart_rx_buf_len),Q_ARG(u8Piont,g_result_info.uart_rx_buf)); // 让UI线程执行 Uart_Rx_Dispaly 槽函数 - g_result_info.result_thread_flag = NONE_DATA; - break; - case LS_RESULT_DATA: - QMetaObject::invokeMethod(obj, "transmit_ls_rx_diaplay",Q_ARG(int , g_result_info.transmit_ls_size),Q_ARG(vPiont,g_result_info.transmit_ls_buff)); - g_result_info.result_thread_flag = NONE_DATA; - break; - case TRANSMIT_FILE_DATA: - QMetaObject::invokeMethod(obj, "transmit_rx_display",Q_ARG(bool, g_result_info.transmit_result_flag)); - g_result_info.transmit_result_flag = false; - g_result_info.result_thread_flag = NONE_DATA; - break; - case AT_RESULT_DATA: - QMetaObject::invokeMethod(obj, "at_rx_display",Q_ARG(int, g_result_info.at_result_len),Q_ARG(u8Piont,g_result_info.at_result_buf)); - g_result_info.result_thread_flag = NONE_DATA; + QMetaObject::invokeMethod(obj, "uart_rx_dispaly1", Q_ARG(int, g_result_info->uart_rx_buf_len),Q_ARG(u8Piont,g_result_info->uart_rx_buf)); // 让UI线程执行 Uart_Rx_Dispaly 槽函数 + g_result_info->result_thread_flag = NONE_DATA; break; default: break; } - g_result_thread_mlock.unlock(); -} + g_result_thread_mlock->unlock(); -uint32_t uart_callback(void *buf, uint32_t buf_len) -{ - g_result_info.uart_rx_buf_len = (int)buf_len; - // rx的数据不包含\0,所以多分配1字节。 - g_result_info.uart_rx_buf=(uint8_t *)malloc(buf_len); - memset(g_result_info.uart_rx_buf,0,buf_len); - memcpy_s(g_result_info.uart_rx_buf, buf_len, (uint8_t *)buf, buf_len); - g_result_info.result_thread_flag = UART_RX_DATA; - g_result_thread_mlock.lock(); - g_result_thread_condition.wakeAll(); - g_result_thread_mlock.unlock(); - return 0; } -uint32_t ls_callback(uint32_t size, uapi_ls_info_t *buff) +uint32_t uart_callback(void *buf, uint32_t buf_len,uint8_t port_index) { - g_result_info.transmit_ls_buff = (uapi_ls_info_t *)malloc(size * sizeof(uapi_ls_info_t)+1); - memcpy_s(g_result_info.transmit_ls_buff, size * sizeof(uapi_ls_info_t), (uapi_ls_info_t *)buff, size * sizeof(uapi_ls_info_t)); - g_result_info.transmit_ls_size = static_cast(size); - g_result_info.result_thread_flag = LS_RESULT_DATA; - g_result_thread_mlock.lock(); - g_result_thread_condition.wakeAll(); - g_result_thread_mlock.unlock(); - return 0; -} + struct result_info *g_result_info=nullptr; + QMutex *g_result_thread_mlock=nullptr; + QWaitCondition *g_result_thread_condition=nullptr; -uint32_t transmit_callback(bool is_finished, uintptr_t usr_data) -{ - g_result_info.transmit_result_flag = is_finished; - Q_UNUSED(usr_data); - g_result_info.result_thread_flag = TRANSMIT_FILE_DATA; - g_result_thread_mlock.lock(); - g_result_thread_condition.wakeAll(); - g_result_thread_mlock.unlock(); - return 0; -} + switch(port_index) + { + case 1: + g_result_info = &g_result_info1; + g_result_thread_mlock = &g_result_thread_mlock1; + g_result_thread_condition = &g_result_thread_condition1; + break; + case 2: + g_result_info = &g_result_info2; + g_result_thread_mlock = &g_result_thread_mlock2; + g_result_thread_condition = &g_result_thread_condition2; + break; + case 3: + g_result_info = &g_result_info3; + g_result_thread_mlock = &g_result_thread_mlock3; + g_result_thread_condition = &g_result_thread_condition3; + break; + case 4: + g_result_info = &g_result_info4; + g_result_thread_mlock = &g_result_thread_mlock4; + g_result_thread_condition = &g_result_thread_condition4; + break; + default: + return 1; + } -uint32_t at_callback(void *buf, uint32_t len) -{ - uint8_t * at_buff = (uint8_t *)malloc(len); - memcpy_s(at_buff, len , buf, len); - g_result_info.at_result_buf = (uint8_t *)at_buff; - g_result_info.at_result_len = len; - g_result_info.result_thread_flag = AT_RESULT_DATA; - g_result_thread_mlock.lock(); - g_result_thread_condition.wakeAll(); - g_result_thread_mlock.unlock(); + g_result_info->uart_rx_buf_len = (int)buf_len; + // rx的数据不包含\0,所以多分配1字节。 + g_result_info->uart_rx_buf=(uint8_t *)malloc(buf_len); + memset(g_result_info->uart_rx_buf,0,buf_len); + memcpy_s(g_result_info->uart_rx_buf, buf_len, (uint8_t *)buf, buf_len); + g_result_info->result_thread_flag = UART_RX_DATA; + g_result_thread_mlock->lock(); + g_result_thread_condition->wakeAll(); + g_result_thread_mlock->unlock(); return 0; } -void transmit_get_data_count(uint32_t *total_size, uint32_t *current_size) -{ - uapi_transmit_progress transmint_data_count; - uapi_transmit_process(&transmint_data_count); - *total_size=transmint_data_count.total_size; - *current_size=transmint_data_count.transmited_size; -} diff --git a/result_thread.h b/result_thread.h index acb41a5..be0f8bc 100644 --- a/result_thread.h +++ b/result_thread.h @@ -1,13 +1,11 @@ #ifndef RESULT_THREAD_H #define RESULT_THREAD_H #include "mythread.h" -#include "common.h" -#include #include #include #include #include - +#include "common.h" #define BUF_SIZE 4096 #define MLOCK_TIMEOUT 2000 enum get_data_flag @@ -23,36 +21,22 @@ struct result_info{ // uart收到的数据 int uart_rx_buf_len; uint8_t *uart_rx_buf; - - // ls数据大小和内容 - int transmit_ls_size; - uapi_ls_info_t *transmit_ls_buff; - - // 传输文件是否成功 - bool transmit_result_flag; - // 当前回调函数标记 int result_thread_flag; - // at调用返回 - int at_result_len; - uint8_t *at_result_buf; }; class Result_Thread : public MyThread { public: - Result_Thread(QObject *parent = 0); + Result_Thread(QObject *parent = 0,uint8_t _port_index = 0); ~Result_Thread(); protected: void process() override final; private: QObject *obj; + uint8_t port_index; }; -uint32_t uart_callback(void *buf, uint32_t buf_len); -uint32_t ls_callback(uint32_t size, uapi_ls_info_t *buff); -uint32_t transmit_callback(bool is_finished, uintptr_t usr_data); -uint32_t at_callback(void *buf, uint32_t len); -void transmit_get_data_count(uint32_t *total_size, uint32_t *current_size); +uint32_t uart_callback(void *buf, uint32_t buf_len , uint8_t port_index); #endif // RESULT_THREAD_H diff --git a/settings.cpp b/settings.cpp new file mode 100644 index 0000000..36a779d --- /dev/null +++ b/settings.cpp @@ -0,0 +1,199 @@ +#include "settings.h" +#include +#include +settings* settings::instance = NULL; +settings& settings::getInstance() +{ + /* + * 双重锁定,减少每次开销,只有越过if(NULL == instance) 才需要锁定,极低概率 + */ + if(NULL == instance) + { + + if(NULL == instance) + { + instance = new settings(); + } + + } + return *instance; +} + +void settings::release() +{ + if(instance != NULL) + { + + delete instance; + instance = NULL; + + } +} + +void settings::load_settings() +{ + +} + +int settings::mac_config(QString _mac_pre,QString _mac_count,QString _mac_start_hexstr) +{ + mac_pre_head_hexstr = _mac_pre; + mac_start_hexstr = _mac_start_hexstr; + bool ok; + int ret =0; + mac_status_flag = true; + mac_count = _mac_count.toInt(&ok,10); + qDebug()<<" == mac_count "<< mac_count << ok; + if(!ok) + { + mac_status_flag = false; + ret = 2 ; + } + + mac_pre_head = mac_pre_head_hexstr.toUInt(&ok,16); + qDebug()<<" == mac_pre_head_hexstr "<< mac_pre_head_hexstr << mac_pre_head << ok; + if(!ok) + { + mac_status_flag = false; + ret = 2; + } + + mac_start = mac_start_hexstr.toUInt(&ok,16); + qDebug()<<" == mac_start_hexstr "<< mac_start_hexstr << mac_start << ok; + if(!ok) + { + mac_status_flag = false; + ret = 2; + } + + mac_end_hexstr = QString("%1").arg((mac_count+mac_start), 6, 16, QLatin1Char( '0' )).toUpper(); + qDebug()<<" == mac_end_hexstr "<6) + { + mac_status_flag = false; + qDebug()<<"数量过多"; + ret = 1; + } + + + qDebug()<<"格式正确? "<mac_count;i++) + { + QString mac_tmp=""; + mac_tmp.append(this->mac_pre_head_hexstr); + QString mac_end_str = QString("%1").arg((mac_start+i), 6, 16, QLatin1Char( '0' )).toUpper(); + mac_tmp.append(mac_end_str); + ret = sqlitemanager->insert_mac_addr(i,mac_tmp); + qDebug()<< "insert "<< i <<" "<< mac_tmp <<" ret " << ret; + } + return ret; +} + +int settings::create_new_database() +{ + if (mac_status_flag == false ) + { + qDebug()<<"mac_status_flag false skip craete database"; + return 0; + } + int ret = sqlitemanager->create_db_tables(); + + if (ret == 1) + { + gen_new_mac(); + }else if (ret == 2) + { + int count = sqlitemanager->get_mac_count(); + qDebug()<<"mac count "< 0 ) + { + + return 0; + } + + gen_new_mac(); + }else{ + qDebug()<< "create_database failed " ; + return 0; + } + return 1; +} + +settings::settings() +{ +// QSettings *settings = new QSettings(setting_path, QSettings::IniFormat); + +// // 写入第一组数据 +// settings->beginGroup("Uart_setting"); +//// settings->setValue("uart_com", ui->cbox_uart_com_select_1->currentText()); +//// settings->setValue("uart_baud", ui->cbox_uart_baud_select->currentIndex()); +//// settings->setValue("spp_addr", ui->ledit_spp_addr->text()); +// settings->sync(); +// settings->endGroup(); +//// // 写入第二组数据 +//// settings->beginGroup("Download_Setting"); +//// settings->setValue("download_board_path", ui->ledit_formboad_bordpath->text()); +//// settings->setValue("download_local_path", ui->ledit_frombord_savefilepath->text()); +//// settings->sync(); +//// settings->endGroup(); + +//// settings->beginGroup("Upload_Setting"); +//// settings->setValue("upload_board_path", ui->ledit_toboard_boardpath->text()); +//// settings->setValue("upload_local_path", ui->ledit_toboard_filepath->text()); +//// settings->sync(); +//// settings->endGroup(); + +//// settings->beginGroup("At_Setting"); +//// settings->setValue("at_mediamusicplay", ui->ledit_at_mediamusicplay->text()); +//// settings->setValue("at_mediaaudiorecord", ui->ledit_at_mediaaudiorecord->text()); +//// settings->setValue("at_fsrm", ui->ledit_at_fsrm->text()); +//// settings->setValue("at_delay_ms", ui->ledit_delay_ms->text()); +//// settings->setValue("at_spp_addr", ui->ledit_dongle_mac->text()); +//// settings->setValue("custom_module_id", ui->ledit_at_custom_moduleId->text()); +//// settings->setValue("custom_cmd_id", ui->ledit_at_custom_CmdId->text()); +//// settings->setValue("custom_payload", ui->ledit_at_custom_Payload->text()); +//// settings->sync(); +//// settings->endGroup(); + +// delete settings; +// settings = nullptr; + + sqlitemanager = new DbManager("mac_address.db"); +} + diff --git a/settings.h b/settings.h new file mode 100644 index 0000000..1d175e4 --- /dev/null +++ b/settings.h @@ -0,0 +1,37 @@ +#ifndef SETTINGS_H +#define SETTINGS_H +#include +#include +#include +#include "sqldbmanager.h" + +#define MAC_LEN 12 +class settings +{ +public: + static settings& getInstance(); //获取settings的唯一对象 + static void release(); + + settings(); + int create_new_database(); + void load_settings(); + int mac_config(QString _mac_pre,QString _mac_count,QString _mac_start_hexstr); + int save_to_database(); + QString getmacStatus(); +private: + int gen_new_mac(); + QString setting_path="Setting.ini"; + QString mac_pre_head_hexstr; + uint mac_pre_head; + uint mac_count; + QString mac_start_hexstr; + QString mac_end_hexstr; + uint mac_start; + int mac_used; + QDateTime cfg_updateTime; + static settings* instance; //settings 全局唯一的变量 + bool mac_status_flag=true; + DbManager *sqlitemanager{NULL}; +}; + +#endif // SETTINGS_H diff --git a/sqldbmanager.cpp b/sqldbmanager.cpp new file mode 100644 index 0000000..6f78a77 --- /dev/null +++ b/sqldbmanager.cpp @@ -0,0 +1,178 @@ +#include "sqldbmanager.h" +#include +#include +#include +#include +DbManager::DbManager(const QString& path="mac_address.db") +{ + m_db = QSqlDatabase::addDatabase("QSQLITE"); + m_db.setDatabaseName(path); + + if (!m_db.open()) + { + qDebug() << "Error: connection with database failed"; + } + else + { + qDebug() << "Database: connection ok"; + } +} + + +/*** + * 创建基本数据库表 + * 记录mac地址 + * btmac总计6个字节 , + * mac不变的头字节,3字节, + * 可变mac地址mac_start,3字节 + * 根据 mac_prefix + mac_start 开始,依次每个地址加1,直到 有mac_count个地址 + * +*/ +int DbManager::create_db_tables() +{ + +// QString create_database_str = "create table bt_addrs (id int primary key, mac_ddr varchar(20), cpuid varchar(20), update_time int, used_flag int)"; + QString create_database_str = "CREATE TABLE [main].[bt_addrs]( [id] int PRIMARY KEY ASC NOT NULL UNIQUE, [mac_ddr] varchar(20) NOT NULL DEFAULT \"\", [cpuid] varchar(40) NOT NULL DEFAULT \"\",[update_time_str] varchar(20) NOT NULL DEFAULT \"\", [update_time] int NOT NULL DEFAULT 0, [used_flag] int NOT NULL DEFAULT 0);"; + QStringList tables = m_db.tables(); + if (tables.length()==1 && tables.at(0) == "bt_addrs") + { + qDebug()<<" table bt_addrs already exist!"; + return 2; + }else{ + QSqlQuery query ;//= m_db.exec(create_database_str); + query.prepare(create_database_str); + if ( query.exec()) + { + qDebug()<< create_database_str << " success"; + + }else{ + qDebug()< +#include +#include +#include +class DbManager +{ +public: + DbManager(const QString& path); + /*** + * 创建基本数据库表 + * 记录mac地址 + * btmac总计6个字节 , + * mac不变的头字节,3字节, + * 可变mac地址mac_start,3字节 + * 根据 mac_prefix + mac_start 开始,依次每个地址加1,直到 有mac_count个地址 + * + */ + int create_db_tables(); + int insert_mac_addr(int id,QString mac_addr); + + /*** + * 获取mac地址总数 + */ + int get_mac_count(); + + /**** + * 获取已经被使用的mac地址数 + * */ + int get_mac_used_count(); + + /*** + *返回未被写的mac地址 + */ + QString get_avalible_mac(); + + /* + *更新某个mac地址为已使用状态 + */ + int set_mac_used(QString mac_hexstr,QString cpuid,bool used); + /* + * 打印数据库里具体多少mac地址被使用,多少地址还可用。 + */ + void dump_mac_status_in_db(); + +private: + int prefix_len{3}; + uint32_t mac_prefix{0x281106}; + QSqlDatabase m_db; + QMutex m_lock_database; +}; + + +#endif // SQLDBMANAGER +