Skip to content

Commit

Permalink
Increase BLE Transfer Threshold
Browse files Browse the repository at this point in the history
This commit doubles the transfer threshold of the RSSI value so devices can be further apart when performing the transfer.

Issue: #61
  • Loading branch information
pr1sm committed Feb 21, 2018
1 parent 74e7f72 commit 01fbcd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions PowerScout/Bluetooth/ServiceStore+ProtocolHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ extension ServiceStore: CBCentralManagerDelegate {
filters[peripheral.identifier]!.addValue(RSSI.doubleValue)
let filter = filters[peripheral.identifier]!
let deviceIdx = self.foundNearbyDevices.index(where: {peripheral.identifier.hashValue == $0.hash && $0.type == .coreBluetooth})
if filter.average > -30.0 && deviceIdx == nil {
if filter.average > -60.0 && deviceIdx == nil {
print("CentralManager did discover peripheral \(peripheral.debugDescription) with addata \(advertisementData.debugDescription) and rssi \(RSSI)")
let newDevice = NearbyDevice(displayName: advertisementData[CBAdvertisementDataLocalNameKey] as? String ?? peripheral.name ?? "Unknown", type: .coreBluetooth, hash: peripheral.identifier.hashValue, mcInfo: [:], mcId: nil, cbPeripheral: peripheral)
self.foundNearbyDevices.append(newDevice)
self.delegate?.serviceStore(self, foundNearbyDevice: newDevice)
} else if filter.average < -30.0 && deviceIdx != nil {
} else if filter.average < -60.0 && deviceIdx != nil {
print("CentralManager did undiscover peripheral \(peripheral.debugDescription) with addata \(advertisementData.debugDescription) and rssi \(RSSI)")
let oldDevice = self.foundNearbyDevices.remove(at: deviceIdx!)
self.delegate?.serviceStore(self, lostNearbyDevice: oldDevice)
Expand Down
2 changes: 1 addition & 1 deletion PowerScout/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSBluetoothPeripheralUsageDescription</key>
Expand Down

0 comments on commit 01fbcd0

Please sign in to comment.