esp32p4 ble client with esp_hosted
esp32p4 ble client with esp_hosted
Hi people, recently bought myself ESP32P4 evolution board kit, figured out the Wi-Fi, LVGL, but I can not understand how to deal with BLE, I use the stack NimBle. In the Internet did not find normal examples for creating a client, because my task is to connect to a device (server) and periodically receive data. I tried to use GATT, but due to, probably, misunderstanding, I didn't understand where to move further. Unfortunately, I can't attach the code, because I don't have it. The task is to create a ble client on esp32p4 with esp32c6 via SDIO connected. Help who can, I will be very grateful!!!

Last edited by sign25893 on Tue May 20, 2025 6:06 am, edited 1 time in total.
-
yogesh.mantri
- Espressif staff

- Posts: 5
- Joined: Fri Jun 26, 2020 4:57 pm
Re: esp32p4 ble client with esp_hosted
Hello @ sign25893,
Would it possible for you to raise a query on ESP-Hosted-MCU repo for this?
Repo: https://github.com/espressif/esp-hosted-mcu/issues
Would it possible for you to raise a query on ESP-Hosted-MCU repo for this?
Repo: https://github.com/espressif/esp-hosted-mcu/issues
Re: esp32p4 ble client with esp_hosted
Hi,
using ble on P4 with hosted should be fairly easy.
When you want to use nimble as the stack it should work out of the box, with no extra code, as far as i remember.
Recently esp_hosted has been updated and you can use bluedroid stack. In this case some extra code is required, just few lines, and some bledroid init code has to be removed, but the whole process is really easy.
Personally i like to use this library as component to work with nimble and esp-idf and it should be updated to work on P4 already:
https://github.com/h2zero/esp-nimble-cpp
You can pick any example and it should works.
using ble on P4 with hosted should be fairly easy.
When you want to use nimble as the stack it should work out of the box, with no extra code, as far as i remember.
Recently esp_hosted has been updated and you can use bluedroid stack. In this case some extra code is required, just few lines, and some bledroid init code has to be removed, but the whole process is really easy.
Personally i like to use this library as component to work with nimble and esp-idf and it should be updated to work on P4 already:
https://github.com/h2zero/esp-nimble-cpp
You can pick any example and it should works.
Re: esp32p4 ble client with esp_hosted
Hi,
using ble on P4 with hosted should be fairly easy.
When you want to use nimble as the stack it should work out of the box, with no extra code, as far as i remember.
Recently esp_hosted has been updated and you can use bluedroid stack. In this case some extra code is required, just few lines, and some bledroid init code has to be removed, but the whole process is really easy.
Personally i like to use this library as component to work with nimble and esp-idf and it should be updated to work on P4 already:
https://github.com/h2zero/esp-nimble-cpp
You can pick any example and it should works.
Hello, chegewara.
With all due respect, I am new to this topic, last projects were done on Arduino IDE on esp32s3 from lilygo with a screen, so programming esp-idf is given on the best way.
I have played around and did not understand, how can I use this cpp library? There are examples there, but I still do not understand. My task is super dumb and simple, I need to connect to some device, it is also very primitive, by ble, and just receive data from it with different intervals, all UUID and mac addresses are known to me.
I will be very grateful for more detailed consideration of the problem. Regards, sign25893
Re: esp32p4 ble client with esp_hosted
Like i said, it is very easy to make P4 working with nimble.
With the library i mentioned earlier you just need some configs:
- example of sdkconfig.defaults
- idf_component.yml
- basic code, but you need to add some client or server code from library examples (this is just to run scan)
This is from my code i am running, just my code is running in addition and its working with esp32-s3 and esp32-p4 + C6:
- USB/ECM
- html server
- some other peripherals
With the library i mentioned earlier you just need some configs:
- example of sdkconfig.defaults
Code: Select all
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32p4"
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
# Override some defaults so BT stack is enabled
# in this example
#
# BT config
#
CONFIG_BT_CONTROLLER_DISABLED=y
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_TRANSPORT_UART=n
#
# Enable ESP Hosted BT
# Used as VHCI transport between BT Host and Controller
#
CONFIG_ESP_ENABLE_BT=y
CONFIG_ESP_WIFI_REMOTE_LIBRARY_HOSTED=y
CONFIG_ESP32_P4_EV_BOARD=y
CONFIG_IDF_TARGET="esp32p4"
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_ESP32_P4_EV_BOARD=y
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_NIMBLE_TRANSPORT_UART=n
CONFIG_HTTPD_MAX_REQ_HDR_LEN=800
CONFIG_HTTPD_WS_SUPPORT=y
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=n
CONFIG_ESP_WIFI_SLP_IRAM_OPT=n
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FREERTOS_HZ=1000
CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE=y
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y
Code: Select all
## IDF Component Manager Manifest File
dependencies:
espressif/esp_hosted:
version: "*"
rules:
- if: "target in [esp32p4]"
espressif/esp_wifi_remote:
version: "*"
rules:
- if: "target in [esp32p4]"
## Required IDF version
idf:
version: ">=4.1.0"
Code: Select all
NimBLEDevice::init("");
NimBLEDevice::setMTU(517);
pBLEScan = NimBLEDevice::getScan();
pBLEScan->setScanCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setDuplicateFilter(true);
pBLEScan->setInterval(1000);
pBLEScan->setWindow(500);
pBLEScan->setActiveScan(1);
pBLEScan->clearResults();
- USB/ECM
- html server
- some other peripherals
Who is online
Users browsing this forum: No registered users and 5 guests