Implemented network settings

This commit is contained in:
Yury Shuvakin
2022-09-16 03:22:47 +03:00
parent 4dd1f95193
commit 12c4535e06
11 changed files with 401 additions and 30 deletions

View File

@@ -254,6 +254,17 @@ void Commands::processPacket(QByteArray data)
emit pingCanRx(devs, false);
} break;
case COMM_GET_BMS_NET_SETTINGS:
{
QStringList settings;
settings << vb.mid(0, 250);
settings << vb.mid(250, 250);
settings << vb.mid(500, 50);
settings << vb.mid(550, 50);
settings << vb.mid(600, 50);
emit netSettingsReceived(settings);
break;
}
default:
break;
}
@@ -323,6 +334,26 @@ void Commands::getExpansionTemp()
vb.vbAppendInt8(COMM_GET_BMS_EXP_TEMP);
emitData(vb);
}
void Commands::getNetSettings()
{
VByteArray vb;
vb.vbAppendInt8(COMM_GET_BMS_NET_SETTINGS);
emitData(vb);
}
void Commands::setNetSettings(QStringList settings)
{
VByteArray vb;
vb.vbAppendInt8(COMM_SET_BMS_NET_SETTINGS);
vb.append(settings.at(0).leftJustified(250, '\0', true));
vb.append(settings.at(1).leftJustified(250, '\0', true));
vb.append(settings.at(2).leftJustified(50, '\0', true));
vb.append(settings.at(3).leftJustified(50, '\0', true));
vb.append(settings.at(4).leftJustified(50, '\0', true));
emitData(vb);
}
void Commands::sendTerminalCmd(QString cmd)
{
VByteArray vb;

View File

@@ -71,6 +71,7 @@ signals:
void bmsConfigCheckResult(QStringList paramsNotSet);
void valuesSetupReceived(BMS_VALUES values);
void pingCanRx(QVector<int> devs, bool isTimeout);
void netSettingsReceived(QStringList settings);
public slots:
void processPacket(QByteArray data);
@@ -80,6 +81,8 @@ public slots:
void getCells();
void getAux();
void getExpansionTemp();
void getNetSettings();
void setNetSettings(QStringList settings);
void sendTerminalCmd(QString cmd);
void setDetect(disp_pos_mode mode);
void samplePrint(debug_sampling_mode mode, int sample_len, int dec);

View File

@@ -415,7 +415,9 @@ typedef enum {
COMM_STORE_BMS_CONF = 150,
COMM_GET_BMS_CELLS,
COMM_GET_BMS_AUX,
COMM_GET_BMS_EXP_TEMP
COMM_GET_BMS_EXP_TEMP,
COMM_GET_BMS_NET_SETTINGS = 154,
COMM_SET_BMS_NET_SETTINGS = 156
} COMM_PACKET_ID;
typedef struct {

View File

@@ -22,6 +22,12 @@ RowLayout {
property string title: qsTr("Firmware update")
}
Screens.NetworkSettingsScreen {
id: networkSettingsScreen
property string title: qsTr("Network settings")
}
Layout.fillWidth: true
Layout.fillHeight: true
}
@@ -30,7 +36,7 @@ RowLayout {
spacing: 20
Repeater {
model: [terminalScreen.title, firmwareUpdateScreen.title]
model: [terminalScreen.title, firmwareUpdateScreen.title, networkSettingsScreen.title]
delegate: Controls.LinkLabel {
text: modelData
onClicked: stack.currentIndex = index
@@ -41,6 +47,7 @@ RowLayout {
Layout.fillHeight: true
}
Layout.preferredWidth: 180
Layout.minimumWidth: 180
Layout.maximumWidth: 180
}
}

View File

@@ -0,0 +1,212 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import Controls 1.0 as Controls
import Cubo 1.0
ColumnLayout {
spacing: 10
Controls.Frame {
padding: 35
topPadding: 20
bottomPadding: 20
RowLayout {
anchors.fill: parent
spacing: 20
Controls.SubtitleLabel {
id: firstUrlLabel
text: qsTr("Url 1")
TextMetrics {
id: firstUrlMetrics
font: firstUrlLabel.font
text: firstUrlLabel.text
}
Layout.preferredWidth: getMaxLabelWidth()
}
Controls.TextField {
id: firstUrlField
validator: RegExpValidator { regExp: /.{0,250}/ }
Layout.fillWidth: true
}
}
Layout.fillWidth: true
}
Controls.Frame {
padding: 35
topPadding: 20
bottomPadding: 20
RowLayout {
anchors.fill: parent
spacing: 20
Controls.SubtitleLabel {
id: secondUrlLabel
text: qsTr("Url 2")
TextMetrics {
id: secondUrlMetrics
font: secondUrlLabel.font
text: secondUrlLabel.text
}
Layout.preferredWidth: getMaxLabelWidth()
}
Controls.TextField {
id: secondUrlField
validator: RegExpValidator { regExp: /.{0,250}/ }
Layout.fillWidth: true
}
}
Layout.fillWidth: true
}
Controls.Frame {
padding: 35
topPadding: 20
bottomPadding: 20
RowLayout {
anchors.fill: parent
spacing: 20
Controls.SubtitleLabel {
id: apnLabel
text: qsTr("APN")
TextMetrics {
id: apnMetrics
font: apnLabel.font
text: apnLabel.text
}
Layout.preferredWidth: getMaxLabelWidth()
}
Controls.TextField {
id: apnField
validator: RegExpValidator { regExp: /.{0,50}/ }
Layout.fillWidth: true
}
}
Layout.fillWidth: true
}
Controls.Frame {
padding: 35
topPadding: 20
bottomPadding: 20
RowLayout {
anchors.fill: parent
spacing: 20
Controls.SubtitleLabel {
id: userLabel
text: qsTr("User")
TextMetrics {
id: userMetrics
font: userLabel.font
text: userLabel.text
}
Layout.preferredWidth: getMaxLabelWidth()
}
Controls.TextField {
id: userField
validator: RegExpValidator { regExp: /.{0,50}/ }
Layout.fillWidth: true
}
}
Layout.fillWidth: true
}
Controls.Frame {
padding: 35
topPadding: 20
bottomPadding: 20
RowLayout {
anchors.fill: parent
spacing: 20
Controls.SubtitleLabel {
id: passwordLabel
text: qsTr("Password")
TextMetrics {
id: passwordMetrics
font: passwordLabel.font
text: passwordLabel.text
}
Layout.preferredWidth: getMaxLabelWidth()
}
Controls.TextField {
id: passwordField
validator: RegExpValidator { regExp: /.{0,50}/ }
Layout.fillWidth: true
}
}
Layout.fillWidth: true
}
Controls.Button {
text: qsTr("Apply")
onClicked: {
if (!BmsInterface.isPortConnected())
return
var settings = [
firstUrlField.text,
secondUrlField.text,
apnField.text,
userField.text,
passwordField.text,
]
BmsInterface.commands().setNetSettings(settings)
}
}
Connections {
target: BmsInterface.commands()
onNetSettingsReceived: {
if (settings.length < 5) {
return
}
firstUrlField.text = settings[0]
secondUrlField.text = settings[1]
apnField.text = settings[2]
userField.text = settings[3]
passwordField.text = settings[4]
}
}
onVisibleChanged: if (visible) {
if (BmsInterface.isPortConnected()) {
BmsInterface.commands().getNetSettings()
}
}
function getMaxLabelWidth() {
return Math.max(firstUrlMetrics.width, secondUrlMetrics.width, apnMetrics.width, userMetrics.width, passwordMetrics.width)
}
}

View File

@@ -10,3 +10,4 @@ MessageDialog 1.0 MessageDialog.qml
StatusPopup 1.0 StatusPopup.qml
TerminalScreen 1.0 TerminalScreen.qml
FirmwareUpdateScreen 1.0 FirmwareUpdateScreen.qml
NetworkSettingsScreen 1.0 NetworkSettingsScreen.qml

View File

@@ -44,5 +44,6 @@
<file>Screens/TerminalScreen.qml</file>
<file>Screens/FirmwareUpdateScreen.qml</file>
<file>Controls/ProgressBar.qml</file>
<file>Screens/NetworkSettingsScreen.qml</file>
</qresource>
</RCC>

View File

@@ -218,6 +218,11 @@
<source>Firmware update</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/BmsServiceScreen.qml" line="27"/>
<source>Network settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BmsSettingsScreen</name>
@@ -482,45 +487,45 @@ Wait, please.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="462"/>
<location filename="../commands.cpp" line="623"/>
<location filename="../commands.cpp" line="493"/>
<location filename="../commands.cpp" line="654"/>
<source>Buffer erase</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="467"/>
<location filename="../commands.cpp" line="498"/>
<source>Buffer erase timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="475"/>
<location filename="../commands.cpp" line="506"/>
<source>CRC/Size write</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="484"/>
<location filename="../commands.cpp" line="515"/>
<source>CRC/Size write timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="503"/>
<location filename="../commands.cpp" line="534"/>
<source>Firmware data write</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="512"/>
<location filename="../commands.cpp" line="543"/>
<source>Firmware data write timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="540"/>
<location filename="../commands.cpp" line="571"/>
<source>Firmware update completed!
Reconnect to the board if you want to continue working with it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="660"/>
<location filename="../commands.cpp" line="691"/>
<source>Cancelled</source>
<translation type="unfinished"></translation>
</message>
@@ -739,6 +744,39 @@ Reconnect to the board if you want to continue working with it.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NetworkSettingsScreen</name>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="21"/>
<source>Url 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="53"/>
<source>Url 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="85"/>
<source>APN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="117"/>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="149"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="171"/>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>

View File

@@ -218,6 +218,11 @@
<source>Firmware update</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/BmsServiceScreen.qml" line="27"/>
<source>Network settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BmsSettingsScreen</name>
@@ -482,45 +487,45 @@ Wait, please.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="462"/>
<location filename="../commands.cpp" line="623"/>
<location filename="../commands.cpp" line="493"/>
<location filename="../commands.cpp" line="654"/>
<source>Buffer erase</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="467"/>
<location filename="../commands.cpp" line="498"/>
<source>Buffer erase timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="475"/>
<location filename="../commands.cpp" line="506"/>
<source>CRC/Size write</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="484"/>
<location filename="../commands.cpp" line="515"/>
<source>CRC/Size write timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="503"/>
<location filename="../commands.cpp" line="534"/>
<source>Firmware data write</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="512"/>
<location filename="../commands.cpp" line="543"/>
<source>Firmware data write timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="540"/>
<location filename="../commands.cpp" line="571"/>
<source>Firmware update completed!
Reconnect to the board if you want to continue working with it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../commands.cpp" line="660"/>
<location filename="../commands.cpp" line="691"/>
<source>Cancelled</source>
<translation type="unfinished"></translation>
</message>
@@ -739,6 +744,39 @@ Reconnect to the board if you want to continue working with it.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NetworkSettingsScreen</name>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="21"/>
<source>Url 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="53"/>
<source>Url 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="85"/>
<source>APN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="117"/>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="149"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="171"/>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>

Binary file not shown.

View File

@@ -230,6 +230,11 @@
<source>Firmware update</source>
<translation>Обновление прошивки</translation>
</message>
<message>
<location filename="../qml/Screens/BmsServiceScreen.qml" line="27"/>
<source>Network settings</source>
<translation>Настройки сети</translation>
</message>
</context>
<context>
<name>BmsSettingsScreen</name>
@@ -499,38 +504,38 @@ Wait, please.</source>
<translation>Конфигурация BMS установлена</translation>
</message>
<message>
<location filename="../commands.cpp" line="462"/>
<location filename="../commands.cpp" line="623"/>
<location filename="../commands.cpp" line="493"/>
<location filename="../commands.cpp" line="654"/>
<source>Buffer erase</source>
<translation>Стирание буфера</translation>
</message>
<message>
<location filename="../commands.cpp" line="467"/>
<location filename="../commands.cpp" line="498"/>
<source>Buffer erase timeout</source>
<translation>Таймаут стирания буфера</translation>
</message>
<message>
<location filename="../commands.cpp" line="475"/>
<location filename="../commands.cpp" line="506"/>
<source>CRC/Size write</source>
<translation>Запись контрольной суммы</translation>
</message>
<message>
<location filename="../commands.cpp" line="484"/>
<location filename="../commands.cpp" line="515"/>
<source>CRC/Size write timeout</source>
<translation>Таймаут записи контрольной суммы</translation>
</message>
<message>
<location filename="../commands.cpp" line="503"/>
<location filename="../commands.cpp" line="534"/>
<source>Firmware data write</source>
<translation>Запись данных прошивки</translation>
</message>
<message>
<location filename="../commands.cpp" line="512"/>
<location filename="../commands.cpp" line="543"/>
<source>Firmware data write timeout</source>
<translation>Таймаут записи данных прошивки</translation>
</message>
<message>
<location filename="../commands.cpp" line="540"/>
<location filename="../commands.cpp" line="571"/>
<source>Firmware update completed!
Reconnect to the board if you want to continue working with it.</source>
@@ -543,7 +548,7 @@ Reconnect to the board if you want to continue working with it.</source>
<translation type="vanished">Обновление прошивки завершено</translation>
</message>
<message>
<location filename="../commands.cpp" line="660"/>
<location filename="../commands.cpp" line="691"/>
<source>Cancelled</source>
<translation>Отменено</translation>
</message>
@@ -774,6 +779,39 @@ Reconnect to the board if you want to continue working with it.</source>
<translation>Ок</translation>
</message>
</context>
<context>
<name>NetworkSettingsScreen</name>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="21"/>
<source>Url 1</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="53"/>
<source>Url 2</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="85"/>
<source>APN</source>
<translation></translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="117"/>
<source>User</source>
<translation>Пользователь</translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="149"/>
<source>Password</source>
<translation>Пароль</translation>
</message>
<message>
<location filename="../qml/Screens/NetworkSettingsScreen.qml" line="171"/>
<source>Apply</source>
<translation>Применить</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>