Skip to content

BluetoothSerial / esp_bt_mem_release / memory consumption in arduino api #6451

Closed
@ferbar

Description

@ferbar

Related area

BT, BluetoothSerial

Hardware specification

any

Is your feature request related to a problem?

Using BluetoothSerial is taking about 140kB ram of the ESP32. That could be reduced by recompiling the arduino esp idf with a reduced set of options or by using esp_bt_mem_release(BTLE) for example if bluetooth LE isn't required. Since recompiling takes a lot of time I would suggest some options in the ESP32 arduino sdk.

Describe the solution you'd like

When btInUse() is returning true about 70kB ram are in use since boot. When btStart() is called additional 70kB are required. If BluetoothSerial is used, I don't think that BTLE will be used in general, so I suggest an option to BluetoothSerial or BluetoothSerial::begin to disable BTLE and BluetoothSerial::end to disable BT in general (and call esp_bt_mem_release())

a) btStart() has to be changed because of
esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
.mode = ESP_BT_MODE_CLASSIC_BT,

b) esp_bt_mem_release() has to be called before esp_bt_controller_init() and after BluetoothSerial::end()

I already have those modifications and would file a PR when #6380 is merged.
@me-no-dev: what do you think about

  • add a btStartMode(BT_classic / BTLE / DM) -> releases BTLE or BT_classic ram if not used
  • add a btStop_memrelease() -> which frees every BT ram
  • Is there any reason why esp32-hal-bt.c is a .c, not .cpp file (I'm asking because overloading those functions would be more convinient)
  • everything could be done in BluetoothSerial.cpp, however I think esp32-hal-bt.h: btStart() / btStop is be the right place.

Thanks!

Describe alternatives you've considered

No response

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions