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)
}
}
광고 장치를 어떻게 보려고하십니까? LightBlue와 같은 자신의 코드 또는 앱을 사용하고 있습니까? – Paulw11
지금은 이해할 수 있습니다. BLE이므로 내 광고를 청취 할 다른 장치가 필요합니다. 따라서 표준 Bluetooth 장치에는 나타나지 않습니다. 아마이 질문을 삭제해야합니다! – J0hnnieMac