8000 Feature/hardware revision by jjohnstz · Pull Request #12 · combustion-inc/combustion-ios-ble · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/hardware revision #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
13 changes: 9 additions & 4 deletions Sources/CombustionBLE/BleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/CombustionBLE/Device.swift
A5F9
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions Sources/CombustionBLE/DeviceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
0