Skip to content

Commit 44786ae

Browse files
committed
Add method to reset information and clean up found devices when stop scanning
1 parent 64bd83e commit 44786ae

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Improv-iOS.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = "Improv-iOS"
3-
spec.version = "0.0.2"
3+
spec.version = "0.0.3"
44
spec.summary = "Easily detect and connect Improv devices to WiFi networks in iOS"
55
spec.description = "This library abstracts the bluetooth scanning for Improv devices and allow you to connect them to WiFi networks"
66
spec.author = "Improv"

Improv-iOS.xcodeproj/xcuserdata/brunopantaleao.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<key>Improv-iOS.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>0</integer>
10+
<integer>1</integer>
1111
</dict>
1212
<key>Improve-iOS-Demo.xcscheme_^#shared#^_</key>
1313
<dict>
1414
<key>orderHint</key>
15-
<integer>1</integer>
15+
<integer>0</integer>
1616
</dict>
1717
</dict>
1818
</dict>

Improv-iOS/ImprovManager.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public protocol ImprovManagerProtocol: ObservableObject {
1818
func connectToDevice(_ peripheral: CBPeripheral)
1919
func identifyDevice()
2020
func sendWifi(ssid: String, password: String)
21+
func reset()
2122
}
2223

2324
public protocol ImprovManagerDelegate: AnyObject {
@@ -34,6 +35,8 @@ public protocol ImprovManagerDelegate: AnyObject {
3435
func didUpdateErrorState(_ state: ErrorState?)
3536

3637
func didReceiveResult(_ result: [String]?)
38+
39+
func didReset()
3740
}
3841

3942
public final class ImprovManager: NSObject, ImprovManagerProtocol {
@@ -82,6 +85,8 @@ public final class ImprovManager: NSObject, ImprovManagerProtocol {
8285
public func stopScan() {
8386
bluetoothManager.stopScan()
8487
scanInProgress = false
88+
foundDevices = [:]
89+
delegate?.didUpdateFoundDevices(devices: foundDevices)
8590
}
8691

8792
public func connectToDevice(_ peripheral: CBPeripheral) {
@@ -96,6 +101,18 @@ public final class ImprovManager: NSObject, ImprovManagerProtocol {
96101
public func sendWifi(ssid: String, password: String) {
97102
bluetoothManager.sendWifi(ssid: ssid, password: password)
98103
}
104+
105+
public func reset() {
106+
stopScan()
107+
bluetoothState = bluetoothManager.state
108+
errorState = nil
109+
deviceState = nil
110+
lastResult = nil
111+
foundDevices = [String: CBPeripheral]()
112+
connectedDevice = nil
113+
114+
delegate?.didReset()
115+
}
99116
}
100117

101118
extension ImprovManager: BluetoothManagerDelegate {

0 commit comments

Comments
 (0)