nvs_handle_locked.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #include "nvs_handle_locked.hpp"
  14. namespace nvs {
  15. NVSHandleLocked::NVSHandleLocked(NVSHandleSimple *handle) : handle(handle) {
  16. Lock::init();
  17. }
  18. NVSHandleLocked::~NVSHandleLocked() {
  19. Lock lock;
  20. delete handle;
  21. }
  22. esp_err_t NVSHandleLocked::set_string(const char *key, const char* str) {
  23. Lock lock;
  24. return handle->set_string(key, str);
  25. }
  26. esp_err_t NVSHandleLocked::set_blob(const char *key, const void* blob, size_t len) {
  27. Lock lock;
  28. return handle->set_blob(key, blob, len);
  29. }
  30. esp_err_t NVSHandleLocked::get_string(const char *key, char* out_str, size_t len) {
  31. Lock lock;
  32. return handle->get_string(key, out_str, len);
  33. }
  34. esp_err_t NVSHandleLocked::get_blob(const char *key, void* out_blob, size_t len) {
  35. Lock lock;
  36. return handle->get_blob(key, out_blob, len);
  37. }
  38. esp_err_t NVSHandleLocked::get_item_size(ItemType datatype, const char *key, size_t &size) {
  39. Lock lock;
  40. return handle->get_item_size(datatype, key, size);
  41. }
  42. esp_err_t NVSHandleLocked::erase_item(const char* key) {
  43. Lock lock;
  44. return handle->erase_item(key);
  45. }
  46. esp_err_t NVSHandleLocked::erase_all() {
  47. Lock lock;
  48. return handle->erase_all();
  49. }
  50. esp_err_t NVSHandleLocked::commit() {
  51. Lock lock;
  52. return handle->commit();
  53. }
  54. esp_err_t NVSHandleLocked::get_used_entry_count(size_t& usedEntries) {
  55. Lock lock;
  56. return handle->get_used_entry_count(usedEntries);
  57. }
  58. esp_err_t NVSHandleLocked::set_typed_item(ItemType datatype, const char *key, const void* data, size_t dataSize) {
  59. Lock lock;
  60. return handle->set_typed_item(datatype, key, data, dataSize);
  61. }
  62. esp_err_t NVSHandleLocked::get_typed_item(ItemType datatype, const char *key, void* data, size_t dataSize) {
  63. Lock lock;
  64. return handle->get_typed_item(datatype, key, data, dataSize);
  65. }
  66. } // namespace nvs