Skip to content

Commit

Permalink
Cancel unexpected peripheral connection (#48)
Browse files Browse the repository at this point in the history
* Disconnect unwanted peripheral, so it can be discovered.

* - Update Changelog
- Add Readme and Changelog to project
- Bump version to 1.1.3

Co-authored-by: Filip Zieliński <[email protected]>
  • Loading branch information
filip-zielinski and Filip Zieliński committed Nov 3, 2022
1 parent ba7caaf commit 4cba7e9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion BlueSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = 'BlueSwift'
spec.version = '1.1.2'
spec.version = '1.1.3'
spec.summary = 'Easy and lightweight CoreBluetooth wrapper written in Swift'
spec.homepage = 'https://github.com/netguru/BlueSwift'

Expand Down
8 changes: 8 additions & 0 deletions Bluetooth.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
38FE6BE7200689AB00809A06 /* ConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38FE6BA82006898100809A06 /* ConfigurationTests.swift */; };
3A369634210F1C4E007C62F1 /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A369633210F1C4E007C62F1 /* CoreBluetooth.framework */; };
3A369636210F1C57007C62F1 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A369635210F1C57007C62F1 /* XCTest.framework */; };
4B2ACCCD29083F4300EF10B6 /* Readme.md in Resources */ = {isa = PBXBuildFile; fileRef = 4B2ACCCC29083F4200EF10B6 /* Readme.md */; };
4B2ACCCF29083F5400EF10B6 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 4B2ACCCE29083F5400EF10B6 /* CHANGELOG.md */; };
4B62466A280811CA009A8CC7 /* BluetoothAuthorizationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B624669280811CA009A8CC7 /* BluetoothAuthorizationStatus.swift */; };
4BEB6E6F2800735D0061C702 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEB6E6E2800735D0061C702 /* Sequence.swift */; };
4BEB6E72280077010061C702 /* SequenceExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEB6E70280075510061C702 /* SequenceExtensionTests.swift */; };
Expand Down Expand Up @@ -153,6 +155,8 @@
3A142D24210F0EEE000A6089 /* Sample-Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Sample-Base.xcconfig"; sourceTree = "<group>"; };
3A369633210F1C4E007C62F1 /* CoreBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBluetooth.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/CoreBluetooth.framework; sourceTree = DEVELOPER_DIR; };
3A369635210F1C57007C62F1 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
4B2ACCCC29083F4200EF10B6 /* Readme.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = "<group>"; };
4B2ACCCE29083F5400EF10B6 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
4B624669280811CA009A8CC7 /* BluetoothAuthorizationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothAuthorizationStatus.swift; sourceTree = "<group>"; };
4BEB6E6E2800735D0061C702 /* Sequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sequence.swift; sourceTree = "<group>"; };
4BEB6E70280075510061C702 /* SequenceExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequenceExtensionTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -190,6 +194,8 @@
3837BA021FFFC2FE00DF300E = {
isa = PBXGroup;
children = (
4B2ACCCC29083F4200EF10B6 /* Readme.md */,
4B2ACCCE29083F5400EF10B6 /* CHANGELOG.md */,
38FE6BC32006898100809A06 /* Bluetooth */,
38FE6BB32006898100809A06 /* Framework */,
38FE6BA62006898100809A06 /* Unit Tests */,
Expand Down Expand Up @@ -591,7 +597,9 @@
buildActionMask = 2147483647;
files = (
38EBB9572052D0EF002797A1 /* Main.storyboard in Resources */,
4B2ACCCF29083F5400EF10B6 /* CHANGELOG.md in Resources */,
38FE6BE42006898F00809A06 /* Assets.xcassets in Resources */,
4B2ACCCD29083F4300EF10B6 /* Readme.md in Resources */,
38FE6BE52006899300809A06 /* LaunchScreen.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.1.3] - 2022-10-25

### Changed

- Peripheral which was connected, but it was not on the list of peripherals that should be connected, is disconnected. This change allows to discover this peripheral again.

## [1.1.2] - 2022-09-06

### Added
Expand Down
2 changes: 1 addition & 1 deletion Configurations/Common/Common-Base.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "../xcconfigs/Common/Common.xcconfig"

_BUILD_VERSION = 1.1.2
_BUILD_VERSION = 1.1.3
_BUILD_NUMBER = 1

_DEPLOYMENT_TARGET_IOS = 11.0
Expand Down
7 changes: 6 additions & 1 deletion Framework/Source Files/Connection/ConnectionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ extension ConnectionService: CBCentralManagerDelegate {
/// Called upon a successfull peripheral connection.
/// - SeeAlso: CBCentralManagerDelegate
public func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
guard let connectingPeripheral = peripherals.first(withIdentical: peripheral) else { return }
guard let connectingPeripheral = peripherals.first(withIdentical: peripheral) else {
// Central manager did connect to a peripheral, which is not on the list of allowed peripherals at this moment.
// Peripheral might have re-connected unexpectedly. Disconnect it, so it can be discovered.
centralManager.cancelPeripheralConnection(peripheral)
return
}
self.connectingPeripheral = connectingPeripheral
connectingPeripheral.peripheral = peripheral
peripheral.delegate = self
Expand Down
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ Just drop the line below to your Podfile:

`pod 'BlueSwift'`

(but probably you'd like to pin it to the nearest major release, so `pod 'BlueSwift' , '~> 1.1.2'`)
(but probably you'd like to pin it to the nearest major release, so `pod 'BlueSwift' , '~> 1.1.3'`)

### ![](https://img.shields.io/badge/carthage-compatible-green.svg)

The same as with Cocoapods, insert the line below to your Cartfile:

`github 'netguru/BlueSwift'`

, or including version - `github 'netguru/BlueSwift' ~> 1.1.2`
, or including version - `github 'netguru/BlueSwift' ~> 1.1.3`

## 📄 License

Expand Down

0 comments on commit 4cba7e9

Please sign in to comment.