Jak uzyskać listę dostępnych urządzeń Bluetooth?

Obecnie tworzę aplikację na iPhone'a (Xcode 4.3.1, IOS 5), która może korzystać z urządzeń Bluetooth! Głównym celem tej aplikacji jest nawigacja w pomieszczeniach (GPS wewnątrz budynków nie jest naprawdę dokładny).

Jedynym rozwiązaniem, które widzę tutaj (aby zachować moją aplikację w AppStore), jest próba skanowania dostępnych urządzeń Bluetooth!

Próbowałem użyć framework CoreBluetooth, ale nie mam listy dostępnych urządzeń! Może nie korzystam z tych funkcji poprawnie

<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>

Nie jestem pewien co do tej linii, jak przekazać prawidłowe parametry?

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

Przyjrzałem się referencjom do jabłek ... i nadal nie rozumiem, co to jest CBUUID ??? Każde urządzenie ma jakiś identyfikator Bluetooth? gdzie mogę to znaleźć?

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

Parametry serviceUUIDs - Tablica CBUUIDs, którymi aplikacja jest zainteresowana. Opcje - słownik do dostosowania skanowania, patrz CBCentralManagerScanOptionAllowDuplicatesKey.

Czy istnieje inny sposób korzystania z Bluetooth w IOS? Mam na myśli starsze struktury, które nie używają BLE 4.0!

każda rada byłaby mile widziana!

dzięki!

questionAnswers(5)

yourAnswerToTheQuestion