From ff16fbe921feb3ca00249cf421c50900d20b280a Mon Sep 17 00:00:00 2001 From: Jesse Johnston Date: Thu, 7 Apr 2022 15:32:08 -0700 Subject: [PATCH 1/2] Read probe hardware revision --- Sources/CombustionBLE/BleManager.swift | 13 +++++++++---- Sources/CombustionBLE/Device.swift | 3 +++ Sources/CombustionBLE/DeviceManager.swift | 6 ++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Sources/CombustionBLE/BleManager.swift b/Sources/CombustionBLE/BleManager.swift index 942498f..f363c31 100644 --- a/Sources/CombustionBLE/BleManager.swift +++ b/Sources/CombustionBLE/BleManager.swift @@ -38,6 +38,7 @@ protocol BleManagerDelegate: AnyObject { func updateDeviceWithAdvertising(advertising: AdvertisingData, rssi: NSNumber, identifier: UUID) func updateDeviceWithLogResponse(identifier: UUID, logResponse: LogResponse) func updateDeviceFwVersion(identifier: UUID, fwVersion: String) + func updateDeviceHwRevision(identifier: UUID, hwRevision: String) } /// Manages Core Bluetooth interface with the rest of the app. @@ -60,6 +61,7 @@ class BleManager : NSObject { static let UART_SERVICE = CBUUID(string: "6E400001-B5A3-F393-E0A9-E50E24DCCA9E") static let FW_VERSION_CHAR = CBUUID(string: "2a26") + static let HW_REVISION_CHAR = CBUUID(string: "2a27") static let DEVICE_STATUS_CHAR = CBUUID(string: "00000101-CAAB-3792-3D44-97AE51C1407A") static let UART_RX_CHAR = CBUUID(string: "6E400002-B5A3-F393-E0A9-E50E24DCCA9E") static let UART_TX_CHAR = CBUUID(string: "6E400003-B5A3-F393-E0A9-E50E24DCCA9E") @@ -200,14 +202,13 @@ extension BleManager: CBPeripheralDelegate { guard let characteristics = service.characteristics else { return } for characteristic in characteristics { - // print("discovered characteristic : \(characteristic.uuid) : \(characteristic.uuid.uuidString) :\(characteristic.descriptors)") - if(characteristic.uuid == Constants.UART_RX_CHAR) { - print("Found UART characteristic") uartCharacteristics[peripheral.identifier.uuidString] = characteristic } else if(characteristic.uuid == Constants.DEVICE_STATUS_CHAR) { deviceStatusCharacteristics[peripheral.identifier.uuidString] = characteristic - } else if(characteristic.uuid == Constants.FW_VERSION_CHAR) { + } else if(characteristic.uuid == Constants.FW_VERSION_CHAR || + characteristic.uuid == Constants.HW_REVISION_CHAR) { + // Read FW version and HW revision when the characteristics are discovered peripheral.readValue(for: characteristic) } @@ -254,6 +255,10 @@ extension BleManager: CBPeripheralDelegate { let fwVersion = String(decoding: data, as: UTF8.self) delegate?.updateDeviceFwVersion(identifier: peripheral.identifier, fwVersion: fwVersion) } + else if characteristic.uuid == Constants.HW_REVISION_CHAR { + let hwRevision = String(decoding: data, as: UTF8.self) + delegate?.updateDeviceHwRevision(identifier: peripheral.identifier, hwRevision: hwRevision) + } else { // print("didUpdateValueFor: \(characteristic): unknown service") } diff --git a/Sources/CombustionBLE/Device.swift b/Sources/CombustionBLE/Device.swift index 8329a16..1717005 100644 --- a/Sources/CombustionBLE/Device.swift +++ b/Sources/CombustionBLE/Device.swift @@ -48,6 +48,9 @@ public class Device : ObservableObject { /// Device firmware version public internal(set) var firmareVersion: String? + /// Device hardware revision + public internal(set) var hardwareRevision: String? + /// Current connection state of device @Published public internal(set) var connectionState: ConnectionState = .disconnected diff --git a/Sources/CombustionBLE/DeviceManager.swift b/Sources/CombustionBLE/DeviceManager.swift index 2d4cb14..cab5821 100644 --- a/Sources/CombustionBLE/DeviceManager.swift +++ b/Sources/CombustionBLE/DeviceManager.swift @@ -241,6 +241,12 @@ extension DeviceManager : BleManagerDelegate { } } + func updateDeviceHwRevision(identifier: UUID, hwRevision: String) { + if let device = devices[identifier.uuidString] { + device.hardwareRevision = hwRevision + } + } + func handleSetIDResponse(identifier: UUID, success: Bool) { setIDCompetionHandlers[identifier.uuidString]?.handler(success) From 4bebc5f588533c23305eced6ececf9f78d7350cc Mon Sep 17 00:00:00 2001 From: Jesse Johnston Date: Thu, 7 Apr 2022 15:37:55 -0700 Subject: [PATCH 2/2] Update readme --- README.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0b9c2bc..d4f5431 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ An instance of the `Probe` class representes an individual temperature probe tha - `name` - String format of probe serial number - `macAddress` - Probe's MAC address - `macAddressString` - String representation of Probe's MAC address +- `id` - Probe's numeric ID (1-8) +- `color` - Probe's silicone ring color - `batteryLevel` - Battery level as reported by probe *NOTE: This is not yet implemented in probe firmware and will likely change to a boolean 'battery low' flag in the near future.* - `currentTemperatures` - `ProbeTemperatures` struct containing the most recent temperatures read by the Probe. - `currentTemperatures.values` - Array of these temperatures, in celsius, where `values[0]` is temperature sensor T1, and `values[7]` is temperature sensor T8. @@ -90,7 +92,7 @@ An instance of the `Probe` class representes an individual temperature probe tha - T7 - High-temperature thermistor - T8 - High-temperature thermistor on handle tip measuring ambient -- `id` - iOS-provided UUID for the device +- `identifier` - iOS-provided UUID for the device - `rssi` - Signal strength between Probe and iOS device @@ -102,9 +104,8 @@ An instance of the `Probe` class representes an individual temperature probe tha - `stale` - `true` if no advertising data or notifications have been received from the Probe within the "staleness timeout" (15 seconds), or `false` if recent data has been received. -- `status` - `DeviceStatus` struct containing device status information. - - `minSequenceNumber` - Minimum sequence number of log records stored on the probe - - `maxSequenceNumber` - Maximum sequence number of log records stored on the probe +- `minSequenceNumber` - Minimum sequence number of log records stored on the probe +- `maxSequenceNumber` - Maximum sequence number of log records stored on the probe - `logsUpToDate` - Boolean value that indicates whether all log sequence numbers contained in the probe (determined by the `status` sequence number range) have been successfully retrieved and stored in the app's memory. @@ -154,14 +155,6 @@ struct EngineeringProbeList: View { The following features are planned for near-term development but are not yet implemented in this version of the Combustion BLE Framework. -### Set ring color - -The framework will provide functions allowing a probe's identifying silicone ring color to be configured by the user (colors TBA). - -### Set numeric ID - -The framework will provide functions allowing a Probe's numeric ID (1-8) to be configured by the user. - ### Firmware update The framework will provide methods for updating a Probe's firmware with a signed firmware image.