Skip to content
This repository was archived by the owner on Dec 19, 2022. It is now read-only.

Commit 4d7922e

Browse files
authored
Merge pull request #1 from NordicSemiconductor/develop
Release 1.0.1
2 parents 609babc + 2aa2119 commit 4d7922e

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- **1.0.1**:
2+
- Bugfix: Fixed an issue where swiping back from the peripheral view without actually dismissing would cause the app not to reconnect to the Blinky peripheral.
3+
4+
- **1.0**:
5+
- Initial implementation

nRFBlinky/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>1.0.1</string>
1919
<key>CFBundleVersion</key>
20-
<string>1</string>
20+
<string>2</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>UILaunchStoryboardName</key>

nRFBlinky/ViewControllers/BlinkyView/BlinkyViewController.swift

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,7 @@ class BlinkyViewController: UITableViewController, CBCentralManagerDelegate {
5252
}
5353
}
5454

55-
//MARK: - UITableViewDelegate
56-
override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
57-
return false
58-
}
59-
60-
//MARK: - UIViewController
61-
override func viewWillAppear(_ animated: Bool) {
62-
super.viewWillAppear(animated)
63-
55+
private func setupDependencies() {
6456
//This will run on iOS 10 or above
6557
//and will generate a tap feedback when the button is tapped on the Dev kit.
6658
prepareHaptics()
@@ -70,7 +62,7 @@ class BlinkyViewController: UITableViewController, CBCentralManagerDelegate {
7062
buttonStateLabel.text = "Reading ..."
7163
ledStateLabel.text = "Reading ..."
7264
ledToggleSwitch.isEnabled = false
73-
65+
7466
print("Adding button notification and LED write callback handlers")
7567
blinkyPeripheral.setButtonCallback { (isPressed) -> (Void) in
7668
DispatchQueue.main.async {
@@ -88,7 +80,7 @@ class BlinkyViewController: UITableViewController, CBCentralManagerDelegate {
8880
if !self.ledToggleSwitch.isEnabled {
8981
self.ledToggleSwitch.isEnabled = true
9082
}
91-
83+
9284
if isOn {
9385
self.ledStateLabel.text = "ON"
9486
if self.ledToggleSwitch.isOn == false {
@@ -103,18 +95,33 @@ class BlinkyViewController: UITableViewController, CBCentralManagerDelegate {
10395
}
10496
}
10597
}
98+
//MARK: - UITableViewDelegate
99+
override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
100+
return false
101+
}
102+
103+
//MARK: - UIViewController
104+
override func viewWillAppear(_ animated: Bool) {
105+
super.viewWillAppear(animated)
106+
guard blinkyPeripheral.basePeripheral.state != .connected else {
107+
//View is coming back from a swipe, everything is already setup
108+
return
109+
}
110+
//This is the first time view appears, setup the subviews and dependencies
111+
setupDependencies()
112+
}
106113

107-
override func viewWillDisappear(_ animated: Bool) {
114+
override func viewDidDisappear(_ animated: Bool) {
108115
print("Removing button notification and LED write callback handlers")
109116
blinkyPeripheral.removeLEDCallback()
110117
blinkyPeripheral.removeButtonCallback()
111118

112119
if blinkyPeripheral.basePeripheral.state == .connected {
113120
centralManager.cancelPeripheralConnection(blinkyPeripheral.basePeripheral)
114121
}
115-
116-
super.viewWillDisappear(animated)
122+
super.viewDidDisappear(animated)
117123
}
124+
118125
//MARK: - CBCentralManagerDelegate
119126
func centralManagerDidUpdateState(_ central: CBCentralManager) {
120127
if central.state != .poweredOn {

nRFBlinky/ViewControllers/ScannerView/ScannerTableViewController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ class ScannerTableViewController: UITableViewController, CBCentralManagerDelegat
104104
// MARK: - UIViewController
105105
override func viewWillAppear(_ animated: Bool) {
106106
super.viewWillAppear(animated)
107-
centralManager.delegate = self
108107
discoveredPeripherals.removeAll()
109108
tableView.reloadData()
110-
109+
}
110+
111+
override func viewDidAppear(_ animated: Bool) {
112+
super.viewDidDisappear(animated)
113+
centralManager.delegate = self
111114
if centralManager.state == .poweredOn {
112115
activityIndicator.startAnimating()
113116
centralManager.scanForPeripherals(withServices: [BlinkyPeripheral.nordicBlinkyServiceUUID], options: [CBCentralManagerScanOptionAllowDuplicatesKey : true])

0 commit comments

Comments
 (0)