2022-01-05 19:10:18 +03:00
|
|
|
#include "rfid_key.h"
|
2022-07-20 13:56:33 +03:00
|
|
|
#include <core/check.h>
|
2021-06-30 15:02:46 +03:00
|
|
|
#include <string.h>
|
2021-06-28 17:42:30 +03:00
|
|
|
|
|
|
|
RfidKey::RfidKey() {
|
2021-06-30 15:02:46 +03:00
|
|
|
clear();
|
2021-06-28 17:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RfidKey::~RfidKey() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void RfidKey::set_type(LfrfidKeyType _type) {
|
|
|
|
type = _type;
|
|
|
|
}
|
|
|
|
|
2021-06-30 15:02:46 +03:00
|
|
|
void RfidKey::set_data(const uint8_t* _data, const uint8_t _data_size) {
|
2021-06-28 17:42:30 +03:00
|
|
|
furi_assert(_data_size <= data.size());
|
|
|
|
for(uint8_t i = 0; i < _data_size; i++) {
|
|
|
|
data[i] = _data[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 15:02:46 +03:00
|
|
|
void RfidKey::set_name(const char* _name) {
|
|
|
|
strlcpy(name, _name, get_name_length());
|
|
|
|
}
|
|
|
|
|
2021-06-28 17:42:30 +03:00
|
|
|
LfrfidKeyType RfidKey::get_type() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2021-06-30 15:02:46 +03:00
|
|
|
const uint8_t* RfidKey::get_data() {
|
2021-06-28 17:42:30 +03:00
|
|
|
return &data[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* RfidKey::get_type_text() {
|
|
|
|
return lfrfid_key_get_type_string(type);
|
|
|
|
}
|
|
|
|
|
2022-05-06 16:37:10 +03:00
|
|
|
uint8_t RfidKey::get_type_data_count() const {
|
2021-06-28 17:42:30 +03:00
|
|
|
return lfrfid_key_get_type_data_count(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
char* RfidKey::get_name() {
|
|
|
|
return name;
|
|
|
|
}
|
2021-06-30 15:02:46 +03:00
|
|
|
|
|
|
|
uint8_t RfidKey::get_name_length() {
|
|
|
|
return LFRFID_KEY_NAME_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RfidKey::clear() {
|
|
|
|
set_name("");
|
|
|
|
set_type(LfrfidKeyType::KeyEM4100);
|
|
|
|
data.fill(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
RfidKey& RfidKey::operator=(const RfidKey& rhs) {
|
|
|
|
if(this == &rhs) return *this;
|
|
|
|
|
|
|
|
set_type(rhs.type);
|
|
|
|
set_name(rhs.name);
|
|
|
|
set_data(&rhs.data[0], get_type_data_count());
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|