2

After app open, and Press ON BLE Device.

centralManagerDidUpdateState function is working.

    CBUUID *uuid = [CBUUID UUIDWithString:@"8A1FEA41-3A2F-7860-568D-2325D6C31C91"];
    NSArray *services = [NSArray arrayWithObjects:uuid, nil];
    NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
    [central scanForPeripheralsWithServices:services options:options];

Would not call to didDiscoverPeripheral: function.

-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI{
}

But if call nill value to scanForPeripheralsWithServices than will call to didDiscoverPeripheral: function.

[central scanForPeripheralsWithServices:nil options:options];

What is issue? Please.

Jamie Taylor
  • 4,709
  • 5
  • 44
  • 66
Nag Raja
  • 214
  • 2
  • 11
  • "Stupid" question: Is your peripheral advertising a service with this UUID (could be a annoying typo error) ? Note that it can have it, but not advertise it (check `advertisementData` in the `didDiscoverPeripheral` callback). – Larme Feb 17 '14 at 17:05
  • @Larme Can u show me example advertisementData? How to set it to didDiscoverPeripheral? – Nag Raja Feb 20 '14 at 11:53
  • Do `[central scanForPeripheralsWithServices:nil options:options];` in `-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI`, log the `advertisementData` given. – Larme Feb 20 '14 at 11:54
  • Showed Log in debug advertisementData kCBAdvDataChannel = 38; kCBAdvDataIsConnectable = 1; kCBAdvDataLocalName = Keyfobdemo; kCBAdvDataServiceUUIDs = ( "Unknown (<1803>)", "Unknown (<1802>)", "Unknown (<1804>)" ); i Cant see UUID. – Nag Raja Feb 20 '14 at 11:57
  • So it advertise that it has 3 services with UUID (1802, 1803 and 1804). With 4 hex characters, they are standards services. It does not advertise that it may have other services (custom or not, which are "hidden" unless you connect) Note that custom services need to have these 32 hex characters. So that's normal that your scan (with your NSArray of services) don't find anything. – Larme Feb 20 '14 at 12:01
  • from debug showed peripheral.UUID -> 8A1FEA41-3A2F-7860-568D-2325D6C31C91 .. isnot that UUID? – Nag Raja Feb 20 '14 at 12:06
  • Seems so. Where did you get that UUID by the way? Because, the method `scanForPeripheralsWithServices` need an *array of UUID of services*, not array of UUID of the peripheral. `UUID` mean *Universal Unique IDendifier*, it's used a lot and not only for services, but for peripheral also, etc. But keep in mind that only THIS peripheral will have this UUID, and an other (of the same type), not. So forget about this UUID to filter the way you want. – Larme Feb 20 '14 at 12:09
  • How we can to get 32 hex characters of serviceUDID? – Nag Raja Feb 20 '14 at 12:12
  • What are you trying to achieve, really? – Larme Feb 20 '14 at 12:13
  • 8A1FEA41-3A2F-7860-568D-2325D6C31C91 UDID cant call to centralManager: didDiscoverPeripheral: method – Nag Raja Feb 20 '14 at 12:21
  • That's normal, did you read the doc? didDiscoverPeripheral is a delegate method. – Larme Feb 20 '14 at 12:40
  • @Larme Yes i readied didDiscoverPeripheral delegate method. But not working it. I am not sure understand 80%. How to get serviceUDID? – Nag Raja Feb 21 '14 at 04:43
  • NSMultipleArray *arrayServiceID = [[NSMultipleArray allow] initWithObjects:[advertisementData objectForKey:@"kCBAdvDataServiceUUIDs"],nil]; it is added from didDiscoverPeripheral delegate right? – Nag Raja Feb 21 '14 at 04:45
  • @Larme serviceUUID is getting from advertisementData right? – Nag Raja Feb 21 '14 at 11:34
  • Yes, but as I said, if it does not advertise the service UUID that you want, you can't filter that way. Not advertising does not mean that it doesn't have it. It's like when you see someone, you may tell him/her your name (advertise), but you won't tell him your address, when you're not home, only if you're friend with him and want to invite him (that's when you connect to the peripheral and search for services). – Larme Feb 21 '14 at 11:36
  • @Larme ok i will try it – Nag Raja Feb 21 '14 at 12:05
  • `NSLog(@"advertisementData :%@",[advertisementData objectForKey:CBAdvertisementDataServiceUUIDsKey]);`
    Debug says **advertisementData :( "Unknown ()" )** is correct serviceUUID?
    – Nag Raja Feb 21 '14 at 12:21
  • YES, that's a normal Service UUID. – Larme Feb 21 '14 at 13:08
  • `[arrayBackgroundUUID addObject:[advertisementData objectForKey:CBAdvertisementDataServiceUUIDsKey]];` arrayBackgroundUUID is **NSMutableArray**. After added array than should to `[central scanForPeripheralsWithServices:arrayBackgroundUUID options:options]` right? – Nag Raja Feb 22 '14 at 08:25
  • Got Got background notification. happpppy thank. – Nag Raja Feb 22 '14 at 10:11
  • @Larme Background mode -> long discovery times too. Need faster. Is possible do it? – Nag Raja Feb 24 '14 at 07:33
  • possible duplicate of [didDiscoverPeripheral not been called after advertising another iOS device](http://stackoverflow.com/questions/26320578/diddiscoverperipheral-not-been-called-after-advertising-another-ios-device) – Paulw11 Oct 19 '14 at 19:32

0 Answers0