bluetooth, send and receive raw data

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
c22
Posts: 10
Joined: Tue Sep 29, 2020 8:03 pm

bluetooth, send and receive raw data

Post by c22 » Fri Oct 23, 2020 4:48 pm

Hi all.

Just bought a ESP-WROOM-32, immediately flashed Micropython and played a bit with it, very cool!

I'm really not a bluetooth expert, but I wrote in the past some client-server programs to communicate between PCs using pybluez and the serial-like RFCOMM protocol. I'm trying to do the same thing with my ESP32, especially configured as server.

I'm having a hard time finding examples about the usage of RFCOMM. RFCOMM isn't mandatory, but I'm looking for an easy way to send raw data between ESP32 and my PC, with the least possible troubles of advertising, pairing, connections, encryption and security. Any suggestion and/or examples?

Thanks a lot.

User avatar
jimmo
Posts: 2015
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: bluetooth, send and receive raw data

Post by jimmo » Sat Oct 24, 2020 4:50 am

c22 wrote:
Fri Oct 23, 2020 4:48 pm
I'm really not a bluetooth expert, but I wrote in the past some client-server programs to communicate between PCs using pybluez and the serial-like RFCOMM protocol. I'm trying to do the same thing with my ESP32, especially configured as server.

I'm having a hard time finding examples about the usage of RFCOMM. RFCOMM isn't mandatory, but I'm looking for an easy way to send raw data between ESP32 and my PC, with the least possible troubles of advertising, pairing, connections, encryption and security. Any suggestion and/or examples?
RFCOMM is a Bluetooth Classic profile. Although the ESP32 supports classic, MicroPython's bindings only support Bluetooth Low Energy.

There are two ways to achieve a similar result over BLE:
- Use the "Nordic UART Service", which is a way of doing streaming data over a pair of GATT characteristics. I wrote an example peripheral here -- https://github.com/micropython/micropyt ... ipheral.py -- and an example that dupterm's the REPL into it here -- https://github.com/micropython/micropyt ... rt_repl.py There are a few Android (and I imagine iOS too) apps that can connect to it. I use Adafruit's "Bluefruit Connect".
- BLE also supports opening an L2CAP "connection oriented channel". This is supported by Android 10+ and iOS 11+. This is much more like how RFCOMM works over classic, and essentially gives you something a bit like a socket. This is not currently supported by MicroPython but I am currently working on implementing it. Only tested on STM32 so far (can do ~30kiB/s pyboard-d to pyboard-d) but I need this for a project so will hopefully complete it soon.

c22
Posts: 10
Joined: Tue Sep 29, 2020 8:03 pm

Re: bluetooth, send and receive raw data

Post by c22 » Sat Oct 24, 2020 8:03 pm

I was expecting that Bluetooth LE was a just a low-power version on the regular bluetooth. Now I know it isn't :)

Thanks a lot!

Post Reply