nvs_handle_locked.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. NVSHandleLocked::~NVSHandleLocked() {
  17. Lock lock;
  18. delete handle;
  19. }
  20. esp_err_t NVSHandleLocked::set_string(const char *key, const char* str) {
  21. Lock lock;
  22. return handle->set_string(key, str);
  23. }
  24. esp_err_t NVSHandleLocked::set_blob(const char *key, const void* blob, size_t len) {
  25. Lock lock;
  26. return handle->set_blob(key, blob, len);
  27. }
  28. esp_err_t NVSHandleLocked::get_string(const char *key, char* out_str, size_t len) {
  29. Lock lock;
  30. return handle->get_string(key, out_str, len);
  31. }
  32. esp_err_t NVSHandleLocked::get_blob(const char *key, void* out_blob, size_t len) {
  33. Lock lock;
  34. return handle->get_blob(key, out_blob, len);
  35. }
  36. esp_err_t NVSHandleLocked::get_item_size(ItemType datatype, const char *key, size_t &size) {
  37. Lock lock;
  38. return handle->get_item_size(datatype, key, size);
  39. }
  40. esp_err_t NVSHandleLocked::erase_item(const char* key) {
  41. Lock lock;
  42. return handle->erase_item(key);
  43. }
  44. esp_err_t NVSHandleLocked::erase_all() {
  45. Lock lock;
  46. return handle->erase_all();
  47. }
  48. esp_err_t NVSHandleLocked::commit() {
  49. Lock lock;
  50. return handle->commit();
  51. }
  52. esp_err_t NVSHandleLocked::get_used_entry_count(size_t& usedEntries) {
  53. Lock lock;
  54. return handle->get_used_entry_count(usedEntries);
  55. }
  56. esp_err_t NVSHandleLocked::set_typed_item(ItemType datatype, const char *key, const void* data, size_t dataSize) {
  57. Lock lock;
  58. return handle->set_typed_item(datatype, key, data, dataSize);
  59. }
  60. esp_err_t NVSHandleLocked::get_typed_item(ItemType datatype, const char *key, void* data, size_t dataSize) {
  61. Lock lock;
  62. return handle->get_typed_item(datatype, key, data, dataSize);
  63. }
  64. } // namespace nvs