Re: BLE -peripheral:didDiscoverServices: never gets called
Re: BLE -peripheral:didDiscoverServices: never gets called
- Subject: Re: BLE -peripheral:didDiscoverServices: never gets called
- From: Carl Hoefs <email@hidden>
- Date: Tue, 23 Aug 2016 17:21:39 -0700
Of course, 1 minute after I press "Send" I discover I had forgotten to set the newly discovered peripheral's delegate. D'Oh!
Sorry for the noise!
-Carl
> On Aug 23, 2016, at 5:09 PM, Carl Hoefs <email@hidden> wrote:
>
> iOS 9.3.2
>
> I'm developing an app that interfaces to a (unencrypted) BLE arduino, but I'm having difficulty getting CoreBluetooth to issue the -peripheral:didDiscoverServices: callback. Thus I can't proceed to do a -writeValue: without a send_characteristic for the peripheral.
>
> Here are the (condensed) steps I'm taking, all of which work, except the last. The methods are all within the same controller object, which is adherent to both CBCentralManagerDelegate and CBPeripheralDelegate protocols:
>
> @interface BLEViewController : UIViewController <CBCentralManagerDelegate,CBPeripheralDelegate>
>
>
> (1) Start scanning
>
> -(void)centralManagerDidUpdateState:(CBCentralManager *)central
> {
> if ([central state] == CBCentralManagerStatePoweredOn) {
> [centralManager scanForPeripheralsWithServices:arrayOfCBUUIDs options:nil];
> }
> }
>
> // The above invokes the following:
>
> (2) Connect to the peripheral
>
> -(void)centralManager:(CBCentralManager *)central
> didDiscoverPeripheral:(CBPeripheral *)peripheral
> advertisementData:(NSDictionary *)advertisementData
> RSSI:(NSNumber *)RSSI
> {
> [centralManager stopScan];
> [centralManager connectPeripheral:peripheral options:nil];
> }
>
> // The above invokes the following:
>
> (3) Discover the peripheral's services
>
> -(void)centralManager:(CBCentralManager *)central
> didConnectPeripheral:(CBPeripheral *)peripheral
> {
> [peripheral discoverServices:nil];
> }
>
> // The above is *supposed to* invoke the following but never does:
>
> (4) Obtain the service.UUID
>
> -(void)peripheral:(CBPeripheral *)peripheral
> didDiscoverServices:(NSError *)error
> {
> NSLog(@"didDiscoverServices: %@", peripheral); // never invoked!
> }
>
> I've stepped through execution in the debugger, and all the objects are set and valid, including the centralManager.delegate.
>
> The BLE device works correctly with other apps, so I must have overlooked a step, but what?
>
> -Carl
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Bluetooth-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden