Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ios/Classes/FlutterBluePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterEventChannel* stateChannel = [FlutterEventChannel eventChannelWithName:NAMESPACE @"/state" binaryMessenger:[registrar messenger]];
FlutterBluePlugin* instance = [[FlutterBluePlugin alloc] init];
instance.channel = channel;
instance.centralManager = [[CBCentralManager alloc] initWithDelegate:instance queue:nil];
instance.scannedPeripherals = [NSMutableDictionary new];
instance.servicesThatNeedDiscovered = [NSMutableArray new];
instance.characteristicsThatNeedDiscovered = [NSMutableArray new];
Expand All @@ -67,7 +66,12 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
NSNumber *logLevelIndex = [call arguments];
_logLevel = (LogLevel)[logLevelIndex integerValue];
result(nil);
} else if ([@"state" isEqualToString:call.method]) {
return;
}
if (self.centralManager == nil) {
self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
if ([@"state" isEqualToString:call.method]) {
FlutterStandardTypedData *data = [self toFlutterData:[self toBluetoothStateProto:self->_centralManager.state]];
result(data);
} else if([@"isAvailable" isEqualToString:call.method]) {
Expand Down
6 changes: 2 additions & 4 deletions lib/src/flutter_blue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ class FlutterBlue {
}

_setLogLevelIfAvailable() async {
if (await isAvailable) {
// Send the log level to the underlying platforms.
setLogLevel(logLevel);
}
// Send the log level to the underlying platforms.
setLogLevel(logLevel);
}

/// Starts a scan for Bluetooth Low Energy devices and returns a stream
Expand Down