Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
laki_icu_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
laki_icu_app
Commits
74d50b40
Commit
74d50b40
authored
Jun 24, 2026
by
akari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 更改SN格式
parent
266ba06d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
8 deletions
+49
-8
monitoring_mock_data.dart
lib/repositories/mock/monitoring_mock_data.dart
+4
-4
mcu_report.dart
lib/utils/bluetooth/mcu_report.dart
+18
-1
monitoring_index_cubit.dart
lib/views/monitoring/index/cubit/monitoring_index_cubit.dart
+27
-3
No files found.
lib/repositories/mock/monitoring_mock_data.dart
View file @
74d50b40
...
...
@@ -11,28 +11,28 @@ class MonitoringMockData {
static
List
<
MonitoringMetricBO
>
getMockMetrics
()
{
return
const
[
MonitoringMetricBO
(
value:
'
24.5
'
,
value:
'
--
'
,
unit:
'℃'
,
label:
'舱内温度'
,
borderColorValue:
0xFF00FF9D
,
backgroundColorValue:
0x1A00FF9D
,
),
MonitoringMetricBO
(
value:
'
63
'
,
value:
'
--
'
,
unit:
'RH'
,
label:
'舱内湿度'
,
borderColorValue:
0xFF00B8FF
,
backgroundColorValue:
0x1A00B8FF
,
),
MonitoringMetricBO
(
value:
'
21
'
,
value:
'
--
'
,
unit:
'%'
,
label:
'氧气浓度'
,
borderColorValue:
0xFF00FF9D
,
backgroundColorValue:
0x1A00FF9D
,
),
MonitoringMetricBO
(
value:
'
0.5
'
,
value:
'
--
'
,
unit:
'%'
,
label:
'二氧化碳'
,
borderColorValue:
0xFFFF7D00
,
...
...
lib/utils/bluetooth/mcu_report.dart
View file @
74d50b40
...
...
@@ -366,6 +366,7 @@ class McuReportParser {
String
hex2
()
=>
remainingPayloadBytes
()
>=
2
?
payload
!.
readHex
(
2
)
:
''
;
String
ascii
(
int
bytes
)
=>
remainingPayloadBytes
()
>=
bytes
?
payload
!.
readAscii
(
bytes
)
:
''
;
String
snAscii
(
int
bytes
)
=>
_normalizeSn
(
ascii
(
bytes
));
return
McuReport
(
head:
head
,
...
...
@@ -432,7 +433,7 @@ class McuReportParser {
pulseRate:
highByte
(),
xyyStatus:
highByte
(),
xyyError1:
highByte
(),
sn:
a
scii
(
10
),
sn:
snA
scii
(
10
),
topTempCorrect:
highByte
(),
midTempCorrect:
highByte
(),
o2OpenCorrectStart:
highByte
(),
...
...
@@ -447,6 +448,22 @@ class McuReportParser {
return
parseHex
(
_bytesToHex
(
bytes
));
}
static
String
_normalizeSn
(
String
value
)
{
if
(
value
.
isEmpty
)
return
value
;
final
buffer
=
StringBuffer
();
for
(
var
index
=
0
;
index
<
value
.
length
;
index
+=
2
)
{
if
(
index
+
1
<
value
.
length
)
{
buffer
..
write
(
value
[
index
+
1
])
..
write
(
value
[
index
]);
}
else
{
buffer
.
write
(
value
[
index
]);
}
}
return
buffer
.
toString
();
}
static
String
_bytesToHex
(
List
<
int
>
bytes
)
{
return
bytes
.
map
((
item
)
=>
item
.
toRadixString
(
16
).
padLeft
(
2
,
'0'
))
...
...
lib/views/monitoring/index/cubit/monitoring_index_cubit.dart
View file @
74d50b40
...
...
@@ -134,8 +134,10 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
'co2Set=
${latestReport.co2Setting}
'
'sn=
${latestReport.sn.isEmpty ? '<EMPTY>' : latestReport.sn}
'
,
);
final
bluetoothReadInfo
=
BluetoothReadModel
.
fromMcuReport
(
latestReport
);
final
reportSn
=
_appendBluetoothSideToSn
(
latestReport
.
sn
);
final
bluetoothReadInfo
=
BluetoothReadModel
.
fromMcuReport
(
latestReport
,
).
copyWith
(
sn:
reportSn
.
isEmpty
?
null
:
reportSn
);
if
(
bluetoothReadInfo
.
hasSn
)
{
await
_storageService
.
saveBluetoothReadSn
(
bluetoothReadInfo
.
sn
!);
await
_connectMqttForDeviceSn
(
bluetoothReadInfo
.
sn
!);
...
...
@@ -175,6 +177,19 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
});
}
String
_appendBluetoothSideToSn
(
String
sn
)
{
final
cleanSn
=
sn
.
trim
();
if
(
cleanSn
.
isEmpty
)
return
''
;
final
deviceName
=
state
.
boundBluetoothDeviceName
?.
trim
();
if
(
deviceName
==
null
||
deviceName
.
isEmpty
)
return
cleanSn
;
final
side
=
deviceName
[
deviceName
.
length
-
1
].
toUpperCase
();
if
(
side
!=
'L'
&&
side
!=
'R'
)
return
cleanSn
;
return
cleanSn
.
toUpperCase
().
endsWith
(
side
)
?
cleanSn
:
'
$cleanSn$side
'
;
}
Future
<
void
>
_loadBoundBluetoothDevice
()
async
{
final
boundDevice
=
await
_storageService
.
getBoundBluetoothDevice
();
if
(
isClosed
)
return
;
...
...
@@ -192,7 +207,16 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
boundBluetoothDeviceName:
boundDevice
[
'deviceName'
],
));
if
(
bluetoothReadInfo
.
hasSn
)
{
_connectMqttForDeviceSn
(
bluetoothReadInfo
.
sn
!);
final
sn
=
_appendBluetoothSideToSn
(
bluetoothReadInfo
.
sn
!);
if
(
sn
.
isNotEmpty
)
{
if
(
sn
!=
bluetoothReadInfo
.
sn
)
{
await
_storageService
.
saveBluetoothReadSn
(
sn
);
eventBus
.
emit
(
BluetoothReadInfoChangedEvent
(
bluetoothReadInfo
.
copyWith
(
sn:
sn
)),
);
}
_connectMqttForDeviceSn
(
sn
);
}
}
if
(
deviceId
!=
null
&&
deviceId
.
isNotEmpty
)
{
_isAutoReconnectEnabled
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment