Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 SPP Support Merge Request #28

Open
BrianAtDocumentedDesigns opened this issue Sep 15, 2021 · 10 comments
Open

ESP32 SPP Support Merge Request #28

BrianAtDocumentedDesigns opened this issue Sep 15, 2021 · 10 comments
Labels
invalid This doesn't seem right

Comments

@BrianAtDocumentedDesigns

Kai
Thanks for writing this. I don't know how to contact you (I am pretty new to github, etc) but I cam across your code while looking for an example BLE application so I could add BLE to my little project.

My hardware is ESP32-C3 based and your code does not support ESP32 so I managed to port it over and got it working with the esp32_spp_server.cpp demo which espressif provides. (see https://github.com/BrianAtDocumentedDesigns/SimpleBluetoothLeTerminal/tree/ESP32_C3_SPP_Support).

I am pretty sure the ESP32 spp server does not implement flow control so I set

        writeCredits = Integer.MAX_VALUE;

as a sort of a kludge.

I know I am not much of a programmer but I thought I'd let you know in case you were interested in incorporating support for the popular ESP32 family into your code.

I will probably add flow control to the ESP32 code when I make some progress on my project.

Thanks again

Brian Piccioni
Documented Designs.

@kai-morich
Copy link
Owner

SPP is a protocol defined for bluetooth classic. For BLE there is no standard, but various vendors have predefined UUIDs for a serial like protocol. I couldn't find esp32_spp_server.cpp.

For ESP32 i know this variant https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/examples/BLE_uart/BLE_uart.ino which works with this app by simply changing UUIDs.

@kai-morich kai-morich added the invalid This doesn't seem right label Oct 19, 2021
@mrx23dot
Copy link

mrx23dot commented Jul 27, 2023

Please add ESP32 kind of BLE SPP, it would be very useful.

AT+BLESPPCFG?
+BLESPPCFG:0,0,0,0,1

+BLESPPCFG:<tx_service_index>,<tx_char_index>,<rx_service_index>,<rx_char_index>,<auto_conn>

• <tx_service_index>: tx service’s index. It can be fetched with command AT+BLEGATTCPRIMSRV=<conn_index> and AT+BLEGATTSSRV?.
• <tx_char_index>: tx characteristic’s index. It can be fetched with command AT+BLEGATTCCHAR=<conn_index>,<srv_index> and AT+BLEGATTSCHAR?.
• <rx_service_index>: rx service’s index. It can be fetched with command AT+BLEGATTCPRIMSRV=<conn_index> and AT+BLEGATTSSRV?.
• <rx_char_index>: rx characteristic’s index. It can be fetched with command AT+BLEGATTCCHAR=<conn_index>,<srv_index> and AT+BLEGATTSCHAR?.

I think this fully describes ESP32 server:
AT+BLEGATTSSRV?
+BLEGATTSSRV:<srv_index>,<start>,<srv_uuid>,<srv_type>
+BLEGATTSSRV:1,1,0xA002,primary service

+BLEGATTSSRV:2,1,0xA003,primary service


image
image

In Bluetooth LE client, the property of tx characteristic must be write with response or write without response, and the property of rx characteristic must be indicate or notify.
[ESP32-AT][v2.4.0.0]User-Guide.pdf
Hardcoding those 4numbers is better than nothing.

@kai-morich
Copy link
Owner

@mrx23dot
Copy link

mrx23dot commented Aug 8, 2023

wow, I manage to get it working with their default AT firmware.
It can send and receive in transparent mode.

Service 
    0000a002-0000-1000-8000-00805f9b34fb
Write 
    0000c304-0000-1000-8000-00805f9b34fb
Read 
    0000c306-0000-1000-8000-00805f9b34fb
    uses indicate method

could we add this as known profile? These don't change, I have tested on a 2nd different esp32.

On ESP32 side it requires ESP-AT SW and:

AT+BLEINIT=2
AT+BLEGATTSSRVCRE
AT+BLEGATTSSRVSTART
AT+BLEADDR?
AT+BLESPPCFG=1,1,7,1,5
AT+BLEADVSTART
//connect
AT+BLESPP
>hello

@thanhphongK19
Copy link

hi Kai-morich,
I am using esp32 with platform idf. I run gatt-server on esp32 and run your source app.
Your app display debug terminal: "discoverServices() - device: 48:55:19:BD:D7:A6 (My mac address)"
But my device can not connect with your app because it face to trouble "no serial profile found"

@mrx23dot
Copy link

Try the custom profile I wrote above, it works for me.

@thanhphongK19
Copy link

Sorry, but i don't understand. You can show me how you add custom profile in source code android. Thank

@mrx23dot
Copy link

There is an option in app's menu to add custom profiles, then you connect and it selects the profile.

Not in source code. But if you have access to that you could add it as built in profile for us, just search for other existing profiles.

@thanhphongK19
Copy link

Thank you

@Luxin812
Copy link

@mrx23dot
ESP-AT should have flow control function. You can set it by setting the AT+UART_CUR command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

5 participants