Merge branch 'UNLEASHED' into 420

This commit is contained in:
RogueMaster
2022-10-26 17:49:42 -04:00
14 changed files with 171 additions and 28 deletions

View File

@@ -230,9 +230,11 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
subghz->txrx->txrx_state = SubGhzTxRxStateSleep;
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
if(!alloc_for_tx_only) {
subghz->txrx->history = subghz_history_alloc();
}
subghz->txrx->raw_threshold_rssi = SUBGHZ_RAW_TRESHOLD_MIN;
subghz->txrx->history = subghz_history_alloc();
subghz->txrx->worker = subghz_worker_alloc();
subghz->txrx->fff_data = flipper_format_string_alloc();

View File

@@ -639,6 +639,9 @@ int32_t i2ctools_app(void* p) {
}
view_port_update(i2caddrs->view_port);
}
// Reset GPIO pins to default state
furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_init(&gpio_ext_pc1, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
gui_remove_view_port(gui, i2caddrs->view_port);
view_port_free(i2caddrs->view_port);
furi_message_queue_free(event_queue);

View File

@@ -181,12 +181,15 @@ int32_t hc_sr04_app() {
hc_sr04_state_init(plugin_state);
furi_hal_console_disable();
ValueMutex state_mutex;
if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) {
FURI_LOG_E("hc_sr04", "cannot create mutex\r\n");
if(furi_hal_power_is_otg_enabled()) {
furi_hal_power_disable_otg();
}
furi_hal_console_enable();
furi_hal_power_suppress_charge_exit();
furi_message_queue_free(event_queue);
free(plugin_state);
@@ -239,6 +242,22 @@ int32_t hc_sr04_app() {
furi_hal_power_disable_otg();
}
furi_hal_power_suppress_charge_exit();
// Return TX / RX back to usart mode
furi_hal_gpio_init_ex(
&gpio_usart_tx,
GpioModeAltFunctionPushPull,
GpioPullUp,
GpioSpeedVeryHigh,
GpioAltFn7USART1);
furi_hal_gpio_init_ex(
&gpio_usart_rx,
GpioModeAltFunctionPushPull,
GpioPullUp,
GpioSpeedVeryHigh,
GpioAltFn7USART1);
furi_hal_console_enable();
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
furi_record_close(RECORD_GUI);

View File

@@ -146,14 +146,15 @@ int32_t sentry_safe_app(void* p) {
}
}
}
} else {
// event timeout
}
view_port_update(view_port);
release_mutex(&state_mutex, sentry_state);
}
// Reset GPIO pins to default state
furi_hal_gpio_init(&gpio_ext_pc1, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
furi_record_close(RECORD_GUI);

View File

@@ -18,7 +18,7 @@
#define DEAUTH_APP_DEBUG 0
#if DEAUTH_APP_DEBUG
#define APP_NAME_TAG "WiFi_Scanner"
#define APP_NAME_TAG "WiFi_Deauther"
#define DEAUTH_APP_LOG_I(format, ...) FURI_LOG_I(APP_NAME_TAG, format, ##__VA_ARGS__)
#define DEAUTH_APP_LOG_D(format, ...) FURI_LOG_D(APP_NAME_TAG, format, ##__VA_ARGS__)
#define DEAUTH_APP_LOG_E(format, ...) FURI_LOG_E(APP_NAME_TAG, format, ##__VA_ARGS__)
@@ -167,7 +167,7 @@ static void esp8266_deauth_module_render_callback(Canvas* const canvas, void* ct
canvas_clear(canvas);
canvas_set_font(canvas, FontSecondary);
const char* strInitializing = "Attach WiFi scanner module";
const char* strInitializing = "Attach WiFi Deauther module";
canvas_draw_str(
canvas,
(u8g2_GetDisplayWidth(&canvas->fb) / 2) -
@@ -472,8 +472,6 @@ int32_t esp8266_deauth_app(void* p) {
}
}
}
} else {
DEAUTH_APP_LOG_D("osMessageQueue: event timeout");
}
#if ENABLE_MODULE_DETECTION
@@ -497,6 +495,13 @@ int32_t esp8266_deauth_app(void* p) {
DEAUTH_APP_LOG_I("Thread Deleted");
// Reset GPIO pins to default state
furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_init(&gpio_ext_pc3, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_init(&gpio_ext_pb2, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_init(&gpio_ext_pb3, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_init(&gpio_ext_pa4, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
#if DISABLE_CONSOLE
furi_hal_console_enable();
#endif

View File

@@ -795,8 +795,6 @@ int32_t wifi_scanner_app(void* p) {
}
}
}
} else {
WIFI_APP_LOG_D("osMessageQueue: event timeout");
}
#if ENABLE_MODULE_DETECTION
@@ -820,6 +818,9 @@ int32_t wifi_scanner_app(void* p) {
WIFI_APP_LOG_I("Thread Deleted");
// Reset GPIO pins to default state
furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
#if DISABLE_CONSOLE
furi_hal_console_enable();
#endif

View File

@@ -391,16 +391,39 @@ void canvas_set_bitmap_mode(Canvas* canvas, bool alpha) {
void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation) {
furi_assert(canvas);
if(canvas->orientation != orientation) {
canvas->orientation = orientation;
if(canvas->orientation == CanvasOrientationHorizontal) {
FURI_SWAP(canvas->width, canvas->height);
switch(orientation) {
case CanvasOrientationHorizontal:
if(canvas->orientation == CanvasOrientationVertical ||
canvas->orientation == CanvasOrientationVerticalFlip) {
FURI_SWAP(canvas->width, canvas->height);
}
u8g2_SetDisplayRotation(&canvas->fb, U8G2_R0);
} else if(canvas->orientation == CanvasOrientationVertical) {
FURI_SWAP(canvas->width, canvas->height);
break;
case CanvasOrientationHorizontalFlip:
if(canvas->orientation == CanvasOrientationVertical ||
canvas->orientation == CanvasOrientationVerticalFlip) {
FURI_SWAP(canvas->width, canvas->height);
}
u8g2_SetDisplayRotation(&canvas->fb, U8G2_R2);
break;
case CanvasOrientationVertical:
if(canvas->orientation == CanvasOrientationHorizontal ||
canvas->orientation == CanvasOrientationHorizontalFlip) {
FURI_SWAP(canvas->width, canvas->height);
};
u8g2_SetDisplayRotation(&canvas->fb, U8G2_R3);
} else {
break;
case CanvasOrientationVerticalFlip:
if(canvas->orientation == CanvasOrientationHorizontal ||
canvas->orientation == CanvasOrientationHorizontalFlip) {
FURI_SWAP(canvas->width, canvas->height);
}
u8g2_SetDisplayRotation(&canvas->fb, U8G2_R1);
break;
default:
furi_assert(0);
}
canvas->orientation = orientation;
}
}

View File

@@ -43,7 +43,9 @@ typedef enum {
/** Canvas Orientation */
typedef enum {
CanvasOrientationHorizontal,
CanvasOrientationHorizontalFlip,
CanvasOrientationVertical,
CanvasOrientationVerticalFlip,
} CanvasOrientation;
/** Font Direction */

View File

@@ -305,7 +305,9 @@ void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
furi_check(layer < GuiLayerMAX);
// Only fullscreen supports Vertical orientation for now
furi_assert(
(layer == GuiLayerFullscreen) || (view_port->orientation != ViewPortOrientationVertical));
(layer == GuiLayerFullscreen) ||
((view_port->orientation != ViewPortOrientationVertical) &&
(view_port->orientation != ViewPortOrientationVerticalFlip)));
gui_lock(gui);
// Verify that view port is not yet added

View File

@@ -25,7 +25,9 @@ extern "C" {
typedef enum {
ViewOrientationHorizontal,
ViewOrientationHorizontalFlip,
ViewOrientationVertical,
ViewOrientationVerticalFlip,
} ViewOrientation;
/** View, anonymous type */

View File

@@ -331,10 +331,16 @@ void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* vie
view_dispatcher->current_view = view;
// Dispatch view enter event
if(view_dispatcher->current_view) {
if(view->orientation == ViewOrientationVertical)
if(view->orientation == ViewOrientationVertical) {
view_port_set_orientation(view_dispatcher->view_port, ViewPortOrientationVertical);
else if(view->orientation == ViewOrientationHorizontal)
} else if(view->orientation == ViewOrientationVerticalFlip) {
view_port_set_orientation(view_dispatcher->view_port, ViewPortOrientationVerticalFlip);
} else if(view->orientation == ViewOrientationHorizontal) {
view_port_set_orientation(view_dispatcher->view_port, ViewPortOrientationHorizontal);
} else if(view->orientation == ViewOrientationHorizontalFlip) {
view_port_set_orientation(
view_dispatcher->view_port, ViewPortOrientationHorizontalFlip);
}
view_enter(view_dispatcher->current_view);
view_port_enabled_set(view_dispatcher->view_port, true);
view_port_update(view_dispatcher->view_port);

View File

@@ -7,7 +7,7 @@
// TODO add mutex to view_port ops
static void view_port_rotate_buttons(InputEvent* event) {
static void view_port_remap_buttons_vertical(InputEvent* event) {
switch(event->key) {
case InputKeyUp:
event->key = InputKeyRight;
@@ -26,14 +26,61 @@ static void view_port_rotate_buttons(InputEvent* event) {
}
}
static void view_port_setup_canvas_orientation(const ViewPort* view_port, Canvas* canvas) {
if(view_port->orientation == ViewPortOrientationHorizontal) {
canvas_set_orientation(canvas, CanvasOrientationHorizontal);
} else if(view_port->orientation == ViewPortOrientationVertical) {
canvas_set_orientation(canvas, CanvasOrientationVertical);
static void view_port_remap_buttons_vertical_flip(InputEvent* event) {
switch(event->key) {
case InputKeyUp:
event->key = InputKeyLeft;
break;
case InputKeyDown:
event->key = InputKeyRight;
break;
case InputKeyRight:
event->key = InputKeyUp;
break;
case InputKeyLeft:
event->key = InputKeyDown;
break;
default:
break;
}
}
static void view_port_remap_buttons_horizontal_flip(InputEvent* event) {
switch(event->key) {
case InputKeyUp:
event->key = InputKeyDown;
break;
case InputKeyDown:
event->key = InputKeyUp;
break;
case InputKeyRight:
event->key = InputKeyLeft;
break;
case InputKeyLeft:
event->key = InputKeyRight;
break;
default:
break;
}
}
static void view_port_setup_canvas_orientation(const ViewPort* view_port, Canvas* canvas) {
switch(view_port->orientation) {
case ViewPortOrientationHorizontalFlip:
canvas_set_orientation(canvas, CanvasOrientationHorizontalFlip);
break;
case ViewPortOrientationVertical:
canvas_set_orientation(canvas, CanvasOrientationVertical);
break;
case ViewPortOrientationVerticalFlip:
canvas_set_orientation(canvas, CanvasOrientationVerticalFlip);
break;
default:
canvas_set_orientation(canvas, CanvasOrientationHorizontal);
break;
};
}
ViewPort* view_port_alloc() {
ViewPort* view_port = malloc(sizeof(ViewPort));
view_port->orientation = ViewPortOrientationHorizontal;
@@ -122,8 +169,19 @@ void view_port_input(ViewPort* view_port, InputEvent* event) {
furi_check(view_port->gui);
if(view_port->input_callback) {
if(view_port_get_orientation(view_port) == ViewPortOrientationVertical) {
view_port_rotate_buttons(event);
ViewPortOrientation orientation = view_port_get_orientation(view_port);
switch(orientation) {
case ViewPortOrientationHorizontalFlip:
view_port_remap_buttons_horizontal_flip(event);
break;
case ViewPortOrientationVertical:
view_port_remap_buttons_vertical(event);
break;
case ViewPortOrientationVerticalFlip:
view_port_remap_buttons_vertical_flip(event);
break;
default:
break;
}
view_port->input_callback(event, view_port->input_callback_context);
}

View File

@@ -16,7 +16,9 @@ typedef struct ViewPort ViewPort;
typedef enum {
ViewPortOrientationHorizontal,
ViewPortOrientationHorizontalFlip,
ViewPortOrientationVertical,
ViewPortOrientationVerticalFlip,
} ViewPortOrientation;
/** ViewPort Draw callback

View File

@@ -316,8 +316,25 @@ void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t durati
furi_assert(context);
SubGhzProtocolDecoderRAW* instance = context;
if(!instance->pause && (instance->upload_raw != NULL)) {
if(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) {
float rssi = furi_hal_subghz_get_rssi();
if(rssi >= instance->rssi_threshold) {
subghz_protocol_decoder_raw_write_data(context, level, duration);
instance->has_rssi_above_threshold = true;
instance->postroll_frames = 0;
} else if(instance->has_rssi_above_threshold) {
subghz_protocol_decoder_raw_write_data(instance, level, duration);
instance->postroll_frames++;
if(instance->postroll_frames >= SUBGHZ_AUTO_DETECT_RAW_POSTROLL_FRAMES) {
if(instance->base.callback)
instance->base.callback(&instance->base, instance->base.context);
}
}
} else {
if(instance->last_level != level) {
instance->last_level = (level ? true : false);
instance->upload_raw[instance->ind_write++] = (level ? duration : -duration);