diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-09-26 13:36:07 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-09-26 13:36:07 +1000 |
| commit | 4d99d22e10a3cb2a421da1618c127128816613c9 (patch) | |
| tree | 527490a466348e5cf40cf10a8f3768aa5be4e7c1 /src/drivers/bluetooth.cpp | |
| parent | f6d06421090f88094aba76b72b04d614f54efafa (diff) | |
| download | tangara-fw-4d99d22e10a3cb2a421da1618c127128816613c9.tar.gz | |
std::string -> std::pmr::string in psram
Diffstat (limited to 'src/drivers/bluetooth.cpp')
| -rw-r--r-- | src/drivers/bluetooth.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/drivers/bluetooth.cpp b/src/drivers/bluetooth.cpp index 924cdf42..1d9d57df 100644 --- a/src/drivers/bluetooth.cpp +++ b/src/drivers/bluetooth.cpp @@ -7,6 +7,7 @@ #include <mutex> #include <ostream> #include <sstream> +#include <string> #include "bluetooth_types.hpp" #include "esp_a2dp_api.h" @@ -21,6 +22,7 @@ #include "esp_wifi.h" #include "esp_wifi_types.h" #include "freertos/portmacro.h" +#include "memory_resource.hpp" #include "nvs.hpp" #include "tinyfsm/include/tinyfsm.hpp" @@ -108,13 +110,13 @@ auto Bluetooth::SetEventHandler(std::function<void(bluetooth::Event)> cb) bluetooth::BluetoothState::event_handler(cb); } -auto DeviceName() -> std::string { +auto DeviceName() -> std::pmr::string { uint8_t mac[8]{0}; esp_efuse_mac_get_default(mac); std::ostringstream name; name << "TANGARA " << std::hex << static_cast<int>(mac[0]) << static_cast<int>(mac[1]); - return name.str(); + return std::pmr::string{name.str(), &memory::kSpiRamResource}; } namespace bluetooth { @@ -212,7 +214,7 @@ void Disabled::react(const events::Enable&) { esp_bt_gap_set_security_param(param_type, &iocap, sizeof(uint8_t)); // Set a reasonable name for the device. - std::string name = DeviceName(); + std::pmr::string name = DeviceName(); esp_bt_dev_set_device_name(name.c_str()); // Initialise GAP. This controls advertising our device, and scanning for @@ -307,8 +309,8 @@ auto Scanning::OnDeviceDiscovered(esp_bt_gap_cb_param_t* param) -> void { return; } - device.name = - std::string{reinterpret_cast<char*>(name), static_cast<size_t>(length)}; + device.name = std::pmr::string{reinterpret_cast<char*>(name), + static_cast<size_t>(length)}; bool is_preferred = false; { |
