Skip to content

Commit

Permalink
Add warnings to scan against leaving serviceIdentifiers set to nil
Browse files Browse the repository at this point in the history
…or empty (#160)

* add warning to calling `scan` with `serviceIdentifiers` empty

* bump version number in podspec and info, updated changelog

* update changelog

* Update tag version in podspec as well
  • Loading branch information
brendanlensink authored and Jeremy Chiang committed Aug 2, 2018
1 parent a3dfd50 commit 158c4f5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Bluejay.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |spec|
spec.name = 'Bluejay'
spec.version = '0.6.3'
spec.version = '0.6.4'
spec.license = { type: 'MIT', file: 'LICENSE' }
spec.homepage = 'https://github.com/steamclock/bluejay'
spec.authors = { 'Jeremy Chiang' => '[email protected]' }
spec.summary = 'Bluejay is a simple Swift framework for building reliable Bluetooth apps.'
spec.homepage = 'https://github.com/steamclock/bluejay'
spec.source = { git: 'https://github.com/steamclock/bluejay.git', tag: 'v0.6.3' }
spec.source = { git: 'https://github.com/steamclock/bluejay.git', tag: 'v0.6.4' }
spec.source_files = 'Bluejay/Bluejay/*.{h,swift}'
spec.framework = 'SystemConfiguration'
spec.platform = :ios, '9.3'
Expand Down
2 changes: 2 additions & 0 deletions Bluejay/Bluejay/Bluejay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ public class Bluejay: NSObject {

/**
Scan for the peripheral(s) specified.
- Warning: Setting `serviceIdentifiers` to `nil` will result in picking up all available Bluetooth peripherals in the vicinity, **but is not recommended by Apple**. It may cause battery and cpu issues on prolonged scanning, and **it also doesn't work in the background**. If you need to scan for all Bluetooth devices, we recommend making use of the `duration` parameter to stop the scan after 5 ~ 10 seconds to avoid scanning indefinitely and overloading the hardware.
- Parameters:
- duration: Stops the scan when the duration in seconds is reached. Defaults to zero (indefinite).
Expand Down
2 changes: 1 addition & 1 deletion Bluejay/Bluejay/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.6.3</string>
<string>0.6.4</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
4 changes: 4 additions & 0 deletions Bluejay/Bluejay/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Scan: Queueable {
self.expired = expired
self.stopped = stopped
self.manager = manager

if serviceIdentifiers?.isEmpty != false {
log("Warning: Setting `serviceIdentifiers` to `nil` is not recommended by Apple. It may cause battery and cpu issues on prolonged scanning, and **it also doesn't work in the background**. If you need to scan for all Bluetooth devices, we recommend making use of the `duration` parameter to stop the scan after 5 ~ 10 seconds to avoid scanning indefinitely and overloading the hardware.")
}
}

func start() {
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.6.4] - 2018-08-02
### Added
- Added warnings against using `scan` with `serviceIdentifiers` set to `nil` or empty.

## [0.6.3] - 2018-07-26
### Added
- Add API to check whether a peripheral is listening to a characteristic
Expand Down

0 comments on commit 158c4f5

Please sign in to comment.