 1242327e14
			
		
	
	
		1242327e14
		
			
		
	
	
	
	
		
			
			* ibutton: remove existing key file before saving new * ibutton: save key name in iButtunKey object * ibutton: rename IBUTTON_KEY_SIZE -> IBUTTON_KEY_DATA_SIZE * ibutton: clear key when enter one manually * ibutton: change strcpy -> strlcpy Co-authored-by: あく <alleteam@gmail.com>
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include "ibutton-key.h"
 | |
| #include <furi.h>
 | |
| 
 | |
| uint8_t iButtonKey::get_size() {
 | |
|     return IBUTTON_KEY_DATA_SIZE;
 | |
| }
 | |
| 
 | |
| void iButtonKey::set_data(uint8_t* _data, uint8_t _data_count) {
 | |
|     furi_check(_data_count > 0);
 | |
|     furi_check(_data_count <= get_size());
 | |
| 
 | |
|     memset(data, 0, get_size());
 | |
|     memcpy(data, _data, _data_count);
 | |
| }
 | |
| 
 | |
| void iButtonKey::clear_data() {
 | |
|     memset(data, 0, get_size());
 | |
| }
 | |
| 
 | |
| uint8_t* iButtonKey::get_data() {
 | |
|     return data;
 | |
| }
 | |
| 
 | |
| uint8_t iButtonKey::get_type_data_size() {
 | |
|     uint8_t size = 0;
 | |
| 
 | |
|     switch(type) {
 | |
|     case iButtonKeyType::KeyCyfral:
 | |
|         size = 2;
 | |
|         break;
 | |
|     case iButtonKeyType::KeyMetakom:
 | |
|         size = 4;
 | |
|         break;
 | |
|     case iButtonKeyType::KeyDallas:
 | |
|         size = 8;
 | |
|         break;
 | |
|     }
 | |
| 
 | |
|     return size;
 | |
| }
 | |
| 
 | |
| void iButtonKey::set_name(const char* _name) {
 | |
|     strlcpy(name, _name, IBUTTON_KEY_NAME_SIZE);
 | |
| }
 | |
| 
 | |
| char* iButtonKey::get_name() {
 | |
|     return name;
 | |
| }
 | |
| 
 | |
| void iButtonKey::set_type(iButtonKeyType _key_type) {
 | |
|     type = _key_type;
 | |
| }
 | |
| 
 | |
| iButtonKeyType iButtonKey::get_key_type() {
 | |
|     return type;
 | |
| }
 | |
| 
 | |
| iButtonKey::iButtonKey() {
 | |
| }
 |