BluetoothServices.swift 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // BluetoothServices.swift
  3. // xDripG5
  4. //
  5. // Created by Nathan Racklyeft on 10/16/15.
  6. // Copyright © 2015 Nathan Racklyeft. All rights reserved.
  7. //
  8. import CoreBluetooth
  9. /*
  10. G5 BLE attributes, retrieved using LightBlue on 2015-10-01
  11. These are the G4 details, for reference:
  12. https://github.com/StephenBlackWasAlreadyTaken/xDrip/blob/af20e32652d19aa40becc1a39f6276cad187fdce/app/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/DexShareAttributes.java
  13. */
  14. protocol CBUUIDRawValue: RawRepresentable {}
  15. extension CBUUIDRawValue where RawValue == String {
  16. var cbUUID: CBUUID {
  17. return CBUUID(string: rawValue)
  18. }
  19. }
  20. enum TransmitterServiceUUID: String, CBUUIDRawValue {
  21. case deviceInfo = "180A"
  22. case advertisement = "FEBC"
  23. case cgmService = "F8083532-849E-531C-C594-30F1F86A4EA5"
  24. case serviceB = "F8084532-849E-531C-C594-30F1F86A4EA5"
  25. }
  26. enum DeviceInfoCharacteristicUUID: String, CBUUIDRawValue {
  27. // Read
  28. // "DexcomUN"
  29. case manufacturerNameString = "2A29"
  30. }
  31. enum CGMServiceCharacteristicUUID: String, CBUUIDRawValue {
  32. // Read/Notify
  33. case communication = "F8083533-849E-531C-C594-30F1F86A4EA5"
  34. // Write/Indicate
  35. case control = "F8083534-849E-531C-C594-30F1F86A4EA5"
  36. // Write/Indicate
  37. case authentication = "F8083535-849E-531C-C594-30F1F86A4EA5"
  38. // Read/Write/Notify
  39. case backfill = "F8083536-849E-531C-C594-30F1F86A4EA5"
  40. // // Unknown attribute present on older G6 transmitters
  41. // case unknown1 = "F8083537-849E-531C-C594-30F1F86A4EA5"
  42. //
  43. // // Updated G6 characteristic (read/notify)
  44. // case unknown2 = "F8083538-849E-531C-C594-30F1F86A4EA5"
  45. }
  46. enum ServiceBCharacteristicUUID: String, CBUUIDRawValue {
  47. // Write/Indicate
  48. case characteristicE = "F8084533-849E-531C-C594-30F1F86A4EA5"
  49. // Read/Write/Notify
  50. case characteristicF = "F8084534-849E-531C-C594-30F1F86A4EA5"
  51. }
  52. extension PeripheralManager.Configuration {
  53. static var dexcomG5: PeripheralManager.Configuration {
  54. return PeripheralManager.Configuration(
  55. serviceCharacteristics: [
  56. TransmitterServiceUUID.cgmService.cbUUID: [
  57. CGMServiceCharacteristicUUID.communication.cbUUID,
  58. CGMServiceCharacteristicUUID.authentication.cbUUID,
  59. CGMServiceCharacteristicUUID.control.cbUUID,
  60. CGMServiceCharacteristicUUID.backfill.cbUUID,
  61. ]
  62. ],
  63. notifyingCharacteristics: [:],
  64. valueUpdateMacros: [:]
  65. )
  66. }
  67. }