samedi 29 novembre 2014

Null data with Core Bluetooth with iOS 8

I'm working for the first time with Core Bluetooth and iOS 8.1.1 and I'm having problems just in the first steps of Ray Wenderlich tutorial.


This is what I'm doing:



  • I create the centralManager > OK

  • centralManagerDidUpdateState is called with state CBCentralManagerStatePoweredOn > OK

  • I call scanForPeripheralsWithServices (I called this just after creating my central manager but my code didn't detect any devices. Here in several posts of Stackoverflow I read that with iOS 8 I had to call this after the PowerOn is received. Now it's ok) > OK

  • didDiscoverPeripheral is called but the Peripheral info read is "strange".


I'm launching this code in my iPod 5th generation with iOS 8.1.1. I'm trying to detect my MacBook Pro with OS X 10.9.4 and a Samsung Smart TV. My iPod Bluetooth settings detect my MacBook and my Samsung Smart TV without problems with their correct names. My MacBook Bluetooth settings detect my iPod and my Samsung Smart TV without problems with their correct names.


When I run my code this is my log in didDiscoverPeripheral:



<Warning>: PERIPHERAL DETECTED WITH
ID: <__NSConcreteUUID 0x16fca020> 81535702-93F4-69F7-EA61-E5FB28E364D8,
STATE: 0,
NAME: (null),
SERVICES: (null),
DESCRIPTION:
{
kCBAdvDataIsConnectable = 1;
kCBAdvDataServiceData =
{
"Device Information" = <0704>;
};
kCBAdvDataServiceUUIDs =
(
"ADAB3E70-6E7D-4601-BDA2-BFFAA68956BA"
);
}
<Warning>: PERIPHERAL DETECTED WITH
ID: <__NSConcreteUUID 0x16fdb7b0> 77124A38-7185-36F7-F587-FFB60D8478E7,
STATE: 0,
NAME: (null),
SERVICES: (null),
DESCRIPTION:
{
kCBAdvDataIsConnectable = 1;
}


I didn't receive any name. In detail, this is my code:



- (void)viewDidLoad
{
[super viewDidLoad];
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}

- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
if ([central state] == CBCentralManagerStatePoweredOn)
{
//NSArray *services = @[[CBUUID UUIDWithString:SERVICE_1_UUID]];
// By the moment I'm looking for all devices
NSDictionary *options = @{CBCentralManagerScanOptionAllowDuplicatesKey: @YES};
[_centralManager scanForPeripheralsWithServices:nil options:options];
}
}

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)periph advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
NSLog(@"PERIPHERAL DETECTED WITH ID: %@, STATE: %d, NAME: %@, SERVICES: %@, DESCRIPTION: %@",
[periph identifier],
[periph state],
[periph name],
[periph services],
[advertisementData description]);
NSString *name = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey];
if ([name length] > 0)
{
// I store all periphs detected, show them in a TableView so the user can select the one to connect.
}
}


So, is there any problem with my code and iOS 8? How could I get the information about the peripherals?




Aucun commentaire:

Enregistrer un commentaire