Skip to content

Commit

Permalink
Merge pull request #9 from ElectronicCats/dev
Browse files Browse the repository at this point in the history
fix: keep sniffing after exit of an address
  • Loading branch information
sabas1080 authored Sep 13, 2024
2 parents 035bd97 + 7104c71 commit cb0cb77
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Binary file modified Canbus_app/dist/canbus_app.fap
Binary file not shown.
Binary file modified Canbus_app/dist/debug/canbus_app_d.elf
Binary file not shown.
17 changes: 6 additions & 11 deletions Canbus_app/scenes/SnifferOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ void draw_box_text(App* app) {
// --------------------------- Thread on work
// ------------------------------------------------------

static void callback_interrupt(void* context) {
App* app = context;
furi_thread_flags_set(furi_thread_get_id(app->thread), WorkerflagReceived);
}

static int32_t worker_sniffing(void* context) {
App* app = context;
MCP2515* mcp_can = app->mcp_can;
Expand All @@ -162,9 +157,6 @@ static int32_t worker_sniffing(void* context) {
bool run = true;
bool first_address = true;

furi_hal_gpio_init(&gpio_swclk, GpioModeInterruptFall, GpioPullNo, GpioSpeedVeryHigh);
furi_hal_gpio_add_int_callback(&gpio_swclk, callback_interrupt, app);

mcp_can->mode = MCP_LISTENONLY;
ERROR_CAN debugStatus = mcp2515_init(mcp_can);

Expand All @@ -173,7 +165,7 @@ static int32_t worker_sniffing(void* context) {
view_dispatcher_send_custom_event(app->view_dispatcher, DEVICE_NO_CONNECTED);
}

while(run && furi_hal_gpio_read(&gpio_button_back)) {
while(run) {
bool new = true;

if(read_can_message(mcp_can, &frame) == ERROR_OK) {
Expand Down Expand Up @@ -261,6 +253,11 @@ static int32_t worker_sniffing(void* context) {

app->num_of_devices = num_of_devices;
}

if(condition && !furi_hal_gpio_read(&gpio_button_back)) {
break;
}
furi_delay_ms(1);
}

if((app->save_logs == SaveAll) && (app->log_file_ready)) {
Expand All @@ -269,7 +266,6 @@ static int32_t worker_sniffing(void* context) {
}

furi_string_free(text_label);
furi_hal_gpio_remove_int_callback(&gpio_swclk);
free_mcp2515(mcp_can);
return 0;
}
Expand Down Expand Up @@ -326,7 +322,6 @@ bool app_scene_sniffing_on_event(void* context, SceneManagerEvent event) {
void app_scene_sniffing_on_exit(void* context) {
App* app = context;
if(condition) {
furi_thread_flags_set(furi_thread_get_id(app->thread), WorkerflagStop);
furi_thread_join(app->thread);
furi_thread_free(app->thread);
submenu_reset(app->submenu);
Expand Down

0 comments on commit cb0cb77

Please sign in to comment.