Como obter lista de dispositivos Bluetooth disponíveis?

Atualmente estou criando um aplicativo para iPhone (Xcode 4.3.1, IOS 5) que poderia usar dispositivos Bluetooth! O principal objetivo desta aplicação é a navegação interna (GPS dentro de edifícios não é realmente preciso).

A única solução que vejo aqui (para manter meu aplicativo na AppStore) é tentar verificar os dispositivos bluetooth disponíveis!

Eu tentei usar o framework CoreBluetooth, mas não tenho lista de dispositivos disponíveis! Talvez eu não use essas funções corretamente

<code>#import <UIKit/UIKit.h>
#import <CoreBluetooth/CoreBluetooth.h>

@interface AboutBhyperView : UIViewController <CBPeripheralDelegate, CBCentralManagerDelegate>
{
    CBCentralManager *mgr;
}
@property (readwrite, nonatomic) CBCentralManager *mgr;
@end



- (void)viewDidLoad
{
    [super viewDidLoad];

    mgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}


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


    NSLog([NSString stringWithFormat:@"%@",[advertisementData description]]);
}

-(void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals{
    NSLog(@"This is it!");
}


- (void)centralManagerDidUpdateState:(CBCentralManager *)central{ 
    NSString *messtoshow;

    switch (central.state) {
        case CBCentralManagerStateUnknown:
        {
            messtoshow=[NSString stringWithFormat:@"State unknown, update imminent."];
            break;
        }
        case CBCentralManagerStateResetting:
        {
            messtoshow=[NSString stringWithFormat:@"The connection with the system service was momentarily lost, update imminent."];
            break;
        }
        case CBCentralManagerStateUnsupported:
        {
            messtoshow=[NSString stringWithFormat:@"The platform doesn't support Bluetooth Low Energy"];
            break;
        }
        case CBCentralManagerStateUnauthorized:
        {
            messtoshow=[NSString stringWithFormat:@"The app is not authorized to use Bluetooth Low Energy"];
            break;
        }
        case CBCentralManagerStatePoweredOff:
        {
            messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered off."];
            break;
        }
        case CBCentralManagerStatePoweredOn:
        {
            messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered on and available to use."];
            [mgr scanForPeripheralsWithServices:nil options:nil];
            //[mgr retrieveConnectedPeripherals];

//--- it works, I Do get in this area!

            break;
        }   

    }
    NSLog(messtoshow); 
} 
</code>

Não tenho certeza sobre esta linha, como passar parâmetros corretos?

<code>[mgr scanForPeripheralsWithServices:nil options:nil];
</code>

Eu dei uma olhada em referência de maçã .. e eu ainda não entendo o que é isso CBUUID ??? Todo dispositivo tem algum ID Bluetooth? Onde posso encontrá-lo?

<code>- (void)scanForPeripheralsWithServices:(NSArray *)serviceUUIDs options:(NSDictionary *)options;
</code>

Parâmetros serviceUUIDs - Uma matriz de CBUUIDs na qual o aplicativo está interessado. Options - Um dicionário para personalizar a verificação, consulte CBCentralManagerScanOptionAllowDuplicatesKey.

Existe alguma outra maneira de usar o Bluetooth no IOS? Quero dizer, frameworks mais antigos que não usam o BLE 4.0!

Qualquer conselho seria apreciado!

obrigado!

questionAnswers(5)

yourAnswerToTheQuestion