mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2025-02-17 05:48:33 +00:00
code formatted
This commit is contained in:
parent
6cc2d47ed4
commit
767f7ff92e
20 changed files with 843 additions and 659 deletions
|
@ -58,10 +58,9 @@ static DialogMessageButton unleashed_info_screen(DialogsApp* dialogs, DialogMess
|
|||
DialogMessageButton result;
|
||||
|
||||
const char* screen_header = "Unleashed Firmware\n";
|
||||
|
||||
|
||||
const char* screen_text = "Play with caution.\n"
|
||||
"Not for illegal use!";
|
||||
|
||||
"Not for illegal use!";
|
||||
|
||||
dialog_message_set_header(message, screen_header, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, screen_text, 0, 26, AlignLeft, AlignTop);
|
||||
|
|
|
@ -48,13 +48,13 @@ extern int32_t file_browser_app(void* p);
|
|||
// Plugins
|
||||
extern int32_t music_player_app(void* p);
|
||||
extern int32_t wav_player_app(void* p);
|
||||
extern int32_t clock_app(void *p);
|
||||
extern int32_t unirfremix_app(void *p);
|
||||
extern int32_t clock_app(void* p);
|
||||
extern int32_t unirfremix_app(void* p);
|
||||
extern int32_t spectrum_analyzer_app(void* p);
|
||||
|
||||
// Games
|
||||
extern int32_t snake_game_app(void* p);
|
||||
extern int32_t tetris_game_app(void *p);
|
||||
extern int32_t tetris_game_app(void* p);
|
||||
extern int32_t tictactoe_game_app(void* p);
|
||||
extern int32_t arkanoid_game_app(void* p);
|
||||
|
||||
|
@ -231,7 +231,7 @@ const FlipperApplication FLIPPER_APPS[] = {
|
|||
#endif
|
||||
|
||||
#ifdef APP_UNIRFREMIX
|
||||
{.app = unirfremix_app,
|
||||
{.app = unirfremix_app,
|
||||
.name = "UniRF Remix",
|
||||
.stack_size = 2048,
|
||||
.icon = &A_UniRFRemix_14,
|
||||
|
@ -239,11 +239,11 @@ const FlipperApplication FLIPPER_APPS[] = {
|
|||
#endif
|
||||
|
||||
#ifdef APP_SPECTRUM_ANALYZER
|
||||
{.app = spectrum_analyzer_app,
|
||||
.name = "Spectrum Analyzer",
|
||||
.stack_size = 1024,
|
||||
.icon = &A_SpectrumAnalyzer_14,
|
||||
.flags = FlipperApplicationFlagDefault},
|
||||
{.app = spectrum_analyzer_app,
|
||||
.name = "Spectrum Analyzer",
|
||||
.stack_size = 1024,
|
||||
.icon = &A_SpectrumAnalyzer_14,
|
||||
.flags = FlipperApplicationFlagDefault},
|
||||
#endif
|
||||
|
||||
#ifdef APP_LF_RFID
|
||||
|
@ -406,7 +406,6 @@ const FlipperApplication FLIPPER_GAMES[] = {
|
|||
.flags = FlipperApplicationFlagDefault},
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef APP_ARKANOID_GAME
|
||||
{.app = arkanoid_game_app,
|
||||
.name = "Arkanoid",
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#define TAG "Clock"
|
||||
|
||||
bool timerStarted=false;
|
||||
int timerSecs=0;
|
||||
int songSelect=2;
|
||||
bool timerStarted = false;
|
||||
int timerSecs = 0;
|
||||
int songSelect = 2;
|
||||
|
||||
typedef enum {
|
||||
EventTypeTick,
|
||||
|
@ -27,7 +27,7 @@ typedef struct {
|
|||
} ClockState;
|
||||
|
||||
static void clock_input_callback(InputEvent* input_event, osMessageQueueId_t event_queue) {
|
||||
furi_assert(event_queue);
|
||||
furi_assert(event_queue);
|
||||
PluginEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
}
|
||||
|
@ -37,11 +37,21 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
|
|||
canvas_set_color(canvas, ColorBlack);
|
||||
ClockState* state = (ClockState*)acquire_mutex((ValueMutex*)ctx, 25);
|
||||
char strings[3][20];
|
||||
int curMin = (timerSecs/60);
|
||||
int curSec = timerSecs-(curMin *60);
|
||||
sprintf(strings[0], "%.4d-%.2d-%.2d", state->datetime.year, state->datetime.month, state->datetime.day);
|
||||
sprintf(strings[1], "%.2d:%.2d:%.2d", state->datetime.hour, state->datetime.minute, state->datetime.second);
|
||||
sprintf(strings[2], "%.2d:%.2d", curMin , curSec);
|
||||
int curMin = (timerSecs / 60);
|
||||
int curSec = timerSecs - (curMin * 60);
|
||||
sprintf(
|
||||
strings[0],
|
||||
"%.4d-%.2d-%.2d",
|
||||
state->datetime.year,
|
||||
state->datetime.month,
|
||||
state->datetime.day);
|
||||
sprintf(
|
||||
strings[1],
|
||||
"%.2d:%.2d:%.2d",
|
||||
state->datetime.hour,
|
||||
state->datetime.minute,
|
||||
state->datetime.second);
|
||||
sprintf(strings[2], "%.2d:%.2d", curMin, curSec);
|
||||
release_mutex((ValueMutex*)ctx, state);
|
||||
canvas_set_font(canvas, FontBigNumbers);
|
||||
canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignCenter, strings[1]);
|
||||
|
@ -58,13 +68,13 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
|
|||
} else {
|
||||
elements_button_center(canvas, "Start");
|
||||
}
|
||||
if(songSelect==0) {
|
||||
if(songSelect == 0) {
|
||||
elements_button_right(canvas, "S:OFF");
|
||||
} else if(songSelect==1) {
|
||||
} else if(songSelect == 1) {
|
||||
elements_button_right(canvas, "S:PoRa");
|
||||
} else if(songSelect==2) {
|
||||
} else if(songSelect == 2) {
|
||||
elements_button_right(canvas, "S:Mario");
|
||||
} else if(songSelect==3) {
|
||||
} else if(songSelect == 3) {
|
||||
elements_button_right(canvas, "S:ByMin");
|
||||
}
|
||||
}
|
||||
|
@ -74,65 +84,177 @@ static void clock_state_init(ClockState* const state) {
|
|||
}
|
||||
|
||||
const NotificationSequence clock_alert_silent = {
|
||||
&message_force_vibro_setting_on, &message_vibro_on, &message_red_255, &message_green_255, &message_blue_255, &message_display_backlight_on,
|
||||
&message_vibro_off, &message_display_backlight_off, &message_delay_50, &message_display_backlight_on, NULL,
|
||||
&message_force_vibro_setting_on,
|
||||
&message_vibro_on,
|
||||
&message_red_255,
|
||||
&message_green_255,
|
||||
&message_blue_255,
|
||||
&message_display_backlight_on,
|
||||
&message_vibro_off,
|
||||
&message_display_backlight_off,
|
||||
&message_delay_50,
|
||||
&message_display_backlight_on,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_pr1 = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_force_vibro_setting_on, &message_vibro_on, &message_red_255, &message_green_255, &message_blue_255, &message_display_backlight_on,
|
||||
&message_note_g5, &message_delay_100, &message_delay_100, &message_delay_50, &message_sound_off,
|
||||
&message_vibro_off, &message_display_backlight_off, &message_delay_50, &message_display_backlight_on,
|
||||
&message_note_g5, &message_delay_100, &message_delay_100, &message_delay_50, &message_sound_off, NULL,
|
||||
&message_force_vibro_setting_on,
|
||||
&message_vibro_on,
|
||||
&message_red_255,
|
||||
&message_green_255,
|
||||
&message_blue_255,
|
||||
&message_display_backlight_on,
|
||||
&message_note_g5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
&message_display_backlight_off,
|
||||
&message_delay_50,
|
||||
&message_display_backlight_on,
|
||||
&message_note_g5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_pr2 = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_force_vibro_setting_on, &message_vibro_on,
|
||||
&message_note_fs5, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_display_backlight_off, &message_vibro_off, &message_delay_50,
|
||||
&message_note_g5, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_display_backlight_on, &message_delay_50,
|
||||
&message_note_a5, &message_delay_100, &message_delay_100, &message_sound_off, NULL,
|
||||
&message_force_vibro_setting_on,
|
||||
&message_vibro_on,
|
||||
&message_note_fs5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
&message_display_backlight_off,
|
||||
&message_vibro_off,
|
||||
&message_delay_50,
|
||||
&message_note_g5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
&message_display_backlight_on,
|
||||
&message_delay_50,
|
||||
&message_note_a5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_pr3 = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_display_backlight_off,
|
||||
&message_note_g5, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_delay_50, &message_red_255, &message_green_255, &message_blue_255, &message_display_backlight_on, &message_delay_100, NULL,
|
||||
&message_note_g5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
&message_delay_50,
|
||||
&message_red_255,
|
||||
&message_green_255,
|
||||
&message_blue_255,
|
||||
&message_display_backlight_on,
|
||||
&message_delay_100,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_mario1 = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_force_vibro_setting_on, &message_vibro_on, &message_red_255, &message_green_255, &message_blue_255, &message_display_backlight_on,
|
||||
&message_note_e5, &message_delay_100, &message_delay_100, &message_delay_50, &message_sound_off,
|
||||
&message_note_e5, &message_delay_100, &message_delay_100, &message_delay_50, &message_sound_off,
|
||||
&message_vibro_off, &message_display_backlight_off, &message_delay_100, &message_display_backlight_on, &message_delay_100,
|
||||
&message_note_e5, &message_delay_100, &message_delay_100, &message_delay_50, &message_sound_off, NULL,
|
||||
&message_force_vibro_setting_on,
|
||||
&message_vibro_on,
|
||||
&message_red_255,
|
||||
&message_green_255,
|
||||
&message_blue_255,
|
||||
&message_display_backlight_on,
|
||||
&message_note_e5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_note_e5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
&message_display_backlight_off,
|
||||
&message_delay_100,
|
||||
&message_display_backlight_on,
|
||||
&message_delay_100,
|
||||
&message_note_e5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_mario2 = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_force_vibro_setting_on, &message_vibro_on, &message_display_backlight_off, &message_delay_100, &message_display_backlight_on, &message_delay_100,
|
||||
&message_note_c5, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_display_backlight_off, &message_vibro_off, &message_delay_50,
|
||||
&message_note_e5, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_display_backlight_on, NULL,
|
||||
&message_force_vibro_setting_on,
|
||||
&message_vibro_on,
|
||||
&message_display_backlight_off,
|
||||
&message_delay_100,
|
||||
&message_display_backlight_on,
|
||||
&message_delay_100,
|
||||
&message_note_c5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
&message_display_backlight_off,
|
||||
&message_vibro_off,
|
||||
&message_delay_50,
|
||||
&message_note_e5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
&message_display_backlight_on,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_mario3 = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_display_backlight_off,
|
||||
&message_note_g5, &message_delay_100, &message_delay_100, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_delay_50, &message_red_255, &message_green_255, &message_blue_255, &message_display_backlight_on, &message_delay_100,
|
||||
&message_note_g4, &message_delay_100, &message_delay_100, &message_delay_100, &message_delay_100, &message_sound_off,
|
||||
&message_note_g5,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
&message_delay_50,
|
||||
&message_red_255,
|
||||
&message_green_255,
|
||||
&message_blue_255,
|
||||
&message_display_backlight_on,
|
||||
&message_delay_100,
|
||||
&message_note_g4,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_delay_100,
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_perMin = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_note_g5, &message_delay_100, &message_delay_50, &message_sound_off,
|
||||
&message_note_g5,
|
||||
&message_delay_100,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_delay_10,
|
||||
&message_note_g4, &message_delay_50, &message_delay_10, &message_delay_10, &message_sound_off,
|
||||
&message_note_g4,
|
||||
&message_delay_50,
|
||||
&message_delay_10,
|
||||
&message_delay_10,
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
const NotificationSequence clock_alert_startStop = {
|
||||
&message_force_speaker_volume_setting_1f,
|
||||
&message_note_d6, &message_delay_100, &message_delay_10, &message_delay_10, &message_sound_off, NULL,
|
||||
&message_note_d6,
|
||||
&message_delay_100,
|
||||
&message_delay_10,
|
||||
&message_delay_10,
|
||||
&message_sound_off,
|
||||
NULL,
|
||||
};
|
||||
|
||||
// Runs every 1000ms by default
|
||||
|
@ -141,46 +263,46 @@ static void clock_tick(void* ctx) {
|
|||
osMessageQueueId_t event_queue = ctx;
|
||||
PluginEvent event = {.type = EventTypeTick};
|
||||
if(timerStarted) {
|
||||
timerSecs=timerSecs+1;
|
||||
if(timerSecs%60==0 && songSelect!=0) {
|
||||
timerSecs = timerSecs + 1;
|
||||
if(timerSecs % 60 == 0 && songSelect != 0) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_perMin);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
if(songSelect==1 ) {
|
||||
if(timerSecs==80) {
|
||||
if(songSelect == 1) {
|
||||
if(timerSecs == 80) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_pr1);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
if(timerSecs==81) {
|
||||
if(timerSecs == 81) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_pr2);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
if(timerSecs==82) {
|
||||
if(timerSecs == 82) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_pr3);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
} else if(songSelect==2 ) {
|
||||
if(timerSecs==80) {
|
||||
} else if(songSelect == 2) {
|
||||
if(timerSecs == 80) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_mario1);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
if(timerSecs==81) {
|
||||
if(timerSecs == 81) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_mario2);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
if(timerSecs==82) {
|
||||
if(timerSecs == 82) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_mario3);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
} else {
|
||||
if(timerSecs==80) {
|
||||
if(timerSecs == 80) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_silent);
|
||||
furi_record_close("notification");
|
||||
|
@ -193,14 +315,14 @@ static void clock_tick(void* ctx) {
|
|||
|
||||
int32_t clock_app(void* p) {
|
||||
UNUSED(p);
|
||||
timerStarted=false;
|
||||
timerSecs=0;
|
||||
songSelect=2;
|
||||
timerStarted = false;
|
||||
timerSecs = 0;
|
||||
songSelect = 2;
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(PluginEvent), NULL);
|
||||
ClockState* plugin_state = malloc(sizeof(ClockState));
|
||||
clock_state_init(plugin_state);
|
||||
ValueMutex state_mutex;
|
||||
if (!init_mutex(&state_mutex, plugin_state, sizeof(ClockState))) {
|
||||
if(!init_mutex(&state_mutex, plugin_state, sizeof(ClockState))) {
|
||||
FURI_LOG_E(TAG, "cannot create mutex\r\n");
|
||||
free(plugin_state);
|
||||
return 255;
|
||||
|
@ -216,44 +338,44 @@ int32_t clock_app(void* p) {
|
|||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
// Main loop
|
||||
PluginEvent event;
|
||||
for (bool processing = true; processing;) {
|
||||
for(bool processing = true; processing;) {
|
||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 100);
|
||||
ClockState* plugin_state = (ClockState*)acquire_mutex_block(&state_mutex);
|
||||
if (event_status == osOK) {
|
||||
if(event_status == osOK) {
|
||||
// press events
|
||||
if (event.type == EventTypeKey) {
|
||||
if (event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
||||
switch(event.input.key) {
|
||||
case InputKeyUp:
|
||||
if(timerStarted) timerSecs=timerSecs+5;
|
||||
if(timerStarted) timerSecs = timerSecs + 5;
|
||||
break;
|
||||
case InputKeyDown:
|
||||
if(timerStarted) timerSecs=timerSecs-5;
|
||||
if(timerStarted) timerSecs = timerSecs - 5;
|
||||
break;
|
||||
case InputKeyRight:
|
||||
if(songSelect==0) {
|
||||
songSelect=1;
|
||||
} else if(songSelect==1) {
|
||||
songSelect=2;
|
||||
} else if(songSelect==2) {
|
||||
songSelect=3;
|
||||
if(songSelect == 0) {
|
||||
songSelect = 1;
|
||||
} else if(songSelect == 1) {
|
||||
songSelect = 2;
|
||||
} else if(songSelect == 2) {
|
||||
songSelect = 3;
|
||||
} else {
|
||||
songSelect=0;
|
||||
songSelect = 0;
|
||||
}
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
break;
|
||||
case InputKeyOk:
|
||||
if(songSelect==1 || songSelect==2 || songSelect==3) {
|
||||
case InputKeyOk:
|
||||
if(songSelect == 1 || songSelect == 2 || songSelect == 3) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &clock_alert_startStop);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
if(timerStarted) {
|
||||
timerStarted=false;
|
||||
timerSecs=0;
|
||||
timerStarted = false;
|
||||
timerSecs = 0;
|
||||
} else {
|
||||
timerStarted=true;
|
||||
timerStarted = true;
|
||||
}
|
||||
break;
|
||||
case InputKeyBack:
|
||||
|
|
|
@ -124,11 +124,7 @@ static void spectrum_analyzer_render_callback(Canvas* const canvas, void* ctx) {
|
|||
|
||||
// Current mode label
|
||||
char tmp_str[21];
|
||||
snprintf(
|
||||
tmp_str,
|
||||
21,
|
||||
"Mode: %s",
|
||||
temp_mode_str);
|
||||
snprintf(tmp_str, 21, "Mode: %s", temp_mode_str);
|
||||
canvas_draw_str_aligned(canvas, 127, 4, AlignRight, AlignTop, tmp_str);
|
||||
}
|
||||
// Draw cross and label
|
||||
|
@ -167,7 +163,7 @@ static void spectrum_analyzer_render_callback(Canvas* const canvas, void* ctx) {
|
|||
"Peak: %3.2f Mhz %3.1f dbm",
|
||||
((double)(model->channel0_frequency + (model->max_rssi_channel * model->spacing)) /
|
||||
1000000),
|
||||
(double) model->max_rssi);
|
||||
(double)model->max_rssi);
|
||||
canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, temp_str);
|
||||
}
|
||||
|
||||
|
@ -479,13 +475,13 @@ int32_t spectrum_analyzer_app(void* p) {
|
|||
model->width = WIDE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
model->mode_change = true;
|
||||
view_port_update(spectrum_analyzer->view_port);
|
||||
|
||||
|
||||
furi_hal_delay_ms(1000);
|
||||
|
||||
|
||||
model->mode_change = false;
|
||||
spectrum_analyzer_calculate_frequencies(model);
|
||||
spectrum_analyzer_worker_set_frequencies(
|
||||
|
|
|
@ -87,11 +87,8 @@ static int32_t spectrum_analyzer_worker_thread(void* context) {
|
|||
instance->max_rssi_dec = 0;
|
||||
|
||||
// Visit each channel non-consecutively
|
||||
for(
|
||||
uint8_t ch_offset = 0, chunk = 0;
|
||||
ch_offset < CHUNK_SIZE;
|
||||
++chunk >= NUM_CHUNKS && ++ch_offset && (chunk = 0)
|
||||
) {
|
||||
for(uint8_t ch_offset = 0, chunk = 0; ch_offset < CHUNK_SIZE;
|
||||
++chunk >= NUM_CHUNKS && ++ch_offset && (chunk = 0)) {
|
||||
uint8_t ch = chunk * CHUNK_SIZE + ch_offset;
|
||||
furi_hal_subghz_set_frequency(instance->channel0_frequency + (ch * instance->spacing));
|
||||
|
||||
|
|
|
@ -66,6 +66,6 @@ typedef enum {
|
|||
SubGhzCustomEventViewTransmitterSendStart,
|
||||
SubGhzCustomEventViewTransmitterSendStop,
|
||||
SubGhzCustomEventViewTransmitterError,
|
||||
|
||||
|
||||
SubGhzCustomEventByteInputDone,
|
||||
} SubGhzCustomEvent;
|
||||
|
|
|
@ -247,10 +247,15 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
|||
FuriHalRtcDateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
char strings[1][25];
|
||||
sprintf(strings[0], "%s%.4d%.2d%.2d%.2d%.2d", "R"
|
||||
, datetime.year, datetime.month, datetime.day
|
||||
, datetime.hour, datetime.minute
|
||||
);
|
||||
sprintf(
|
||||
strings[0],
|
||||
"%s%.4d%.2d%.2d%.2d%.2d",
|
||||
"R",
|
||||
datetime.year,
|
||||
datetime.month,
|
||||
datetime.day,
|
||||
datetime.hour,
|
||||
datetime.minute);
|
||||
|
||||
string_printf(
|
||||
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, strings[0], SUBGHZ_APP_EXTENSION);
|
||||
|
@ -277,10 +282,15 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
|||
FuriHalRtcDateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
char strings[1][25];
|
||||
sprintf(strings[0], "%s%.4d%.2d%.2d%.2d%.2d", "R"
|
||||
, datetime.year, datetime.month, datetime.day
|
||||
, datetime.hour, datetime.minute
|
||||
);
|
||||
sprintf(
|
||||
strings[0],
|
||||
"%s%.4d%.2d%.2d%.2d%.2d",
|
||||
"R",
|
||||
datetime.year,
|
||||
datetime.month,
|
||||
datetime.day,
|
||||
datetime.hour,
|
||||
datetime.minute);
|
||||
if(subghz_protocol_raw_save_to_file_init(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
|
||||
strings[0],
|
||||
|
|
|
@ -32,15 +32,18 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
|||
bool generated_protocol = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
|
||||
uint32_t fix_part = subghz->txrx->secure_data->fix[0] << 24 | subghz->txrx->secure_data->fix[1] << 16 |
|
||||
subghz->txrx->secure_data->fix[2] << 8 | subghz->txrx->secure_data->fix[3];
|
||||
uint32_t fix_part =
|
||||
subghz->txrx->secure_data->fix[0] << 24 | subghz->txrx->secure_data->fix[1] << 16 |
|
||||
subghz->txrx->secure_data->fix[2] << 8 | subghz->txrx->secure_data->fix[3];
|
||||
|
||||
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 | subghz->txrx->secure_data->cnt[1];
|
||||
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 |
|
||||
subghz->txrx->secure_data->cnt[1];
|
||||
|
||||
uint32_t seed = subghz->txrx->secure_data->seed[0] << 24 |
|
||||
subghz->txrx->secure_data->seed[1] << 16 |
|
||||
subghz->txrx->secure_data->seed[2] << 8 |
|
||||
subghz->txrx->secure_data->seed[3];
|
||||
|
||||
uint32_t seed = subghz->txrx->secure_data->seed[0] << 24 | subghz->txrx->secure_data->seed[1] << 16 |
|
||||
subghz->txrx->secure_data->seed[2] << 8 | subghz->txrx->secure_data->seed[3];
|
||||
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "Faac SLH");
|
||||
if(subghz->txrx->transmitter) {
|
||||
|
@ -54,21 +57,22 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
|||
"FAAC_SLH",
|
||||
868350000,
|
||||
FuriHalSubGhzPresetOok650Async);
|
||||
|
||||
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
flipper_format_write_hex(
|
||||
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
flipper_format_write_hex(subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
|
||||
|
||||
if(!generated_protocol) {
|
||||
string_set_str(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
|
@ -76,7 +80,7 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
|||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
|
||||
if(generated_protocol) {
|
||||
subghz_file_name_clear(subghz);
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzAddManually);
|
||||
|
@ -86,12 +90,12 @@ bool subghz_scene_set_seed_on_event(void* context, SceneManagerEvent event) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return consumed;;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
|
||||
// Clear view
|
||||
byte_input_set_result_callback(subghz->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(subghz->byte_input, "");
|
||||
|
|
|
@ -32,15 +32,18 @@ bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event)
|
|||
bool generated_protocol = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventByteInputDone) {
|
||||
|
||||
uint32_t fix_part = subghz->txrx->secure_data->fix[0] << 24 | subghz->txrx->secure_data->fix[1] << 16 |
|
||||
subghz->txrx->secure_data->fix[2] << 8 | subghz->txrx->secure_data->fix[3];
|
||||
uint32_t fix_part =
|
||||
subghz->txrx->secure_data->fix[0] << 24 | subghz->txrx->secure_data->fix[1] << 16 |
|
||||
subghz->txrx->secure_data->fix[2] << 8 | subghz->txrx->secure_data->fix[3];
|
||||
|
||||
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 | subghz->txrx->secure_data->cnt[1];
|
||||
uint16_t cnt = subghz->txrx->secure_data->cnt[0] << 8 |
|
||||
subghz->txrx->secure_data->cnt[1];
|
||||
|
||||
uint32_t seed = subghz->txrx->secure_data->seed[0] << 24 |
|
||||
subghz->txrx->secure_data->seed[1] << 16 |
|
||||
subghz->txrx->secure_data->seed[2] << 8 |
|
||||
subghz->txrx->secure_data->seed[3];
|
||||
|
||||
uint32_t seed = subghz->txrx->secure_data->seed[0] << 24 | subghz->txrx->secure_data->seed[1] << 16 |
|
||||
subghz->txrx->secure_data->seed[2] << 8 | subghz->txrx->secure_data->seed[3];
|
||||
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "KeeLoq");
|
||||
if(subghz->txrx->transmitter) {
|
||||
|
@ -54,21 +57,22 @@ bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event)
|
|||
"BFT",
|
||||
433920000,
|
||||
FuriHalSubGhzPresetOok650Async);
|
||||
|
||||
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (seed >> i * 8) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
flipper_format_write_hex(
|
||||
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
flipper_format_write_hex(subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
|
||||
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
|
||||
|
||||
if(!generated_protocol) {
|
||||
string_set_str(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
|
@ -76,7 +80,7 @@ bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event)
|
|||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
|
||||
if(generated_protocol) {
|
||||
subghz_file_name_clear(subghz);
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzAddManually);
|
||||
|
@ -86,12 +90,12 @@ bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return consumed;;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_scene_set_seed_bft_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
|
||||
// Clear view
|
||||
byte_input_set_result_callback(subghz->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(subghz->byte_input, "");
|
||||
|
|
|
@ -31,7 +31,7 @@ static const uint32_t subghz_frequency_list[] = {
|
|||
390000000,
|
||||
418000000,
|
||||
433075000, /* LPD433 first */
|
||||
433220000, /* 2016-2020 Honda */
|
||||
433220000, /* 2016-2020 Honda */
|
||||
433420000,
|
||||
433889000, /* ROGUE? */
|
||||
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
|
||||
|
@ -105,7 +105,7 @@ static void subghz_setting_load_default_region(
|
|||
// Region check removed
|
||||
void subghz_setting_load_default(SubGhzSetting* instance) {
|
||||
subghz_setting_load_default_region(
|
||||
instance, subghz_frequency_list, subghz_hopper_frequency_list);
|
||||
instance, subghz_frequency_list, subghz_hopper_frequency_list);
|
||||
}
|
||||
|
||||
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
||||
|
|
|
@ -22,35 +22,24 @@ typedef struct Point {
|
|||
|
||||
// Rotation logic taken from
|
||||
// https://www.youtube.com/watch?v=yIpk5TJ_uaI
|
||||
typedef enum {
|
||||
OffsetTypeCommon,
|
||||
OffsetTypeI,
|
||||
OffsetTypeO
|
||||
} OffsetType;
|
||||
typedef enum { OffsetTypeCommon, OffsetTypeI, OffsetTypeO } OffsetType;
|
||||
|
||||
// Since we only support rotating clockwise, these are actual translation values,
|
||||
// not values to be subtracted to get translation values
|
||||
|
||||
static const Point rotOffsetTranslation[3][4][5] = {
|
||||
{
|
||||
{ {0,0}, {-1,0}, {-1,-1}, {0,2}, {-1,2} },
|
||||
{ {0,0}, {1,0}, {1,1}, {0,-2}, {1,-2} },
|
||||
{ {0,0}, {1,0}, {1,-1}, {0,2}, {1,2} },
|
||||
{ {0,0}, {-1,0}, {-1,1}, {0,-2}, {-1,-2} }
|
||||
},
|
||||
{
|
||||
{ {1,0}, {-1,0}, {2,0}, {-1,1}, {2,-2} },
|
||||
{ {0,1}, {-1,1}, {2,1}, {-1,-1}, {2,2} },
|
||||
{ {-1,0}, {1,0}, {-2,0}, {1,-1}, {-2,2} },
|
||||
{ {0,-1}, {1,-1}, {-2,-1}, {1,1}, {-2,-2} }
|
||||
},
|
||||
{
|
||||
{ {0,-1}, {0,0}, {0,0}, {0,0}, {0,0} },
|
||||
{ {1,0}, {0,0}, {0,0}, {0,0}, {0,0} },
|
||||
{ {0,1}, {0,0}, {0,0}, {0,0}, {0,0} },
|
||||
{ {-1,0}, {0,0}, {0,0}, {0,0}, {0,0} }
|
||||
}
|
||||
};
|
||||
{{{0, 0}, {-1, 0}, {-1, -1}, {0, 2}, {-1, 2}},
|
||||
{{0, 0}, {1, 0}, {1, 1}, {0, -2}, {1, -2}},
|
||||
{{0, 0}, {1, 0}, {1, -1}, {0, 2}, {1, 2}},
|
||||
{{0, 0}, {-1, 0}, {-1, 1}, {0, -2}, {-1, -2}}},
|
||||
{{{1, 0}, {-1, 0}, {2, 0}, {-1, 1}, {2, -2}},
|
||||
{{0, 1}, {-1, 1}, {2, 1}, {-1, -1}, {2, 2}},
|
||||
{{-1, 0}, {1, 0}, {-2, 0}, {1, -1}, {-2, 2}},
|
||||
{{0, -1}, {1, -1}, {-2, -1}, {1, 1}, {-2, -2}}},
|
||||
{{{0, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{1, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
{{-1, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}}};
|
||||
|
||||
typedef struct {
|
||||
Point p[4];
|
||||
|
@ -60,19 +49,16 @@ typedef struct {
|
|||
|
||||
// Shapes @ spawn locations, rotation point first
|
||||
static Piece shapes[] = {
|
||||
{ .p = {{5, 1}, {4, 0}, {5, 0}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeCommon }, // Z
|
||||
{ .p = {{5, 1}, {4, 1}, {5, 0}, {6, 0}}, .rotIdx = 0, .offsetType = OffsetTypeCommon }, // S
|
||||
{ .p = {{5, 1}, {4, 1}, {6, 1}, {6, 0}}, .rotIdx = 0, .offsetType = OffsetTypeCommon }, // L
|
||||
{ .p = {{5, 1}, {4, 0}, {4, 1}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeCommon }, // J
|
||||
{ .p = {{5, 1}, {4, 1}, {5, 0}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeCommon }, // T
|
||||
{ .p = {{5, 1}, {4, 1}, {6, 1}, {7, 1}}, .rotIdx = 0, .offsetType = OffsetTypeI }, // I
|
||||
{ .p = {{5, 1}, {5, 0}, {6, 0}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeO } // O
|
||||
{.p = {{5, 1}, {4, 0}, {5, 0}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeCommon}, // Z
|
||||
{.p = {{5, 1}, {4, 1}, {5, 0}, {6, 0}}, .rotIdx = 0, .offsetType = OffsetTypeCommon}, // S
|
||||
{.p = {{5, 1}, {4, 1}, {6, 1}, {6, 0}}, .rotIdx = 0, .offsetType = OffsetTypeCommon}, // L
|
||||
{.p = {{5, 1}, {4, 0}, {4, 1}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeCommon}, // J
|
||||
{.p = {{5, 1}, {4, 1}, {5, 0}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeCommon}, // T
|
||||
{.p = {{5, 1}, {4, 1}, {6, 1}, {7, 1}}, .rotIdx = 0, .offsetType = OffsetTypeI}, // I
|
||||
{.p = {{5, 1}, {5, 0}, {6, 0}, {6, 1}}, .rotIdx = 0, .offsetType = OffsetTypeO} // O
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GameStatePlaying,
|
||||
GameStateGameOver
|
||||
} GameState;
|
||||
typedef enum { GameStatePlaying, GameStateGameOver } GameState;
|
||||
|
||||
typedef struct {
|
||||
bool playField[FIELD_HEIGHT][FIELD_WIDTH];
|
||||
|
@ -106,35 +92,31 @@ static void tetris_game_draw_border(Canvas* const canvas) {
|
|||
static void tetris_game_draw_playfield(Canvas* const canvas, const TetrisState* tetris_state) {
|
||||
// Playfield: 11 x 24
|
||||
|
||||
for (int y = 0; y < FIELD_HEIGHT; y++) {
|
||||
for (int x = 0; x < FIELD_WIDTH; x++) {
|
||||
if (tetris_state->playField[y][x]) {
|
||||
for(int y = 0; y < FIELD_HEIGHT; y++) {
|
||||
for(int x = 0; x < FIELD_WIDTH; x++) {
|
||||
if(tetris_state->playField[y][x]) {
|
||||
uint16_t xOffset = x * 5;
|
||||
uint16_t yOffset = y * 5;
|
||||
|
||||
canvas_draw_rframe(
|
||||
canvas,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + xOffset,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset - 1,
|
||||
BLOCK_WIDTH,
|
||||
canvas,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + xOffset,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset - 1,
|
||||
BLOCK_WIDTH,
|
||||
BLOCK_HEIGHT,
|
||||
1
|
||||
);
|
||||
1);
|
||||
canvas_draw_dot(
|
||||
canvas,
|
||||
canvas,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + xOffset + 2,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1
|
||||
);
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1);
|
||||
canvas_draw_dot(
|
||||
canvas,
|
||||
canvas,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + xOffset + 3,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1
|
||||
);
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1);
|
||||
canvas_draw_dot(
|
||||
canvas,
|
||||
canvas,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + xOffset + 2,
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset + 2
|
||||
);
|
||||
BORDER_OFFSET + MARGIN_OFFSET + yOffset + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,8 +155,8 @@ static void tetris_game_render_callback(Canvas* const canvas, void* ctx) {
|
|||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str_aligned(canvas, 32, 73, AlignCenter, AlignBottom, buffer);
|
||||
}
|
||||
release_mutex((ValueMutex *)ctx, tetris_state);
|
||||
}
|
||||
release_mutex((ValueMutex*)ctx, tetris_state);
|
||||
}
|
||||
|
||||
static void tetris_game_input_callback(InputEvent* input_event, osMessageQueueId_t event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
@ -195,7 +177,7 @@ static void tetris_game_init_state(TetrisState* tetris_state) {
|
|||
}
|
||||
|
||||
static void tetris_game_remove_curr_piece(TetrisState* tetris_state) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
uint8_t x = tetris_state->currPiece.p[i].x;
|
||||
uint8_t y = tetris_state->currPiece.p[i].y;
|
||||
|
||||
|
@ -204,7 +186,7 @@ static void tetris_game_remove_curr_piece(TetrisState* tetris_state) {
|
|||
}
|
||||
|
||||
static void tetris_game_render_curr_piece(TetrisState* tetris_state) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
uint8_t x = tetris_state->currPiece.p[i].x;
|
||||
uint8_t y = tetris_state->currPiece.p[i].y;
|
||||
|
||||
|
@ -218,7 +200,7 @@ static void tetris_game_rotate_shape(Point currShape[], Point newShape[]) {
|
|||
newShape[i] = currShape[i];
|
||||
}
|
||||
|
||||
for (int i = 1; i < 4; i++) {
|
||||
for(int i = 1; i < 4; i++) {
|
||||
int8_t relX = currShape[i].x - currShape[0].x;
|
||||
int8_t relY = currShape[i].y - currShape[0].y;
|
||||
|
||||
|
@ -239,19 +221,20 @@ static void tetris_game_apply_kick(Point points[], Point kick) {
|
|||
}
|
||||
|
||||
static bool tetris_game_is_valid_pos(TetrisState* tetris_state, Point* shape) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(shape[i].x < 0 || shape[i].x > (FIELD_WIDTH - 1) || tetris_state->playField[shape[i].y][shape[i].x] == true) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(shape[i].x < 0 || shape[i].x > (FIELD_WIDTH - 1) ||
|
||||
tetris_state->playField[shape[i].y][shape[i].x] == true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void tetris_game_try_rotation(TetrisState* tetris_state, Piece *newPiece) {
|
||||
static void tetris_game_try_rotation(TetrisState* tetris_state, Piece* newPiece) {
|
||||
uint8_t currRotIdx = tetris_state->currPiece.rotIdx;
|
||||
|
||||
Point *rotatedShape = malloc(sizeof(Point) * 4);
|
||||
Point *kickedShape = malloc(sizeof(Point) * 4);
|
||||
Point* rotatedShape = malloc(sizeof(Point) * 4);
|
||||
Point* kickedShape = malloc(sizeof(Point) * 4);
|
||||
|
||||
memcpy(rotatedShape, &tetris_state->currPiece.p, sizeof(tetris_state->currPiece.p));
|
||||
|
||||
|
@ -259,7 +242,8 @@ static void tetris_game_try_rotation(TetrisState* tetris_state, Piece *newPiece)
|
|||
|
||||
for(int i = 0; i < 5; i++) {
|
||||
memcpy(kickedShape, rotatedShape, (sizeof(Point) * 4));
|
||||
tetris_game_apply_kick(kickedShape, rotOffsetTranslation[newPiece->offsetType][currRotIdx][i]);
|
||||
tetris_game_apply_kick(
|
||||
kickedShape, rotOffsetTranslation[newPiece->offsetType][currRotIdx][i]);
|
||||
|
||||
if(tetris_game_is_valid_pos(tetris_state, kickedShape)) {
|
||||
memcpy(&newPiece->p, kickedShape, sizeof(newPiece->p));
|
||||
|
@ -273,13 +257,13 @@ static void tetris_game_try_rotation(TetrisState* tetris_state, Piece *newPiece)
|
|||
|
||||
static bool tetris_game_row_is_line(bool row[]) {
|
||||
for(int i = 0; i < FIELD_WIDTH; i++) {
|
||||
if(row[i] == false)
|
||||
return false;
|
||||
if(row[i] == false) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void tetris_game_check_for_lines(TetrisState* tetris_state, uint8_t* lines, uint8_t* numLines) {
|
||||
static void
|
||||
tetris_game_check_for_lines(TetrisState* tetris_state, uint8_t* lines, uint8_t* numLines) {
|
||||
for(int i = 0; i < FIELD_HEIGHT; i++) {
|
||||
if(tetris_game_row_is_line(tetris_state->playField[i])) {
|
||||
*(lines++) = i;
|
||||
|
@ -289,9 +273,9 @@ static void tetris_game_check_for_lines(TetrisState* tetris_state, uint8_t* line
|
|||
}
|
||||
|
||||
static bool tetris_game_piece_at_bottom(TetrisState* tetris_state, Piece* newPiece) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Point *pos = (Point *)&newPiece->p;
|
||||
if (pos[i].y >= FIELD_HEIGHT || tetris_state->playField[pos[i].y][pos[i].x] == true) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
Point* pos = (Point*)&newPiece->p;
|
||||
if(pos[i].y >= FIELD_HEIGHT || tetris_state->playField[pos[i].y][pos[i].x] == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -305,9 +289,9 @@ static void tetris_game_update_timer_callback(osMessageQueueId_t event_queue) {
|
|||
osMessageQueuePut(event_queue, &event, 0, osWaitForever);
|
||||
}
|
||||
|
||||
static void tetris_game_process_step(TetrisState* tetris_state, Piece* newPiece, bool wasDownMove) {
|
||||
if(tetris_state->gameState == GameStateGameOver)
|
||||
return;
|
||||
static void
|
||||
tetris_game_process_step(TetrisState* tetris_state, Piece* newPiece, bool wasDownMove) {
|
||||
if(tetris_state->gameState == GameStateGameOver) return;
|
||||
|
||||
tetris_game_remove_curr_piece(tetris_state);
|
||||
|
||||
|
@ -317,20 +301,20 @@ static void tetris_game_process_step(TetrisState* tetris_state, Piece* newPiece,
|
|||
|
||||
tetris_game_render_curr_piece(tetris_state);
|
||||
uint8_t numLines = 0;
|
||||
uint8_t lines[] = { 0,0,0,0 };
|
||||
uint8_t lines[] = {0, 0, 0, 0};
|
||||
|
||||
tetris_game_check_for_lines(tetris_state, lines, &numLines);
|
||||
if(numLines > 0) {
|
||||
for(int i = 0; i < numLines; i++) {
|
||||
|
||||
// zero out row
|
||||
for(int j = 0; j < FIELD_WIDTH; j++) {
|
||||
tetris_state->playField[lines[i]][j] = false;
|
||||
}
|
||||
// move all above rows down
|
||||
for(int k = lines[i]; k >= 0 ; k--) {
|
||||
for(int k = lines[i]; k >= 0; k--) {
|
||||
for(int m = 0; m < FIELD_WIDTH; m++) {
|
||||
tetris_state->playField[k][m] = (k == 0) ? false : tetris_state->playField[k-1][m];
|
||||
tetris_state->playField[k][m] =
|
||||
(k == 0) ? false : tetris_state->playField[k - 1][m];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +344,6 @@ static void tetris_game_process_step(TetrisState* tetris_state, Piece* newPiece,
|
|||
tetris_game_render_curr_piece(tetris_state);
|
||||
}
|
||||
|
||||
|
||||
int32_t tetris_game_app() {
|
||||
srand(DWT->CYCCNT);
|
||||
|
||||
|
@ -392,12 +375,13 @@ int32_t tetris_game_app() {
|
|||
Gui* gui = furi_record_open("gui");
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
|
||||
tetris_state->timer = osTimerNew(tetris_game_update_timer_callback, osTimerPeriodic, event_queue, NULL);
|
||||
tetris_state->timer =
|
||||
osTimerNew(tetris_game_update_timer_callback, osTimerPeriodic, event_queue, NULL);
|
||||
tetris_game_init_state(tetris_state);
|
||||
|
||||
TetrisEvent event;
|
||||
|
||||
Piece *newPiece = malloc(sizeof(Piece));
|
||||
Piece* newPiece = malloc(sizeof(Piece));
|
||||
uint8_t downRepeatCounter = 0;
|
||||
|
||||
for(bool processing = true; processing;) {
|
||||
|
@ -411,8 +395,8 @@ int32_t tetris_game_app() {
|
|||
|
||||
if(!furi_hal_gpio_read(&gpio_button_right)) {
|
||||
if(downRepeatCounter > 3) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
newPiece->p[i].y += 1;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
newPiece->p[i].y += 1;
|
||||
}
|
||||
downRepeatCounter = 0;
|
||||
wasDownMove = true;
|
||||
|
@ -423,19 +407,20 @@ int32_t tetris_game_app() {
|
|||
|
||||
if(event_status == osOK) {
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypePress || event.input.type == InputTypeLong || event.input.type == InputTypeRepeat) {
|
||||
if(event.input.type == InputTypePress || event.input.type == InputTypeLong ||
|
||||
event.input.type == InputTypeRepeat) {
|
||||
switch(event.input.key) {
|
||||
case InputKeyUp:
|
||||
break;
|
||||
case InputKeyDown:
|
||||
break;
|
||||
case InputKeyRight:
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
newPiece->p[i].x += 1;
|
||||
}
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
newPiece->p[i].x -= 1;
|
||||
}
|
||||
break;
|
||||
|
@ -457,8 +442,8 @@ int32_t tetris_game_app() {
|
|||
// TODO: This is inverted. it returns true when the button is not pressed.
|
||||
// see macro in input.c and do that
|
||||
if(furi_hal_gpio_read(&gpio_button_right)) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
newPiece->p[i].y += 1;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
newPiece->p[i].y += 1;
|
||||
}
|
||||
wasDownMove = true;
|
||||
}
|
||||
|
@ -471,7 +456,7 @@ int32_t tetris_game_app() {
|
|||
release_mutex(&state_mutex, tetris_state);
|
||||
}
|
||||
|
||||
osTimerDelete(tetris_state->timer);
|
||||
osTimerDelete(tetris_state->timer);
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close("gui");
|
||||
|
|
|
@ -19,11 +19,7 @@ static bool open_wav_stream(Storage* storage, Stream* stream) {
|
|||
string_t path;
|
||||
string_init(path);
|
||||
string_set_str(path, "/ext/wav_player");
|
||||
bool ret =
|
||||
dialog_file_browser_show(dialogs, path, path, ".wav",
|
||||
true,
|
||||
&I_music_10px,
|
||||
false);
|
||||
bool ret = dialog_file_browser_show(dialogs, path, path, ".wav", true, &I_music_10px, false);
|
||||
|
||||
furi_record_close("dialogs");
|
||||
if(ret) {
|
||||
|
|
|
@ -124,7 +124,8 @@ static LevelDuration
|
|||
* Generating an upload from data.
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderCameAtomo instance
|
||||
*/
|
||||
static void subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderCameAtomo* instance) {
|
||||
static void
|
||||
subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderCameAtomo* instance) {
|
||||
furi_assert(instance);
|
||||
size_t index = 0;
|
||||
|
||||
|
@ -141,20 +142,23 @@ static void subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderC
|
|||
level_duration_make(true, (uint32_t)subghz_protocol_came_atomo_const.te_long * 15);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_came_atomo_const.te_long * 60);
|
||||
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
pack[0] = (instance->generic.data_2 >> 56);
|
||||
pack[1] = (instance->generic.cnt >> 8);
|
||||
pack[2] = (instance->generic.cnt & 0xFF);
|
||||
pack[3] = ((instance->generic.data_2 >> 32) & 0xFF);
|
||||
pack[4] = ((instance->generic.data_2 >> 24) & 0xFF);
|
||||
pack[5] = ((instance->generic.data_2 >> 16) & 0xFF);
|
||||
pack[6] = ((instance->generic.data_2 >> 8) & 0xFF);
|
||||
pack[7] = (instance->generic.data_2 & 0xFF);
|
||||
|
||||
pack[0] = (instance->generic.data_2 >> 56); pack[1] = (instance->generic.cnt >> 8);
|
||||
pack[2] = (instance->generic.cnt & 0xFF); pack[3] = ((instance->generic.data_2 >> 32) & 0xFF);
|
||||
pack[4] = ((instance->generic.data_2 >> 24) & 0xFF); pack[5] = ((instance->generic.data_2 >> 16) & 0xFF);
|
||||
pack[6] = ((instance->generic.data_2 >> 8) & 0xFF); pack[7] = (instance->generic.data_2 & 0xFF);
|
||||
|
||||
if (pack[0] == 0x7F) {
|
||||
if(pack[0] == 0x7F) {
|
||||
pack[0] = 0;
|
||||
} else {
|
||||
pack[0] += (i+1);
|
||||
pack[0] += (i + 1);
|
||||
}
|
||||
|
||||
|
||||
atomo_encrypt(pack);
|
||||
uint32_t hi = pack[0] << 24 | pack[1] << 16 | pack[2] << 8 | pack[3];
|
||||
uint32_t lo = pack[4] << 24 | pack[5] << 16 | pack[6] << 8 | pack[7];
|
||||
|
@ -162,21 +166,27 @@ static void subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderC
|
|||
|
||||
instance->generic.data ^= 0xFFFFFFFFFFFFFFFF;
|
||||
instance->generic.data >>= 4;
|
||||
instance->generic.data &= 0xFFFFFFFFFFFFFFF;
|
||||
|
||||
instance->generic.data &= 0xFFFFFFFFFFFFFFF;
|
||||
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_came_atomo_const.te_long);
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_came_atomo_const.te_long);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_came_atomo_const.te_short);
|
||||
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_came_atomo_const.te_short);
|
||||
|
||||
for(uint8_t i = (instance->generic.data_count_bit - 2); i > 0; i--) {
|
||||
if(!manchester_encoder_advance(&enc_state, !bit_read(instance->generic.data, i - 1), &result)) {
|
||||
instance->encoder.upload[index++] = subghz_protocol_encoder_came_atomo_add_duration_to_upload(result);
|
||||
manchester_encoder_advance(&enc_state, !bit_read(instance->generic.data, i - 1), &result);
|
||||
if(!manchester_encoder_advance(
|
||||
&enc_state, !bit_read(instance->generic.data, i - 1), &result)) {
|
||||
instance->encoder.upload[index++] =
|
||||
subghz_protocol_encoder_came_atomo_add_duration_to_upload(result);
|
||||
manchester_encoder_advance(
|
||||
&enc_state, !bit_read(instance->generic.data, i - 1), &result);
|
||||
}
|
||||
instance->encoder.upload[index++] = subghz_protocol_encoder_came_atomo_add_duration_to_upload(result);
|
||||
instance->encoder.upload[index++] =
|
||||
subghz_protocol_encoder_came_atomo_add_duration_to_upload(result);
|
||||
}
|
||||
instance->encoder.upload[index] = subghz_protocol_encoder_came_atomo_add_duration_to_upload(manchester_encoder_finish(&enc_state));
|
||||
instance->encoder.upload[index] =
|
||||
subghz_protocol_encoder_came_atomo_add_duration_to_upload(
|
||||
manchester_encoder_finish(&enc_state));
|
||||
if(level_duration_get_level(instance->encoder.upload[index])) {
|
||||
index++;
|
||||
}
|
||||
|
@ -186,11 +196,15 @@ static void subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderC
|
|||
}
|
||||
instance->encoder.size_upload = index;
|
||||
instance->generic.cnt_2++;
|
||||
pack[0] = (instance->generic.cnt_2); pack[1] = (instance->generic.cnt >> 8);
|
||||
pack[2] = (instance->generic.cnt & 0xFF); pack[3] = ((instance->generic.data_2 >> 32) & 0xFF);
|
||||
pack[4] = ((instance->generic.data_2 >> 24) & 0xFF); pack[5] = ((instance->generic.data_2 >> 16) & 0xFF);
|
||||
pack[6] = ((instance->generic.data_2 >> 8) & 0xFF); pack[7] = (instance->generic.data_2 & 0xFF);
|
||||
|
||||
pack[0] = (instance->generic.cnt_2);
|
||||
pack[1] = (instance->generic.cnt >> 8);
|
||||
pack[2] = (instance->generic.cnt & 0xFF);
|
||||
pack[3] = ((instance->generic.data_2 >> 32) & 0xFF);
|
||||
pack[4] = ((instance->generic.data_2 >> 24) & 0xFF);
|
||||
pack[5] = ((instance->generic.data_2 >> 16) & 0xFF);
|
||||
pack[6] = ((instance->generic.data_2 >> 8) & 0xFF);
|
||||
pack[7] = (instance->generic.data_2 & 0xFF);
|
||||
|
||||
atomo_encrypt(pack);
|
||||
uint32_t hi = pack[0] << 24 | pack[1] << 16 | pack[2] << 8 | pack[3];
|
||||
uint32_t lo = pack[4] << 24 | pack[5] << 16 | pack[6] << 8 | pack[7];
|
||||
|
@ -376,8 +390,7 @@ void subghz_protocol_decoder_came_atomo_feed(void* context, bool level, uint32_t
|
|||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
* @param file_name Full path to rainbow table the file
|
||||
*/
|
||||
static void subghz_protocol_came_atomo_remote_controller(
|
||||
SubGhzBlockGeneric* instance) {
|
||||
static void subghz_protocol_came_atomo_remote_controller(SubGhzBlockGeneric* instance) {
|
||||
/*
|
||||
* ***SkorP ver.***
|
||||
* 0x1fafef3ed0f7d9ef
|
||||
|
@ -443,65 +456,77 @@ static void subghz_protocol_came_atomo_remote_controller(
|
|||
|
||||
instance->data ^= 0xFFFFFFFFFFFFFFFF;
|
||||
instance->data <<= 4;
|
||||
|
||||
|
||||
uint8_t pack[8] = {};
|
||||
pack[0] = (instance->data >> 56); pack[1] = ((instance->data >> 48) & 0xFF);
|
||||
pack[2] = ((instance->data >> 40) & 0xFF); pack[3] = ((instance->data >> 32) & 0xFF);
|
||||
pack[4] = ((instance->data >> 24) & 0xFF); pack[5] = ((instance->data >> 16) & 0xFF);
|
||||
pack[6] = ((instance->data >> 8) & 0xFF); pack[7] = (instance->data & 0xFF);
|
||||
|
||||
pack[0] = (instance->data >> 56);
|
||||
pack[1] = ((instance->data >> 48) & 0xFF);
|
||||
pack[2] = ((instance->data >> 40) & 0xFF);
|
||||
pack[3] = ((instance->data >> 32) & 0xFF);
|
||||
pack[4] = ((instance->data >> 24) & 0xFF);
|
||||
pack[5] = ((instance->data >> 16) & 0xFF);
|
||||
pack[6] = ((instance->data >> 8) & 0xFF);
|
||||
pack[7] = (instance->data & 0xFF);
|
||||
|
||||
atomo_decrypt(pack);
|
||||
|
||||
instance->cnt_2 = pack[0];
|
||||
instance->cnt = (uint16_t)pack[1] << 8 | pack[2];
|
||||
instance->serial = (uint32_t)(pack[3]) << 24 | pack[4] << 16 | pack[5] << 8 | pack[6];
|
||||
|
||||
|
||||
uint8_t btn_decode = (pack[7] >> 4);
|
||||
if(btn_decode == 0x0) {instance->btn = 0x1;}
|
||||
if(btn_decode == 0x2) {instance->btn = 0x2;}
|
||||
if(btn_decode == 0x4) {instance->btn = 0x3;}
|
||||
if(btn_decode == 0x6) {instance->btn = 0x4;}
|
||||
|
||||
if(btn_decode == 0x0) {
|
||||
instance->btn = 0x1;
|
||||
}
|
||||
if(btn_decode == 0x2) {
|
||||
instance->btn = 0x2;
|
||||
}
|
||||
if(btn_decode == 0x4) {
|
||||
instance->btn = 0x3;
|
||||
}
|
||||
if(btn_decode == 0x6) {
|
||||
instance->btn = 0x4;
|
||||
}
|
||||
|
||||
uint32_t hi = pack[0] << 24 | pack[1] << 16 | pack[2] << 8 | pack[3];
|
||||
uint32_t lo = pack[4] << 24 | pack[5] << 16 | pack[6] << 8 | pack[7];
|
||||
instance->data_2 = (uint64_t)hi << 32 | lo;
|
||||
}
|
||||
|
||||
void atomo_encrypt(uint8_t *buff) {
|
||||
uint8_t tmpB = (~buff[0]+1) & 0x7F;
|
||||
void atomo_encrypt(uint8_t* buff) {
|
||||
uint8_t tmpB = (~buff[0] + 1) & 0x7F;
|
||||
|
||||
uint8_t bitCnt = 8;
|
||||
while (bitCnt < 59) {
|
||||
if ( (tmpB & 0x18) && ( ((tmpB / 8) & 3) != 3 ) ) {
|
||||
while(bitCnt < 59) {
|
||||
if((tmpB & 0x18) && (((tmpB / 8) & 3) != 3)) {
|
||||
tmpB = ((tmpB << 1) & 0xFF) | 1;
|
||||
} else {
|
||||
tmpB = (tmpB << 1) & 0xFF;
|
||||
}
|
||||
|
||||
if ( tmpB & 0x80 ) {
|
||||
buff[bitCnt/8] ^= (0x80 >> (bitCnt & 7));
|
||||
if(tmpB & 0x80) {
|
||||
buff[bitCnt / 8] ^= (0x80 >> (bitCnt & 7));
|
||||
}
|
||||
|
||||
bitCnt++;
|
||||
}
|
||||
|
||||
buff[0] = ( buff[0] ^ 5 ) & 0x7F;
|
||||
buff[0] = (buff[0] ^ 5) & 0x7F;
|
||||
}
|
||||
|
||||
void atomo_decrypt(uint8_t *buff) {
|
||||
buff[0] = ( buff[0] ^ 5 ) & 0x7F;
|
||||
uint8_t tmpB = ( -buff[0]) & 0x7F;
|
||||
void atomo_decrypt(uint8_t* buff) {
|
||||
buff[0] = (buff[0] ^ 5) & 0x7F;
|
||||
uint8_t tmpB = (-buff[0]) & 0x7F;
|
||||
|
||||
uint8_t bitCnt = 8;
|
||||
while (bitCnt < 59) {
|
||||
if ( (tmpB & 0x18) && ( ((tmpB / 8) & 3) != 3 ) ) {
|
||||
while(bitCnt < 59) {
|
||||
if((tmpB & 0x18) && (((tmpB / 8) & 3) != 3)) {
|
||||
tmpB = ((tmpB << 1) & 0xFF) | 1;
|
||||
} else {
|
||||
tmpB = (tmpB << 1) & 0xFF;
|
||||
}
|
||||
|
||||
if ( tmpB & 0x80 ) {
|
||||
buff[bitCnt /8] ^= (0x80 >> (bitCnt & 7));
|
||||
if(tmpB & 0x80) {
|
||||
buff[bitCnt / 8] ^= (0x80 >> (bitCnt & 7));
|
||||
}
|
||||
|
||||
bitCnt++;
|
||||
|
@ -534,8 +559,7 @@ bool subghz_protocol_decoder_came_atomo_deserialize(void* context, FlipperFormat
|
|||
void subghz_protocol_decoder_came_atomo_get_string(void* context, string_t output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderCameAtomo* instance = context;
|
||||
subghz_protocol_came_atomo_remote_controller(
|
||||
&instance->generic);
|
||||
subghz_protocol_came_atomo_remote_controller(&instance->generic);
|
||||
uint32_t code_found_hi = instance->generic.data >> 32;
|
||||
uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff;
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ extern const SubGhzProtocolDecoder subghz_protocol_came_atomo_decoder;
|
|||
extern const SubGhzProtocolEncoder subghz_protocol_came_atomo_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_came_atomo;
|
||||
|
||||
void atomo_decrypt(uint8_t *buff);
|
||||
void atomo_decrypt(uint8_t* buff);
|
||||
|
||||
void atomo_encrypt(uint8_t *buff);
|
||||
void atomo_encrypt(uint8_t* buff);
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderCameAtomo.
|
||||
|
@ -48,7 +48,6 @@ void subghz_protocol_encoder_came_atomo_stop(void* context);
|
|||
*/
|
||||
LevelDuration subghz_protocol_encoder_came_atomo_yield(void* context);
|
||||
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolDecoderCameAtomo.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
|
|
@ -84,10 +84,10 @@ const SubGhzProtocol subghz_protocol_faac_slh = {
|
|||
* @param keystore Pointer to a SubGhzKeystore* instance
|
||||
* @param manufacture_name
|
||||
*/
|
||||
static void subghz_protocol_faac_slh_check_remote_controller
|
||||
(SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name);
|
||||
static void subghz_protocol_faac_slh_check_remote_controller(
|
||||
SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name);
|
||||
|
||||
void* subghz_protocol_encoder_faac_slh_alloc(SubGhzEnvironment* environment) {
|
||||
SubGhzProtocolEncoderFaacSLH* instance = malloc(sizeof(SubGhzProtocolEncoderFaacSLH));
|
||||
|
@ -119,16 +119,15 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
|||
int res = 0;
|
||||
char fixx[8] = {};
|
||||
int shiftby = 32;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for(int i = 0; i < 8; i++) {
|
||||
fixx[i] = (fix >> (shiftby -= 4)) & 0xF;
|
||||
}
|
||||
if ((instance->generic.cnt % 2) == 0) {
|
||||
decrypt = fixx[6] << 28 | fixx[7] << 24 | fixx[5] << 20 |
|
||||
fixx[1] << 16 | instance->generic.cnt;
|
||||
}
|
||||
else {
|
||||
decrypt = fixx[2] << 28 | fixx[3] << 24 | fixx[4] << 20 |
|
||||
fixx[1] << 16 | instance->generic.cnt;
|
||||
if((instance->generic.cnt % 2) == 0) {
|
||||
decrypt = fixx[6] << 28 | fixx[7] << 24 | fixx[5] << 20 | fixx[1] << 16 |
|
||||
instance->generic.cnt;
|
||||
} else {
|
||||
decrypt = fixx[2] << 28 | fixx[3] << 24 | fixx[4] << 20 | fixx[1] << 16 |
|
||||
instance->generic.cnt;
|
||||
}
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(instance->keystore), SubGhzKeyArray_t) {
|
||||
|
@ -137,7 +136,8 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
|||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_FAAC:
|
||||
//FAAC Learning
|
||||
man = subghz_protocol_keeloq_common_faac_learning(instance->generic.seed, manufacture_code->key);
|
||||
man = subghz_protocol_keeloq_common_faac_learning(
|
||||
instance->generic.seed, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
break;
|
||||
}
|
||||
|
@ -160,19 +160,20 @@ bool subghz_protocol_faac_slh_create_data(
|
|||
const char* manufacture_name,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderFaacSLH* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.btn = btn;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->generic.seed = seed;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_faac_slh_gen_data(instance);
|
||||
if(res) {
|
||||
res = subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
}
|
||||
return res;
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderFaacSLH* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.btn = btn;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->generic.seed = seed;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_faac_slh_gen_data(instance);
|
||||
if(res) {
|
||||
res =
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,8 +181,7 @@ bool subghz_protocol_faac_slh_create_data(
|
|||
* @param instance Pointer to a SubGhzProtocolEncoderFaacSLH instance
|
||||
* @return true On success
|
||||
*/
|
||||
static bool
|
||||
subghz_protocol_encoder_faac_slh_get_upload(SubGhzProtocolEncoderFaacSLH* instance) {
|
||||
static bool subghz_protocol_encoder_faac_slh_get_upload(SubGhzProtocolEncoderFaacSLH* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
subghz_protocol_faac_slh_gen_data(instance);
|
||||
|
@ -236,11 +236,12 @@ bool subghz_protocol_encoder_faac_slh_deserialize(void* context, FlipperFormat*
|
|||
FURI_LOG_E(TAG, "Missing Seed");
|
||||
break;
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3] ;
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||
seed_data[3];
|
||||
|
||||
subghz_protocol_faac_slh_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
|
||||
//optional parameter parameter
|
||||
flipper_format_read_uint32(
|
||||
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
||||
|
@ -259,7 +260,7 @@ bool subghz_protocol_encoder_faac_slh_deserialize(void* context, FlipperFormat*
|
|||
FURI_LOG_E(TAG, "Unable to add Key");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
instance->encoder.is_runing = true;
|
||||
|
||||
res = true;
|
||||
|
@ -390,11 +391,10 @@ void subghz_protocol_decoder_faac_slh_feed(void* context, bool level, uint32_t d
|
|||
* @param keystore Pointer to a SubGhzKeystore* instance
|
||||
* @param manifacture_name Manufacturer name
|
||||
*/
|
||||
static void subghz_protocol_faac_slh_check_remote_controller
|
||||
(SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name) {
|
||||
|
||||
static void subghz_protocol_faac_slh_check_remote_controller(
|
||||
SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name) {
|
||||
uint32_t code_fix = instance->data >> 32;
|
||||
uint32_t code_hop = instance->data & 0xFFFFFFFF;
|
||||
instance->serial = code_fix >> 4;
|
||||
|
@ -403,16 +403,17 @@ static void subghz_protocol_faac_slh_check_remote_controller
|
|||
uint64_t man;
|
||||
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_FAAC:
|
||||
// FAAC Learning
|
||||
man = subghz_protocol_keeloq_common_faac_learning(instance->seed, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(code_hop, man);
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
break;
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_FAAC:
|
||||
// FAAC Learning
|
||||
man = subghz_protocol_keeloq_common_faac_learning(
|
||||
instance->seed, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(code_hop, man);
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
instance->cnt = decrypt & 0xFFFF;
|
||||
}
|
||||
|
||||
|
@ -431,17 +432,19 @@ bool subghz_protocol_decoder_faac_slh_serialize(
|
|||
furi_assert(context);
|
||||
SubGhzProtocolDecoderFaacSLH* instance = context;
|
||||
|
||||
bool res = subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
bool res =
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
|
||||
uint8_t seed_data[sizeof(uint32_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF;
|
||||
}
|
||||
for(size_t i = 0; i < sizeof(uint32_t); i++) {
|
||||
seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF;
|
||||
}
|
||||
if(res && !flipper_format_write_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to add Seed");
|
||||
res = false;
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3];
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||
seed_data[3];
|
||||
|
||||
subghz_protocol_faac_slh_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
@ -470,17 +473,19 @@ bool subghz_protocol_decoder_faac_slh_deserialize(void* context, FlipperFormat*
|
|||
FURI_LOG_E(TAG, "Missing Seed");
|
||||
break;
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3];
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||
seed_data[3];
|
||||
res = true;
|
||||
} while(false);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_faac_slh_get_string(void* context, string_t output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderFaacSLH* instance = context;
|
||||
subghz_protocol_faac_slh_check_remote_controller(&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
subghz_protocol_faac_slh_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
uint32_t code_fix = instance->generic.data >> 32;
|
||||
uint32_t code_hop = instance->generic.data & 0xFFFFFFFF;
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ const SubGhzProtocol subghz_protocol_keeloq = {
|
|||
.name = SUBGHZ_PROTOCOL_KEELOQ_NAME,
|
||||
.type = SubGhzProtocolTypeDynamic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_868 | SubGhzProtocolFlag_315 |
|
||||
SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save |
|
||||
SubGhzProtocolFlag_Send,
|
||||
SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load |
|
||||
SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
|
||||
.decoder = &subghz_protocol_keeloq_decoder,
|
||||
.encoder = &subghz_protocol_keeloq_encoder,
|
||||
|
@ -141,11 +141,11 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc
|
|||
uint64_t code_found_reverse;
|
||||
int res = 0;
|
||||
|
||||
if (strcmp(instance->manufacture_name, "Unknown") == 0) {
|
||||
if(strcmp(instance->manufacture_name, "Unknown") == 0) {
|
||||
code_found_reverse = subghz_protocol_blocks_reverse_key(
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
hop = code_found_reverse & 0x00000000ffffffff;
|
||||
} else {
|
||||
} else {
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(instance->keystore), SubGhzKeyArray_t) {
|
||||
res = strcmp(string_get_cstr(manufacture_code->name), instance->manufacture_name);
|
||||
|
@ -157,32 +157,48 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc
|
|||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
//Simple Learning
|
||||
man = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
man =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
break;
|
||||
case KEELOQ_LEARNING_SECURE:
|
||||
//Secure Learning
|
||||
man = subghz_protocol_keeloq_common_secure_learning(fix, instance->generic.seed, manufacture_code->key);
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->generic.seed, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
break;
|
||||
case KEELOQ_LEARNING_MAGIC_XOR_TYPE_1:
|
||||
//Magic XOR type-1 Learning
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(instance->generic.serial, manufacture_code->key);
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(
|
||||
instance->generic.serial, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
if(kl_type == 1) { hop = subghz_protocol_keeloq_common_encrypt(decrypt, manufacture_code->key); }
|
||||
if(kl_type == 2) { man = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man); }
|
||||
if(kl_type == 3) { man = subghz_protocol_keeloq_common_secure_learning(fix, instance->generic.seed, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man); }
|
||||
if(kl_type == 4) { man = subghz_protocol_keeloq_common_magic_xor_type1_learning(instance->generic.serial, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man); }
|
||||
if(kl_type == 1) {
|
||||
hop =
|
||||
subghz_protocol_keeloq_common_encrypt(decrypt, manufacture_code->key);
|
||||
}
|
||||
if(kl_type == 2) {
|
||||
man = subghz_protocol_keeloq_common_normal_learning(
|
||||
fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
}
|
||||
if(kl_type == 3) {
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->generic.seed, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
}
|
||||
if(kl_type == 4) {
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(
|
||||
instance->generic.serial, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
if(hop) {
|
||||
uint64_t yek = (uint64_t)fix << 32 | hop;
|
||||
instance->generic.data =
|
||||
|
@ -200,17 +216,18 @@ bool subghz_protocol_keeloq_create_data(
|
|||
const char* manufacture_name,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderKeeloq* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn);
|
||||
if(res) {
|
||||
res = subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
}
|
||||
return res;
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderKeeloq* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn);
|
||||
if(res) {
|
||||
res =
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool subghz_protocol_keeloq_bft_create_data(
|
||||
|
@ -223,19 +240,20 @@ bool subghz_protocol_keeloq_bft_create_data(
|
|||
const char* manufacture_name,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderKeeloq* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.btn = btn;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->generic.seed = seed;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn);
|
||||
if(res) {
|
||||
res = subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
}
|
||||
return res;
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderKeeloq* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.btn = btn;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->generic.seed = seed;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_keeloq_gen_data(instance, btn);
|
||||
if(res) {
|
||||
res =
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,7 +339,8 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
|
|||
if(!flipper_format_read_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
|
||||
FURI_LOG_E(TAG, "Missing Seed");
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3];
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||
seed_data[3];
|
||||
|
||||
subghz_protocol_keeloq_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
@ -534,8 +553,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
|||
uint64_t man;
|
||||
int res = 0;
|
||||
|
||||
if(strcmp(mfname, "") == 0) {
|
||||
|
||||
if(strcmp(mfname, "") == 0) {
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
switch(manufacture_code->type) {
|
||||
|
@ -668,147 +686,149 @@ if(strcmp(mfname, "") == 0) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(mfname, "Unknown") == 0) {
|
||||
return 1;
|
||||
} else if(strcmp(mfname, "Unknown") == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
res = strcmp(string_get_cstr(manufacture_code->name), mfname);
|
||||
if(res == 0) {
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_SIMPLE:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_SECURE:
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->seed, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_MAGIC_XOR_TYPE_1:
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(
|
||||
fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
uint64_t man_rev = 0;
|
||||
uint64_t man_rev_byte = 0;
|
||||
for(uint8_t i = 0; i < 64; i += 8) {
|
||||
man_rev_byte = (uint8_t)(manufacture_code->key >> i);
|
||||
man_rev = man_rev | man_rev_byte << (56 - i);
|
||||
}
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
//###########################
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_SIMPLE:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_SECURE:
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->seed, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_MAGIC_XOR_TYPE_1:
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(
|
||||
fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
uint64_t man_rev = 0;
|
||||
uint64_t man_rev_byte = 0;
|
||||
for(uint8_t i = 0; i < 64; i += 8) {
|
||||
man_rev_byte = (uint8_t)(manufacture_code->key >> i);
|
||||
man_rev = man_rev | man_rev_byte << (56 - i);
|
||||
}
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
//###########################
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check for mirrored man
|
||||
man = subghz_protocol_keeloq_common_normal_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
man = subghz_protocol_keeloq_common_normal_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Secure Learning
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->seed, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 3;
|
||||
return 1;
|
||||
}
|
||||
// Secure Learning
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->seed, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check for mirrored man
|
||||
man = subghz_protocol_keeloq_common_secure_learning(fix, instance->seed, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 3;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
man = subghz_protocol_keeloq_common_secure_learning(
|
||||
fix, instance->seed, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Magic xor type1 learning
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(
|
||||
fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 4;
|
||||
return 1;
|
||||
}
|
||||
// Magic xor type1 learning
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(
|
||||
fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 4;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check for mirrored man
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 4;
|
||||
return 1;
|
||||
// Check for mirrored man
|
||||
man = subghz_protocol_keeloq_common_magic_xor_type1_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 4;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*manufacture_name = "Unknown";
|
||||
mfname = "Unknown";
|
||||
instance->cnt = 0;
|
||||
|
@ -857,7 +877,7 @@ bool subghz_protocol_decoder_keeloq_serialize(
|
|||
|
||||
bool res =
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
|
||||
|
||||
subghz_protocol_keeloq_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
|
@ -889,7 +909,8 @@ bool subghz_protocol_decoder_keeloq_deserialize(void* context, FlipperFormat* fl
|
|||
if(!flipper_format_read_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
|
||||
FURI_LOG_E(TAG, "Missing Seed");
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3];
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
|
||||
seed_data[3];
|
||||
res = true;
|
||||
} while(false);
|
||||
|
||||
|
@ -899,7 +920,7 @@ bool subghz_protocol_decoder_keeloq_deserialize(void* context, FlipperFormat* fl
|
|||
void subghz_protocol_decoder_keeloq_get_string(void* context, string_t output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeeloq* instance = context;
|
||||
|
||||
|
||||
subghz_protocol_keeloq_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
|
|
|
@ -89,12 +89,12 @@ inline uint64_t
|
|||
* @return man_learning for this seed number (64bit)
|
||||
*/
|
||||
|
||||
inline uint64_t
|
||||
inline uint64_t
|
||||
subghz_protocol_keeloq_common_faac_learning(const uint32_t seed, const uint64_t key) {
|
||||
uint16_t hs = seed >> 16;
|
||||
const uint16_t ending = 0x544D;
|
||||
uint32_t lsb = (uint32_t)hs << 16 | ending;
|
||||
uint64_t man = (uint64_t)subghz_protocol_keeloq_common_encrypt(seed, key) << 32 |
|
||||
subghz_protocol_keeloq_common_encrypt(lsb, key);
|
||||
uint64_t man = (uint64_t)subghz_protocol_keeloq_common_encrypt(seed, key) << 32 |
|
||||
subghz_protocol_keeloq_common_encrypt(lsb, key);
|
||||
return man;
|
||||
}
|
|
@ -114,12 +114,14 @@ void subghz_protocol_encoder_nice_flor_s_free(void* context) {
|
|||
* @param instance Pointer to a SubGhzProtocolEncoderNiceFlorS instance
|
||||
* @return true On success
|
||||
*/
|
||||
static void
|
||||
subghz_protocol_encoder_nice_flor_s_get_upload(SubGhzProtocolEncoderNiceFlorS* instance, uint8_t btn, const char* file_name) {
|
||||
static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
SubGhzProtocolEncoderNiceFlorS* instance,
|
||||
uint8_t btn,
|
||||
const char* file_name) {
|
||||
furi_assert(instance);
|
||||
size_t index = 0;
|
||||
btn = instance->generic.btn;
|
||||
|
||||
|
||||
size_t size_upload = ((instance->generic.data_count_bit * 2) + ((37 + 2 + 2) * 2) * 16);
|
||||
if(size_upload > instance->encoder.size_upload) {
|
||||
FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer.");
|
||||
|
@ -131,46 +133,45 @@ static void
|
|||
uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt;
|
||||
uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt(decrypt, file_name);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
||||
static const uint64_t loops[16] = {
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF};
|
||||
|
||||
uint8_t byte;
|
||||
for(int i = 0; i < 16; i++) {
|
||||
static const uint64_t loops[16] = {
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF};
|
||||
|
||||
byte = btn << 4 | (0xF ^ btn ^ loops[i]);
|
||||
instance->generic.data = (uint64_t)byte << 44 | enc_part;
|
||||
|
||||
//Send header
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 37);
|
||||
//Send start bit
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
uint8_t byte;
|
||||
|
||||
//Send key data
|
||||
for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) {
|
||||
if(bit_read(instance->generic.data, i - 1)) {
|
||||
//send bit 1
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short);
|
||||
} else {
|
||||
//send bit 0
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||
byte = btn << 4 | (0xF ^ btn ^ loops[i]);
|
||||
instance->generic.data = (uint64_t)byte << 44 | enc_part;
|
||||
|
||||
//Send header
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 37);
|
||||
//Send start bit
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
|
||||
//Send key data
|
||||
for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) {
|
||||
if(bit_read(instance->generic.data, i - 1)) {
|
||||
//send bit 1
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||
instance->encoder.upload[index++] = level_duration_make(
|
||||
false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short);
|
||||
} else {
|
||||
//send bit 0
|
||||
instance->encoder.upload[index++] = level_duration_make(
|
||||
true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short);
|
||||
instance->encoder.upload[index++] = level_duration_make(
|
||||
false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Send stop bit
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
//instance->encoder.upload[index++] =
|
||||
//level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
//Send stop bit
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
//instance->encoder.upload[index++] =
|
||||
//level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||
}
|
||||
instance->encoder.size_upload = index;
|
||||
}
|
||||
|
@ -189,8 +190,10 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma
|
|||
flipper_format_read_uint32(
|
||||
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
||||
|
||||
subghz_protocol_nice_flor_s_remote_controller(&instance->generic, instance->nice_flor_s_rainbow_table_file_name);
|
||||
subghz_protocol_encoder_nice_flor_s_get_upload(instance, instance->generic.btn, instance->nice_flor_s_rainbow_table_file_name);
|
||||
subghz_protocol_nice_flor_s_remote_controller(
|
||||
&instance->generic, instance->nice_flor_s_rainbow_table_file_name);
|
||||
subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
instance, instance->generic.btn, instance->nice_flor_s_rainbow_table_file_name);
|
||||
|
||||
if(!flipper_format_rewind(flipper_format)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
|
|
|
@ -73,8 +73,8 @@ const SubGhzProtocolEncoder subghz_protocol_star_line_encoder = {
|
|||
const SubGhzProtocol subghz_protocol_star_line = {
|
||||
.name = SUBGHZ_PROTOCOL_STAR_LINE_NAME,
|
||||
.type = SubGhzProtocolTypeDynamic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable
|
||||
| SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
|
||||
.decoder = &subghz_protocol_star_line_decoder,
|
||||
.encoder = &subghz_protocol_star_line_encoder,
|
||||
|
@ -129,21 +129,19 @@ void subghz_protocol_encoder_star_line_free(void* context) {
|
|||
* @param instance Pointer to a SubGhzProtocolEncoderKeeloq* instance
|
||||
* @param btn Button number, 4 bit
|
||||
*/
|
||||
static bool subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
|
||||
static bool
|
||||
subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
|
||||
instance->generic.cnt++;
|
||||
uint32_t fix = btn << 24 | instance->generic.serial;
|
||||
uint32_t decrypt = btn << 24 |
|
||||
(instance->generic.serial & 0xFF)
|
||||
<< 16 |
|
||||
instance->generic.cnt;
|
||||
uint32_t decrypt = btn << 24 | (instance->generic.serial & 0xFF) << 16 | instance->generic.cnt;
|
||||
uint32_t hop = 0;
|
||||
uint64_t man = 0;
|
||||
uint64_t code_found_reverse;
|
||||
int res = 0;
|
||||
|
||||
if (strcmp(instance->manufacture_name, "Unknown") == 0) {
|
||||
if(strcmp(instance->manufacture_name, "Unknown") == 0) {
|
||||
code_found_reverse = subghz_protocol_blocks_reverse_key(
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
hop = code_found_reverse & 0x00000000ffffffff;
|
||||
} else {
|
||||
for
|
||||
|
@ -162,14 +160,21 @@ static bool subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* in
|
|||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
if(kl_type == 1) { hop = subghz_protocol_keeloq_common_encrypt(decrypt, manufacture_code->key); }
|
||||
if(kl_type == 2) { man = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man); }
|
||||
if(kl_type == 1) {
|
||||
hop =
|
||||
subghz_protocol_keeloq_common_encrypt(decrypt, manufacture_code->key);
|
||||
}
|
||||
if(kl_type == 2) {
|
||||
man = subghz_protocol_keeloq_common_normal_learning(
|
||||
fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
if(hop) {
|
||||
uint64_t yek = (uint64_t)fix << 32 | hop;
|
||||
instance->generic.data =
|
||||
|
@ -209,8 +214,9 @@ bool subghz_protocol_star_line_create_data(
|
|||
* @param instance Pointer to a SubGhzProtocolEncoderKeeloq instance
|
||||
* @return true On success
|
||||
*/
|
||||
static bool
|
||||
subghz_protocol_encoder_star_line_get_upload(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
|
||||
static bool subghz_protocol_encoder_star_line_get_upload(
|
||||
SubGhzProtocolEncoderStarLine* instance,
|
||||
uint8_t btn) {
|
||||
furi_assert(instance);
|
||||
|
||||
//gen new key
|
||||
|
@ -469,8 +475,7 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
|||
uint64_t man_normal_learning;
|
||||
int res = 0;
|
||||
|
||||
if(strcmp(mfname, "") == 0) {
|
||||
|
||||
if(strcmp(mfname, "") == 0) {
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
switch(manufacture_code->type) {
|
||||
|
@ -486,7 +491,8 @@ if(strcmp(mfname, "") == 0) {
|
|||
case KEELOQ_LEARNING_NORMAL:
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
|
@ -520,7 +526,8 @@ if(strcmp(mfname, "") == 0) {
|
|||
//###########################
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
|
@ -540,83 +547,91 @@ if(strcmp(mfname, "") == 0) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(mfname, "Unknown") == 0) {
|
||||
} else if(strcmp(mfname, "Unknown") == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
res = strcmp(string_get_cstr(manufacture_code->name), mfname);
|
||||
if(res == 0) {
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_SIMPLE:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
uint64_t man_rev = 0;
|
||||
uint64_t man_rev_byte = 0;
|
||||
for(uint8_t i = 0; i < 64; i += 8) {
|
||||
man_rev_byte = (uint8_t)(manufacture_code->key >> i);
|
||||
man_rev = man_rev | man_rev_byte << (56 - i);
|
||||
}
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
//###########################
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning = subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_SIMPLE:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
uint64_t man_rev = 0;
|
||||
uint64_t man_rev_byte = 0;
|
||||
for(uint8_t i = 0; i < 64; i += 8) {
|
||||
man_rev_byte = (uint8_t)(manufacture_code->key >> i);
|
||||
man_rev = man_rev | man_rev_byte << (56 - i);
|
||||
}
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
//###########################
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check for mirrored man
|
||||
man_normal_learning = subghz_protocol_keeloq_common_normal_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
// Check for mirrored man
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = string_get_cstr(manufacture_code->name);
|
||||
mfname = *manufacture_name;
|
||||
kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*manufacture_name = "Unknown";
|
||||
|
|
|
@ -9,9 +9,14 @@ void set_random_name(char* name, uint8_t max_name_size) {
|
|||
FuriHalRtcDateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
char strings[1][25];
|
||||
sprintf(strings[0], "%s%.4d%.2d%.2d%.2d%.2d", "s"
|
||||
, datetime.year, datetime.month, datetime.day
|
||||
, datetime.hour, datetime.minute
|
||||
);
|
||||
sprintf(
|
||||
strings[0],
|
||||
"%s%.4d%.2d%.2d%.2d%.2d",
|
||||
"s",
|
||||
datetime.year,
|
||||
datetime.month,
|
||||
datetime.day,
|
||||
datetime.hour,
|
||||
datetime.minute);
|
||||
sniprintf(name, max_name_size, "%s", strings[0]);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue