Skip to content

Commit

Permalink
Fix #393: the measurement won't stuck of the sink server is unreachab…
Browse files Browse the repository at this point in the history
…le. destroy instead of close may make it more robust

(TrackMyIndoorWorkout/FTMSServer#2)
  • Loading branch information
MrCsabaToth committed Jan 9, 2023
1 parent f1fed32 commit 36750dd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/ui/recording.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,17 @@ class RecordingState extends State<RecordingScreen> {
widget.sport == ActivityType.canoeing ||
widget.sport == ActivityType.rowing ||
widget.sport == ActivityType.swim)) {
_sinkSocket = await Socket.connect(_sinkAddress.item1, _sinkAddress.item2);
// Send descriptor packet
const version = 1;
final uuidLsb = widget.sport == ActivityType.ride ? 0xD2 : 0xD1;
final packetLength = RecordWithSport.binarySerializedLength(widget.sport);
_sinkSocket?.add([version, 0x18, 0x26, 0x2A, uuidLsb, packetLength]);
try {
_sinkSocket = await Socket.connect(_sinkAddress.item1, _sinkAddress.item2);
// Send descriptor packet
const version = 1;
final uuidLsb = widget.sport == ActivityType.ride ? 0xD2 : 0xD1;
final packetLength = RecordWithSport.binarySerializedLength(widget.sport);
_sinkSocket?.add([version, 0x18, 0x26, 0x2A, uuidLsb, packetLength]);
} on SocketException {
Get.snackbar("Error", "Could not connect to Sink Server");
_sinkSocket = null;
}
}

await _fitnessEquipment?.additionalSensorsOnDemand();
Expand Down Expand Up @@ -1095,7 +1100,7 @@ class RecordingState extends State<RecordingScreen> {
}
}

_sinkSocket?.close();
_sinkSocket?.destroy();
_sinkSocket = null;
}

Expand Down

0 comments on commit 36750dd

Please sign in to comment.