• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CBPeripheralManager add/remove service several times
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CBPeripheralManager add/remove service several times


  • Subject: CBPeripheralManager add/remove service several times
  • From: Alpwise iOS Dev <email@hidden>
  • Date: Mon, 15 Apr 2013 10:26:34 +0200

Hi,

During the lifetime of my application, I add and remove several times a service but it seems that the number of creation/deletion is limited.

Here is my example (short version). I create a service, i add it in the data base and in the callback i delete it and re-add it, and so on...

@interface ViewController () <CBPeripheralManagerDelegate>
@property(strong,nonatomic) CBPeripheralManager *manager;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    _manager = [[CBPeripheralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)addService
{
    CBMutableCharacteristic *currentTimeCharacteristic = [[CBMutableCharacteristic alloc] initWithType:[CBUUID UUIDWithString:@"AAAA"]
                                                                                            properties:CBCharacteristicPropertyNotify+CBCharacteristicPropertyRead
                                                                                                 value:nil
                                                                                           permissions:CBAttributePermissionsReadable];
    CBMutableService *currentTimeService = [[CBMutableService alloc] initWithType:[CBUUID UUIDWithString:@"1111"] primary:YES];

    

    currentTimeService.characteristics = @[currentTimeCharacteristic];
    NSLog(@"add service request");
    [_manager addService:currentTimeService];
}

- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral
{
    if(peripheral.state == CBPeripheralManagerStatePoweredOn) {
        [self addService];
    }
}

- (void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(NSError *)error
{
    NSLog(@"did add service %@",[error localizedDescription]);
    [_manager removeAllServices];
    [self addService];
}


The output is :
2013-04-15 10:06:26.804 TestBug[1920:907] add service request
2013-04-15 10:06:26.819 TestBug[1920:907] did add service (null)
2013-04-15 10:06:26.821 TestBug[1920:907] add service request
2013-04-15 10:06:26.826 TestBug[1920:907] did add service (null)
2013-04-15 10:06:26.828 TestBug[1920:907] add service request
2013-04-15 10:06:26.833 TestBug[1920:907] did add service (null)
2013-04-15 10:06:26.836 TestBug[1920:907] add service request
2013-04-15 10:06:26.839 TestBug[1920:907] did add service (null)
2013-04-15 10:06:26.842 TestBug[1920:907] add service request
2013-04-15 10:06:26.845 TestBug[1920:907] did add service (null)
2013-04-15 10:06:26.847 TestBug[1920:907] add service request
2013-04-15 10:06:26.850 TestBug[1920:907] did add service (null)
2013-04-15 10:06:26.853 TestBug[1920:907] add service request

So, for the last (7th) add request the callback is never call.
It's a bug or a limitation from Apple? is there a known workaround?

Thanks,

Sam

 _______________________________________________
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

  • Follow-Ups:
    • Re: CBPeripheralManager add/remove service several times
      • From: Etan Kissling <email@hidden>
  • Prev by Date: Accessory with BT Module
  • Next by Date: Re: CBPeripheralManager add/remove service several times
  • Previous by thread: Accessory with BT Module
  • Next by thread: Re: CBPeripheralManager add/remove service several times
  • Index(es):
    • Date
    • Thread