Find common Bluetooth devices within reach

We use the iOS private framework BluetoothManager for a simple experiment - to find discovered universal (not iOS) BT devices within reach. Now only the following line returns devices:

for(BluetoothDevice* device in [[BluetoothManager sharedInstance] pairedDevices])

Unfortunately, it only returns devices that are already paired, which is not exactly what we want. Using connectingDevicesinstead pairedDevicesdoes not return any device at all. So, what parameters should we have in order to detect any Bluetooth device within reach? I don’t think I can use GameKit because I want to open non-iOS devices.

Any suggestions are welcome.

+4
source share
4 answers

, .

, :

[[BluetoothManager sharedInstance] setDeviceScanningEnabled:YES];

, BluetoothDeviceDiscoveredNotification. , NSNotification, , BluetoothDevice *.

, BluetoothManager -, NSMutableArray.

, , API.

+3

BluetoothManager, Bluetooth, Bluetooth- .

, . BluetoothDevice.

BluetoothDevice, , .

RSSI, , BluetoothDevice.h.

, iOS 5.1, : http://www.pocketmagic.net/?p=2827

!

+3

BluetoothManager, Game Kit, Bluetooth ( , , )

.

GKPeerPickerController

// create a session on each of your devices
GKSession *session = [[GKSession alloc] initWithSessionID:@"uniqueSessionID" displayName:@"deviceDisplayName" sessionMode:GKSessionModePeer
// set the delegate on the session
session.delegate = self;

,

- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state

, ,

GKPeerStateAvailable
-2
source

The GKSession class , which is part of the GameKit framework, is what you are looking for, as it provides the ability to discover and connect to nearby iOS devices using Bluetooth.

-2
source

All Articles