2017-01-06 1 views
0

iOSのiPhoneをBluetooth周辺機器としてセットアップしようとしていたので、他のiDeviceからBluetoothデバイスを見て情報を送信することができました。CoreBluetooth広告は他のデバイスからは見えない

私は自分自身を広告していると思いますが、別のiPhone、iPad、またはMacのどこからでも見ることはできません。コンソールの出力はそれが広告であることを示唆していますか?私は明白な何かを見逃していますか?(私は周りを見回しました、グーグルで、ここにありますが)運はありません。

コンソール:

self.peripheralManager powered on. 
Service Added 
peripheralManagerDidStartAdvertising(_:error:) 
Advertising 

コード:私たちはBLE中央側にあなたのコードを参照してくださいする必要があり、より良いサポートについて

import UIKit 
import CoreBluetooth 
class ViewController: UIViewController,CBPeripheralManagerDelegate { 
    var peripheralManager:CBPeripheralManager! 
    var transferCharacteristic: CBMutableCharacteristic? 
    let MyP_Service_UUID = CBUUID(string: "1B981746-2064-4F68-BBB8-69A185314FC6") 
    let MyP_Characteristics_UUID = CBUUID(string: "4271CEC1-652D-489B-8484-7C3550C6075E") 
    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 
     self.peripheralManager = CBPeripheralManager(delegate: self, queue: nil) 
    } 
    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 
    override func viewDidDisappear(_ animated: Bool) { 
     super.viewDidDisappear(animated) 
     // Don't keep it going while we're not showing. 
     peripheralManager.stopAdvertising() 
    } 
    func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { 
     if (peripheral.state != .poweredOn) { 
      return 
     } 
     print("self.peripheralManager powered on.") 
     // ... so build our service. 
     let myCharacteristic = CBMutableCharacteristic(type: MyP_Characteristics_UUID, properties: [.notify], value: nil, permissions: .readable) 
     let myService = CBMutableService(type: MyP_Service_UUID, primary: true) 
     myService.characteristics?.append(myCharacteristic) 
     peripheralManager.add(myService) 
     peripheralManager.startAdvertising([ CBAdvertisementDataServiceUUIDsKey: [MyP_Service_UUID], CBAdvertisementDataLocalNameKey : "MyP"]) 
    } 

    func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: Error?) { 
     print(error ?? "Service Added") 
    } 
    func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { 
     print(#function) 
     print(error ?? "Advertising") 
    } 
    func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic) { 
     print(#function) 
    } 
    func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didUnsubscribeFrom characteristic: CBCharacteristic) { 
     print(#function) 
    } 
    func peripheralManagerIsReady(toUpdateSubscribers peripheral: CBPeripheralManager) { 
     print(#function) 
    } 

} 
+2

どのように広告装置を参照しようとしていますか?あなた自身のコードやLightBlueのようなアプリを使っていますか? – Paulw11

+0

今私はそれを理解していると思います。私はそれがBLEであるので、私の広告を聞いている別のデバイスが必要になります。したがって、標準のBluetoothデバイスには表示されません。おそらく私はこの質問を削除する必要があります! – J0hnnieMac

答えて

1

。あなたのスキャンデバイスで同じサービスUUIDをスキャンしていますか?

ところで、ユースケースに応じて、あなたのためのすべてのBluetoothの対話を処理できる他のSDKをチェックしたいと思うかもしれません。 例:MultipeerConnectivity、p2pkit、近くのGoogle。

免責事項:私はp2pkit

0

私は初心者のあまりだったとどのようにBLEの仕事を理解していなかったを開発しているチームで作業 。私は今、私は正しいサービスなどを宣伝する必要があることを見て、その後、他のデバイスが購読します。

私が最初に私のiPhoneのBluetoothのペアリング画面でそれを見ることが期待します。

ありがとう

0

自分のデバイスのBluetoothデバイスのリストに自分の広告デバイスが表示されません。

関連する問題