获取蓝牙设备的列表是附近iPhone的SDK [英] Getting list of bluetooth devices nearby on iphone sdk

查看:321
本文介绍了获取蓝牙设备的列表是附近iPhone的SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够到附近搜索所有蓝牙设备,只是那里的ID。我并不需要进行配对的。我使用iPhone 2.3测试版。

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.

这是可能的L使用的GameKit都试过,没有运气没有人知道如何做到这一点。

Is this possible 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;
}

它死在[self.session setDataReceiveHandler:自withContext:无];

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

与下面的错误

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

然后
〜DNSServiceRegister回调:REF = 471fa40,旗帜= 2,错误类型= 0 NAME = 00rusor1A..iPhone模拟器regtype = _q1eu29voete9jf._udp。域=本地。

推荐答案

确实实施所需的方法

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

地方?否则,它是无法满足 -setDataReceiveHandler的需求:withContext:方法。另外,我不相信你可以在iPhone模拟器中访问蓝牙功能。

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.

总体来说,我不认为这会做你想要什么。的GameKit使用Bonjour发现检测其他的iPhone / iPod touch上运行的本地蓝牙网络中类似的游戏会话。它不会检测到附近的所有蓝牙设备。您可以使用较低级别的Bonjour发现自己找到那些通过WiFi或蓝牙网络访问的卓悦的所有设备,但蓝牙接入本身是从你抽象出来。

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.

这篇关于获取蓝牙设备的列表是附近iPhone的SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆