BLE SPP emulation on ESP32-S3

eriksl
Posts: 116
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

BLE SPP emulation on ESP32-S3

Postby eriksl » Tue Apr 23, 2024 11:37 am

Hi there,

I just found of the hard way that the S3 does only support BLE and no "classic" BT. It appears you can actually configure BT classic in menuconfig, but you'll get all sorts of weird errors, crashes etc. when running your app. I see some possibilities for improvement here :)

Anyway, what I want is, I think something very simple, but this way it is going to be complex I am afraid.

What I am after: a very simple communication channel, over BT (LE...) for me to send and receive arbitrary ascii strings from my Linux computer to/from the ESP32-S3. So the SPP would have been ideal, but won't work, as I just learned LE doesn't have a SPP profile...

In the examples there are sources for an SPP emulation using BlueDroid and using Nimble, fine, nice. The problem is need to interface with a Linux computer, not ESP32 <-> ESP32.

So how do I get a client on Linux than can do this? Anyone having something like this lying around? I understand that programming under Bluez (standard BE stack on Linux) is very cumbersome, so if at all possible, I'd like to avoid that.

Any hints are appreciated!

eriksl
Posts: 116
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

Re: BLE SPP emulation on ESP32-S3

Postby eriksl » Tue Apr 23, 2024 5:08 pm

Update:

I may get this working with some finding out, for now I have a different challenge:

- BLE "server" works, I can see the "SPP" service on my computer
- but I can't get the pairing working.

I want to have some sort of pairing using a sort of (simple) pre-shared key. The ESP32 has the key, the client must know to pair. I can't get it working. All the examples are only calling ble_gap_security_initiate when they're the client (peripheral?). How should a server (central?) do this?

Also I never see a BLE_GAP_EVENT_PASSKEY_ACTION event nor BLE_GAP_EVENT_ENC_CHANGE. I am at loss here.

I've tried lots of combinations in the ble_hs_cfg struct.

eriksl
Posts: 116
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

Re: BLE SPP emulation on ESP32-S3

Postby eriksl » Wed Apr 24, 2024 6:57 am

It's starting to work now. Apparently the "server" (accepting side) doesn't need to do an "ble_gap_security_initiate". And also the ESP32, even in "server" role, apparently needs to be addressed as a "peripheral" and not a "central". Having a closer look at the "bleprph" example, I got quite a bit working now (at least the pairing). Now still to do is some tweaking in the process.

I think, for the client (on the Linux side), it will be enough to open an L2CAP socket to a fixed channel ("SCN") completely bypassing the GATT, which makes it complex with Bluez. We'll see.

I must say the examples seem to be out-of-date here and there and also they're missing some bits and pieces, you can't just build/run them (at least the ones I tried).

Who is online

Users browsing this forum: Google [Bot] and 103 guests