[FL-1061] iButton save and load from sd card (#394)

* SD App: fix queue adresses
* sd-filesystem: fix making path on file select event
* ibutton: add key reading from sd card
* ibutton: save ibutton key to sd card
* ibutton: add deleting keys from sd card
* ibutton: remove KeyStore from application
* ibutton: make directory if necessary on key save

Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-03-31 20:47:32 +03:00
committed by GitHub
parent 6375f21cf5
commit 5309bfae41
15 changed files with 132 additions and 256 deletions

View File

@@ -1,69 +0,0 @@
#include "key-store.h"
#include <furi.h>
uint16_t KeyStore::get_key_count() {
return store.size();
}
uint8_t KeyStore::add_key() {
store.push_back(iButtonKey());
return get_key_count() - 1;
}
void KeyStore::set_key_type(uint8_t index, iButtonKeyType type) {
iButtonKey* key = get_key(index);
key->set_type(type);
}
void KeyStore::set_key_name(uint8_t index, char* name) {
iButtonKey* key = get_key(index);
char* orphan = strdup(name);
key->set_name(orphan);
}
void KeyStore::set_key_data(uint8_t index, uint8_t* data, uint8_t data_size) {
iButtonKey* key = get_key(index);
key->set_data(data, data_size);
}
iButtonKeyType KeyStore::get_key_type(uint8_t index) {
iButtonKey* key = get_key(index);
return key->get_key_type();
}
const char* KeyStore::get_key_name(uint8_t index) {
iButtonKey* key = get_key(index);
return key->get_name();
}
uint8_t* KeyStore::get_key_data(uint8_t index) {
iButtonKey* key = get_key(index);
return key->get_data();
}
void KeyStore::remove_key(uint8_t index) {
furi_check(index >= 0);
furi_check(index < get_key_count());
auto item = std::next(store.begin(), index);
store.erase(item);
}
KeyStore::KeyStore() {
store.push_back(iButtonKey(
iButtonKeyType::KeyDallas, "Dallas_1", 0x01, 0x41, 0xCE, 0x67, 0x0F, 0x00, 0x00, 0xB6));
store.push_back(iButtonKey(
iButtonKeyType::KeyDallas, "Dallas_2", 0x01, 0xFD, 0x0E, 0x84, 0x01, 0x00, 0x00, 0xDB));
store.push_back(iButtonKey(
iButtonKeyType::KeyCyfral, "Cyfral_1", 0xA6, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
store.push_back(iButtonKey(
iButtonKeyType::KeyMetakom, "Metakom_1", 0xB1, 0x2E, 0x47, 0xB2, 0x00, 0x00, 0x00, 0x00));
}
KeyStore::~KeyStore() {
}
iButtonKey* KeyStore::get_key(uint8_t index) {
furi_check(index >= 0);
furi_check(index < get_key_count());
return &(*std::next(store.begin(), index));
}

View File

@@ -1,29 +0,0 @@
#pragma once
#include <stdint.h>
#include <list>
#include "key-info.h"
#include "../ibutton-key.h"
class KeyStore {
public:
uint16_t get_key_count();
uint8_t add_key();
void set_key_type(uint8_t index, iButtonKeyType type);
void set_key_name(uint8_t index, char* name);
void set_key_data(uint8_t index, uint8_t* data, uint8_t data_size);
iButtonKeyType get_key_type(uint8_t index);
const char* get_key_name(uint8_t index);
uint8_t* get_key_data(uint8_t index);
void remove_key(uint8_t index);
KeyStore();
~KeyStore();
private:
std::list<iButtonKey> store;
iButtonKey* get_key(uint8_t index);
};