Thursday 15 April 2010

Every time on scanning bluetooth devices gives CBCentralManagerStateUnknown? -


The first time I am using Core Bluetooth. Here is my implementation, there is no wrong thing in it.

  @ synthesis chief minister, active refill; - (id) Init {if ((self = [Super Init])) {CM = [[CBC Central Manager alloc] initWithDelegate: Self-quote: dispatch_get_main_queue ()]; } Healthy return; } - (zero) viewDidoadload [[Super Viewedload]; // Setup an additional after loading the view, usually from a nibb. } - (int) scanForPeripherals {if (! Self.CM.state = CBCentralManagerStatePoweredOn) {NSLog (@, [self centralManagerStateToString: self.CM.state] "is CoreBluetooth% s"); Return -1; } [Self.CM scanForPeripheralsWithServices: [NSArray arrayWithObject: [CBUUID UUIDWithString: @ "180D"]] options: @ {CBCentralManagerScanOptionAllowDuplicatesKey: @YES}]; Return 0; } - (Cons 4 *) Central ManagerStattoString: (Int) State (Switch) (State) {Case CBCAdministrationStateless: Unrecognized "State unknown (cb.tr.l.min.jeststat unknown)"; CBCentralManagerStateResetting Cases: Return "State Resetting (CBCentralManagerStateUnknown)"; Case CBCentralManagerStateUnsupported: return "state BLE unsupported (CBCentralManagerStateResetting)"; Case CBCentralManagerStateUnuthorized: "State Unauthorized Return (CBCentralManagerStateUnauthorized)"; Case CBSLM Newsstand Paid Off: "State Blade Operated Shut Down (CBC Central Administration Set Off Off)" Return; Case CBCNTRM AdministratorstoPoOn: "State-operated and Ready (CBC.InternetStatePoOnOn)" return; Default: Return "State unknown"; } Return "unknown state"; } - (zero) connect peripheral: (CBParyFerral *) Peripheral {printf ("Connecting with peripherals with UIID:% s \ r \ n", [UUIDTosting itself: peripheral .UUID]); Self.activePeripheral = peripheral; Self.activePeripheral.delegate = self; [Self.CM connectPeripheral: self.activePeripheral option: [NSDictionary dictionaryWithObject: [NSNumber numberWithBool: Yes] forKey: CBConnectPeripheralOptionNotifyOnDisconnectionKey]]; } - (Const char *) UUIDToString: (Sifuuaidiarf) Uuaidi (if (! Uuaidi) "tap" returns; CFStringRef s = CFUUIDCreateString (NULL, UUID); return CFStringGetCStringPtr (S, 0);} #pragma mark -kentrl Manager delegate method - (void) Union ManagerDidUpdateState: (CBCentralManager *) central {NSLog (@ "hit"); if (Sentrlstet! = Sibisiantrlmnejrstetpoidon) {return;} IsOn = yes;} - (void) centralManager: (CBCentralManager *) central DidDiscoverPeripheral: (CBPeripheral *) Peripheral advertisementData: (NSDictionary *) AdvertisementData RSSI: (NSNumber *) RSSI {NSLog (@ "Periferal Rep Appropriate to:% @ ", peripheral); Anselog (@" ed data:% @ ", Vigyapandeta) [Mbeepipradrshnacudi hide HUDForView: self.view animated: YES];} - (void) Central Manager (Sibisiantrl manager *) Central was Knektpiriferl: (Sibeepiriferl *) peripheral {Anselog (@ "connected peripherals% @", peripheral);} - centralManager (zero): (CBCentralManager *) central DidFailToConnectPeripheral: (CBPeripheral *) peripheral error: (NSError *) error { NSLog (@ "Error occurred:% @", [error localizedDescription]); } - (zero) did risiv memorialisation [[super daviditamammy warning]; // Any resource settlement which can be reproduced. } - (IBAction) ScanDiveVision: (ID) Sender {if (ION) {[MBP GrowthHUDUAUDUUD: Self. Annie animated: Yes]; [Self scanfairs]; }}   

This log returns every time

  Core Bluetooth state is unknown (CBCentralManagerStateUnknown)   

Updates

After the suggestion given by @Michael Dautermann to the question, I know that my centralManagerDidUpdateState representative method does not know why this is happening. I'm getting. If any reason Please do not let me know.

Core Bluetooth is just in the process of starting.

This representative method is required for you to hit first:

  - (zero) CentralManagerDidupdate: (CBC Central Manager *) Central;   

And once it happens, then you can start scanning for external devices.

No comments:

Post a Comment