Skip to content

Commit 734d2b5

Browse files
implementing kvstore for unor4
1 parent b00e106 commit 734d2b5

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

src/kvstore/implementation/UnoR4.h

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
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+
112
#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";
220

321
class Unor4KVStore: public KVStoreInterface {
422
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;
835

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;
1438

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

Comments
 (0)