Flipper Zero Firmware
Loading...
Searching...
No Matches
ibutton_protocols.h File Reference

Common interface for accessing various iButton protocols. More...

#include <stdint.h>
#include <stddef.h>
#include "protocols/protocol_common.h"
#include "ibutton_key.h"

Go to the source code of this file.

Typedefs

typedef struct iButtonProtocols iButtonProtocols
 

Functions

iButtonProtocolsibutton_protocols_alloc (void)
 Allocate an iButtonProtocols object.
 
void ibutton_protocols_free (iButtonProtocols *protocols)
 Destroy an iButtonProtocols object, free resources.
 
uint32_t ibutton_protocols_get_protocol_count (void)
 Get the total number of available protocols.
 
size_t ibutton_protocols_get_max_data_size (iButtonProtocols *protocols)
 Get maximum data size out of all protocols available.
 
iButtonProtocolId ibutton_protocols_get_id_by_name (iButtonProtocols *protocols, const char *name)
 Get the protocol id based on its name.
 
const char * ibutton_protocols_get_manufacturer (iButtonProtocols *protocols, iButtonProtocolId id)
 Get the manufacturer name based on the protocol id.
 
const char * ibutton_protocols_get_name (iButtonProtocols *protocols, iButtonProtocolId id)
 Get the protocol name based on the protocol id.
 
uint32_t ibutton_protocols_get_features (iButtonProtocols *protocols, iButtonProtocolId id)
 Get protocol features bitmask by protocol id.
 
bool ibutton_protocols_read (iButtonProtocols *protocols, iButtonKey *key)
 Read a physical device (a key or an emulator)
 
bool ibutton_protocols_write_blank (iButtonProtocols *protocols, iButtonKey *key)
 Write the key to a blank.
 
bool ibutton_protocols_write_copy (iButtonProtocols *protocols, iButtonKey *key)
 Write the key to another one of the same type.
 
void ibutton_protocols_emulate_start (iButtonProtocols *protocols, iButtonKey *key)
 Start emulating the key.
 
void ibutton_protocols_emulate_stop (iButtonProtocols *protocols, iButtonKey *key)
 Stop emulating the key.
 
bool ibutton_protocols_save (iButtonProtocols *protocols, const iButtonKey *key, const char *file_name)
 Save the key data to a file.
 
bool ibutton_protocols_load (iButtonProtocols *protocols, iButtonKey *key, const char *file_name)
 Load the key from a file.
 
void ibutton_protocols_render_uid (iButtonProtocols *protocols, const iButtonKey *key, FuriString *result)
 Format a string containing defice UID.
 
void ibutton_protocols_render_data (iButtonProtocols *protocols, const iButtonKey *key, FuriString *result)
 Format a string containing device full data.
 
void ibutton_protocols_render_brief_data (iButtonProtocols *protocols, const iButtonKey *key, FuriString *result)
 Format a string containing device brief data.
 
void ibutton_protocols_render_error (iButtonProtocols *protocols, const iButtonKey *key, FuriString *result)
 Format a string containing error message (for invalid keys)
 
bool ibutton_protocols_is_valid (iButtonProtocols *protocols, const iButtonKey *key)
 Check whether the key data is valid.
 
void ibutton_protocols_get_editable_data (iButtonProtocols *protocols, const iButtonKey *key, iButtonEditableData *editable)
 Get a pointer to the key's editable data (for in-place editing)
 
void ibutton_protocols_apply_edits (iButtonProtocols *protocols, const iButtonKey *key)
 Make all necessary internal adjustments after editing the key.
 

Detailed Description

Common interface for accessing various iButton protocols.

Function Documentation

◆ ibutton_protocols_alloc()

iButtonProtocols * ibutton_protocols_alloc ( void )

Allocate an iButtonProtocols object.

Returns
pointer to an iButtonProtocols object

◆ ibutton_protocols_apply_edits()

void ibutton_protocols_apply_edits ( iButtonProtocols * protocols,
const iButtonKey * key )

Make all necessary internal adjustments after editing the key.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in,out]keypointer to the key to be adjusted

◆ ibutton_protocols_emulate_start()

void ibutton_protocols_emulate_start ( iButtonProtocols * protocols,
iButtonKey * key )

Start emulating the key.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be emulated

◆ ibutton_protocols_emulate_stop()

void ibutton_protocols_emulate_stop ( iButtonProtocols * protocols,
iButtonKey * key )

Stop emulating the key.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be emulated

◆ ibutton_protocols_free()

void ibutton_protocols_free ( iButtonProtocols * protocols)

Destroy an iButtonProtocols object, free resources.

Parameters
[in]protocolspointer to an iButtonProtocols object

◆ ibutton_protocols_get_editable_data()

void ibutton_protocols_get_editable_data ( iButtonProtocols * protocols,
const iButtonKey * key,
iButtonEditableData * editable )

Get a pointer to the key's editable data (for in-place editing)

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be checked
[out]editablepointer to a structure to contain the editable data

◆ ibutton_protocols_get_features()

uint32_t ibutton_protocols_get_features ( iButtonProtocols * protocols,
iButtonProtocolId id )

Get protocol features bitmask by protocol id.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]idid of the protocol in question

◆ ibutton_protocols_get_id_by_name()

iButtonProtocolId ibutton_protocols_get_id_by_name ( iButtonProtocols * protocols,
const char * name )

Get the protocol id based on its name.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]namepointer to a string containing the name
Returns
protocol id on success on iButtonProtocolIdInvalid on failure

◆ ibutton_protocols_get_manufacturer()

const char * ibutton_protocols_get_manufacturer ( iButtonProtocols * protocols,
iButtonProtocolId id )

Get the manufacturer name based on the protocol id.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]idid of the protocol in question
Returns
pointer to a statically allocated string with manufacturer name

◆ ibutton_protocols_get_max_data_size()

size_t ibutton_protocols_get_max_data_size ( iButtonProtocols * protocols)

Get maximum data size out of all protocols available.

Parameters
[in]protocolspointer to an iButtonProtocols object
Returns
maximum data size in bytes

◆ ibutton_protocols_get_name()

const char * ibutton_protocols_get_name ( iButtonProtocols * protocols,
iButtonProtocolId id )

Get the protocol name based on the protocol id.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]idid of the protocol in question
Returns
pointer to a statically allocated string with protocol name

◆ ibutton_protocols_is_valid()

bool ibutton_protocols_is_valid ( iButtonProtocols * protocols,
const iButtonKey * key )

Check whether the key data is valid.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be checked
Returns
true if data is valid, false otherwise

◆ ibutton_protocols_load()

bool ibutton_protocols_load ( iButtonProtocols * protocols,
iButtonKey * key,
const char * file_name )

Load the key from a file.

Parameters
[in]protocolspointer to an iButtonProtocols object
[out]keypointer to the key to load into (must be allocated before)
[in]file_namefull absolute path to the file name
Returns
true on success, false on failure

◆ ibutton_protocols_read()

bool ibutton_protocols_read ( iButtonProtocols * protocols,
iButtonKey * key )

Read a physical device (a key or an emulator)

Parameters
[in]protocolspointer to an iButtonProtocols object
[out]keypointer to the key to read into (must be allocated before)
Returns
true on success, false on failure

◆ ibutton_protocols_render_brief_data()

void ibutton_protocols_render_brief_data ( iButtonProtocols * protocols,
const iButtonKey * key,
FuriString * result )

Format a string containing device brief data.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be rendered
[out]resultpointer to the FuriString instance (must be initialized)

◆ ibutton_protocols_render_data()

void ibutton_protocols_render_data ( iButtonProtocols * protocols,
const iButtonKey * key,
FuriString * result )

Format a string containing device full data.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be rendered
[out]resultpointer to the FuriString instance (must be initialized)

◆ ibutton_protocols_render_error()

void ibutton_protocols_render_error ( iButtonProtocols * protocols,
const iButtonKey * key,
FuriString * result )

Format a string containing error message (for invalid keys)

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be rendered
[out]resultpointer to the FuriString instance (must be initialized)

◆ ibutton_protocols_render_uid()

void ibutton_protocols_render_uid ( iButtonProtocols * protocols,
const iButtonKey * key,
FuriString * result )

Format a string containing defice UID.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be rendered
[out]resultpointer to the FuriString instance (must be initialized)

◆ ibutton_protocols_save()

bool ibutton_protocols_save ( iButtonProtocols * protocols,
const iButtonKey * key,
const char * file_name )

Save the key data to a file.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be saved
[in]file_namefull absolute path to the file name
Returns
true on success, false on failure

◆ ibutton_protocols_write_blank()

bool ibutton_protocols_write_blank ( iButtonProtocols * protocols,
iButtonKey * key )

Write the key to a blank.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be written
Returns
true on success, false on failure

◆ ibutton_protocols_write_copy()

bool ibutton_protocols_write_copy ( iButtonProtocols * protocols,
iButtonKey * key )

Write the key to another one of the same type.

Parameters
[in]protocolspointer to an iButtonProtocols object
[in]keypointer to the key to be written
Returns
true on success, false on failure