我試圖在我的應用程序中連接一個附件,而沒有在「設置 - >藍牙」中進行設置。如何使用BluetoothManager正確連接到附件?
我按照以下鏈接中的步驟操作:http://www.pocketmagic.net/2012/07/bluetooth-and-ios-use-bluetooth-in-your-iphone-apps/#.UTKqLKVvdha運行良好,直到我嘗試連接到附件時收到消息「失敗,出現錯誤305」。
這裏是我的步驟列表:
獲取
BluetoothManager
服務的處理程序和實例:btManager = [BluetoothManager sharedInstance];
註冊通知,藍牙無線電的變化(開/關)和用於發現新設備:
// setup bluetooth notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDiscovered:) name:@"BluetoothDeviceDiscoveredNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bluetoothAvailabilityChanged:) name:@"BluetoothAvailabilityChangedNotification" object:nil];
這裏的應用程序可以使用
BluetoothDevice
方法類似[btdev connect]
發現在- (void)deviceDiscovered:(NSNotification *) notification
連接到附件附件。在這裏,我收到消息
「與設備上的服務0x00001000的連接」附件「F0:B4:79:0B:68:45失敗,錯誤305」。
我嘗試其他方法,如[acceptSSP]
,[connectWithServices]
但它並沒有幫助。我必須先配對嗎?如果是這樣,我該怎麼做?