Skip to content

Commit

Permalink
Release 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilczajkasilabs committed Jan 12, 2021
1 parent ac1d1f8 commit e069e26
Show file tree
Hide file tree
Showing 165 changed files with 5,205 additions and 2,430 deletions.
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ SPEC CHECKSUMS:
ActionSheetPicker-3.0: eef157d75e151f255c5333d26656c7fbfe905a51
ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64
Charts: e0dd4cd8f257bccf98407b58183ddca8e8d5b578
Crashlytics: 07fb167b1694128c1c9a5a5cc319b0e9c3ca0933
Crashlytics: a33af323773f73904037dc2e684cd2f0d29f4fe2
Eddystone: a56b4cb97540f43617d6fc488a9ff75eab1d66a4
Fabric: f988e33c97f08930a413e08123064d2e5f68d655
Fabric: 09ef2d9b99b104702bede1acaf469fb8f20a9146
IP-UIKit-Wisdom: b395a065344071b33659e5f6b918043a97c48a44
KVOController: d72ace34afea42468329623b3379ab3cd1d286b6
MZTimerLabel: cd9bfb9304540ef2a9e163384fca9c978f0dbf83
Expand All @@ -90,4 +90,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 2c4307b5fdc69d190078ca339757cbf3833d671b

COCOAPODS: 1.8.4
COCOAPODS: 1.10.0
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ The app is divided into two main functional areas, the demo and the develop view
The demo view lists a number of demos that are meant for quickly testing some of the sample apps in the Silicon Labs Bluetooth SDK. The currently supported demos are:

- **Health Thermometer demo:** Connects to an EFR32/BGM device running the soc-thermometer sample application from the Bluetooth SDK and displays the temperature read from the SI7021 sensor on the WSTK mainboard.
- **Connect Lighting DMP demo:** Leverages the DMP sample apps to control a DMP light node from both a mobile app as well as the protocol specific switch node (Zigbee, proprietary) while keeping the light status in sync across all devices.
- **Range Test demo:** Allows visualizing the RSSI and other RF performance data on the mobile phone while running Range Test sample application on a pair of Silicon Labs radio boards.

The develop view contains functionalities focused on helping developers create and troubleshoot their Bluetooth applications based on EFR32/BGM devices. The currently supported functionalities are:

- **Bluetooth Browser:** This is a generic and powerful tool that allows you to explore the BLE devices around you. Key features of the browser include:
- Scan results with rich data set
- Scan and sort results with rich data set
- Connectable/non-connectable
- Beacon type
- Advertisement interval
Expand All @@ -37,7 +39,7 @@ The develop view contains functionalities focused on helping developers create a
- Over-the-air (OTA) device firmware upgrade (DFU) with both reliable and speed modes
- Configurable MTU and connection interval
- Support for all GATT operations
- **Bluetooth Advertiser**: Allows you to create multiple advertisement sets and enable them in parallel
- **Bluetooth Advertiser**: Allows you to create multiple advertisement sets and enable them in parallel
- Ability to manually start/stop advertisement, or stop based on time limit
- Support for multiple AD types

Expand Down
12 changes: 12 additions & 0 deletions SiliconLabsApp-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@
#import "SILBluetoothBitModel.h"
#import "SILBluetoothXMLParser.h"
#import "UIView+SILShadow.h"
#import "SILDeviceSelectionViewModel.h"
#import "SILDeviceSelectionViewController.h"
#import "SILCentralManagerBuilder.h"
#import "NSObject+SILAssociatedObject.h"
#import "SILDescriptorTableModel.h"
#import "SILSortOption.h"
#import "UIImage+SILImages.h"
#import "SILBrowserLogViewController.h"
#import "SILBrowserFilterViewController.h"
#import "SILBrowserConnectionsViewController.h"
#import "SILStoryboard+Constants.h"
#import "SILBrowserBeaconType.h"
242 changes: 190 additions & 52 deletions SiliconLabsApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

848 changes: 0 additions & 848 deletions SiliconLabsApp/Base.lproj/RangeTest/RangeTestStoryboard.storyboard

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions SiliconLabsApp/BluetoothControllers/SILAdvertiserService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SILAdvertiserService: NSObject, CBPeripheralManagerDelegate {
private let settings: SILAdvertiserSettings

let runningAdvertisers: SILObservable<[SILAdvertisingSetEntity]> = SILObservable(initialValue: [])
let blutoothEnabled: SILObservable<Bool> = SILObservable(initialValue: true)
private var runningAdvertisersMap: [String: SILRunningAdvertiser] = [:]

init(settings: SILAdvertiserSettings) {
Expand Down Expand Up @@ -72,6 +73,11 @@ class SILAdvertiserService: NSObject, CBPeripheralManagerDelegate {
}

if peripheral.state == CBManagerState.poweredOn {
if blutoothEnabled.value == false {
blutoothEnabled.value = true
print("Bluetooth enabled")
}

let advertiser = runningAdvertiser.advertiser
var advertisementData: [String: Any] = [:]

Expand Down Expand Up @@ -104,6 +110,10 @@ class SILAdvertiserService: NSObject, CBPeripheralManagerDelegate {
self.stop(advertiser: runningAdvertiser.advertiser)
})
}
} else if peripheral.state == CBManagerState.poweredOff {
blutoothEnabled.value = false
print("Bluetooth disabled")
stopAllAdvertisers()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// SILBluetoothDisabledAlert.swift
// BlueGecko
//
// Created by Kamil Czajka on 22.12.2020.
// Copyright © 2020 SiliconLabs. All rights reserved.
//

import Foundation

@objc
enum SILBluetoothDisabledAlert: Int {
case browser
case advertiser
case healthThermometer
case rangeTest
case connectedLighting

var title: String {
"Bluetooth Disabled"
}

var message: String {
let backMsg = "You will back to the home screen."
let turnOnMsg = "Turn on Bluetooth to"
switch self {
case .browser:
return "\(backMsg) \(turnOnMsg) using Browser."
case .advertiser:
return "\(turnOnMsg) start any Advertiser."
case .healthThermometer:
return "\(backMsg) \(turnOnMsg) using Health Thermometer."
case .rangeTest:
return "\(backMsg) \(turnOnMsg) using Range Test."
case .connectedLighting:
return "\(backMsg) \(turnOnMsg) using Connected Lighting."
}
}
}

@objc
class SILBluetoothDisabledAlertObjc: NSObject {
private let bluetoothDisabledAlert: SILBluetoothDisabledAlert

@objc init(bluetoothDisabledAlert: SILBluetoothDisabledAlert) {
self.bluetoothDisabledAlert = bluetoothDisabledAlert
}

@objc func getTitle() -> String {
return bluetoothDisabledAlert.title
}

@objc func getMessage() -> String {
return bluetoothDisabledAlert.message
}
}
1 change: 1 addition & 0 deletions SiliconLabsApp/BluetoothControllers/SILCentralManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
extern NSString * _Nonnull const SILCentralManagerDidConnectPeripheralNotification;
extern NSString * _Nonnull const SILCentralManagerDidDisconnectPeripheralNotification;
extern NSString * _Nonnull const SILCentralManagerDidFailToConnectPeripheralNotification;
extern NSString * _Nonnull const SILCentralManagerBluetoothDisabledNotification;

extern NSString * _Nonnull const SILCentralManagerDiscoveredPeripheralsKey;
extern NSString * _Nonnull const SILCentralManagerPeripheralKey;
Expand Down
20 changes: 19 additions & 1 deletion SiliconLabsApp/BluetoothControllers/SILCentralManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
NSString * const SILCentralManagerDidConnectPeripheralNotification = @"SILCentralManagerDidConnectPeripheralNotification";
NSString * const SILCentralManagerDidDisconnectPeripheralNotification = @"SILCentralManagerDidDisconnectPeripheralNotification";
NSString * const SILCentralManagerDidFailToConnectPeripheralNotification = @"SILCentralManagerDidFailToConnectPeripheralNotification";
NSString * const SILCentralManagerBluetoothDisabledNotification = @"SILCentralManagerBluetoothWasDisabledNotification";

NSString * const SILCentralManagerDiscoveredPeripheralsKey = @"SILCentralManagerDiscoveredPeripheralsKey";
NSString * const SILCentralManagerPeripheralKey = @"SILCentralManagerPeripheralKey";
Expand Down Expand Up @@ -313,9 +314,25 @@ - (void)stopScanning {
#pragma mark - CBCentralManagerDelegate

- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
[self checkBluetoothState:central.state];
[self toggleScanning];
}

- (void)checkBluetoothState:(CBManagerState)state {
if (state == CBManagerStatePoweredOff) {
[self postBluetoothWasDisabledNotification];
NSLog(@"BLUETOOTH DISABLED!");
} else if (state == CBManagerStatePoweredOn) {
NSLog(@"Blutooth enabled");
}
}

- (void)postBluetoothWasDisabledNotification {
[[NSNotificationCenter defaultCenter] postNotificationName:SILCentralManagerBluetoothDisabledNotification
object:self
userInfo:nil];
}

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
if (![self isProbablyIBeacon:advertisementData]) {
if (peripheral.identifier) {
Expand Down Expand Up @@ -462,10 +479,11 @@ - (void)postDeleteDisconnectedPeripheral:(CBPeripheral*)peripheral andError:(NSE
}

- (void)postFailedToConnectPeripheral:(CBPeripheral*)peripheral andError:(NSError*)error {
NSString* peripheralName = peripheral.name ?: @"N/A";
[[NSNotificationCenter defaultCenter] postNotificationName:SILNotificationFailedToConnectPeripheral
object:self
userInfo:@{
SILNotificationKeyPeripheralName: peripheral.name,
SILNotificationKeyPeripheralName: peripheralName,
SILNotificationKeyError: [NSString stringWithFormat:@"%ld", (long)error.code]
}];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@
- (void)updateWithIBeacon:(CLBeacon*)iBeacon andDiscoveringTimestamp:(double)timestamp;
- (NSString *)rssiDescription;
- (void)resetLastTimestampValue;
- (NSNumber *)rssiValue;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (instancetype)initWithPeripheral:(CBPeripheral *)peripheral
- (void)updateWithAdvertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI
andDiscoveringTimestamp:(double)timestamp {
self.advertisedLocalName = advertisementData[CBAdvertisementDataLocalNameKey];
self.advertisedLocalName = advertisementData[CBAdvertisementDataLocalNameKey] ?: self.peripheral.name;
self.advertisedServiceUUIDs = advertisementData[CBAdvertisementDataServiceUUIDsKey];
self.txPowerLevel = advertisementData[CBAdvertisementDataTxPowerLevelKey];
if (!self.isConnectable) {
Expand Down Expand Up @@ -206,4 +206,8 @@ - (NSString *)rssiDescription {
}
}

- (NSNumber *)rssiValue {
return self.RSSIMeasurementTable.lastRSSIMeasurement;
}

@end
20 changes: 20 additions & 0 deletions SiliconLabsApp/Categories/NSObject+SILAssociatedObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// NSObject+SILAssociatedObject.h
// BlueGecko
//
// Created by Michal Lenart on 03/12/2020.
// Copyright © 2020 SiliconLabs. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSObject(SILAssociatedObject)

- (nullable id)sil_associatedObject:(NSString*)key;
- (void)sil_setAssociatedObject:(nullable id)object forKey:(NSString*)key;

@end

NS_ASSUME_NONNULL_END
31 changes: 31 additions & 0 deletions SiliconLabsApp/Categories/NSObject+SILAssociatedObject.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// NSObject+SILAssociatedObject.m
// BlueGecko
//
// Created by Michal Lenart on 03/12/2020.
// Copyright © 2020 SiliconLabs. All rights reserved.
//

#import "NSObject+SILAssociatedObject.h"

static void* const kSILAssociatedObjectsKey = (void*)&kSILAssociatedObjectsKey;

@implementation NSObject(SILAssociatedObject)

- (nullable id)sil_associatedObject:(NSString*)key {
NSDictionary* objects = objc_getAssociatedObject(self, kSILAssociatedObjectsKey);
return [objects valueForKey:key];
}

- (void)sil_setAssociatedObject:(nullable id)object forKey:(NSString*)key {
NSMutableDictionary* objects = objc_getAssociatedObject(self, kSILAssociatedObjectsKey);

if (objects == nil) {
objects = [NSMutableDictionary dictionary];
objc_setAssociatedObject(self, kSILAssociatedObjectsKey, objects, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

[objects setValue:object forKey:key];
}

@end
1 change: 1 addition & 0 deletions SiliconLabsApp/Categories/SILStoryboard+Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern NSString * const SILSceneConnectedDevice;
extern NSString * const SILSceneFilter;
extern NSString * const SILSceneConnections;
extern NSString * const SILSceneLog;
extern NSString * const SILSceneSort;

extern NSString * const SILClassBrowserDeviceViewCell;
extern NSString * const SILClassBrowserServiceViewCell;
1 change: 1 addition & 0 deletions SiliconLabsApp/Categories/SILStoryboard+Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
NSString * const SILSceneFilter = @"Filter";
NSString * const SILSceneConnections = @"Connections";
NSString * const SILSceneLog = @"Log";
NSString * const SILSceneSort = @"Sort";

NSString * const SILClassBrowserDeviceViewCell = @"SILBrowserDeviceViewCell";
NSString * const SILClassBrowserServiceViewCell = @"SILBrowserServiceViewCell";
11 changes: 11 additions & 0 deletions SiliconLabsApp/Categories/UIImage+SILImages.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,14 @@ extern NSString * const SILImageExitView;

extern NSString * const SILImageChevronCollapsed;
extern NSString * const SILImageChevronExpanded;
extern NSString * const SILImageSortOn;
extern NSString * const SILImageSortOff;
extern NSString * const SILImageSortAscendingOff;
extern NSString * const SILImageSortAscendingOn;
extern NSString * const SILImageSortAZOff;
extern NSString * const SILImageSortAZOn;
extern NSString * const SILImageSortZAOff;
extern NSString * const SILImageSortZAOn;
extern NSString * const SILImageSortDescendingOff;
extern NSString * const SILImageSortDescendingOn;

13 changes: 12 additions & 1 deletion SiliconLabsApp/Categories/UIImage+SILImages.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
NSString * const SILImageNameHomeDebug = @"browser";
NSString * const SILImageNameHomeKitDebug = @"HomeKitDebug";
NSString * const SILImageNameHomeConnectedLighting = @"light";
NSString * const SILImageNameHomeRangeTestDemo = @"HomeRangeTestDemo";
NSString * const SILImageNameHomeRangeTestDemo = @"icon - demo - range_test";
NSString * const SILImageNameHomeAdvertiser = @"icon - advertiser";

NSString * const SILImageNameKeyboard = @"Keyboard";
Expand Down Expand Up @@ -91,3 +91,14 @@
NSString * const SILImageExitView = @"exitView";
NSString * const SILImageChevronCollapsed = @"chevron_collapsed";
NSString * const SILImageChevronExpanded = @"chevron_expanded";
NSString * const SILImageSortOn = @"icon - sort - on";
NSString * const SILImageSortOff = @"icon - sort - off";
NSString * const SILImageSortAscendingOff = @"icon - sort - ascending - off";
NSString * const SILImageSortAscendingOn = @"icon - sort - ascending - on";
NSString * const SILImageSortAZOff = @"icon - sort - AZ - off";
NSString * const SILImageSortAZOn = @"icon - sort - AZ - on";
NSString * const SILImageSortZAOff = @"icon - sort - ZA - off";
NSString * const SILImageSortZAOn = @"icon - sort - ZA - on";
NSString * const SILImageSortDescendingOff = @"icon - descending - off";
NSString * const SILImageSortDescendingOn = @"icon - descending - on";

22 changes: 22 additions & 0 deletions SiliconLabsApp/Categories/UIViewController+Alert.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// UIViewController+Alert.swift
// BlueGecko
//
// Created by Kamil Czajka on 22.12.2020.
// Copyright © 2020 SiliconLabs. All rights reserved.
//

import Foundation

@objc
extension UIViewController {
@objc func alertWithOKButton(title: String, message: String, completion: ((UIAlertAction) -> Void)? = nil) {
let alert = UIAlertController(title: title,
message: message,
preferredStyle: .alert)

let okButton = UIAlertAction(title: "OK", style: .default, handler: completion)
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)
}
}
28 changes: 28 additions & 0 deletions SiliconLabsApp/Categories/UIViewController+SILContext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// UIViewController+Context.swift
// BlueGecko
//
// Created by Michal Lenart on 03/12/2020.
// Copyright © 2020 SiliconLabs. All rights reserved.
//

import UIKit

extension UIViewController {
/// Provide any context down to the UIViewController tree. Context can be retrieved with sil_useContext method in any UIViewController descendant.
func sil_provideContext<T>(type: T.Type, value: T?) {
let key = String(describing: T.self)
self.sil_setAssociatedObject(value, forKey: key)
}

/// Get context with given type that was provider in any UIViewController ancestor.
func sil_useContext<T>(type: T.Type) -> T? {
let key = String(describing: T.self)

if let value = self.sil_associatedObject(key) as? T {
return value
} else {
return parent?.sil_useContext(type: type)
}
}
}
Loading

0 comments on commit e069e26

Please sign in to comment.