mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-17 00:28:11 -07:00
Api Symbols: replace asserts with checks (#3507)
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
class TextStore {
|
||||
public:
|
||||
TextStore(uint8_t text_size);
|
||||
~TextStore();
|
||||
~TextStore(void);
|
||||
|
||||
void set(const char* text...);
|
||||
const uint8_t text_size;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class ByteInputVM : public GenericViewModule {
|
||||
public:
|
||||
ByteInputVM();
|
||||
ByteInputVM(void);
|
||||
~ByteInputVM() final;
|
||||
View* get_view() final;
|
||||
void clean() final;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class DialogExVM : public GenericViewModule {
|
||||
public:
|
||||
DialogExVM();
|
||||
DialogExVM(void);
|
||||
~DialogExVM() final;
|
||||
View* get_view() final;
|
||||
void clean() final;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class PopupVM : public GenericViewModule {
|
||||
public:
|
||||
PopupVM();
|
||||
PopupVM(void);
|
||||
~PopupVM() final;
|
||||
View* get_view() final;
|
||||
void clean() final;
|
||||
@@ -56,12 +56,12 @@ public:
|
||||
/**
|
||||
* Enable popup timeout
|
||||
*/
|
||||
void enable_timeout();
|
||||
void enable_timeout(void);
|
||||
|
||||
/**
|
||||
* Disable popup timeout
|
||||
*/
|
||||
void disable_timeout();
|
||||
void disable_timeout(void);
|
||||
|
||||
private:
|
||||
Popup* popup;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class SubmenuVM : public GenericViewModule {
|
||||
public:
|
||||
SubmenuVM();
|
||||
SubmenuVM(void);
|
||||
~SubmenuVM() final;
|
||||
View* get_view() final;
|
||||
void clean() final;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class TextInputVM : public GenericViewModule {
|
||||
public:
|
||||
TextInputVM();
|
||||
TextInputVM(void);
|
||||
~TextInputVM() final;
|
||||
View* get_view() final;
|
||||
void clean() final;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
void set_validator(TextInputValidatorCallback callback, void* callback_context);
|
||||
|
||||
void* get_validator_callback_context();
|
||||
void* get_validator_callback_context(void);
|
||||
|
||||
private:
|
||||
TextInput* text_input;
|
||||
|
||||
+10
-10
@@ -418,8 +418,8 @@ uint16_t bit_lib_crc16(
|
||||
}
|
||||
|
||||
void bit_lib_num_to_bytes_be(uint64_t src, uint8_t len, uint8_t* dest) {
|
||||
furi_assert(dest);
|
||||
furi_assert(len <= 8);
|
||||
furi_check(dest);
|
||||
furi_check(len <= 8);
|
||||
|
||||
while(len--) {
|
||||
dest[len] = (uint8_t)src;
|
||||
@@ -428,8 +428,8 @@ void bit_lib_num_to_bytes_be(uint64_t src, uint8_t len, uint8_t* dest) {
|
||||
}
|
||||
|
||||
void bit_lib_num_to_bytes_le(uint64_t src, uint8_t len, uint8_t* dest) {
|
||||
furi_assert(dest);
|
||||
furi_assert(len <= 8);
|
||||
furi_check(dest);
|
||||
furi_check(len <= 8);
|
||||
|
||||
for(int i = 0; i < len; i++) {
|
||||
dest[i] = (uint8_t)(src >> (8 * i));
|
||||
@@ -437,8 +437,8 @@ void bit_lib_num_to_bytes_le(uint64_t src, uint8_t len, uint8_t* dest) {
|
||||
}
|
||||
|
||||
uint64_t bit_lib_bytes_to_num_be(const uint8_t* src, uint8_t len) {
|
||||
furi_assert(src);
|
||||
furi_assert(len <= 8);
|
||||
furi_check(src);
|
||||
furi_check(len <= 8);
|
||||
|
||||
uint64_t res = 0;
|
||||
while(len--) {
|
||||
@@ -449,8 +449,8 @@ uint64_t bit_lib_bytes_to_num_be(const uint8_t* src, uint8_t len) {
|
||||
}
|
||||
|
||||
uint64_t bit_lib_bytes_to_num_le(const uint8_t* src, uint8_t len) {
|
||||
furi_assert(src);
|
||||
furi_assert(len <= 8);
|
||||
furi_check(src);
|
||||
furi_check(len <= 8);
|
||||
|
||||
uint64_t res = 0;
|
||||
uint8_t shift = 0;
|
||||
@@ -462,8 +462,8 @@ uint64_t bit_lib_bytes_to_num_le(const uint8_t* src, uint8_t len) {
|
||||
}
|
||||
|
||||
uint64_t bit_lib_bytes_to_num_bcd(const uint8_t* src, uint8_t len, bool* is_bcd) {
|
||||
furi_assert(src);
|
||||
furi_assert(len <= 9);
|
||||
furi_check(src);
|
||||
furi_check(len <= 9);
|
||||
|
||||
uint64_t res = 0;
|
||||
uint8_t nibble_1, nibble_2;
|
||||
|
||||
@@ -169,7 +169,7 @@ static BleEventAckStatus ble_svc_hid_event_handler(void* event, void* context) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
BleServiceHid* ble_svc_hid_start() {
|
||||
BleServiceHid* ble_svc_hid_start(void) {
|
||||
BleServiceHid* hid_svc = malloc(sizeof(BleServiceHid));
|
||||
|
||||
// Register event handler
|
||||
|
||||
@@ -9,7 +9,7 @@ extern "C" {
|
||||
|
||||
typedef struct BleServiceHid BleServiceHid;
|
||||
|
||||
BleServiceHid* ble_svc_hid_start();
|
||||
BleServiceHid* ble_svc_hid_start(void);
|
||||
|
||||
void ble_svc_hid_stop(BleServiceHid* service);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "datetime.h"
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "DateTime"
|
||||
|
||||
@@ -37,6 +38,8 @@ bool datetime_validate_datetime(DateTime* datetime) {
|
||||
}
|
||||
|
||||
uint32_t datetime_datetime_to_timestamp(DateTime* datetime) {
|
||||
furi_check(datetime);
|
||||
|
||||
uint32_t timestamp = 0;
|
||||
uint8_t years = 0;
|
||||
uint8_t leap_years = 0;
|
||||
@@ -67,6 +70,7 @@ uint32_t datetime_datetime_to_timestamp(DateTime* datetime) {
|
||||
}
|
||||
|
||||
void datetime_timestamp_to_datetime(uint32_t timestamp, DateTime* datetime) {
|
||||
furi_check(datetime);
|
||||
uint32_t days = timestamp / SECONDS_PER_DAY;
|
||||
uint32_t seconds_in_day = timestamp % SECONDS_PER_DAY;
|
||||
|
||||
|
||||
@@ -115,17 +115,17 @@ void digital_sequence_register_signal(
|
||||
DigitalSequence* sequence,
|
||||
uint8_t signal_index,
|
||||
const DigitalSignal* signal) {
|
||||
furi_assert(sequence);
|
||||
furi_assert(signal);
|
||||
furi_assert(signal_index < DIGITAL_SEQUENCE_BANK_SIZE);
|
||||
furi_check(sequence);
|
||||
furi_check(signal);
|
||||
furi_check(signal_index < DIGITAL_SEQUENCE_BANK_SIZE);
|
||||
|
||||
sequence->signals[signal_index] = signal;
|
||||
}
|
||||
|
||||
void digital_sequence_add_signal(DigitalSequence* sequence, uint8_t signal_index) {
|
||||
furi_assert(sequence);
|
||||
furi_assert(signal_index < DIGITAL_SEQUENCE_BANK_SIZE);
|
||||
furi_assert(sequence->size < sequence->max_size);
|
||||
furi_check(sequence);
|
||||
furi_check(signal_index < DIGITAL_SEQUENCE_BANK_SIZE);
|
||||
furi_check(sequence->size < sequence->max_size);
|
||||
|
||||
sequence->data[sequence->size++] = signal_index;
|
||||
}
|
||||
@@ -140,14 +140,14 @@ static inline void digital_sequence_start_dma(DigitalSequence* sequence) {
|
||||
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_2);
|
||||
}
|
||||
|
||||
static inline void digital_sequence_stop_dma() {
|
||||
static inline void digital_sequence_stop_dma(void) {
|
||||
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1);
|
||||
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2);
|
||||
LL_DMA_ClearFlag_TC1(DMA1);
|
||||
LL_DMA_ClearFlag_TC2(DMA1);
|
||||
}
|
||||
|
||||
static inline void digital_sequence_start_timer() {
|
||||
static inline void digital_sequence_start_timer(void) {
|
||||
furi_hal_bus_enable(FuriHalBusTIM2);
|
||||
|
||||
LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP);
|
||||
@@ -162,7 +162,7 @@ static inline void digital_sequence_start_timer() {
|
||||
LL_TIM_GenerateEvent_UPDATE(TIM2);
|
||||
}
|
||||
|
||||
static void digital_sequence_stop_timer() {
|
||||
static void digital_sequence_stop_timer(void) {
|
||||
LL_TIM_DisableCounter(TIM2);
|
||||
LL_TIM_DisableUpdateEvent(TIM2);
|
||||
LL_TIM_DisableDMAReq_UPDATE(TIM2);
|
||||
@@ -280,9 +280,9 @@ static inline void digital_sequence_timer_buffer_reset(DigitalSequence* sequence
|
||||
}
|
||||
|
||||
void digital_sequence_transmit(DigitalSequence* sequence) {
|
||||
furi_assert(sequence);
|
||||
furi_assert(sequence->size);
|
||||
furi_assert(sequence->state == DigitalSequenceStateIdle);
|
||||
furi_check(sequence);
|
||||
furi_check(sequence->size);
|
||||
furi_check(sequence->state == DigitalSequenceStateIdle);
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
|
||||
@@ -15,33 +15,33 @@ DigitalSignal* digital_signal_alloc(uint32_t max_size) {
|
||||
}
|
||||
|
||||
void digital_signal_free(DigitalSignal* signal) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
free(signal->data);
|
||||
free(signal);
|
||||
}
|
||||
|
||||
bool digital_signal_get_start_level(const DigitalSignal* signal) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
return signal->start_level;
|
||||
}
|
||||
|
||||
void digital_signal_set_start_level(DigitalSignal* signal, bool level) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
signal->start_level = level;
|
||||
}
|
||||
|
||||
uint32_t digital_signal_get_size(const DigitalSignal* signal) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
return signal->size;
|
||||
}
|
||||
|
||||
void digital_signal_add_period(DigitalSignal* signal, uint32_t ticks) {
|
||||
furi_assert(signal);
|
||||
furi_assert(signal->size < signal->max_size);
|
||||
furi_check(signal);
|
||||
furi_check(signal->size < signal->max_size);
|
||||
|
||||
const uint32_t duration = ticks + signal->remainder;
|
||||
|
||||
@@ -80,7 +80,7 @@ static void digital_signal_extend_last_period(DigitalSignal* signal, uint32_t ti
|
||||
}
|
||||
|
||||
void digital_signal_add_period_with_level(DigitalSignal* signal, uint32_t ticks, bool level) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
if(signal->size == 0) {
|
||||
signal->start_level = level;
|
||||
|
||||
+37
-37
@@ -34,7 +34,7 @@ static void st25r3916_reg_tx_byte(FuriHalSpiBusHandle* handle, uint8_t byte) {
|
||||
}
|
||||
|
||||
void st25r3916_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* val) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
st25r3916_read_burst_regs(handle, reg, val, 1);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ void st25r3916_read_burst_regs(
|
||||
uint8_t reg_start,
|
||||
uint8_t* values,
|
||||
uint8_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(values);
|
||||
furi_assert(length);
|
||||
furi_check(handle);
|
||||
furi_check(values);
|
||||
furi_check(length);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
|
||||
@@ -60,7 +60,7 @@ void st25r3916_read_burst_regs(
|
||||
}
|
||||
|
||||
void st25r3916_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t val) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
uint8_t reg_val = val;
|
||||
st25r3916_write_burst_regs(handle, reg, ®_val, 1);
|
||||
}
|
||||
@@ -70,9 +70,9 @@ void st25r3916_write_burst_regs(
|
||||
uint8_t reg_start,
|
||||
const uint8_t* values,
|
||||
uint8_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(values);
|
||||
furi_assert(length);
|
||||
furi_check(handle);
|
||||
furi_check(values);
|
||||
furi_check(length);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
|
||||
@@ -87,10 +87,10 @@ void st25r3916_write_burst_regs(
|
||||
}
|
||||
|
||||
void st25r3916_reg_write_fifo(FuriHalSpiBusHandle* handle, const uint8_t* buff, size_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(buff);
|
||||
furi_assert(length);
|
||||
furi_assert(length <= ST25R3916_FIFO_DEPTH);
|
||||
furi_check(handle);
|
||||
furi_check(buff);
|
||||
furi_check(length);
|
||||
furi_check(length <= ST25R3916_FIFO_DEPTH);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_FIFO_LOAD);
|
||||
@@ -99,10 +99,10 @@ void st25r3916_reg_write_fifo(FuriHalSpiBusHandle* handle, const uint8_t* buff,
|
||||
}
|
||||
|
||||
void st25r3916_reg_read_fifo(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(buff);
|
||||
furi_assert(length);
|
||||
furi_assert(length <= ST25R3916_FIFO_DEPTH);
|
||||
furi_check(handle);
|
||||
furi_check(buff);
|
||||
furi_check(length);
|
||||
furi_check(length <= ST25R3916_FIFO_DEPTH);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_FIFO_READ);
|
||||
@@ -111,10 +111,10 @@ void st25r3916_reg_read_fifo(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t
|
||||
}
|
||||
|
||||
void st25r3916_write_pta_mem(FuriHalSpiBusHandle* handle, const uint8_t* values, size_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(values);
|
||||
furi_assert(length);
|
||||
furi_assert(length <= ST25R3916_PTM_LEN);
|
||||
furi_check(handle);
|
||||
furi_check(values);
|
||||
furi_check(length);
|
||||
furi_check(length <= ST25R3916_PTM_LEN);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_PT_A_CONFIG_LOAD);
|
||||
@@ -123,10 +123,10 @@ void st25r3916_write_pta_mem(FuriHalSpiBusHandle* handle, const uint8_t* values,
|
||||
}
|
||||
|
||||
void st25r3916_read_pta_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(buff);
|
||||
furi_assert(length);
|
||||
furi_assert(length <= ST25R3916_PTM_LEN);
|
||||
furi_check(handle);
|
||||
furi_check(buff);
|
||||
furi_check(length);
|
||||
furi_check(length <= ST25R3916_PTM_LEN);
|
||||
|
||||
uint8_t tmp_buff[ST25R3916_PTM_LEN + 1];
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
@@ -137,8 +137,8 @@ void st25r3916_read_pta_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t l
|
||||
}
|
||||
|
||||
void st25r3916_write_ptf_mem(FuriHalSpiBusHandle* handle, const uint8_t* values, size_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(values);
|
||||
furi_check(handle);
|
||||
furi_check(values);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_PT_F_CONFIG_LOAD);
|
||||
@@ -147,8 +147,8 @@ void st25r3916_write_ptf_mem(FuriHalSpiBusHandle* handle, const uint8_t* values,
|
||||
}
|
||||
|
||||
void st25r3916_write_pttsn_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t length) {
|
||||
furi_assert(handle);
|
||||
furi_assert(buff);
|
||||
furi_check(handle);
|
||||
furi_check(buff);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_PT_TSN_DATA_LOAD);
|
||||
@@ -157,7 +157,7 @@ void st25r3916_write_pttsn_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_
|
||||
}
|
||||
|
||||
void st25r3916_direct_cmd(FuriHalSpiBusHandle* handle, uint8_t cmd) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, cmd | ST25R3916_CMD_MODE);
|
||||
@@ -165,7 +165,7 @@ void st25r3916_direct_cmd(FuriHalSpiBusHandle* handle, uint8_t cmd) {
|
||||
}
|
||||
|
||||
void st25r3916_read_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* val) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_CMD_TEST_ACCESS);
|
||||
@@ -175,7 +175,7 @@ void st25r3916_read_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t*
|
||||
}
|
||||
|
||||
void st25r3916_write_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t val) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
st25r3916_reg_tx_byte(handle, ST25R3916_CMD_TEST_ACCESS);
|
||||
@@ -185,7 +185,7 @@ void st25r3916_write_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t
|
||||
}
|
||||
|
||||
void st25r3916_clear_reg_bits(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t clr_mask) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
st25r3916_read_reg(handle, reg, ®_val);
|
||||
@@ -196,7 +196,7 @@ void st25r3916_clear_reg_bits(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t
|
||||
}
|
||||
|
||||
void st25r3916_set_reg_bits(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t set_mask) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
st25r3916_read_reg(handle, reg, ®_val);
|
||||
@@ -211,7 +211,7 @@ void st25r3916_change_reg_bits(
|
||||
uint8_t reg,
|
||||
uint8_t mask,
|
||||
uint8_t value) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
st25r3916_modify_reg(handle, reg, mask, (mask & value));
|
||||
}
|
||||
@@ -221,7 +221,7 @@ void st25r3916_modify_reg(
|
||||
uint8_t reg,
|
||||
uint8_t clr_mask,
|
||||
uint8_t set_mask) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
uint8_t new_val = 0;
|
||||
@@ -237,7 +237,7 @@ void st25r3916_change_test_reg_bits(
|
||||
uint8_t reg,
|
||||
uint8_t mask,
|
||||
uint8_t value) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
uint8_t new_val = 0;
|
||||
@@ -249,7 +249,7 @@ void st25r3916_change_test_reg_bits(
|
||||
}
|
||||
|
||||
bool st25r3916_check_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t mask, uint8_t val) {
|
||||
furi_assert(handle);
|
||||
furi_check(handle);
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
st25r3916_read_reg(handle, reg, ®_val);
|
||||
|
||||
@@ -9,6 +9,10 @@ bool elf_resolve_from_hashtable(
|
||||
const ElfApiInterface* interface,
|
||||
uint32_t hash,
|
||||
Elf32_Addr* address) {
|
||||
|
||||
furi_check(interface);
|
||||
furi_check(address);
|
||||
|
||||
bool result = false;
|
||||
const HashtableApiInterface* hashtable_interface =
|
||||
static_cast<const HashtableApiInterface*>(interface);
|
||||
@@ -33,5 +37,6 @@ bool elf_resolve_from_hashtable(
|
||||
}
|
||||
|
||||
uint32_t elf_symbolname_hash(const char* s) {
|
||||
furi_check(s);
|
||||
return elf_gnu_hash(s);
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "application_manifest.h"
|
||||
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi.h>
|
||||
|
||||
bool flipper_application_manifest_is_valid(const FlipperApplicationManifest* manifest) {
|
||||
furi_check(manifest);
|
||||
|
||||
if((manifest->base.manifest_magic != FAP_MANIFEST_MAGIC) ||
|
||||
(manifest->base.manifest_version != FAP_MANIFEST_SUPPORTED_VERSION)) {
|
||||
return false;
|
||||
@@ -14,6 +17,9 @@ bool flipper_application_manifest_is_valid(const FlipperApplicationManifest* man
|
||||
bool flipper_application_manifest_is_too_old(
|
||||
const FlipperApplicationManifest* manifest,
|
||||
const ElfApiInterface* api_interface) {
|
||||
furi_check(manifest);
|
||||
furi_check(api_interface);
|
||||
|
||||
if(manifest->base.api_version.major < api_interface->api_version_major /* ||
|
||||
manifest->base.api_version.minor > app->api_interface->api_version_minor */) {
|
||||
return false;
|
||||
@@ -25,6 +31,9 @@ bool flipper_application_manifest_is_too_old(
|
||||
bool flipper_application_manifest_is_too_new(
|
||||
const FlipperApplicationManifest* manifest,
|
||||
const ElfApiInterface* api_interface) {
|
||||
furi_check(manifest);
|
||||
furi_check(api_interface);
|
||||
|
||||
if(manifest->base.api_version.major > api_interface->api_version_major /* ||
|
||||
manifest->base.api_version.minor > app->api_interface->api_version_minor */) {
|
||||
return false;
|
||||
@@ -34,6 +43,8 @@ bool flipper_application_manifest_is_too_new(
|
||||
}
|
||||
|
||||
bool flipper_application_manifest_is_target_compatible(const FlipperApplicationManifest* manifest) {
|
||||
furi_check(manifest);
|
||||
|
||||
const Version* version = furi_hal_version_get_firmware_version();
|
||||
return version_get_target(version) == manifest->base.hardware_target_id;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ FlipperApplicationList_t flipper_application_loaded_app_list = {0};
|
||||
static bool flipper_application_loaded_app_list_initialized = false;
|
||||
|
||||
static void flipper_application_list_add_app(const FlipperApplication* app) {
|
||||
furi_assert(app);
|
||||
furi_check(app);
|
||||
|
||||
if(!flipper_application_loaded_app_list_initialized) {
|
||||
FlipperApplicationList_init(flipper_application_loaded_app_list);
|
||||
@@ -34,8 +34,8 @@ static void flipper_application_list_add_app(const FlipperApplication* app) {
|
||||
}
|
||||
|
||||
static void flipper_application_list_remove_app(const FlipperApplication* app) {
|
||||
furi_assert(flipper_application_loaded_app_list_initialized);
|
||||
furi_assert(app);
|
||||
furi_check(flipper_application_loaded_app_list_initialized);
|
||||
furi_check(app);
|
||||
|
||||
FlipperApplicationList_it_t it;
|
||||
for(FlipperApplicationList_it(it, flipper_application_loaded_app_list);
|
||||
@@ -52,19 +52,24 @@ static void flipper_application_list_remove_app(const FlipperApplication* app) {
|
||||
|
||||
FlipperApplication*
|
||||
flipper_application_alloc(Storage* storage, const ElfApiInterface* api_interface) {
|
||||
furi_check(storage);
|
||||
furi_check(api_interface);
|
||||
|
||||
FlipperApplication* app = malloc(sizeof(FlipperApplication));
|
||||
app->elf = elf_file_alloc(storage, api_interface);
|
||||
app->thread = NULL;
|
||||
app->ep_thread_args = NULL;
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
bool flipper_application_is_plugin(FlipperApplication* app) {
|
||||
furi_check(app);
|
||||
return app->manifest.stack_size == 0;
|
||||
}
|
||||
|
||||
void flipper_application_free(FlipperApplication* app) {
|
||||
furi_assert(app);
|
||||
furi_check(app);
|
||||
|
||||
if(app->thread) {
|
||||
furi_thread_join(app->thread);
|
||||
@@ -184,20 +189,29 @@ static FlipperApplicationPreloadStatus
|
||||
/* Parse headers, load manifest */
|
||||
FlipperApplicationPreloadStatus
|
||||
flipper_application_preload_manifest(FlipperApplication* app, const char* path) {
|
||||
furi_check(app);
|
||||
furi_check(path);
|
||||
|
||||
return flipper_application_load(app, path, false);
|
||||
}
|
||||
|
||||
/* Parse headers, load full file */
|
||||
FlipperApplicationPreloadStatus
|
||||
flipper_application_preload(FlipperApplication* app, const char* path) {
|
||||
furi_check(app);
|
||||
furi_check(path);
|
||||
|
||||
return flipper_application_load(app, path, true);
|
||||
}
|
||||
|
||||
const FlipperApplicationManifest* flipper_application_get_manifest(FlipperApplication* app) {
|
||||
furi_check(app);
|
||||
return &app->manifest;
|
||||
}
|
||||
|
||||
FlipperApplicationLoadStatus flipper_application_map_to_memory(FlipperApplication* app) {
|
||||
furi_check(app);
|
||||
|
||||
ELFFileLoadStatus status = elf_file_load_sections(app->elf);
|
||||
|
||||
switch(status) {
|
||||
@@ -215,7 +229,7 @@ FlipperApplicationLoadStatus flipper_application_map_to_memory(FlipperApplicatio
|
||||
}
|
||||
|
||||
static int32_t flipper_application_thread(void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FlipperApplication* app = (FlipperApplication*)context;
|
||||
|
||||
elf_file_call_init(app->elf);
|
||||
@@ -237,6 +251,7 @@ static int32_t flipper_application_thread(void* context) {
|
||||
}
|
||||
|
||||
FuriThread* flipper_application_alloc_thread(FlipperApplication* app, const char* args) {
|
||||
furi_check(app);
|
||||
furi_check(app->thread == NULL);
|
||||
furi_check(!flipper_application_is_plugin(app));
|
||||
|
||||
@@ -290,6 +305,8 @@ const char* flipper_application_load_status_to_string(FlipperApplicationLoadStat
|
||||
|
||||
const FlipperAppPluginDescriptor*
|
||||
flipper_application_plugin_get_descriptor(FlipperApplication* app) {
|
||||
furi_check(app);
|
||||
|
||||
if(!flipper_application_is_plugin(app)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -318,6 +335,11 @@ bool flipper_application_load_name_and_icon(
|
||||
Storage* storage,
|
||||
uint8_t** icon_ptr,
|
||||
FuriString* item_name) {
|
||||
furi_check(path);
|
||||
furi_check(storage);
|
||||
furi_check(icon_ptr);
|
||||
furi_check(item_name);
|
||||
|
||||
FlipperApplication* app = flipper_application_alloc(storage, firmware_api_interface);
|
||||
|
||||
FlipperApplicationPreloadStatus preload_res =
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "composite_resolver.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <m-list.h>
|
||||
#include <m-algo.h>
|
||||
|
||||
@@ -25,21 +26,28 @@ static bool composite_api_resolver_callback(
|
||||
return false;
|
||||
}
|
||||
|
||||
CompositeApiResolver* composite_api_resolver_alloc() {
|
||||
CompositeApiResolver* composite_api_resolver_alloc(void) {
|
||||
CompositeApiResolver* resolver = malloc(sizeof(CompositeApiResolver));
|
||||
|
||||
resolver->api_interface.api_version_major = 0;
|
||||
resolver->api_interface.api_version_minor = 0;
|
||||
resolver->api_interface.resolver_callback = &composite_api_resolver_callback;
|
||||
ElfApiInterfaceList_init(resolver->interfaces);
|
||||
|
||||
return resolver;
|
||||
}
|
||||
|
||||
void composite_api_resolver_free(CompositeApiResolver* resolver) {
|
||||
furi_check(resolver);
|
||||
|
||||
ElfApiInterfaceList_clear(resolver->interfaces);
|
||||
free(resolver);
|
||||
}
|
||||
|
||||
void composite_api_resolver_add(CompositeApiResolver* resolver, const ElfApiInterface* interface) {
|
||||
furi_check(resolver);
|
||||
furi_check(interface);
|
||||
|
||||
if(ElfApiInterfaceList_empty_p(resolver->interfaces)) {
|
||||
resolver->api_interface.api_version_major = interface->api_version_major;
|
||||
resolver->api_interface.api_version_minor = interface->api_version_minor;
|
||||
@@ -48,5 +56,6 @@ void composite_api_resolver_add(CompositeApiResolver* resolver, const ElfApiInte
|
||||
}
|
||||
|
||||
const ElfApiInterface* composite_api_resolver_get(CompositeApiResolver* resolver) {
|
||||
furi_check(resolver);
|
||||
return &resolver->api_interface;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef struct CompositeApiResolver CompositeApiResolver;
|
||||
* @brief Allocate composite API resolver
|
||||
* @return CompositeApiResolver* instance
|
||||
*/
|
||||
CompositeApiResolver* composite_api_resolver_alloc();
|
||||
CompositeApiResolver* composite_api_resolver_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free composite API resolver
|
||||
|
||||
@@ -36,6 +36,8 @@ PluginManager* plugin_manager_alloc(
|
||||
}
|
||||
|
||||
void plugin_manager_free(PluginManager* manager) {
|
||||
furi_check(manager);
|
||||
|
||||
for
|
||||
M_EACH(loaded_lib, manager->libs, FlipperApplicationList_t) {
|
||||
flipper_application_free(*loaded_lib);
|
||||
@@ -46,6 +48,7 @@ void plugin_manager_free(PluginManager* manager) {
|
||||
}
|
||||
|
||||
PluginManagerError plugin_manager_load_single(PluginManager* manager, const char* path) {
|
||||
furi_check(manager);
|
||||
FlipperApplication* lib = flipper_application_alloc(manager->storage, manager->api_interface);
|
||||
|
||||
PluginManagerError error = PluginManagerErrorNone;
|
||||
@@ -103,6 +106,7 @@ PluginManagerError plugin_manager_load_single(PluginManager* manager, const char
|
||||
}
|
||||
|
||||
PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* path) {
|
||||
furi_check(manager);
|
||||
File* directory = storage_file_alloc(manager->storage);
|
||||
char file_name_buffer[256];
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
@@ -139,15 +143,21 @@ PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* p
|
||||
}
|
||||
|
||||
uint32_t plugin_manager_get_count(PluginManager* manager) {
|
||||
furi_check(manager);
|
||||
|
||||
return FlipperApplicationList_size(manager->libs);
|
||||
}
|
||||
|
||||
const FlipperAppPluginDescriptor* plugin_manager_get(PluginManager* manager, uint32_t index) {
|
||||
furi_check(manager);
|
||||
|
||||
FlipperApplication* app = *FlipperApplicationList_get(manager->libs, index);
|
||||
return flipper_application_plugin_get_descriptor(app);
|
||||
}
|
||||
|
||||
const void* plugin_manager_get_ep(PluginManager* manager, uint32_t index) {
|
||||
furi_check(manager);
|
||||
|
||||
const FlipperAppPluginDescriptor* lib_descr = plugin_manager_get(manager, index);
|
||||
furi_check(lib_descr);
|
||||
return lib_descr->entry_point;
|
||||
|
||||
@@ -23,7 +23,7 @@ Stream* flipper_format_get_raw_stream(FlipperFormat* flipper_format) {
|
||||
|
||||
/********************************** Public **********************************/
|
||||
|
||||
FlipperFormat* flipper_format_string_alloc() {
|
||||
FlipperFormat* flipper_format_string_alloc(void) {
|
||||
FlipperFormat* flipper_format = malloc(sizeof(FlipperFormat));
|
||||
flipper_format->stream = string_stream_alloc();
|
||||
flipper_format->strict_mode = false;
|
||||
@@ -45,18 +45,18 @@ FlipperFormat* flipper_format_buffered_file_alloc(Storage* storage) {
|
||||
}
|
||||
|
||||
bool flipper_format_file_open_existing(FlipperFormat* flipper_format, const char* path) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_OPEN_EXISTING);
|
||||
}
|
||||
|
||||
bool flipper_format_buffered_file_open_existing(FlipperFormat* flipper_format, const char* path) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return buffered_file_stream_open(
|
||||
flipper_format->stream, path, FSAM_READ_WRITE, FSOM_OPEN_EXISTING);
|
||||
}
|
||||
|
||||
bool flipper_format_file_open_append(FlipperFormat* flipper_format, const char* path) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
|
||||
bool result =
|
||||
file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_OPEN_APPEND);
|
||||
@@ -87,33 +87,33 @@ bool flipper_format_file_open_append(FlipperFormat* flipper_format, const char*
|
||||
}
|
||||
|
||||
bool flipper_format_file_open_always(FlipperFormat* flipper_format, const char* path) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS);
|
||||
}
|
||||
|
||||
bool flipper_format_buffered_file_open_always(FlipperFormat* flipper_format, const char* path) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return buffered_file_stream_open(
|
||||
flipper_format->stream, path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS);
|
||||
}
|
||||
|
||||
bool flipper_format_file_open_new(FlipperFormat* flipper_format, const char* path) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_CREATE_NEW);
|
||||
}
|
||||
|
||||
bool flipper_format_file_close(FlipperFormat* flipper_format) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return file_stream_close(flipper_format->stream);
|
||||
}
|
||||
|
||||
bool flipper_format_buffered_file_close(FlipperFormat* flipper_format) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return buffered_file_stream_close(flipper_format->stream);
|
||||
}
|
||||
|
||||
void flipper_format_free(FlipperFormat* flipper_format) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
stream_free(flipper_format->stream);
|
||||
free(flipper_format);
|
||||
}
|
||||
@@ -123,12 +123,12 @@ void flipper_format_set_strict_mode(FlipperFormat* flipper_format, bool strict_m
|
||||
}
|
||||
|
||||
bool flipper_format_rewind(FlipperFormat* flipper_format) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return stream_rewind(flipper_format->stream);
|
||||
}
|
||||
|
||||
bool flipper_format_seek_to_end(FlipperFormat* flipper_format) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return stream_seek(flipper_format->stream, 0, StreamOffsetFromEnd);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ bool flipper_format_read_header(
|
||||
FlipperFormat* flipper_format,
|
||||
FuriString* filetype,
|
||||
uint32_t* version) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_read_string(flipper_format, flipper_format_filetype_key, filetype) &&
|
||||
flipper_format_read_uint32(flipper_format, flipper_format_version_key, version, 1);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ bool flipper_format_write_header(
|
||||
FlipperFormat* flipper_format,
|
||||
FuriString* filetype,
|
||||
const uint32_t version) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_write_header_cstr(
|
||||
flipper_format, furi_string_get_cstr(filetype), version);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ bool flipper_format_write_header_cstr(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* filetype,
|
||||
const uint32_t version) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_write_string_cstr(
|
||||
flipper_format, flipper_format_filetype_key, filetype) &&
|
||||
flipper_format_write_uint32(flipper_format, flipper_format_version_key, &version, 1);
|
||||
@@ -173,19 +173,19 @@ bool flipper_format_get_value_count(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
uint32_t* count) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_stream_get_value_count(
|
||||
flipper_format->stream, key, count, flipper_format->strict_mode);
|
||||
}
|
||||
|
||||
bool flipper_format_read_string(FlipperFormat* flipper_format, const char* key, FuriString* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_stream_read_value_line(
|
||||
flipper_format->stream, key, FlipperStreamValueStr, data, 1, flipper_format->strict_mode);
|
||||
}
|
||||
|
||||
bool flipper_format_write_string(FlipperFormat* flipper_format, const char* key, FuriString* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueStr,
|
||||
@@ -200,7 +200,7 @@ bool flipper_format_write_string_cstr(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
const char* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueStr,
|
||||
@@ -216,7 +216,7 @@ bool flipper_format_read_hex_uint64(
|
||||
const char* key,
|
||||
uint64_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_stream_read_value_line(
|
||||
flipper_format->stream,
|
||||
key,
|
||||
@@ -231,7 +231,7 @@ bool flipper_format_write_hex_uint64(
|
||||
const char* key,
|
||||
const uint64_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueHexUint64,
|
||||
@@ -247,7 +247,7 @@ bool flipper_format_read_uint32(
|
||||
const char* key,
|
||||
uint32_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_stream_read_value_line(
|
||||
flipper_format->stream,
|
||||
key,
|
||||
@@ -262,7 +262,7 @@ bool flipper_format_write_uint32(
|
||||
const char* key,
|
||||
const uint32_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueUint32,
|
||||
@@ -292,7 +292,7 @@ bool flipper_format_write_int32(
|
||||
const char* key,
|
||||
const int32_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueInt32,
|
||||
@@ -322,7 +322,7 @@ bool flipper_format_write_bool(
|
||||
const char* key,
|
||||
const bool* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueBool,
|
||||
@@ -352,7 +352,7 @@ bool flipper_format_write_float(
|
||||
const char* key,
|
||||
const float* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueFloat,
|
||||
@@ -382,7 +382,7 @@ bool flipper_format_write_hex(
|
||||
const char* key,
|
||||
const uint8_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueHex,
|
||||
@@ -394,17 +394,17 @@ bool flipper_format_write_hex(
|
||||
}
|
||||
|
||||
bool flipper_format_write_comment(FlipperFormat* flipper_format, FuriString* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_write_comment_cstr(flipper_format, furi_string_get_cstr(data));
|
||||
}
|
||||
|
||||
bool flipper_format_write_comment_cstr(FlipperFormat* flipper_format, const char* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
return flipper_format_stream_write_comment_cstr(flipper_format->stream, data);
|
||||
}
|
||||
|
||||
bool flipper_format_delete_key(FlipperFormat* flipper_format, const char* key) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueIgnore,
|
||||
@@ -417,7 +417,7 @@ bool flipper_format_delete_key(FlipperFormat* flipper_format, const char* key) {
|
||||
}
|
||||
|
||||
bool flipper_format_update_string(FlipperFormat* flipper_format, const char* key, FuriString* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueStr,
|
||||
@@ -433,7 +433,7 @@ bool flipper_format_update_string_cstr(
|
||||
FlipperFormat* flipper_format,
|
||||
const char* key,
|
||||
const char* data) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueStr,
|
||||
@@ -450,7 +450,7 @@ bool flipper_format_update_uint32(
|
||||
const char* key,
|
||||
const uint32_t* data,
|
||||
const uint16_t data_size) {
|
||||
furi_assert(flipper_format);
|
||||
furi_check(flipper_format);
|
||||
FlipperStreamWriteData write_data = {
|
||||
.key = key,
|
||||
.type = FlipperStreamValueUint32,
|
||||
|
||||
@@ -106,7 +106,7 @@ typedef struct FlipperFormat FlipperFormat;
|
||||
* Allocate FlipperFormat as string.
|
||||
* @return FlipperFormat* pointer to a FlipperFormat instance
|
||||
*/
|
||||
FlipperFormat* flipper_format_string_alloc();
|
||||
FlipperFormat* flipper_format_string_alloc(void);
|
||||
|
||||
/**
|
||||
* Allocate FlipperFormat as file.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ibutton_key_i.h"
|
||||
#include <furi.h>
|
||||
|
||||
struct iButtonKey {
|
||||
iButtonProtocolId protocol_id;
|
||||
@@ -17,20 +18,28 @@ iButtonKey* ibutton_key_alloc(size_t data_size) {
|
||||
}
|
||||
|
||||
void ibutton_key_free(iButtonKey* key) {
|
||||
furi_check(key);
|
||||
|
||||
free(key->protocol_data);
|
||||
free(key);
|
||||
}
|
||||
|
||||
void ibutton_key_reset(iButtonKey* key) {
|
||||
furi_check(key);
|
||||
|
||||
key->protocol_id = iButtonProtocolIdInvalid;
|
||||
|
||||
memset(key->protocol_data, 0, key->protocol_data_size);
|
||||
}
|
||||
|
||||
iButtonProtocolId ibutton_key_get_protocol_id(const iButtonKey* key) {
|
||||
furi_check(key);
|
||||
|
||||
return key->protocol_id;
|
||||
}
|
||||
|
||||
void ibutton_key_set_protocol_id(iButtonKey* key, iButtonProtocolId protocol_id) {
|
||||
furi_check(key);
|
||||
key->protocol_id = protocol_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ static void ibutton_protocols_get_group_by_id(
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
iButtonProtocols* ibutton_protocols_alloc() {
|
||||
iButtonProtocols* ibutton_protocols_alloc(void) {
|
||||
iButtonProtocols* protocols = malloc(sizeof(iButtonProtocols*));
|
||||
|
||||
protocols->group_datas = malloc(sizeof(iButtonProtocolGroupData*) * iButtonProtocolGroupMax);
|
||||
@@ -64,6 +64,8 @@ iButtonProtocols* ibutton_protocols_alloc() {
|
||||
}
|
||||
|
||||
void ibutton_protocols_free(iButtonProtocols* protocols) {
|
||||
furi_check(protocols);
|
||||
|
||||
for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) {
|
||||
ibutton_protocol_groups[i]->free(protocols->group_datas[i]);
|
||||
}
|
||||
@@ -72,7 +74,7 @@ void ibutton_protocols_free(iButtonProtocols* protocols) {
|
||||
free(protocols);
|
||||
}
|
||||
|
||||
uint32_t ibutton_protocols_get_protocol_count() {
|
||||
uint32_t ibutton_protocols_get_protocol_count(void) {
|
||||
uint32_t count = 0;
|
||||
|
||||
for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) {
|
||||
@@ -83,6 +85,9 @@ uint32_t ibutton_protocols_get_protocol_count() {
|
||||
}
|
||||
|
||||
iButtonProtocolId ibutton_protocols_get_id_by_name(iButtonProtocols* protocols, const char* name) {
|
||||
furi_check(protocols);
|
||||
furi_check(name);
|
||||
|
||||
iButtonProtocolLocalId offset = 0;
|
||||
|
||||
for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) {
|
||||
@@ -96,11 +101,16 @@ iButtonProtocolId ibutton_protocols_get_id_by_name(iButtonProtocols* protocols,
|
||||
}
|
||||
|
||||
uint32_t ibutton_protocols_get_features(iButtonProtocols* protocols, iButtonProtocolId id) {
|
||||
furi_check(protocols);
|
||||
|
||||
GET_PROTOCOL_GROUP(id);
|
||||
|
||||
return GROUP_BASE->get_features(GROUP_DATA, PROTOCOL_ID);
|
||||
}
|
||||
|
||||
size_t ibutton_protocols_get_max_data_size(iButtonProtocols* protocols) {
|
||||
furi_check(protocols);
|
||||
|
||||
size_t max_size = 0;
|
||||
|
||||
for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) {
|
||||
@@ -115,16 +125,25 @@ size_t ibutton_protocols_get_max_data_size(iButtonProtocols* protocols) {
|
||||
}
|
||||
|
||||
const char* ibutton_protocols_get_manufacturer(iButtonProtocols* protocols, iButtonProtocolId id) {
|
||||
furi_check(protocols);
|
||||
|
||||
GET_PROTOCOL_GROUP(id);
|
||||
|
||||
return GROUP_BASE->get_manufacturer(GROUP_DATA, PROTOCOL_ID);
|
||||
}
|
||||
|
||||
const char* ibutton_protocols_get_name(iButtonProtocols* protocols, iButtonProtocolId id) {
|
||||
furi_check(protocols);
|
||||
|
||||
GET_PROTOCOL_GROUP(id);
|
||||
|
||||
return GROUP_BASE->get_name(GROUP_DATA, PROTOCOL_ID);
|
||||
}
|
||||
|
||||
bool ibutton_protocols_read(iButtonProtocols* protocols, iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
iButtonProtocolLocalId id = iButtonProtocolIdInvalid;
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -142,6 +161,9 @@ bool ibutton_protocols_read(iButtonProtocols* protocols, iButtonKey* key) {
|
||||
}
|
||||
|
||||
bool ibutton_protocols_write_blank(iButtonProtocols* protocols, iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -150,6 +172,9 @@ bool ibutton_protocols_write_blank(iButtonProtocols* protocols, iButtonKey* key)
|
||||
}
|
||||
|
||||
bool ibutton_protocols_write_copy(iButtonProtocols* protocols, iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -158,6 +183,9 @@ bool ibutton_protocols_write_copy(iButtonProtocols* protocols, iButtonKey* key)
|
||||
}
|
||||
|
||||
void ibutton_protocols_emulate_start(iButtonProtocols* protocols, iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -166,6 +194,9 @@ void ibutton_protocols_emulate_start(iButtonProtocols* protocols, iButtonKey* ke
|
||||
}
|
||||
|
||||
void ibutton_protocols_emulate_stop(iButtonProtocols* protocols, iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -177,6 +208,10 @@ bool ibutton_protocols_save(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
const char* file_name) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
furi_check(file_name);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
const iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -207,6 +242,10 @@ bool ibutton_protocols_save(
|
||||
}
|
||||
|
||||
bool ibutton_protocols_load(iButtonProtocols* protocols, iButtonKey* key, const char* file_name) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
furi_check(file_name);
|
||||
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
bool success = false;
|
||||
@@ -252,6 +291,10 @@ void ibutton_protocols_render_data(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
FuriString* result) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
furi_check(result);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
const iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -263,6 +306,10 @@ void ibutton_protocols_render_brief_data(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
FuriString* result) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
furi_check(result);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
const iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -274,6 +321,10 @@ void ibutton_protocols_render_error(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
FuriString* result) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
furi_check(result);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
const iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -282,6 +333,9 @@ void ibutton_protocols_render_error(
|
||||
}
|
||||
|
||||
bool ibutton_protocols_is_valid(iButtonProtocols* protocols, const iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
const iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -293,6 +347,10 @@ void ibutton_protocols_get_editable_data(
|
||||
iButtonProtocols* protocols,
|
||||
const iButtonKey* key,
|
||||
iButtonEditableData* editable) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
furi_check(editable);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
@@ -301,6 +359,9 @@ void ibutton_protocols_get_editable_data(
|
||||
}
|
||||
|
||||
void ibutton_protocols_apply_edits(iButtonProtocols* protocols, const iButtonKey* key) {
|
||||
furi_check(protocols);
|
||||
furi_check(key);
|
||||
|
||||
const iButtonProtocolId id = ibutton_key_get_protocol_id(key);
|
||||
iButtonProtocolData* data = ibutton_key_get_protocol_data(key);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef struct iButtonProtocols iButtonProtocols;
|
||||
* Allocate an iButtonProtocols object
|
||||
* @return pointer to an iButtonProtocols object
|
||||
*/
|
||||
iButtonProtocols* ibutton_protocols_alloc();
|
||||
iButtonProtocols* ibutton_protocols_alloc(void);
|
||||
|
||||
/**
|
||||
* Destroy an iButtonProtocols object, free resources
|
||||
@@ -34,7 +34,7 @@ void ibutton_protocols_free(iButtonProtocols* protocols);
|
||||
/**
|
||||
* Get the total number of available protocols
|
||||
*/
|
||||
uint32_t ibutton_protocols_get_protocol_count();
|
||||
uint32_t ibutton_protocols_get_protocol_count(void);
|
||||
|
||||
/**
|
||||
* Get maximum data size out of all protocols available
|
||||
|
||||
@@ -23,6 +23,8 @@ typedef struct {
|
||||
static int32_t ibutton_worker_thread(void* thread_context);
|
||||
|
||||
iButtonWorker* ibutton_worker_alloc(iButtonProtocols* protocols) {
|
||||
furi_check(protocols);
|
||||
|
||||
iButtonWorker* worker = malloc(sizeof(iButtonWorker));
|
||||
|
||||
worker->protocols = protocols;
|
||||
@@ -38,7 +40,9 @@ void ibutton_worker_read_set_callback(
|
||||
iButtonWorker* worker,
|
||||
iButtonWorkerReadCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == iButtonWorkerModeIdle);
|
||||
|
||||
worker->read_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
}
|
||||
@@ -47,7 +51,9 @@ void ibutton_worker_write_set_callback(
|
||||
iButtonWorker* worker,
|
||||
iButtonWorkerWriteCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == iButtonWorkerModeIdle);
|
||||
|
||||
worker->write_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
}
|
||||
@@ -56,55 +62,83 @@ void ibutton_worker_emulate_set_callback(
|
||||
iButtonWorker* worker,
|
||||
iButtonWorkerEmulateCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == iButtonWorkerModeIdle);
|
||||
|
||||
worker->emulate_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
}
|
||||
|
||||
void ibutton_worker_read_start(iButtonWorker* worker, iButtonKey* key) {
|
||||
furi_check(worker);
|
||||
|
||||
iButtonMessage message = {.type = iButtonMessageRead, .data.key = key};
|
||||
|
||||
furi_check(
|
||||
furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void ibutton_worker_write_blank_start(iButtonWorker* worker, iButtonKey* key) {
|
||||
furi_check(worker);
|
||||
furi_check(key);
|
||||
|
||||
iButtonMessage message = {.type = iButtonMessageWriteBlank, .data.key = key};
|
||||
|
||||
furi_check(
|
||||
furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void ibutton_worker_write_copy_start(iButtonWorker* worker, iButtonKey* key) {
|
||||
furi_check(worker);
|
||||
furi_check(key);
|
||||
|
||||
iButtonMessage message = {.type = iButtonMessageWriteCopy, .data.key = key};
|
||||
|
||||
furi_check(
|
||||
furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void ibutton_worker_emulate_start(iButtonWorker* worker, iButtonKey* key) {
|
||||
furi_check(worker);
|
||||
|
||||
iButtonMessage message = {.type = iButtonMessageEmulate, .data.key = key};
|
||||
|
||||
furi_check(
|
||||
furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void ibutton_worker_stop(iButtonWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
iButtonMessage message = {.type = iButtonMessageStop};
|
||||
|
||||
furi_check(
|
||||
furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void ibutton_worker_free(iButtonWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_message_queue_free(worker->messages);
|
||||
furi_thread_free(worker->thread);
|
||||
|
||||
free(worker);
|
||||
}
|
||||
|
||||
void ibutton_worker_start_thread(iButtonWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_start(worker->thread);
|
||||
}
|
||||
|
||||
void ibutton_worker_stop_thread(iButtonWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
iButtonMessage message = {.type = iButtonMessageEnd};
|
||||
|
||||
furi_check(
|
||||
furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
furi_thread_join(worker->thread);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef struct {
|
||||
OneWireSlave* bus;
|
||||
} iButtonProtocolGroupDallas;
|
||||
|
||||
static iButtonProtocolGroupDallas* ibutton_protocol_group_dallas_alloc() {
|
||||
static iButtonProtocolGroupDallas* ibutton_protocol_group_dallas_alloc(void) {
|
||||
iButtonProtocolGroupDallas* group = malloc(sizeof(iButtonProtocolGroupDallas));
|
||||
|
||||
group->host = onewire_host_alloc(&gpio_ibutton);
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef struct {
|
||||
ProtocolId emulate_id;
|
||||
} iButtonProtocolGroupMisc;
|
||||
|
||||
static iButtonProtocolGroupMisc* ibutton_protocol_group_misc_alloc() {
|
||||
static iButtonProtocolGroupMisc* ibutton_protocol_group_misc_alloc(void) {
|
||||
iButtonProtocolGroupMisc* group = malloc(sizeof(iButtonProtocolGroupMisc));
|
||||
|
||||
group->dict = protocol_dict_alloc(ibutton_protocols_misc, iButtonProtocolMiscMax);
|
||||
|
||||
@@ -149,7 +149,7 @@ static const InfraredProtocolVariant* infrared_get_variant_by_protocol(InfraredP
|
||||
|
||||
const InfraredMessage*
|
||||
infrared_decode(InfraredDecoderHandler* handler, bool level, uint32_t duration) {
|
||||
furi_assert(handler);
|
||||
furi_check(handler);
|
||||
|
||||
InfraredMessage* message = NULL;
|
||||
InfraredMessage* result = NULL;
|
||||
@@ -181,8 +181,8 @@ InfraredDecoderHandler* infrared_alloc_decoder(void) {
|
||||
}
|
||||
|
||||
void infrared_free_decoder(InfraredDecoderHandler* handler) {
|
||||
furi_assert(handler);
|
||||
furi_assert(handler->ctx);
|
||||
furi_check(handler);
|
||||
furi_check(handler->ctx);
|
||||
|
||||
for(size_t i = 0; i < COUNT_OF(infrared_encoder_decoder); ++i) {
|
||||
if(infrared_encoder_decoder[i].decoder.free)
|
||||
@@ -194,6 +194,8 @@ void infrared_free_decoder(InfraredDecoderHandler* handler) {
|
||||
}
|
||||
|
||||
void infrared_reset_decoder(InfraredDecoderHandler* handler) {
|
||||
furi_check(handler);
|
||||
|
||||
for(size_t i = 0; i < COUNT_OF(infrared_encoder_decoder); ++i) {
|
||||
if(infrared_encoder_decoder[i].decoder.reset)
|
||||
infrared_encoder_decoder[i].decoder.reset(handler->ctx[i]);
|
||||
@@ -201,7 +203,7 @@ void infrared_reset_decoder(InfraredDecoderHandler* handler) {
|
||||
}
|
||||
|
||||
const InfraredMessage* infrared_check_decoder_ready(InfraredDecoderHandler* handler) {
|
||||
furi_assert(handler);
|
||||
furi_check(handler);
|
||||
|
||||
InfraredMessage* message = NULL;
|
||||
InfraredMessage* result = NULL;
|
||||
@@ -226,13 +228,13 @@ InfraredEncoderHandler* infrared_alloc_encoder(void) {
|
||||
}
|
||||
|
||||
void infrared_free_encoder(InfraredEncoderHandler* handler) {
|
||||
furi_assert(handler);
|
||||
furi_check(handler);
|
||||
const InfraredEncoders* encoder = handler->encoder;
|
||||
|
||||
if(encoder || handler->handler) {
|
||||
furi_assert(encoder);
|
||||
furi_assert(handler->handler);
|
||||
furi_assert(encoder->free);
|
||||
furi_check(encoder);
|
||||
furi_check(handler->handler);
|
||||
furi_check(encoder->free);
|
||||
encoder->free(handler->handler);
|
||||
}
|
||||
|
||||
@@ -250,20 +252,20 @@ static int infrared_find_index_by_protocol(InfraredProtocol protocol) {
|
||||
}
|
||||
|
||||
void infrared_reset_encoder(InfraredEncoderHandler* handler, const InfraredMessage* message) {
|
||||
furi_assert(handler);
|
||||
furi_assert(message);
|
||||
furi_check(handler);
|
||||
furi_check(message);
|
||||
int index = infrared_find_index_by_protocol(message->protocol);
|
||||
furi_check(index >= 0);
|
||||
|
||||
const InfraredEncoders* required_encoder = &infrared_encoder_decoder[index].encoder;
|
||||
furi_assert(required_encoder);
|
||||
furi_assert(required_encoder->reset);
|
||||
furi_assert(required_encoder->alloc);
|
||||
furi_check(required_encoder);
|
||||
furi_check(required_encoder->reset);
|
||||
furi_check(required_encoder->alloc);
|
||||
|
||||
/* Realloc encoder if different protocol set */
|
||||
if(required_encoder != handler->encoder) {
|
||||
if(handler->handler != NULL) {
|
||||
furi_assert(handler->encoder->free);
|
||||
furi_check(handler->encoder->free);
|
||||
handler->encoder->free(handler->handler);
|
||||
}
|
||||
handler->encoder = required_encoder;
|
||||
@@ -274,15 +276,16 @@ void infrared_reset_encoder(InfraredEncoderHandler* handler, const InfraredMessa
|
||||
}
|
||||
|
||||
InfraredStatus infrared_encode(InfraredEncoderHandler* handler, uint32_t* duration, bool* level) {
|
||||
furi_assert(handler);
|
||||
furi_assert(duration);
|
||||
furi_assert(level);
|
||||
furi_check(handler);
|
||||
furi_check(duration);
|
||||
furi_check(level);
|
||||
|
||||
const InfraredEncoders* encoder = handler->encoder;
|
||||
furi_assert(encoder);
|
||||
furi_assert(encoder->encode);
|
||||
furi_check(encoder);
|
||||
furi_check(encoder->encode);
|
||||
|
||||
InfraredStatus status = encoder->encode(handler->handler, duration, level);
|
||||
furi_assert(status != InfraredStatusError);
|
||||
furi_check(status != InfraredStatusError);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -292,6 +295,8 @@ bool infrared_is_protocol_valid(InfraredProtocol protocol) {
|
||||
}
|
||||
|
||||
InfraredProtocol infrared_get_protocol_by_name(const char* protocol_name) {
|
||||
furi_check(protocol_name);
|
||||
|
||||
for(InfraredProtocol protocol = 0; protocol < InfraredProtocolMAX; ++protocol) {
|
||||
const char* name = infrared_get_protocol_name(protocol);
|
||||
if(!strcmp(name, protocol_name)) return protocol;
|
||||
@@ -306,7 +311,7 @@ static const InfraredProtocolVariant* infrared_get_variant_by_protocol(InfraredP
|
||||
variant = infrared_encoder_decoder[index].get_protocol_variant(protocol);
|
||||
}
|
||||
|
||||
furi_assert(variant);
|
||||
furi_check(variant);
|
||||
return variant;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ void infrared_send_raw_ext(
|
||||
bool start_from_mark,
|
||||
uint32_t frequency,
|
||||
float duty_cycle) {
|
||||
furi_assert(timings);
|
||||
furi_check(timings);
|
||||
|
||||
infrared_tx_raw_start_from_mark = start_from_mark;
|
||||
infrared_tx_raw_timings_index = 0;
|
||||
@@ -53,7 +53,7 @@ void infrared_send_raw_ext(
|
||||
furi_hal_infrared_async_tx_start(frequency, duty_cycle);
|
||||
furi_hal_infrared_async_tx_wait_termination();
|
||||
|
||||
furi_assert(!furi_hal_infrared_is_busy());
|
||||
furi_check(!furi_hal_infrared_is_busy());
|
||||
}
|
||||
|
||||
void infrared_send_raw(const uint32_t timings[], uint32_t timings_cnt, bool start_from_mark) {
|
||||
@@ -95,9 +95,9 @@ FuriHalInfraredTxGetDataState
|
||||
}
|
||||
|
||||
void infrared_send(const InfraredMessage* message, int times) {
|
||||
furi_assert(message);
|
||||
furi_assert(times);
|
||||
furi_assert(infrared_is_protocol_valid(message->protocol));
|
||||
furi_check(message);
|
||||
furi_check(times);
|
||||
furi_check(infrared_is_protocol_valid(message->protocol));
|
||||
|
||||
InfraredEncoderHandler* handler = infrared_alloc_encoder();
|
||||
infrared_reset_encoder(handler, message);
|
||||
@@ -113,5 +113,5 @@ void infrared_send(const InfraredMessage* message, int times) {
|
||||
|
||||
infrared_free_encoder(handler);
|
||||
|
||||
furi_assert(!furi_hal_infrared_is_busy());
|
||||
furi_check(!furi_hal_infrared_is_busy());
|
||||
}
|
||||
|
||||
@@ -217,12 +217,13 @@ void infrared_worker_rx_set_received_signal_callback(
|
||||
InfraredWorker* instance,
|
||||
InfraredWorkerReceivedSignalCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->rx.received_signal_callback = callback;
|
||||
instance->rx.received_signal_context = context;
|
||||
}
|
||||
|
||||
InfraredWorker* infrared_worker_alloc() {
|
||||
InfraredWorker* infrared_worker_alloc(void) {
|
||||
InfraredWorker* instance = malloc(sizeof(InfraredWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc_ex("InfraredWorker", 2048, NULL, instance);
|
||||
@@ -242,8 +243,8 @@ InfraredWorker* infrared_worker_alloc() {
|
||||
}
|
||||
|
||||
void infrared_worker_free(InfraredWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == InfraredWorkerStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == InfraredWorkerStateIdle);
|
||||
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
infrared_free_decoder(instance->infrared_decoder);
|
||||
@@ -255,8 +256,8 @@ void infrared_worker_free(InfraredWorker* instance) {
|
||||
}
|
||||
|
||||
void infrared_worker_rx_start(InfraredWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == InfraredWorkerStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == InfraredWorkerStateIdle);
|
||||
|
||||
furi_stream_set_trigger_level(instance->stream, sizeof(LevelDuration));
|
||||
|
||||
@@ -274,8 +275,8 @@ void infrared_worker_rx_start(InfraredWorker* instance) {
|
||||
}
|
||||
|
||||
void infrared_worker_rx_stop(InfraredWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == InfraredWorkerStateRunRx);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == InfraredWorkerStateRunRx);
|
||||
|
||||
furi_hal_infrared_async_rx_set_timeout_isr_callback(NULL, NULL);
|
||||
furi_hal_infrared_async_rx_set_capture_isr_callback(NULL, NULL);
|
||||
@@ -284,15 +285,14 @@ void infrared_worker_rx_stop(InfraredWorker* instance) {
|
||||
furi_thread_flags_set(furi_thread_get_id(instance->thread), INFRARED_WORKER_EXIT);
|
||||
furi_thread_join(instance->thread);
|
||||
|
||||
FuriStatus status = furi_stream_buffer_reset(instance->stream);
|
||||
furi_assert(status == FuriStatusOk);
|
||||
(void)status;
|
||||
furi_check(furi_stream_buffer_reset(instance->stream) == FuriStatusOk);
|
||||
|
||||
instance->state = InfraredWorkerStateIdle;
|
||||
}
|
||||
|
||||
bool infrared_worker_signal_is_decoded(const InfraredWorkerSignal* signal) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
return signal->decoded;
|
||||
}
|
||||
|
||||
@@ -300,33 +300,36 @@ void infrared_worker_get_raw_signal(
|
||||
const InfraredWorkerSignal* signal,
|
||||
const uint32_t** timings,
|
||||
size_t* timings_cnt) {
|
||||
furi_assert(signal);
|
||||
furi_assert(timings);
|
||||
furi_assert(timings_cnt);
|
||||
furi_check(signal);
|
||||
furi_check(timings);
|
||||
furi_check(timings_cnt);
|
||||
|
||||
*timings = signal->raw.timings;
|
||||
*timings_cnt = signal->timings_cnt;
|
||||
}
|
||||
|
||||
const InfraredMessage* infrared_worker_get_decoded_signal(const InfraredWorkerSignal* signal) {
|
||||
furi_assert(signal);
|
||||
furi_check(signal);
|
||||
|
||||
return &signal->message;
|
||||
}
|
||||
|
||||
void infrared_worker_rx_enable_blink_on_receiving(InfraredWorker* instance, bool enable) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->blink_enable = enable;
|
||||
}
|
||||
|
||||
void infrared_worker_rx_enable_signal_decoding(InfraredWorker* instance, bool enable) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->decode_enable = enable;
|
||||
}
|
||||
|
||||
void infrared_worker_tx_start(InfraredWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == InfraredWorkerStateIdle);
|
||||
furi_assert(instance->tx.get_signal_callback);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == InfraredWorkerStateIdle);
|
||||
furi_check(instance->tx.get_signal_callback);
|
||||
|
||||
// size have to be greater than api hal infrared async tx buffer size
|
||||
furi_stream_set_trigger_level(instance->stream, sizeof(InfraredWorkerTiming));
|
||||
@@ -560,7 +563,8 @@ void infrared_worker_tx_set_get_signal_callback(
|
||||
InfraredWorker* instance,
|
||||
InfraredWorkerGetSignalCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->tx.get_signal_callback = callback;
|
||||
instance->tx.get_signal_context = context;
|
||||
}
|
||||
@@ -569,14 +573,15 @@ void infrared_worker_tx_set_signal_sent_callback(
|
||||
InfraredWorker* instance,
|
||||
InfraredWorkerMessageSentCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->tx.message_sent_callback = callback;
|
||||
instance->tx.message_sent_context = context;
|
||||
}
|
||||
|
||||
void infrared_worker_tx_stop(InfraredWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state != InfraredWorkerStateRunRx);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state != InfraredWorkerStateRunRx);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(instance->thread), INFRARED_WORKER_EXIT);
|
||||
furi_thread_join(instance->thread);
|
||||
@@ -584,15 +589,14 @@ void infrared_worker_tx_stop(InfraredWorker* instance) {
|
||||
furi_hal_infrared_async_tx_set_signal_sent_isr_callback(NULL, NULL);
|
||||
|
||||
instance->signal.timings_cnt = 0;
|
||||
FuriStatus status = furi_stream_buffer_reset(instance->stream);
|
||||
furi_assert(status == FuriStatusOk);
|
||||
(void)status;
|
||||
furi_check(furi_stream_buffer_reset(instance->stream) == FuriStatusOk);
|
||||
|
||||
instance->state = InfraredWorkerStateIdle;
|
||||
}
|
||||
|
||||
void infrared_worker_set_decoded_signal(InfraredWorker* instance, const InfraredMessage* message) {
|
||||
furi_assert(instance);
|
||||
furi_assert(message);
|
||||
furi_check(instance);
|
||||
furi_check(message);
|
||||
|
||||
instance->signal.decoded = true;
|
||||
instance->signal.message = *message;
|
||||
@@ -604,11 +608,12 @@ void infrared_worker_set_raw_signal(
|
||||
size_t timings_cnt,
|
||||
uint32_t frequency,
|
||||
float duty_cycle) {
|
||||
furi_assert(instance);
|
||||
furi_assert(timings);
|
||||
furi_assert(timings_cnt > 0);
|
||||
furi_assert((frequency <= INFRARED_MAX_FREQUENCY) && (frequency >= INFRARED_MIN_FREQUENCY));
|
||||
furi_assert((duty_cycle < 1.0f) && (duty_cycle > 0.0f));
|
||||
furi_check(instance);
|
||||
furi_check(timings);
|
||||
furi_check(timings_cnt > 0);
|
||||
furi_check((frequency <= INFRARED_MAX_FREQUENCY) && (frequency >= INFRARED_MIN_FREQUENCY));
|
||||
furi_check((duty_cycle < 1.0f) && (duty_cycle > 0.0f));
|
||||
|
||||
size_t max_copy_num = COUNT_OF(instance->signal.raw.timings) - 1;
|
||||
furi_check(timings_cnt <= max_copy_num);
|
||||
|
||||
@@ -623,6 +628,8 @@ void infrared_worker_set_raw_signal(
|
||||
InfraredWorkerGetSignalResponse
|
||||
infrared_worker_tx_get_signal_steady_callback(void* context, InfraredWorker* instance) {
|
||||
UNUSED(context);
|
||||
furi_check(instance);
|
||||
|
||||
InfraredWorkerGetSignalResponse response = instance->tx.steady_signal_sent ?
|
||||
InfraredWorkerGetSignalResponseSame :
|
||||
InfraredWorkerGetSignalResponseNew;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef void (
|
||||
*
|
||||
* @return just created instance of InfraredWorker
|
||||
*/
|
||||
InfraredWorker* infrared_worker_alloc();
|
||||
InfraredWorker* infrared_worker_alloc(void);
|
||||
|
||||
/** Free InfraredWorker
|
||||
*
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
#define LFRFID_DICT_FILETYPE "Flipper RFID key"
|
||||
|
||||
bool lfrfid_dict_file_save(ProtocolDict* dict, ProtocolId protocol, const char* filename) {
|
||||
furi_check(dict);
|
||||
furi_check(protocol != PROTOCOL_NO);
|
||||
furi_check(filename);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
size_t data_size = protocol_dict_get_data_size(dict, protocol);
|
||||
@@ -139,6 +142,9 @@ static ProtocolId lfrfid_dict_protocol_fallback(
|
||||
}
|
||||
|
||||
ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename) {
|
||||
furi_check(dict);
|
||||
furi_check(filename);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
ProtocolId result = PROTOCOL_NO;
|
||||
|
||||
@@ -26,6 +26,8 @@ struct LFRFIDRawFile {
|
||||
};
|
||||
|
||||
LFRFIDRawFile* lfrfid_raw_file_alloc(Storage* storage) {
|
||||
furi_check(storage);
|
||||
|
||||
LFRFIDRawFile* file = malloc(sizeof(LFRFIDRawFile));
|
||||
file->stream = file_stream_alloc(storage);
|
||||
file->buffer = NULL;
|
||||
@@ -33,16 +35,24 @@ LFRFIDRawFile* lfrfid_raw_file_alloc(Storage* storage) {
|
||||
}
|
||||
|
||||
void lfrfid_raw_file_free(LFRFIDRawFile* file) {
|
||||
furi_check(file);
|
||||
|
||||
if(file->buffer) free(file->buffer);
|
||||
stream_free(file->stream);
|
||||
free(file);
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_open_write(LFRFIDRawFile* file, const char* file_path) {
|
||||
furi_check(file);
|
||||
furi_check(file_path);
|
||||
|
||||
return file_stream_open(file->stream, file_path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS);
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_open_read(LFRFIDRawFile* file, const char* file_path) {
|
||||
furi_check(file);
|
||||
furi_check(file_path);
|
||||
|
||||
return file_stream_open(file->stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||
}
|
||||
|
||||
@@ -51,6 +61,8 @@ bool lfrfid_raw_file_write_header(
|
||||
float frequency,
|
||||
float duty_cycle,
|
||||
uint32_t max_buffer_size) {
|
||||
furi_check(file);
|
||||
|
||||
LFRFIDRawFileHeader header = {
|
||||
.magic = LFRFID_RAW_FILE_MAGIC,
|
||||
.version = LFRFID_RAW_FILE_VERSION,
|
||||
@@ -63,6 +75,10 @@ bool lfrfid_raw_file_write_header(
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, size_t buffer_size) {
|
||||
furi_check(file);
|
||||
furi_check(buffer_data);
|
||||
furi_check(buffer_size);
|
||||
|
||||
size_t size;
|
||||
size = stream_write(file->stream, (uint8_t*)&buffer_size, sizeof(size_t));
|
||||
if(size != sizeof(size_t)) return false;
|
||||
@@ -74,6 +90,10 @@ bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, siz
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_read_header(LFRFIDRawFile* file, float* frequency, float* duty_cycle) {
|
||||
furi_check(file);
|
||||
furi_check(frequency);
|
||||
furi_check(duty_cycle);
|
||||
|
||||
LFRFIDRawFileHeader header;
|
||||
size_t size = stream_read(file->stream, (uint8_t*)&header, sizeof(LFRFIDRawFileHeader));
|
||||
if(size == sizeof(LFRFIDRawFileHeader)) {
|
||||
@@ -98,6 +118,10 @@ bool lfrfid_raw_file_read_pair(
|
||||
uint32_t* duration,
|
||||
uint32_t* pulse,
|
||||
bool* pass_end) {
|
||||
furi_check(file);
|
||||
furi_check(duration);
|
||||
furi_check(pulse);
|
||||
|
||||
size_t length = 0;
|
||||
if(file->buffer_counter >= file->buffer_size) {
|
||||
if(stream_eof(file->stream)) {
|
||||
|
||||
@@ -58,21 +58,23 @@ typedef enum {
|
||||
static int32_t lfrfid_raw_read_worker_thread(void* thread_context);
|
||||
static int32_t lfrfid_raw_emulate_worker_thread(void* thread_context);
|
||||
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc() {
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc(void) {
|
||||
LFRFIDRawWorker* worker = malloc(sizeof(LFRFIDRawWorker));
|
||||
|
||||
worker->thread = furi_thread_alloc_ex("LfrfidRawWorker", 2048, NULL, worker);
|
||||
|
||||
worker->events = furi_event_flag_alloc(NULL);
|
||||
|
||||
worker->events = furi_event_flag_alloc();
|
||||
worker->file_path = furi_string_alloc();
|
||||
|
||||
return worker;
|
||||
}
|
||||
|
||||
void lfrfid_raw_worker_free(LFRFIDRawWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_free(worker->thread);
|
||||
furi_event_flag_free(worker->events);
|
||||
furi_string_free(worker->file_path);
|
||||
|
||||
free(worker);
|
||||
}
|
||||
|
||||
@@ -83,6 +85,8 @@ void lfrfid_raw_worker_start_read(
|
||||
float duty_cycle,
|
||||
LFRFIDWorkerReadRawCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(file_path);
|
||||
furi_check(furi_thread_get_state(worker->thread) == FuriThreadStateStopped);
|
||||
|
||||
furi_string_set(worker->file_path, file_path);
|
||||
@@ -102,7 +106,10 @@ void lfrfid_raw_worker_start_emulate(
|
||||
const char* file_path,
|
||||
LFRFIDWorkerEmulateRawCallback callback,
|
||||
void* context) {
|
||||
furi_check(worker);
|
||||
furi_check(file_path);
|
||||
furi_check(furi_thread_get_state(worker->thread) == FuriThreadStateStopped);
|
||||
|
||||
furi_string_set(worker->file_path, file_path);
|
||||
worker->emulate_callback = callback;
|
||||
worker->context = context;
|
||||
@@ -111,6 +118,8 @@ void lfrfid_raw_worker_start_emulate(
|
||||
}
|
||||
|
||||
void lfrfid_raw_worker_stop(LFRFIDRawWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
worker->emulate_callback = NULL;
|
||||
worker->context = NULL;
|
||||
worker->read_callback = NULL;
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct LFRFIDRawWorker LFRFIDRawWorker;
|
||||
*
|
||||
* @return LFRFIDRawWorker*
|
||||
*/
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc();
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free a LFRFIDRawWorker instance
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef enum {
|
||||
static int32_t lfrfid_worker_thread(void* thread_context);
|
||||
|
||||
LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) {
|
||||
furi_assert(dict);
|
||||
furi_check(dict);
|
||||
|
||||
LFRFIDWorker* worker = malloc(sizeof(LFRFIDWorker));
|
||||
worker->mode_index = LFRFIDWorkerIdle;
|
||||
@@ -37,6 +37,8 @@ LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) {
|
||||
}
|
||||
|
||||
void lfrfid_worker_free(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
if(worker->raw_filename) {
|
||||
free(worker->raw_filename);
|
||||
}
|
||||
@@ -50,7 +52,9 @@ void lfrfid_worker_read_start(
|
||||
LFRFIDWorkerReadType type,
|
||||
LFRFIDWorkerReadCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
worker->read_type = type;
|
||||
worker->read_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -62,7 +66,7 @@ void lfrfid_worker_write_start(
|
||||
LFRFIDProtocol protocol,
|
||||
LFRFIDWorkerWriteCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
worker->protocol = protocol;
|
||||
worker->write_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -70,7 +74,9 @@ void lfrfid_worker_write_start(
|
||||
}
|
||||
|
||||
void lfrfid_worker_emulate_start(LFRFIDWorker* worker, LFRFIDProtocol protocol) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
worker->protocol = protocol;
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventEmulate);
|
||||
}
|
||||
@@ -89,7 +95,9 @@ void lfrfid_worker_read_raw_start(
|
||||
LFRFIDWorkerReadType type,
|
||||
LFRFIDWorkerReadRawCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
worker->read_type = type;
|
||||
worker->read_raw_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -102,7 +110,9 @@ void lfrfid_worker_emulate_raw_start(
|
||||
const char* filename,
|
||||
LFRFIDWorkerEmulateRawCallback callback,
|
||||
void* context) {
|
||||
furi_assert(worker->mode_index == LFRFIDWorkerIdle);
|
||||
furi_check(worker);
|
||||
furi_check(worker->mode_index == LFRFIDWorkerIdle);
|
||||
|
||||
lfrfid_worker_set_filename(worker, filename);
|
||||
worker->emulate_raw_cb = callback;
|
||||
worker->cb_ctx = context;
|
||||
@@ -110,14 +120,20 @@ void lfrfid_worker_emulate_raw_start(
|
||||
}
|
||||
|
||||
void lfrfid_worker_stop(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventStopMode);
|
||||
}
|
||||
|
||||
void lfrfid_worker_start_thread(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_start(worker->thread);
|
||||
}
|
||||
|
||||
void lfrfid_worker_stop_thread(LFRFIDWorker* worker) {
|
||||
furi_check(worker);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventStopThread);
|
||||
furi_thread_join(worker->thread);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
#define T5577_BLOCKS_IN_PAGE_0 8
|
||||
#define T5577_BLOCKS_IN_PAGE_1 4
|
||||
|
||||
static void t5577_start() {
|
||||
static void t5577_start(void) {
|
||||
furi_hal_rfid_tim_read_start(125000, 0.5);
|
||||
|
||||
// do not ground the antenna
|
||||
furi_hal_rfid_pin_pull_release();
|
||||
}
|
||||
|
||||
static void t5577_stop() {
|
||||
static void t5577_stop(void) {
|
||||
furi_hal_rfid_tim_read_stop();
|
||||
furi_hal_rfid_pins_reset();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ static void t5577_write_opcode(uint8_t value) {
|
||||
t5577_write_bit((value >> 0) & 1);
|
||||
}
|
||||
|
||||
static void t5577_write_reset() {
|
||||
static void t5577_write_reset(void) {
|
||||
t5577_write_gap(T5577_TIMING_START_GAP);
|
||||
t5577_write_bit(1);
|
||||
t5577_write_bit(0);
|
||||
|
||||
@@ -8,7 +8,7 @@ struct VarintPair {
|
||||
uint8_t data[VARINT_PAIR_SIZE];
|
||||
};
|
||||
|
||||
VarintPair* varint_pair_alloc() {
|
||||
VarintPair* varint_pair_alloc(void) {
|
||||
VarintPair* pair = malloc(sizeof(VarintPair));
|
||||
pair->data_length = 0;
|
||||
return pair;
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct VarintPair VarintPair;
|
||||
* VarintPair is a buffer that holds pair of varint values
|
||||
* @return VarintPair*
|
||||
*/
|
||||
VarintPair* varint_pair_alloc();
|
||||
VarintPair* varint_pair_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free a VarintPair instance
|
||||
|
||||
@@ -97,7 +97,7 @@ static int32_t music_worker_thread_callback(void* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
MusicWorker* music_worker_alloc() {
|
||||
MusicWorker* music_worker_alloc(void) {
|
||||
MusicWorker* instance = malloc(sizeof(MusicWorker));
|
||||
|
||||
NoteBlockArray_init(instance->notes);
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef void (*MusicWorkerCallback)(
|
||||
|
||||
typedef struct MusicWorker MusicWorker;
|
||||
|
||||
MusicWorker* music_worker_alloc();
|
||||
MusicWorker* music_worker_alloc(void);
|
||||
|
||||
void music_worker_clear(MusicWorker* instance);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ static uint16_t
|
||||
}
|
||||
|
||||
void iso13239_crc_append(Iso13239CrcType type, BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
|
||||
@@ -41,6 +43,8 @@ void iso13239_crc_append(Iso13239CrcType type, BitBuffer* buf) {
|
||||
}
|
||||
|
||||
bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
if(data_size <= ISO13239_CRC_SIZE) return false;
|
||||
|
||||
@@ -55,6 +59,8 @@ bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) {
|
||||
}
|
||||
|
||||
void iso13239_crc_trim(BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
furi_assert(data_size > ISO13239_CRC_SIZE);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ static inline void iso14443_4_layer_update_pcb(Iso14443_4Layer* instance) {
|
||||
instance->pcb ^= (uint8_t)0x01;
|
||||
}
|
||||
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc() {
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc(void) {
|
||||
Iso14443_4Layer* instance = malloc(sizeof(Iso14443_4Layer));
|
||||
|
||||
iso14443_4_layer_reset(instance);
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C" {
|
||||
|
||||
typedef struct Iso14443_4Layer Iso14443_4Layer;
|
||||
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc();
|
||||
Iso14443_4Layer* iso14443_4_layer_alloc(void);
|
||||
|
||||
void iso14443_4_layer_free(Iso14443_4Layer* instance);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ static uint16_t
|
||||
}
|
||||
|
||||
void iso14443_crc_append(Iso14443CrcType type, BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
|
||||
@@ -36,6 +38,8 @@ void iso14443_crc_append(Iso14443CrcType type, BitBuffer* buf) {
|
||||
}
|
||||
|
||||
bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
if(data_size <= ISO14443_CRC_SIZE) return false;
|
||||
|
||||
@@ -50,8 +54,9 @@ bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) {
|
||||
}
|
||||
|
||||
void iso14443_crc_trim(BitBuffer* buf) {
|
||||
furi_check(buf);
|
||||
const size_t data_size = bit_buffer_get_size_bytes(buf);
|
||||
furi_assert(data_size > ISO14443_CRC_SIZE);
|
||||
furi_check(data_size > ISO14443_CRC_SIZE);
|
||||
|
||||
bit_buffer_set_size_bytes(buf, data_size - ISO14443_CRC_SIZE);
|
||||
}
|
||||
|
||||
@@ -552,9 +552,14 @@ static const NfcDataGenerator nfc_data_generator[NfcDataGeneratorTypeNum] = {
|
||||
};
|
||||
|
||||
const char* nfc_data_generator_get_name(NfcDataGeneratorType type) {
|
||||
furi_check(type < NfcDataGeneratorTypeNum);
|
||||
|
||||
return nfc_data_generator[type].name;
|
||||
}
|
||||
|
||||
void nfc_data_generator_fill_data(NfcDataGeneratorType type, NfcDevice* nfc_device) {
|
||||
furi_check(type < NfcDataGeneratorTypeNum);
|
||||
furi_check(nfc_device);
|
||||
|
||||
nfc_data_generator[type].handler(nfc_device);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ uint8_t nfc_util_odd_parity8(uint8_t data) {
|
||||
}
|
||||
|
||||
void nfc_util_odd_parity(const uint8_t* src, uint8_t* dst, uint8_t len) {
|
||||
furi_assert(src);
|
||||
furi_assert(dst);
|
||||
furi_check(src);
|
||||
furi_check(dst);
|
||||
|
||||
uint8_t parity = 0;
|
||||
uint8_t bit = 0;
|
||||
|
||||
+40
-42
@@ -235,7 +235,7 @@ static int32_t nfc_worker_poller(void* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Nfc* nfc_alloc() {
|
||||
Nfc* nfc_alloc(void) {
|
||||
furi_check(furi_hal_nfc_acquire() == FuriHalNfcErrorNone);
|
||||
|
||||
Nfc* instance = malloc(sizeof(Nfc));
|
||||
@@ -253,8 +253,8 @@ Nfc* nfc_alloc() {
|
||||
}
|
||||
|
||||
void nfc_free(Nfc* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == NfcStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == NfcStateIdle);
|
||||
|
||||
furi_thread_free(instance->worker_thread);
|
||||
free(instance);
|
||||
@@ -263,10 +263,10 @@ void nfc_free(Nfc* instance) {
|
||||
}
|
||||
|
||||
void nfc_config(Nfc* instance, NfcMode mode, NfcTech tech) {
|
||||
furi_assert(instance);
|
||||
furi_assert(mode < NfcModeNum);
|
||||
furi_assert(tech < NfcTechNum);
|
||||
furi_assert(instance->config_state == NfcConfigurationStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(mode < NfcModeNum);
|
||||
furi_check(tech < NfcTechNum);
|
||||
furi_check(instance->config_state == NfcConfigurationStateIdle);
|
||||
|
||||
FuriHalNfcTech hal_tech = nfc_tech_table[mode][tech];
|
||||
if(hal_tech == FuriHalNfcTechInvalid) {
|
||||
@@ -282,35 +282,35 @@ void nfc_config(Nfc* instance, NfcMode mode, NfcTech tech) {
|
||||
}
|
||||
|
||||
void nfc_set_fdt_poll_fc(Nfc* instance, uint32_t fdt_poll_fc) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->fdt_poll_fc = fdt_poll_fc;
|
||||
}
|
||||
|
||||
void nfc_set_fdt_listen_fc(Nfc* instance, uint32_t fdt_listen_fc) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->fdt_listen_fc = fdt_listen_fc;
|
||||
}
|
||||
|
||||
void nfc_set_fdt_poll_poll_us(Nfc* instance, uint32_t fdt_poll_poll_us) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->fdt_poll_poll_us = fdt_poll_poll_us;
|
||||
}
|
||||
|
||||
void nfc_set_guard_time_us(Nfc* instance, uint32_t guard_time_us) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->guard_time_us = guard_time_us;
|
||||
}
|
||||
|
||||
void nfc_set_mask_receive_time_fc(Nfc* instance, uint32_t mask_rx_time_fc) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
instance->mask_rx_time_fc = mask_rx_time_fc;
|
||||
}
|
||||
|
||||
void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->worker_thread);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->config_state == NfcConfigurationStateDone);
|
||||
furi_check(instance);
|
||||
furi_check(instance->worker_thread);
|
||||
furi_check(callback);
|
||||
furi_check(instance->config_state == NfcConfigurationStateDone);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -324,8 +324,8 @@ void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
|
||||
}
|
||||
|
||||
void nfc_stop(Nfc* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == NfcStateRunning);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == NfcStateRunning);
|
||||
|
||||
if(instance->mode == NfcModeListener) {
|
||||
furi_hal_nfc_abort();
|
||||
@@ -336,8 +336,8 @@ void nfc_stop(Nfc* instance) {
|
||||
}
|
||||
|
||||
NfcError nfc_listener_tx(Nfc* instance, const BitBuffer* tx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
|
||||
@@ -409,11 +409,11 @@ NfcError nfc_iso14443a_poller_trx_custom_parity(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -462,11 +462,11 @@ NfcError nfc_iso14443a_poller_trx_custom_parity(
|
||||
|
||||
NfcError
|
||||
nfc_poller_trx(Nfc* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -511,7 +511,7 @@ NfcError nfc_iso14443a_listener_set_col_res_data(
|
||||
uint8_t uid_len,
|
||||
uint8_t* atqa,
|
||||
uint8_t sak) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
FuriHalNfcError error =
|
||||
furi_hal_nfc_iso14443a_listener_set_col_res_data(uid, uid_len, atqa, sak);
|
||||
@@ -524,14 +524,14 @@ NfcError nfc_iso14443a_poller_trx_short_frame(
|
||||
NfcIso14443aShortFrame frame,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
FuriHalNfcaShortFrame short_frame = (frame == NfcIso14443aShortFrameAllReqa) ?
|
||||
FuriHalNfcaShortFrameAllReq :
|
||||
FuriHalNfcaShortFrameSensReq;
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -574,11 +574,11 @@ NfcError nfc_iso14443a_poller_trx_sdd_frame(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
furi_assert(instance->poller_state == NfcPollerStateReady);
|
||||
furi_check(instance->poller_state == NfcPollerStateReady);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -618,8 +618,8 @@ NfcError nfc_iso14443a_poller_trx_sdd_frame(
|
||||
}
|
||||
|
||||
NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer* tx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
|
||||
NfcError ret = NfcErrorNone;
|
||||
FuriHalNfcError error = FuriHalNfcErrorNone;
|
||||
@@ -635,7 +635,7 @@ NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer*
|
||||
}
|
||||
|
||||
NfcError nfc_iso15693_listener_tx_sof(Nfc* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
while(furi_hal_nfc_timer_block_tx_is_running()) {
|
||||
}
|
||||
@@ -652,9 +652,7 @@ NfcError nfc_felica_listener_set_sensf_res_data(
|
||||
const uint8_t idm_len,
|
||||
const uint8_t* pmm,
|
||||
const uint8_t pmm_len) {
|
||||
furi_assert(instance);
|
||||
furi_assert(idm);
|
||||
furi_assert(pmm);
|
||||
furi_check(instance);
|
||||
|
||||
FuriHalNfcError error =
|
||||
furi_hal_nfc_felica_listener_set_sensf_res_data(idm, idm_len, pmm, pmm_len);
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ typedef enum {
|
||||
*
|
||||
* @returns pointer to the allocated Nfc instance.
|
||||
*/
|
||||
Nfc* nfc_alloc();
|
||||
Nfc* nfc_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Delete an Nfc instance.
|
||||
|
||||
+34
-30
@@ -14,7 +14,7 @@
|
||||
|
||||
#define NFC_DEVICE_UID_MAX_LEN (10U)
|
||||
|
||||
NfcDevice* nfc_device_alloc() {
|
||||
NfcDevice* nfc_device_alloc(void) {
|
||||
NfcDevice* instance = malloc(sizeof(NfcDevice));
|
||||
instance->protocol = NfcProtocolInvalid;
|
||||
|
||||
@@ -22,14 +22,14 @@ NfcDevice* nfc_device_alloc() {
|
||||
}
|
||||
|
||||
void nfc_device_free(NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_device_clear(instance);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void nfc_device_clear(NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
if(instance->protocol == NfcProtocolInvalid) {
|
||||
furi_assert(instance->protocol_data == NULL);
|
||||
@@ -43,8 +43,8 @@ void nfc_device_clear(NfcDevice* instance) {
|
||||
}
|
||||
|
||||
void nfc_device_reset(NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
if(instance->protocol_data) {
|
||||
nfc_devices[instance->protocol]->reset(instance->protocol_data);
|
||||
@@ -52,37 +52,40 @@ void nfc_device_reset(NfcDevice* instance) {
|
||||
}
|
||||
|
||||
NfcProtocol nfc_device_get_protocol(const NfcDevice* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
return instance->protocol;
|
||||
}
|
||||
|
||||
const NfcDeviceData* nfc_device_get_data(const NfcDevice* instance, NfcProtocol protocol) {
|
||||
furi_check(instance);
|
||||
return nfc_device_get_data_ptr(instance, protocol);
|
||||
}
|
||||
|
||||
const char* nfc_device_get_protocol_name(NfcProtocol protocol) {
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[protocol]->protocol_name;
|
||||
}
|
||||
|
||||
const char* nfc_device_get_name(const NfcDevice* instance, NfcDeviceNameType name_type) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[instance->protocol]->get_name(instance->protocol_data, name_type);
|
||||
}
|
||||
|
||||
const uint8_t* nfc_device_get_uid(const NfcDevice* instance, size_t* uid_len) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(uid_len);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[instance->protocol]->get_uid(instance->protocol_data, uid_len);
|
||||
}
|
||||
|
||||
bool nfc_device_set_uid(NfcDevice* instance, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(uid);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_devices[instance->protocol]->set_uid(instance->protocol_data, uid, uid_len);
|
||||
}
|
||||
@@ -91,8 +94,9 @@ void nfc_device_set_data(
|
||||
NfcDevice* instance,
|
||||
NfcProtocol protocol,
|
||||
const NfcDeviceData* protocol_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(instance);
|
||||
furi_check(protocol_data);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
nfc_device_clear(instance);
|
||||
|
||||
@@ -106,9 +110,9 @@ void nfc_device_copy_data(
|
||||
const NfcDevice* instance,
|
||||
NfcProtocol protocol,
|
||||
NfcDeviceData* protocol_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(protocol_data);
|
||||
furi_check(instance);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(protocol_data);
|
||||
|
||||
if(instance->protocol != protocol) {
|
||||
furi_crash(NFC_DEV_TYPE_ERROR);
|
||||
@@ -121,17 +125,17 @@ bool nfc_device_is_equal_data(
|
||||
const NfcDevice* instance,
|
||||
NfcProtocol protocol,
|
||||
const NfcDeviceData* protocol_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(protocol_data);
|
||||
furi_check(instance);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(protocol_data);
|
||||
|
||||
return instance->protocol == protocol &&
|
||||
nfc_devices[protocol]->is_equal(instance->protocol_data, protocol_data);
|
||||
}
|
||||
|
||||
bool nfc_device_is_equal(const NfcDevice* instance, const NfcDevice* other) {
|
||||
furi_assert(instance);
|
||||
furi_assert(other);
|
||||
furi_check(instance);
|
||||
furi_check(other);
|
||||
|
||||
return nfc_device_is_equal_data(instance, other->protocol, other->protocol_data);
|
||||
}
|
||||
@@ -140,17 +144,17 @@ void nfc_device_set_loading_callback(
|
||||
NfcDevice* instance,
|
||||
NfcLoadingCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
|
||||
instance->loading_callback = callback;
|
||||
instance->loading_callback_context = context;
|
||||
}
|
||||
|
||||
bool nfc_device_save(NfcDevice* instance, const char* path) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol < NfcProtocolNum);
|
||||
furi_assert(path);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol < NfcProtocolNum);
|
||||
furi_check(path);
|
||||
|
||||
bool saved = false;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
@@ -313,8 +317,8 @@ static bool nfc_device_load_legacy(NfcDevice* instance, FlipperFormat* ff, uint3
|
||||
}
|
||||
|
||||
bool nfc_device_load(NfcDevice* instance, const char* path) {
|
||||
furi_assert(instance);
|
||||
furi_assert(path);
|
||||
furi_check(instance);
|
||||
furi_check(path);
|
||||
|
||||
bool loaded = false;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -47,7 +47,7 @@ typedef void (*NfcLoadingCallback)(void* context, bool state);
|
||||
*
|
||||
* @returns pointer to the allocated instance.
|
||||
*/
|
||||
NfcDevice* nfc_device_alloc();
|
||||
NfcDevice* nfc_device_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Delete an NfcDevice instance.
|
||||
|
||||
+10
-10
@@ -73,10 +73,10 @@ static void nfc_listener_list_free(NfcListener* instance) {
|
||||
}
|
||||
|
||||
NfcListener* nfc_listener_alloc(Nfc* nfc, NfcProtocol protocol, const NfcDeviceData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(data);
|
||||
furi_assert(nfc_listeners_api[protocol]);
|
||||
furi_check(nfc);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(data);
|
||||
furi_check(nfc_listeners_api[protocol]);
|
||||
|
||||
NfcListener* instance = malloc(sizeof(NfcListener));
|
||||
instance->nfc = nfc;
|
||||
@@ -89,7 +89,7 @@ NfcListener* nfc_listener_alloc(Nfc* nfc, NfcProtocol protocol, const NfcDeviceD
|
||||
}
|
||||
|
||||
void nfc_listener_free(NfcListener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_listener_list_free(instance);
|
||||
nfc_device_free(instance->nfc_dev);
|
||||
@@ -116,7 +116,7 @@ NfcCommand nfc_listener_start_callback(NfcEvent event, void* context) {
|
||||
}
|
||||
|
||||
void nfc_listener_start(NfcListener* instance, NfcGenericCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
NfcListenerListElement* tail_element = instance->list.tail;
|
||||
tail_element->listener_api->set_callback(tail_element->listener, callback, context);
|
||||
@@ -124,20 +124,20 @@ void nfc_listener_start(NfcListener* instance, NfcGenericCallback callback, void
|
||||
}
|
||||
|
||||
void nfc_listener_stop(NfcListener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_stop(instance->nfc);
|
||||
}
|
||||
|
||||
NfcProtocol nfc_listener_get_protocol(const NfcListener* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->protocol;
|
||||
}
|
||||
|
||||
const NfcDeviceData* nfc_listener_get_data(const NfcListener* instance, NfcProtocol protocol) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol == protocol);
|
||||
furi_check(instance);
|
||||
furi_check(instance->protocol == protocol);
|
||||
|
||||
NfcListenerListElement* tail_element = instance->list.tail;
|
||||
return tail_element->listener_api->get_data(tail_element->listener);
|
||||
|
||||
+15
-15
@@ -75,8 +75,8 @@ static void nfc_poller_list_free(NfcPoller* instance) {
|
||||
}
|
||||
|
||||
NfcPoller* nfc_poller_alloc(Nfc* nfc, NfcProtocol protocol) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(nfc);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
NfcPoller* instance = malloc(sizeof(NfcPoller));
|
||||
instance->session_state = NfcPollerSessionStateIdle;
|
||||
@@ -88,7 +88,7 @@ NfcPoller* nfc_poller_alloc(Nfc* nfc, NfcProtocol protocol) {
|
||||
}
|
||||
|
||||
void nfc_poller_free(NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
nfc_poller_list_free(instance);
|
||||
free(instance);
|
||||
@@ -119,9 +119,9 @@ static NfcCommand nfc_poller_start_callback(NfcEvent event, void* context) {
|
||||
}
|
||||
|
||||
void nfc_poller_start(NfcPoller* instance, NfcGenericCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->session_state == NfcPollerSessionStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
furi_check(instance->session_state == NfcPollerSessionStateIdle);
|
||||
|
||||
NfcPollerListElement* tail_poller = instance->list.tail;
|
||||
tail_poller->poller_api->set_callback(tail_poller->poller, callback, context);
|
||||
@@ -180,9 +180,9 @@ static NfcCommand nfc_poller_start_ex_head_callback(NfcEvent event, void* contex
|
||||
}
|
||||
|
||||
void nfc_poller_start_ex(NfcPoller* instance, NfcGenericCallbackEx callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->session_state == NfcPollerSessionStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
furi_check(instance->session_state == NfcPollerSessionStateIdle);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -200,8 +200,8 @@ void nfc_poller_start_ex(NfcPoller* instance, NfcGenericCallbackEx callback, voi
|
||||
}
|
||||
|
||||
void nfc_poller_stop(NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
instance->session_state = NfcPollerSessionStateStopRequest;
|
||||
nfc_stop(instance->nfc);
|
||||
@@ -246,8 +246,8 @@ static NfcCommand nfc_poller_detect_head_callback(NfcEvent event, void* context)
|
||||
}
|
||||
|
||||
bool nfc_poller_detect(NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->session_state == NfcPollerSessionStateIdle);
|
||||
furi_check(instance);
|
||||
furi_check(instance->session_state == NfcPollerSessionStateIdle);
|
||||
|
||||
instance->session_state = NfcPollerSessionStateActive;
|
||||
NfcPollerListElement* tail_poller = instance->list.tail;
|
||||
@@ -270,13 +270,13 @@ bool nfc_poller_detect(NfcPoller* instance) {
|
||||
}
|
||||
|
||||
NfcProtocol nfc_poller_get_protocol(const NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->protocol;
|
||||
}
|
||||
|
||||
const NfcDeviceData* nfc_poller_get_data(const NfcPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
NfcPollerListElement* tail_poller = instance->list.tail;
|
||||
return tail_poller->poller_api->get_data(tail_poller->poller);
|
||||
|
||||
@@ -218,7 +218,7 @@ static int32_t nfc_scanner_worker(void* context) {
|
||||
}
|
||||
|
||||
NfcScanner* nfc_scanner_alloc(Nfc* nfc) {
|
||||
furi_assert(nfc);
|
||||
furi_check(nfc);
|
||||
|
||||
NfcScanner* instance = malloc(sizeof(NfcScanner));
|
||||
instance->nfc = nfc;
|
||||
@@ -227,16 +227,17 @@ NfcScanner* nfc_scanner_alloc(Nfc* nfc) {
|
||||
}
|
||||
|
||||
void nfc_scanner_free(NfcScanner* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(instance->state == NfcScannerStateIdle);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void nfc_scanner_start(NfcScanner* instance, NfcScannerCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_assert(instance->session_state == NfcScannerSessionStateIdle);
|
||||
furi_assert(instance->scan_worker == NULL);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
furi_check(instance->state == NfcScannerStateIdle);
|
||||
furi_check(instance->scan_worker == NULL);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -252,8 +253,8 @@ void nfc_scanner_start(NfcScanner* instance, NfcScannerCallback callback, void*
|
||||
}
|
||||
|
||||
void nfc_scanner_stop(NfcScanner* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->scan_worker);
|
||||
furi_check(instance);
|
||||
furi_check(instance->scan_worker);
|
||||
|
||||
instance->session_state = NfcScannerSessionStateStopRequest;
|
||||
furi_thread_join(instance->scan_worker);
|
||||
|
||||
@@ -29,7 +29,7 @@ const NfcDeviceBase nfc_device_felica = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)felica_get_base_data,
|
||||
};
|
||||
|
||||
FelicaData* felica_alloc() {
|
||||
FelicaData* felica_alloc(void) {
|
||||
FelicaData* data = malloc(sizeof(FelicaData));
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_felica;
|
||||
|
||||
FelicaData* felica_alloc();
|
||||
FelicaData* felica_alloc(void);
|
||||
|
||||
void felica_free(FelicaData* data);
|
||||
|
||||
|
||||
@@ -28,36 +28,40 @@ const NfcDeviceBase nfc_device_iso14443_3a = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_3a_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_3aData* iso14443_3a_alloc() {
|
||||
Iso14443_3aData* iso14443_3a_alloc(void) {
|
||||
Iso14443_3aData* data = malloc(sizeof(Iso14443_3aData));
|
||||
return data;
|
||||
}
|
||||
|
||||
void iso14443_3a_free(Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void iso14443_3a_reset(Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
memset(data, 0, sizeof(Iso14443_3aData));
|
||||
}
|
||||
|
||||
void iso14443_3a_copy(Iso14443_3aData* data, const Iso14443_3aData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
*data = *other;
|
||||
}
|
||||
|
||||
bool iso14443_3a_verify(Iso14443_3aData* data, const FuriString* device_type) {
|
||||
UNUSED(data);
|
||||
furi_check(device_type);
|
||||
|
||||
return furi_string_equal(device_type, ISO14443_3A_PROTOCOL_NAME_LEGACY);
|
||||
}
|
||||
|
||||
bool iso14443_3a_load(Iso14443_3aData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -78,7 +82,8 @@ bool iso14443_3a_load(Iso14443_3aData* data, FlipperFormat* ff, uint32_t version
|
||||
}
|
||||
|
||||
bool iso14443_3a_save(const Iso14443_3aData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -98,8 +103,8 @@ bool iso14443_3a_save(const Iso14443_3aData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso14443_3a_is_equal(const Iso14443_3aData* data, const Iso14443_3aData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data, other, sizeof(Iso14443_3aData)) == 0;
|
||||
}
|
||||
@@ -111,7 +116,7 @@ const char* iso14443_3a_get_device_name(const Iso14443_3aData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_3a_get_uid(const Iso14443_3aData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(uid_len) {
|
||||
*uid_len = data->uid_len;
|
||||
@@ -121,7 +126,8 @@ const uint8_t* iso14443_3a_get_uid(const Iso14443_3aData* data, size_t* uid_len)
|
||||
}
|
||||
|
||||
bool iso14443_3a_set_uid(Iso14443_3aData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
const bool uid_valid = uid_len == ISO14443_3A_UID_4_BYTES ||
|
||||
uid_len == ISO14443_3A_UID_7_BYTES ||
|
||||
@@ -141,7 +147,7 @@ Iso14443_3aData* iso14443_3a_get_base_data(const Iso14443_3aData* data) {
|
||||
}
|
||||
|
||||
uint32_t iso14443_3a_get_cuid(const Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint32_t cuid = 0;
|
||||
const uint8_t* cuid_start = data->uid;
|
||||
@@ -154,33 +160,33 @@ uint32_t iso14443_3a_get_cuid(const Iso14443_3aData* data) {
|
||||
}
|
||||
|
||||
bool iso14443_3a_supports_iso14443_4(const Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->sak & ISO14443A_ATS_BIT;
|
||||
}
|
||||
|
||||
uint8_t iso14443_3a_get_sak(const Iso14443_3aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->sak;
|
||||
}
|
||||
|
||||
void iso14443_3a_get_atqa(const Iso14443_3aData* data, uint8_t atqa[2]) {
|
||||
furi_assert(data);
|
||||
furi_assert(atqa);
|
||||
furi_check(data);
|
||||
furi_check(atqa);
|
||||
|
||||
memcpy(atqa, data->atqa, sizeof(data->atqa));
|
||||
}
|
||||
|
||||
void iso14443_3a_set_sak(Iso14443_3aData* data, uint8_t sak) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
data->sak = sak;
|
||||
}
|
||||
|
||||
void iso14443_3a_set_atqa(Iso14443_3aData* data, const uint8_t atqa[2]) {
|
||||
furi_assert(data);
|
||||
furi_assert(atqa);
|
||||
furi_check(data);
|
||||
furi_check(atqa);
|
||||
|
||||
memcpy(data->atqa, atqa, sizeof(data->atqa));
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef struct {
|
||||
uint8_t sak;
|
||||
} Iso14443_3aData;
|
||||
|
||||
Iso14443_3aData* iso14443_3a_alloc();
|
||||
Iso14443_3aData* iso14443_3a_alloc(void);
|
||||
|
||||
void iso14443_3a_free(Iso14443_3aData* data);
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ static Iso14443_3aError iso14443_3a_poller_standard_frame_exchange(
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
NfcError error = NfcErrorNone;
|
||||
Iso14443_3aError ret = Iso14443_3aErrorNone;
|
||||
@@ -80,9 +80,9 @@ Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance)
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(instance->tx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(instance->tx_buffer);
|
||||
|
||||
uint8_t halt_cmd[2] = {0x50, 0x00};
|
||||
bit_buffer_copy_bytes(instance->tx_buffer, halt_cmd, sizeof(halt_cmd));
|
||||
@@ -96,10 +96,10 @@ Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance) {
|
||||
|
||||
Iso14443_3aError
|
||||
iso14443_3a_poller_activate(Iso14443_3aPoller* instance, Iso14443_3aData* iso14443_3a_data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(instance->tx_buffer);
|
||||
furi_assert(instance->rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(instance->tx_buffer);
|
||||
furi_check(instance->rx_buffer);
|
||||
|
||||
// Reset Iso14443_3a poller state
|
||||
memset(&instance->col_res, 0, sizeof(instance->col_res));
|
||||
@@ -244,9 +244,9 @@ Iso14443_3aError iso14443_3a_poller_txrx_custom_parity(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3aError ret = Iso14443_3aErrorNone;
|
||||
NfcError error =
|
||||
@@ -263,9 +263,9 @@ Iso14443_3aError iso14443_3a_poller_txrx(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3aError ret = Iso14443_3aErrorNone;
|
||||
NfcError error = nfc_poller_trx(instance->nfc, tx_buffer, rx_buffer, fwt);
|
||||
@@ -281,9 +281,9 @@ Iso14443_3aError iso14443_3a_poller_send_standard_frame(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3aError ret =
|
||||
iso14443_3a_poller_standard_frame_exchange(instance, tx_buffer, rx_buffer, fwt);
|
||||
|
||||
@@ -35,8 +35,8 @@ NfcCommand iso14443_3a_poller_read_callback(NfcGenericEvent event, void* context
|
||||
}
|
||||
|
||||
Iso14443_3aError iso14443_3a_poller_sync_read(Nfc* nfc, Iso14443_3aData* iso14443_3a_data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(iso14443_3a_data);
|
||||
furi_check(nfc);
|
||||
furi_check(iso14443_3a_data);
|
||||
|
||||
Iso14443_3aPollerContext poller_context = {};
|
||||
poller_context.thread_id = furi_thread_get_current_id();
|
||||
|
||||
@@ -30,24 +30,26 @@ const NfcDeviceBase nfc_device_iso14443_3b = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_3b_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_3bData* iso14443_3b_alloc() {
|
||||
Iso14443_3bData* iso14443_3b_alloc(void) {
|
||||
Iso14443_3bData* data = malloc(sizeof(Iso14443_3bData));
|
||||
return data;
|
||||
}
|
||||
|
||||
void iso14443_3b_free(Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void iso14443_3b_reset(Iso14443_3bData* data) {
|
||||
furi_check(data);
|
||||
|
||||
memset(data, 0, sizeof(Iso14443_3bData));
|
||||
}
|
||||
|
||||
void iso14443_3b_copy(Iso14443_3bData* data, const Iso14443_3bData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
*data = *other;
|
||||
}
|
||||
@@ -60,7 +62,8 @@ bool iso14443_3b_verify(Iso14443_3bData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool iso14443_3b_load(Iso14443_3bData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -84,7 +87,8 @@ bool iso14443_3b_load(Iso14443_3bData* data, FlipperFormat* ff, uint32_t version
|
||||
}
|
||||
|
||||
bool iso14443_3b_save(const Iso14443_3bData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -107,8 +111,8 @@ bool iso14443_3b_save(const Iso14443_3bData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso14443_3b_is_equal(const Iso14443_3bData* data, const Iso14443_3bData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data, other, sizeof(Iso14443_3bData)) == 0;
|
||||
}
|
||||
@@ -121,15 +125,16 @@ const char* iso14443_3b_get_device_name(const Iso14443_3bData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_3b_get_uid(const Iso14443_3bData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_assert(uid_len);
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
*uid_len = ISO14443_3B_UID_SIZE;
|
||||
return data->uid;
|
||||
}
|
||||
|
||||
bool iso14443_3b_set_uid(Iso14443_3bData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
const bool uid_valid = uid_len == ISO14443_3B_UID_SIZE;
|
||||
|
||||
@@ -146,13 +151,13 @@ Iso14443_3bData* iso14443_3b_get_base_data(const Iso14443_3bData* data) {
|
||||
}
|
||||
|
||||
bool iso14443_3b_supports_iso14443_4(const Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->protocol_info.protocol_type == 0x01;
|
||||
}
|
||||
|
||||
bool iso14443_3b_supports_bit_rate(const Iso14443_3bData* data, Iso14443_3bBitRate bit_rate) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t capability = data->protocol_info.bit_rate_capability;
|
||||
|
||||
@@ -177,7 +182,7 @@ bool iso14443_3b_supports_bit_rate(const Iso14443_3bData* data, Iso14443_3bBitRa
|
||||
}
|
||||
|
||||
bool iso14443_3b_supports_frame_option(const Iso14443_3bData* data, Iso14443_3bFrameOption option) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
switch(option) {
|
||||
case Iso14443_3bFrameOptionNad:
|
||||
@@ -190,15 +195,15 @@ bool iso14443_3b_supports_frame_option(const Iso14443_3bData* data, Iso14443_3bF
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_3b_get_application_data(const Iso14443_3bData* data, size_t* data_size) {
|
||||
furi_assert(data);
|
||||
furi_assert(data_size);
|
||||
furi_check(data);
|
||||
furi_check(data_size);
|
||||
|
||||
*data_size = ISO14443_3B_APP_DATA_SIZE;
|
||||
return data->app_data;
|
||||
}
|
||||
|
||||
uint16_t iso14443_3b_get_frame_size_max(const Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t fs_bits = data->protocol_info.max_frame_size;
|
||||
|
||||
@@ -216,7 +221,7 @@ uint16_t iso14443_3b_get_frame_size_max(const Iso14443_3bData* data) {
|
||||
}
|
||||
|
||||
uint32_t iso14443_3b_get_fwt_fc_max(const Iso14443_3bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t fwi = data->protocol_info.fwi;
|
||||
return fwi < 0x0F ? 4096UL << fwi : ISO14443_3B_FDT_POLL_DEFAULT_FC;
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct Iso14443_3bData Iso14443_3bData;
|
||||
|
||||
// Virtual methods
|
||||
|
||||
Iso14443_3bData* iso14443_3b_alloc();
|
||||
Iso14443_3bData* iso14443_3b_alloc(void);
|
||||
|
||||
void iso14443_3b_free(Iso14443_3bData* data);
|
||||
|
||||
|
||||
@@ -64,8 +64,9 @@ static Iso14443_3bError iso14443_3b_poller_frame_exchange(
|
||||
}
|
||||
|
||||
Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso14443_3bData* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3b_reset(data);
|
||||
|
||||
@@ -155,7 +156,7 @@ Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso144
|
||||
}
|
||||
|
||||
Iso14443_3bError iso14443_3b_poller_halt(Iso14443_3bPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
@@ -188,6 +189,10 @@ Iso14443_3bError iso14443_3b_poller_send_frame(
|
||||
Iso14443_3bPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso14443_3bError ret;
|
||||
|
||||
do {
|
||||
|
||||
@@ -35,7 +35,7 @@ const NfcDeviceBase nfc_device_iso14443_4a = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_4a_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_4aData* iso14443_4a_alloc() {
|
||||
Iso14443_4aData* iso14443_4a_alloc(void) {
|
||||
Iso14443_4aData* data = malloc(sizeof(Iso14443_4aData));
|
||||
|
||||
data->iso14443_3a_data = iso14443_3a_alloc();
|
||||
@@ -45,7 +45,7 @@ Iso14443_4aData* iso14443_4a_alloc() {
|
||||
}
|
||||
|
||||
void iso14443_4a_free(Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
simple_array_free(data->ats_data.t1_tk);
|
||||
iso14443_3a_free(data->iso14443_3a_data);
|
||||
@@ -54,7 +54,7 @@ void iso14443_4a_free(Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
void iso14443_4a_reset(Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_reset(data->iso14443_3a_data);
|
||||
|
||||
@@ -68,8 +68,8 @@ void iso14443_4a_reset(Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
void iso14443_4a_copy(Iso14443_4aData* data, const Iso14443_4aData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
|
||||
@@ -91,7 +91,8 @@ bool iso14443_4a_verify(Iso14443_4aData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool iso14443_4a_load(Iso14443_4aData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -145,7 +146,8 @@ bool iso14443_4a_load(Iso14443_4aData* data, FlipperFormat* ff, uint32_t version
|
||||
}
|
||||
|
||||
bool iso14443_4a_save(const Iso14443_4aData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -186,6 +188,9 @@ bool iso14443_4a_save(const Iso14443_4aData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso14443_4a_is_equal(const Iso14443_4aData* data, const Iso14443_4aData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso14443_3a_is_equal(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
}
|
||||
|
||||
@@ -196,23 +201,26 @@ const char* iso14443_4a_get_device_name(const Iso14443_4aData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_4a_get_uid(const Iso14443_4aData* data, size_t* uid_len) {
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len);
|
||||
}
|
||||
|
||||
bool iso14443_4a_set_uid(Iso14443_4aData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len);
|
||||
}
|
||||
|
||||
Iso14443_3aData* iso14443_4a_get_base_data(const Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3a_data;
|
||||
}
|
||||
|
||||
uint16_t iso14443_4a_get_frame_size_max(const Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const uint8_t fsci = data->ats_data.t0 & 0x0F;
|
||||
|
||||
@@ -230,7 +238,7 @@ uint16_t iso14443_4a_get_frame_size_max(const Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
uint32_t iso14443_4a_get_fwt_fc_max(const Iso14443_4aData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint32_t fwt_fc_max = ISO14443_4A_FDT_DEFAULT_FC;
|
||||
|
||||
@@ -248,8 +256,8 @@ uint32_t iso14443_4a_get_fwt_fc_max(const Iso14443_4aData* data) {
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uint32_t* count) {
|
||||
furi_assert(data);
|
||||
furi_assert(count);
|
||||
furi_check(data);
|
||||
furi_check(count);
|
||||
|
||||
*count = simple_array_get_count(data->ats_data.t1_tk);
|
||||
const uint8_t* hist_bytes = NULL;
|
||||
@@ -261,7 +269,7 @@ const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uin
|
||||
}
|
||||
|
||||
bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRate bit_rate) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(!(data->ats_data.t0 & ISO14443_4A_ATS_T0_TA1))
|
||||
return bit_rate == Iso14443_4aBitRateBoth106Kbit;
|
||||
@@ -289,7 +297,7 @@ bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRa
|
||||
}
|
||||
|
||||
bool iso14443_4a_supports_frame_option(const Iso14443_4aData* data, Iso14443_4aFrameOption option) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const Iso14443_4aAtsData* ats_data = &data->ats_data;
|
||||
if(!(ats_data->t0 & ISO14443_4A_ATS_T0_TC1)) return false;
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef struct {
|
||||
|
||||
// Virtual methods
|
||||
|
||||
Iso14443_4aData* iso14443_4a_alloc();
|
||||
Iso14443_4aData* iso14443_4a_alloc(void);
|
||||
|
||||
void iso14443_4a_free(Iso14443_4aData* data);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define ISO14443_4A_FSDI_256 (0x8U)
|
||||
|
||||
Iso14443_4aError iso14443_4a_poller_halt(Iso14443_4aPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
iso14443_3a_poller_halt(instance->iso14443_3a_poller);
|
||||
instance->poller_state = Iso14443_4aPollerStateIdle;
|
||||
@@ -19,7 +19,8 @@ Iso14443_4aError iso14443_4a_poller_halt(Iso14443_4aPoller* instance) {
|
||||
|
||||
Iso14443_4aError
|
||||
iso14443_4a_poller_read_ats(Iso14443_4aPoller* instance, Iso14443_4aAtsData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_append_byte(instance->tx_buffer, ISO14443_4A_CMD_READ_ATS);
|
||||
@@ -54,7 +55,9 @@ Iso14443_4aError iso14443_4a_poller_send_block(
|
||||
Iso14443_4aPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer);
|
||||
|
||||
@@ -22,7 +22,7 @@ const NfcDeviceBase nfc_device_iso14443_4b = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso14443_4b_get_base_data,
|
||||
};
|
||||
|
||||
Iso14443_4bData* iso14443_4b_alloc() {
|
||||
Iso14443_4bData* iso14443_4b_alloc(void) {
|
||||
Iso14443_4bData* data = malloc(sizeof(Iso14443_4bData));
|
||||
|
||||
data->iso14443_3b_data = iso14443_3b_alloc();
|
||||
@@ -30,21 +30,21 @@ Iso14443_4bData* iso14443_4b_alloc() {
|
||||
}
|
||||
|
||||
void iso14443_4b_free(Iso14443_4bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3b_free(data->iso14443_3b_data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void iso14443_4b_reset(Iso14443_4bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3b_reset(data->iso14443_3b_data);
|
||||
}
|
||||
|
||||
void iso14443_4b_copy(Iso14443_4bData* data, const Iso14443_4bData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3b_copy(data->iso14443_3b_data, other->iso14443_3b_data);
|
||||
}
|
||||
@@ -58,16 +58,21 @@ bool iso14443_4b_verify(Iso14443_4bData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool iso14443_4b_load(Iso14443_4bData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
return iso14443_3b_load(data->iso14443_3b_data, ff, version);
|
||||
}
|
||||
|
||||
bool iso14443_4b_save(const Iso14443_4bData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
return iso14443_3b_save(data->iso14443_3b_data, ff);
|
||||
}
|
||||
|
||||
bool iso14443_4b_is_equal(const Iso14443_4bData* data, const Iso14443_4bData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso14443_3b_is_equal(data->iso14443_3b_data, other->iso14443_3b_data);
|
||||
}
|
||||
|
||||
@@ -78,17 +83,21 @@ const char* iso14443_4b_get_device_name(const Iso14443_4bData* data, NfcDeviceNa
|
||||
}
|
||||
|
||||
const uint8_t* iso14443_4b_get_uid(const Iso14443_4bData* data, size_t* uid_len) {
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
return iso14443_3b_get_uid(data->iso14443_3b_data, uid_len);
|
||||
}
|
||||
|
||||
bool iso14443_4b_set_uid(Iso14443_4bData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
return iso14443_3b_set_uid(data->iso14443_3b_data, uid, uid_len);
|
||||
}
|
||||
|
||||
Iso14443_3bData* iso14443_4b_get_base_data(const Iso14443_4bData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3b_data;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef struct Iso14443_4bData Iso14443_4bData;
|
||||
|
||||
// Virtual methods
|
||||
|
||||
Iso14443_4bData* iso14443_4b_alloc();
|
||||
Iso14443_4bData* iso14443_4b_alloc(void);
|
||||
|
||||
void iso14443_4b_free(Iso14443_4bData* data);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define TAG "Iso14443_4bPoller"
|
||||
|
||||
Iso14443_4bError iso14443_4b_poller_halt(Iso14443_4bPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
iso14443_3b_poller_halt(instance->iso14443_3b_poller);
|
||||
instance->poller_state = Iso14443_4bPollerStateIdle;
|
||||
@@ -19,7 +19,9 @@ Iso14443_4bError iso14443_4b_poller_send_block(
|
||||
Iso14443_4bPoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer);
|
||||
|
||||
@@ -36,7 +36,7 @@ const NfcDeviceBase nfc_device_iso15693_3 = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)iso15693_3_get_base_data,
|
||||
};
|
||||
|
||||
Iso15693_3Data* iso15693_3_alloc() {
|
||||
Iso15693_3Data* iso15693_3_alloc(void) {
|
||||
Iso15693_3Data* data = malloc(sizeof(Iso15693_3Data));
|
||||
|
||||
data->block_data = simple_array_alloc(&simple_array_config_uint8_t);
|
||||
@@ -46,7 +46,7 @@ Iso15693_3Data* iso15693_3_alloc() {
|
||||
}
|
||||
|
||||
void iso15693_3_free(Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
simple_array_free(data->block_data);
|
||||
simple_array_free(data->block_security);
|
||||
@@ -54,7 +54,7 @@ void iso15693_3_free(Iso15693_3Data* data) {
|
||||
}
|
||||
|
||||
void iso15693_3_reset(Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
memset(data->uid, 0, ISO15693_3_UID_SIZE);
|
||||
memset(&data->system_info, 0, sizeof(Iso15693_3SystemInfo));
|
||||
@@ -65,8 +65,8 @@ void iso15693_3_reset(Iso15693_3Data* data) {
|
||||
}
|
||||
|
||||
void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
memcpy(data->uid, other->uid, ISO15693_3_UID_SIZE);
|
||||
|
||||
@@ -79,6 +79,8 @@ void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other) {
|
||||
|
||||
bool iso15693_3_verify(Iso15693_3Data* data, const FuriString* device_type) {
|
||||
UNUSED(data);
|
||||
furi_check(device_type);
|
||||
|
||||
return furi_string_equal(device_type, ISO15693_3_PROTOCOL_NAME_LEGACY);
|
||||
}
|
||||
|
||||
@@ -136,7 +138,8 @@ static inline bool iso15693_3_load_security(Iso15693_3Data* data, FlipperFormat*
|
||||
}
|
||||
|
||||
bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
UNUSED(version);
|
||||
|
||||
bool loaded = false;
|
||||
@@ -207,7 +210,8 @@ bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version)
|
||||
}
|
||||
|
||||
bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -280,12 +284,15 @@ bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool iso15693_3_is_equal(const Iso15693_3Data* data, const Iso15693_3Data* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data->uid, other->uid, ISO15693_3_UID_SIZE) == 0 &&
|
||||
memcmp(&data->settings, &other->settings, sizeof(Iso15693_3Settings)) == 0 &&
|
||||
memcmp(&data->system_info, &other->system_info, sizeof(Iso15693_3SystemInfo)) == 0 &&
|
||||
memcmp( //-V1103
|
||||
&data->system_info,
|
||||
&other->system_info,
|
||||
sizeof(Iso15693_3SystemInfo)) == 0 &&
|
||||
simple_array_is_equal(data->block_data, other->block_data) &&
|
||||
simple_array_is_equal(data->block_security, other->block_security);
|
||||
}
|
||||
@@ -298,15 +305,15 @@ const char* iso15693_3_get_device_name(const Iso15693_3Data* data, NfcDeviceName
|
||||
}
|
||||
|
||||
const uint8_t* iso15693_3_get_uid(const Iso15693_3Data* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(uid_len) *uid_len = ISO15693_3_UID_SIZE;
|
||||
return data->uid;
|
||||
}
|
||||
|
||||
bool iso15693_3_set_uid(Iso15693_3Data* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_assert(uid);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
bool uid_valid = uid_len == ISO15693_3_UID_SIZE;
|
||||
|
||||
@@ -325,33 +332,33 @@ Iso15693_3Data* iso15693_3_get_base_data(const Iso15693_3Data* data) {
|
||||
}
|
||||
|
||||
bool iso15693_3_is_block_locked(const Iso15693_3Data* data, uint8_t block_index) {
|
||||
furi_assert(data);
|
||||
furi_assert(block_index < data->system_info.block_count);
|
||||
furi_check(data);
|
||||
furi_check(block_index < data->system_info.block_count);
|
||||
|
||||
return *(const uint8_t*)simple_array_cget(data->block_security, block_index);
|
||||
}
|
||||
|
||||
uint8_t iso15693_3_get_manufacturer_id(const Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->uid[1];
|
||||
}
|
||||
|
||||
uint16_t iso15693_3_get_block_count(const Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->system_info.block_count;
|
||||
}
|
||||
|
||||
uint8_t iso15693_3_get_block_size(const Iso15693_3Data* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->system_info.block_size;
|
||||
}
|
||||
|
||||
const uint8_t* iso15693_3_get_block_data(const Iso15693_3Data* data, uint8_t block_index) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->system_info.block_count > block_index);
|
||||
furi_check(data);
|
||||
furi_check(data->system_info.block_count > block_index);
|
||||
|
||||
return (const uint8_t*)simple_array_cget(
|
||||
data->block_data, block_index * data->system_info.block_size);
|
||||
|
||||
@@ -122,7 +122,7 @@ typedef struct {
|
||||
SimpleArray* block_security;
|
||||
} Iso15693_3Data;
|
||||
|
||||
Iso15693_3Data* iso15693_3_alloc();
|
||||
Iso15693_3Data* iso15693_3_alloc(void);
|
||||
|
||||
void iso15693_3_free(Iso15693_3Data* data);
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ Iso15693_3Error iso15693_3_poller_send_frame(
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
Iso15693_3Error ret = Iso15693_3ErrorNone;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#define BEBIT(x, n) FURI_BIT(x, (n) ^ 24)
|
||||
|
||||
Crypto1* crypto1_alloc() {
|
||||
Crypto1* crypto1_alloc(void) {
|
||||
Crypto1* instance = malloc(sizeof(Crypto1));
|
||||
|
||||
return instance;
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef struct {
|
||||
uint32_t even;
|
||||
} Crypto1;
|
||||
|
||||
Crypto1* crypto1_alloc();
|
||||
Crypto1* crypto1_alloc(void);
|
||||
|
||||
void crypto1_free(Crypto1* instance);
|
||||
|
||||
|
||||
@@ -56,28 +56,28 @@ const NfcDeviceBase nfc_device_mf_classic = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)mf_classic_get_base_data,
|
||||
};
|
||||
|
||||
MfClassicData* mf_classic_alloc() {
|
||||
MfClassicData* mf_classic_alloc(void) {
|
||||
MfClassicData* data = malloc(sizeof(MfClassicData));
|
||||
data->iso14443_3a_data = iso14443_3a_alloc();
|
||||
return data;
|
||||
}
|
||||
|
||||
void mf_classic_free(MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_free(data->iso14443_3a_data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void mf_classic_reset(MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_reset(data->iso14443_3a_data);
|
||||
}
|
||||
|
||||
void mf_classic_copy(MfClassicData* data, const MfClassicData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
for(size_t i = 0; i < COUNT_OF(data->block); i++) {
|
||||
@@ -92,7 +92,9 @@ void mf_classic_copy(MfClassicData* data, const MfClassicData* other) {
|
||||
}
|
||||
|
||||
bool mf_classic_verify(MfClassicData* data, const FuriString* device_type) {
|
||||
furi_check(device_type);
|
||||
UNUSED(data);
|
||||
|
||||
return furi_string_equal_str(device_type, "Mifare Classic");
|
||||
}
|
||||
|
||||
@@ -146,7 +148,8 @@ static void mf_classic_parse_block(FuriString* block_str, MfClassicData* data, u
|
||||
}
|
||||
|
||||
bool mf_classic_load(MfClassicData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool parsed = false;
|
||||
@@ -255,7 +258,8 @@ static void
|
||||
}
|
||||
|
||||
bool mf_classic_save(const MfClassicData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool saved = false;
|
||||
@@ -297,6 +301,9 @@ bool mf_classic_save(const MfClassicData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool mf_classic_is_equal(const MfClassicData* data, const MfClassicData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
bool is_equal = false;
|
||||
bool data_array_is_equal = true;
|
||||
|
||||
@@ -329,8 +336,8 @@ bool mf_classic_is_equal(const MfClassicData* data, const MfClassicData* other)
|
||||
}
|
||||
|
||||
const char* mf_classic_get_device_name(const MfClassicData* data, NfcDeviceNameType name_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->type < MfClassicTypeNum);
|
||||
furi_check(data);
|
||||
furi_check(data->type < MfClassicTypeNum);
|
||||
|
||||
if(name_type == NfcDeviceNameTypeFull) {
|
||||
return mf_classic_features[data->type].full_name;
|
||||
@@ -340,13 +347,13 @@ const char* mf_classic_get_device_name(const MfClassicData* data, NfcDeviceNameT
|
||||
}
|
||||
|
||||
const uint8_t* mf_classic_get_uid(const MfClassicData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len);
|
||||
}
|
||||
|
||||
bool mf_classic_set_uid(MfClassicData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool uid_valid = iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len);
|
||||
|
||||
@@ -370,16 +377,18 @@ bool mf_classic_set_uid(MfClassicData* data, const uint8_t* uid, size_t uid_len)
|
||||
}
|
||||
|
||||
Iso14443_3aData* mf_classic_get_base_data(const MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3a_data;
|
||||
}
|
||||
|
||||
uint8_t mf_classic_get_total_sectors_num(MfClassicType type) {
|
||||
furi_check(type < MfClassicTypeNum);
|
||||
return mf_classic_features[type].sectors_total;
|
||||
}
|
||||
|
||||
uint16_t mf_classic_get_total_block_num(MfClassicType type) {
|
||||
furi_check(type < MfClassicTypeNum);
|
||||
return mf_classic_features[type].blocks_total;
|
||||
}
|
||||
|
||||
@@ -411,7 +420,7 @@ uint8_t mf_classic_get_sector_trailer_num_by_block(uint8_t block) {
|
||||
|
||||
MfClassicSectorTrailer*
|
||||
mf_classic_get_sector_trailer_by_sector(const MfClassicData* data, uint8_t sector_num) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t sec_tr_block = mf_classic_get_sector_trailer_num_by_sector(sector_num);
|
||||
MfClassicSectorTrailer* sec_trailer = (MfClassicSectorTrailer*)&data->block[sec_tr_block];
|
||||
@@ -436,7 +445,8 @@ uint8_t mf_classic_get_sector_by_block(uint8_t block) {
|
||||
}
|
||||
|
||||
bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint8_t* addr) {
|
||||
furi_assert(block);
|
||||
furi_check(block);
|
||||
furi_check(value);
|
||||
|
||||
uint32_t v = *(uint32_t*)&block->data[0];
|
||||
uint32_t v_inv = *(uint32_t*)&block->data[sizeof(uint32_t)];
|
||||
@@ -445,9 +455,7 @@ bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint
|
||||
bool val_checks =
|
||||
((v == v1) && (v == ~v_inv) && (block->data[12] == (~block->data[13] & 0xFF)) &&
|
||||
(block->data[14] == (~block->data[15] & 0xFF)) && (block->data[12] == block->data[14]));
|
||||
if(value) {
|
||||
*value = (int32_t)v;
|
||||
}
|
||||
*value = (int32_t)v;
|
||||
if(addr) {
|
||||
*addr = block->data[12];
|
||||
}
|
||||
@@ -455,7 +463,7 @@ bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint
|
||||
}
|
||||
|
||||
void mf_classic_value_to_block(int32_t value, uint8_t addr, MfClassicBlock* block) {
|
||||
furi_assert(block);
|
||||
furi_check(block);
|
||||
|
||||
uint32_t v_inv = ~((uint32_t)value);
|
||||
|
||||
@@ -473,7 +481,7 @@ bool mf_classic_is_key_found(
|
||||
const MfClassicData* data,
|
||||
uint8_t sector_num,
|
||||
MfClassicKeyType key_type) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool key_found = false;
|
||||
if(key_type == MfClassicKeyTypeA) {
|
||||
@@ -490,7 +498,7 @@ void mf_classic_set_key_found(
|
||||
uint8_t sector_num,
|
||||
MfClassicKeyType key_type,
|
||||
uint64_t key) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t key_arr[6] = {};
|
||||
MfClassicSectorTrailer* sec_trailer =
|
||||
@@ -509,7 +517,7 @@ void mf_classic_set_key_not_found(
|
||||
MfClassicData* data,
|
||||
uint8_t sector_num,
|
||||
MfClassicKeyType key_type) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(key_type == MfClassicKeyTypeA) {
|
||||
FURI_BIT_CLEAR(data->key_a_mask, sector_num);
|
||||
@@ -519,13 +527,14 @@ void mf_classic_set_key_not_found(
|
||||
}
|
||||
|
||||
bool mf_classic_is_block_read(const MfClassicData* data, uint8_t block_num) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return (FURI_BIT(data->block_read_mask[block_num / 32], block_num % 32) == 1);
|
||||
}
|
||||
|
||||
void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassicBlock* block_data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(block_data);
|
||||
|
||||
if(mf_classic_is_sector_trailer(block_num)) {
|
||||
memcpy(&data->block[block_num].data[6], &block_data->data[6], 4);
|
||||
@@ -536,7 +545,7 @@ void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassic
|
||||
}
|
||||
|
||||
uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector) {
|
||||
furi_assert(sector < 40);
|
||||
furi_check(sector < 40);
|
||||
|
||||
uint8_t block = 0;
|
||||
if(sector < 32) {
|
||||
@@ -549,7 +558,8 @@ uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector) {
|
||||
}
|
||||
|
||||
uint8_t mf_classic_get_blocks_num_in_sector(uint8_t sector) {
|
||||
furi_assert(sector < 40);
|
||||
furi_check(sector < 40);
|
||||
|
||||
return sector < 32 ? 4 : 16;
|
||||
}
|
||||
|
||||
@@ -557,9 +567,9 @@ void mf_classic_get_read_sectors_and_keys(
|
||||
const MfClassicData* data,
|
||||
uint8_t* sectors_read,
|
||||
uint8_t* keys_found) {
|
||||
furi_assert(data);
|
||||
furi_assert(sectors_read);
|
||||
furi_assert(keys_found);
|
||||
furi_check(data);
|
||||
furi_check(sectors_read);
|
||||
furi_check(keys_found);
|
||||
|
||||
*sectors_read = 0;
|
||||
*keys_found = 0;
|
||||
@@ -585,7 +595,7 @@ void mf_classic_get_read_sectors_and_keys(
|
||||
}
|
||||
|
||||
bool mf_classic_is_card_read(const MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t sectors_total = mf_classic_get_total_sectors_num(data->type);
|
||||
uint8_t sectors_read = 0;
|
||||
@@ -597,7 +607,7 @@ bool mf_classic_is_card_read(const MfClassicData* data) {
|
||||
}
|
||||
|
||||
bool mf_classic_is_sector_read(const MfClassicData* data, uint8_t sector_num) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool sector_read = false;
|
||||
do {
|
||||
@@ -662,7 +672,7 @@ bool mf_classic_is_allowed_access_data_block(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAction action) {
|
||||
furi_assert(sec_tr);
|
||||
furi_check(sec_tr);
|
||||
|
||||
uint8_t* access_bits_arr = sec_tr->access_bits.data;
|
||||
|
||||
@@ -732,7 +742,7 @@ bool mf_classic_is_allowed_access(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAction action) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool access_allowed = false;
|
||||
if(mf_classic_is_sector_trailer(block_num)) {
|
||||
@@ -749,7 +759,7 @@ bool mf_classic_is_allowed_access(
|
||||
}
|
||||
|
||||
bool mf_classic_is_value_block(MfClassicSectorTrailer* sec_tr, uint8_t block_num) {
|
||||
furi_assert(sec_tr);
|
||||
furi_check(sec_tr);
|
||||
|
||||
// Check if key A can write, if it can, it's transport configuration, not data block
|
||||
return !mf_classic_is_allowed_access_data_block(
|
||||
|
||||
@@ -143,7 +143,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_mf_classic;
|
||||
|
||||
MfClassicData* mf_classic_alloc();
|
||||
MfClassicData* mf_classic_alloc(void);
|
||||
|
||||
void mf_classic_free(MfClassicData* data);
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ MfClassicError mf_classic_poller_get_nt(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicNt* nt) {
|
||||
furi_check(instance);
|
||||
|
||||
return mf_classic_poller_get_nt_common(instance, block_num, key_type, nt, false);
|
||||
}
|
||||
|
||||
@@ -98,6 +100,8 @@ MfClassicError mf_classic_poller_get_nt_nested(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicNt* nt) {
|
||||
furi_check(instance);
|
||||
|
||||
return mf_classic_poller_get_nt_common(instance, block_num, key_type, nt, true);
|
||||
}
|
||||
|
||||
@@ -179,6 +183,8 @@ MfClassicError mf_classic_poller_auth(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAuthContext* data) {
|
||||
furi_check(instance);
|
||||
furi_check(key);
|
||||
return mf_classic_poller_auth_common(instance, block_num, key, key_type, data, false);
|
||||
}
|
||||
|
||||
@@ -188,10 +194,14 @@ MfClassicError mf_classic_poller_auth_nested(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAuthContext* data) {
|
||||
furi_check(instance);
|
||||
furi_check(key);
|
||||
return mf_classic_poller_auth_common(instance, block_num, key, key_type, data, true);
|
||||
}
|
||||
|
||||
MfClassicError mf_classic_poller_halt(MfClassicPoller* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -223,6 +233,9 @@ MfClassicError mf_classic_poller_read_block(
|
||||
MfClassicPoller* instance,
|
||||
uint8_t block_num,
|
||||
MfClassicBlock* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -269,6 +282,9 @@ MfClassicError mf_classic_poller_write_block(
|
||||
MfClassicPoller* instance,
|
||||
uint8_t block_num,
|
||||
MfClassicBlock* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -341,6 +357,8 @@ MfClassicError mf_classic_poller_value_cmd(
|
||||
uint8_t block_num,
|
||||
MfClassicValueCommand cmd,
|
||||
int32_t data) {
|
||||
furi_check(instance);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -407,6 +425,8 @@ MfClassicError mf_classic_poller_value_cmd(
|
||||
}
|
||||
|
||||
MfClassicError mf_classic_poller_value_transfer(MfClassicPoller* instance, uint8_t block_num) {
|
||||
furi_check(instance);
|
||||
|
||||
MfClassicError ret = MfClassicErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ MfClassicError mf_classic_poller_sync_collect_nt(
|
||||
uint8_t block_num,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicNt* nt) {
|
||||
furi_assert(nfc);
|
||||
furi_check(nfc);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeCollectNt,
|
||||
@@ -250,8 +250,8 @@ MfClassicError mf_classic_poller_sync_auth(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicAuthContext* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeAuth,
|
||||
@@ -277,9 +277,9 @@ MfClassicError mf_classic_poller_sync_read_block(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicBlock* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeReadBlock,
|
||||
@@ -303,9 +303,9 @@ MfClassicError mf_classic_poller_sync_write_block(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
MfClassicBlock* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeWriteBlock,
|
||||
@@ -326,9 +326,9 @@ MfClassicError mf_classic_poller_sync_read_value(
|
||||
MfClassicKey* key,
|
||||
MfClassicKeyType key_type,
|
||||
int32_t* value) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(value);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(value);
|
||||
|
||||
MfClassicPollerContext poller_context = {
|
||||
.cmd_type = MfClassicPollerCmdTypeReadValue,
|
||||
@@ -353,9 +353,9 @@ MfClassicError mf_classic_poller_sync_change_value(
|
||||
MfClassicKeyType key_type,
|
||||
int32_t data,
|
||||
int32_t* new_value) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(key);
|
||||
furi_assert(new_value);
|
||||
furi_check(nfc);
|
||||
furi_check(key);
|
||||
furi_check(new_value);
|
||||
|
||||
MfClassicValueCommand command = MfClassicValueCommandRestore;
|
||||
int32_t command_data = 0;
|
||||
@@ -459,9 +459,9 @@ NfcCommand mf_classic_poller_read_callback(NfcGenericEvent event, void* context)
|
||||
|
||||
MfClassicError
|
||||
mf_classic_poller_sync_read(Nfc* nfc, const MfClassicDeviceKeys* keys, MfClassicData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(keys);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(keys);
|
||||
furi_check(data);
|
||||
|
||||
MfClassicError error = MfClassicErrorNone;
|
||||
MfClassicPollerContext poller_context = {};
|
||||
@@ -493,8 +493,8 @@ MfClassicError
|
||||
}
|
||||
|
||||
MfClassicError mf_classic_poller_sync_detect_type(Nfc* nfc, MfClassicType* type) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(type);
|
||||
furi_check(nfc);
|
||||
furi_check(type);
|
||||
|
||||
MfClassicError error = MfClassicErrorNone;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ const NfcDeviceBase nfc_device_mf_desfire = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)mf_desfire_get_base_data,
|
||||
};
|
||||
|
||||
MfDesfireData* mf_desfire_alloc() {
|
||||
MfDesfireData* mf_desfire_alloc(void) {
|
||||
MfDesfireData* data = malloc(sizeof(MfDesfireData));
|
||||
data->iso14443_4a_data = iso14443_4a_alloc();
|
||||
data->master_key_versions = simple_array_alloc(&mf_desfire_key_version_array_config);
|
||||
@@ -31,7 +31,7 @@ MfDesfireData* mf_desfire_alloc() {
|
||||
}
|
||||
|
||||
void mf_desfire_free(MfDesfireData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
mf_desfire_reset(data);
|
||||
simple_array_free(data->applications);
|
||||
@@ -42,7 +42,7 @@ void mf_desfire_free(MfDesfireData* data) {
|
||||
}
|
||||
|
||||
void mf_desfire_reset(MfDesfireData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_4a_reset(data->iso14443_4a_data);
|
||||
|
||||
@@ -55,8 +55,8 @@ void mf_desfire_reset(MfDesfireData* data) {
|
||||
}
|
||||
|
||||
void mf_desfire_copy(MfDesfireData* data, const MfDesfireData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
mf_desfire_reset(data);
|
||||
|
||||
@@ -77,7 +77,8 @@ bool mf_desfire_verify(MfDesfireData* data, const FuriString* device_type) {
|
||||
}
|
||||
|
||||
bool mf_desfire_load(MfDesfireData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* prefix = furi_string_alloc();
|
||||
|
||||
@@ -143,7 +144,8 @@ bool mf_desfire_load(MfDesfireData* data, FlipperFormat* ff, uint32_t version) {
|
||||
}
|
||||
|
||||
bool mf_desfire_save(const MfDesfireData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* prefix = furi_string_alloc();
|
||||
|
||||
@@ -208,12 +210,15 @@ bool mf_desfire_save(const MfDesfireData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool mf_desfire_is_equal(const MfDesfireData* data, const MfDesfireData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso14443_4a_is_equal(data->iso14443_4a_data, other->iso14443_4a_data) &&
|
||||
memcmp(&data->version, &other->version, sizeof(MfDesfireVersion)) == 0 &&
|
||||
memcmp(&data->free_memory, &other->free_memory, sizeof(MfDesfireFreeMemory)) == 0 &&
|
||||
memcmp( //-V1103
|
||||
&data->free_memory,
|
||||
&other->free_memory,
|
||||
sizeof(MfDesfireFreeMemory)) == 0 &&
|
||||
memcmp(
|
||||
&data->master_key_settings,
|
||||
&other->master_key_settings,
|
||||
@@ -230,25 +235,29 @@ const char* mf_desfire_get_device_name(const MfDesfireData* data, NfcDeviceNameT
|
||||
}
|
||||
|
||||
const uint8_t* mf_desfire_get_uid(const MfDesfireData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid_len);
|
||||
|
||||
return iso14443_4a_get_uid(data->iso14443_4a_data, uid_len);
|
||||
}
|
||||
|
||||
bool mf_desfire_set_uid(MfDesfireData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_4a_set_uid(data->iso14443_4a_data, uid, uid_len);
|
||||
}
|
||||
|
||||
Iso14443_4aData* mf_desfire_get_base_data(const MfDesfireData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_4a_data;
|
||||
}
|
||||
|
||||
const MfDesfireApplication*
|
||||
mf_desfire_get_application(const MfDesfireData* data, const MfDesfireApplicationId* app_id) {
|
||||
furi_check(data);
|
||||
furi_check(app_id);
|
||||
|
||||
MfDesfireApplication* app = NULL;
|
||||
|
||||
for(uint32_t i = 0; i < simple_array_get_count(data->application_ids); ++i) {
|
||||
@@ -263,6 +272,9 @@ const MfDesfireApplication*
|
||||
|
||||
const MfDesfireFileSettings*
|
||||
mf_desfire_get_file_settings(const MfDesfireApplication* data, const MfDesfireFileId* file_id) {
|
||||
furi_check(data);
|
||||
furi_check(file_id);
|
||||
|
||||
MfDesfireFileSettings* file_settings = NULL;
|
||||
|
||||
for(uint32_t i = 0; i < simple_array_get_count(data->file_ids); ++i) {
|
||||
@@ -277,6 +289,9 @@ const MfDesfireFileSettings*
|
||||
|
||||
const MfDesfireFileData*
|
||||
mf_desfire_get_file_data(const MfDesfireApplication* data, const MfDesfireFileId* file_id) {
|
||||
furi_check(data);
|
||||
furi_check(file_id);
|
||||
|
||||
MfDesfireFileData* file_data = NULL;
|
||||
|
||||
for(uint32_t i = 0; i < simple_array_get_count(data->file_ids); ++i) {
|
||||
|
||||
@@ -152,7 +152,7 @@ extern const NfcDeviceBase nfc_device_mf_desfire;
|
||||
|
||||
// Virtual methods
|
||||
|
||||
MfDesfireData* mf_desfire_alloc();
|
||||
MfDesfireData* mf_desfire_alloc(void);
|
||||
|
||||
void mf_desfire_free(MfDesfireData* data);
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ MfDesfireError mf_desfire_send_chunks(
|
||||
MfDesfirePoller* instance,
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->iso14443_4a_poller);
|
||||
furi_assert(instance->tx_buffer);
|
||||
furi_assert(instance->rx_buffer);
|
||||
furi_assert(tx_buffer);
|
||||
furi_assert(rx_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->iso14443_4a_poller);
|
||||
furi_check(instance->tx_buffer);
|
||||
furi_check(instance->rx_buffer);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
@@ -75,7 +75,7 @@ MfDesfireError mf_desfire_send_chunks(
|
||||
}
|
||||
|
||||
MfDesfireError mf_desfire_poller_read_version(MfDesfirePoller* instance, MfDesfireVersion* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_VERSION);
|
||||
@@ -97,7 +97,7 @@ MfDesfireError mf_desfire_poller_read_version(MfDesfirePoller* instance, MfDesfi
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_free_memory(MfDesfirePoller* instance, MfDesfireFreeMemory* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FREE_MEMORY);
|
||||
@@ -119,7 +119,7 @@ MfDesfireError
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_key_settings(MfDesfirePoller* instance, MfDesfireKeySettings* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_KEY_SETTINGS);
|
||||
@@ -143,8 +143,8 @@ MfDesfireError mf_desfire_poller_read_key_versions(
|
||||
MfDesfirePoller* instance,
|
||||
SimpleArray* data,
|
||||
uint32_t count) {
|
||||
furi_assert(instance);
|
||||
furi_assert(count > 0);
|
||||
furi_check(instance);
|
||||
furi_check(count > 0);
|
||||
|
||||
simple_array_init(data, count);
|
||||
|
||||
@@ -171,7 +171,8 @@ MfDesfireError mf_desfire_poller_read_key_versions(
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_application_ids(MfDesfirePoller* instance, SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_APPLICATION_IDS);
|
||||
@@ -204,7 +205,7 @@ MfDesfireError
|
||||
MfDesfireError mf_desfire_poller_select_application(
|
||||
MfDesfirePoller* instance,
|
||||
const MfDesfireApplicationId* id) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_SELECT_APPLICATION);
|
||||
@@ -218,7 +219,8 @@ MfDesfireError mf_desfire_poller_select_application(
|
||||
}
|
||||
|
||||
MfDesfireError mf_desfire_poller_read_file_ids(MfDesfirePoller* instance, SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FILE_IDS);
|
||||
@@ -251,7 +253,8 @@ MfDesfireError mf_desfire_poller_read_file_settings(
|
||||
MfDesfirePoller* instance,
|
||||
MfDesfireFileId id,
|
||||
MfDesfireFileSettings* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FILE_SETTINGS);
|
||||
@@ -276,7 +279,9 @@ MfDesfireError mf_desfire_poller_read_file_settings_multi(
|
||||
MfDesfirePoller* instance,
|
||||
const SimpleArray* file_ids,
|
||||
SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(file_ids);
|
||||
furi_check(data);
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
@@ -300,7 +305,8 @@ MfDesfireError mf_desfire_poller_read_file_data(
|
||||
uint32_t offset,
|
||||
size_t size,
|
||||
MfDesfireFileData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_DATA);
|
||||
@@ -327,7 +333,8 @@ MfDesfireError mf_desfire_poller_read_file_value(
|
||||
MfDesfirePoller* instance,
|
||||
MfDesfireFileId id,
|
||||
MfDesfireFileData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_VALUE);
|
||||
@@ -354,7 +361,8 @@ MfDesfireError mf_desfire_poller_read_file_records(
|
||||
uint32_t offset,
|
||||
size_t size,
|
||||
MfDesfireFileData* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_RECORDS);
|
||||
@@ -382,8 +390,11 @@ MfDesfireError mf_desfire_poller_read_file_data_multi(
|
||||
const SimpleArray* file_ids,
|
||||
const SimpleArray* file_settings,
|
||||
SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(simple_array_get_count(file_ids) == simple_array_get_count(file_settings));
|
||||
furi_check(instance);
|
||||
furi_check(file_ids);
|
||||
furi_check(file_settings);
|
||||
furi_check(data);
|
||||
furi_check(simple_array_get_count(file_ids) == simple_array_get_count(file_settings));
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
@@ -419,8 +430,8 @@ MfDesfireError mf_desfire_poller_read_file_data_multi(
|
||||
|
||||
MfDesfireError
|
||||
mf_desfire_poller_read_application(MfDesfirePoller* instance, MfDesfireApplication* data) {
|
||||
furi_assert(instance);
|
||||
furi_assert(data);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfDesfireError error;
|
||||
|
||||
@@ -452,7 +463,8 @@ MfDesfireError mf_desfire_poller_read_applications(
|
||||
MfDesfirePoller* instance,
|
||||
const SimpleArray* app_ids,
|
||||
SimpleArray* data) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfDesfireError error = MfDesfireErrorNone;
|
||||
|
||||
|
||||
@@ -168,28 +168,28 @@ const NfcDeviceBase nfc_device_mf_ultralight = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)mf_ultralight_get_base_data,
|
||||
};
|
||||
|
||||
MfUltralightData* mf_ultralight_alloc() {
|
||||
MfUltralightData* mf_ultralight_alloc(void) {
|
||||
MfUltralightData* data = malloc(sizeof(MfUltralightData));
|
||||
data->iso14443_3a_data = iso14443_3a_alloc();
|
||||
return data;
|
||||
}
|
||||
|
||||
void mf_ultralight_free(MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_free(data->iso14443_3a_data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void mf_ultralight_reset(MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso14443_3a_reset(data->iso14443_3a_data);
|
||||
}
|
||||
|
||||
void mf_ultralight_copy(MfUltralightData* data, const MfUltralightData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data);
|
||||
for(size_t i = 0; i < COUNT_OF(data->counter); i++) {
|
||||
@@ -222,7 +222,8 @@ static const char*
|
||||
}
|
||||
|
||||
bool mf_ultralight_verify(MfUltralightData* data, const FuriString* device_type) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(device_type);
|
||||
|
||||
bool verified = false;
|
||||
|
||||
@@ -239,7 +240,8 @@ bool mf_ultralight_verify(MfUltralightData* data, const FuriString* device_type)
|
||||
}
|
||||
|
||||
bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool parsed = false;
|
||||
@@ -338,7 +340,8 @@ bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t vers
|
||||
}
|
||||
|
||||
bool mf_ultralight_save(const MfUltralightData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool saved = false;
|
||||
@@ -419,6 +422,9 @@ bool mf_ultralight_save(const MfUltralightData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool mf_ultralight_is_equal(const MfUltralightData* data, const MfUltralightData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
bool is_equal = false;
|
||||
bool data_array_is_equal = true;
|
||||
|
||||
@@ -467,20 +473,20 @@ bool mf_ultralight_is_equal(const MfUltralightData* data, const MfUltralightData
|
||||
|
||||
const char*
|
||||
mf_ultralight_get_device_name(const MfUltralightData* data, NfcDeviceNameType name_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->type < MfUltralightTypeNum);
|
||||
furi_check(data);
|
||||
furi_check(data->type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_get_device_name_by_type(data->type, name_type);
|
||||
}
|
||||
|
||||
const uint8_t* mf_ultralight_get_uid(const MfUltralightData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len);
|
||||
}
|
||||
|
||||
bool mf_ultralight_set_uid(MfUltralightData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool uid_valid = iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len);
|
||||
|
||||
@@ -498,13 +504,13 @@ bool mf_ultralight_set_uid(MfUltralightData* data, const uint8_t* uid, size_t ui
|
||||
}
|
||||
|
||||
Iso14443_3aData* mf_ultralight_get_base_data(const MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso14443_3a_data;
|
||||
}
|
||||
|
||||
MfUltralightType mf_ultralight_get_type_by_version(MfUltralightVersion* version) {
|
||||
furi_assert(version);
|
||||
furi_check(version);
|
||||
|
||||
MfUltralightType type = MfUltralightTypeUnknown;
|
||||
|
||||
@@ -538,15 +544,19 @@ MfUltralightType mf_ultralight_get_type_by_version(MfUltralightVersion* version)
|
||||
}
|
||||
|
||||
uint16_t mf_ultralight_get_pages_total(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_features[type].total_pages;
|
||||
}
|
||||
|
||||
uint32_t mf_ultralight_get_feature_support_set(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_features[type].feature_set;
|
||||
}
|
||||
|
||||
bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data) {
|
||||
furi_assert(iso14443_3a_data);
|
||||
furi_check(iso14443_3a_data);
|
||||
|
||||
bool mfu_detected = (iso14443_3a_data->atqa[0] == 0x44) &&
|
||||
(iso14443_3a_data->atqa[1] == 0x00) && (iso14443_3a_data->sak == 0x00);
|
||||
@@ -555,10 +565,14 @@ bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data) {
|
||||
}
|
||||
|
||||
uint16_t mf_ultralight_get_config_page_num(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
return mf_ultralight_features[type].config_page;
|
||||
}
|
||||
|
||||
uint8_t mf_ultralight_get_pwd_page_num(MfUltralightType type) {
|
||||
furi_check(type < MfUltralightTypeNum);
|
||||
|
||||
uint8_t config_page = mf_ultralight_features[type].config_page;
|
||||
return (config_page != 0) ? config_page + 2 : 0;
|
||||
}
|
||||
@@ -574,8 +588,8 @@ bool mf_ultralight_support_feature(const uint32_t feature_set, const uint32_t fe
|
||||
}
|
||||
|
||||
bool mf_ultralight_get_config_page(const MfUltralightData* data, MfUltralightConfigPages** config) {
|
||||
furi_assert(data);
|
||||
furi_assert(config);
|
||||
furi_check(data);
|
||||
furi_check(config);
|
||||
|
||||
bool config_pages_found = false;
|
||||
|
||||
@@ -589,7 +603,7 @@ bool mf_ultralight_get_config_page(const MfUltralightData* data, MfUltralightCon
|
||||
}
|
||||
|
||||
bool mf_ultralight_is_all_data_read(const MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool all_read = false;
|
||||
if(data->pages_read == data->pages_total ||
|
||||
@@ -616,7 +630,7 @@ bool mf_ultralight_is_all_data_read(const MfUltralightData* data) {
|
||||
}
|
||||
|
||||
bool mf_ultralight_is_counter_configured(const MfUltralightData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightConfigPages* config = NULL;
|
||||
bool configured = false;
|
||||
|
||||
@@ -177,7 +177,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_mf_ultralight;
|
||||
|
||||
MfUltralightData* mf_ultralight_alloc();
|
||||
MfUltralightData* mf_ultralight_alloc(void);
|
||||
|
||||
void mf_ultralight_free(MfUltralightData* data);
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ MfUltralightError mf_ultralight_process_error(Iso14443_3aError error) {
|
||||
MfUltralightError mf_ultralight_poller_auth_pwd(
|
||||
MfUltralightPoller* instance,
|
||||
MfUltralightPollerAuthContext* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
uint8_t auth_cmd[5] = {MF_ULTRALIGHT_CMD_PWD_AUTH}; //-V1009
|
||||
memccpy(&auth_cmd[1], data->password.data, 0, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE);
|
||||
bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd));
|
||||
@@ -60,6 +63,8 @@ MfUltralightError mf_ultralight_poller_auth_pwd(
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_authenticate(MfUltralightPoller* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
uint8_t auth_cmd[2] = {MF_ULTRALIGHT_CMD_AUTH, 0x00};
|
||||
bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd));
|
||||
|
||||
@@ -91,6 +96,9 @@ MfUltralightError mf_ultralight_poller_read_page_from_sector(
|
||||
uint8_t sector,
|
||||
uint8_t tag,
|
||||
MfUltralightPageReadCommandData* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -132,6 +140,9 @@ MfUltralightError mf_ultralight_poller_read_page(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t start_page,
|
||||
MfUltralightPageReadCommandData* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -162,6 +173,9 @@ MfUltralightError mf_ultralight_poller_write_page(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t page,
|
||||
const MfUltralightPage* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -193,6 +207,9 @@ MfUltralightError mf_ultralight_poller_write_page(
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_read_version(MfUltralightPoller* instance, MfUltralightVersion* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -222,6 +239,9 @@ MfUltralightError
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_read_signature(MfUltralightPoller* instance, MfUltralightSignature* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -251,6 +271,9 @@ MfUltralightError mf_ultralight_poller_read_counter(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t counter_num,
|
||||
MfUltralightCounter* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
@@ -280,6 +303,9 @@ MfUltralightError mf_ultralight_poller_read_tearing_flag(
|
||||
MfUltralightPoller* instance,
|
||||
uint8_t tearing_falg_num,
|
||||
MfUltralightTearingFlag* data) {
|
||||
furi_check(instance);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightError ret = MfUltralightErrorNone;
|
||||
Iso14443_3aError error = Iso14443_3aErrorNone;
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ static MfUltralightError
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_sync_read_page(Nfc* nfc, uint16_t page, MfUltralightPage* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadPage,
|
||||
@@ -138,8 +138,8 @@ MfUltralightError
|
||||
|
||||
MfUltralightError
|
||||
mf_ultralight_poller_sync_write_page(Nfc* nfc, uint16_t page, MfUltralightPage* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeWritePage,
|
||||
@@ -156,8 +156,8 @@ MfUltralightError
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_sync_read_version(Nfc* nfc, MfUltralightVersion* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadVersion,
|
||||
@@ -173,8 +173,8 @@ MfUltralightError mf_ultralight_poller_sync_read_version(Nfc* nfc, MfUltralightV
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_sync_read_signature(Nfc* nfc, MfUltralightSignature* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadSignature,
|
||||
@@ -193,8 +193,8 @@ MfUltralightError mf_ultralight_poller_sync_read_counter(
|
||||
Nfc* nfc,
|
||||
uint8_t counter_num,
|
||||
MfUltralightCounter* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadCounter,
|
||||
@@ -214,8 +214,8 @@ MfUltralightError mf_ultralight_poller_sync_read_tearing_flag(
|
||||
Nfc* nfc,
|
||||
uint8_t flag_num,
|
||||
MfUltralightTearingFlag* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {
|
||||
.cmd_type = MfUltralightPollerCmdTypeReadTearingFlag,
|
||||
@@ -261,8 +261,8 @@ static NfcCommand mf_ultralight_poller_read_callback(NfcGenericEvent event, void
|
||||
}
|
||||
|
||||
MfUltralightError mf_ultralight_poller_sync_read_card(Nfc* nfc, MfUltralightData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
MfUltralightPollerContext poller_context = {};
|
||||
poller_context.thread_id = furi_thread_get_current_id();
|
||||
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
*
|
||||
* @returns pointer to the allocated instance.
|
||||
*/
|
||||
typedef NfcDeviceData* (*NfcDeviceAlloc)();
|
||||
typedef NfcDeviceData* (*NfcDeviceAlloc)(void);
|
||||
|
||||
/**
|
||||
* @brief Delete the protocol-specific NFC device data instance.
|
||||
|
||||
@@ -150,14 +150,14 @@ static const NfcProtocolTreeNode nfc_protocol_nodes[NfcProtocolNum] = {
|
||||
};
|
||||
|
||||
NfcProtocol nfc_protocol_get_parent(NfcProtocol protocol) {
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
|
||||
return nfc_protocol_nodes[protocol].parent_protocol;
|
||||
}
|
||||
|
||||
bool nfc_protocol_has_parent(NfcProtocol protocol, NfcProtocol parent_protocol) {
|
||||
furi_assert(protocol < NfcProtocolNum);
|
||||
furi_assert(parent_protocol < NfcProtocolNum);
|
||||
furi_check(protocol < NfcProtocolNum);
|
||||
furi_check(parent_protocol < NfcProtocolNum);
|
||||
|
||||
bool parent_found = false;
|
||||
const NfcProtocolTreeNode* iter = &nfc_protocol_nodes[protocol];
|
||||
|
||||
@@ -89,7 +89,7 @@ static void slix_password_set_defaults(SlixPassword* passwords) {
|
||||
}
|
||||
}
|
||||
|
||||
SlixData* slix_alloc() {
|
||||
SlixData* slix_alloc(void) {
|
||||
SlixData* data = malloc(sizeof(SlixData));
|
||||
|
||||
data->iso15693_3_data = iso15693_3_alloc();
|
||||
@@ -99,7 +99,7 @@ SlixData* slix_alloc() {
|
||||
}
|
||||
|
||||
void slix_free(SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso15693_3_free(data->iso15693_3_data);
|
||||
|
||||
@@ -107,7 +107,7 @@ void slix_free(SlixData* data) {
|
||||
}
|
||||
|
||||
void slix_reset(SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
iso15693_3_reset(data->iso15693_3_data);
|
||||
slix_password_set_defaults(data->passwords);
|
||||
@@ -119,8 +119,8 @@ void slix_reset(SlixData* data) {
|
||||
}
|
||||
|
||||
void slix_copy(SlixData* data, const SlixData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
iso15693_3_copy(data->iso15693_3_data, other->iso15693_3_data);
|
||||
|
||||
@@ -160,7 +160,8 @@ static bool slix_load_passwords(SlixPassword* passwords, SlixType slix_type, Fli
|
||||
}
|
||||
|
||||
bool slix_load(SlixData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool loaded = false;
|
||||
|
||||
@@ -238,7 +239,8 @@ static bool
|
||||
}
|
||||
|
||||
bool slix_save(const SlixData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool saved = false;
|
||||
|
||||
@@ -303,6 +305,9 @@ bool slix_save(const SlixData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool slix_is_equal(const SlixData* data, const SlixData* other) {
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return iso15693_3_is_equal(data->iso15693_3_data, other->iso15693_3_data) &&
|
||||
memcmp(&data->system_info, &other->system_info, sizeof(SlixSystemInfo)) == 0 &&
|
||||
memcmp(
|
||||
@@ -313,6 +318,7 @@ bool slix_is_equal(const SlixData* data, const SlixData* other) {
|
||||
}
|
||||
|
||||
const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_type) {
|
||||
furi_check(data);
|
||||
UNUSED(name_type);
|
||||
|
||||
const SlixType slix_type = slix_get_type(data);
|
||||
@@ -322,22 +328,25 @@ const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_ty
|
||||
}
|
||||
|
||||
const uint8_t* slix_get_uid(const SlixData* data, size_t* uid_len) {
|
||||
furi_check(data);
|
||||
return iso15693_3_get_uid(data->iso15693_3_data, uid_len);
|
||||
}
|
||||
|
||||
bool slix_set_uid(SlixData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return iso15693_3_set_uid(data->iso15693_3_data, uid, uid_len);
|
||||
}
|
||||
|
||||
const Iso15693_3Data* slix_get_base_data(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->iso15693_3_data;
|
||||
}
|
||||
|
||||
SlixType slix_get_type(const SlixData* data) {
|
||||
furi_check(data);
|
||||
|
||||
SlixType type = SlixTypeUnknown;
|
||||
|
||||
do {
|
||||
@@ -364,14 +373,14 @@ SlixType slix_get_type(const SlixData* data) {
|
||||
}
|
||||
|
||||
SlixPassword slix_get_password(const SlixData* data, SlixPasswordType password_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(password_type < SlixPasswordTypeCount);
|
||||
furi_check(data);
|
||||
furi_check(password_type < SlixPasswordTypeCount);
|
||||
|
||||
return data->passwords[password_type];
|
||||
}
|
||||
|
||||
uint16_t slix_get_counter(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
const SlixCounter* counter = (const SlixCounter*)iso15693_3_get_block_data(
|
||||
data->iso15693_3_data, SLIX_COUNTER_BLOCK_NUM);
|
||||
|
||||
@@ -379,7 +388,7 @@ uint16_t slix_get_counter(const SlixData* data) {
|
||||
}
|
||||
|
||||
bool slix_is_privacy_mode(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
return data->privacy;
|
||||
}
|
||||
@@ -388,8 +397,8 @@ bool slix_is_block_protected(
|
||||
const SlixData* data,
|
||||
SlixPasswordType password_type,
|
||||
uint8_t block_num) {
|
||||
furi_assert(data);
|
||||
furi_assert(password_type < SlixPasswordTypeCount);
|
||||
furi_check(data);
|
||||
furi_check(password_type < SlixPasswordTypeCount);
|
||||
|
||||
bool ret = false;
|
||||
|
||||
@@ -411,7 +420,7 @@ bool slix_is_block_protected(
|
||||
}
|
||||
|
||||
bool slix_is_counter_increment_protected(const SlixData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
const SlixCounter* counter = (const SlixCounter*)iso15693_3_get_block_data(
|
||||
data->iso15693_3_data, SLIX_COUNTER_BLOCK_NUM);
|
||||
@@ -420,14 +429,14 @@ bool slix_is_counter_increment_protected(const SlixData* data) {
|
||||
}
|
||||
|
||||
bool slix_type_has_features(SlixType slix_type, SlixTypeFeatures features) {
|
||||
furi_assert(slix_type < SlixTypeCount);
|
||||
furi_check(slix_type < SlixTypeCount);
|
||||
|
||||
return (slix_type_features[slix_type] & features) == features;
|
||||
}
|
||||
|
||||
bool slix_type_supports_password(SlixType slix_type, SlixPasswordType password_type) {
|
||||
furi_assert(slix_type < SlixTypeCount);
|
||||
furi_assert(password_type < SlixPasswordTypeCount);
|
||||
furi_check(slix_type < SlixTypeCount);
|
||||
furi_check(password_type < SlixPasswordTypeCount);
|
||||
|
||||
return slix_type_features[slix_type] & slix_password_configs[password_type].feature_flag;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ typedef struct {
|
||||
SlixPrivacy privacy;
|
||||
} SlixData;
|
||||
|
||||
SlixData* slix_alloc();
|
||||
SlixData* slix_alloc(void);
|
||||
|
||||
void slix_free(SlixData* data);
|
||||
|
||||
|
||||
@@ -79,35 +79,39 @@ const NfcDeviceBase nfc_device_st25tb = {
|
||||
.get_base_data = (NfcDeviceGetBaseData)st25tb_get_base_data,
|
||||
};
|
||||
|
||||
St25tbData* st25tb_alloc() {
|
||||
St25tbData* st25tb_alloc(void) {
|
||||
St25tbData* data = malloc(sizeof(St25tbData));
|
||||
return data;
|
||||
}
|
||||
|
||||
void st25tb_free(St25tbData* data) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void st25tb_reset(St25tbData* data) {
|
||||
furi_check(data);
|
||||
memset(data, 0, sizeof(St25tbData));
|
||||
}
|
||||
|
||||
void st25tb_copy(St25tbData* data, const St25tbData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
*data = *other;
|
||||
}
|
||||
|
||||
bool st25tb_verify(St25tbData* data, const FuriString* device_type) {
|
||||
furi_check(device_type);
|
||||
UNUSED(data);
|
||||
|
||||
return furi_string_equal_str(device_type, ST25TB_PROTOCOL_NAME);
|
||||
}
|
||||
|
||||
bool st25tb_load(St25tbData* data, FlipperFormat* ff, uint32_t version) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -150,7 +154,8 @@ bool st25tb_load(St25tbData* data, FlipperFormat* ff, uint32_t version) {
|
||||
}
|
||||
|
||||
bool st25tb_save(const St25tbData* data, FlipperFormat* ff) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(ff);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
bool saved = false;
|
||||
@@ -184,19 +189,21 @@ bool st25tb_save(const St25tbData* data, FlipperFormat* ff) {
|
||||
}
|
||||
|
||||
bool st25tb_is_equal(const St25tbData* data, const St25tbData* other) {
|
||||
furi_assert(data);
|
||||
furi_assert(other);
|
||||
furi_check(data);
|
||||
furi_check(other);
|
||||
|
||||
return memcmp(data, other, sizeof(St25tbData)) == 0;
|
||||
return memcmp(data, other, sizeof(St25tbData)) == 0; //-V1103
|
||||
}
|
||||
|
||||
uint8_t st25tb_get_block_count(St25tbType type) {
|
||||
furi_check(type < St25tbTypeNum);
|
||||
|
||||
return st25tb_features[type].blocks_total;
|
||||
}
|
||||
|
||||
const char* st25tb_get_device_name(const St25tbData* data, NfcDeviceNameType name_type) {
|
||||
furi_assert(data);
|
||||
furi_assert(data->type < St25tbTypeNum);
|
||||
furi_check(data);
|
||||
furi_check(data->type < St25tbTypeNum);
|
||||
|
||||
if(name_type == NfcDeviceNameTypeFull) {
|
||||
return st25tb_features[data->type].full_name;
|
||||
@@ -206,7 +213,7 @@ const char* st25tb_get_device_name(const St25tbData* data, NfcDeviceNameType nam
|
||||
}
|
||||
|
||||
const uint8_t* st25tb_get_uid(const St25tbData* data, size_t* uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
if(uid_len) {
|
||||
*uid_len = ST25TB_UID_SIZE;
|
||||
@@ -216,7 +223,8 @@ const uint8_t* st25tb_get_uid(const St25tbData* data, size_t* uid_len) {
|
||||
}
|
||||
|
||||
bool st25tb_set_uid(St25tbData* data, const uint8_t* uid, size_t uid_len) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
furi_check(uid);
|
||||
|
||||
const bool uid_valid = uid_len == ST25TB_UID_SIZE;
|
||||
|
||||
@@ -233,6 +241,8 @@ St25tbData* st25tb_get_base_data(const St25tbData* data) {
|
||||
}
|
||||
|
||||
St25tbType st25tb_get_type_from_uid(const uint8_t* uid) {
|
||||
furi_check(uid);
|
||||
|
||||
switch(uid[2] >> 2) {
|
||||
case 0x0:
|
||||
case 0x3:
|
||||
|
||||
@@ -48,7 +48,7 @@ typedef struct {
|
||||
|
||||
extern const NfcDeviceBase nfc_device_st25tb;
|
||||
|
||||
St25tbData* st25tb_alloc();
|
||||
St25tbData* st25tb_alloc(void);
|
||||
|
||||
void st25tb_free(St25tbData* data);
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ St25tbError st25tb_poller_send_frame(
|
||||
const BitBuffer* tx_buffer,
|
||||
BitBuffer* rx_buffer,
|
||||
uint32_t fwt) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
furi_check(tx_buffer);
|
||||
furi_check(rx_buffer);
|
||||
|
||||
const size_t tx_bytes = bit_buffer_get_size_bytes(tx_buffer);
|
||||
furi_assert(
|
||||
@@ -54,8 +56,8 @@ St25tbError st25tb_poller_send_frame(
|
||||
|
||||
St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr) {
|
||||
// Send Initiate()
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
@@ -86,8 +88,8 @@ St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr)
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_select(St25tbPoller* instance, uint8_t* chip_id_ptr) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
|
||||
St25tbError ret;
|
||||
|
||||
@@ -169,8 +171,9 @@ St25tbError st25tb_poller_read(St25tbPoller* instance, St25tbData* data) {
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(uid);
|
||||
|
||||
St25tbError ret;
|
||||
|
||||
@@ -213,10 +216,10 @@ St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) {
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(block);
|
||||
furi_assert(
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(block);
|
||||
furi_check(
|
||||
(block_number <= st25tb_get_block_count(instance->data->type)) ||
|
||||
block_number == ST25TB_SYSTEM_OTP_BLOCK);
|
||||
FURI_LOG_T(TAG, "reading block %d", block_number);
|
||||
@@ -248,9 +251,9 @@ St25tbError
|
||||
|
||||
St25tbError
|
||||
st25tb_poller_write_block(St25tbPoller* instance, uint32_t block, uint8_t block_number) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->nfc);
|
||||
furi_assert(
|
||||
furi_check(instance);
|
||||
furi_check(instance->nfc);
|
||||
furi_check(
|
||||
(block_number <= st25tb_get_block_count(instance->data->type)) ||
|
||||
block_number == ST25TB_SYSTEM_OTP_BLOCK);
|
||||
FURI_LOG_T(TAG, "writing block %d", block_number);
|
||||
@@ -292,7 +295,7 @@ St25tbError
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_halt(St25tbPoller* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
|
||||
@@ -109,7 +109,8 @@ static St25tbError st25tb_poller_cmd_execute(Nfc* nfc, St25tbPollerSyncContext*
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_read_block(Nfc* nfc, uint8_t block_num, uint32_t* block) {
|
||||
furi_assert(block);
|
||||
furi_check(nfc);
|
||||
furi_check(block);
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.cmd_type = St25tbPollerCmdTypeReadBlock,
|
||||
.cmd_data =
|
||||
@@ -125,6 +126,7 @@ St25tbError st25tb_poller_sync_read_block(Nfc* nfc, uint8_t block_num, uint32_t*
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_write_block(Nfc* nfc, uint8_t block_num, uint32_t block) {
|
||||
furi_check(nfc);
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.cmd_type = St25tbPollerCmdTypeWriteBlock,
|
||||
.cmd_data =
|
||||
@@ -140,7 +142,8 @@ St25tbError st25tb_poller_sync_write_block(Nfc* nfc, uint8_t block_num, uint32_t
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_detect_type(Nfc* nfc, St25tbType* type) {
|
||||
furi_assert(type);
|
||||
furi_check(nfc);
|
||||
furi_check(type);
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.cmd_type = St25tbPollerCmdTypeDetectType,
|
||||
.cmd_data =
|
||||
@@ -185,8 +188,8 @@ static NfcCommand nfc_scene_read_poller_callback_st25tb(NfcGenericEvent event, v
|
||||
}
|
||||
|
||||
St25tbError st25tb_poller_sync_read(Nfc* nfc, St25tbData* data) {
|
||||
furi_assert(nfc);
|
||||
furi_assert(data);
|
||||
furi_check(nfc);
|
||||
furi_check(data);
|
||||
|
||||
St25tbPollerSyncContext poller_context = {
|
||||
.thread_id = furi_thread_get_current_id(),
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "maxim_crc.h"
|
||||
#include <furi.h>
|
||||
|
||||
uint8_t maxim_crc8(const uint8_t* data, const uint8_t data_size, const uint8_t crc_init) {
|
||||
furi_check(data);
|
||||
|
||||
uint8_t crc = crc_init;
|
||||
|
||||
for(uint8_t index = 0; index < data_size; ++index) {
|
||||
|
||||
@@ -56,19 +56,26 @@ struct OneWireHost {
|
||||
};
|
||||
|
||||
OneWireHost* onewire_host_alloc(const GpioPin* gpio_pin) {
|
||||
furi_check(gpio_pin);
|
||||
|
||||
OneWireHost* host = malloc(sizeof(OneWireHost));
|
||||
host->gpio_pin = gpio_pin;
|
||||
onewire_host_reset_search(host);
|
||||
onewire_host_set_overdrive(host, false);
|
||||
|
||||
return host;
|
||||
}
|
||||
|
||||
void onewire_host_free(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
onewire_host_stop(host);
|
||||
free(host);
|
||||
}
|
||||
|
||||
bool onewire_host_reset(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
uint8_t r;
|
||||
uint8_t retries = 125;
|
||||
|
||||
@@ -100,6 +107,8 @@ bool onewire_host_reset(OneWireHost* host) {
|
||||
}
|
||||
|
||||
bool onewire_host_read_bit(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
bool result;
|
||||
|
||||
const OneWireHostTimings* timings = host->timings;
|
||||
@@ -120,6 +129,8 @@ bool onewire_host_read_bit(OneWireHost* host) {
|
||||
}
|
||||
|
||||
uint8_t onewire_host_read(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
uint8_t result = 0;
|
||||
|
||||
for(uint8_t bitMask = 0x01; bitMask; bitMask <<= 1) {
|
||||
@@ -132,12 +143,17 @@ uint8_t onewire_host_read(OneWireHost* host) {
|
||||
}
|
||||
|
||||
void onewire_host_read_bytes(OneWireHost* host, uint8_t* buffer, uint16_t count) {
|
||||
furi_check(host);
|
||||
furi_check(buffer);
|
||||
|
||||
for(uint16_t i = 0; i < count; i++) {
|
||||
buffer[i] = onewire_host_read(host);
|
||||
}
|
||||
}
|
||||
|
||||
void onewire_host_write_bit(OneWireHost* host, bool value) {
|
||||
furi_check(host);
|
||||
|
||||
const OneWireHostTimings* timings = host->timings;
|
||||
|
||||
if(value) {
|
||||
@@ -160,6 +176,8 @@ void onewire_host_write_bit(OneWireHost* host, bool value) {
|
||||
}
|
||||
|
||||
void onewire_host_write(OneWireHost* host, uint8_t value) {
|
||||
furi_check(host);
|
||||
|
||||
uint8_t bitMask;
|
||||
|
||||
for(bitMask = 0x01; bitMask; bitMask <<= 1) {
|
||||
@@ -168,22 +186,31 @@ void onewire_host_write(OneWireHost* host, uint8_t value) {
|
||||
}
|
||||
|
||||
void onewire_host_write_bytes(OneWireHost* host, const uint8_t* buffer, uint16_t count) {
|
||||
furi_check(host);
|
||||
furi_check(buffer);
|
||||
|
||||
for(uint16_t i = 0; i < count; ++i) {
|
||||
onewire_host_write(host, buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void onewire_host_start(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
furi_hal_gpio_write(host->gpio_pin, true);
|
||||
furi_hal_gpio_init(host->gpio_pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
void onewire_host_stop(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
furi_hal_gpio_write(host->gpio_pin, true);
|
||||
furi_hal_gpio_init(host->gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
void onewire_host_reset_search(OneWireHost* host) {
|
||||
furi_check(host);
|
||||
|
||||
host->last_discrepancy = 0;
|
||||
host->last_device_flag = false;
|
||||
host->last_family_discrepancy = 0;
|
||||
@@ -194,6 +221,8 @@ void onewire_host_reset_search(OneWireHost* host) {
|
||||
}
|
||||
|
||||
void onewire_host_target_search(OneWireHost* host, uint8_t family_code) {
|
||||
furi_check(host);
|
||||
|
||||
host->saved_rom[0] = family_code;
|
||||
for(uint8_t i = 1; i < 8; i++) host->saved_rom[i] = 0;
|
||||
host->last_discrepancy = 64;
|
||||
@@ -202,6 +231,8 @@ void onewire_host_target_search(OneWireHost* host, uint8_t family_code) {
|
||||
}
|
||||
|
||||
bool onewire_host_search(OneWireHost* host, uint8_t* new_addr, OneWireHostSearchMode mode) {
|
||||
furi_check(host);
|
||||
|
||||
uint8_t id_bit_number;
|
||||
uint8_t last_zero, rom_byte_number, search_result;
|
||||
uint8_t id_bit, cmp_id_bit;
|
||||
@@ -317,5 +348,7 @@ bool onewire_host_search(OneWireHost* host, uint8_t* new_addr, OneWireHostSearch
|
||||
}
|
||||
|
||||
void onewire_host_set_overdrive(OneWireHost* host, bool set) {
|
||||
furi_check(host);
|
||||
|
||||
host->timings = set ? &onewire_host_timings_overdrive : &onewire_host_timings_normal;
|
||||
}
|
||||
|
||||
@@ -205,6 +205,7 @@ static void onewire_slave_exti_callback(void* context) {
|
||||
/*********************** PUBLIC ***********************/
|
||||
|
||||
OneWireSlave* onewire_slave_alloc(const GpioPin* gpio_pin) {
|
||||
furi_check(gpio_pin);
|
||||
OneWireSlave* bus = malloc(sizeof(OneWireSlave));
|
||||
|
||||
bus->gpio_pin = gpio_pin;
|
||||
@@ -215,17 +216,23 @@ OneWireSlave* onewire_slave_alloc(const GpioPin* gpio_pin) {
|
||||
}
|
||||
|
||||
void onewire_slave_free(OneWireSlave* bus) {
|
||||
furi_check(bus);
|
||||
|
||||
onewire_slave_stop(bus);
|
||||
free(bus);
|
||||
}
|
||||
|
||||
void onewire_slave_start(OneWireSlave* bus) {
|
||||
furi_check(bus);
|
||||
|
||||
furi_hal_gpio_add_int_callback(bus->gpio_pin, onewire_slave_exti_callback, bus);
|
||||
furi_hal_gpio_write(bus->gpio_pin, true);
|
||||
furi_hal_gpio_init(bus->gpio_pin, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow);
|
||||
}
|
||||
|
||||
void onewire_slave_stop(OneWireSlave* bus) {
|
||||
furi_check(bus);
|
||||
|
||||
furi_hal_gpio_write(bus->gpio_pin, true);
|
||||
furi_hal_gpio_init(bus->gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_remove_int_callback(bus->gpio_pin);
|
||||
@@ -235,6 +242,7 @@ void onewire_slave_set_reset_callback(
|
||||
OneWireSlave* bus,
|
||||
OneWireSlaveResetCallback callback,
|
||||
void* context) {
|
||||
furi_check(bus);
|
||||
bus->reset_callback = callback;
|
||||
bus->reset_callback_context = context;
|
||||
}
|
||||
@@ -243,6 +251,8 @@ void onewire_slave_set_command_callback(
|
||||
OneWireSlave* bus,
|
||||
OneWireSlaveCommandCallback callback,
|
||||
void* context) {
|
||||
furi_check(bus);
|
||||
|
||||
bus->command_callback = callback;
|
||||
bus->command_callback_context = context;
|
||||
}
|
||||
@@ -251,11 +261,14 @@ void onewire_slave_set_result_callback(
|
||||
OneWireSlave* bus,
|
||||
OneWireSlaveResultCallback result_cb,
|
||||
void* context) {
|
||||
furi_check(bus);
|
||||
bus->result_callback = result_cb;
|
||||
bus->result_callback_context = context;
|
||||
}
|
||||
|
||||
bool onewire_slave_receive_bit(OneWireSlave* bus) {
|
||||
furi_check(bus);
|
||||
|
||||
const OneWireSlaveTimings* timings = bus->timings;
|
||||
// wait while bus is low
|
||||
if(!onewire_slave_wait_while_gpio_is(bus, timings->tslot_max, false)) {
|
||||
@@ -274,6 +287,8 @@ bool onewire_slave_receive_bit(OneWireSlave* bus) {
|
||||
}
|
||||
|
||||
bool onewire_slave_send_bit(OneWireSlave* bus, bool value) {
|
||||
furi_check(bus);
|
||||
|
||||
const OneWireSlaveTimings* timings = bus->timings;
|
||||
// wait while bus is low
|
||||
if(!onewire_slave_wait_while_gpio_is(bus, timings->tslot_max, false)) {
|
||||
@@ -305,6 +320,8 @@ bool onewire_slave_send_bit(OneWireSlave* bus, bool value) {
|
||||
}
|
||||
|
||||
bool onewire_slave_send(OneWireSlave* bus, const uint8_t* data, size_t data_size) {
|
||||
furi_check(bus);
|
||||
|
||||
furi_hal_gpio_write(bus->gpio_pin, true);
|
||||
|
||||
size_t bytes_sent = 0;
|
||||
@@ -324,6 +341,8 @@ bool onewire_slave_send(OneWireSlave* bus, const uint8_t* data, size_t data_size
|
||||
}
|
||||
|
||||
bool onewire_slave_receive(OneWireSlave* bus, uint8_t* data, size_t data_size) {
|
||||
furi_check(bus);
|
||||
|
||||
furi_hal_gpio_write(bus->gpio_pin, true);
|
||||
|
||||
size_t bytes_received = 0;
|
||||
@@ -347,6 +366,7 @@ bool onewire_slave_receive(OneWireSlave* bus, uint8_t* data, size_t data_size) {
|
||||
}
|
||||
|
||||
void onewire_slave_set_overdrive(OneWireSlave* bus, bool set) {
|
||||
furi_check(bus);
|
||||
const OneWireSlaveTimings* new_timings = set ? &onewire_slave_timings_overdrive :
|
||||
&onewire_slave_timings_normal;
|
||||
if(bus->timings != new_timings) {
|
||||
|
||||
@@ -86,9 +86,9 @@ SignalReader* signal_reader_alloc(const GpioPin* gpio_pin, uint32_t size) {
|
||||
}
|
||||
|
||||
void signal_reader_free(SignalReader* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->gpio_buffer);
|
||||
furi_assert(instance->bitstream_buffer);
|
||||
furi_check(instance);
|
||||
furi_check(instance->gpio_buffer);
|
||||
furi_check(instance->bitstream_buffer);
|
||||
|
||||
free(instance->gpio_buffer);
|
||||
free(instance->bitstream_buffer);
|
||||
@@ -96,13 +96,13 @@ void signal_reader_free(SignalReader* instance) {
|
||||
}
|
||||
|
||||
void signal_reader_set_pull(SignalReader* instance, GpioPull pull) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->pull = pull;
|
||||
}
|
||||
|
||||
void signal_reader_set_polarity(SignalReader* instance, SignalReaderPolarity polarity) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->polarity = polarity;
|
||||
}
|
||||
@@ -111,14 +111,14 @@ void signal_reader_set_sample_rate(
|
||||
SignalReader* instance,
|
||||
SignalReaderTimeUnit time_unit,
|
||||
uint32_t time) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
UNUSED(time_unit);
|
||||
|
||||
instance->tim_arr = time;
|
||||
}
|
||||
|
||||
void signal_reader_set_trigger(SignalReader* instance, SignalReaderTrigger trigger) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->trigger = trigger;
|
||||
}
|
||||
@@ -186,8 +186,8 @@ static void furi_hal_sw_digital_pin_dma_rx_isr(void* context) {
|
||||
}
|
||||
|
||||
void signal_reader_start(SignalReader* instance, SignalReaderCallback callback, void* context) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback);
|
||||
furi_check(instance);
|
||||
furi_check(callback);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->context = context;
|
||||
@@ -306,7 +306,7 @@ void signal_reader_start(SignalReader* instance, SignalReaderCallback callback,
|
||||
}
|
||||
|
||||
void signal_reader_stop(SignalReader* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
furi_hal_interrupt_set_isr(SIGNAL_READER_DMA_GPIO_IRQ, NULL, NULL);
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "math.h"
|
||||
#include <core/check.h>
|
||||
|
||||
#include "furi.h"
|
||||
|
||||
#define TAG "SubGhzBlockEncoder"
|
||||
|
||||
void subghz_protocol_blocks_set_bit_array(
|
||||
@@ -11,7 +9,7 @@ void subghz_protocol_blocks_set_bit_array(
|
||||
uint8_t data_array[],
|
||||
size_t set_index_bit,
|
||||
size_t max_size_array) {
|
||||
furi_assert(set_index_bit < max_size_array * 8);
|
||||
furi_check(set_index_bit < max_size_array * 8);
|
||||
bit_write(data_array[set_index_bit >> 3], 7 - (set_index_bit & 0x7), bit_value);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ SubGhzProtocolStatus subghz_block_generic_serialize(
|
||||
SubGhzBlockGeneric* instance,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
@@ -94,7 +94,8 @@ SubGhzProtocolStatus subghz_block_generic_serialize(
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_block_generic_deserialize(SubGhzBlockGeneric* instance, FlipperFormat* flipper_format) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
@@ -135,6 +136,7 @@ SubGhzProtocolStatus subghz_block_generic_deserialize_check_count_bit(
|
||||
SubGhzBlockGeneric* instance,
|
||||
FlipperFormat* flipper_format,
|
||||
uint16_t count_bit) {
|
||||
furi_check(instance);
|
||||
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
|
||||
do {
|
||||
ret = subghz_block_generic_deserialize(instance, flipper_format);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "registry.h"
|
||||
|
||||
void subghz_devices_init() {
|
||||
void subghz_devices_init(void) {
|
||||
furi_check(!subghz_device_registry_is_valid());
|
||||
subghz_device_registry_init();
|
||||
}
|
||||
@@ -27,8 +27,8 @@ const char* subghz_devices_get_name(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
bool subghz_devices_begin(const SubGhzDevice* device) {
|
||||
furi_check(device);
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
if(device->interconnect->begin) {
|
||||
ret = device->interconnect->begin();
|
||||
}
|
||||
@@ -36,15 +36,15 @@ bool subghz_devices_begin(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
void subghz_devices_end(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->end) {
|
||||
device->interconnect->end();
|
||||
}
|
||||
}
|
||||
|
||||
bool subghz_devices_is_connect(const SubGhzDevice* device) {
|
||||
furi_check(device);
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
if(device->interconnect->is_connect) {
|
||||
ret = device->interconnect->is_connect();
|
||||
}
|
||||
@@ -52,21 +52,21 @@ bool subghz_devices_is_connect(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
void subghz_devices_reset(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->reset) {
|
||||
device->interconnect->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_sleep(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->sleep) {
|
||||
device->interconnect->sleep();
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_idle(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->idle) {
|
||||
device->interconnect->idle();
|
||||
}
|
||||
@@ -76,15 +76,15 @@ void subghz_devices_load_preset(
|
||||
const SubGhzDevice* device,
|
||||
FuriHalSubGhzPreset preset,
|
||||
uint8_t* preset_data) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->load_preset) {
|
||||
device->interconnect->load_preset(preset, preset_data);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t subghz_devices_set_frequency(const SubGhzDevice* device, uint32_t frequency) {
|
||||
furi_check(device);
|
||||
uint32_t ret = 0;
|
||||
furi_assert(device);
|
||||
if(device->interconnect->set_frequency) {
|
||||
ret = device->interconnect->set_frequency(frequency);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ uint32_t subghz_devices_set_frequency(const SubGhzDevice* device, uint32_t frequ
|
||||
|
||||
bool subghz_devices_is_frequency_valid(const SubGhzDevice* device, uint32_t frequency) {
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->is_frequency_valid) {
|
||||
ret = device->interconnect->is_frequency_valid(frequency);
|
||||
}
|
||||
@@ -101,15 +101,15 @@ bool subghz_devices_is_frequency_valid(const SubGhzDevice* device, uint32_t freq
|
||||
}
|
||||
|
||||
void subghz_devices_set_async_mirror_pin(const SubGhzDevice* device, const GpioPin* gpio) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->set_async_mirror_pin) {
|
||||
device->interconnect->set_async_mirror_pin(gpio);
|
||||
}
|
||||
}
|
||||
|
||||
const GpioPin* subghz_devices_get_data_gpio(const SubGhzDevice* device) {
|
||||
furi_check(device);
|
||||
const GpioPin* ret = NULL;
|
||||
furi_assert(device);
|
||||
if(device->interconnect->get_data_gpio) {
|
||||
ret = device->interconnect->get_data_gpio();
|
||||
}
|
||||
@@ -118,7 +118,7 @@ const GpioPin* subghz_devices_get_data_gpio(const SubGhzDevice* device) {
|
||||
|
||||
bool subghz_devices_set_tx(const SubGhzDevice* device) {
|
||||
bool ret = 0;
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->set_tx) {
|
||||
ret = device->interconnect->set_tx();
|
||||
}
|
||||
@@ -126,7 +126,7 @@ bool subghz_devices_set_tx(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
void subghz_devices_flush_tx(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->flush_tx) {
|
||||
device->interconnect->flush_tx();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ void subghz_devices_flush_tx(const SubGhzDevice* device) {
|
||||
|
||||
bool subghz_devices_start_async_tx(const SubGhzDevice* device, void* callback, void* context) {
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->start_async_tx) {
|
||||
ret = device->interconnect->start_async_tx(callback, context);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ bool subghz_devices_start_async_tx(const SubGhzDevice* device, void* callback, v
|
||||
|
||||
bool subghz_devices_is_async_complete_tx(const SubGhzDevice* device) {
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->is_async_complete_tx) {
|
||||
ret = device->interconnect->is_async_complete_tx();
|
||||
}
|
||||
@@ -151,35 +151,35 @@ bool subghz_devices_is_async_complete_tx(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
void subghz_devices_stop_async_tx(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->stop_async_tx) {
|
||||
device->interconnect->stop_async_tx();
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_set_rx(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->set_rx) {
|
||||
device->interconnect->set_rx();
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_flush_rx(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->flush_rx) {
|
||||
device->interconnect->flush_rx();
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_start_async_rx(const SubGhzDevice* device, void* callback, void* context) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->start_async_rx) {
|
||||
device->interconnect->start_async_rx(callback, context);
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_stop_async_rx(const SubGhzDevice* device) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->stop_async_rx) {
|
||||
device->interconnect->stop_async_rx();
|
||||
}
|
||||
@@ -187,7 +187,7 @@ void subghz_devices_stop_async_rx(const SubGhzDevice* device) {
|
||||
|
||||
float subghz_devices_get_rssi(const SubGhzDevice* device) {
|
||||
float ret = 0;
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->get_rssi) {
|
||||
ret = device->interconnect->get_rssi();
|
||||
}
|
||||
@@ -195,8 +195,8 @@ float subghz_devices_get_rssi(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
uint8_t subghz_devices_get_lqi(const SubGhzDevice* device) {
|
||||
furi_check(device);
|
||||
uint8_t ret = 0;
|
||||
furi_assert(device);
|
||||
if(device->interconnect->get_lqi) {
|
||||
ret = device->interconnect->get_lqi();
|
||||
}
|
||||
@@ -204,8 +204,8 @@ uint8_t subghz_devices_get_lqi(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
bool subghz_devices_rx_pipe_not_empty(const SubGhzDevice* device) {
|
||||
furi_check(device);
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
if(device->interconnect->rx_pipe_not_empty) {
|
||||
ret = device->interconnect->rx_pipe_not_empty();
|
||||
}
|
||||
@@ -214,7 +214,7 @@ bool subghz_devices_rx_pipe_not_empty(const SubGhzDevice* device) {
|
||||
|
||||
bool subghz_devices_is_rx_data_crc_valid(const SubGhzDevice* device) {
|
||||
bool ret = false;
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->is_rx_data_crc_valid) {
|
||||
ret = device->interconnect->is_rx_data_crc_valid();
|
||||
}
|
||||
@@ -222,14 +222,14 @@ bool subghz_devices_is_rx_data_crc_valid(const SubGhzDevice* device) {
|
||||
}
|
||||
|
||||
void subghz_devices_read_packet(const SubGhzDevice* device, uint8_t* data, uint8_t* size) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->read_packet) {
|
||||
device->interconnect->read_packet(data, size);
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_devices_write_packet(const SubGhzDevice* device, const uint8_t* data, uint8_t size) {
|
||||
furi_assert(device);
|
||||
furi_check(device);
|
||||
if(device->interconnect->write_packet) {
|
||||
device->interconnect->write_packet(data, size);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user