mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 06:13:14 +03:00
parent
5681016dce
commit
a1b368abda
@ -86,6 +86,8 @@ void SCLcallback(void* _i2c_sniffer) {
|
||||
i2cSniffer* i2c_sniffer_alloc() {
|
||||
i2cSniffer* i2c_sniffer = malloc(sizeof(i2cSniffer));
|
||||
i2c_sniffer->started = false;
|
||||
i2c_sniffer->row_index = 0;
|
||||
i2c_sniffer->menu_index = 0;
|
||||
clear_sniffer_buffers(i2c_sniffer);
|
||||
return i2c_sniffer;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ typedef struct {
|
||||
i2cFrame frames[MAX_RECORDS];
|
||||
uint8_t frame_index;
|
||||
uint8_t menu_index;
|
||||
uint8_t row_index;
|
||||
} i2cSniffer;
|
||||
|
||||
void clear_sniffer_buffers(i2cSniffer* i2c_sniffer);
|
||||
|
@ -68,6 +68,7 @@ int32_t i2ctools_app(void* p) {
|
||||
i2ctools->sender->scanner = i2ctools->scanner;
|
||||
|
||||
while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
|
||||
// Back
|
||||
if(event.key == InputKeyBack && event.type == InputTypeRelease) {
|
||||
if(i2ctools->main_view->current_view == MAIN_VIEW) {
|
||||
break;
|
||||
@ -79,7 +80,9 @@ int32_t i2ctools_app(void* p) {
|
||||
}
|
||||
i2ctools->main_view->current_view = MAIN_VIEW;
|
||||
}
|
||||
} else if(event.key == InputKeyUp && event.type == InputTypeRelease) {
|
||||
}
|
||||
// Up
|
||||
else if(event.key == InputKeyUp && event.type == InputTypeRelease) {
|
||||
if(i2ctools->main_view->current_view == MAIN_VIEW) {
|
||||
if((i2ctools->main_view->menu_index > SCAN_VIEW)) {
|
||||
i2ctools->main_view->menu_index--;
|
||||
@ -88,41 +91,76 @@ int32_t i2ctools_app(void* p) {
|
||||
if(i2ctools->scanner->menu_index > 0) {
|
||||
i2ctools->scanner->menu_index--;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SNIFF_VIEW) {
|
||||
if(i2ctools->sniffer->row_index > 0) {
|
||||
i2ctools->sniffer->row_index--;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SEND_VIEW) {
|
||||
if(i2ctools->sender->value < 0xFF) {
|
||||
i2ctools->sender->value++;
|
||||
i2ctools->sender->sended = false;
|
||||
}
|
||||
}
|
||||
} else if(
|
||||
}
|
||||
// Long Up
|
||||
else if(
|
||||
event.key == InputKeyUp &&
|
||||
(event.type == InputTypeLong || event.type == InputTypeRepeat)) {
|
||||
if(i2ctools->main_view->current_view == SEND_VIEW) {
|
||||
if(i2ctools->main_view->current_view == SCAN_VIEW) {
|
||||
if(i2ctools->scanner->menu_index > 5) {
|
||||
i2ctools->scanner->menu_index -= 5;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SEND_VIEW) {
|
||||
if(i2ctools->sender->value < 0xF9) {
|
||||
i2ctools->sender->value += 5;
|
||||
i2ctools->sender->sended = false;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SNIFF_VIEW) {
|
||||
if(i2ctools->sniffer->row_index > 5) {
|
||||
i2ctools->sniffer->row_index -= 5;
|
||||
} else {
|
||||
i2ctools->sniffer->row_index = 0;
|
||||
}
|
||||
}
|
||||
} else if(event.key == InputKeyDown && event.type == InputTypeRelease) {
|
||||
}
|
||||
// Down
|
||||
else if(event.key == InputKeyDown && event.type == InputTypeRelease) {
|
||||
if(i2ctools->main_view->current_view == MAIN_VIEW) {
|
||||
if(i2ctools->main_view->menu_index < 3) {
|
||||
if(i2ctools->main_view->menu_index < MENU_SIZE - 1) {
|
||||
i2ctools->main_view->menu_index++;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SCAN_VIEW) {
|
||||
if(i2ctools->scanner->menu_index < ((int)i2ctools->scanner->nb_found / 3)) {
|
||||
i2ctools->scanner->menu_index++;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SNIFF_VIEW) {
|
||||
if((i2ctools->sniffer->row_index + 3) <
|
||||
(int)i2ctools->sniffer->frames[i2ctools->sniffer->menu_index].data_index) {
|
||||
i2ctools->sniffer->row_index++;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SEND_VIEW) {
|
||||
if(i2ctools->sender->value > 0x00) {
|
||||
i2ctools->sender->value--;
|
||||
i2ctools->sender->sended = false;
|
||||
}
|
||||
}
|
||||
} else if(event.key == InputKeyDown && event.type == InputTypeLong) {
|
||||
}
|
||||
// Long Down
|
||||
else if(
|
||||
event.key == InputKeyDown &&
|
||||
(event.type == InputTypeLong || event.type == InputTypeRepeat)) {
|
||||
if(i2ctools->main_view->current_view == SEND_VIEW) {
|
||||
if(i2ctools->sender->value > 0x05) {
|
||||
i2ctools->sender->value -= 5;
|
||||
i2ctools->sender->sended = false;
|
||||
} else {
|
||||
i2ctools->sender->value = 0;
|
||||
i2ctools->sender->sended = false;
|
||||
}
|
||||
} else if(i2ctools->main_view->current_view == SNIFF_VIEW) {
|
||||
if((i2ctools->sniffer->row_index + 8) <
|
||||
(int)i2ctools->sniffer->frames[i2ctools->sniffer->menu_index].data_index) {
|
||||
i2ctools->sniffer->row_index += 5;
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,6 +191,7 @@ int32_t i2ctools_app(void* p) {
|
||||
} else if(i2ctools->main_view->current_view == SNIFF_VIEW) {
|
||||
if(i2ctools->sniffer->menu_index < i2ctools->sniffer->frame_index) {
|
||||
i2ctools->sniffer->menu_index++;
|
||||
i2ctools->sniffer->row_index = 0;
|
||||
}
|
||||
}
|
||||
} else if(event.key == InputKeyLeft && event.type == InputTypeRelease) {
|
||||
@ -164,6 +203,7 @@ int32_t i2ctools_app(void* p) {
|
||||
} else if(i2ctools->main_view->current_view == SNIFF_VIEW) {
|
||||
if(i2ctools->sniffer->menu_index > 0) {
|
||||
i2ctools->sniffer->menu_index--;
|
||||
i2ctools->sniffer->row_index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
@ -4,9 +4,8 @@ void draw_main_view(Canvas* canvas, i2cMainView* main_view) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 0, 0, 128, 64, 3);
|
||||
canvas_draw_icon(canvas, 2, 13, &I_passport_bad3_46x49);
|
||||
canvas_draw_icon(canvas, 2, 2, &I_i2ctools_main_76x59);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 3, 3, AlignLeft, AlignTop, APP_NAME);
|
||||
|
||||
switch(main_view->menu_index) {
|
||||
case SCAN_VIEW:
|
||||
@ -15,7 +14,7 @@ void draw_main_view(Canvas* canvas, i2cMainView* main_view) {
|
||||
canvas, SNIFF_MENU_X, SNIFF_MENU_Y, AlignLeft, AlignTop, SNIFF_MENU_TEXT);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, SEND_MENU_X, SEND_MENU_Y, AlignLeft, AlignTop, SEND_MENU_TEXT);
|
||||
canvas_draw_rbox(canvas, 60, SCAN_MENU_Y - 2, 60, 13, 3);
|
||||
canvas_draw_rbox(canvas, 80, SCAN_MENU_Y - 2, 43, 13, 3);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, SCAN_MENU_X, SCAN_MENU_Y, AlignLeft, AlignTop, SCAN_MENU_TEXT);
|
||||
@ -27,7 +26,7 @@ void draw_main_view(Canvas* canvas, i2cMainView* main_view) {
|
||||
canvas, SCAN_MENU_X, SCAN_MENU_Y, AlignLeft, AlignTop, SCAN_MENU_TEXT);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, SEND_MENU_X, SEND_MENU_Y, AlignLeft, AlignTop, SEND_MENU_TEXT);
|
||||
canvas_draw_rbox(canvas, 60, SNIFF_MENU_Y - 2, 60, 13, 3);
|
||||
canvas_draw_rbox(canvas, 80, SNIFF_MENU_Y - 2, 43, 13, 3);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, SNIFF_MENU_X, SNIFF_MENU_Y, AlignLeft, AlignTop, SNIFF_MENU_TEXT);
|
||||
@ -39,7 +38,7 @@ void draw_main_view(Canvas* canvas, i2cMainView* main_view) {
|
||||
canvas, SCAN_MENU_X, SCAN_MENU_Y, AlignLeft, AlignTop, SCAN_MENU_TEXT);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, SNIFF_MENU_X, SNIFF_MENU_Y, AlignLeft, AlignTop, SNIFF_MENU_TEXT);
|
||||
canvas_draw_rbox(canvas, 60, SEND_MENU_Y - 2, 60, 13, 3);
|
||||
canvas_draw_rbox(canvas, 80, SEND_MENU_Y - 2, 43, 13, 3);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_str_aligned(
|
||||
canvas, SEND_MENU_X, SEND_MENU_Y, AlignLeft, AlignTop, SEND_MENU_TEXT);
|
||||
|
@ -5,16 +5,16 @@
|
||||
#define APP_NAME "I2C Tools"
|
||||
|
||||
#define SCAN_MENU_TEXT "Scan"
|
||||
#define SCAN_MENU_X 75
|
||||
#define SCAN_MENU_Y 6
|
||||
#define SCAN_MENU_X 90
|
||||
#define SCAN_MENU_Y 13
|
||||
|
||||
#define SNIFF_MENU_TEXT "Sniff"
|
||||
#define SNIFF_MENU_X 75
|
||||
#define SNIFF_MENU_Y 20
|
||||
#define SNIFF_MENU_X 90
|
||||
#define SNIFF_MENU_Y 27
|
||||
|
||||
#define SEND_MENU_TEXT "Send"
|
||||
#define SEND_MENU_X 75
|
||||
#define SEND_MENU_Y 34
|
||||
#define SEND_MENU_X 90
|
||||
#define SEND_MENU_Y 41
|
||||
|
||||
// Menu
|
||||
typedef enum {
|
||||
|
@ -4,15 +4,12 @@ void draw_scanner_view(Canvas* canvas, i2cScanner* i2c_scanner) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 0, 0, 128, 64, 3);
|
||||
canvas_draw_icon(canvas, 2, 13, &I_passport_happy3_46x49);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 3, 3, AlignLeft, AlignTop, SCAN_MENU_TEXT);
|
||||
|
||||
char count_text[46];
|
||||
char count_text_fmt[] = "Found: %d";
|
||||
char count_text_fmt[] = "Peripherals Found: %d";
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
snprintf(count_text, sizeof(count_text), count_text_fmt, (int)i2c_scanner->nb_found);
|
||||
canvas_draw_str_aligned(canvas, 50, 3, AlignLeft, AlignTop, count_text);
|
||||
canvas_draw_str_aligned(canvas, 3, 3, AlignLeft, AlignTop, count_text);
|
||||
uint8_t x_pos = 0;
|
||||
uint8_t y_pos = 0;
|
||||
uint8_t idx_to_print = 0;
|
||||
@ -23,21 +20,16 @@ void draw_scanner_view(Canvas* canvas, i2cScanner* i2c_scanner) {
|
||||
}
|
||||
snprintf(
|
||||
count_text, sizeof(count_text), "0x%02x ", (int)i2c_scanner->addresses[idx_to_print]);
|
||||
if(i < 3) {
|
||||
x_pos = 50 + (i * 26);
|
||||
const uint8_t x_start = 3;
|
||||
if(i < 4) {
|
||||
x_pos = x_start + (i * 26);
|
||||
y_pos = 15;
|
||||
} else if(i < 6) {
|
||||
x_pos = 50 + ((i - 3) * 26);
|
||||
} else if(i < 8) {
|
||||
x_pos = x_start + ((i - 4) * 26);
|
||||
y_pos = 25;
|
||||
} else if(i < 9) {
|
||||
x_pos = 50 + ((i - 6) * 26);
|
||||
y_pos = 35;
|
||||
} else if(i < 12) {
|
||||
x_pos = 50 + ((i - 9) * 26);
|
||||
y_pos = 45;
|
||||
} else if(i < 15) {
|
||||
x_pos = 50 + ((i - 12) * 26);
|
||||
y_pos = 55;
|
||||
x_pos = x_start + ((i - 8) * 26);
|
||||
y_pos = 35;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -48,8 +40,8 @@ void draw_scanner_view(Canvas* canvas, i2cScanner* i2c_scanner) {
|
||||
canvas_draw_rbox(canvas, 125, y_pos, 3, 10, 1);
|
||||
|
||||
// Button
|
||||
canvas_draw_rbox(canvas, 70, 48, 45, 13, 3);
|
||||
canvas_draw_rbox(canvas, 45, 48, 45, 13, 3);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_icon(canvas, 75, 50, &I_Ok_btn_9x9);
|
||||
canvas_draw_str_aligned(canvas, 85, 51, AlignLeft, AlignTop, "Scan");
|
||||
canvas_draw_icon(canvas, 50, 50, &I_Ok_btn_9x9);
|
||||
canvas_draw_str_aligned(canvas, 62, 51, AlignLeft, AlignTop, "Scan");
|
||||
}
|
@ -4,8 +4,6 @@
|
||||
#include <i2cTools_icons.h>
|
||||
#include "../i2cscanner.h"
|
||||
|
||||
#define SCAN_MENU_TEXT "Scan"
|
||||
#define SCAN_MENU_X 75
|
||||
#define SCAN_MENU_Y 6
|
||||
#define SCAN_TEXT "SCAN"
|
||||
|
||||
void draw_scanner_view(Canvas* canvas, i2cScanner* i2c_scanner);
|
@ -4,9 +4,6 @@ void draw_sender_view(Canvas* canvas, i2cSender* i2c_sender) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 0, 0, 128, 64, 3);
|
||||
canvas_draw_icon(canvas, 2, 13, &I_passport_happy2_46x49);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 3, 3, AlignLeft, AlignTop, SEND_MENU_TEXT);
|
||||
|
||||
if(!i2c_sender->scanner->scanned) {
|
||||
scan_i2c_bus(i2c_sender->scanner);
|
||||
@ -14,39 +11,60 @@ void draw_sender_view(Canvas* canvas, i2cSender* i2c_sender) {
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
if(i2c_sender->scanner->nb_found <= 0) {
|
||||
canvas_draw_str_aligned(canvas, 60, 5, AlignLeft, AlignTop, "No peripherals");
|
||||
canvas_draw_str_aligned(canvas, 60, 15, AlignLeft, AlignTop, "Found");
|
||||
canvas_draw_str_aligned(canvas, 20, 5, AlignLeft, AlignTop, "No peripherals found");
|
||||
return;
|
||||
}
|
||||
canvas_draw_rbox(canvas, 70, 48, 45, 13, 3);
|
||||
// Send Button
|
||||
canvas_draw_rbox(canvas, 45, 48, 45, 13, 3);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_icon(canvas, 75, 50, &I_Ok_btn_9x9);
|
||||
canvas_draw_str_aligned(canvas, 85, 51, AlignLeft, AlignTop, "Send");
|
||||
canvas_draw_icon(canvas, 50, 50, &I_Ok_btn_9x9);
|
||||
canvas_draw_str_aligned(canvas, 62, 51, AlignLeft, AlignTop, "Send");
|
||||
// Addr
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, 50, 5, AlignLeft, AlignTop, "Addr: ");
|
||||
canvas_draw_icon(canvas, 80, 5, &I_ButtonLeft_4x7);
|
||||
canvas_draw_icon(canvas, 115, 5, &I_ButtonRight_4x7);
|
||||
canvas_draw_str_aligned(canvas, 3, 5, AlignLeft, AlignTop, "Addr: ");
|
||||
canvas_draw_icon(canvas, 33, 5, &I_ButtonLeft_4x7);
|
||||
canvas_draw_icon(canvas, 68, 5, &I_ButtonRight_4x7);
|
||||
char addr_text[8];
|
||||
snprintf(
|
||||
addr_text,
|
||||
sizeof(addr_text),
|
||||
"0x%02x",
|
||||
(int)i2c_sender->scanner->addresses[i2c_sender->address_idx]);
|
||||
canvas_draw_str_aligned(canvas, 90, 5, AlignLeft, AlignTop, addr_text);
|
||||
canvas_draw_str_aligned(canvas, 50, 15, AlignLeft, AlignTop, "Value: ");
|
||||
|
||||
canvas_draw_icon(canvas, 80, 17, &I_ButtonUp_7x4);
|
||||
canvas_draw_icon(canvas, 115, 17, &I_ButtonDown_7x4);
|
||||
canvas_draw_str_aligned(canvas, 43, 5, AlignLeft, AlignTop, addr_text);
|
||||
// Value
|
||||
canvas_draw_str_aligned(canvas, 3, 15, AlignLeft, AlignTop, "Value: ");
|
||||
canvas_draw_icon(canvas, 33, 17, &I_ButtonUp_7x4);
|
||||
canvas_draw_icon(canvas, 68, 17, &I_ButtonDown_7x4);
|
||||
snprintf(addr_text, sizeof(addr_text), "0x%02x", (int)i2c_sender->value);
|
||||
canvas_draw_str_aligned(canvas, 90, 15, AlignLeft, AlignTop, addr_text);
|
||||
canvas_draw_str_aligned(canvas, 43, 15, AlignLeft, AlignTop, addr_text);
|
||||
if(i2c_sender->must_send) {
|
||||
i2c_send(i2c_sender);
|
||||
}
|
||||
canvas_draw_str_aligned(canvas, 50, 25, AlignLeft, AlignTop, "Result: ");
|
||||
// Result
|
||||
canvas_draw_str_aligned(canvas, 3, 25, AlignLeft, AlignTop, "Result: ");
|
||||
if(i2c_sender->sended) {
|
||||
uint8_t row = 1;
|
||||
uint8_t column = 1;
|
||||
const uint8_t x_min = 3;
|
||||
const uint8_t y_min = 25;
|
||||
uint8_t x_pos = 0;
|
||||
uint8_t y_pos = 0;
|
||||
for(uint8_t i = 0; i < sizeof(i2c_sender->recv); i++) {
|
||||
x_pos = x_min + (column - 1) * 35;
|
||||
if(row == 1) {
|
||||
x_pos += 40;
|
||||
}
|
||||
y_pos = y_min + (row - 1) * 10;
|
||||
snprintf(addr_text, sizeof(addr_text), "0x%02x", (int)i2c_sender->recv[i]);
|
||||
canvas_draw_str_aligned(canvas, 90, 25 + (i * 10), AlignLeft, AlignTop, addr_text);
|
||||
canvas_draw_str_aligned(canvas, x_pos, y_pos, AlignLeft, AlignTop, addr_text);
|
||||
column++;
|
||||
if((row > 1 && column > 3) || (row == 1 && column > 2)) {
|
||||
column = 1;
|
||||
row++;
|
||||
}
|
||||
if(row > 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@
|
||||
#include <i2cTools_icons.h>
|
||||
#include "../i2csender.h"
|
||||
|
||||
#define SEND_MENU_TEXT "Send"
|
||||
#define SEND_MENU_X 75
|
||||
#define SEND_MENU_Y 34
|
||||
#define SEND_TEXT "SEND"
|
||||
|
||||
void draw_sender_view(Canvas* canvas, i2cSender* i2c_sender);
|
@ -4,73 +4,89 @@ void draw_sniffer_view(Canvas* canvas, i2cSniffer* i2c_sniffer) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 0, 0, 128, 64, 3);
|
||||
canvas_draw_icon(canvas, 2, 13, &I_passport_happy2_46x49);
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 3, 3, AlignLeft, AlignTop, SNIFF_MENU_TEXT);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
|
||||
// Button
|
||||
canvas_draw_rbox(canvas, 70, 48, 45, 13, 3);
|
||||
canvas_draw_rbox(canvas, 40, 48, 45, 13, 3);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_icon(canvas, 75, 50, &I_Ok_btn_9x9);
|
||||
canvas_draw_icon(canvas, 45, 50, &I_Ok_btn_9x9);
|
||||
if(!i2c_sniffer->started) {
|
||||
canvas_draw_str_aligned(canvas, 85, 51, AlignLeft, AlignTop, "Start");
|
||||
canvas_draw_str_aligned(canvas, 57, 51, AlignLeft, AlignTop, "Start");
|
||||
} else {
|
||||
canvas_draw_str_aligned(canvas, 85, 51, AlignLeft, AlignTop, "Stop");
|
||||
canvas_draw_str_aligned(canvas, 57, 51, AlignLeft, AlignTop, "Stop");
|
||||
}
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
if(i2c_sniffer->first) {
|
||||
canvas_draw_str_aligned(canvas, 50, 3, AlignLeft, AlignTop, "Nothing Recorded");
|
||||
canvas_draw_str_aligned(canvas, 30, 3, AlignLeft, AlignTop, "Nothing Recorded");
|
||||
return;
|
||||
}
|
||||
char text_buffer[8];
|
||||
char text_buffer[10];
|
||||
// nbFrame text
|
||||
canvas_draw_str_aligned(canvas, 50, 3, AlignLeft, AlignTop, "Frame: ");
|
||||
snprintf(text_buffer, sizeof(text_buffer), "%d", (int)i2c_sniffer->menu_index + 1);
|
||||
canvas_draw_str_aligned(canvas, 85, 3, AlignLeft, AlignTop, text_buffer);
|
||||
canvas_draw_str_aligned(canvas, 100, 3, AlignLeft, AlignTop, "/");
|
||||
snprintf(text_buffer, sizeof(text_buffer), "%d", (int)i2c_sniffer->frame_index + 1);
|
||||
canvas_draw_str_aligned(canvas, 110, 3, AlignLeft, AlignTop, text_buffer);
|
||||
canvas_draw_str_aligned(canvas, 3, 3, AlignLeft, AlignTop, "Frame: ");
|
||||
snprintf(
|
||||
text_buffer,
|
||||
sizeof(text_buffer),
|
||||
"%d/%d",
|
||||
(int)i2c_sniffer->menu_index + 1,
|
||||
(int)i2c_sniffer->frame_index + 1);
|
||||
canvas_draw_str_aligned(canvas, 38, 3, AlignLeft, AlignTop, text_buffer);
|
||||
// Address text
|
||||
snprintf(
|
||||
text_buffer,
|
||||
sizeof(text_buffer),
|
||||
"0x%02x",
|
||||
(int)(i2c_sniffer->frames[i2c_sniffer->menu_index].data[0] >> 1));
|
||||
canvas_draw_str_aligned(canvas, 50, 13, AlignLeft, AlignTop, "Addr: ");
|
||||
canvas_draw_str_aligned(canvas, 75, 13, AlignLeft, AlignTop, text_buffer);
|
||||
canvas_draw_str_aligned(canvas, 3, 13, AlignLeft, AlignTop, "Addr: ");
|
||||
canvas_draw_str_aligned(canvas, 30, 13, AlignLeft, AlignTop, text_buffer);
|
||||
// R/W
|
||||
if((int)(i2c_sniffer->frames[i2c_sniffer->menu_index].data[0]) % 2 == 0) {
|
||||
canvas_draw_str_aligned(canvas, 105, 13, AlignLeft, AlignTop, "W");
|
||||
canvas_draw_str_aligned(canvas, 58, 13, AlignLeft, AlignTop, "Write");
|
||||
} else {
|
||||
canvas_draw_str_aligned(canvas, 105, 13, AlignLeft, AlignTop, "R");
|
||||
canvas_draw_str_aligned(canvas, 58, 13, AlignLeft, AlignTop, "Read");
|
||||
}
|
||||
// ACK
|
||||
if(i2c_sniffer->frames[i2c_sniffer->menu_index].ack[0]) {
|
||||
canvas_draw_str_aligned(canvas, 90, 13, AlignLeft, AlignTop, "ACK");
|
||||
} else {
|
||||
canvas_draw_str_aligned(canvas, 90, 13, AlignLeft, AlignTop, "NACK");
|
||||
}
|
||||
// Frames content
|
||||
const uint8_t x_min = 50;
|
||||
const uint8_t x_min = 3;
|
||||
const uint8_t y_min = 23;
|
||||
uint8_t x_pos = 0;
|
||||
uint8_t y_pos = 0;
|
||||
uint8_t row = 1;
|
||||
uint8_t column = 1;
|
||||
for(uint8_t i = 1; i < i2c_sniffer->frames[i2c_sniffer->menu_index].data_index; i++) {
|
||||
uint8_t frame_size = i2c_sniffer->frames[i2c_sniffer->menu_index].data_index;
|
||||
uint8_t offset = i2c_sniffer->row_index;
|
||||
if(i2c_sniffer->row_index > 0) {
|
||||
offset += 1;
|
||||
}
|
||||
canvas_draw_str_aligned(canvas, x_min, y_min, AlignLeft, AlignTop, "Data:");
|
||||
for(uint8_t i = 1 + offset; i < frame_size; i++) {
|
||||
snprintf(
|
||||
text_buffer,
|
||||
sizeof(text_buffer),
|
||||
"0x%02x",
|
||||
(int)i2c_sniffer->frames[i2c_sniffer->menu_index].data[i]);
|
||||
x_pos = x_min + (column - 1) * 35;
|
||||
y_pos = y_min + (row - 1) * 10;
|
||||
column++;
|
||||
if(column > 2) {
|
||||
column = 1;
|
||||
row++;
|
||||
if(row == 1) {
|
||||
x_pos += 30;
|
||||
}
|
||||
y_pos = y_min + (row - 1) * 10;
|
||||
canvas_draw_str_aligned(canvas, x_pos, y_pos, AlignLeft, AlignTop, text_buffer);
|
||||
if(i2c_sniffer->frames[i2c_sniffer->menu_index].ack[i]) {
|
||||
canvas_draw_str_aligned(canvas, x_pos + 24, y_pos, AlignLeft, AlignTop, "A");
|
||||
} else {
|
||||
canvas_draw_str_aligned(canvas, x_pos + 24, y_pos, AlignLeft, AlignTop, "N");
|
||||
}
|
||||
column++;
|
||||
if((row > 1 && column > 3) || (row == 1 && column > 2)) {
|
||||
column = 1;
|
||||
row++;
|
||||
}
|
||||
if(row > 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@
|
||||
#include <i2cTools_icons.h>
|
||||
#include "../i2csniffer.h"
|
||||
|
||||
#define SNIFF_MENU_TEXT "Sniff"
|
||||
#define SNIFF_MENU_X 75
|
||||
#define SNIFF_MENU_Y 20
|
||||
#define SNIFF_TEXT "SNIFF"
|
||||
|
||||
void draw_sniffer_view(Canvas* canvas, i2cSniffer* i2c_sniffer);
|
@ -60,7 +60,15 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
|
||||
{"Sniff",
|
||||
{"beacon", "deauth", "esp", "pmkid", "probe", "pwn", "raw", "bt", "skim"},
|
||||
9,
|
||||
{"sniffbeacon", "sniffdeauth", "sniffesp", "sniffpmkid", "sniffprobe", "sniffpwn", "sniffraw", "sniffbt", "sniffskim"},
|
||||
{"sniffbeacon",
|
||||
"sniffdeauth",
|
||||
"sniffesp",
|
||||
"sniffpmkid",
|
||||
"sniffprobe",
|
||||
"sniffpwn",
|
||||
"sniffraw",
|
||||
"sniffbt",
|
||||
"sniffskim"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
|
Loading…
Reference in New Issue
Block a user