2017-01-06 7 views
0

iOS iPhone을 Bluetooth 주변 장치로 설정하려고 했으므로 다른 iDevice에서 Bluetooth 장치를보고 정보를 보낼 수있었습니다.CoreBluetooth 광고하지만 다른 장치에서 볼 수 없음

나는 광고하고 있다고 생각하지만 다른 iPhone, iPad 또는 Mac에서 볼 수는 없습니다. 콘솔 출력은 그것이 광고하고있는 것을 제안합니까? 나는 명백한 무엇인가 놓치고 있냐? (나는 주변에서 둘러 보았다. Googled and here) 운이 없다.

콘솔 :

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를 스캔하고 있습니까?

그런데 사용 사례에 따라 모든 블루투스 상호 작용을 처리 할 수있는 다른 SDK를 확인하고 싶을 수 있습니다. 예 : MultipeerConnectivity, p2pkit, 가까운 Google.

면책 조항 : 나는 p2pkit

0

내가 초보자 너무 많이했다 방법 BLE 일을 이해하지 못했다을 개발 한 팀에서 작업 . 이제는 올바른 서비스 등을 광고해야한다는 것을 알게되고 다른 장치가 구독하게됩니다.

나는 처음에 내 iPhone의 블루투스 페어링 화면에서 볼 것으로 예상됩니다.

감사합니다.

0

기기의 블루투스 목록에 자신의 광고 장치가 표시되지 않습니다.