Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make my python's Bluetooth server visible to iOS

I've been struggling to connect a Bluetooth server (using Bluez or similar) in a Python script which runs on a Linux service, with an iPhone device which runs a Cordova hybrid app.

I'm using cordova-plugin-ble-central for the latter, and for the former I give you the code below:

try:
    server_sock = BluetoothSocket(RFCOMM)

    server_sock.bind(("", 0))
    server_sock.listen(1)
    port = server_sock.getsockname()[1]

    uuid = "d507688e-5fa7-11e7-907b-a6006ad3dba0"
    advertise_service(server_sock, "TestService", service_id=uuid, service_classes=[uuid])

    print("Waiting for connection on RFCOMM channel %d" % port)

    client_sock, address = server_sock.accept()
    print "Accepted connection from ", address

    data = client_sock.recv(1024)
    print "received [%s]" % data

    client_sock.close()
    server_sock.close()
except Exception as e:
    print 'ERROR: ' + str(e)

The issue is that a "scan()" function result from the iPhone gives me several devices nearby, but not mine...in Android it works great off course!

What am I missing? Is there a way to make it discover-able?

Thanks in advance

like image 488
DanielY Avatar asked Jul 03 '17 08:07

DanielY


1 Answers

You cannot.

iOS filter the Bluetooth profiles, and the RFCOMM (aka Bluetooth Serial Port Profile) is not supported. Here is the list of the iOS Supported Bluetooth profiles from Apple itself.

And yes, it's a shame, we know that's working perfectly on Desktop and Android, but you can't do the same on iOS :)

like image 168
tito Avatar answered Oct 06 '22 23:10

tito