|
| 1 | +/* |
| 2 | + * This file is part of Arduino_KVStore. |
| 3 | + * |
| 4 | + * Copyright (c) 2024 Arduino SA |
| 5 | + * |
| 6 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 7 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 8 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 9 | + */ |
| 10 | +#pragma once |
| 11 | + |
1 | 12 | #include "../kvstore.h"
|
| 13 | +#include <Arduino.h> |
| 14 | +#include <Modem.h> |
| 15 | +#include <string> |
| 16 | + |
| 17 | +using namespace std; |
| 18 | + |
| 19 | +constexpr char DEFAULT_KVSTORE_NAME[] = "arduino"; |
2 | 20 |
|
3 | 21 | class Unor4KVStore: public KVStoreInterface {
|
4 | 22 | public:
|
5 |
| - void begin(); |
6 |
| - void end(); |
7 |
| - void clear(); |
| 23 | + Unor4KVStore(): name(DEFAULT_KVSTORE_NAME) {} |
| 24 | + |
| 25 | + bool begin() override; |
| 26 | + bool begin(const char* name, bool readOnly=false, const char* partitionLabel=nullptr); |
| 27 | + bool end() override; |
| 28 | + bool clear() override; |
| 29 | + |
| 30 | + typename KVStoreInterface::res_t remove(const key_t& key) override; |
| 31 | + bool exists(const key_t& key) const override; |
| 32 | + typename KVStoreInterface::res_t putBytes(const key_t& key, const uint8_t b[], size_t s) override; |
| 33 | + typename KVStoreInterface::res_t getBytes(const key_t& key, uint8_t b[], size_t s) const override; |
| 34 | + size_t getBytesLength(const key_t& key) const override; |
8 | 35 |
|
9 |
| - typename KVStoreInterface<Key>::res_t remove(const Key& key) override; |
10 |
| - bool exists(const Key& key) const override; |
11 |
| - typename KVStoreInterface<Key>::res_t putBytes(const Key& key, uint8_t b[], size_t s) override; |
12 |
| - typename KVStoreInterface<Key>::res_t getBytes(const Key& key, uint8_t b[], size_t s) const override; |
13 |
| - size_t getBytesLength(Key key) const override; |
| 36 | + size_t getString(const key_t& key, char value[], size_t maxLen) override; |
| 37 | + String getString(const key_t& key, const String defaultValue = String()) override; |
14 | 38 |
|
15 |
| -} |
| 39 | +protected: |
| 40 | + res_t _put(const key_t& key, const uint8_t value[], size_t len, Type t) override; |
| 41 | + res_t _get(const key_t& key, uint8_t value[], size_t len, Type t) override; |
| 42 | +private: |
| 43 | + const char* name; |
| 44 | +}; |
0 commit comments