diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-04-15 14:53:41 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-04-15 14:53:41 +1000 |
| commit | 874218e3ff0ffd244936b3d56f1645efc3f9519f (patch) | |
| tree | be6f9cc544d3c6f91725471306e39ae66820a41d /src/drivers | |
| parent | 1baaa6dadcea5b8a85f1629e31119f4edba91b75 (diff) | |
| download | tangara-fw-874218e3ff0ffd244936b3d56f1645efc3f9519f.tar.gz | |
Fix some bt device issues
- Don't allow adjusting volume if there's no device
- Cap bt nvs values correctly
- Persist bt volumes correctly even when the encoded for has a null
byte (facepalm 4 me)
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/nvs.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp index 33d92a9f..fbdb5286 100644 --- a/src/drivers/nvs.cpp +++ b/src/drivers/nvs.cpp @@ -273,7 +273,7 @@ auto NvsStorage::BluetoothVolume(const bluetooth::mac_addr_t& mac) -> uint8_t { // Note we don't set the dirty flag here, even though it's an LRU cache, so // that we can avoid constantly re-writing this setting to flash when the // user hasn't actually been changing their volume. - return bt_volumes_.Get(mac).value_or(10); + return bt_volumes_.Get(mac).value_or(50); } auto NvsStorage::BluetoothVolume(const bluetooth::mac_addr_t& mac, uint8_t vol) @@ -405,7 +405,7 @@ class VolumesParseClient : public cppbor::ParseClient { std::copy(data.begin(), data.end(), mac_->begin()); } else if (item->type() == cppbor::UINT && state_ == State::kPair) { vol_ = - std::clamp<uint64_t>(item->asUint()->unsignedValue(), 0, UINT8_MAX); + std::clamp<uint64_t>(item->asUint()->unsignedValue(), 0, UINT16_MAX); } return this; } @@ -470,7 +470,7 @@ auto NvsStorage::writeBtVolumes() -> void { cppbor::Uint{vol->second}}); } std::string encoded = enc.toString(); - nvs_set_str(handle_, kKeyBluetoothVolumes, encoded.c_str()); + nvs_set_blob(handle_, kKeyBluetoothVolumes, encoded.data(), encoded.size()); } } // namespace drivers |
