TrioRemoteControl+Helpers.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import Foundation
  2. extension TrioRemoteControl {
  3. func logError(_ errorMessage: String, payload: CommandPayload? = nil) async {
  4. var note = errorMessage
  5. if let payload = payload {
  6. note += " Details: \(payload.humanReadableDescription())"
  7. if let returnInfo = payload.returnNotification {
  8. await RemoteNotificationResponseManager.shared.sendResponseNotification(
  9. to: returnInfo,
  10. commandType: payload.commandType,
  11. success: false,
  12. message: errorMessage
  13. )
  14. }
  15. }
  16. debug(.remoteControl, note)
  17. await nightscoutManager.uploadNoteTreatment(note: note)
  18. }
  19. func logSuccess(_ message: String, payload: CommandPayload, customNotificationMessage: String? = nil) async {
  20. debug(.remoteControl, message)
  21. if let returnInfo = payload.returnNotification {
  22. await RemoteNotificationResponseManager.shared.sendResponseNotification(
  23. to: returnInfo,
  24. commandType: payload.commandType,
  25. success: true,
  26. message: customNotificationMessage ?? "Command successful"
  27. )
  28. }
  29. }
  30. }