Skip to content

Commit fa6dc34

Browse files
Release 2.0.3
1 parent 3f0a045 commit fa6dc34

File tree

169 files changed

+3050
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+3050
-862
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ xcuserdata/
6060
*.dSYM
6161

6262
# CocoaPods - Refactored to standalone file
63-
63+
Pods/*
6464

6565
# Carthage - Refactored to standalone file
6666

SiliconLabsApp-Bridging-Header.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
#import "UIColor+SILColors.h"
2121
#import "NSString+SILBrowserNotifications.h"
2222
#import "SILBluetoothBrowser+Constants.h"
23+
#import "SILAdvertisementDataModel.h"
24+
#import "SILBluetoothModelManager.h"

SiliconLabsApp.xcodeproj/project.pbxproj

Lines changed: 91 additions & 21 deletions
Large diffs are not rendered by default.

SiliconLabsApp/BluetoothControllers/SILCentralManager.m

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -378,31 +378,30 @@ - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(C
378378
[self removeUnfiredConnectionTimeoutTimer];
379379
[self handleConnectionFailureWithError:error];
380380
[self postRegisterLogNotification:[SILLogDataModel prepareLogDescription:@"didFailToConnectPeripheral: " andPeripheral:peripheral andError:error]];
381+
[self postFailedToConnectPeripheral:peripheral andError:error];
381382
}
382383

383384
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
384385
NSLog(@"didDisconnectPeripheral: %@", peripheral.name);
385386
NSLog(@"error: %@", error);
386-
if (self.connectedPeripheral && [self.connectedPeripheral isEqual:peripheral]) {
387-
self.connectedPeripheral = nil;
388-
389-
NSMutableDictionary *userInfo = nil;
390-
if(self.disconnectingPeripheral) {
391-
self.disconnectingPeripheral = nil;
392-
} else {
393-
userInfo = [NSMutableDictionary dictionary];
394-
userInfo[SILCentralManagerPeripheralKey] = peripheral;
395-
if (error) {
396-
userInfo[SILCentralManagerErrorKey] = error;
397-
}
398-
}
399-
400-
[[NSNotificationCenter defaultCenter] postNotificationName:SILCentralManagerDidDisconnectPeripheralNotification
401-
object:self
402-
userInfo:userInfo];
387+
388+
BOOL wasConnected = [self.connectionsViewModel isConnectedPeripheral:peripheral];
389+
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
390+
userInfo[SILCentralManagerPeripheralKey] = peripheral;
391+
userInfo[SILNotificationKeyUUID] = peripheral.identifier.UUIDString;
392+
if (error) {
393+
userInfo[SILCentralManagerErrorKey] = error;
403394
}
395+
396+
[[NSNotificationCenter defaultCenter] postNotificationName:SILCentralManagerDidDisconnectPeripheralNotification
397+
object:self
398+
userInfo:userInfo];
404399
[self postRegisterLogNotification:[SILLogDataModel prepareLogDescription:@"didDisconnectPeripheral: " andPeripheral:peripheral andError:error]];
405-
[self postDeleteDisconnectedPeripheral:peripheral];
400+
if (wasConnected) {
401+
[self postDeleteDisconnectedPeripheral:peripheral andError:error];
402+
} else {
403+
[self postFailedToConnectPeripheral:peripheral andError:error];
404+
}
406405
}
407406

408407
#pragma mark - Notifications
@@ -446,11 +445,29 @@ - (void)removeScanForPeripheralsObserver:(id)observer {
446445
}
447446

448447
- (void)postRegisterLogNotification:(NSString*)description {
449-
[[NSNotificationCenter defaultCenter] postNotificationName:SILNotificationRegisterLog object:self userInfo:@{ SILNotificationKeyDescription : description}];
448+
[[NSNotificationCenter defaultCenter] postNotificationName:SILNotificationRegisterLog
449+
object:self
450+
userInfo:@{
451+
SILNotificationKeyDescription : description
452+
}];
450453
}
451454

452-
- (void)postDeleteDisconnectedPeripheral:(CBPeripheral*)peripheral {
453-
[[NSNotificationCenter defaultCenter] postNotificationName:SILNotificationDeleteDisconnectedPeripheral object:self userInfo:@{ SILNotificationKeyUUID: peripheral.identifier.UUIDString}];
455+
- (void)postDeleteDisconnectedPeripheral:(CBPeripheral*)peripheral andError:(NSError*)error {
456+
[[NSNotificationCenter defaultCenter] postNotificationName:SILNotificationDeleteDisconnectedPeripheral
457+
object:self
458+
userInfo:@{
459+
SILNotificationKeyUUID: peripheral.identifier.UUIDString,
460+
SILNotificationKeyError: [NSString stringWithFormat:@"%ld", (long)error.code]
461+
}];
462+
}
463+
464+
- (void)postFailedToConnectPeripheral:(CBPeripheral*)peripheral andError:(NSError*)error {
465+
[[NSNotificationCenter defaultCenter] postNotificationName:SILNotificationFailedToConnectPeripheral
466+
object:self
467+
userInfo:@{
468+
SILNotificationKeyPeripheralName: peripheral.name,
469+
SILNotificationKeyError: [NSString stringWithFormat:@"%ld", (long)error.code]
470+
}];
454471
}
455472

456473
#pragma mark - CLLocationManagerDelegate

SiliconLabsApp/BluetoothControllers/SILDiscoveredPeripheral.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
@property (strong, nonatomic) CBPeripheral *peripheral;
2929
@property (strong, nonatomic) SILRSSIMeasurementTable *RSSIMeasurementTable;
3030
@property (strong, nonatomic) NSString *advertisedLocalName;
31-
@property (strong, nonatomic) NSArray *advertisedServiceUUIDs;
31+
@property (strong, nonatomic) NSArray<CBUUID*>* advertisedServiceUUIDs;
3232
@property (strong, nonatomic) NSNumber *txPowerLevel;
3333
@property (strong, nonatomic) NSData *manufacturerData;
34+
@property (strong, nonatomic) NSArray<CBUUID*>* solicitedServiceUUIDs;
35+
@property (strong, nonatomic) NSDictionary<CBUUID*, NSData*>* dataServiceData;
3436
@property (strong, nonatomic) SILBeacon* beacon;
3537
@property (nonatomic) BOOL isFavourite;
3638
@property double advertisingInterval;

SiliconLabsApp/BluetoothControllers/SILDiscoveredPeripheral.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ @implementation SILDiscoveredPeripheral
2424
NSString* const RSSIAppendingString = @" RSSI";
2525
NSString* const ConnectableDevice = @"Connectable";
2626
NSString* const NonConnectableDevice = @"Non-connectable";
27-
27+
NSString* const EddystoneService = @"FEAA";
2828
+ (NSString *)connectableDevice { return ConnectableDevice; }
2929
+ (NSString *)nonConnectableDevice { return NonConnectableDevice; }
3030

@@ -51,13 +51,15 @@ - (instancetype)initWithPeripheral:(CBPeripheral *)peripheral
5151
- (void)updateWithAdvertisementData:(NSDictionary *)advertisementData
5252
RSSI:(NSNumber *)RSSI
5353
andDiscoveringTimestamp:(double)timestamp {
54-
self.advertisedLocalName = advertisementData[CBAdvertisementDataLocalNameKey] ?: self.peripheral.name;
54+
self.advertisedLocalName = advertisementData[CBAdvertisementDataLocalNameKey];
5555
self.advertisedServiceUUIDs = advertisementData[CBAdvertisementDataServiceUUIDsKey];
5656
self.txPowerLevel = advertisementData[CBAdvertisementDataTxPowerLevelKey];
5757
if (!self.isConnectable) {
5858
self.isConnectable = [advertisementData[CBAdvertisementDataIsConnectable] boolValue];
5959
}
6060
self.manufacturerData = advertisementData[CBAdvertisementDataManufacturerDataKey];
61+
self.solicitedServiceUUIDs = advertisementData[CBAdvertisementDataSolicitedServiceUUIDsKey];
62+
self.dataServiceData = advertisementData[CBAdvertisementDataServiceDataKey];
6163
self.beacon = [self parseBeaconData:advertisementData];
6264
if ([self isCorrectAdvertisingPacket:timestamp]) {
6365
self.packetReceivedCount++;
@@ -112,6 +114,9 @@ - (SILBeacon*)parseBeaconData:(NSDictionary*)adverisement {
112114
if (error == nil) {
113115
return beacon;
114116
}
117+
} else if ([self hasEddystoneService]) {
118+
SILBeacon* eddystoneBeacon = [SILBeacon beaconWithEddystone:self.dataServiceData[[CBUUID UUIDWithString:EddystoneService]]];
119+
return eddystoneBeacon;
115120
}
116121

117122
SILBeacon* unknownBeacon = [[SILBeacon alloc] init];
@@ -180,6 +185,10 @@ - (BOOL)isRangeTest {
180185
return [self isContainService:SILServiceNumberRangeTest];
181186
}
182187

188+
- (BOOL)hasEddystoneService {
189+
return [self isContainService:EddystoneService];
190+
}
191+
183192
- (BOOL)isContainService:(NSString *)serviceUUID {
184193
CBUUID * const service = [CBUUID UUIDWithString:serviceUUID];
185194
return [self.advertisedServiceUUIDs containsObject:service];

SiliconLabsApp/Categories/CBService+Categories.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ - (BOOL)hasOTADataCharacteristic {
2727
}
2828

2929
- (CBCharacteristic *)otaDataCharacteristic {
30-
return [self characteristicForUUID:[SILUUIDProvider sharedProvider].otaCharacteristicDataUUID];
30+
return [self characteristicForUUID:[SILUUIDProvider sharedProvider].otaCharacteristicOTADataAttributeUUID];
3131
}
3232

3333
- (BOOL)hasOTAControlCharacteristic {
3434
return [self otaControlCharacteristic]!= nil;
3535
}
3636

3737
- (CBCharacteristic *)otaControlCharacteristic {
38-
return [self characteristicForUUID:[SILUUIDProvider sharedProvider].otaCharacteristicControlUUID];
38+
return [self characteristicForUUID:[SILUUIDProvider sharedProvider].otaCharacteristicOTAControlAttributeUUID];
3939
}
4040

4141
@end

SiliconLabsApp/Categories/NSString+SILBrowserNotifications.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ extern NSString * const SILNotificationReloadLogTableView;
2020
extern NSString * const SILNotificationDisconnectPeripheral;
2121
extern NSString * const SILNotificationDeleteDisconnectedPeripheral;
2222
extern NSString * const SILNotificationDisconnectAllPeripheral;
23+
extern NSString * const SILNotificationFailedToConnectPeripheral;
2324
extern NSString * const SILNotificationCellsForVisibleRows;
25+
extern NSString * const SILNotificationDisplayToastRequest;
26+
extern NSString * const SILNotificationDisplayToastResponse;
2427

2528
extern NSString * const SILNotificationKeyIndex;
2629
extern NSString * const SILNotificationKeyUUID;
2730
extern NSString * const SILNotificationKeyDescription;
31+
extern NSString * const SILNotificationKeyError;
32+
extern NSString * const SILNotificationKeyPeripheralName;

SiliconLabsApp/Categories/NSString+SILBrowserNotifications.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
NSString * const SILNotificationReloadLogTableView = @"ReloadLogTableView";
2020
NSString * const SILNotificationDisconnectPeripheral = @"DisconnectPeripheral";
2121
NSString * const SILNotificationDeleteDisconnectedPeripheral = @"DeleteDisconnectedPeripheral";
22+
NSString * const SILNotificationFailedToConnectPeripheral = @"FailedToConnectPeripheral";
2223
NSString * const SILNotificationDisconnectAllPeripheral = @"DisconnectAllPeripheral";
2324
NSString * const SILNotificationCellsForVisibleRows = @"CellsForVisibleRows";
25+
NSString * const SILNotificationDisplayToastRequest = @"DisplayToastRequest";
26+
NSString * const SILNotificationDisplayToastResponse = @"DisplayToastResponse";
2427

2528
NSString * const SILNotificationKeyIndex = @"index";
2629
NSString * const SILNotificationKeyUUID = @"uuid";
2730
NSString * const SILNotificationKeyDescription = @"description";
31+
NSString * const SILNotificationKeyError = @"error";
32+
NSString * const SILNotificationKeyPeripheralName = @"peripheralName";

SiliconLabsApp/Categories/UIImage+SILImages.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ extern NSString * const SILImageConnectOff;
7676
extern NSString * const SILImageConnectOn;
7777
extern NSString * const SILImageSearchOff;
7878
extern NSString * const SILImageSearchOn;
79+
extern NSString * const SILImageFilterOff;
80+
extern NSString * const SILImageFilterOffSelected;
81+
extern NSString * const SILImageFilterOn;
82+
extern NSString * const SILImageFilterOnSelected;
7983
extern NSString * const SILImageConnectable;
8084
extern NSString * const SILImageRSSI;
8185
extern NSString * const SILImageBeacon;

0 commit comments

Comments
 (0)