Introduction
Looking around I couldn't find an easy and clear way to access Bluetooth in Mathematica, so I decided to create one.
What it can do
You can use the package for finding Bluetooth devices, discovering their names, creating sockets, connecting to devices, and sending/receiving information.
How it works
Since I wanted to kept it simple to make the task of adding new functionalities easy I used Python as an intermediary, so this is how it works:
​
Bluetooth.wl interacts with Bluetooth.py that interacts with the PyBluez library.
How to use it
◼
  • Note that errors in the evaluation of the cells are completely normal.
  • How to create a server

    port = 1​​​​​​​​session = StartExternalSession["Python"]​​ExternalEvaluate[session, File["path/to/Bluetooth.py"]]​​​​BluetoothSocketCreate[session, 1]​​BluetoothSocketBind[session, 1, port]​​​​BluetoothSocketListen[session, 1]​​​​BluetoothSocketAccept[session, 1, 2]​​​​data = ""​​While[data ≠ "b'close'", ​​ data = BluetoothSocketReceive[session, 2];​​ Print[data]​​]​​​​BluetoothSocketClose[session, 1]​​BluetoothSocketClose[session, 2]

    How to create a client

    session = StartExternalSession["Python"]​​ExternalEvaluate[session, File["path/to/Bluetooth.py"]]​​​​devices = BluetoothDiscoverDevices[session]​​device = BluetoothDiscoverDevices[session][[1]][[1]]​​​​port = 1​​​​BluetoothSocketCreate[session, 1]​​BluetoothSocketConnect[session, 1, device, port]​​​​BluetoothSocketSend[session, 1, "Hello World!"]​​​​BluetoothSocketClose[session, 1]

    Two other useful functions

    BluetoothAddressLookupName[session, address]​​BluetoothSocketGetAddress[session, socket]
    Last note
    Note that this won't work on Windows 10, however, the Bluetooth.py file is extremely short and you can easily integrate another library (like Bleak), this library was meant to work with GNU/Linux, so you can use it on your Raspberry or on a Linux PC.