getWeightEnsuringConnection method
If not connected, refreshes device list and opens scale with first device, then reads weight.
Implementation
@override
Future<AclasWeightInfo?> getWeightEnsuringConnection() async {
if (!(await isConnected())) {
final list = await getDeviceList();
final type = await getConnectionType();
if (list.isNotEmpty) {
if (type == AclasConnectionType.Serial) {
await openScale(path: list.first);
} else if (type == AclasConnectionType.USB) {
await openScale(index: 0);
} else {
await openScale(address: list.first);
}
}
}
return getWeight();
}