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 | |
| parent | f6d06421090f88094aba76b72b04d614f54efafa (diff) | |
| download | tangara-fw-4d99d22e10a3cb2a421da1618c127128816613c9.tar.gz | |
std::string -> std::pmr::string in psram
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/bluetooth.cpp | 12 | ||||
| -rw-r--r-- | src/drivers/include/bluetooth_types.hpp | 4 | ||||
| -rw-r--r-- | src/drivers/include/fatfs_audio_input.hpp | 2 | ||||
| -rw-r--r-- | src/drivers/storage.cpp | 3 | ||||
| -rw-r--r-- | src/drivers/test/test_storage.cpp | 8 |
5 files changed, 17 insertions, 12 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; { diff --git a/src/drivers/include/bluetooth_types.hpp b/src/drivers/include/bluetooth_types.hpp index 12ed5cb3..7e26f0d7 100644 --- a/src/drivers/include/bluetooth_types.hpp +++ b/src/drivers/include/bluetooth_types.hpp @@ -4,6 +4,8 @@ #include <array> #include <string> +#include "memory_resource.hpp" + namespace drivers { namespace bluetooth { @@ -11,7 +13,7 @@ typedef std::array<uint8_t, 6> mac_addr_t; struct Device { mac_addr_t address; - std::string name; + std::pmr::string name; uint32_t class_of_device; int8_t signal_strength; }; diff --git a/src/drivers/include/fatfs_audio_input.hpp b/src/drivers/include/fatfs_audio_input.hpp index e1f62811..705f6e7d 100644 --- a/src/drivers/include/fatfs_audio_input.hpp +++ b/src/drivers/include/fatfs_audio_input.hpp @@ -39,7 +39,7 @@ class FatfsAudioInput { std::shared_ptr<SdStorage> storage_; RingbufHandle_t output_; - std::string path_; + std::pmr::string path_; }; } // namespace drivers diff --git a/src/drivers/storage.cpp b/src/drivers/storage.cpp index 6acb6870..0492b5dc 100644 --- a/src/drivers/storage.cpp +++ b/src/drivers/storage.cpp @@ -24,6 +24,7 @@ #include "sdmmc_cmd.h" #include "gpios.hpp" +#include "memory_resource.hpp" static const char* kTag = "SDSTORAGE"; static const uint8_t kMaxOpenFiles = 8; @@ -74,7 +75,7 @@ auto SdStorage::Create(IGpios& gpio) -> cpp::result<SdStorage*, Error> { // Mount right now, not on first operation. FRESULT ferr = f_mount(fs, "", 1); if (ferr != FR_OK) { - std::string err_str; + std::pmr::string err_str; switch (ferr) { case FR_DISK_ERR: err_str = "FR_DISK_ERR"; diff --git a/src/drivers/test/test_storage.cpp b/src/drivers/test/test_storage.cpp index c785fa01..062de3af 100644 --- a/src/drivers/test/test_storage.cpp +++ b/src/drivers/test/test_storage.cpp @@ -22,9 +22,9 @@ namespace drivers { -static const std::string kTestFilename = "test"; -static const std::string kTestFilePath = - std::string(kStoragePath) + "/" + kTestFilename; +static const std::pmr::string kTestFilename = "test"; +static const std::pmr::string kTestFilePath = + std::pmr::string(kStoragePath) + "/" + kTestFilename; TEST_CASE("sd card storage", "[integration]") { I2CFixture i2c; @@ -46,7 +46,7 @@ TEST_CASE("sd card storage", "[integration]") { std::ifstream test_file; test_file.open(kTestFilePath.c_str()); - std::string line; + std::pmr::string line; REQUIRE(std::getline(test_file, line)); REQUIRE(line == "hello here is some test"); |
