Skip to content

Commit

Permalink
Merge pull request #36 from atsign-foundation/ErrorChecking
Browse files Browse the repository at this point in the history
feat: Stop looking for receivers or data owners if there is no pulse …
  • Loading branch information
cconstab authored Oct 2, 2022
2 parents a2e602a + f05372a commit 7321340
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dart/iot_sender/lib/iot_mqtt_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ Future<void> iotListen(AtClientManager atClientManager, NotificationService noti
final recMess = c![0].payload as MqttPublishMessage;
final pt = MqttPublishPayload.bytesToStringAsString(recMess.payload.message);

// If the mqtt subject is "mqtt/mwc_beat_hr_o2" but no pulse has been found
// just return and do not bother doing anything else.
if (c[0].topic == "mqtt/mwc_beat_hr_o2") {
if (c[0].topic == "mqtt/mwc_beat_hr_o2") {
List<String> beatBpmSpo = ['false', '0', '0'];
bool hrDetect = false;
try {
beatBpmSpo = pt.split(",");
hrDetect = beatBpmSpo[0].parseBool();
} catch (e) {
logger.severe('Error in message sent to mqtt/mwc_beat_hr_o2 format HR,O2 and this was received: $pt');
}
if (!hrDetect) {
logger.info('Data received on mqtt but no pulse found: $pt');
return;
}
}
}

// Set of Receivers (prevents dupes)
// To the set first we add the data owners
// Then we add the receivers that the dataowners want to add
Expand Down

0 comments on commit 7321340

Please sign in to comment.