OmnipodDashHeartbeatBluetoothTransmitter.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // LoopFollow
  2. // OmnipodDashHeartbeatBluetoothTransmitter.swift
  3. // Created by Jonas Björkert on 2025-01-13.
  4. import CoreBluetooth
  5. import Foundation
  6. class OmnipodDashHeartbeatBluetoothTransmitter: BluetoothDevice {
  7. private let CBUUID_Service: String = "1A7E4024-E3ED-4464-8B7E-751E03D0DC5F"
  8. private let CBUUID_Advertisement: String = "00004024-0000-1000-8000-00805f9b34fb"
  9. private let CBUUID_ReceiveCharacteristic: String = "1A7E2442-E3ED-4464-8B7E-751E03D0DC5F"
  10. private let CBUUID_ReceiveCharacteristic_Data: String = ""
  11. init(address: String, name: String?, bluetoothDeviceDelegate: BluetoothDeviceDelegate) {
  12. super.init(
  13. address: address,
  14. name: name,
  15. CBUUID_Advertisement: nil,
  16. servicesCBUUIDs: [CBUUID(string: CBUUID_Service)],
  17. CBUUID_ReceiveCharacteristic: CBUUID_ReceiveCharacteristic,
  18. bluetoothDeviceDelegate: bluetoothDeviceDelegate
  19. )
  20. }
  21. override func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
  22. super.centralManager(central, didConnect: peripheral)
  23. }
  24. override func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
  25. super.peripheral(peripheral, didUpdateValueFor: characteristic, error: error)
  26. bluetoothDeviceDelegate?.heartBeat()
  27. }
  28. override func expectedHeartbeatInterval() -> TimeInterval? {
  29. return 3 * 60
  30. }
  31. }