7

I've just found out that some Python code I've got working on Linux also needs to work on OSX.

For reliability reasons, on Linux I've been using a cludgy but effective approach to reading and writing characteristics on Bluetooth Low Energy devices. I've been simply spawning a subprocess that calls the gatttool command with the appropriate arguments and capturing the output. (None of the libraries that I tried would work reliably).

So now that I have to get it working on OSX, it would be wonderful to just use the same approach, but with a tool that works on OSX. Requirements for the tool are:

  • Read from an arbitrary bluetooth characteristic on an arbitrary device
  • Write to an arbitrary bluetooth characteristic on an arbitrary device

Is there such a tool for OSX? If not is there a way I can get gatttool working under OSX?

Thanks

  • I'm about to tackle the same problem, do you mind sharing how you got on with the posted solution? – slaw Mar 23 '18 at 4:45
1

GATT isn't exposed on macOS as easily as CoreBluetooth (which you can get to easily from the command line with swift or python and objective c bridging).

The pybluez code is very well commented and has good nuggets like:

See https://developer.apple.com/documentation/iobluetooth for Apple's IOBluetooth documentation.

See http://pyobjc.sourceforge.net for details on how to access Objective-C classes through PyObjC.

If those python examples don't work, then if you are a developer, I would start with the Additional Tools downloads for Xcode (latest beta version). If you're not a developer, then the free Xcode would be where I start to see how quickly you could get to GATT or see if the CoreBluetooth API are suitable for what you want to do.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .