mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
app upd + fmt
This commit is contained in:
@@ -16,14 +16,14 @@
|
|||||||
#define HEX_VIEWER_APP_PATH_FOLDER "/any"
|
#define HEX_VIEWER_APP_PATH_FOLDER "/any"
|
||||||
#define HEX_VIEWER_APP_EXTENSION "*"
|
#define HEX_VIEWER_APP_EXTENSION "*"
|
||||||
|
|
||||||
#define HEX_VIEWER_BYTES_PER_ROW 4
|
#define HEX_VIEWER_BYTES_PER_LINE 4u
|
||||||
#define HEX_VIEWER_ROW_COUNT 4
|
#define HEX_VIEWER_LINES_ON_SCREEN 4u
|
||||||
#define HEX_VIEWER_BUF_SIZE (HEX_VIEWER_BYTES_PER_ROW * HEX_VIEWER_ROW_COUNT)
|
#define HEX_VIEWER_BUF_SIZE (HEX_VIEWER_LINES_ON_SCREEN * HEX_VIEWER_BYTES_PER_LINE)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t file_bytes[HEX_VIEWER_ROW_COUNT][HEX_VIEWER_ROW_COUNT];
|
uint8_t file_bytes[HEX_VIEWER_LINES_ON_SCREEN][HEX_VIEWER_BYTES_PER_LINE];
|
||||||
uint32_t line;
|
uint32_t file_offset;
|
||||||
uint32_t read_bytes;
|
uint32_t file_read_bytes;
|
||||||
uint32_t file_size;
|
uint32_t file_size;
|
||||||
Stream* stream;
|
Stream* stream;
|
||||||
bool mode; // Print address or content
|
bool mode; // Print address or content
|
||||||
@@ -54,27 +54,28 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
|||||||
int TOP_OFFSET = 10;
|
int TOP_OFFSET = 10;
|
||||||
int LEFT_OFFSET = 3;
|
int LEFT_OFFSET = 3;
|
||||||
|
|
||||||
uint32_t line_count = hex_viewer->model->file_size / HEX_VIEWER_BYTES_PER_ROW;
|
uint32_t line_count = hex_viewer->model->file_size / HEX_VIEWER_BYTES_PER_LINE;
|
||||||
if(hex_viewer->model->file_size % HEX_VIEWER_BYTES_PER_ROW != 0) line_count += 1;
|
if(hex_viewer->model->file_size % HEX_VIEWER_BYTES_PER_LINE != 0) line_count += 1;
|
||||||
if(line_count > HEX_VIEWER_ROW_COUNT) {
|
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);
|
uint8_t width = canvas_width(canvas);
|
||||||
elements_scrollbar_pos(
|
elements_scrollbar_pos(
|
||||||
canvas,
|
canvas,
|
||||||
width,
|
width,
|
||||||
0,
|
0,
|
||||||
ROW_HEIGHT * HEX_VIEWER_ROW_COUNT,
|
ROW_HEIGHT * HEX_VIEWER_LINES_ON_SCREEN,
|
||||||
hex_viewer->model->line,
|
first_line_on_screen, // TODO
|
||||||
line_count - (HEX_VIEWER_ROW_COUNT - 1));
|
line_count - (HEX_VIEWER_LINES_ON_SCREEN - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
char temp_buf[32];
|
char temp_buf[32];
|
||||||
uint32_t row_iters = hex_viewer->model->read_bytes / HEX_VIEWER_BYTES_PER_ROW;
|
uint32_t row_iters = hex_viewer->model->file_read_bytes / HEX_VIEWER_BYTES_PER_LINE;
|
||||||
if(hex_viewer->model->read_bytes % HEX_VIEWER_BYTES_PER_ROW != 0) row_iters += 1;
|
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) {
|
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;
|
uint32_t bytes_left_per_row =
|
||||||
if(bytes_left_per_row > HEX_VIEWER_BYTES_PER_ROW)
|
hex_viewer->model->file_read_bytes - i * HEX_VIEWER_BYTES_PER_LINE;
|
||||||
bytes_left_per_row = HEX_VIEWER_BYTES_PER_ROW;
|
bytes_left_per_row = MIN(bytes_left_per_row, HEX_VIEWER_BYTES_PER_LINE);
|
||||||
|
|
||||||
if(hex_viewer->model->mode) {
|
if(hex_viewer->model->mode) {
|
||||||
memcpy(temp_buf, hex_viewer->model->file_bytes[i], bytes_left_per_row);
|
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_set_font(canvas, FontKeyboard);
|
||||||
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
|
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
|
||||||
} else {
|
} else {
|
||||||
int addr = (i + hex_viewer->model->line) * HEX_VIEWER_BYTES_PER_ROW;
|
uint32_t addr = hex_viewer->model->file_offset + i * HEX_VIEWER_BYTES_PER_LINE;
|
||||||
snprintf(temp_buf, 32, "%04X", addr);
|
snprintf(temp_buf, 32, "%04lX", addr);
|
||||||
|
|
||||||
canvas_set_font(canvas, FontKeyboard);
|
canvas_set_font(canvas, FontKeyboard);
|
||||||
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
|
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) {
|
static void input_callback(InputEvent* input_event, void* ctx) {
|
||||||
HexViewer* hex_viewer = 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);
|
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) {
|
static bool hex_viewer_read_file(HexViewer* hex_viewer) {
|
||||||
furi_assert(hex_viewer);
|
furi_assert(hex_viewer);
|
||||||
furi_assert(hex_viewer->model->stream);
|
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);
|
memset(hex_viewer->model->file_bytes, 0x0, HEX_VIEWER_BUF_SIZE);
|
||||||
bool isOk = true;
|
bool isOk = true;
|
||||||
|
|
||||||
do {
|
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)) {
|
if(!stream_seek(hex_viewer->model->stream, offset, true)) {
|
||||||
FURI_LOG_E(TAG, "Unable to seek stream");
|
FURI_LOG_E(TAG, "Unable to seek stream");
|
||||||
isOk = false;
|
isOk = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hex_viewer->model->read_bytes = stream_read(
|
hex_viewer->model->file_read_bytes = stream_read(
|
||||||
hex_viewer->model->stream,
|
hex_viewer->model->stream,
|
||||||
(uint8_t*)hex_viewer->model->file_bytes,
|
(uint8_t*)hex_viewer->model->file_bytes,
|
||||||
HEX_VIEWER_BUF_SIZE);
|
HEX_VIEWER_BUF_SIZE);
|
||||||
@@ -233,19 +235,18 @@ int32_t hex_viewer_app(void* p) {
|
|||||||
break;
|
break;
|
||||||
} else if(input.key == InputKeyUp) {
|
} else if(input.key == InputKeyUp) {
|
||||||
furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
|
furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
|
||||||
if(hex_viewer->model->line > 0) {
|
if(hex_viewer->model->file_offset > 0) {
|
||||||
hex_viewer->model->line--;
|
hex_viewer->model->file_offset -= HEX_VIEWER_BYTES_PER_LINE;
|
||||||
|
|
||||||
if(!hex_viewer_read_file(hex_viewer)) break;
|
if(!hex_viewer_read_file(hex_viewer)) break;
|
||||||
}
|
}
|
||||||
furi_mutex_release(hex_viewer->mutex);
|
furi_mutex_release(hex_viewer->mutex);
|
||||||
} else if(input.key == InputKeyDown) {
|
} else if(input.key == InputKeyDown) {
|
||||||
furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
|
furi_check(furi_mutex_acquire(hex_viewer->mutex, FuriWaitForever) == FuriStatusOk);
|
||||||
uint32_t cur_pos = hex_viewer->model->line * HEX_VIEWER_BYTES_PER_ROW +
|
uint32_t last_byte_on_screen =
|
||||||
hex_viewer->model->read_bytes;
|
hex_viewer->model->file_offset + hex_viewer->model->file_read_bytes;
|
||||||
|
|
||||||
if(hex_viewer->model->file_size > cur_pos) {
|
if(hex_viewer->model->file_size > last_byte_on_screen) {
|
||||||
hex_viewer->model->line++;
|
hex_viewer->model->file_offset += HEX_VIEWER_BYTES_PER_LINE;
|
||||||
if(!hex_viewer_read_file(hex_viewer)) break;
|
if(!hex_viewer_read_file(hex_viewer)) break;
|
||||||
}
|
}
|
||||||
furi_mutex_release(hex_viewer->mutex);
|
furi_mutex_release(hex_viewer->mutex);
|
||||||
@@ -265,7 +266,7 @@ int32_t hex_viewer_app(void* p) {
|
|||||||
|
|
||||||
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
|
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
|
||||||
DialogMessage* message = dialog_message_alloc();
|
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_icon(message, &I_hex_10px, 3, 2);
|
||||||
dialog_message_set_text(
|
dialog_message_set_text(
|
||||||
message, furi_string_get_cstr(buffer), 3, 16, AlignLeft, AlignTop);
|
message, furi_string_get_cstr(buffer), 3, 16, AlignLeft, AlignTop);
|
||||||
|
|||||||
@@ -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.
|
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.<br>
|
|||||||
<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-1.png">
|
<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-1.png">
|
||||||
<br>
|
<br>
|
||||||
<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-2.png">
|
<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-2.png">
|
||||||
|
<br>
|
||||||
|
<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-3.png">
|
||||||
|
<br>
|
||||||
|
<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-4.png">
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
## PinOut from from NoComp/Frog
|
## PinOut from from NoComp/Frog
|
||||||
<img src="https://media.discordapp.net/attachments/937479784726949900/994495234618687509/unknown.png?width=567&height=634">
|
<img src="https://media.discordapp.net/attachments/937479784726949900/994495234618687509/unknown.png?width=567&height=634">
|
||||||
@@ -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. ¯\\\_(ツ)_/¯
|
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. ¯\\\_(ツ)_/¯
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
applications/plugins/nrf24scan/Screenshot-3.png
Normal file
BIN
applications/plugins/nrf24scan/Screenshot-3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
applications/plugins/nrf24scan/Screenshot-4.png
Normal file
BIN
applications/plugins/nrf24scan/Screenshot-4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -1,5 +1,5 @@
|
|||||||
1
|
Rate: 1
|
||||||
120
|
Ch: 120
|
||||||
C8C801
|
P0: C8C801
|
||||||
C8C802
|
P1: C8C802
|
||||||
03
|
P2: 03
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
1
|
Rate: 1
|
||||||
120
|
Ch: 120
|
||||||
C8C8E5
|
P0: C8C8E5
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
1
|
Rate: 1
|
||||||
0
|
Ch: 0
|
||||||
0055
|
P0: 0055
|
||||||
00AA
|
P1: 00AA
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// Modified by vad7, 25.11.2022
|
||||||
|
//
|
||||||
#include "nrf24.h"
|
#include "nrf24.h"
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
@@ -176,9 +178,10 @@ uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t siz
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle) {
|
uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe) {
|
||||||
uint8_t len = 0;
|
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;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,8 +191,7 @@ uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) {
|
||||||
nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) {
|
|
||||||
uint8_t status = 0;
|
uint8_t status = 0;
|
||||||
uint8_t size = 0;
|
uint8_t size = 0;
|
||||||
uint8_t tx_pl_wid[] = {R_RX_PL_WID, 0};
|
uint8_t tx_pl_wid[] = {R_RX_PL_WID, 0};
|
||||||
@@ -201,12 +203,12 @@ uint8_t
|
|||||||
|
|
||||||
if(status & 0x40) {
|
if(status & 0x40) {
|
||||||
if(full)
|
if(full)
|
||||||
size = nrf24_get_packetlen(handle);
|
size = nrf24_get_packetlen(handle, (status >> 1) & 7);
|
||||||
else {
|
else {
|
||||||
nrf24_spi_trx(handle, tx_pl_wid, rx_pl_wid, 2, nrf24_TIMEOUT);
|
nrf24_spi_trx(handle, tx_pl_wid, rx_pl_wid, 2, nrf24_TIMEOUT);
|
||||||
size = rx_pl_wid[1];
|
size = rx_pl_wid[1];
|
||||||
}
|
}
|
||||||
|
if(size > 32) size = 32;
|
||||||
tx_cmd[0] = R_RX_PAYLOAD;
|
tx_cmd[0] = R_RX_PAYLOAD;
|
||||||
nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT);
|
nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT);
|
||||||
nrf24_write_reg(handle, REG_STATUS, 0x50); // clear RX_DR, MAX_RT.
|
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);
|
status = nrf24_write_reg(handle, REG_CONFIG, cfg);
|
||||||
//nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1
|
//nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1
|
||||||
furi_hal_gpio_write(nrf24_CE_PIN, true);
|
furi_hal_gpio_write(nrf24_CE_PIN, true);
|
||||||
furi_delay_ms(2000);
|
furi_delay_ms(2);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,10 +150,10 @@ uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle);
|
|||||||
/** Gets the RX packet length in data pipe 0
|
/** Gets the RX packet length in data pipe 0
|
||||||
*
|
*
|
||||||
* @param handle - pointer to FuriHalSpiHandle
|
* @param handle - pointer to FuriHalSpiHandle
|
||||||
*
|
* pipe - pipe index (0..5)
|
||||||
* @return packet length in data pipe 0
|
* @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
|
/** Sets the RX packet length in data pipe 0
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -869,6 +869,7 @@ int32_t nrf24scan_app(void* p) {
|
|||||||
if(what_doing == 1 && key_press_seq_ok != event.input.sequence) { // Send
|
if(what_doing == 1 && key_press_seq_ok != event.input.sequence) { // Send
|
||||||
nrf24_send_packet();
|
nrf24_send_packet();
|
||||||
}
|
}
|
||||||
|
key_press_seq_ok--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InputKeyBack:
|
case InputKeyBack:
|
||||||
|
|||||||
Reference in New Issue
Block a user