From 44f3a256a76a7e48a6f286f63ce799c048df324c Mon Sep 17 00:00:00 2001 From: Igor Makarov Date: Tue, 25 Jul 2017 09:21:47 +0300 Subject: [PATCH] fix TX power propery on Eddystone-UID & Eddytone-URL + bump version --- BeaconKit.podspec | 2 +- BeaconKitTests/EddystoneUidParserTests.swift | 4 ++-- BeaconKitTests/EddystoneUrlParserTests.swift | 4 ++-- Sources/Core/Classes/Beacon Implementations/Eddystone.swift | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/BeaconKit.podspec b/BeaconKit.podspec index 358d3b9..22b0473 100644 --- a/BeaconKit.podspec +++ b/BeaconKit.podspec @@ -4,7 +4,7 @@ filename = File.basename(__FILE__, '.podspec') Pod::Spec.new do |s| s.name = "#{filename}" - s.version = '1.0.0' + s.version = '1.0.1' s.summary = 'Beacon detection framework using CoreBluetooth' s.description = <<~DESC diff --git a/BeaconKitTests/EddystoneUidParserTests.swift b/BeaconKitTests/EddystoneUidParserTests.swift index 0d524a7..6eb0dda 100644 --- a/BeaconKitTests/EddystoneUidParserTests.swift +++ b/BeaconKitTests/EddystoneUidParserTests.swift @@ -20,7 +20,7 @@ class EddystoneUidParserTests: XCTestCase { } func testParsingValidBeacon() { - let data = Data.from(hex: "00e70001020304050607080901020304050A") + let data = Data.from(hex: "00010001020304050607080901020304050A") let rssi = -25 let identifier = UUID() let advertisement = BluetoothAdvertisement.service(CBUUID(string: "FEAA"), data) @@ -30,7 +30,7 @@ class EddystoneUidParserTests: XCTestCase { let beacon = beacons[0] as! EddystoneUidBeacon XCTAssertEqual(beacon.rssi, rssi) XCTAssertEqual(beacon.identifier, identifier) - XCTAssertEqual(beacon.txPower, -25) + XCTAssertEqual(beacon.txPower, -40) XCTAssertEqual(beacon.beaconType, 0) XCTAssertEqual(beacon.namespace, "00010203040506070809") XCTAssertEqual(beacon.instance, "01020304050A") diff --git a/BeaconKitTests/EddystoneUrlParserTests.swift b/BeaconKitTests/EddystoneUrlParserTests.swift index 1580b66..5213640 100644 --- a/BeaconKitTests/EddystoneUrlParserTests.swift +++ b/BeaconKitTests/EddystoneUrlParserTests.swift @@ -20,7 +20,7 @@ class EddystoneUrlParserTests: XCTestCase { } func testParsingValidBeacon() { - let data = Data.from(hex: "10E703636F636F61636173747300") + let data = Data.from(hex: "100203636F636F61636173747300") let rssi = -25 let identifier = UUID() let advertisement = BluetoothAdvertisement.service(CBUUID(string: "FEAA"), data) @@ -30,7 +30,7 @@ class EddystoneUrlParserTests: XCTestCase { let beacon = beacons[0] as! EddystoneUrlBeacon XCTAssertEqual(beacon.rssi, rssi) XCTAssertEqual(beacon.identifier, identifier) - XCTAssertEqual(beacon.txPower, -25) + XCTAssertEqual(beacon.txPower, -39) XCTAssertEqual(beacon.beaconType, 0x10) XCTAssertEqual(beacon.url, URL(string: "https://cocoacasts.com/")) XCTAssertEqual(beacon.beaconData.fields, []) diff --git a/Sources/Core/Classes/Beacon Implementations/Eddystone.swift b/Sources/Core/Classes/Beacon Implementations/Eddystone.swift index d6532ec..9ef95af 100644 --- a/Sources/Core/Classes/Beacon Implementations/Eddystone.swift +++ b/Sources/Core/Classes/Beacon Implementations/Eddystone.swift @@ -9,6 +9,10 @@ import CoreBluetooth public class EddystoneBeacon: Beacon { override open class var serviceUuid: CBUUID? { return CBUUID(string: "FEAA") } override open class var advertisementType: AdvertisementType { return .service } + // Eddystone TX value is zeroed at 0m so need to subtract 41dB + // to get 1m TX power + // [reference]: https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power + override public var txPower: Int { return super.txPower - 41 } } public class EddystoneUidBeacon: EddystoneBeacon {