Merge branch 'fz-dev' into dev

This commit is contained in:
MX 2022-10-26 19:27:45 +03:00
commit 89e27d10a2
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
14 changed files with 234 additions and 47 deletions

View file

@ -6,6 +6,7 @@
#define RAW_FILE_NAME "RAW_" #define RAW_FILE_NAME "RAW_"
#define TAG "SubGhzSceneReadRAW" #define TAG "SubGhzSceneReadRAW"
#define RAW_THRESHOLD_RSSI_LOW_COUNT 10
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) { bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
bool ret = false; bool ret = false;
@ -77,24 +78,33 @@ void subghz_scene_read_raw_on_enter(void* context) {
switch(subghz->txrx->rx_key_state) { switch(subghz->txrx->rx_key_state) {
case SubGhzRxKeyStateBack: case SubGhzRxKeyStateBack:
subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, ""); subghz_read_raw_set_status(
subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "", subghz->txrx->raw_threshold_rssi);
break; break;
case SubGhzRxKeyStateRAWLoad: case SubGhzRxKeyStateRAWLoad:
path_extract_filename(subghz->file_path, file_name, true); path_extract_filename(subghz->file_path, file_name, true);
subghz_read_raw_set_status( subghz_read_raw_set_status(
subghz->subghz_read_raw, subghz->subghz_read_raw,
SubGhzReadRAWStatusLoadKeyTX, SubGhzReadRAWStatusLoadKeyTX,
furi_string_get_cstr(file_name)); furi_string_get_cstr(file_name),
subghz->txrx->raw_threshold_rssi);
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break; break;
case SubGhzRxKeyStateRAWSave: case SubGhzRxKeyStateRAWSave:
path_extract_filename(subghz->file_path, file_name, true); path_extract_filename(subghz->file_path, file_name, true);
subghz_read_raw_set_status( subghz_read_raw_set_status(
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, furi_string_get_cstr(file_name)); subghz->subghz_read_raw,
SubGhzReadRAWStatusSaveKey,
furi_string_get_cstr(file_name),
subghz->txrx->raw_threshold_rssi);
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break; break;
default: default:
subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusStart, ""); subghz_read_raw_set_status(
subghz->subghz_read_raw,
SubGhzReadRAWStatusStart,
"",
subghz->txrx->raw_threshold_rssi);
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
break; break;
} }
@ -291,7 +301,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
if(subghz->txrx->rx_key_state != SubGhzRxKeyStateIDLE) { if(subghz->txrx->rx_key_state != SubGhzRxKeyStateIDLE) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
} else { } else {
//subghz_get_preset_name(subghz, subghz->error_str); subghz->txrx->raw_threshold_rssi_low_count = RAW_THRESHOLD_RSSI_LOW_COUNT;
if(subghz_protocol_raw_save_to_file_init( if(subghz_protocol_raw_save_to_file_init(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, (SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
RAW_FILE_NAME, RAW_FILE_NAME,
@ -337,7 +347,35 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz->subghz_read_raw, subghz->subghz_read_raw,
subghz_protocol_raw_get_sample_write( subghz_protocol_raw_get_sample_write(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result)); (SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result));
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, furi_hal_subghz_get_rssi());
float rssi = furi_hal_subghz_get_rssi();
if(subghz->txrx->raw_threshold_rssi == SUBGHZ_RAW_TRESHOLD_MIN) {
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, true);
subghz_protocol_raw_save_to_file_pause(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, false);
} else {
if(rssi < subghz->txrx->raw_threshold_rssi) {
subghz->txrx->raw_threshold_rssi_low_count++;
if(subghz->txrx->raw_threshold_rssi_low_count > RAW_THRESHOLD_RSSI_LOW_COUNT) {
subghz->txrx->raw_threshold_rssi_low_count = RAW_THRESHOLD_RSSI_LOW_COUNT;
}
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, false);
} else {
subghz->txrx->raw_threshold_rssi_low_count = 0;
}
if(subghz->txrx->raw_threshold_rssi_low_count == RAW_THRESHOLD_RSSI_LOW_COUNT) {
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, false);
subghz_protocol_raw_save_to_file_pause(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, true);
} else {
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, true);
subghz_protocol_raw_save_to_file_pause(
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, false);
}
}
break; break;
case SubGhzNotificationStateTx: case SubGhzNotificationStateTx:
notification_message(subghz->notifications, &sequence_blink_magenta_10); notification_message(subghz->notifications, &sequence_blink_magenta_10);

View file

@ -1,4 +1,5 @@
#include "../subghz_i.h" #include "../subghz_i.h"
#include <lib/toolbox/value_index.h>
#include <lib/subghz/protocols/raw.h> #include <lib/subghz/protocols/raw.h>
@ -11,6 +12,36 @@ enum SubGhzSettingIndex {
SubGhzSettingIndexDetectRaw, SubGhzSettingIndexDetectRaw,
SubGhzSettingIndexRSSIThreshold, SubGhzSettingIndexRSSIThreshold,
SubGhzSettingIndexLock, SubGhzSettingIndexLock,
SubGhzSettingIndexRAWThesholdRSSI,
};
#define RAW_THRESHOLD_RSSI_COUNT 11
const char* const raw_theshold_rssi_text[RAW_THRESHOLD_RSSI_COUNT] = {
"-----",
"-85.0",
"-80.0",
"-75.0",
"-70.0",
"-65.0",
"-60.0",
"-55.0",
"-50.0",
"-45.0",
"-40.0",
};
const float raw_theshold_rssi_value[RAW_THRESHOLD_RSSI_COUNT] = {
-90.0f,
-85.0f,
-80.0f,
-75.0f,
-70.0f,
-65.0f,
-60.0f,
-55.0f,
-50.0f,
-45.0f,
-40.0f,
}; };
#define HOPPING_COUNT 2 #define HOPPING_COUNT 2
@ -249,6 +280,14 @@ static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item)
}*/ }*/
} }
static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, raw_theshold_rssi_text[index]);
subghz->txrx->raw_threshold_rssi = raw_theshold_rssi_value[index];
}
static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) { static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
furi_assert(context); furi_assert(context);
SubGhz* subghz = context; SubGhz* subghz = context;
@ -356,7 +395,19 @@ void subghz_scene_receiver_config_on_enter(void* context) {
subghz_scene_receiver_config_var_list_enter_callback, subghz_scene_receiver_config_var_list_enter_callback,
subghz); subghz);
} }
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
SubGhzCustomEventManagerSet) {
item = variable_item_list_add(
subghz->variable_item_list,
"RSSI Threshold:",
RAW_THRESHOLD_RSSI_COUNT,
subghz_scene_receiver_config_set_raw_threshold_rssi,
subghz);
value_index = value_index_float(
subghz->txrx->raw_threshold_rssi, raw_theshold_rssi_value, RAW_THRESHOLD_RSSI_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, raw_theshold_rssi_text[value_index]);
}
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
} }

View file

@ -234,6 +234,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
subghz->txrx->history = subghz_history_alloc(); subghz->txrx->history = subghz_history_alloc();
} }
subghz->txrx->raw_threshold_rssi = SUBGHZ_RAW_TRESHOLD_MIN;
subghz->txrx->worker = subghz_worker_alloc(); subghz->txrx->worker = subghz_worker_alloc();
subghz->txrx->fff_data = flipper_format_string_alloc(); subghz->txrx->fff_data = flipper_format_string_alloc();

View file

@ -72,6 +72,9 @@ struct SubGhzTxRx {
uint8_t hopper_timeout; uint8_t hopper_timeout;
uint8_t hopper_idx_frequency; uint8_t hopper_idx_frequency;
SubGhzRxKeyState rx_key_state; SubGhzRxKeyState rx_key_state;
float raw_threshold_rssi;
uint8_t raw_threshold_rssi_low_count;
}; };
typedef struct SubGhzTxRx SubGhzTxRx; typedef struct SubGhzTxRx SubGhzTxRx;

View file

@ -23,11 +23,13 @@ typedef struct {
FuriString* sample_write; FuriString* sample_write;
FuriString* file_name; FuriString* file_name;
uint8_t* rssi_history; uint8_t* rssi_history;
uint8_t rssi_curret;
bool rssi_history_end; bool rssi_history_end;
uint8_t ind_write; uint8_t ind_write;
uint8_t ind_sin; uint8_t ind_sin;
SubGhzReadRAWStatus status; SubGhzReadRAWStatus status;
bool raw_send_only; bool raw_send_only;
float raw_threshold_rssi;
} SubGhzReadRAWModel; } SubGhzReadRAWModel;
void subghz_read_raw_set_callback( void subghz_read_raw_set_callback(
@ -55,21 +57,27 @@ void subghz_read_raw_add_data_statusbar(
true); true);
} }
void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi) { void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi, bool trace) {
furi_assert(instance); furi_assert(instance);
uint8_t u_rssi = 0; uint8_t u_rssi = 0;
if(rssi < -90) { if(rssi < SUBGHZ_RAW_TRESHOLD_MIN) {
u_rssi = 0; u_rssi = 0;
} else { } else {
u_rssi = (uint8_t)((rssi + 90) / 2.7); u_rssi = (uint8_t)((rssi - SUBGHZ_RAW_TRESHOLD_MIN) / 2.7);
} }
with_view_model( with_view_model(
instance->view, instance->view,
SubGhzReadRAWModel * model, SubGhzReadRAWModel * model,
{ {
model->rssi_history[model->ind_write++] = u_rssi; model->rssi_curret = u_rssi;
if(trace) {
model->rssi_history[model->ind_write++] = u_rssi;
} else {
model->rssi_history[model->ind_write] = u_rssi;
}
if(model->ind_write > SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE) { if(model->ind_write > SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE) {
model->rssi_history_end = true; model->rssi_history_end = true;
model->ind_write = 0; model->ind_write = 0;
@ -188,24 +196,53 @@ void subghz_read_raw_draw_scale(Canvas* canvas, SubGhzReadRAWModel* model) {
void subghz_read_raw_draw_rssi(Canvas* canvas, SubGhzReadRAWModel* model) { void subghz_read_raw_draw_rssi(Canvas* canvas, SubGhzReadRAWModel* model) {
int ind = 0; int ind = 0;
int base = 0; int base = 0;
uint8_t width = 2;
if(model->rssi_history_end == false) { if(model->rssi_history_end == false) {
for(int i = model->ind_write; i >= 0; i--) { for(int i = model->ind_write; i >= 0; i--) {
canvas_draw_line(canvas, i, 47, i, 47 - model->rssi_history[i]); canvas_draw_line(canvas, i, 47, i, 47 - model->rssi_history[i]);
} }
canvas_draw_line(
canvas, model->ind_write + 1, 47, model->ind_write + 1, 47 - model->rssi_curret);
if(model->ind_write > 3) { if(model->ind_write > 3) {
canvas_draw_line(canvas, model->ind_write, 47, model->ind_write, 13); canvas_draw_line(
canvas, model->ind_write - 1, 47, model->ind_write - 1, 47 - model->rssi_curret);
for(uint8_t i = 13; i < 47; i += width * 2) {
canvas_draw_line(canvas, model->ind_write, i, model->ind_write, i + width);
}
canvas_draw_line(canvas, model->ind_write - 2, 12, model->ind_write + 2, 12); canvas_draw_line(canvas, model->ind_write - 2, 12, model->ind_write + 2, 12);
canvas_draw_line(canvas, model->ind_write - 1, 13, model->ind_write + 1, 13); canvas_draw_line(canvas, model->ind_write - 1, 13, model->ind_write + 1, 13);
} }
} else { } else {
int i = 0;
base = SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE - model->ind_write; base = SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE - model->ind_write;
for(int i = SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE; i >= 0; i--) { for(i = SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE; i > 0; i--) {
ind = i - base; ind = i - base;
if(ind < 0) ind += SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE; if(ind < 0) ind += SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE;
canvas_draw_line(canvas, i, 47, i, 47 - model->rssi_history[ind]); canvas_draw_line(canvas, i, 47, i, 47 - model->rssi_history[ind]);
} }
canvas_draw_line( canvas_draw_line(
canvas, SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE, 47, SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE, 13); canvas,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE - 1,
47,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE - 1,
47 - model->rssi_curret);
canvas_draw_line(
canvas,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE + 1,
47,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE + 1,
47 - model->rssi_curret);
for(uint8_t i = 13; i < 47; i += width * 2) {
canvas_draw_line(
canvas,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE,
i,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE,
i + width);
}
canvas_draw_line( canvas_draw_line(
canvas, canvas,
SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE - 2, SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE - 2,
@ -221,6 +258,24 @@ void subghz_read_raw_draw_rssi(Canvas* canvas, SubGhzReadRAWModel* model) {
} }
} }
void subghz_read_raw_draw_threshold_rssi(Canvas* canvas, SubGhzReadRAWModel* model) {
uint8_t x = 118;
uint8_t y = 48;
if(model->raw_threshold_rssi > SUBGHZ_RAW_TRESHOLD_MIN) {
uint8_t x = 118;
y -= (uint8_t)((model->raw_threshold_rssi - SUBGHZ_RAW_TRESHOLD_MIN) / 2.7);
uint8_t width = 3;
for(uint8_t i = 0; i < x; i += width * 2) {
canvas_draw_line(canvas, i, y, i + width, y);
}
}
canvas_draw_line(canvas, x, y - 2, x, y + 2);
canvas_draw_line(canvas, x - 1, y - 1, x - 1, y + 1);
canvas_draw_dot(canvas, x - 2, y);
}
void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) { void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
uint8_t graphics_mode = 1; uint8_t graphics_mode = 1;
canvas_set_color(canvas, ColorBlack); canvas_set_color(canvas, ColorBlack);
@ -281,8 +336,9 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
} else { } else {
subghz_read_raw_draw_rssi(canvas, model); subghz_read_raw_draw_rssi(canvas, model);
subghz_read_raw_draw_scale(canvas, model); subghz_read_raw_draw_scale(canvas, model);
subghz_read_raw_draw_threshold_rssi(canvas, model);
canvas_set_font_direction(canvas, CanvasDirectionBottomToTop); canvas_set_font_direction(canvas, CanvasDirectionBottomToTop);
canvas_draw_str(canvas, 126, 40, "RSSI"); canvas_draw_str(canvas, 128, 40, "RSSI");
canvas_set_font_direction(canvas, CanvasDirectionLeftToRight); canvas_set_font_direction(canvas, CanvasDirectionLeftToRight);
} }
} }
@ -440,7 +496,8 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
void subghz_read_raw_set_status( void subghz_read_raw_set_status(
SubGhzReadRAW* instance, SubGhzReadRAW* instance,
SubGhzReadRAWStatus status, SubGhzReadRAWStatus status,
const char* file_name) { const char* file_name,
float raw_threshold_rssi) {
furi_assert(instance); furi_assert(instance);
switch(status) { switch(status) {
@ -454,6 +511,7 @@ void subghz_read_raw_set_status(
model->ind_write = 0; model->ind_write = 0;
furi_string_reset(model->file_name); furi_string_reset(model->file_name);
furi_string_set(model->sample_write, "0 spl."); furi_string_set(model->sample_write, "0 spl.");
model->raw_threshold_rssi = raw_threshold_rssi;
}, },
true); true);
break; break;
@ -544,6 +602,7 @@ SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only) {
model->file_name = furi_string_alloc(); model->file_name = furi_string_alloc();
model->raw_send_only = raw_send_only; model->raw_send_only = raw_send_only;
model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t)); model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
model->raw_threshold_rssi = -127.0f;
}, },
true); true);

View file

@ -3,6 +3,8 @@
#include <gui/view.h> #include <gui/view.h>
#include "../helpers/subghz_custom_event.h" #include "../helpers/subghz_custom_event.h"
#define SUBGHZ_RAW_TRESHOLD_MIN -90.0f
typedef struct SubGhzReadRAW SubGhzReadRAW; typedef struct SubGhzReadRAW SubGhzReadRAW;
typedef void (*SubGhzReadRAWCallback)(SubGhzCustomEvent event, void* context); typedef void (*SubGhzReadRAWCallback)(SubGhzCustomEvent event, void* context);
@ -40,11 +42,12 @@ void subghz_read_raw_stop_send(SubGhzReadRAW* instance);
void subghz_read_raw_update_sin(SubGhzReadRAW* instance); void subghz_read_raw_update_sin(SubGhzReadRAW* instance);
void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi); void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi, bool trace);
void subghz_read_raw_set_status( void subghz_read_raw_set_status(
SubGhzReadRAW* instance, SubGhzReadRAW* instance,
SubGhzReadRAWStatus status, SubGhzReadRAWStatus status,
const char* file_name); const char* file_name,
float raw_threshold_rssi);
View* subghz_read_raw_get_view(SubGhzReadRAW* subghz_static); View* subghz_read_raw_get_view(SubGhzReadRAW* subghz_static);

View file

@ -19,7 +19,7 @@ static const SubGhzBlockConst ws_oregon2_const = {
}; };
#define OREGON2_PREAMBLE_BITS 19 #define OREGON2_PREAMBLE_BITS 19
#define OREGON2_PREAMBLE_MASK ((1 << (OREGON2_PREAMBLE_BITS + 1)) - 1) #define OREGON2_PREAMBLE_MASK 0b1111111111111111111
#define OREGON2_SENSOR_ID(d) (((d) >> 16) & 0xFFFF) #define OREGON2_SENSOR_ID(d) (((d) >> 16) & 0xFFFF)
#define OREGON2_CHECKSUM_BITS 8 #define OREGON2_CHECKSUM_BITS 8
@ -103,6 +103,7 @@ static ManchesterEvent level_and_duration_to_event(bool level, uint32_t duration
// From sensor id code return amount of bits in variable section // From sensor id code return amount of bits in variable section
static uint8_t oregon2_sensor_id_var_bits(uint16_t sensor_id) { static uint8_t oregon2_sensor_id_var_bits(uint16_t sensor_id) {
if(sensor_id == 0xEC40) return 16; if(sensor_id == 0xEC40) return 16;
if(sensor_id == 0x1D20) return 24;
return 0; return 0;
} }
@ -119,18 +120,30 @@ static void ws_oregon2_decode_const_data(WSBlockGeneric* ws_block) {
ws_block->battery_low = (ws_block->data & OREGON2_FLAG_BAT_LOW) ? 1 : 0; ws_block->battery_low = (ws_block->data & OREGON2_FLAG_BAT_LOW) ? 1 : 0;
} }
static void uint16_t bcd_decode_short(uint32_t data) {
ws_oregon2_decode_var_data(WSBlockGeneric* ws_block, uint16_t sensor_id, uint32_t var_data) { return (data & 0xF) * 10 + ((data >> 4) & 0xF);
int16_t temp_val; }
if(sensor_id == 0xEC40) {
temp_val = ((var_data >> 4) & 0xF) * 10 + ((var_data >> 8) & 0xF);
temp_val *= 10;
temp_val += (var_data >> 12) & 0xF;
if(var_data & 0xF) temp_val = -temp_val;
} else
return;
ws_block->temp = (float)temp_val / 10.0; static float ws_oregon2_decode_temp(uint32_t data) {
int32_t temp_val;
temp_val = bcd_decode_short(data >> 4);
temp_val *= 10;
temp_val += (data >> 12) & 0xF;
if(data & 0xF) temp_val = -temp_val;
return (float)temp_val / 10.0;
}
static void ws_oregon2_decode_var_data(WSBlockGeneric* ws_b, uint16_t sensor_id, uint32_t data) {
switch(sensor_id) {
case 0xEC40:
ws_b->temp = ws_oregon2_decode_temp(data);
ws_b->humidity = WS_NO_HUMIDITY;
break;
case 0x1D20:
ws_b->humidity = bcd_decode_short(data);
ws_b->temp = ws_oregon2_decode_temp(data >> 8);
break;
}
} }
void ws_protocol_decoder_oregon2_feed(void* context, bool level, uint32_t duration) { void ws_protocol_decoder_oregon2_feed(void* context, bool level, uint32_t duration) {
@ -347,8 +360,7 @@ const SubGhzProtocolDecoder ws_protocol_oregon2_decoder = {
const SubGhzProtocol ws_protocol_oregon2 = { const SubGhzProtocol ws_protocol_oregon2 = {
.name = WS_PROTOCOL_OREGON2_NAME, .name = WS_PROTOCOL_OREGON2_NAME,
.type = SubGhzProtocolWeatherStation, .type = SubGhzProtocolWeatherStation,
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable,
SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable,
.decoder = &ws_protocol_oregon2_decoder, .decoder = &ws_protocol_oregon2_decoder,
}; };

View file

@ -54,7 +54,7 @@ To run cleanup (think of `make clean`) for specified targets, add `-c` option.
- `blackmagic` - debug firmware with Blackmagic probe (WiFi dev board) - `blackmagic` - debug firmware with Blackmagic probe (WiFi dev board)
- `openocd` - just start OpenOCD - `openocd` - just start OpenOCD
- `get_blackmagic` - output blackmagic address in gdb remote format. Useful for IDE integration - `get_blackmagic` - output blackmagic address in gdb remote format. Useful for IDE integration
- `get_stlink` - output serial numbers for attached STLink probes. Ued for `OPENOCD_ADAPTER_SERIAL=...`. - `get_stlink` - output serial numbers for attached STLink probes. Used for specifying an adapter with `OPENOCD_ADAPTER_SERIAL=...`.
- `lint`, `format` - run clang-format on C source code to check and reformat it according to `.clang-format` specs - `lint`, `format` - run clang-format on C source code to check and reformat it according to `.clang-format` specs
- `lint_py`, `format_py` - run [black](https://black.readthedocs.io/en/stable/index.html) on Python source code, build system files & application manifests - `lint_py`, `format_py` - run [black](https://black.readthedocs.io/en/stable/index.html) on Python source code, build system files & application manifests
- `cli` - start Flipper CLI session over USB - `cli` - start Flipper CLI session over USB

View file

@ -292,9 +292,10 @@ Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_all", fw_artifacts)
if fwenv["IS_BASE_FIRMWARE"]: if fwenv["IS_BASE_FIRMWARE"]:
sdk_source = fwenv.SDKPrebuilder( sdk_source = fwenv.SDKPrebuilder(
"sdk_origin", "sdk_origin",
# Deps on root SDK headers and generated files
(fwenv["SDK_HEADERS"], fwenv["FW_ASSETS_HEADERS"]), (fwenv["SDK_HEADERS"], fwenv["FW_ASSETS_HEADERS"]),
) )
# Extra deps for root headers and generated files # Extra deps on headers included in deeper levels
Depends(sdk_source, fwenv.ProcessSdkDepends("sdk_origin.d")) Depends(sdk_source, fwenv.ProcessSdkDepends("sdk_origin.d"))
fwenv["SDK_DIR"] = fwenv.Dir("sdk") fwenv["SDK_DIR"] = fwenv.Dir("sdk")

View file

@ -2323,7 +2323,7 @@ Function,-,subghz_keystore_raw_encrypted_save,_Bool,"const char*, const char*, u
Function,-,subghz_keystore_raw_get_data,_Bool,"const char*, size_t, uint8_t*, size_t" Function,-,subghz_keystore_raw_get_data,_Bool,"const char*, size_t, uint8_t*, size_t"
Function,-,subghz_keystore_save,_Bool,"SubGhzKeystore*, const char*, uint8_t*" Function,-,subghz_keystore_save,_Bool,"SubGhzKeystore*, const char*, uint8_t*"
Function,+,subghz_protocol_blocks_add_bit,void,"SubGhzBlockDecoder*, uint8_t" Function,+,subghz_protocol_blocks_add_bit,void,"SubGhzBlockDecoder*, uint8_t"
Function,+,subghz_protocol_blocks_add_bytes,uint8_t,"const uint8_t[], unsigned" Function,+,subghz_protocol_blocks_add_bytes,uint8_t,"const uint8_t[], size_t"
Function,+,subghz_protocol_blocks_crc16,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t" Function,+,subghz_protocol_blocks_crc16,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t"
Function,+,subghz_protocol_blocks_crc16lsb,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t" Function,+,subghz_protocol_blocks_crc16lsb,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t"
Function,+,subghz_protocol_blocks_crc4,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t" Function,+,subghz_protocol_blocks_crc4,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t"
@ -2338,10 +2338,10 @@ Function,+,subghz_protocol_blocks_lfsr_digest16,uint16_t,"const uint8_t[], unsig
Function,+,subghz_protocol_blocks_lfsr_digest8,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t" Function,+,subghz_protocol_blocks_lfsr_digest8,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t"
Function,+,subghz_protocol_blocks_lfsr_digest8_reflect,uint8_t,"const uint8_t[], int, uint8_t, uint8_t" Function,+,subghz_protocol_blocks_lfsr_digest8_reflect,uint8_t,"const uint8_t[], int, uint8_t, uint8_t"
Function,+,subghz_protocol_blocks_parity8,int,uint8_t Function,+,subghz_protocol_blocks_parity8,int,uint8_t
Function,+,subghz_protocol_blocks_parity_bytes,int,"const uint8_t[], unsigned" Function,+,subghz_protocol_blocks_parity_bytes,int,"const uint8_t[], size_t"
Function,+,subghz_protocol_blocks_reverse_key,uint64_t,"uint64_t, uint8_t" Function,+,subghz_protocol_blocks_reverse_key,uint64_t,"uint64_t, uint8_t"
Function,+,subghz_protocol_blocks_set_bit_array,void,"_Bool, uint8_t[], size_t, size_t" Function,+,subghz_protocol_blocks_set_bit_array,void,"_Bool, uint8_t[], size_t, size_t"
Function,+,subghz_protocol_blocks_xor_bytes,uint8_t,"const uint8_t[], unsigned" Function,+,subghz_protocol_blocks_xor_bytes,uint8_t,"const uint8_t[], size_t"
Function,-,subghz_protocol_decoder_base_deserialize,_Bool,"SubGhzProtocolDecoderBase*, FlipperFormat*" Function,-,subghz_protocol_decoder_base_deserialize,_Bool,"SubGhzProtocolDecoderBase*, FlipperFormat*"
Function,+,subghz_protocol_decoder_base_get_hash_data,uint8_t,SubGhzProtocolDecoderBase* Function,+,subghz_protocol_decoder_base_get_hash_data,uint8_t,SubGhzProtocolDecoderBase*
Function,+,subghz_protocol_decoder_base_get_string,_Bool,"SubGhzProtocolDecoderBase*, FuriString*" Function,+,subghz_protocol_decoder_base_get_string,_Bool,"SubGhzProtocolDecoderBase*, FuriString*"
@ -2776,6 +2776,7 @@ Function,-,subghz_protocol_raw_file_encoder_worker_set_callback_end,void,"SubGhz
Function,+,subghz_protocol_raw_gen_fff_data,void,"FlipperFormat*, const char*" Function,+,subghz_protocol_raw_gen_fff_data,void,"FlipperFormat*, const char*"
Function,+,subghz_protocol_raw_get_sample_write,size_t,SubGhzProtocolDecoderRAW* Function,+,subghz_protocol_raw_get_sample_write,size_t,SubGhzProtocolDecoderRAW*
Function,+,subghz_protocol_raw_save_to_file_init,_Bool,"SubGhzProtocolDecoderRAW*, const char*, SubGhzRadioPreset*" Function,+,subghz_protocol_raw_save_to_file_init,_Bool,"SubGhzProtocolDecoderRAW*, const char*, SubGhzRadioPreset*"
Function,+,subghz_protocol_raw_save_to_file_pause,void,"SubGhzProtocolDecoderRAW*, _Bool"
Function,+,subghz_protocol_raw_save_to_file_stop,void,SubGhzProtocolDecoderRAW* Function,+,subghz_protocol_raw_save_to_file_stop,void,SubGhzProtocolDecoderRAW*
Function,+,subghz_protocol_registry_count,size_t,const SubGhzProtocolRegistry* Function,+,subghz_protocol_registry_count,size_t,const SubGhzProtocolRegistry*
Function,+,subghz_protocol_registry_get_by_index,const SubGhzProtocol*,"const SubGhzProtocolRegistry*, size_t" Function,+,subghz_protocol_registry_get_by_index,const SubGhzProtocol*,"const SubGhzProtocolRegistry*, size_t"

1 entry status name type params
2323 Function - subghz_keystore_raw_get_data _Bool const char*, size_t, uint8_t*, size_t
2324 Function - subghz_keystore_save _Bool SubGhzKeystore*, const char*, uint8_t*
2325 Function + subghz_protocol_blocks_add_bit void SubGhzBlockDecoder*, uint8_t
2326 Function + subghz_protocol_blocks_add_bytes uint8_t const uint8_t[], unsigned const uint8_t[], size_t
2327 Function + subghz_protocol_blocks_crc16 uint16_t const uint8_t[], unsigned, uint16_t, uint16_t
2328 Function + subghz_protocol_blocks_crc16lsb uint16_t const uint8_t[], unsigned, uint16_t, uint16_t
2329 Function + subghz_protocol_blocks_crc4 uint8_t const uint8_t[], unsigned, uint8_t, uint8_t
2338 Function + subghz_protocol_blocks_lfsr_digest8 uint8_t const uint8_t[], unsigned, uint8_t, uint8_t
2339 Function + subghz_protocol_blocks_lfsr_digest8_reflect uint8_t const uint8_t[], int, uint8_t, uint8_t
2340 Function + subghz_protocol_blocks_parity8 int uint8_t
2341 Function + subghz_protocol_blocks_parity_bytes int const uint8_t[], unsigned const uint8_t[], size_t
2342 Function + subghz_protocol_blocks_reverse_key uint64_t uint64_t, uint8_t
2343 Function + subghz_protocol_blocks_set_bit_array void _Bool, uint8_t[], size_t, size_t
2344 Function + subghz_protocol_blocks_xor_bytes uint8_t const uint8_t[], unsigned const uint8_t[], size_t
2345 Function - subghz_protocol_decoder_base_deserialize _Bool SubGhzProtocolDecoderBase*, FlipperFormat*
2346 Function + subghz_protocol_decoder_base_get_hash_data uint8_t SubGhzProtocolDecoderBase*
2347 Function + subghz_protocol_decoder_base_get_string _Bool SubGhzProtocolDecoderBase*, FuriString*
2776 Function + subghz_protocol_raw_gen_fff_data void FlipperFormat*, const char*
2777 Function + subghz_protocol_raw_get_sample_write size_t SubGhzProtocolDecoderRAW*
2778 Function + subghz_protocol_raw_save_to_file_init _Bool SubGhzProtocolDecoderRAW*, const char*, SubGhzRadioPreset*
2779 Function + subghz_protocol_raw_save_to_file_pause void SubGhzProtocolDecoderRAW*, _Bool
2780 Function + subghz_protocol_raw_save_to_file_stop void SubGhzProtocolDecoderRAW*
2781 Function + subghz_protocol_registry_count size_t const SubGhzProtocolRegistry*
2782 Function + subghz_protocol_registry_get_by_index const SubGhzProtocol* const SubGhzProtocolRegistry*, size_t

View file

@ -218,9 +218,9 @@ uint16_t subghz_protocol_blocks_lfsr_digest16(
return sum; return sum;
} }
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], unsigned num_bytes) { uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t num_bytes) {
int result = 0; int result = 0;
for(unsigned i = 0; i < num_bytes; ++i) { for(size_t i = 0; i < num_bytes; ++i) {
result += message[i]; result += message[i];
} }
return (uint8_t)result; return (uint8_t)result;
@ -232,17 +232,17 @@ int subghz_protocol_blocks_parity8(uint8_t byte) {
return (0x6996 >> byte) & 1; return (0x6996 >> byte) & 1;
} }
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_bytes) { int subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t num_bytes) {
int result = 0; int result = 0;
for(unsigned i = 0; i < num_bytes; ++i) { for(size_t i = 0; i < num_bytes; ++i) {
result ^= subghz_protocol_blocks_parity8(message[i]); result ^= subghz_protocol_blocks_parity8(message[i]);
} }
return result; return result;
} }
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], unsigned num_bytes) { uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t num_bytes) {
uint8_t result = 0; uint8_t result = 0;
for(unsigned i = 0; i < num_bytes; ++i) { for(size_t i = 0; i < num_bytes; ++i) {
result ^= message[i]; result ^= message[i];
} }
return result; return result;

View file

@ -167,7 +167,7 @@ uint16_t subghz_protocol_blocks_lfsr_digest16(
* @param num_bytes number of bytes to sum * @param num_bytes number of bytes to sum
* @return summation value * @return summation value
**/ **/
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], unsigned num_bytes); uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t num_bytes);
/** /**
* Compute bit parity of a single byte (8 bits). * Compute bit parity of a single byte (8 bits).
@ -182,7 +182,7 @@ int subghz_protocol_blocks_parity8(uint8_t byte);
* @param num_bytes number of bytes to sum * @param num_bytes number of bytes to sum
* @return 1 odd parity, 0 even parity * @return 1 odd parity, 0 even parity
**/ **/
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_bytes); int subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t num_bytes);
/** /**
* Compute XOR (byte-wide parity) of a number of bytes. * Compute XOR (byte-wide parity) of a number of bytes.
@ -190,7 +190,7 @@ int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_by
* @param num_bytes number of bytes to sum * @param num_bytes number of bytes to sum
* @return summation value, per bit-position 1 odd parity, 0 even parity * @return summation value, per bit-position 1 odd parity, 0 even parity
**/ **/
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], unsigned num_bytes); uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t num_bytes);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -43,6 +43,7 @@ struct SubGhzProtocolDecoderRAW {
bool has_rssi_above_threshold; bool has_rssi_above_threshold;
int rssi_threshold; int rssi_threshold;
uint8_t postroll_frames; uint8_t postroll_frames;
bool pause;
}; };
struct SubGhzProtocolEncoderRAW { struct SubGhzProtocolEncoderRAW {
@ -169,6 +170,7 @@ bool subghz_protocol_raw_save_to_file_init(
instance->upload_raw = malloc(SUBGHZ_DOWNLOAD_MAX_SIZE * sizeof(int32_t)); instance->upload_raw = malloc(SUBGHZ_DOWNLOAD_MAX_SIZE * sizeof(int32_t));
instance->file_is_open = RAWFileIsOpenWrite; instance->file_is_open = RAWFileIsOpenWrite;
instance->sample_write = 0; instance->sample_write = 0;
instance->pause = false;
init = true; init = true;
} while(0); } while(0);
@ -240,6 +242,14 @@ void subghz_protocol_decoder_raw_set_auto_mode(void* context, bool auto_mode) {
subghz_protocol_decoder_raw_reset(context); subghz_protocol_decoder_raw_reset(context);
} }
void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause) {
furi_assert(instance);
if(instance->pause != pause) {
instance->pause = pause;
}
}
size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolDecoderRAW* instance) { size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolDecoderRAW* instance) {
return instance->sample_write + instance->ind_write; return instance->sample_write + instance->ind_write;
} }
@ -306,7 +316,8 @@ void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t durati
furi_assert(context); furi_assert(context);
SubGhzProtocolDecoderRAW* instance = context; SubGhzProtocolDecoderRAW* instance = context;
if(instance->upload_raw != NULL && duration > subghz_protocol_raw_const.te_short) { if(instance->upload_raw != NULL && !instance->pause &&
duration > subghz_protocol_raw_const.te_short) {
if(instance->auto_mode) { if(instance->auto_mode) {
float rssi = furi_hal_subghz_get_rssi(); float rssi = furi_hal_subghz_get_rssi();

View file

@ -142,6 +142,13 @@ void subghz_protocol_encoder_raw_free(void* context);
*/ */
void subghz_protocol_encoder_raw_stop(void* context); void subghz_protocol_encoder_raw_stop(void* context);
/**
* pause writing to flash.
* @param context Pointer to a SubGhzProtocolEncoderRAW instance
* @param pause pause writing
*/
void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause);
/** /**
* Set callback on completion of file transfer. * Set callback on completion of file transfer.
* @param instance Pointer to a SubGhzProtocolEncoderRAW instance * @param instance Pointer to a SubGhzProtocolEncoderRAW instance