Home:ALL Converter>Raspberry Pi Bluetooth not detecting in iOS Swift

Raspberry Pi Bluetooth not detecting in iOS Swift

Ask Time:2018-06-08T22:03:23         Author:user6298177

Json Formatter

I need to send data from my iPhone 5s to Raspberry Pi (Model B). But the problem is, Raspberry Pi bluetooth not discovering by program, But It is discovered and paired from iPhone default Bluetooth settings(screenshot attached).

Also, my iBeacons(Transmitter only) are programmatically discovered, but Raspberry Pi not.

How can I detect Raspberry Pi (Model B) bluetooth same as iPhone Bluetooth settings in Swift?

Tried Code:

import UIKit
import CoreBluetooth

class ViewController: UIViewController,CBCentralManagerDelegate {

    var centralManager:CBCentralManager!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.centralManager = CBCentralManager(delegate: self, queue: .main)



    }

    func centralManagerDidUpdateState(_ central: CBCentralManager) {

        switch central.state {

        case .poweredOn:

            print("Powerd On State  ")
            let options: [String: Any] = [CBCentralManagerScanOptionAllowDuplicatesKey:
                NSNumber(value: false)]
            self.centralManager.scanForPeripherals(withServices: nil, options: options)

        case .poweredOff:
            print("Power on the Bluetooth")
        default:
            print("Something went wrong!")
            break
        }
    }

    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {

        print("Peripheral Discovered: ",peripheral.name ?? "Nil")
    }

}

iPhone Bluetooth settings:

enter image description here

Regarding Console Output:

enter image description here

Author:user6298177,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762407/raspberry-pi-bluetooth-not-detecting-in-ios-swift
yy