Oh no, need to push exclusive special code

It comes with the price, but we wanna some new features so...

TODO: Remake this to not use un-defines
Make it use "log level" when making defines instead
This commit is contained in:
MX
2026-06-09 05:43:45 +03:00
parent fb701333f0
commit 6ac1e754aa
27 changed files with 84 additions and 19 deletions
@@ -51,10 +51,12 @@ struct Expansion {
ExpansionState state;
};
#ifndef LOGS_RELEASE_BUILD
static const char* const expansion_uart_names[] = {
"USART",
"LPUART",
};
#endif
// Called from the serial control thread
static void expansion_detect_callback(void* context) {
+6
View File
@@ -31,7 +31,11 @@ static void rpc_system_app_send_state_response(
response->which_content = PB_Main_app_state_response_tag;
response->content.app_state_response.state = state;
#ifndef LOGS_RELEASE_BUILD
FURI_LOG_D(TAG, "%s", name);
#else
UNUSED(name);
#endif
rpc_send(rpc_app->session, response);
free(response);
@@ -371,7 +375,9 @@ void rpc_system_app_confirm(RpcAppSystem* rpc_app, bool result) {
rpc_app->last_event_type == RpcAppEventTypeDataExchange);
const uint32_t last_command_id = rpc_app->last_command_id;
#ifndef LOGS_RELEASE_BUILD
const RpcAppSystemEventType last_event_type = rpc_app->last_event_type;
#endif
rpc_app->last_command_id = 0;
rpc_app->last_event_type = RpcAppEventTypeInvalid;
+2
View File
@@ -43,8 +43,10 @@ void rpc_cli_command_start_session(PipeSide* pipe, FuriString* args, void* conte
furi_assert(context);
Rpc* rpc = context;
#ifndef LOGS_RELEASE_BUILD
uint32_t mem_before = memmgr_get_free_heap();
FURI_LOG_D(TAG, "Free memory %lu", mem_before);
#endif
furi_hal_usb_lock();
RpcSession* rpc_session = rpc_session_open(rpc, RpcOwnerUsb);
+3
View File
@@ -49,6 +49,7 @@ env = ENV.Clone(
"CPPDEFINES": [
"NDEBUG",
"FURI_DEBUG" if ENV["LIB_DEBUG"] else "FURI_NDEBUG",
"LOGS_DEBUG_BUILD" if ENV["LIB_DEBUG"] else "LOGS_RELEASE_BUILD",
],
# You can add other entries named after libraries
# If they are present, they have precedence over Default
@@ -61,6 +62,7 @@ env = ENV.Clone(
"CPPDEFINES": [
"NDEBUG",
"FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG",
"LOGS_DEBUG_BUILD" if ENV["LIB_DEBUG"] else "LOGS_RELEASE_BUILD",
],
},
"flipper_application": {
@@ -70,6 +72,7 @@ env = ENV.Clone(
"CPPDEFINES": [
"NDEBUG",
"FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG",
"LOGS_DEBUG_BUILD" if ENV["LIB_DEBUG"] else "LOGS_RELEASE_BUILD",
],
},
},
+17
View File
@@ -160,6 +160,23 @@ bool furi_log_level_from_string(const char* str, FuriLogLevel* level);
#define FURI_LOG_RAW_T(format, ...) \
furi_log_print_raw_format(FuriLogLevelTrace, format, ##__VA_ARGS__)
#ifdef LOGS_RELEASE_BUILD
// Undefine existing macros
//#undef FURI_LOG_E
//#undef FURI_LOG_W
//#undef FURI_LOG_I
#undef FURI_LOG_D
#undef FURI_LOG_T
#undef FURI_LOG_RAW_T
// Define empty macros
//#define FURI_LOG_E(tag, format, ...)
//#define FURI_LOG_W(tag, format, ...)
//#define FURI_LOG_I(tag, format, ...)
#define FURI_LOG_D(tag, format, ...)
#define FURI_LOG_T(tag, format, ...)
#define FURI_LOG_RAW_T(format, ...)
#endif
#ifdef __cplusplus
}
#endif
+5
View File
@@ -56,6 +56,7 @@ void lfrfid_worker_delay(LFRFIDWorker* worker, uint32_t milliseconds) {
}
void t5577_trace(LFRFIDT5577 t5577, const char* message) {
#ifndef LOGS_RELEASE_BUILD
if(furi_log_get_level() == FuriLogLevelTrace) {
FURI_LOG_T(TAG, "%s", message);
for(uint8_t i = 0; i < 8; i++)
@@ -63,6 +64,10 @@ void t5577_trace(LFRFIDT5577 t5577, const char* message) {
FURI_LOG_T(TAG, "Mask: %u", t5577.mask);
FURI_LOG_T(TAG, "Blocks to write: %lu", t5577.blocks_to_write);
}
#else
UNUSED(t5577);
UNUSED(message);
#endif
}
/**************************************************************************************************/
+8 -1
View File
@@ -59,6 +59,7 @@ EmvError emv_process_error(Iso14443_4aError error) {
}
static void emv_trace(EmvPoller* instance, const char* message) {
#ifndef LOGS_RELEASE_BUILD
if(furi_log_get_level() == FuriLogLevelTrace) {
FURI_LOG_T(TAG, "%s", message);
@@ -75,6 +76,10 @@ static void emv_trace(EmvPoller* instance, const char* message) {
}
printf("\r\n");
}
#else
UNUSED(instance);
UNUSED(message);
#endif
}
static bool
@@ -181,7 +186,8 @@ static bool
}
}
// Convert 4-bit to ASCII representation
// Convert 4-bit to ASCII representation
#ifndef LOGS_RELEASE_BUILD
char track_2_equiv[41];
uint8_t track_2_equiv_len = 0;
for(int x = 0; x < tlen; x++) {
@@ -196,6 +202,7 @@ static bool
}
track_2_equiv[track_2_equiv_len] = '\0';
FURI_LOG_T(TAG, "found EMV_TAG_TRACK_2 %X : %s", tag, track_2_equiv);
#endif
success = true;
break;
}
@@ -1358,6 +1358,7 @@ NfcCommand mf_classic_poller_handler_nested_calibrate(MfClassicPoller* instance)
instance->state = MfClassicPollerStateNestedController;
mf_classic_poller_halt(instance);
#ifndef LOGS_RELEASE_BUILD
uint16_t d_dist = dict_attack_ctx->d_max - dict_attack_ctx->d_min;
FURI_LOG_D(
TAG,
@@ -1365,7 +1366,7 @@ NfcCommand mf_classic_poller_handler_nested_calibrate(MfClassicPoller* instance)
dict_attack_ctx->d_min,
dict_attack_ctx->d_max,
((d_dist >= 3) && (d_dist <= 6)) ? "true" : "false");
#endif
return command;
}
@@ -418,9 +418,11 @@ static NfcCommand mf_ultralight_poller_handler_auth(MfUltralightPoller* instance
command = instance->callback(instance->general_event, instance->context);
if(!instance->mfu_event.data->auth_context.skip_auth) {
instance->auth_context.password = instance->mfu_event.data->auth_context.password;
#ifndef LOGS_RELEASE_BUILD
uint32_t pass = bit_lib_bytes_to_num_be(
instance->auth_context.password.data, sizeof(MfUltralightAuthPassword));
FURI_LOG_D(TAG, "Trying to authenticate with password %08lX", pass);
#endif
instance->error = mf_ultralight_poller_auth_pwd(instance, &instance->auth_context);
if(instance->error == MfUltralightErrorNone) {
FURI_LOG_D(TAG, "Auth success");
@@ -77,8 +77,10 @@ St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr)
ret = St25tbErrorCommunication;
break;
}
#ifndef LOGS_RELEASE_BUILD
uint8_t chip_id = bit_buffer_get_byte(instance->rx_buffer, 0);
FURI_LOG_D(TAG, "Got chip_id=0x%02X", chip_id);
#endif
if(chip_id_ptr) {
*chip_id_ptr = bit_buffer_get_byte(instance->rx_buffer, 0);
}
+2 -1
View File
@@ -351,8 +351,9 @@ static void subghz_protocol_beninca_arc_encoder_prepare_packets(
instance->generic.btn = subghz_protocol_beninca_arc_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->generic.btn))
if(subghz_block_generic_global_button_override_get(&instance->generic.btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->generic.btn);
}
// Make 3 packets with different mini counter values - 2, 4, 6
for(uint8_t i = 0; i < 3; i++) {
+2 -1
View File
@@ -265,8 +265,9 @@ static void subghz_protocol_encoder_came_atomo_get_upload(
}
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
//Send header
instance->encoder.upload[index++] =
+2 -4
View File
@@ -351,9 +351,6 @@ static void subghz_protocol_ditec_gol4_decode_key(SubGhzBlockGeneric* instance)
static void subghz_protocol_ditec_gol4_encode_key(SubGhzBlockGeneric* instance) {
// Encoder crypto part:
//
// TODO: Current issue - last bit at original remote sometimes 0 but we encode as 1, or vice versa.
// This does not affect decoding but may have issue on real receiver
//
uint8_t decrypted[GOL4_RAW_BYTES];
// Save original button for later use
@@ -364,8 +361,9 @@ static void subghz_protocol_ditec_gol4_encode_key(SubGhzBlockGeneric* instance)
instance->btn = subghz_protocol_ditec_gol4_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->btn))
if(subghz_block_generic_global_button_override_get(&instance->btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->btn);
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
+2 -1
View File
@@ -170,8 +170,9 @@ static void subghz_protocol_encoder_gangqi_get_upload(SubGhzProtocolEncoderGangQ
instance->generic.btn = subghz_protocol_gangqi_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->generic.btn))
if(subghz_block_generic_global_button_override_get(&instance->generic.btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->generic.btn);
}
uint16_t serial = (uint16_t)((instance->generic.data >> 18) & 0xFFFF);
uint8_t const_and_button = (uint8_t)(0xD0 | instance->generic.btn);
+2 -1
View File
@@ -145,8 +145,9 @@ static void subghz_protocol_encoder_hay21_get_upload(SubGhzProtocolEncoderHay21*
instance->generic.btn = subghz_protocol_hay21_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->generic.btn))
if(subghz_block_generic_global_button_override_get(&instance->generic.btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->generic.btn);
}
// Counter increment
// Check for OFEX (overflow experimental) mode
+2 -1
View File
@@ -169,8 +169,9 @@ static void subghz_protocol_encoder_hollarm_get_upload(SubGhzProtocolEncoderHoll
instance->generic.btn = subghz_protocol_hollarm_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->generic.btn))
if(subghz_block_generic_global_button_override_get(&instance->generic.btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->generic.btn);
}
uint64_t new_key = (instance->generic.data >> 12) << 12 | (instance->generic.btn << 8);
+2 -1
View File
@@ -153,8 +153,9 @@ static bool
btn = subghz_protocol_jarolift_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
+2 -1
View File
@@ -198,8 +198,9 @@ static bool subghz_protocol_keeloq_gen_data(
}
// end gendata part
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
uint32_t fix = (uint32_t)btn << 28 | instance->generic.serial;
uint32_t hop = 0;
+2 -1
View File
@@ -155,8 +155,9 @@ static bool subghz_protocol_kinggates_stylo_4k_gen_data(
btn = subghz_protocol_kinggates_stylo_4k_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
+2 -1
View File
@@ -258,8 +258,9 @@ static bool
instance->generic.btn = subghz_protocol_princeton_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->generic.btn))
if(subghz_block_generic_global_button_override_get(&instance->generic.btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->generic.btn);
}
// Reconstruction of the data
// If we have 8bit button code move serial to left by 8 bits (and 4 if 4 bits)
+2 -1
View File
@@ -179,8 +179,9 @@ static void subghz_protocol_encoder_roger_get_upload(SubGhzProtocolEncoderRoger*
btn = subghz_protocol_roger_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
// If End is not == button - transmit as is, no custom button allowed
// For "End" values 23 and 20 - transmit correct ending used for their buttons
+2 -1
View File
@@ -396,8 +396,9 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
instance->generic.btn = subghz_protocol_secplus_v2_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&instance->generic.btn))
if(subghz_block_generic_global_button_override_get(&instance->generic.btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", instance->generic.btn);
}
uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20};
uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF};
+2 -1
View File
@@ -164,8 +164,9 @@ static bool
btn = subghz_protocol_somfy_keytis_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
+2 -1
View File
@@ -125,8 +125,9 @@ static bool subghz_protocol_somfy_telis_gen_data(
btn = subghz_protocol_somfy_telis_get_btn_code();
// override button if we change it with signal settings button editor
if(subghz_block_generic_global_button_override_get(&btn))
if(subghz_block_generic_global_button_override_get(&btn)) {
FURI_LOG_D(TAG, "Button sucessfully changed to 0x%X", btn);
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
+3
View File
@@ -6,6 +6,7 @@ if ENV["DEBUG"]:
CPPDEFINES=[
"FURI_DEBUG",
"NDEBUG",
"LOGS_DEBUG_BUILD",
],
CCFLAGS=[
"-Og",
@@ -16,6 +17,7 @@ elif ENV["COMPACT"]:
CPPDEFINES=[
"FURI_NDEBUG",
"NDEBUG",
"LOGS_RELEASE_BUILD",
],
CCFLAGS=[
"-Os",
@@ -26,6 +28,7 @@ else:
CPPDEFINES=[
"FURI_NDEBUG",
"NDEBUG",
"LOGS_DEBUG_BUILD",
],
CCFLAGS=[
"-Os",
@@ -103,6 +103,7 @@ static BleEventAckStatus ble_svc_serial_event_handler(void* event, void* context
}
serial_svc->bytes_ready_to_receive -= MIN(
serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length);
#ifndef LOGS_RELEASE_BUILD
SerialServiceEvent event = {
.event = SerialServiceEventTypeDataReceived,
.data = {
@@ -111,6 +112,7 @@ static BleEventAckStatus ble_svc_serial_event_handler(void* event, void* context
}};
uint32_t buff_free_size = serial_svc->callback(event, serial_svc->context);
FURI_LOG_D(TAG, "Available buff size: %ld", buff_free_size);
#endif
furi_check(furi_mutex_release(serial_svc->buff_size_mtx) == FuriStatusOk);
}
ret = BleEventAckFlowEnable;
+2
View File
@@ -899,6 +899,7 @@ void furi_hal_subghz_stop_async_tx(void) {
free(furi_hal_subghz_async_tx.buffer);
#ifndef LOGS_RELEASE_BUILD
float duty_cycle =
100.0f * (float)furi_hal_subghz_async_tx.duty_high /
((float)furi_hal_subghz_async_tx.duty_low + (float)furi_hal_subghz_async_tx.duty_high);
@@ -908,6 +909,7 @@ void furi_hal_subghz_stop_async_tx(void) {
(double)furi_hal_subghz_async_tx.duty_high,
(double)furi_hal_subghz_async_tx.duty_low,
(double)duty_cycle);
#endif
furi_hal_subghz.state = SubGhzStateIdle;
}