Commit c3e219601028e31726189d63f0cab96ff548b042
1 parent
da383e21
fix:negative int compatibility
Showing
2 changed files
with
8 additions
and
8 deletions
HDFwear/Home/Model/NewGpsModel.swift
@@ -13,10 +13,10 @@ import SwiftDate | @@ -13,10 +13,10 @@ import SwiftDate | ||
13 | class NewGpsModel: NSObject { | 13 | class NewGpsModel: NSObject { |
14 | required override init() { } | 14 | required override init() { } |
15 | struct LocationPoint { | 15 | struct LocationPoint { |
16 | - var longitudeValue: UInt32 | ||
17 | - var longitudeScale: UInt32 | ||
18 | - var latitudeValue: UInt32 | ||
19 | - var latitudeScale: UInt32 | 16 | + var longitudeValue: Int32 |
17 | + var longitudeScale: Int32 | ||
18 | + var latitudeValue: Int32 | ||
19 | + var latitudeScale: Int32 | ||
20 | 20 | ||
21 | var longitude: Double { | 21 | var longitude: Double { |
22 | return convert(value: longitudeValue, scale: longitudeScale) | 22 | return convert(value: longitudeValue, scale: longitudeScale) |
@@ -26,7 +26,7 @@ class NewGpsModel: NSObject { | @@ -26,7 +26,7 @@ class NewGpsModel: NSObject { | ||
26 | return convert(value: latitudeValue, scale: latitudeScale) | 26 | return convert(value: latitudeValue, scale: latitudeScale) |
27 | } | 27 | } |
28 | 28 | ||
29 | - private func convert(value: UInt32, scale: UInt32) -> Double { | 29 | + private func convert(value: Int32, scale: Int32) -> Double { |
30 | if scale == 0 { | 30 | if scale == 0 { |
31 | return 0 | 31 | return 0 |
32 | } | 32 | } |
@@ -91,7 +91,7 @@ class NewGpsModel: NSObject { | @@ -91,7 +91,7 @@ class NewGpsModel: NSObject { | ||
91 | let latitudeValue = data[index + 8..<index + 12].reduce(0) { ($0 << 8) + UInt32($1) } | 91 | let latitudeValue = data[index + 8..<index + 12].reduce(0) { ($0 << 8) + UInt32($1) } |
92 | let latitudeScale = data[index + 12..<index + 16].reduce(0) { ($0 << 8) + UInt32($1) } | 92 | let latitudeScale = data[index + 12..<index + 16].reduce(0) { ($0 << 8) + UInt32($1) } |
93 | 93 | ||
94 | - let point = LocationPoint(longitudeValue: longitudeValue, longitudeScale: longitudeScale, latitudeValue: latitudeValue, latitudeScale: latitudeScale) | 94 | + let point = LocationPoint(longitudeValue: Int32(bitPattern:longitudeValue), longitudeScale: Int32(bitPattern:longitudeScale), latitudeValue: Int32(bitPattern:latitudeValue), latitudeScale: Int32(bitPattern:latitudeScale)) |
95 | arr.append(point) | 95 | arr.append(point) |
96 | } | 96 | } |
97 | gpsModel.locations = arr | 97 | gpsModel.locations = arr |
HDFwear/Tools/BleMessage+Function.swift
@@ -132,9 +132,9 @@ extension BleMessage { | @@ -132,9 +132,9 @@ extension BleMessage { | ||
132 | // withUnsafeBytes(of: timeInterval) { uint32Data.append(contentsOf: $0) } | 132 | // withUnsafeBytes(of: timeInterval) { uint32Data.append(contentsOf: $0) } |
133 | 133 | ||
134 | 134 | ||
135 | - var bytes:[UInt8] = [byte1, byte2, byte3, byte4, UInt8(weather.currentTemperature), UInt8(weather.lowestTemperature), UInt8(weather.highestTemperature), UInt8(weather.type.rawValue), UInt8(weather.airQuality.rawValue), UInt8(weather.humidity), UInt8(weather.wind.rawValue), UInt8(weather.windForce)] | 135 | + var bytes:[UInt8] = [byte1, byte2, byte3, byte4, UInt8(bitPattern: Int8(weather.currentTemperature)), UInt8(bitPattern: Int8(weather.lowestTemperature)), UInt8(bitPattern: Int8(weather.highestTemperature)), UInt8(weather.type.rawValue), UInt8(weather.airQuality.rawValue), UInt8(weather.humidity), UInt8(weather.wind.rawValue), UInt8(weather.windForce)] |
136 | for day in weather.next5Days { | 136 | for day in weather.next5Days { |
137 | - bytes += [UInt8(day.type.rawValue), UInt8(day.lowestTemperature), UInt8(day.highestTemperature)] | 137 | + bytes += [UInt8(day.type.rawValue), UInt8(bitPattern: Int8(day.lowestTemperature)), UInt8(bitPattern: Int8(day.highestTemperature))] |
138 | } | 138 | } |
139 | 139 | ||
140 | if let utf8Data = weather.position.data(using: .utf8) { | 140 | if let utf8Data = weather.position.data(using: .utf8) { |