Wie erhalte ich eine Liste der verfügbaren Bluetooth-Geräte?

Ich erstelle gerade eine iPhone-App (Xcode 4.3.1, IOS 5), die Bluetooth-Geräte verwenden kann! Hauptziel dieser Anwendung ist die Navigation in Innenräumen (GPS in Gebäuden ist nicht wirklich genau).

Die einzige Lösung, die ich hier sehe (um meine App im AppStore zu behalten), besteht darin, nach verfügbaren Bluetooth-Geräten zu suchen!

Ich habe versucht, das CoreBluetooth-Framework zu verwenden, aber ich erhalte keine Liste der verfügbaren Geräte! Vielleicht benutze ich diese Funktionen nicht richtig

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

Ich bin mir bei dieser Zeile nicht sicher, wie ich die richtigen Parameter übergeben soll.

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

Ich habe mir Apple Reference angesehen und verstehe immer noch nicht, was das für eine CBUUID ist ??? Jedes Gerät hat eine Bluetooth-ID? wo kann ich es finden?

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

Parameter serviceUUIDs - Ein Array von CBUUIDs, an denen die App interessiert ist. Options - Ein Wörterbuch zum Anpassen des Scans, siehe CBCentralManagerScanOptionAllowDuplicatesKey.

Gibt es eine andere Möglichkeit, Bluetooth unter IOS zu verwenden? Ich meine, ältere Frameworks, die BLE 4.0 nicht verwenden!

Jeder Rat wäre dankbar!

Vielen Dank!

Antworten auf die Frage(5)

Ihre Antwort auf die Frage