Question

I need to send ASCII-codes via bluetooth to the third-party device. Hope it's possible to do with spp. I could be wrong in terminology. I don't know enough this programming area.

In centralManagerDidUpdateState I'm scanning for peripherals:

CBUUID *cbuuidService = [CBUUID UUIDWithString:@"0x1101"];
NSArray *service = @[ cbuuidService ];
NSDictionary *options = @{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES };
[central scanForPeripheralsWithServices:service options:options];

but didDiscoverPeripheral never called.

I tried to scan without services and it has the same effect.

What am I doing wrong? What cbuuid do I need and where can I find it? Thank for any help.

Was it helpful?

Solution

You need to have one device act as a central (which you do) and one as a peripheral device. So assuming that you use your MB Air as the central, you need to start a CBPeripheralManager on your iPad and have it publish and advertise a service. Then you should be able to discover it on your MB.

I guess the easiest way would be to get a working peripheral (e.g. a heart rate belt), so you can familiarize yourself with the usage of CBCentralManager. Then you could start implementing your own peripheral.

PS: I am not sure it is correct to put 0x at the beginning of the identifier.

OTHER TIPS

Believe CoreBluetooth is very hard to use.

Instead of working with that messy framework use LGBluetooth (It woks over CoreBluetooth).

    [[LGCentralManager sharedInstance] scanForPeripheralsByInterval:10
                                                         completion:^(NSArray *peripherals)
     {
     }];

here is a example of scanning by interval.

Check it out https://github.com/l0gg3r/LGBluetooth

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top