iphone - Still can't get CoreBluetooth to work in a simple name discovery app -


i'm trying make simple application scan nearby bluetooth devices , list names discovered. i'm using corebluetooth in accordance every guide i've found, including apple's guide here

however, never works. put iphone 4s in discoverable mode next iphone 5 running app, , never discovers it. tried bluetooth-enabled car, don't know if has ble. doing wrong? here essence of code, in viewcontroller.m

- (void)viewdidload {     [super viewdidload];     [activity stopanimating]; isscanning = no; //activity gui activity wheel     centralmanager = [[cbcentralmanager alloc] initwithdelegate: self queue: nil]; }  - (void)centralmanagerdidupdatestate:(cbcentralmanager *)central{     int state = central.state;     [self log: [nsstring stringwithformat: @"cbcentralmanagerdidupdatestate: %d", state]]; //[self log] nslogs message , adds text view user see.     if (state!=cbcentralmanagerstatepoweredon){         [self log: @"error! bluetooth not powered on!"]; //i never error.     } }  - (void)centralmanager:(cbcentralmanager *)central diddiscoverperipheral:(cbperipheral *)peripheral advertisementdata:(nsdictionary *)advertisementdata rssi:(nsnumber *)rssi{     [self log: [nsstring stringwithformat: @"peripheral found corebluetooth: %@", peripheral.name]]; //and never see of these "peripheral found" messages. }  - (ibaction)scanbutton:(id)sender {     if (!isscanning){         [activity startanimating];         isscanning = yes;         [centralmanager scanforperipheralswithservices:nil options:nil];         [self log: @"scanning started."];     }     else{         [activity stopanimating];         isscanning = no;         [centralmanager stopscan];         [self log: @"scanning stopped."];     } } 

thanks suggestions.

i found answer here: can't seem core bluetooth work need ios device in peripheral mode or ble peripheral. annoying because no peripherals use ble.

it works brother's iphone 4s running free app app store called lightblue. app lets put device in peripheral mode... it's kind of developer put out nice testing app this.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -