Skip to content

Commit

Permalink
Address iOS deprecation warnings & general warnings (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
peitschie committed Jul 13, 2024
1 parent bdd6f7e commit c77a0fd
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/ios/BLECentralPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ - (void)pluginInitialize {
stopNotificationCallbacks = [NSMutableDictionary new];
l2CapContexts = [NSMutableDictionary new];
bluetoothStates = [NSDictionary dictionaryWithObjectsAndKeys:
@"unknown", @(CBCentralManagerStateUnknown),
@"resetting", @(CBCentralManagerStateResetting),
@"unsupported", @(CBCentralManagerStateUnsupported),
@"unauthorized", @(CBCentralManagerStateUnauthorized),
@"off", @(CBCentralManagerStatePoweredOff),
@"on", @(CBCentralManagerStatePoweredOn),
@"unknown", @(CBManagerStateUnknown),
@"resetting", @(CBManagerStateResetting),
@"unsupported", @(CBManagerStateUnsupported),
@"unauthorized", @(CBManagerStateUnauthorized),
@"off", @(CBManagerStatePoweredOff),
@"on", @(CBManagerStatePoweredOn),
nil];
readRSSICallbacks = [NSMutableDictionary new];
}
Expand Down Expand Up @@ -353,14 +353,14 @@ - (void)stopNotification:(CDVInvokedUrlCommand*)command {

- (void)isEnabled:(CDVInvokedUrlCommand*)command {
CDVPluginResult *pluginResult = nil;
int bluetoothState = [manager state];
CBManagerState bluetoothState = [manager state];

BOOL enabled = bluetoothState == CBCentralManagerStatePoweredOn;
BOOL enabled = bluetoothState == CBManagerStatePoweredOn;

if (enabled) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:bluetoothState];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsNSInteger:bluetoothState];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
Expand Down Expand Up @@ -446,8 +446,8 @@ - (void)startStateNotifications:(CDVInvokedUrlCommand *)command {

if (stateCallbackId == nil) {
stateCallbackId = [command.callbackId copy];
int bluetoothState = [manager state];
NSString *state = [bluetoothStates objectForKey:[NSNumber numberWithInt:bluetoothState]];
CBManagerState bluetoothState = [manager state];
NSString *state = [bluetoothStates objectForKey:@(bluetoothState)];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:state];
[pluginResult setKeepCallbackAsBool:TRUE];
NSLog(@"Start state notifications on callback %@", stateCallbackId);
Expand Down Expand Up @@ -689,7 +689,7 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
NSLog(@"Status of CoreBluetooth central manager changed %ld %@", (long)central.state, [self centralManagerStateToString: central.state]);

if (central.state == CBCentralManagerStateUnsupported)
if (central.state == CBManagerStateUnsupported)
{
NSLog(@"=============================================================");
NSLog(@"WARNING: This hardware does not support Bluetooth Low Energy.");
Expand Down Expand Up @@ -1234,21 +1234,21 @@ -(void) cleanupOperationCallbacks: (CBPeripheral *)peripheral withResult:(CDVPlu

#pragma mark - util

- (NSString*) centralManagerStateToString: (int)state {
- (NSString*) centralManagerStateToString: (CBManagerState)state {
switch(state)
{
case CBCentralManagerStateUnknown:
return @"State unknown (CBCentralManagerStateUnknown)";
case CBCentralManagerStateResetting:
return @"State resetting (CBCentralManagerStateUnknown)";
case CBCentralManagerStateUnsupported:
return @"State BLE unsupported (CBCentralManagerStateResetting)";
case CBCentralManagerStateUnauthorized:
return @"State unauthorized (CBCentralManagerStateUnauthorized)";
case CBCentralManagerStatePoweredOff:
return @"State BLE powered off (CBCentralManagerStatePoweredOff)";
case CBCentralManagerStatePoweredOn:
return @"State powered up and ready (CBCentralManagerStatePoweredOn)";
case CBManagerStateUnknown:
return @"State unknown (CBManagerStateUnknown)";
case CBManagerStateResetting:
return @"State resetting (CBManagerStateUnknown)";
case CBManagerStateUnsupported:
return @"State BLE unsupported (CBManagerStateResetting)";
case CBManagerStateUnauthorized:
return @"State unauthorized (CBManagerStateUnauthorized)";
case CBManagerStatePoweredOff:
return @"State BLE powered off (CBManagerStatePoweredOff)";
case CBManagerStatePoweredOn:
return @"State powered up and ready (CBManagerStatePoweredOn)";
default:
return @"State unknown";
}
Expand Down

0 comments on commit c77a0fd

Please sign in to comment.