Thursday, July 13, 2017

Make my python's Bluetooth server visible to iOS

Leave a Comment

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

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment