1616#import " SILWeakNotificationPair.h"
1717#import " SILConstants.h"
1818#import " NSString+SILBrowserNotifications.h"
19+ #import " BlueGecko-Swift.h"
1920#if ENABLE_HOMEKIT
2021#import < HomeKit/HomeKit.h>
2122#endif
@@ -58,7 +59,7 @@ @interface SILCentralManager ()
5859
5960@property (nonatomic , strong ) NSArray <CLBeaconRegion *> *regions;
6061@property (nonatomic , strong ) CLLocationManager *locationManager;
61-
62+ @property ( nonatomic , strong ) IOPLog *logObj;
6263@end
6364
6465@implementation SILCentralManager
@@ -73,6 +74,7 @@ - (instancetype)initWithServiceUUIDs:(NSArray *)serviceUUIDs {
7374 [self setupNotifications ];
7475 [self setupBeaconMonitoring ];
7576 self.connectionsViewModel = [SILBrowserConnectionsViewModel sharedInstance ];
77+ _logObj = [[IOPLog alloc ] init ];
7678 }
7779 return self;
7880}
@@ -124,9 +126,14 @@ - (void)setupNotifications {
124126- (void )applicationWillTerminateNotification : (NSNotification *)notification {
125127 if (self.connectedPeripheral ) {
126128 NSLog (@" Disconnected from connected peripheral" );
129+
130+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" Disconnected from connected peripheral: %@ " , self .connectedPeripheral]];
131+
127132 [self disconnectFromPeripheral: self .connectedPeripheral];
128133 } else if (self.connectingPeripheral ) {
129134 NSLog (@" Disconnect from connecting peripheral" );
135+
136+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" Disconnect from connecting peripheral: %@ " , self .connectingPeripheral]];
130137 [self disconnectFromPeripheral: self .connectingPeripheral];
131138 }
132139}
@@ -383,6 +390,8 @@ - (double)getTimestampWithAdvertisementData:(NSDictionary *)advertisementData {
383390
384391- (void )centralManager : (CBCentralManager *)central didConnectPeripheral : (CBPeripheral *)peripheral {
385392 NSLog (@" didConnectPeripheral: %@ " , peripheral);
393+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" didConnectPeripheral: %@ " , peripheral]];
394+
386395 [self removeUnfiredConnectionTimeoutTimer ];
387396 self.connectingPeripheral = nil ;
388397 self.connectedPeripheral = peripheral;
@@ -398,6 +407,11 @@ - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPerip
398407- (void )centralManager : (CBCentralManager *)central didFailToConnectPeripheral : (CBPeripheral *)peripheral error : (NSError *)error {
399408 NSLog (@" didFailToConnectPeripheral: %@ " , peripheral.name );
400409 NSLog (@" error: %@ " , error);
410+
411+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" didDisconnectPeripheral: %@ " , peripheral]];
412+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" didDisconnectPeripheral: %@ " , peripheral.name]];
413+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" error: %@ " , error]];
414+
401415 [self removeUnfiredConnectionTimeoutTimer ];
402416 [self handleConnectionFailureWithError: error];
403417 [self postRegisterLogNotification: [SILLogDataModel prepareLogDescription: @" didFailToConnectPeripheral: " andPeripheral: peripheral andError: error]];
@@ -408,14 +422,20 @@ - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPe
408422 NSLog (@" didDisconnectPeripheral: %@ " , peripheral.name );
409423 NSLog (@" error: %@ " , error);
410424
425+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" didDisconnectPeripheral: %@ " , peripheral]];
426+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" didDisconnectPeripheral: %@ " , peripheral.name]];
427+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" error: %@ " , error]];
428+
411429 BOOL wasConnected = [self .connectionsViewModel isConnectedPeripheral: peripheral];
412430 NSMutableDictionary *userInfo = [NSMutableDictionary dictionary ];
413431 userInfo[SILCentralManagerPeripheralKey] = peripheral;
414432 userInfo[SILNotificationKeyUUID] = peripheral.identifier .UUIDString ;
415433 if (error) {
416434 userInfo[SILCentralManagerErrorKey] = error;
417435 }
418-
436+
437+ [_logObj iopLogSwiftFunctionWithMessage: [NSString stringWithFormat: @" UserInfo: %@ " , userInfo]];
438+
419439 [[NSNotificationCenter defaultCenter ] postNotificationName: SILCentralManagerDidDisconnectPeripheralNotification
420440 object: self
421441 userInfo: userInfo];
0 commit comments