unleashed-firmware/lib/one_wire/ibutton/ibutton_key.h
hedger 4d6b170769
[FL-2520] FW build with -Wextra (#1185)
* Fixing compiler warnings with -Wextra
* More warnings suppression, WIP
* Even more warning fixes
* Added new lines at end of text files.
* Padding fix
* Additional fixes to warnings on different build configurations; added -Wextra to default build pipeline
* Fixes for Secplus v1
* -additional warnings
* +-Wredundant-decls fixes
* FuriHal: print stack overflow task name in console
* FuriHal: add missing include

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2022-05-06 16:37:10 +03:00

145 lines
2.4 KiB
C

/**
* @file ibutton_key.h
*
* iButton key data holder
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define IBUTTON_KEY_DATA_SIZE 8
#define IBUTTON_KEY_NAME_SIZE 22
typedef enum {
iButtonKeyDS1990,
iButtonKeyCyfral,
iButtonKeyMetakom,
} iButtonKeyType;
typedef struct iButtonKey iButtonKey;
/**
* Allocate key
* @return iButtonKey*
*/
iButtonKey* ibutton_key_alloc();
/**
* Free key
* @param key
*/
void ibutton_key_free(iButtonKey* key);
/**
* Copy key
* @param to
* @param from
*/
void ibutton_key_set(iButtonKey* to, const iButtonKey* from);
/**
* Set key data
* @param key
* @param data
* @param data_count
*/
void ibutton_key_set_data(iButtonKey* key, uint8_t* data, uint8_t data_count);
/**
* Clear key data
* @param key
*/
void ibutton_key_clear_data(iButtonKey* key);
/**
* Get pointer to key data
* @param key
* @return const uint8_t*
*/
const uint8_t* ibutton_key_get_data_p(iButtonKey* key);
/**
* Get key data size
* @param key
* @return uint8_t
*/
uint8_t ibutton_key_get_data_size(iButtonKey* key);
/**
* Set key name
* @param key
* @param name
*/
void ibutton_key_set_name(iButtonKey* key, const char* name);
/**
* Get pointer to key name
* @param key
* @return const char*
*/
const char* ibutton_key_get_name_p(iButtonKey* key);
/**
* Set key type
* @param key
* @param key_type
*/
void ibutton_key_set_type(iButtonKey* key, iButtonKeyType key_type);
/**
* Get key type
* @param key
* @return iButtonKeyType
*/
iButtonKeyType ibutton_key_get_type(iButtonKey* key);
/**
* Get type string from key type
* @param key_type
* @return const char*
*/
const char* ibutton_key_get_string_by_type(iButtonKeyType key_type);
/**
* Get key type from string
* @param type_string
* @param key_type
* @return bool
*/
bool ibutton_key_get_type_by_string(const char* type_string, iButtonKeyType* key_type);
/**
* Get key data size from type
* @param key_type
* @return uint8_t
*/
uint8_t ibutton_key_get_size_by_type(iButtonKeyType key_type);
/**
* Get max key size
* @return uint8_t
*/
uint8_t ibutton_key_get_max_size();
/**
* Check if CRC for onewire key is valid
* @param key
* @return true
* @return false
*/
bool ibutton_key_dallas_crc_is_valid(iButtonKey* key);
/**
* Check if onewire key is a DS1990 key
* @param key
* @return true
* @return false
*/
bool ibutton_key_dallas_is_1990_key(iButtonKey* key);
#ifdef __cplusplus
}
#endif