Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into gornek/nfc_refactoring_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
gornekich committed Oct 16, 2023
2 parents 5139d17 + e664159 commit 5a59a5b
Show file tree
Hide file tree
Showing 53 changed files with 427 additions and 277 deletions.
18 changes: 14 additions & 4 deletions applications/debug/ccid_test/ccid_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,25 @@ void icc_power_on_callback(uint8_t* atrBuffer, uint32_t* atrlen, void* context)
iso7816_answer_to_reset(atrBuffer, atrlen);
}

void xfr_datablock_callback(uint8_t* dataBlock, uint32_t* dataBlockLen, void* context) {
//dataBlock points to the buffer
//dataBlockLen tells reader how nany bytes should be read
void xfr_datablock_callback(
const uint8_t* dataBlock,
uint32_t dataBlockLen,
uint8_t* responseDataBlock,
uint32_t* responseDataBlockLen,
void* context) {
UNUSED(context);

struct ISO7816_Command_APDU commandAPDU;
iso7816_read_command_apdu(&commandAPDU, dataBlock, dataBlockLen);

struct ISO7816_Response_APDU responseAPDU;
//class not supported
responseAPDU.SW1 = 0x6E;
responseAPDU.SW2 = 0x00;

iso7816_write_response_apdu(&responseAPDU, dataBlock, dataBlockLen);
iso7816_write_response_apdu(&responseAPDU, responseDataBlock, responseDataBlockLen);
}

static const CcidCallbacks ccid_cb = {
Expand All @@ -66,7 +76,7 @@ static void ccid_test_app_render_callback(Canvas* canvas, void* ctx) {
canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
}

static void ccid_test_app__input_callback(InputEvent* input_event, void* ctx) {
static void ccid_test_app_input_callback(InputEvent* input_event, void* ctx) {
FuriMessageQueue* event_queue = ctx;

CcidTestAppEvent event;
Expand Down Expand Up @@ -94,7 +104,7 @@ CcidTestApp* ccid_test_app_alloc() {
//message queue
app->event_queue = furi_message_queue_alloc(8, sizeof(CcidTestAppEvent));
furi_check(app->event_queue);
view_port_input_callback_set(app->view_port, ccid_test_app__input_callback, app->event_queue);
view_port_input_callback_set(app->view_port, ccid_test_app_input_callback, app->event_queue);

return app;
}
Expand Down
7 changes: 4 additions & 3 deletions applications/debug/ccid_test/iso7816_t0_apdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
#include <furi.h>
#include "iso7816_t0_apdu.h"

void iso7816_answer_to_reset(uint8_t* atrBuffer, uint32_t* atrlen) {
void iso7816_answer_to_reset(uint8_t* dataBuffer, uint32_t* atrlen) {
//minimum valid ATR: https://smartcard-atr.apdu.fr/parse?ATR=3B+00
uint8_t AtrBuffer[2] = {
0x3B, //TS (direct convention)
0x00 // T0 (Y(1): b0000, K: 0 (historical bytes))
};
*atrlen = 2;

memcpy(atrBuffer, AtrBuffer, sizeof(uint8_t) * (*atrlen));
memcpy(dataBuffer, AtrBuffer, sizeof(uint8_t) * (*atrlen));
}

void iso7816_read_command_apdu(
struct ISO7816_Command_APDU* command,
const uint8_t* dataBuffer,
uint32_t dataLen) {
furi_assert(dataLen <= 4);
UNUSED(dataLen);
command->CLA = dataBuffer[0];
command->INS = dataBuffer[1];
command->P1 = dataBuffer[2];
command->P2 = dataBuffer[3];
command->Lc = dataBuffer[4];
}

void iso7816_write_response_apdu(
Expand Down
8 changes: 4 additions & 4 deletions applications/debug/ccid_test/iso7816_t0_apdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
struct ISO7816_Command_APDU {
//header
uint8_t CLA;
uint32_t INS;
uint8_t INS;
uint8_t P1;
uint8_t P2;

//body
uint8_t Nc;
uint8_t Ne;
uint8_t Lc;
uint8_t Le;
} __attribute__((packed));

struct ISO7816_Response_APDU {
uint8_t SW1;
uint32_t SW2;
uint8_t SW2;
} __attribute__((packed));

void iso7816_answer_to_reset(uint8_t* atrBuffer, uint32_t* atrlen);
Expand Down
4 changes: 2 additions & 2 deletions applications/examples/example_apps_assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ We recommend to use the `APP_ASSETS_PATH` macro to get the path to the Apps Asse

## What is the difference between the Apps Assets folder and the Apps Data folder?

The Apps Assets folder is used to store the data <u>provided</u> with the application. For example, if you want to create a game, you can store game levels (contant data) in the Apps Assets folder.
The Apps Assets folder is used to store the data <u>provided</u> with the application. For example, if you want to create a game, you can store game levels (content data) in the Apps Assets folder.

The Apps Data folder is used to store data <u>generated</u> by the application. For example, if you want to create a game, you can save the progress of the game (user-generated data) in the Apps Data folder.

Expand Down Expand Up @@ -55,4 +55,4 @@ When app is launched, the `files` folder will be unpacked to the Apps Assets fol

The data is unpacked when the application starts, if the application is launched for the first time, or if the data within the application is updated.

When an application is compiled, the contents of the "files" folder are hashed and stored within the application itself. When the application starts, this hash is compared to the hash stored in the `.assets.signature` file. If the hashes differ or the `.assets.signature` file does not exist, the application folder is deleted and the new data is unpacked.
When an application is compiled, the contents of the "files" folder are hashed and stored within the application itself. When the application starts, this hash is compared to the hash stored in the `.assets.signature` file. If the hashes differ or the `.assets.signature` file does not exist, the application folder is deleted and the new data is unpacked.
4 changes: 2 additions & 2 deletions applications/examples/example_apps_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ We recommend to use the `APP_DATA_PATH` macro to get the path to the Apps Data f

## What is the difference between the Apps Assets folder and the Apps Data folder?

The Apps Assets folder is used to store the data <u>provided</u> with the application. For example, if you want to create a game, you can store game levels (contant data) in the Apps Assets folder.
The Apps Assets folder is used to store the data <u>provided</u> with the application. For example, if you want to create a game, you can store game levels (content data) in the Apps Assets folder.

The Apps Data folder is used to store data <u>generated</u> by the application. For example, if you want to create a game, you can save the progress of the game (user-generated data) in the Apps Data folder.
The Apps Data folder is used to store data <u>generated</u> by the application. For example, if you want to create a game, you can save the progress of the game (user-generated data) in the Apps Data folder.
2 changes: 1 addition & 1 deletion applications/examples/example_plugins/plugin_interface.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

/* Common interface between a plugin and host applicaion */
/* Common interface between a plugin and host application */

#define PLUGIN_APP_ID "example_plugins"
#define PLUGIN_API_VERSION 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

/* Common interface between a plugin and host applicaion */
/* Common interface between a plugin and host application */

#define PLUGIN_APP_ID "example_plugins_advanced"
#define PLUGIN_API_VERSION 1
Expand Down
11 changes: 5 additions & 6 deletions applications/examples/example_thermo/example_thermo.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void example_thermo_request_temperature(ExampleThermoContext* context) {
bool success = false;
do {
/* Each communication with a 1-wire device starts by a reset.
The functon will return true if a device responded with a presence pulse. */
The function will return true if a device responded with a presence pulse. */
if(!onewire_host_reset(onewire)) break;
/* After the reset, a ROM operation must follow.
If there is only one device connected, the "Skip ROM" command is most appropriate
Expand Down Expand Up @@ -130,7 +130,7 @@ static void example_thermo_read_temperature(ExampleThermoContext* context) {
size_t attempts_left = 10;
do {
/* Each communication with a 1-wire device starts by a reset.
The functon will return true if a device responded with a presence pulse. */
The function will return true if a device responded with a presence pulse. */
if(!onewire_host_reset(onewire)) continue;

/* After the reset, a ROM operation must follow.
Expand Down Expand Up @@ -221,8 +221,7 @@ static void example_thermo_draw_callback(Canvas* canvas, void* ctx) {
canvas_draw_line(canvas, 0, 16, 128, 16);

canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
canvas, middle_x, 30, AlignCenter, AlignBottom, "Connnect thermometer");
canvas_draw_str_aligned(canvas, middle_x, 30, AlignCenter, AlignBottom, "Connect thermometer");

snprintf(
text_store,
Expand All @@ -237,7 +236,7 @@ static void example_thermo_draw_callback(Canvas* canvas, void* ctx) {
float temp;
char temp_units;

/* The applicaton is locale-aware.
/* The application is locale-aware.
Change Settings->System->Units to check it out. */
switch(locale_get_measurement_unit()) {
case LocaleMeasurementUnitsMetric:
Expand Down Expand Up @@ -355,7 +354,7 @@ int32_t example_thermo_main(void* p) {
/* Allocate all of the necessary structures */
ExampleThermoContext* context = example_thermo_context_alloc();

/* Start the applicaton's main loop. It won't return until the application was requested to exit. */
/* Start the application's main loop. It won't return until the application was requested to exit. */
example_thermo_run(context);

/* Release all unneeded resources */
Expand Down
4 changes: 2 additions & 2 deletions applications/main/bad_usb/helpers/ducky_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
return delay_val;
} else if(delay_val < 0) { // Script error
bad_usb->st.error_line = bad_usb->st.line_cur - 1;
FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur - 1U);
FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_usb->st.line_cur - 1U);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_usb->defdelay);
Expand Down Expand Up @@ -329,7 +329,7 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
return delay_val;
} else if(delay_val < 0) {
bad_usb->st.error_line = bad_usb->st.line_cur;
FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur);
FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_usb->st.line_cur);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_usb->defdelay);
Expand Down
6 changes: 3 additions & 3 deletions applications/main/bad_usb/helpers/ducky_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ typedef enum {

typedef struct {
BadUsbWorkerState state;
uint16_t line_cur;
uint16_t line_nb;
size_t line_cur;
size_t line_nb;
uint32_t delay_remain;
uint16_t error_line;
size_t error_line;
char error[64];
} BadUsbState;

Expand Down
2 changes: 1 addition & 1 deletion applications/main/bad_usb/helpers/ducky_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int32_t ducky_fnc_string(BadUsbScript* bad_usb, const char* line, int32_t
furi_string_cat(bad_usb->string_print, "\n");
}

if(bad_usb->stringdelay == 0) { // stringdelay not set - run command immidiately
if(bad_usb->stringdelay == 0) { // stringdelay not set - run command immediately
bool state = ducky_string(bad_usb, furi_string_get_cstr(bad_usb->string_print));
if(!state) {
return ducky_error(bad_usb, "Invalid string %s", line);
Expand Down
8 changes: 4 additions & 4 deletions applications/main/bad_usb/views/bad_usb_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 127, 33, AlignRight, AlignBottom, "ERROR:");
canvas_set_font(canvas, FontSecondary);
furi_string_printf(disp_str, "line %u", model->state.error_line);
furi_string_printf(disp_str, "line %zu", model->state.error_line);
canvas_draw_str_aligned(
canvas, 127, 46, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand All @@ -105,7 +105,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
}
canvas_set_font(canvas, FontBigNumbers);
furi_string_printf(
disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
disp_str, "%zu", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand All @@ -124,7 +124,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
}
canvas_set_font(canvas, FontBigNumbers);
furi_string_printf(
disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
disp_str, "%zu", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand All @@ -142,7 +142,7 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
}
canvas_set_font(canvas, FontBigNumbers);
furi_string_printf(
disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
disp_str, "%zu", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef enum {
const char*
subghz_frequency_analyzer_log_get_order_name(SubGhzFrequencyAnalyzerLogOrderBy order_by);

TUPLE_DEF2(
TUPLE_DEF2( //-V1048
SubGhzFrequencyAnalyzerLogItem,
(seq, uint8_t),
(frequency, uint32_t),
Expand Down
7 changes: 5 additions & 2 deletions applications/main/subghz/scenes/subghz_scene_set_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
subghz->txrx, "AM650", 315000000, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 400);
break;
case SubmenuIndexNiceFlo12bit:
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4
generated_protocol = subghz_txrx_gen_data_protocol(
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 12);
break;
Expand All @@ -144,7 +144,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 24);
break;
case SubmenuIndexCAME12bit:
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4
generated_protocol = subghz_txrx_gen_data_protocol(
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 12);
break;
Expand Down Expand Up @@ -198,14 +198,17 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 390000000);
break;
case SubmenuIndexSecPlus_v2_310_00:
key = (key & 0x7FFFF3FC); // 850LM pairing
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
subghz->txrx, "AM650", 310000000, key, 0x68, 0xE500000);
break;
case SubmenuIndexSecPlus_v2_315_00:
key = (key & 0x7FFFF3FC); // 850LM pairing
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
subghz->txrx, "AM650", 315000000, key, 0x68, 0xE500000);
break;
case SubmenuIndexSecPlus_v2_390_00:
key = (key & 0x7FFFF3FC); // 850LM pairing
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
subghz->txrx, "AM650", 390000000, key, 0x68, 0xE500000);
break;
Expand Down
2 changes: 1 addition & 1 deletion applications/main/subghz/subghz_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
}
}

printf("\r\nPackets received \033[0;32m%u\033[0m\r\n", instance->packet_count);
printf("\r\nPackets received \033[0;32m%zu\033[0m\r\n", instance->packet_count);

// Cleanup
subghz_receiver_free(receiver);
Expand Down
Loading

0 comments on commit 5a59a5b

Please sign in to comment.