diff --git a/applications/plugins/hex_viewer/hex_viewer.c b/applications/plugins/hex_viewer/hex_viewer.c
index 1ac3923e8..50c34d634 100644
--- a/applications/plugins/hex_viewer/hex_viewer.c
+++ b/applications/plugins/hex_viewer/hex_viewer.c
@@ -16,14 +16,14 @@
#define HEX_VIEWER_APP_PATH_FOLDER "/any"
#define HEX_VIEWER_APP_EXTENSION "*"
-#define HEX_VIEWER_BYTES_PER_ROW 4
-#define HEX_VIEWER_ROW_COUNT 4
-#define HEX_VIEWER_BUF_SIZE (HEX_VIEWER_BYTES_PER_ROW * HEX_VIEWER_ROW_COUNT)
+#define HEX_VIEWER_BYTES_PER_LINE 4u
+#define HEX_VIEWER_LINES_ON_SCREEN 4u
+#define HEX_VIEWER_BUF_SIZE (HEX_VIEWER_LINES_ON_SCREEN * HEX_VIEWER_BYTES_PER_LINE)
typedef struct {
- uint8_t file_bytes[HEX_VIEWER_ROW_COUNT][HEX_VIEWER_ROW_COUNT];
- uint32_t line;
- uint32_t read_bytes;
+ uint8_t file_bytes[HEX_VIEWER_LINES_ON_SCREEN][HEX_VIEWER_BYTES_PER_LINE];
+ uint32_t file_offset;
+ uint32_t file_read_bytes;
uint32_t file_size;
Stream* stream;
bool mode; // Print address or content
@@ -54,27 +54,28 @@ static void render_callback(Canvas* canvas, void* ctx) {
int TOP_OFFSET = 10;
int LEFT_OFFSET = 3;
- uint32_t line_count = hex_viewer->model->file_size / HEX_VIEWER_BYTES_PER_ROW;
- if(hex_viewer->model->file_size % HEX_VIEWER_BYTES_PER_ROW != 0) line_count += 1;
- if(line_count > HEX_VIEWER_ROW_COUNT) {
+ uint32_t line_count = hex_viewer->model->file_size / HEX_VIEWER_BYTES_PER_LINE;
+ if(hex_viewer->model->file_size % HEX_VIEWER_BYTES_PER_LINE != 0) line_count += 1;
+ uint32_t first_line_on_screen = hex_viewer->model->file_offset / HEX_VIEWER_BYTES_PER_LINE;
+ if(line_count > HEX_VIEWER_LINES_ON_SCREEN) {
uint8_t width = canvas_width(canvas);
elements_scrollbar_pos(
canvas,
width,
0,
- ROW_HEIGHT * HEX_VIEWER_ROW_COUNT,
- hex_viewer->model->line,
- line_count - (HEX_VIEWER_ROW_COUNT - 1));
+ ROW_HEIGHT * HEX_VIEWER_LINES_ON_SCREEN,
+ first_line_on_screen, // TODO
+ line_count - (HEX_VIEWER_LINES_ON_SCREEN - 1));
}
char temp_buf[32];
- uint32_t row_iters = hex_viewer->model->read_bytes / HEX_VIEWER_BYTES_PER_ROW;
- if(hex_viewer->model->read_bytes % HEX_VIEWER_BYTES_PER_ROW != 0) row_iters += 1;
+ uint32_t row_iters = hex_viewer->model->file_read_bytes / HEX_VIEWER_BYTES_PER_LINE;
+ if(hex_viewer->model->file_read_bytes % HEX_VIEWER_BYTES_PER_LINE != 0) row_iters += 1;
for(uint32_t i = 0; i < row_iters; ++i) {
- uint32_t bytes_left_per_row = hex_viewer->model->read_bytes - i * HEX_VIEWER_BYTES_PER_ROW;
- if(bytes_left_per_row > HEX_VIEWER_BYTES_PER_ROW)
- bytes_left_per_row = HEX_VIEWER_BYTES_PER_ROW;
+ uint32_t bytes_left_per_row =
+ hex_viewer->model->file_read_bytes - i * HEX_VIEWER_BYTES_PER_LINE;
+ bytes_left_per_row = MIN(bytes_left_per_row, HEX_VIEWER_BYTES_PER_LINE);
if(hex_viewer->model->mode) {
memcpy(temp_buf, hex_viewer->model->file_bytes[i], bytes_left_per_row);
@@ -85,8 +86,8 @@ static void render_callback(Canvas* canvas, void* ctx) {
canvas_set_font(canvas, FontKeyboard);
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
} else {
- int addr = (i + hex_viewer->model->line) * HEX_VIEWER_BYTES_PER_ROW;
- snprintf(temp_buf, 32, "%04X", addr);
+ uint32_t addr = hex_viewer->model->file_offset + i * HEX_VIEWER_BYTES_PER_LINE;
+ snprintf(temp_buf, 32, "%04lX", addr);
canvas_set_font(canvas, FontKeyboard);
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
@@ -105,7 +106,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
static void input_callback(InputEvent* input_event, void* ctx) {
HexViewer* hex_viewer = ctx;
- if(input_event->type == InputTypeShort) {
+ if(input_event->type == InputTypeShort || input_event->type == InputTypeRepeat) {
furi_message_queue_put(hex_viewer->input_queue, input_event, 0);
}
}
@@ -173,19 +174,20 @@ static bool hex_viewer_open_file(HexViewer* hex_viewer, const char* file_path) {
static bool hex_viewer_read_file(HexViewer* hex_viewer) {
furi_assert(hex_viewer);
furi_assert(hex_viewer->model->stream);
+ furi_assert(hex_viewer->model->file_offset % HEX_VIEWER_BYTES_PER_LINE == 0);
memset(hex_viewer->model->file_bytes, 0x0, HEX_VIEWER_BUF_SIZE);
bool isOk = true;
do {
- uint32_t offset = hex_viewer->model->line * HEX_VIEWER_BYTES_PER_ROW;
+ uint32_t offset = hex_viewer->model->file_offset;
if(!stream_seek(hex_viewer->model->stream, offset, true)) {
FURI_LOG_E(TAG, "Unable to seek stream");
isOk = false;
break;
}
- hex_viewer->model->read_bytes = stream_read(
+ hex_viewer->model->file_read_bytes = stream_read(
hex_viewer->model->stream,
(uint8_t*)hex_viewer->model->file_bytes,
HEX_VIEWER_BUF_SIZE);
@@ -233,19 +235,18 @@ int32_t hex_viewer_app(void* p) {
break;
} else if(input.key == InputKeyUp) {
furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
- if(hex_viewer->model->line > 0) {
- hex_viewer->model->line--;
-
+ if(hex_viewer->model->file_offset > 0) {
+ hex_viewer->model->file_offset -= HEX_VIEWER_BYTES_PER_LINE;
if(!hex_viewer_read_file(hex_viewer)) break;
}
furi_mutex_release(hex_viewer->mutex);
} else if(input.key == InputKeyDown) {
furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
- uint32_t cur_pos = hex_viewer->model->line * HEX_VIEWER_BYTES_PER_ROW +
- hex_viewer->model->read_bytes;
+ uint32_t last_byte_on_screen =
+ hex_viewer->model->file_offset + hex_viewer->model->file_read_bytes;
- if(hex_viewer->model->file_size > cur_pos) {
- hex_viewer->model->line++;
+ if(hex_viewer->model->file_size > last_byte_on_screen) {
+ hex_viewer->model->file_offset += HEX_VIEWER_BYTES_PER_LINE;
if(!hex_viewer_read_file(hex_viewer)) break;
}
furi_mutex_release(hex_viewer->mutex);
@@ -265,7 +266,7 @@ int32_t hex_viewer_app(void* p) {
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
- dialog_message_set_header(message, "Hex Viewer v1.0", 16, 2, AlignLeft, AlignTop);
+ dialog_message_set_header(message, "Hex Viewer v1.1", 16, 2, AlignLeft, AlignTop);
dialog_message_set_icon(message, &I_hex_10px, 3, 2);
dialog_message_set_text(
message, furi_string_get_cstr(buffer), 3, 16, AlignLeft, AlignTop);
diff --git a/applications/plugins/nrf24scan/README.md b/applications/plugins/nrf24scan/README.md
index 51d7bc8e4..7754a7c90 100644
--- a/applications/plugins/nrf24scan/README.md
+++ b/applications/plugins/nrf24scan/README.md
@@ -1,4 +1,4 @@
-# Scanner NRF24 scanner with logging and resend ability for Flipper Zero
+# NRF24 scanner with logging and resend ability for Flipper Zero
An [NRF24](https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf) driver for the [Flipper Zero](https://flipperzero.one/) device. The NRF24 is a popular line of 2.4GHz radio transceivers from Nordic Semiconductors. This library is not currently complete, but functional.
@@ -29,6 +29,12 @@ Long press OK - view addresses.
+
+
+
+
+
+
## PinOut from from NoComp/Frog
@@ -45,3 +51,4 @@ IRQ/8 is left disconnected on nrf24l01

If the nRF module is acting a bit flakey, try adding a capacitor to the vcc/gnd lines! I've not tried the Plus model so it may have a bigger need for a cap. Otherwise, I haven't had any major issues. Anything from a 3.3 uF to 10 uF should do. (Watch your positive/negative placement! Negative to ground.) I learned if you wanna get fancy, include a 0.1 uF cap in parallel. The 3.3 uF to 10 uF will respond to slow freq changes while the 0.1 uF will respond to the high freq switching spikes that the larger one cannot. That said, a single 10 uF will likely suffice for the Mousejack attack. ¯\\\_(ツ)_/¯

+
diff --git a/applications/plugins/nrf24scan/Screenshot-1.png b/applications/plugins/nrf24scan/Screenshot-1.png
index 8f7aca2a5..082e7d5af 100644
Binary files a/applications/plugins/nrf24scan/Screenshot-1.png and b/applications/plugins/nrf24scan/Screenshot-1.png differ
diff --git a/applications/plugins/nrf24scan/Screenshot-3.png b/applications/plugins/nrf24scan/Screenshot-3.png
new file mode 100644
index 000000000..651052350
Binary files /dev/null and b/applications/plugins/nrf24scan/Screenshot-3.png differ
diff --git a/applications/plugins/nrf24scan/Screenshot-4.png b/applications/plugins/nrf24scan/Screenshot-4.png
new file mode 100644
index 000000000..b5396eb20
Binary files /dev/null and b/applications/plugins/nrf24scan/Screenshot-4.png differ
diff --git a/applications/plugins/nrf24scan/addr.txt b/applications/plugins/nrf24scan/addr.txt
index 0e24b1c44..a79064baf 100644
--- a/applications/plugins/nrf24scan/addr.txt
+++ b/applications/plugins/nrf24scan/addr.txt
@@ -1,5 +1,5 @@
-1
-120
-C8C801
-C8C802
-03
+Rate: 1
+Ch: 120
+P0: C8C801
+P1: C8C802
+P2: 03
diff --git a/applications/plugins/nrf24scan/addr1.txt b/applications/plugins/nrf24scan/addr1.txt
index 8ad9c5fd7..5a10c4298 100644
--- a/applications/plugins/nrf24scan/addr1.txt
+++ b/applications/plugins/nrf24scan/addr1.txt
@@ -1,3 +1,3 @@
-1
-120
-C8C8E5
+Rate: 1
+Ch: 120
+P0: C8C8E5
diff --git a/applications/plugins/nrf24scan/addr_sniff.txt b/applications/plugins/nrf24scan/addr_sniff.txt
index 6f1a699c7..f95f8eeff 100644
--- a/applications/plugins/nrf24scan/addr_sniff.txt
+++ b/applications/plugins/nrf24scan/addr_sniff.txt
@@ -1,4 +1,4 @@
-1
-0
-0055
-00AA
+Rate: 1
+Ch: 0
+P0: 0055
+P1: 00AA
diff --git a/applications/plugins/nrf24scan/lib/nrf24/nrf24.c b/applications/plugins/nrf24scan/lib/nrf24/nrf24.c
index 4c344c742..7751175b0 100644
--- a/applications/plugins/nrf24scan/lib/nrf24/nrf24.c
+++ b/applications/plugins/nrf24scan/lib/nrf24/nrf24.c
@@ -1,3 +1,5 @@
+// Modified by vad7, 25.11.2022
+//
#include "nrf24.h"
#include
#include
@@ -176,9 +178,10 @@ uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t siz
return status;
}
-uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle) {
+uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe) {
uint8_t len = 0;
- nrf24_read_reg(handle, RX_PW_P0, &len, 1);
+ if(pipe > 5) pipe = 0;
+ nrf24_read_reg(handle, RX_PW_P0 + pipe, &len, 1);
return len;
}
@@ -188,8 +191,7 @@ uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
return status;
}
-uint8_t
- nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) {
+uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) {
uint8_t status = 0;
uint8_t size = 0;
uint8_t tx_pl_wid[] = {R_RX_PL_WID, 0};
@@ -201,12 +203,12 @@ uint8_t
if(status & 0x40) {
if(full)
- size = nrf24_get_packetlen(handle);
+ size = nrf24_get_packetlen(handle, (status >> 1) & 7);
else {
nrf24_spi_trx(handle, tx_pl_wid, rx_pl_wid, 2, nrf24_TIMEOUT);
size = rx_pl_wid[1];
}
-
+ if(size > 32) size = 32;
tx_cmd[0] = R_RX_PAYLOAD;
nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT);
nrf24_write_reg(handle, REG_STATUS, 0x50); // clear RX_DR, MAX_RT.
@@ -277,7 +279,7 @@ uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle) {
status = nrf24_write_reg(handle, REG_CONFIG, cfg);
//nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1
furi_hal_gpio_write(nrf24_CE_PIN, true);
- furi_delay_ms(2000);
+ furi_delay_ms(2);
return status;
}
diff --git a/applications/plugins/nrf24scan/lib/nrf24/nrf24.h b/applications/plugins/nrf24scan/lib/nrf24/nrf24.h
index 28cf8782b..8ff1ab27e 100644
--- a/applications/plugins/nrf24scan/lib/nrf24/nrf24.h
+++ b/applications/plugins/nrf24scan/lib/nrf24/nrf24.h
@@ -150,10 +150,10 @@ uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle);
/** Gets the RX packet length in data pipe 0
*
* @param handle - pointer to FuriHalSpiHandle
- *
+ * pipe - pipe index (0..5)
* @return packet length in data pipe 0
*/
-uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle);
+uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe);
/** Sets the RX packet length in data pipe 0
*
diff --git a/applications/plugins/nrf24scan/nrf24scan.c b/applications/plugins/nrf24scan/nrf24scan.c
index a8693656a..4fc6a1dcf 100644
--- a/applications/plugins/nrf24scan/nrf24scan.c
+++ b/applications/plugins/nrf24scan/nrf24scan.c
@@ -18,7 +18,7 @@
#define MAX_ADDR 6
#define SCAN_APP_PATH_FOLDER "/ext/nrf24scan"
-#define ADDR_FILENAME \
+#define ADDR_FILENAME \
"addr.txt" // File format (1 parameter per line): \
// Rate: 0/1/2 - rate in Mbps (=0.25/1/2) \
// Ch: 0..125 - default channel \
@@ -869,6 +869,7 @@ int32_t nrf24scan_app(void* p) {
if(what_doing == 1 && key_press_seq_ok != event.input.sequence) { // Send
nrf24_send_packet();
}
+ key_press_seq_ok--;
}
break;
case InputKeyBack:
@@ -914,4 +915,4 @@ int32_t nrf24scan_app(void* p) {
if(APP->log_arr) free(APP->log_arr);
free(APP);
return 0;
-}
\ No newline at end of file
+}