相关疑难解决方法(0)

如何获取可用蓝牙设备列表?

我目前正在创建一个可以使用蓝牙设备的iPhone应用程序(Xcode 4.3.1,IOS 5)!这个应用程序的主要目标是室内导航(建筑物内的GPS不是很准确).

我在这里看到的唯一解决方案(将我的应用程序保存在AppStore上)是尝试扫描可用的蓝牙设备!

我尝试使用CoreBluetooth框架,但我没有获得可用设备的列表!也许我没有正确使用这些功能

#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:
        { …
Run Code Online (Sandbox Code Playgroud)

bluetooth ios core-bluetooth

49
推荐指数
3
解决办法
8万
查看次数

标签 统计

bluetooth ×1

core-bluetooth ×1

ios ×1