Re: Core Bluetooth > CBPeripheralManager > addService: only works a limited number of times
I tried using the LightBlue app (BLExplr wasn't able to discover my service). LightBlue reported the service the first three times that I added the service (I tore down my peripheral and then re-created the service in between each check). After that, no more service detected. To tear down the service, I call: - (void) stopPeripheral { if ( self.peripheralManager ) { if ( self.peripheralManager.isAdvertising ) [ self.peripheralManager stopAdvertising ]; [ self.peripheralManager removeAllServices ]; // Seems to have no effect on this issue self.peripheralManager = NULL; } } ... look correct? Allan On 1/11/13 12:17 PM, "Etan Kissling" <kissling@oberon.ch> wrote:
Allan,
Try to use a generic client like the BLExplr app for 3$ to enumerate your peripheral app's services.
Do you find something special with such an app?
Normally, you should not run into issues with the service count.
Note that services can only be added while not advertising. Do you wait For advertising to stop before adding / removing services?
Etan
On 11.01.2013, at 20:32, "Allan Young" <allany@adobe.com> wrote:
In Apple's "BTLE Transfer" sample app, and in a test app that I created, I have observed that if the following is performed multiple times as the app is used:
addService startAdvertising stopAdvertising
or even:
addService startAdvertising stopAdvertising removeAllServices
Šthen at some point (after roughly 3-7 iterations of the above), I will no longer get a call to:
peripheralManager:didAddService:error:
Thus, I have to assume that the service has not been added.
To demonstrate this, using the "BTLE Transfer" sample app, add the following to BTLEPeripheralViewController.m:
- (void) peripheralManager: (CBPeripheralManager*) peripheral didAddService: (CBService*) service error: (NSError*) error; { NSLog( @"didAddService" ); }
Šthen, run the app on a device that supports CPPeripheralManager. In the UI, repeatedly perform these two steps: 1. Click "Peripheral" on the first screen 2. Click "Back" on the second screen
Observe in the console that "didAddService" gets logged for the first fews iterations of the above steps, but will eventually no longer appear:
2013-01-10 08:58:14.855 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:14.869 BTLE Transfer[3733:907] didAddService 2013-01-10 08:58:29.476 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:29.484 BTLE Transfer[3733:907] didAddService 2013-01-10 08:58:39.488 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:39.495 BTLE Transfer[3733:907] didAddService 2013-01-10 08:58:46.962 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:46.966 BTLE Transfer[3733:907] didAddService 2013-01-10 08:58:49.349 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:49.352 BTLE Transfer[3733:907] didAddService 2013-01-10 08:58:52.283 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:52.286 BTLE Transfer[3733:907] didAddService 2013-01-10 08:58:54.387 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 08:58:56.358 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 09:04:05.075 BTLE Transfer[3733:907] self.peripheralManager powered on. 2013-01-10 09:04:35.662 BTLE Transfer[3733:907] self.peripheralManager powered on.
Should I be able to perform addService as many times as I like?
_______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/bluetooth-dev/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com
participants (1)
-
Allan Young