卫星终端控制软件_V1.1.0

1、增加信道/复位等参数配置
This commit is contained in:
lz
2026-01-04 13:49:35 +08:00
parent b510f180c2
commit a0aed8f539
10 changed files with 548 additions and 221 deletions

View File

@@ -35,35 +35,6 @@ bool ConfigParam::checkNumber(char type, const QString& number){
return true;
}
void ConfigParam::on_btnGetDefaultChannelAndNumber_clicked()
{
emit sendUdpRequest(pack_config_cmd_DefaultChannelAndNumberGet());
}
void ConfigParam::on_btnSetDefaultChannelAndNumber_clicked()
{
uint8_t channelType = ui->defaultChannelType->currentIndex();
if(channelType == 0)
{
QMessageBox::information(this, "错误", "请选择默认话音通道");
return;
}
// 检查电话号码是否为空
QString u_number = ui->uDefaultNum->text();
if(!checkNumber('U', u_number)){
return;
}
QString s_number = ui->sDefaultNum->text();
if(!checkNumber('S', s_number)){
return;
}
emit sendUdpRequest(pack_config_cmd_DefaultChannelAndNumberSet((channelType - 1), u_number.toStdString(), s_number.toStdString()));
}
void ConfigParam::on_btnGetUDataChannelKeepTime_clicked()
{
emit sendUdpRequest(pack_config_cmd_UDataChannelKeepTimeGet());
@@ -92,12 +63,43 @@ void ConfigParam::on_btnSetUDataChannelKeepTime_clicked()
void ConfigParam::processConfigCmd(const QByteArray& cmd){
switch(uint8_t(cmd[COMMAND_TYPE_INDEX])){
case uint8_t(CommandType::kConfigCmdDefaultChannelAndNumber):
case uint8_t(CommandType::kConfigCmdDefaultChannel):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kGetType))
{
int data_index = COMMAND_DATA_BEGIN_INDEX;
uint8_t channelType = cmd[data_index++];//道类型
uint8_t channelType = cmd[data_index++];//道类型
ui->defaultChannelType->setCurrentIndex(channelType + 1);
}
else if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
//QMessageBox::information(this, "提示", "默认信道设置成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
//QMessageBox::information(this, "提示", "默认信道设置失败");
}
emit sendUdpRequest(pack_config_cmd_DefaultChannelGet()); //查询一次
}
break;
case uint8_t(CommandType::kConfigCmdUDataChannelKeepTime):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kGetType))
{
int data_index = COMMAND_DATA_BEGIN_INDEX;
uint16_t keeptime = qFromBigEndian<quint16>(reinterpret_cast<const uchar*>(cmd.constData()+data_index));
ui->uDataChannelKeepTime->setText(QString("%1").arg(keeptime));
}
else if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
QMessageBox::information(this, "提示", "U数据通道保持时间设置成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
QMessageBox::information(this, "提示", "U数据通道保持时间设置失败");
}
}
break;
case uint8_t(CommandType::kConfigCmdDefaultNumber):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kGetType))
{
int data_index = COMMAND_DATA_BEGIN_INDEX;
// U号码,使用 QByteArray 处理
QByteArray u_data = QByteArray::fromRawData(cmd.constData() + data_index, 20);
u_data.replace('\0', ""); // 移除所有空字符
@@ -116,27 +118,56 @@ void ConfigParam::processConfigCmd(const QByteArray& cmd){
else if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
QMessageBox::information(this, "提示", "默认话音通道与电话号码设置成功");
QMessageBox::information(this, "提示", "默认电话号码设置成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
QMessageBox::information(this, "提示", "默认话音通道与电话号码设置失败");
}
}
break;
case uint8_t(CommandType::kConfigCmdUDataChannelKeepTime):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kGetType))
{
uint16_t keeptime = ((uint16_t)cmd[COMMAND_DATA_BEGIN_INDEX] << 8) | cmd[COMMAND_DATA_BEGIN_INDEX + 1];
ui->uDataChannelKeepTime->setText(QString("%1").arg(keeptime));
}
else if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
QMessageBox::information(this, "提示", "U数据通道保持时间设置成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
QMessageBox::information(this, "提示", "U数据通道保持时间设置失败");
QMessageBox::information(this, "提示", "默认电话号码设置失败");
}
}
break;
}
}
void ConfigParam::on_btnGetDefaultChannel_clicked()
{
emit sendUdpRequest(pack_config_cmd_DefaultChannelGet());
}
void ConfigParam::on_btnSetDefaultChannel_clicked()
{
uint8_t channelType = ui->defaultChannelType->currentIndex();
if(channelType == 0)
{
QMessageBox::information(this, "错误", "请选择默认话音通道");
return;
}
emit sendUdpRequest(pack_config_cmd_DefaultChannelSet((channelType - 1)));
}
void ConfigParam::on_btnGetDefaultNumber_clicked()
{
emit sendUdpRequest(pack_config_cmd_DefaultNumberGet());
}
void ConfigParam::on_btnSetDefaultNumber_clicked()
{
// 检查电话号码是否为空
QString u_number = ui->uDefaultNum->text();
if(!checkNumber('U', u_number)){
return;
}
QString s_number = ui->sDefaultNum->text();
if(!checkNumber('S', s_number)){
return;
}
emit sendUdpRequest(pack_config_cmd_DefaultNumberSet(u_number.toStdString(), s_number.toStdString()));
}

View File

@@ -20,14 +20,18 @@ signals:
void sendUdpRequest(const QByteArray &message);
private slots:
void on_btnGetDefaultChannelAndNumber_clicked();
void on_btnSetDefaultChannelAndNumber_clicked();
void on_btnGetUDataChannelKeepTime_clicked();
void on_btnSetUDataChannelKeepTime_clicked();
void on_btnGetDefaultChannel_clicked();
void on_btnSetDefaultChannel_clicked();
void on_btnGetDefaultNumber_clicked();
void on_btnSetDefaultNumber_clicked();
private:
Ui::ConfigParam *ui;

View File

@@ -14,153 +14,17 @@
<string>参数配置</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="4">
<widget class="QPushButton" name="btnGetUDataChannelKeepTime">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>查 询</string>
</property>
</widget>
</item>
<item row="2" column="5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>84</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="uDataChannelKeepTime">
<property name="whatsThis">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>84</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>U数据通道保持时间</string>
<string>默认信道:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>185</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>84</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="btnSetDefaultChannelAndNumber">
<property name="text">
<string>设 置</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="btnGetDefaultChannelAndNumber">
<property name="text">
<string>查 询</string>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>84</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="5">
<widget class="QPushButton" name="btnSetUDataChannelKeepTime">
<property name="text">
<string>设 置</string>
</property>
</widget>
</item>
<item row="1" column="6">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="sDefaultNum">
<property name="whatsThis">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="uDefaultNum">
<property name="whatsThis">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="1">
<widget class="QComboBox" name="defaultChannelType">
<item>
<property name="text">
@@ -184,17 +48,21 @@
</item>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<item row="0" column="2">
<widget class="QPushButton" name="btnGetDefaultChannel">
<property name="text">
<string>默认话音通道:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
<string>查 询</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="0" column="3">
<widget class="QPushButton" name="btnSetDefaultChannel">
<property name="text">
<string>设 置</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>U默认电话号码</string>
@@ -204,7 +72,44 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="1">
<widget class="QLineEdit" name="uDefaultNum">
<property name="whatsThis">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="1" column="2" rowspan="2">
<widget class="QPushButton" name="btnGetDefaultNumber">
<property name="text">
<string>查 询</string>
</property>
</widget>
</item>
<item row="1" column="3" rowspan="2">
<widget class="QPushButton" name="btnSetDefaultNumber">
<property name="text">
<string>设 置</string>
</property>
</widget>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>S默认电话号码</string>
@@ -214,6 +119,63 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="sDefaultNum">
<property name="whatsThis">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>U数据通道保持时间(ms)</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="uDataChannelKeepTime">
<property name="whatsThis">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="btnGetUDataChannelKeepTime">
<property name="text">
<string>查 询</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="btnSetUDataChannelKeepTime">
<property name="text">
<string>设 置</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>185</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>

View File

@@ -89,7 +89,7 @@ void LoggerWidget::on_btnSRate_clicked()
void LoggerWidget::on_btnPa_clicked()
{
clearRespStatus();
emit sendUdpRequest(pack_debug_cmd_PASwitch(ui->sPa->checkState(), ui->uPa->checkState(), ui->bdPa->checkState()));
emit sendUdpRequest(pack_debug_cmd_PASwitch(ui->sPa->isChecked(), ui->uPa->isChecked(), ui->bdPa->isChecked()));
}

View File

@@ -1,4 +1,4 @@
[Config]
PeerIP = "192.168.2.10"
PeerIP = "191.168.82.192"
LocalPort = 6680
PeerPort = 6678

View File

@@ -35,7 +35,7 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
setWindowTitle("卫星终端控制软件_V1.0.5");
setWindowTitle("卫星终端控制软件_V1.1.0");
//创建logger窗口
m_loggerWidget = std::make_shared<LoggerWidget>();//需要在RecordQuery创建前
@@ -90,6 +90,15 @@ MainWindow::MainWindow(QWidget *parent)
ui->btnUHFSimCardStatus->setStyleSheet(transparentStyle);
ui->labelUHFSimCardStatus->setStyleSheet(transparentStyle);
ui->lblLinkStatus->setText("未连接");
ui->lblLinkStatus->setStyleSheet("color: red;"); // 红色
// 初始化UDP连接状态
m_udpConnected = false;
m_versionQuery = false;
m_channelQuery = false;
m_lastUdpDataTime = QDateTime::currentDateTime();
QString exeDir = QCoreApplication::applicationDirPath();
QSettings settings(exeDir + "/app.ini", QSettings::IniFormat);
m_udpIp = settings.value("Config/PeerIP","192.168.2.10").toString();
@@ -120,17 +129,19 @@ MainWindow::MainWindow(QWidget *parent)
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout1s()));
m_timer->start(1000);
//3秒定时状态检测
m_status_timer = new QTimer(this);
connect(m_status_timer, SIGNAL(timeout()), this, SLOT(onTimerLinkStatus()));
m_status_timer->start(3000);
//测试
//test();
// QString s = "你是谁";
// m_logger->info(u8"{}---{}---{}",1,u8"水电费",s.toStdString());
ui->tabWidget->setCurrentIndex(0); //tab默认显示rdss tab
m_recordQueryWidget->setupNumberCombo(this, ui->cmbCallNumber, NumberKind::Call);
m_recordQueryWidget->setupNumberCombo(this, ui->cmbMessageNumberForUhfAndS, NumberKind::USMsg);
m_recordQueryWidget->setupNumberCombo(this, ui->cmbMessageNumberForBeiDou, NumberKind::BdMsg);
}
MainWindow::~MainWindow() { delete ui; }
@@ -237,6 +248,51 @@ void MainWindow::onTimerTimeout1s(){
}
}
void MainWindow::onTimerLinkStatus(){
// 计算当前时间与最后收到数据的时间差(秒)
qint64 secondsSinceLastData = m_lastUdpDataTime.secsTo(QDateTime::currentDateTime());
// 如果超过3秒没有收到数据则认为连接断开
if(secondsSinceLastData >= 3) {
m_logger->info("LinkStatus: secondsSinceLastData = {}", secondsSinceLastData);
if(m_udpConnected) {
m_udpConnected = false;
m_versionQuery = false;
m_channelQuery = false;
ui->lblLinkStatus->setText("未连接");
//QMessageBox::information(this, "提示", "连接已断开");
ui->lblLinkStatus->setStyleSheet("color: red;");
m_logger->error("Link is disconnected");
}
} else {
if(!m_udpConnected) {
m_udpConnected = true;
ui->lblLinkStatus->setText("已连接");
ui->lblLinkStatus->setStyleSheet("color: green;");
//QMessageBox::information(this, "提示", "已连接");
m_logger->info("Link is Connected");
}
// 连接成功后,查询设备信息
queryDeviceInfo();
}
}
// 查询设备信息
void MainWindow::queryDeviceInfo()
{
// 如果版本号尚未查询,则发送查询命令
if(!m_versionQuery) {
sendUdpMessage(pack_config_cmd_SoftVersionGet());
}
// 如果信道类型尚未查询,则发送查询命令
if(!m_channelQuery) {
sendUdpMessage(pack_config_cmd_DefaultChannelGet());
}
}
void MainWindow::handleUdpRequest(const QByteArray &message)
{
sendUdpMessage(message); // 调用实际的发送方法
@@ -830,8 +886,8 @@ bool MainWindow::checkMessage(const QString& message){
return true;
}
std::pair<bool,Channel> MainWindow::selectChannel(ChannelType comm_type){
//U无SIM卡状态
bool isUhfChannelOk = (m_uhfModuleStatus == ModuleStatus::kNormal)
&& (m_uhfSimCardStatus == SimCardStatus::kExist)
&& (m_uhfNetworkAccessStatus == NetworkAccessStatus::kConnectedDataIsActivated || m_uhfNetworkAccessStatus == NetworkAccessStatus::kConnectedDataIsNotActivated);
bool isSChannelOk = (m_tiantongModuleStatus == ModuleStatus::kNormal)
&& (m_tiantongSimCardStatus == SimCardStatus::kExist)
@@ -1036,6 +1092,18 @@ void MainWindow::processCommand(QByteArray& cmd){
return;
}
// 更新最后收到数据的时间
m_lastUdpDataTime = QDateTime::currentDateTime();
// 如果当前状态是未连接,立即更新状态
if(!m_udpConnected) {
m_udpConnected = true;
ui->lblLinkStatus->setText("已连接");
ui->lblLinkStatus->setStyleSheet("color: green;");
//QMessageBox::information(this, "提示", "已连接");
m_logger->info("Link is Connected");
}
switch(uint8_t(cmd[COMMAND_TYPE_INDEX])){
case uint8_t(CommandType::kTianTongVoice):
processTianTongVoiceCmd(cmd);
@@ -1061,8 +1129,11 @@ void MainWindow::processCommand(QByteArray& cmd){
case uint8_t(CommandType::kSearchZhuanTaiStatusReport):
processZhuanTaiStatusReportCmd(cmd);
break;
case uint8_t(CommandType::kConfigCmdDefaultChannelAndNumber):
case uint8_t(CommandType::kConfigCmdDefaultChannel):
case uint8_t(CommandType::kConfigCmdUDataChannelKeepTime):
case uint8_t(CommandType::kConfigCmdDefaultNumber):
case uint8_t(CommandType::kConfigCmdSoftVersion):
processConfigCmd(cmd);
m_configParamWidget->processConfigCmd(cmd);
break;
case uint8_t(CommandType::kDebugCmd):
@@ -1558,6 +1629,77 @@ void MainWindow::processZhuanTaiStatusReportCmd(const QByteArray& cmd){
ui->lblZhuanTaiStatus->setText(s);
}
void MainWindow::processConfigCmd(const QByteArray& cmd){
switch(uint8_t(cmd[COMMAND_TYPE_INDEX])){
case uint8_t(CommandType::kConfigCmdDefaultChannel):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kGetType))
{
int data_index = COMMAND_DATA_BEGIN_INDEX;
uint8_t channelType = cmd[data_index++];//信道类型
switch(channelType)
{
case uint8_t(ChannelType::ChannelS):
ui->rdbChannelS->setChecked(true);
break;
case uint8_t(ChannelType::ChannelUHF):
ui->rdbChannelUHF->setChecked(true);
break;
case uint8_t(ChannelType::ChannelAuto):
ui->rdbChannelAuto->setChecked(true);
break;
}
m_channelQuery = true;
}
else if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
QMessageBox::information(this, "提示", "默认信道设置成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
QMessageBox::information(this, "提示", "默认信道设置失败");
}
sendUdpMessage(pack_config_cmd_DefaultChannelGet()); //查询一次
}
break;
case uint8_t(CommandType::kConfigCmdSoftVersion):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kGetType))
{
int data_index = COMMAND_DATA_BEGIN_INDEX;
// U号码,使用 QByteArray 处理
QByteArray softversion_data = QByteArray::fromRawData(cmd.constData() + data_index, 32);
softversion_data.replace('\0', ""); // 移除所有空字符
// 转换为 std::string
std::string softversion = softversion_data.toStdString();
ui->lblSoftVersion->setText(QString::fromStdString(softversion));
m_versionQuery = true;
}
break;
case uint8_t(CommandType::kConfigCmdSoftReset):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
QMessageBox::information(this, "提示", "软件复位成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
QMessageBox::information(this, "提示", "软件复位失败");
}
}
break;
case uint8_t(CommandType::kConfigCmdSDataSwitch):
if(cmd[SUB_COMMAND_TYPE_INDEX] == uint8_t(ConfigCommandType::kSetType))
{
if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kSucess)){//设置成功
QMessageBox::information(this, "提示", "S数据开关设置成功");
}else if(cmd[COMMAND_DATA_BEGIN_INDEX] == uint8_t(VoiceAndShortMessageReponse::kFailure)){//设置失败
QMessageBox::information(this, "提示", "S数据开关设置失败");
}
}
break;
default:
break;
}
}
void MainWindow::processDebugCmd(const QByteArray& cmd){
switch(uint8_t(cmd[SUB_COMMAND_TYPE_INDEX])){
case uint8_t(DebugCommandType::kUCattierType):
@@ -1856,6 +1998,7 @@ void MainWindow::processCallStatus(uint8_t tiantong_call_status,uint8_t uhf_call
m_uhfCallStatus = CallStatus(uhf_call_status);
CallStatus status;
static uint8_t lastStatus = 0xFF;
Channel chan;
if(m_tiantongCallStatus != CallStatus::kIdle){
status = m_tiantongCallStatus;
@@ -1896,6 +2039,11 @@ void MainWindow::processCallStatus(uint8_t tiantong_call_status,uint8_t uhf_call
ui->lblCallDuration->setText(""); //清空
break;
case CallStatus::kOnLine://通话中
if(lastStatus == (uint8_t)CallStatus::kIdle)//避免从'空闲'直接变成'通话中'
{
m_logger->error("CallStatus is Err, lastStatus = {}, currentStatus = {}", lastStatus, (uint8_t)status);
return;
}
//通话中
if(chan == Channel::S){
m_currentTalkingNumber = tiantong_number;
@@ -1933,6 +2081,7 @@ void MainWindow::processCallStatus(uint8_t tiantong_call_status,uint8_t uhf_call
ui->lblCallDuration->setText(""); //清空
break;
}
lastStatus = (uint8_t)status;
}
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
@@ -1943,3 +2092,48 @@ void MainWindow::on_btnConfigParam_clicked()
m_configParamWidget->show();
}
void MainWindow::on_rdbChannelS_clicked()
{
sendUdpMessage(pack_config_cmd_DefaultChannelSet(uint8_t(ChannelType::ChannelS)));
}
void MainWindow::on_rdbChannelUHF_clicked()
{
sendUdpMessage(pack_config_cmd_DefaultChannelSet(uint8_t(ChannelType::ChannelUHF)));
}
void MainWindow::on_rdbChannelAuto_clicked()
{
sendUdpMessage(pack_config_cmd_DefaultChannelSet(uint8_t(ChannelType::ChannelAuto)));
}
void MainWindow::on_sDataSwitch_checkStateChanged(const Qt::CheckState &arg1)
{
uint8_t onoff = 0;
if(arg1 == Qt::CheckState::Checked)
{
onoff = 1;
}
sendUdpMessage(pack_config_cmd_SDataSwitchSet(onoff));
}
void MainWindow::on_btnSoftReset_clicked()
{
// 1. 弹出确认对话框(按钮显示中文“确定/取消”)
QMessageBox msgBox(this);
msgBox.setWindowTitle("确认操作");
msgBox.setText("您确定要软件复位吗?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
// 通过 button() 获取按钮指针再 setText不使用 setButtonText
msgBox.button(QMessageBox::Yes)->setText("确定");
msgBox.button(QMessageBox::No)->setText("取消");
if (msgBox.exec() != QMessageBox::Yes) {
return;
}
sendUdpMessage(pack_config_cmd_SoftResetSet());
}

View File

@@ -55,10 +55,21 @@ private slots:
void handleHovered(bool status, int index, QBarSet *barset);
void onTimerTimeout1s();
void onTimerLinkStatus();
void handleUdpRequest(const QByteArray &message);
void on_btnConfigParam_clicked();
void on_rdbChannelS_clicked();
void on_rdbChannelUHF_clicked();
void on_rdbChannelAuto_clicked();
void on_sDataSwitch_checkStateChanged(const Qt::CheckState &arg1);
void on_btnSoftReset_clicked();
protected:
void keyPressEvent(QKeyEvent* event) override;
private:
@@ -87,6 +98,7 @@ private:
void processSearchSatelliteStatusReport(const QByteArray& cmd);
void processZhuanTaiStatusReportCmd(const QByteArray& cmd);
void processDebugCmd(const QByteArray& cmd);
void processConfigCmd(const QByteArray& cmd);
// 处理模块状态
void processUhfModuleStatus(uint8_t status);
void processTianTongModuleStatus(uint8_t status);
@@ -106,6 +118,7 @@ private:
void StartupTalking();
void ShutdownTalking();
void test();
void queryDeviceInfo();
std::pair<QString,QString> parseReceivedShortMessage(const QByteArray& cmd,Channel chan);
@@ -164,7 +177,13 @@ private:
uint16_t m_localPort{8000};
uint16_t m_peerPort{8080};
QDateTime m_lastUdpDataTime; // 记录最后收到UDP数据的时间
bool m_udpConnected = false; // UDP连接状态标志
bool m_versionQuery = false; // 版本号是否已查询
bool m_channelQuery = false; // 信道类型是否已查询
QTimer* m_timer;
QTimer* m_status_timer;
std::shared_ptr<QTimer> m_talkingTimer;
std::shared_ptr<spdlog::logger> m_logger;
std::shared_ptr<QUdpSocket> m_udpSocket;

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1620</width>
<height>980</height>
<height>1137</height>
</rect>
</property>
<property name="windowTitle">
@@ -430,6 +430,53 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_64">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>连接状态:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblLinkStatus">
<property name="text">
<string>未连接</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>软件版本号 </string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblSoftVersion">
<property name="text">
<string>未知</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_21">
<property name="orientation">
@@ -443,6 +490,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnSoftReset">
<property name="text">
<string>软件复位</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConfigParam">
<property name="text">
@@ -834,6 +888,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="sDataSwitch">
<property name="text">
<string>数据开关</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

64
msg.cpp
View File

@@ -180,24 +180,21 @@ QByteArray pack_debug_cmd_CmdCtrl(uint8_t type, const std::string& cmd_content){
return pack_slip(cmd);
}
QByteArray pack_config_cmd_DefaultChannelAndNumberGet(){
QByteArray pack_config_cmd_DefaultChannelGet(){
QByteArray cmd(FRAME_MIN_LEN, '\0');
pack_len(cmd,2);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdDefaultChannelAndNumber);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdDefaultChannel);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kGetType);
calc_checksum(cmd);
return pack_slip(cmd);
}
QByteArray pack_config_cmd_DefaultChannelAndNumberSet(uint8_t type, const std::string& u_number, const std::string& s_number){
assert((u_number.size() <= 20) && (s_number.size() <= 20));
QByteArray cmd(FRAME_MIN_LEN + 1 + 20 + 20, '\0');
pack_len(cmd,2 + 1 + 20 + 20);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdDefaultChannelAndNumber);
QByteArray pack_config_cmd_DefaultChannelSet(uint8_t type){
QByteArray cmd(FRAME_MIN_LEN + 1, '\0');
pack_len(cmd,2 + 1);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdDefaultChannel);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kSetType);
cmd[COMMAND_DATA_BEGIN_INDEX] = type;
memcpy(&cmd[COMMAND_DATA_BEGIN_INDEX + 1],u_number.c_str(),u_number.size());
memcpy(&cmd[COMMAND_DATA_BEGIN_INDEX + 1 + 20],s_number.c_str(),s_number.size());
calc_checksum(cmd);
return pack_slip(cmd);
}
@@ -222,6 +219,55 @@ QByteArray pack_config_cmd_UDataChannelKeepTimeSet(uint16_t time){
return pack_slip(cmd);
}
QByteArray pack_config_cmd_DefaultNumberGet(){
QByteArray cmd(FRAME_MIN_LEN, '\0');
pack_len(cmd,2);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdDefaultNumber);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kGetType);
calc_checksum(cmd);
return pack_slip(cmd);
}
QByteArray pack_config_cmd_DefaultNumberSet(const std::string& u_number, const std::string& s_number){
assert((u_number.size() <= 20) && (s_number.size() <= 20));
QByteArray cmd(FRAME_MIN_LEN + 20 + 20, '\0');
pack_len(cmd,2 + 20 + 20);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdDefaultNumber);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kSetType);
memcpy(&cmd[COMMAND_DATA_BEGIN_INDEX],u_number.c_str(),u_number.size());
memcpy(&cmd[COMMAND_DATA_BEGIN_INDEX + 20],s_number.c_str(),s_number.size());
calc_checksum(cmd);
return pack_slip(cmd);
}
QByteArray pack_config_cmd_SoftVersionGet(){
QByteArray cmd(FRAME_MIN_LEN, '\0');
pack_len(cmd,2);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdSoftVersion);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kGetType);
calc_checksum(cmd);
return pack_slip(cmd);
}
QByteArray pack_config_cmd_SoftResetSet(){
QByteArray cmd(FRAME_MIN_LEN, '\0');
pack_len(cmd,2);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdSoftReset);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kSetType);
calc_checksum(cmd);
return pack_slip(cmd);
}
QByteArray pack_config_cmd_SDataSwitchSet(uint8_t onoff){
QByteArray cmd(FRAME_MIN_LEN + 1, '\0');
pack_len(cmd,2 + 1);
cmd[COMMAND_TYPE_INDEX] = uint8_t(CommandType::kConfigCmdSDataSwitch);
cmd[SUB_COMMAND_TYPE_INDEX] = uint8_t(ConfigCommandType::kSetType);
cmd[COMMAND_DATA_BEGIN_INDEX] = onoff;
calc_checksum(cmd);
return pack_slip(cmd);
}
QByteArray pack_short_message_cmd(CommandType cmd_type,const std::string& number, const std::u16string& message){
assert(number.size() <= 20);
QByteArray cmd(FRAME_MIN_LEN+20+message.size()*sizeof(char16_t), '\0');

16
msg.h
View File

@@ -25,8 +25,12 @@ enum class CommandType : uint8_t{
kStatusReport = 0x80,
kSearchSatelliteStatusReport = 0x90,
kSearchZhuanTaiStatusReport = 0x91,
kConfigCmdDefaultChannelAndNumber = 0xD0,
kConfigCmdDefaultChannel = 0xD0,
kConfigCmdUDataChannelKeepTime = 0xD1,
kConfigCmdDefaultNumber = 0xD2,
kConfigCmdSoftVersion = 0xD3,
kConfigCmdSoftReset = 0xD4,
kConfigCmdSDataSwitch = 0xD5,
kDebugCmd = 0xE0,
};
enum class TianTongVoiceSubCommandType: uint8_t{
@@ -155,10 +159,16 @@ QByteArray pack_debug_cmd_PASwitch(uint8_t s_switch, uint8_t u_switch, uint8_t b
QByteArray pack_debug_cmd_ZTCtrl(uint8_t type);
QByteArray pack_debug_cmd_CmdCtrl(uint8_t type, const std::string& cmd_content);
QByteArray pack_config_cmd_DefaultChannelAndNumberGet();
QByteArray pack_config_cmd_DefaultChannelAndNumberSet(uint8_t type, const std::string& u_number, const std::string& s_number);
QByteArray pack_config_cmd_DefaultChannelGet();
QByteArray pack_config_cmd_DefaultChannelSet(uint8_t type);
QByteArray pack_config_cmd_UDataChannelKeepTimeGet();
QByteArray pack_config_cmd_UDataChannelKeepTimeSet(uint16_t time);
QByteArray pack_config_cmd_DefaultNumberGet();
QByteArray pack_config_cmd_DefaultNumberSet(const std::string& u_number, const std::string& s_number);
QByteArray pack_config_cmd_SoftVersionGet();
QByteArray pack_config_cmd_SoftResetSet();
QByteArray pack_config_cmd_SDataSwitchSet(uint8_t onoff);
QByteArray pack_short_message_cmd(CommandType cmd_type,const std::string& number, const std::u16string& message);
QByteArray pack_slip(QByteArray &message);
int pack_deslip(QByteArray &message);