Commit d1f02dfee301f711b5a61a1b8e83263ffeb25c67
1 parent
384cb690
feat:battery
Showing
3 changed files
with
13 additions
and
8 deletions
HDFwear/Setting/SettingViewController.swift
@@ -510,9 +510,9 @@ class SettingViewController: UIViewController, LBXScanViewControllerDelegate { | @@ -510,9 +510,9 @@ class SettingViewController: UIViewController, LBXScanViewControllerDelegate { | ||
510 | } | 510 | } |
511 | 511 | ||
512 | extension SettingViewController: BluetoothSyncDelegate { | 512 | extension SettingViewController: BluetoothSyncDelegate { |
513 | - func didReceiveBattery(value: Int, isCharging: Bool) { | ||
514 | - DeviceIsCharging = isCharging | ||
515 | - updateBattery(value, isCharging: isCharging) | 513 | + func didReceiveBattery(value: Int) { |
514 | +// DeviceIsCharging = isCharging | ||
515 | + updateBattery(value, isCharging: false) | ||
516 | } | 516 | } |
517 | } | 517 | } |
518 | extension SettingViewController: BluetoothManagerDelegate { | 518 | extension SettingViewController: BluetoothManagerDelegate { |
HDFwear/Tools/BluetoothManager+Function.swift
@@ -286,7 +286,6 @@ extension BluetoothManager { | @@ -286,7 +286,6 @@ extension BluetoothManager { | ||
286 | totalBytes = [] | 286 | totalBytes = [] |
287 | guard bytes.count > 12 else { return } | 287 | guard bytes.count > 12 else { return } |
288 | let msgId = Int(UInt16(bytes[4]) << 8 | UInt16(bytes[5])) | 288 | let msgId = Int(UInt16(bytes[4]) << 8 | UInt16(bytes[5])) |
289 | - let data = Data(bytes: bytes, count: bytes.count) | ||
290 | switch msgId { | 289 | switch msgId { |
291 | case 0x8001: | 290 | case 0x8001: |
292 | parseDefaultResponseData(bytes) | 291 | parseDefaultResponseData(bytes) |
@@ -296,6 +295,10 @@ extension BluetoothManager { | @@ -296,6 +295,10 @@ extension BluetoothManager { | ||
296 | print("实时步数、卡路里、距离自动上报") | 295 | print("实时步数、卡路里、距离自动上报") |
297 | case 0x8010:// 电量变化自动上报 | 296 | case 0x8010:// 电量变化自动上报 |
298 | print("电量变化自动上报") | 297 | print("电量变化自动上报") |
298 | + Battery = Int(bytes[10]) | ||
299 | + for delegate in syncDelegateList { | ||
300 | + delegate.didReceiveBattery(value: Battery) | ||
301 | + } | ||
299 | case 0x8014:// 电话挂断 | 302 | case 0x8014:// 电话挂断 |
300 | print("电话挂断") | 303 | print("电话挂断") |
301 | case 0x8015:// 找手机 | 304 | case 0x8015:// 找手机 |
HDFwear/Tools/BluetoothManager.swift
@@ -30,7 +30,6 @@ protocol BluetoothSyncDelegate { | @@ -30,7 +30,6 @@ protocol BluetoothSyncDelegate { | ||
30 | func didReceiveFindCommand(status: Bool) | 30 | func didReceiveFindCommand(status: Bool) |
31 | func didReceiveCameraCommand(status: SetCmd) | 31 | func didReceiveCameraCommand(status: SetCmd) |
32 | func didReceiveFindPhoneCommand() | 32 | func didReceiveFindPhoneCommand() |
33 | - func didReceiveBattery(value: Int, isCharging: Bool) | ||
34 | func didReceiveHeartRate(value: Int) | 33 | func didReceiveHeartRate(value: Int) |
35 | func didReceiveBloodOxygen() | 34 | func didReceiveBloodOxygen() |
36 | func didReceiveBloodPressure() | 35 | func didReceiveBloodPressure() |
@@ -38,12 +37,13 @@ protocol BluetoothSyncDelegate { | @@ -38,12 +37,13 @@ protocol BluetoothSyncDelegate { | ||
38 | func didReceiveStep() | 37 | func didReceiveStep() |
39 | func firstSync() | 38 | func firstSync() |
40 | func syncBug() | 39 | func syncBug() |
40 | + // adapted | ||
41 | + func didReceiveBattery(value: Int) | ||
41 | } | 42 | } |
42 | extension BluetoothSyncDelegate { | 43 | extension BluetoothSyncDelegate { |
43 | func didReceiveFindCommand(status: Bool) { } | 44 | func didReceiveFindCommand(status: Bool) { } |
44 | func didReceiveCameraCommand(status: SetCmd) { } | 45 | func didReceiveCameraCommand(status: SetCmd) { } |
45 | func didReceiveFindPhoneCommand() { } | 46 | func didReceiveFindPhoneCommand() { } |
46 | - func didReceiveBattery(value: Int, isCharging: Bool) { } | ||
47 | func didReceiveHeartRate(value: Int) { } | 47 | func didReceiveHeartRate(value: Int) { } |
48 | func didReceiveBloodOxygen() { } | 48 | func didReceiveBloodOxygen() { } |
49 | func didReceiveBloodPressure() { } | 49 | func didReceiveBloodPressure() { } |
@@ -51,6 +51,8 @@ extension BluetoothSyncDelegate { | @@ -51,6 +51,8 @@ extension BluetoothSyncDelegate { | ||
51 | func didReceiveStep() { } | 51 | func didReceiveStep() { } |
52 | func firstSync() {} | 52 | func firstSync() {} |
53 | func syncBug() {} | 53 | func syncBug() {} |
54 | + // adapted | ||
55 | + func didReceiveBattery(value: Int) { } | ||
54 | } | 56 | } |
55 | 57 | ||
56 | 58 | ||
@@ -1161,7 +1163,7 @@ class BluetoothManager: NSObject { | @@ -1161,7 +1163,7 @@ class BluetoothManager: NSObject { | ||
1161 | } | 1163 | } |
1162 | 1164 | ||
1163 | for delegate in syncDelegateList { | 1165 | for delegate in syncDelegateList { |
1164 | - delegate.didReceiveBattery(value: Battery, isCharging: isCharging) | 1166 | + delegate.didReceiveBattery(value: Battery) |
1165 | } | 1167 | } |
1166 | } | 1168 | } |
1167 | 1169 | ||
@@ -1440,7 +1442,7 @@ extension BluetoothManager: ClientProfileDelegate { | @@ -1440,7 +1442,7 @@ extension BluetoothManager: ClientProfileDelegate { | ||
1440 | print("电量------\([UInt8](data))") | 1442 | print("电量------\([UInt8](data))") |
1441 | Battery = Int([UInt8](data)[0]) | 1443 | Battery = Int([UInt8](data)[0]) |
1442 | for delegate in syncDelegateList { | 1444 | for delegate in syncDelegateList { |
1443 | - delegate.didReceiveBattery(value: Battery, isCharging: false) | 1445 | + delegate.didReceiveBattery(value: Battery) |
1444 | } | 1446 | } |
1445 | case BLEConfig.MTKDialReadUUID: | 1447 | case BLEConfig.MTKDialReadUUID: |
1446 | print("表盘------\([UInt8](data))") | 1448 | print("表盘------\([UInt8](data))") |