Skip to content

Commit

Permalink
Merge pull request #21 from SiliconLabs/release-2.9.3
Browse files Browse the repository at this point in the history
BTAPP-2011 | Enable BLE provisioning for 917 sensor demo on IOS
  • Loading branch information
mantosh83 authored Oct 14, 2024
2 parents 38a24ea + 8a21914 commit 790fc8e
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 63 deletions.
16 changes: 12 additions & 4 deletions SiliconLabsApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@
4388B2D32C3047910068C950 /* SILWiFiMotionVcCh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4388B2D22C3047910068C950 /* SILWiFiMotionVcCh.swift */; };
4388B2D52C305B0C0068C950 /* WiFiMotionDemoConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4388B2D42C305B0C0068C950 /* WiFiMotionDemoConnection.swift */; };
4388B2E22C3FC9370068C950 /* SILAllWiFiSensorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4388B2E12C3FC9370068C950 /* SILAllWiFiSensorModel.swift */; };
439B76122CA173D700B4E737 /* SILNetworkCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439B76112CA173D700B4E737 /* SILNetworkCheck.swift */; };
439B766A2CA4093F00B4E737 /* SILWifiSensorsHomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439B76692CA4093F00B4E737 /* SILWifiSensorsHomeViewModel.swift */; };
439F2C792C2C18BF00504A12 /* APIRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439F2C782C2C18BF00504A12 /* APIRequest.swift */; };
439F2C7F2C2C242E00504A12 /* SILWifiSensorsHomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439F2C7D2C2C242E00504A12 /* SILWifiSensorsHomeView.swift */; };
439F2C852C2C243600504A12 /* SILSensorCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 439F2C802C2C243600504A12 /* SILSensorCell.swift */; };
Expand Down Expand Up @@ -1939,6 +1941,8 @@
4388B2D22C3047910068C950 /* SILWiFiMotionVcCh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SILWiFiMotionVcCh.swift; sourceTree = "<group>"; };
4388B2D42C305B0C0068C950 /* WiFiMotionDemoConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WiFiMotionDemoConnection.swift; sourceTree = "<group>"; };
4388B2E12C3FC9370068C950 /* SILAllWiFiSensorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SILAllWiFiSensorModel.swift; sourceTree = "<group>"; };
439B76112CA173D700B4E737 /* SILNetworkCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SILNetworkCheck.swift; sourceTree = "<group>"; };
439B76692CA4093F00B4E737 /* SILWifiSensorsHomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SILWifiSensorsHomeViewModel.swift; sourceTree = "<group>"; };
439F2C782C2C18BF00504A12 /* APIRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = APIRequest.swift; sourceTree = "<group>"; };
439F2C7D2C2C242E00504A12 /* SILWifiSensorsHomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SILWifiSensorsHomeView.swift; sourceTree = "<group>"; };
439F2C802C2C243600504A12 /* SILSensorCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SILSensorCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4489,6 +4493,7 @@
children = (
4388B2CC2C2DD9FE0068C950 /* SILWiFiLEDModel.swift */,
4388B2E12C3FC9370068C950 /* SILAllWiFiSensorModel.swift */,
439B76692CA4093F00B4E737 /* SILWifiSensorsHomeViewModel.swift */,
);
path = Model;
sourceTree = "<group>";
Expand All @@ -4514,6 +4519,7 @@
4388B2D02C30476E0068C950 /* SILWiFiMotionVC.swift */,
4388B2D22C3047910068C950 /* SILWiFiMotionVcCh.swift */,
4388B2D42C305B0C0068C950 /* WiFiMotionDemoConnection.swift */,
439B76112CA173D700B4E737 /* SILNetworkCheck.swift */,
);
path = Controller;
sourceTree = "<group>";
Expand Down Expand Up @@ -6284,6 +6290,7 @@
20513222270365A800C27B92 /* RoundCell.swift in Sources */,
0C2FCB1A1F9A542300F4F259 /* SILDebugDeviceTableViewCell.m in Sources */,
2051323B270365A800C27B92 /* DeviceSelectionInteraction.swift in Sources */,
439B76122CA173D700B4E737 /* SILNetworkCheck.swift in Sources */,
1EFC76D626AEE05C0035594E /* SILExitWarningViewModel.swift in Sources */,
1E4DB3B2266A720600405BD2 /* SILGattConfiguratorCharacteristicButtonCellView.swift in Sources */,
FE7B8FDF292E4FBD0075D894 /* SILIOPTestDeviceSelectorController.swift in Sources */,
Expand Down Expand Up @@ -6447,6 +6454,7 @@
0C2FCB3D1F9A542300F4F259 /* SILApp+AttributedProfiles.m in Sources */,
0C2FCB3E1F9A542300F4F259 /* SILOTAFirmwareFile.m in Sources */,
1E4DB342266A711700405BD2 /* SILBluetoothServiceDescriptorModel.swift in Sources */,
439B766A2CA4093F00B4E737 /* SILWifiSensorsHomeViewModel.swift in Sources */,
1E90F5E42473E73E0013AABD /* SILDebugServicesMenuViewController.swift in Sources */,
1EC1F1DB260CE95900508552 /* SILDiscoverFirmwareInfo.swift in Sources */,
72CA90002ABCBBD700FE70BA /* MatterHomeViewController.m in Sources */,
Expand Down Expand Up @@ -7221,7 +7229,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_RESOURCE_RULES_PATH = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 5;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 52444FG85C;
DISPLAY_NAME = "Si Connect";
Expand All @@ -7239,7 +7247,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.9.2;
MARKETING_VERSION = 2.9.3;
PRODUCT_BUNDLE_IDENTIFIER = com.silabs.BlueGeckoDemoApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -7263,7 +7271,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_RESOURCE_RULES_PATH = "";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 5;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 52444FG85C;
Expand All @@ -7281,7 +7289,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.9.2;
MARKETING_VERSION = 2.9.3;
PRODUCT_BUNDLE_IDENTIFIER = com.silabs.BlueGeckoDemoApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "BlueGeckoDemoApp Distribution";
Expand Down
1 change: 1 addition & 0 deletions SiliconLabsApp/SILAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SILAppDelegate : UIResponder, UIApplicationDelegate {
window?.makeKeyAndVisible()

setupLogs()

return true
}
private func setupLogs() {
Expand Down
11 changes: 10 additions & 1 deletion SiliconLabsApp/SupportingFiles/BlueGecko/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,21 @@
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<false/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth and Bluetooth Low Energy (BLE) to connect to and control your Silicon Labs devices.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app uses Bluetooth and Bluetooth Low Energy (BLE) to connect to and control your Silicon Labs devices.</string>
<key>NSBonjourServices</key>
<array>
<string>_lnp._tcp</string>
<string>_bonjour._tcp</string>
<string>_matter._tcp</string>
<string>_matterc._udp</string>
<string>_matterd._udp</string>
Expand All @@ -110,7 +119,7 @@
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location required for use of Retail Beacons.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Apple thinks the app accesses the user&apos;s photos but we don&apos;t know why.</string>
<string>Apple thinks the app accesses the user's photos but we don't know why.</string>
<key>UIAppFonts</key>
<array>
<string>Roboto-Black.ttf</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Foundation
import SVProgressHUD

@objcMembers
class SILAppSelectionViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, SILDeviceSelectionViewControllerDelegate, WYPopoverControllerDelegate, SILThunderboardDeviceSelectionViewControllerDelegate, SILWifiOTAConfigViewControllerDelegate {
class SILAppSelectionViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, SILDeviceSelectionViewControllerDelegate, WYPopoverControllerDelegate, SILThunderboardDeviceSelectionViewControllerDelegate, SILWifiOTAConfigViewControllerDelegate, SILWifiCommissioningViewControllerDelegate {



var appsArray: [SILApp] = SILApp.demoApps()
Expand All @@ -26,6 +27,11 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
private var disposeBag = SILObservableTokenBag()
private var peripheralManager: SILThroughputPeripheralManager!



private var viewModel: SILWifiCommissioningViewModel!


override func viewDidLoad() {
super.viewDidLoad()
self.setupAppCollectionView()
Expand Down Expand Up @@ -93,8 +99,7 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
let selectionViewController = SILDeviceSelectionViewController(deviceSelectionViewModel: viewModel!, shouldConnect: shouldConnect)
selectionViewController.centralManager = SILBrowserConnectionsViewModel.sharedInstance()!.centralManager!
selectionViewController.delegate = self
self.devicePopoverController = WYPopoverController.sil_presentCenterPopover(withContentViewController: selectionViewController, presenting: self,
delegate: self, animated: true)
self.devicePopoverController = WYPopoverController.sil_presentCenterPopover(withContentViewController: selectionViewController, presenting: self, delegate: self, animated: true)
}

private func presentThunderboardDeviceSelection(app: SILApp!, animated: Bool, filter: ((Device) -> Bool)? = nil) {
Expand Down Expand Up @@ -130,7 +135,7 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
private func moveToSILWifiSensorsDemoView() {
let storyBoard : UIStoryboard = UIStoryboard(name: "SILWifiSensors", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "SILWifiSensorsHomeView")
self.navigationController?.pushViewController(nextViewController, animated: true)
self.navigationController?.pushViewController(nextViewController, animated: false)
}

private func showWifiDisabledAlert() {
Expand Down Expand Up @@ -208,12 +213,18 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
showWiFiOTAScreen()
}
case .typeWifiSensor:
moveToSILWifiSensorsDemoView()
self.presentDeviceSelectionViewController(app: app, animated: true) { $0!.advertisedLocalName == "WIFI_SENSOR" }
//localNetworkCheck()
default:
return
}
}

// func localNetworkCheck() {
// let networkOb = SILNetworkCheck()
// networkOb.requestAuthorization { val in
// print(val)
// }
// }
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.appsArray.count
}
Expand Down Expand Up @@ -282,6 +293,7 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
if let wifiCommissioningController = UIStoryboard(name: "SILAppTypeWifiCommissioning", bundle: nil).instantiateInitialViewController() as? SILWifiCommissioningViewController {
wifiCommissioningController.centralManager = viewController.centralManager
wifiCommissioningController.connectedPeripheral = peripheral.peripheral
wifiCommissioningController.demoScreenName = "typeWifiCommissioning"
self.navigationController?.pushViewController(wifiCommissioningController, animated: true)
}

Expand All @@ -293,13 +305,27 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
peripheralDelegate: eslPeripheralDelegate)
self.navigationController?.pushViewController(eslDemoController, animated: true)
}
case .typeWifiSensor:
if let wifiCommissioningController = UIStoryboard(name: "SILAppTypeWifiCommissioning", bundle: nil).instantiateInitialViewController() as? SILWifiCommissioningViewController {
wifiCommissioningController.centralManager = viewController.centralManager
wifiCommissioningController.connectedPeripheral = peripheral.peripheral
wifiCommissioningController.demoScreenName = "typeWifiSensor"
wifiCommissioningController.delegateWifiCommissioning = self
self.navigationController?.pushViewController(wifiCommissioningController, animated: true)
}

default:
break
}
}
}


private func showBluetoothDisabledWarningTemp() {
let bluetoothDisabledAlert = SILBluetoothDisabledAlert.wifiCommissioning
self.alertWithOKButton(title: bluetoothDisabledAlert.title, message: bluetoothDisabledAlert.message) { _ in
self.navigationController?.popViewController(animated: true)
}
}
func didDismissDeviceSelectionViewController() {
if let peripheralManager = peripheralManager {
peripheralManager.stopAdvertising()
Expand Down Expand Up @@ -441,4 +467,11 @@ class SILAppSelectionViewController : UIViewController, UICollectionViewDataSour
self.navigationController?.pushViewController(demoViewController, animated: true)
}
}

// MARK: SILWifiCommissioningViewControllerDelegate
func onceDeviceIsConnect(isConnectedDevice: Bool) {
if isConnectedDevice {
moveToSILWifiSensorsDemoView()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,34 @@ struct ApiHTTPrequest {

}

struct URLForRequest {
var uri: String
func getUrl() -> String {
let ipArress = UserDefaults.standard.string(forKey: "access_point_IPA")
let Url = String(format: "http://\(ipArress ?? "")/\(uri)")
return Url
}

}

class APIRequest {
static let sharedInstance = APIRequest()

func postApiCall(parameterDictionary: String, url : String, completionBlock: @escaping (_ ReponsData: Data?, _ APIClientError:Error?) -> Void) {

let Url = String(format: "http://192.168.10.10/\(url)")
// let ipArress = UserDefaults.standard.string(forKey: "access_point_IPA")
// let Url = String(format: "http://\(ipArress ?? "")/\(url)")

let UrlRe = URLForRequest(uri: url)
let Url = UrlRe.getUrl()
print(Url)

//let Url = String(format: "http://192.168.10.10/\(url)")
guard let serviceUrl = URL(string: Url) else { return }
var request = URLRequest(url: serviceUrl)
request.httpMethod = HttpMethods.POST.rawValue
request.setValue("Application/json", forHTTPHeaderField: "Content-Type")
request.timeoutInterval = 10
request.timeoutInterval = 30
let parameters = parameterDictionary
let postData = parameters.data(using: .utf8)

Expand All @@ -51,12 +68,20 @@ class APIRequest {
}

func getApiCall(url : String, completionBlock: @escaping (_ ReponsData: Data?, _ APIClientError:Error?) -> Void) {
let Url = String(format: "http://192.168.10.10/\(url)")

// let ipArress = UserDefaults.standard.string(forKey: "access_point_IPA")
// let Url = String(format: "http://\(ipArress ?? "")/\(url)")
// print(Url)

let UrlRe = URLForRequest(uri: url)
let Url = UrlRe.getUrl()
print(Url)
//let Url = String(format: "http://192.168.10.10/\(url)")
guard let serviceUrl = URL(string: Url) else { return }
var request = URLRequest(url: serviceUrl)
request.httpMethod = HttpMethods.GET.rawValue
request.setValue("Application/json", forHTTPHeaderField: "Content-Type")
request.timeoutInterval = 10
request.timeoutInterval = 30
let session = URLSession.shared
session.dataTask(with: request) { (data, response, error) in
if let response = response {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// SILNetworkCheck.swift
// BlueGecko
//
// Created by SovanDas Maity on 23/09/24.
// Copyright © 2024 SiliconLabs. All rights reserved.
//

import UIKit
import Foundation
import Network


class SILNetworkCheck: NSObject {
private var browser: NWBrowser?
private var netService: NetService?
private var completion: ((Bool) -> Void)?

public func requestAuthorization(completion: @escaping (Bool) -> Void) {
self.completion = completion

// Create parameters, and allow browsing over peer-to-peer link.
let parameters = NWParameters()
parameters.includePeerToPeer = true

// Browse for a custom service type.
let browser = NWBrowser(for: .bonjour(type: "_bonjour._tcp", domain: nil), using: parameters)
self.browser = browser
browser.stateUpdateHandler = { newState in
switch newState {
case .failed(let error):
print(error.localizedDescription)
case .ready, .cancelled:
break
case let .waiting(error):
print("Local network permission has been denied: \(error)")
self.reset()
self.completion?(false)
default:
break
}
}

self.netService = NetService(domain: "local.", type:"_lnp._tcp.", name: "LocalNetworkPrivacy", port: 1100)
self.netService?.delegate = self

self.browser?.start(queue: .main)
self.netService?.publish()
}

private func reset() {
self.browser?.cancel()
self.browser = nil
self.netService?.stop()
self.netService = nil
}
}



@available(iOS 14.0, *)
extension SILNetworkCheck : NetServiceDelegate {
public func netServiceDidPublish(_ sender: NetService) {
self.reset()
print("Local network permission has been granted")
completion?(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class SILWiFiLEDViewController: UIViewController {
//blubImg.image = LedImage.ledOnImage
self.onBtn.backgroundColor = UIColor(named: "sil_boulderColor")
self.offBtn.backgroundColor = UIColor(named: "sil_boulderColor")
ledStatus()

//Comented: After BLE commissioning led status not to be check.
// ledStatus()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Expand Down
Loading

0 comments on commit 790fc8e

Please sign in to comment.