adapt plugins to furi stream, fix printf formats

This commit is contained in:
MX 2022-10-07 21:05:16 +03:00
parent b4b3c182c5
commit 4c9d62a33f
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
11 changed files with 32 additions and 41 deletions

View file

@ -258,7 +258,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
if(!is_valid) {
FURI_LOG_E(
TAG,
"Invalid note: %u%c%c%u.%u",
"Invalid note: %lu%c%c%lu.%lu",
duration,
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
@ -281,7 +281,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
if(music_player_worker_add_note(instance, semitone, duration, dots)) {
FURI_LOG_D(
TAG,
"Added note: %c%c%u.%u = %u %u",
"Added note: %c%c%lu.%lu = %u %lu",
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
octave,
@ -291,7 +291,7 @@ static bool music_player_worker_parse_notes(MusicPlayerWorker* instance, const c
} else {
FURI_LOG_E(
TAG,
"Invalid note: %c%c%u.%u = %u %u",
"Invalid note: %c%c%lu.%lu = %u %lu",
note_char == '\0' ? '_' : note_char,
sharp_char == '\0' ? '_' : sharp_char,
octave,

View file

@ -10,7 +10,7 @@
//#include <notification/notification.h>
//#include <notification/notification_messages.h>
//#include <stdlib.h>
#include <stream_buffer.h>
#include <u8g2.h>
#include "FlipperZeroWiFiDeauthModuleDefines.h"
@ -65,7 +65,7 @@ typedef struct SWiFiDeauthApp {
Gui* m_gui;
FuriThread* m_worker_thread;
//NotificationApp* m_notification;
StreamBufferHandle_t m_rx_stream;
FuriStreamBuffer* m_rx_stream;
SGpioButtons m_GpioButtons;
bool m_wifiDeauthModuleInitialized;
@ -219,7 +219,6 @@ static void
static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
furi_assert(context);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
SWiFiDeauthApp* app = context;
@ -227,9 +226,8 @@ static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
if(ev == UartIrqEventRXNE) {
DEAUTH_APP_LOG_I("ev == UartIrqEventRXNE");
xStreamBufferSendFromISR(app->m_rx_stream, &data, 1, &xHigherPriorityTaskWoken);
furi_stream_buffer_send(app->m_rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventRx);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
@ -242,7 +240,7 @@ static int32_t uart_worker(void* context) {
return 1;
}
StreamBufferHandle_t rx_stream = app->m_rx_stream;
FuriStreamBuffer* rx_stream = app->m_rx_stream;
release_mutex((ValueMutex*)context, app);
@ -272,7 +270,7 @@ static int32_t uart_worker(void* context) {
const uint8_t dataBufferSize = 64;
uint8_t dataBuffer[dataBufferSize];
dataReceivedLength =
xStreamBufferReceive(rx_stream, dataBuffer, dataBufferSize, 25);
furi_stream_buffer_receive(rx_stream, dataBuffer, dataBufferSize, 25);
if(dataReceivedLength > 0) {
#if ENABLE_MODULE_POWER
if(!initialized) {
@ -367,7 +365,7 @@ int32_t esp8266_deauth_app(void* p) {
DEAUTH_APP_LOG_I("Mutex created");
app->m_rx_stream = xStreamBufferCreate(1 * 1024, 1);
app->m_rx_stream = furi_stream_buffer_alloc(1 * 1024, 1);
//app->m_notification = furi_record_open("notification");
@ -518,7 +516,7 @@ int32_t esp8266_deauth_app(void* p) {
furi_message_queue_free(event_queue);
vStreamBufferDelete(app->m_rx_stream);
furi_stream_buffer_free(app->m_rx_stream);
delete_mutex(&app_data_mutex);

View file

@ -118,7 +118,7 @@ static bool open_ducky_script(Stream* stream, PluginState* plugin_state) {
furi_record_close("dialogs");
if(ret) {
if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_D(TAG, "Cannot open file \"%s\"", (path));
FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
} else {
result = true;
}
@ -147,7 +147,7 @@ static bool open_addrs_file(Stream* stream) {
furi_record_close("dialogs");
if(ret) {
if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_D(TAG, "Cannot open file \"%s\"", (path));
FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
} else {
result = true;
}

View file

@ -261,7 +261,7 @@ static bool mj_process_ducky_line(
repeat_cnt = atoi(line_tmp);
if(repeat_cnt < 2) return false;
FURI_LOG_D(TAG, "repeating %s %d times", prev_line, repeat_cnt);
FURI_LOG_D(TAG, "repeating %s %ld times", prev_line, repeat_cnt);
for(uint32_t i = 0; i < repeat_cnt; i++)
mj_process_ducky_line(handle, addr, addr_size, rate, prev_line, NULL, plugin_state);

View file

@ -473,9 +473,9 @@ static void render_callback(Canvas* canvas, void* ctx) {
canvas, 1, 19, AlignLeft, AlignTop, furi_string_get_cstr(temp_str));
if(app->meta->playlist_repetitions <= 0) {
furi_string_printf(temp_str, "Repeat: inf", app->meta->playlist_repetitions);
furi_string_set(temp_str, "Repeat: inf");
} else if(app->meta->playlist_repetitions == 1) {
furi_string_printf(temp_str, "Repeat: no", app->meta->playlist_repetitions);
furi_string_set(temp_str, "Repeat: no");
} else {
furi_string_printf(temp_str, "Repeat: %dx", app->meta->playlist_repetitions);
}

View file

@ -326,7 +326,7 @@ void spectrum_analyzer_calculate_frequencies(SpectrumAnalyzerModel* model) {
model->max_rssi = -200.0;
model->max_rssi_dec = 0;
FURI_LOG_D("Spectrum", "setup_frequencies - max_hz: %u - min_hz: %u", max_hz, min_hz);
FURI_LOG_D("Spectrum", "setup_frequencies - max_hz: %lu - min_hz: %lu", max_hz, min_hz);
FURI_LOG_D("Spectrum", "center_freq: %u", model->center_freq);
FURI_LOG_D(
"Spectrum",
@ -450,7 +450,7 @@ int32_t spectrum_analyzer_app(void* p) {
break;
case InputKeyRight:
model->center_freq += hstep;
FURI_LOG_D("Spectrum", "center_freq: %lu", model->center_freq);
FURI_LOG_D("Spectrum", "center_freq: %u", model->center_freq);
spectrum_analyzer_calculate_frequencies(model);
spectrum_analyzer_worker_set_frequencies(
spectrum_analyzer->worker, model->channel0_frequency, model->spacing, model->width);
@ -460,7 +460,7 @@ int32_t spectrum_analyzer_app(void* p) {
spectrum_analyzer_calculate_frequencies(model);
spectrum_analyzer_worker_set_frequencies(
spectrum_analyzer->worker, model->channel0_frequency, model->spacing, model->width);
FURI_LOG_D("Spectrum", "center_freq: %lu", model->center_freq);
FURI_LOG_D("Spectrum", "center_freq: %u", model->center_freq);
break;
case InputKeyOk: {
switch(model->width) {

View file

@ -168,7 +168,7 @@ void spectrum_analyzer_worker_set_frequencies(
FURI_LOG_D(
"SpectrumWorker",
"spectrum_analyzer_worker_set_frequencies - channel0_frequency= %u - spacing = %u - width = %u",
"spectrum_analyzer_worker_set_frequencies - channel0_frequency= %lu - spacing = %lu - width = %u",
channel0_frequency,
spacing,
width);

View file

@ -212,7 +212,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
//snprintf(step_payload, sizeof(step_payload), "%16X", step);
//snprintf(step_payload, sizeof(step_payload), "%016llX", step);
FuriString* buffer = furi_string_alloc();
furi_string_printf(buffer, "%16X", step);
furi_string_printf(buffer, "%16llX", step);
int j = 0;
furi_string_set_str(candidate, " ");
for(uint8_t i = 0; i < 16; i++) {

View file

@ -9,7 +9,6 @@
#include <notification/notification_messages.h>
#include <lib/toolbox/stream/stream.h>
#include <stream_buffer.h>
#include <gui/gui.h>
#include <gui/view_dispatcher.h>

View file

@ -1,15 +1,13 @@
#include "wifi_marauder_app_i.h"
#include "wifi_marauder_uart.h"
#include <stream_buffer.h>
#define UART_CH (FuriHalUartIdUSART1)
#define BAUDRATE (115200)
struct WifiMarauderUart {
WifiMarauderApp* app;
FuriThread* rx_thread;
StreamBufferHandle_t rx_stream;
FuriStreamBuffer* rx_stream;
uint8_t rx_buf[RX_BUF_SIZE + 1];
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
};
@ -30,19 +28,17 @@ void wifi_marauder_uart_set_handle_rx_data_cb(
void wifi_marauder_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
WifiMarauderUart* uart = (WifiMarauderUart*)context;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if(ev == UartIrqEventRXNE) {
xStreamBufferSendFromISR(uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken);
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
static int32_t uart_worker(void* context) {
WifiMarauderUart* uart = (void*)context;
uart->rx_stream = xStreamBufferCreate(RX_BUF_SIZE, 1);
uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
while(1) {
uint32_t events =
@ -50,14 +46,14 @@ static int32_t uart_worker(void* context) {
furi_check((events & FuriFlagError) == 0);
if(events & WorkerEvtStop) break;
if(events & WorkerEvtRxDone) {
size_t len = xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
size_t len = furi_stream_buffer_receive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
if(len > 0) {
if(uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
}
}
}
vStreamBufferDelete(uart->rx_stream);
furi_stream_buffer_free(uart->rx_stream);
return 0;
}

View file

@ -10,7 +10,7 @@
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <stdlib.h>
#include <stream_buffer.h>
#include <u8g2.h>
#include "FlipperZeroWiFiModuleDefines.h"
@ -86,7 +86,7 @@ typedef struct SWiFiScannerApp {
Gui* m_gui;
FuriThread* m_worker_thread;
NotificationApp* m_notification;
StreamBufferHandle_t m_rx_stream;
FuriStreamBuffer* m_rx_stream;
bool m_wifiModuleInitialized;
bool m_wifiModuleAttached;
@ -445,7 +445,6 @@ static void wifi_module_input_callback(InputEvent* input_event, FuriMessageQueue
static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
furi_assert(context);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
SWiFiScannerApp* app = context;
@ -453,9 +452,8 @@ static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
if(ev == UartIrqEventRXNE) {
WIFI_APP_LOG_I("ev == UartIrqEventRXNE");
xStreamBufferSendFromISR(app->m_rx_stream, &data, 1, &xHigherPriorityTaskWoken);
furi_stream_buffer_send(app->m_rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventRx);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
@ -467,7 +465,7 @@ static int32_t uart_worker(void* context) {
return 1;
}
StreamBufferHandle_t rx_stream = app->m_rx_stream;
FuriStreamBuffer* rx_stream = app->m_rx_stream;
release_mutex((ValueMutex*)context, app);
@ -483,7 +481,7 @@ static int32_t uart_worker(void* context) {
receivedString = furi_string_alloc();
do {
uint8_t data[64];
length = xStreamBufferReceive(rx_stream, data, 64, 25);
length = furi_stream_buffer_receive(rx_stream, data, 64, 25);
if(length > 0) {
WIFI_APP_LOG_I("Received Data - length: %i", length);
@ -676,7 +674,7 @@ int32_t wifi_scanner_app(void* p) {
WIFI_APP_LOG_I("Mutex created");
app->m_rx_stream = xStreamBufferCreate(1 * 1024, 1);
app->m_rx_stream = furi_stream_buffer_alloc(1 * 1024, 1);
app->m_notification = furi_record_open("notification");
@ -839,7 +837,7 @@ int32_t wifi_scanner_app(void* p) {
furi_message_queue_free(event_queue);
vStreamBufferDelete(app->m_rx_stream);
furi_stream_buffer_free(app->m_rx_stream);
delete_mutex(&app_data_mutex);