开发者

Getting list of bluetooth devices nearby on iphone sdk

I need to be able to search for all bluetooth devices nearby and just get there ids. I don't need to pair at all. I am using iphone 2.3 beta.

Is this possib开发者_高级运维le l have tried using GameKit and no luck does anyone know how to do this.

 BOOL result = NO;
if (!session) {
    session = [[GKSession alloc] initWithSessionID:@"SCANNER" 
                                        displayName:nil 
                                        sessionMode:GKSessionModePeer];
    self.session.delegate = self;
    [self.session setDataReceiveHandler:self withContext:nil];
    self.session.available = YES;
    result = YES;
}

it dies on [self.session setDataReceiveHandler:self withContext:nil];

with the following error

Scanner[42754:207] Error: 30500 -- Invalid parameter for -setDataReceiveHandler:withContext:.

then ~ DNSServiceRegister callback: Ref=471fa40, Flags=2, ErrorType=0 name=00rusor1A..iPhone Simulator regtype=_q1eu29voete9jf._udp. domain=local.


Does self implement the required method

- (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context;

somewhere? Otherwise, it is unable to satisfy the needs of the -setDataReceiveHandler:withContext: method. Also, I don't believe you can access Bluetooth functions from within the iPhone Simulator.

Overall, I don't think this will do what you want. GameKit uses Bonjour discovery to detect other iPhones / iPod touches running similar game sessions within a local Bluetooth network. It will not detect all Bluetooth devices in the vicinity. You can use lower-level Bonjour discovery yourself to find all Bonjour devices that are network-accessible via WiFi or Bluetooth, but Bluetooth access itself is abstracted away from you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜