mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 13:09:49 +04:00
Compare commits
44 Commits
un1-8fdee1
...
un2-f61a8f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a7fa30199 | ||
|
|
e4cdae4922 | ||
|
|
c7a67c1308 | ||
|
|
fd3e70492d | ||
|
|
a4ee73b470 | ||
|
|
8f5cbdc4c2 | ||
|
|
6d999abb80 | ||
|
|
89d49fdba7 | ||
|
|
04d67ca8ae | ||
|
|
4f7ca617cc | ||
|
|
f61a8fda53 | ||
|
|
5e35e51c57 | ||
|
|
dfbe21e720 | ||
|
|
18e7d2eb41 | ||
|
|
e7aaf3dbb2 | ||
|
|
d2018dfa1d | ||
|
|
8ec5527ae4 | ||
|
|
3a50021348 | ||
|
|
20c63664ca | ||
|
|
9b6abd8ef0 | ||
|
|
f96f2e2411 | ||
|
|
6442caa3e4 | ||
|
|
f06930e4ae | ||
|
|
865baed0bb | ||
|
|
f81999ea4a | ||
|
|
89a4b77e73 | ||
|
|
ead9f134f4 | ||
|
|
9ff29d12b2 | ||
|
|
5f3637ca44 | ||
|
|
effcb445ce | ||
|
|
55bad280ee | ||
|
|
b003ede76c | ||
|
|
57362b3eab | ||
|
|
cb0d9ec591 | ||
|
|
dad4772bec | ||
|
|
a16542cda6 | ||
|
|
a5d22154a9 | ||
|
|
ce173fd44c | ||
|
|
d547307357 | ||
|
|
c198a51b1c | ||
|
|
d5b239595f | ||
|
|
947e44ce86 | ||
|
|
55f8beef9f | ||
|
|
e46e6f8ee9 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,11 +1,19 @@
|
||||
### New changes
|
||||
* PR: Feature: lock device with pin by long pressing up button (by @an4tur0r | PR #107)
|
||||
* SubGHz: Keeloq - added support for FAAC RC,XT, Mutancode, Normstahl
|
||||
* LFRFID: CLI - Add raw_analyze to usage help
|
||||
* PR -> Plugins: Minesweeper: Set cursor to initial position on death (by @TQMatvey | PR #113)
|
||||
* PR -> Plugins: Flappy bird: Border hitboxes, bigger Pilars (by @TQMatvey | PR #114)
|
||||
* Plugins: Updated Minesweeper [(by panki27)](https://github.com/panki27/minesweeper)
|
||||
* Plugins: Added DTMF Dolphin [(by litui)](https://github.com/litui/dtmf_dolphin)
|
||||
* Plugins: Updated TOTP (Authenticator) [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator)
|
||||
* OFW PR: scripts: simpler tar format (OFW PR 1871 by hedger)
|
||||
* OFW PR: Updated: MFC Improvements Part 2/2 (OFW PR 1868 by Astrrra)
|
||||
* OFW: Dolphin: add L1_Painting animation
|
||||
* OFW: fbt: more fixes & improvements
|
||||
* OFW: Badusb: show script errors on screen
|
||||
* Infrared: Updated universal remote assets (by @Amec0e)
|
||||
* OFW: Feature: infrared add remote to cli
|
||||
* OFW: Remove the back button from MFC keys list
|
||||
* OFW: NFC fixes part 3
|
||||
* OFW: Enable all `view_` methods in SDK
|
||||
* OFW: fbt: fix for cincludes in app's private library definition
|
||||
* OFW: Desktop: fix fap in settings
|
||||
* OFW: Add BLE disconnect request
|
||||
|
||||
#### [🎲 Download extra apps pack](https://download-directory.github.io/?url=https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed)
|
||||
|
||||
@@ -14,6 +22,7 @@
|
||||
[-> Download qFlipper 1.2.1 (allows .tgz installation) (official link)](https://update.flipperzero.one/builds/qFlipper/1.2.1/)
|
||||
|
||||
## Please support development of the project
|
||||
* Boosty: https://boosty.to/mmxdev
|
||||
* ETH/BSC/ERC20-Tokens: `0xFebF1bBc8229418FF2408C07AF6Afa49152fEc6a`
|
||||
* BTC: `bc1q0np836jk9jwr4dd7p6qv66d04vamtqkxrecck9`
|
||||
* DOGE: `D6R6gYgBn5LwTNmPyvAQR6bZ9EtGgFCpvv`
|
||||
|
||||
@@ -46,10 +46,14 @@ Also check changelog in releases for latest updates!
|
||||
### Current modified and new SubGHz protocols list:
|
||||
- Keeloq [Not ALL systems supported for decode or emulation yet!] - [Supported manufacturers list](https://0bin.net/paste/VwR2lNJY#WH9vnPgvcp7w6zVKucFCuNREKAcOij8KsJ6vqLfMn3b)
|
||||
- Keeloq: HCS101
|
||||
- Keeloq: An-Motors
|
||||
- Keeloq: AN-Motors
|
||||
- Keeloq: JCM Tech
|
||||
- Keeloq: MHouse
|
||||
- Keeloq: Nice Smilo
|
||||
- Keeloq: DTM Neo
|
||||
- Keeloq: FAAC RC,XT
|
||||
- Keeloq: Mutancode
|
||||
- Keeloq: Normstahl
|
||||
- CAME Atomo
|
||||
- Nice Flor S
|
||||
- FAAC SLH (Spa) [External seed calculation required (For info conatct me in Discord: Nano#8998)]
|
||||
@@ -58,6 +62,7 @@ Also check changelog in releases for latest updates!
|
||||
- Star Line (saving only)
|
||||
|
||||
## Support us so we can buy equipment and develop new features
|
||||
* Boosty: https://boosty.to/mmxdev
|
||||
* ETH/BSC/ERC20-Tokens: `0xFebF1bBc8229418FF2408C07AF6Afa49152fEc6a`
|
||||
* BTC: `bc1q0np836jk9jwr4dd7p6qv66d04vamtqkxrecck9`
|
||||
* DOGE: `D6R6gYgBn5LwTNmPyvAQR6bZ9EtGgFCpvv`
|
||||
@@ -81,6 +86,7 @@ Also check changelog in releases for latest updates!
|
||||
- UniversalRF Remix / Sub-GHz Remote [(by ESurge)](https://github.com/ESurge/flipperzero-firmware-unirfremix)[(updated and all protocol support added by darmiel & xMasterX)](https://github.com/darmiel/flipper-playlist/tree/feat/unirf-protocols)
|
||||
- Spectrum Analyzer (with changes) [(by jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) - [Ultra Narrow mode & scan channels non-consecutively](https://github.com/theY4Kman/flipperzero-firmware/commits?author=theY4Kman)
|
||||
- Metronome [(by panki27)](https://github.com/panki27/Metronome)
|
||||
- DTMF Dolphin [(by litui)](https://github.com/litui/dtmf_dolphin)
|
||||
- **TOTP (Authenticator)** [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator)
|
||||
|
||||
Games:
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define NFC_TEST_RESOURCES_DIR EXT_PATH("unit_tests/nfc/")
|
||||
#define NFC_TEST_SIGNAL_SHORT_FILE "nfc_nfca_signal_short.nfc"
|
||||
#define NFC_TEST_SIGNAL_LONG_FILE "nfc_nfca_signal_long.nfc"
|
||||
#define NFC_TEST_DICT_PATH EXT_PATH("unit_tests/mf_classic_dict.nfc")
|
||||
|
||||
static const char* nfc_test_file_type = "Flipper NFC test";
|
||||
static const uint32_t nfc_test_file_version = 1;
|
||||
@@ -220,11 +221,78 @@ MU_TEST(mf_classic_dict_test) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
MU_TEST(mf_classic_dict_load_test) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
mu_assert(storage != NULL, "storage != NULL assert failed\r\n");
|
||||
|
||||
// Delete unit test dict file if exists
|
||||
if(storage_file_exists(storage, NFC_TEST_DICT_PATH)) {
|
||||
mu_assert(
|
||||
storage_simply_remove(storage, NFC_TEST_DICT_PATH),
|
||||
"remove == true assert failed\r\n");
|
||||
}
|
||||
|
||||
// Create unit test dict file
|
||||
Stream* file_stream = file_stream_alloc(storage);
|
||||
mu_assert(file_stream != NULL, "file_stream != NULL assert failed\r\n");
|
||||
mu_assert(
|
||||
file_stream_open(file_stream, NFC_TEST_DICT_PATH, FSAM_WRITE, FSOM_OPEN_ALWAYS),
|
||||
"file_stream_open == true assert failed\r\n");
|
||||
|
||||
// Write unit test dict file
|
||||
char key_str[] = "a0a1a2a3a4a5";
|
||||
mu_assert(
|
||||
stream_write_cstring(file_stream, key_str) == strlen(key_str),
|
||||
"write == true assert failed\r\n");
|
||||
// Close unit test dict file
|
||||
mu_assert(file_stream_close(file_stream), "file_stream_close == true assert failed\r\n");
|
||||
|
||||
// Load unit test dict file
|
||||
MfClassicDict* instance = NULL;
|
||||
instance = mf_classic_dict_alloc(MfClassicDictTypeUnitTest);
|
||||
mu_assert(instance != NULL, "mf_classic_dict_alloc\r\n");
|
||||
uint32_t total_keys = mf_classic_dict_get_total_keys(instance);
|
||||
mu_assert(total_keys == 1, "total_keys == 1 assert failed\r\n");
|
||||
|
||||
// Read key
|
||||
uint64_t key_ref = 0xa0a1a2a3a4a5;
|
||||
uint64_t key_dut = 0;
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
mu_assert(
|
||||
mf_classic_dict_get_next_key_str(instance, temp_str),
|
||||
"get_next_key_str == true assert failed\r\n");
|
||||
mu_assert(furi_string_cmp_str(temp_str, key_str) == 0, "invalid key loaded\r\n");
|
||||
mu_assert(mf_classic_dict_rewind(instance), "mf_classic_dict_rewind == 1 assert failed\r\n");
|
||||
mu_assert(
|
||||
mf_classic_dict_get_next_key(instance, &key_dut),
|
||||
"get_next_key == true assert failed\r\n");
|
||||
mu_assert(key_dut == key_ref, "invalid key loaded\r\n");
|
||||
furi_string_free(temp_str);
|
||||
mf_classic_dict_free(instance);
|
||||
|
||||
// Check that MfClassicDict added new line to the end of the file
|
||||
mu_assert(
|
||||
file_stream_open(file_stream, NFC_TEST_DICT_PATH, FSAM_READ, FSOM_OPEN_EXISTING),
|
||||
"file_stream_open == true assert failed\r\n");
|
||||
mu_assert(stream_seek(file_stream, -1, StreamOffsetFromEnd), "seek == true assert failed\r\n");
|
||||
uint8_t last_char = 0;
|
||||
mu_assert(stream_read(file_stream, &last_char, 1) == 1, "read == true assert failed\r\n");
|
||||
mu_assert(last_char == '\n', "last_char == '\\n' assert failed\r\n");
|
||||
mu_assert(file_stream_close(file_stream), "file_stream_close == true assert failed\r\n");
|
||||
|
||||
// Delete unit test dict file
|
||||
mu_assert(
|
||||
storage_simply_remove(storage, NFC_TEST_DICT_PATH), "remove == true assert failed\r\n");
|
||||
stream_free(file_stream);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(nfc) {
|
||||
nfc_test_alloc();
|
||||
|
||||
MU_RUN_TEST(nfc_digital_signal_test);
|
||||
MU_RUN_TEST(mf_classic_dict_test);
|
||||
MU_RUN_TEST(mf_classic_dict_load_test);
|
||||
|
||||
nfc_test_free();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ App(
|
||||
name="Applications",
|
||||
apptype=FlipperAppType.APP,
|
||||
entry_point="fap_loader_app",
|
||||
cdefines=["APP_FAP_LOADER"],
|
||||
requires=[
|
||||
"gui",
|
||||
"storage",
|
||||
|
||||
@@ -101,7 +101,7 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
|
||||
}
|
||||
|
||||
FURI_LOG_I(TAG, "Loaded in %ums", (size_t)(furi_get_tick() - start));
|
||||
FURI_LOG_I(TAG, "FAP Loader is staring app");
|
||||
FURI_LOG_I(TAG, "FAP Loader is starting app");
|
||||
|
||||
FuriThread* thread = flipper_application_spawn(loader->app, NULL);
|
||||
furi_thread_start(thread);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <cli/cli.h>
|
||||
#include <cli/cli_i.h>
|
||||
#include <infrared.h>
|
||||
#include <infrared_worker.h>
|
||||
#include <furi_hal_infrared.h>
|
||||
@@ -6,12 +7,24 @@
|
||||
#include <toolbox/args.h>
|
||||
|
||||
#include "infrared_signal.h"
|
||||
#include "infrared_brute_force.h"
|
||||
|
||||
#include "m-dict.h"
|
||||
#include "m-string.h"
|
||||
|
||||
#define INFRARED_CLI_BUF_SIZE 10
|
||||
|
||||
DICT_DEF2(dict_signals, string_t, STRING_OPLIST, int, M_DEFAULT_OPLIST)
|
||||
|
||||
enum RemoteTypes { TV = 0, AC = 1 };
|
||||
|
||||
static void infrared_cli_start_ir_rx(Cli* cli, FuriString* args);
|
||||
static void infrared_cli_start_ir_tx(Cli* cli, FuriString* args);
|
||||
static void infrared_cli_process_decode(Cli* cli, FuriString* args);
|
||||
static void infrared_cli_process_universal(Cli* cli, FuriString* args);
|
||||
static void infrared_cli_list_remote_signals(enum RemoteTypes remote_type);
|
||||
static void
|
||||
infrared_cli_brute_force_signals(Cli* cli, enum RemoteTypes remote_type, FuriString* signal);
|
||||
|
||||
static const struct {
|
||||
const char* cmd;
|
||||
@@ -20,6 +33,7 @@ static const struct {
|
||||
{.cmd = "rx", .process_function = infrared_cli_start_ir_rx},
|
||||
{.cmd = "tx", .process_function = infrared_cli_start_ir_tx},
|
||||
{.cmd = "decode", .process_function = infrared_cli_process_decode},
|
||||
{.cmd = "universal", .process_function = infrared_cli_process_universal},
|
||||
};
|
||||
|
||||
static void signal_received_callback(void* context, InfraredWorkerSignal* received_signal) {
|
||||
@@ -90,6 +104,8 @@ static void infrared_cli_print_usage(void) {
|
||||
INFRARED_MIN_FREQUENCY,
|
||||
INFRARED_MAX_FREQUENCY);
|
||||
printf("\tir decode <input_file> [<output_file>]\r\n");
|
||||
printf("\tir universal <tv, ac> <signal name>\r\n");
|
||||
printf("\tir universal list <tv, ac>\r\n");
|
||||
}
|
||||
|
||||
static bool infrared_cli_parse_message(const char* str, InfraredSignal* signal) {
|
||||
@@ -328,6 +344,168 @@ static void infrared_cli_process_decode(Cli* cli, FuriString* args) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void infrared_cli_process_universal(Cli* cli, FuriString* args) {
|
||||
enum RemoteTypes Remote;
|
||||
|
||||
FuriString* command;
|
||||
FuriString* remote;
|
||||
FuriString* signal;
|
||||
command = furi_string_alloc();
|
||||
remote = furi_string_alloc();
|
||||
signal = furi_string_alloc();
|
||||
|
||||
do {
|
||||
if(!args_read_string_and_trim(args, command)) {
|
||||
infrared_cli_print_usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(furi_string_cmp_str(command, "list") == 0) {
|
||||
args_read_string_and_trim(args, remote);
|
||||
if(furi_string_cmp_str(remote, "tv") == 0) {
|
||||
Remote = TV;
|
||||
} else if(furi_string_cmp_str(remote, "ac") == 0) {
|
||||
Remote = AC;
|
||||
} else {
|
||||
printf("Invalid remote type.\r\n");
|
||||
break;
|
||||
}
|
||||
infrared_cli_list_remote_signals(Remote);
|
||||
break;
|
||||
}
|
||||
|
||||
if(furi_string_cmp_str(command, "tv") == 0) {
|
||||
Remote = TV;
|
||||
} else if(furi_string_cmp_str(command, "ac") == 0) {
|
||||
Remote = AC;
|
||||
} else {
|
||||
printf("Invalid remote type.\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
args_read_string_and_trim(args, signal);
|
||||
if(furi_string_empty(signal)) {
|
||||
printf("Must supply a valid signal for type of remote selected.\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
infrared_cli_brute_force_signals(cli, Remote, signal);
|
||||
break;
|
||||
|
||||
} while(false);
|
||||
|
||||
furi_string_free(command);
|
||||
furi_string_free(remote);
|
||||
furi_string_free(signal);
|
||||
}
|
||||
|
||||
static void infrared_cli_list_remote_signals(enum RemoteTypes remote_type) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* ff = flipper_format_buffered_file_alloc(storage);
|
||||
dict_signals_t signals_dict;
|
||||
string_t key;
|
||||
const char* remote_file = NULL;
|
||||
bool success = false;
|
||||
int max = 1;
|
||||
|
||||
switch(remote_type) {
|
||||
case TV:
|
||||
remote_file = EXT_PATH("infrared/assets/tv.ir");
|
||||
break;
|
||||
case AC:
|
||||
remote_file = EXT_PATH("infrared/assets/ac.ir");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dict_signals_init(signals_dict);
|
||||
string_init(key);
|
||||
|
||||
success = flipper_format_buffered_file_open_existing(ff, remote_file);
|
||||
if(success) {
|
||||
FuriString* signal_name;
|
||||
signal_name = furi_string_alloc();
|
||||
printf("Valid signals:\r\n");
|
||||
while(flipper_format_read_string(ff, "name", signal_name)) {
|
||||
string_set_str(key, furi_string_get_cstr(signal_name));
|
||||
int* v = dict_signals_get(signals_dict, key);
|
||||
if(v != NULL) {
|
||||
(*v)++;
|
||||
max = M_MAX(*v, max);
|
||||
} else {
|
||||
dict_signals_set_at(signals_dict, key, 1);
|
||||
}
|
||||
}
|
||||
dict_signals_it_t it;
|
||||
for(dict_signals_it(it, signals_dict); !dict_signals_end_p(it); dict_signals_next(it)) {
|
||||
const struct dict_signals_pair_s* pair = dict_signals_cref(it);
|
||||
printf("\t%s\r\n", string_get_cstr(pair->key));
|
||||
}
|
||||
furi_string_free(signal_name);
|
||||
}
|
||||
|
||||
string_clear(key);
|
||||
dict_signals_clear(signals_dict);
|
||||
flipper_format_free(ff);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void
|
||||
infrared_cli_brute_force_signals(Cli* cli, enum RemoteTypes remote_type, FuriString* signal) {
|
||||
InfraredBruteForce* brute_force = infrared_brute_force_alloc();
|
||||
const char* remote_file = NULL;
|
||||
uint32_t i = 0;
|
||||
bool success = false;
|
||||
|
||||
switch(remote_type) {
|
||||
case TV:
|
||||
remote_file = EXT_PATH("infrared/assets/tv.ir");
|
||||
break;
|
||||
case AC:
|
||||
remote_file = EXT_PATH("infrared/assets/ac.ir");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
infrared_brute_force_set_db_filename(brute_force, remote_file);
|
||||
infrared_brute_force_add_record(brute_force, i++, furi_string_get_cstr(signal));
|
||||
|
||||
success = infrared_brute_force_calculate_messages(brute_force);
|
||||
if(success) {
|
||||
uint32_t record_count;
|
||||
uint32_t index = 0;
|
||||
int records_sent = 0;
|
||||
bool running = false;
|
||||
|
||||
running = infrared_brute_force_start(brute_force, index, &record_count);
|
||||
if(record_count <= 0) {
|
||||
printf("Invalid signal.\n");
|
||||
infrared_brute_force_clear_records(brute_force);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Sending %ld codes to the tv.\r\n", record_count);
|
||||
printf("Press Ctrl-C to stop.\r\n");
|
||||
while(running) {
|
||||
running = infrared_brute_force_send_next(brute_force);
|
||||
|
||||
if(cli_cmd_interrupt_received(cli)) break;
|
||||
|
||||
printf("\r%d%% complete.", (int)((float)records_sent++ / (float)record_count * 100));
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
infrared_brute_force_stop(brute_force);
|
||||
} else {
|
||||
printf("Invalid signal.\r\n");
|
||||
}
|
||||
|
||||
infrared_brute_force_clear_records(brute_force);
|
||||
infrared_brute_force_free(brute_force);
|
||||
}
|
||||
|
||||
static void infrared_cli_start_ir(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(context);
|
||||
if(furi_hal_infrared_is_busy()) {
|
||||
|
||||
@@ -29,6 +29,7 @@ static void lfrfid_cli_print_usage() {
|
||||
printf("rfid <write | emulate> <key_type> <key_data>\r\n");
|
||||
printf("rfid raw_read <ask | psk> <filename>\r\n");
|
||||
printf("rfid raw_emulate <filename>\r\n");
|
||||
printf("rfid raw_analyze <filename>\r\n");
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -34,8 +34,6 @@ void nfc_scene_mf_classic_keys_on_enter(void* context) {
|
||||
widget_add_string_element(nfc->widget, 0, 32, AlignLeft, AlignTop, FontSecondary, temp_str);
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeCenter, "Add", nfc_scene_mf_classic_keys_widget_callback, nfc);
|
||||
widget_add_button_element(
|
||||
nfc->widget, GuiButtonTypeLeft, "Back", nfc_scene_mf_classic_keys_widget_callback, nfc);
|
||||
widget_add_icon_element(nfc->widget, 87, 13, &I_Keychain_39x36);
|
||||
if(user_dict_keys_total > 0) {
|
||||
widget_add_button_element(
|
||||
@@ -57,9 +55,6 @@ bool nfc_scene_mf_classic_keys_on_event(void* context, SceneManagerEvent event)
|
||||
if(event.event == GuiButtonTypeCenter) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicKeysAdd);
|
||||
consumed = true;
|
||||
} else if(event.event == GuiButtonTypeLeft) {
|
||||
scene_manager_previous_scene(nfc->scene_manager);
|
||||
consumed = true;
|
||||
} else if(event.event == GuiButtonTypeRight) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicKeysList);
|
||||
consumed = true;
|
||||
|
||||
@@ -24,9 +24,11 @@ typedef enum {
|
||||
SubmenuIndexLinear_300_00,
|
||||
SubmenuIndexLiftMaster_315_00,
|
||||
SubmenuIndexLiftMaster_390_00,
|
||||
SubmenuIndexLiftMaster_433_00,
|
||||
SubmenuIndexSecPlus_v2_310_00,
|
||||
SubmenuIndexSecPlus_v2_315_00,
|
||||
SubmenuIndexSecPlus_v2_390_00,
|
||||
SubmenuIndexSecPlus_v2_433_00,
|
||||
|
||||
//SubGhzCustomEvent
|
||||
SubGhzCustomEventSceneDeleteSuccess = 100,
|
||||
|
||||
@@ -167,6 +167,12 @@ void subghz_scene_set_type_on_enter(void* context) {
|
||||
SubmenuIndexLiftMaster_390_00,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Security+1.0 433MHz",
|
||||
SubmenuIndexLiftMaster_433_00,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Security+2.0 310MHz",
|
||||
@@ -185,6 +191,12 @@ void subghz_scene_set_type_on_enter(void* context) {
|
||||
SubmenuIndexSecPlus_v2_390_00,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Security+2.0 433MHz",
|
||||
SubmenuIndexSecPlus_v2_433_00,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType));
|
||||
@@ -359,6 +371,20 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexLiftMaster_433_00:
|
||||
while(!subghz_protocol_secplus_v1_check_fixed(key)) {
|
||||
key = subghz_random_serial();
|
||||
}
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz,
|
||||
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME,
|
||||
(uint64_t)key << 32 | 0xE6000000,
|
||||
42,
|
||||
433920000,
|
||||
"AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexSecPlus_v2_310_00:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||
@@ -413,6 +439,24 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
break;
|
||||
case SubmenuIndexSecPlus_v2_433_00:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||
subghz_preset_init(subghz, "AM650", 433920000, NULL, 0);
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_secplus_v2_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
key,
|
||||
0x68,
|
||||
0xE500000,
|
||||
subghz->txrx->preset);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
|
||||
674
applications/plugins/dtmf_dolphin/LICENSE
Normal file
674
applications/plugins/dtmf_dolphin/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
18
applications/plugins/dtmf_dolphin/README.md
Normal file
18
applications/plugins/dtmf_dolphin/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||

|
||||
|
||||
[Original Link](https://github.com/litui/dtmf_dolphin)
|
||||
|
||||
## DTMF Dolphin
|
||||
|
||||
DTMF (Dual-Tone Multi-Frequency) dialer, Bluebox, and Redbox.
|
||||
|
||||
Now in a release-ready state for both Dialer, Bluebox, and Redbox (US/UK) functionality!
|
||||
|
||||
Please note that using the current tone output method, the 2600 tone is scaled about 33 Hz higher than it should be. This is a limitation of the current sample rate.
|
||||
|
||||
### Educational Links:
|
||||
|
||||
* http://www.phrack.org/issues/25/7.html#article
|
||||
* https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling
|
||||
* https://en.wikipedia.org/wiki/Blue_box
|
||||
* https://en.wikipedia.org/wiki/Red_box_(phreaking)
|
||||
16
applications/plugins/dtmf_dolphin/application.fam
Normal file
16
applications/plugins/dtmf_dolphin/application.fam
Normal file
@@ -0,0 +1,16 @@
|
||||
App(
|
||||
appid="dtmf_dolphin",
|
||||
name="DTMF Dolphin",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="dtmf_dolphin_app",
|
||||
cdefines=["DTMF_DOLPHIN"],
|
||||
requires=[
|
||||
"storage",
|
||||
"gui",
|
||||
"dialogs",
|
||||
],
|
||||
fap_icon="phone.png",
|
||||
stack_size=8 * 1024,
|
||||
order=20,
|
||||
fap_category="Tools",
|
||||
)
|
||||
89
applications/plugins/dtmf_dolphin/dtmf_dolphin.c
Normal file
89
applications/plugins/dtmf_dolphin/dtmf_dolphin.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "dtmf_dolphin_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
static bool dtmf_dolphin_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
DTMFDolphinApp* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
static bool dtmf_dolphin_app_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
DTMFDolphinApp* app = context;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static void dtmf_dolphin_app_tick_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
DTMFDolphinApp* app = context;
|
||||
|
||||
scene_manager_handle_tick_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static DTMFDolphinApp* app_alloc() {
|
||||
DTMFDolphinApp* app = malloc(sizeof(DTMFDolphinApp));
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&dtmf_dolphin_scene_handlers, app);
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
app->view_dispatcher, dtmf_dolphin_app_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
app->view_dispatcher, dtmf_dolphin_app_back_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(
|
||||
app->view_dispatcher, dtmf_dolphin_app_tick_event_callback, 100);
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
app->main_menu_list = variable_item_list_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
DTMFDolphinViewMainMenu,
|
||||
variable_item_list_get_view(app->main_menu_list));
|
||||
|
||||
app->dtmf_dolphin_dialer = dtmf_dolphin_dialer_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
DTMFDolphinViewDialer,
|
||||
dtmf_dolphin_dialer_get_view(app->dtmf_dolphin_dialer));
|
||||
|
||||
app->notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(app->notification, &sequence_display_backlight_enforce_on);
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneStart);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void app_free(DTMFDolphinApp* app) {
|
||||
furi_assert(app);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DTMFDolphinViewMainMenu);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, DTMFDolphinViewDialer);
|
||||
variable_item_list_free(app->main_menu_list);
|
||||
|
||||
dtmf_dolphin_dialer_free(app->dtmf_dolphin_dialer);
|
||||
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
scene_manager_free(app->scene_manager);
|
||||
|
||||
notification_message(app->notification, &sequence_display_backlight_enforce_auto);
|
||||
|
||||
furi_record_close(RECORD_GUI);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t dtmf_dolphin_app(void* p) {
|
||||
UNUSED(p);
|
||||
DTMFDolphinApp* app = app_alloc();
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
app_free(app);
|
||||
return 0;
|
||||
}
|
||||
265
applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.c
Normal file
265
applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.c
Normal file
@@ -0,0 +1,265 @@
|
||||
#include "dtmf_dolphin_audio.h"
|
||||
|
||||
DTMFDolphinAudio* current_player;
|
||||
|
||||
static void dtmf_dolphin_audio_dma_isr(void* ctx) {
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
|
||||
if(LL_DMA_IsActiveFlag_HT1(DMA1)) {
|
||||
LL_DMA_ClearFlag_HT1(DMA1);
|
||||
|
||||
DTMFDolphinCustomEvent event = {.type = DTMFDolphinEventDMAHalfTransfer};
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
|
||||
if(LL_DMA_IsActiveFlag_TC1(DMA1)) {
|
||||
LL_DMA_ClearFlag_TC1(DMA1);
|
||||
|
||||
DTMFDolphinCustomEvent event = {.type = DTMFDolphinEventDMAFullTransfer};
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void dtmf_dolphin_audio_clear_samples(DTMFDolphinAudio* player) {
|
||||
for(size_t i = 0; i < player->buffer_length; i++) {
|
||||
player->sample_buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DTMFDolphinOsc* dtmf_dolphin_osc_alloc() {
|
||||
DTMFDolphinOsc* osc = malloc(sizeof(DTMFDolphinOsc));
|
||||
osc->cached_freq = 0;
|
||||
osc->offset = 0;
|
||||
osc->period = 0;
|
||||
osc->lookup_table = NULL;
|
||||
return osc;
|
||||
}
|
||||
|
||||
DTMFDolphinPulseFilter* dtmf_dolphin_pulse_filter_alloc() {
|
||||
DTMFDolphinPulseFilter* pf = malloc(sizeof(DTMFDolphinPulseFilter));
|
||||
pf->duration = 0;
|
||||
pf->period = 0;
|
||||
pf->offset = 0;
|
||||
pf->lookup_table = NULL;
|
||||
return pf;
|
||||
}
|
||||
|
||||
DTMFDolphinAudio* dtmf_dolphin_audio_alloc() {
|
||||
DTMFDolphinAudio* player = malloc(sizeof(DTMFDolphinAudio));
|
||||
player->buffer_length = SAMPLE_BUFFER_LENGTH;
|
||||
player->half_buffer_length = SAMPLE_BUFFER_LENGTH / 2;
|
||||
player->sample_buffer = malloc(sizeof(uint16_t) * player->buffer_length);
|
||||
player->osc1 = dtmf_dolphin_osc_alloc();
|
||||
player->osc2 = dtmf_dolphin_osc_alloc();
|
||||
player->volume = 1.0f;
|
||||
player->queue = furi_message_queue_alloc(10, sizeof(DTMFDolphinCustomEvent));
|
||||
player->filter = dtmf_dolphin_pulse_filter_alloc();
|
||||
player->playing = false;
|
||||
dtmf_dolphin_audio_clear_samples(player);
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
size_t calc_waveform_period(float freq) {
|
||||
if(!freq) {
|
||||
return 0;
|
||||
}
|
||||
// DMA Rate calculation, thanks to Dr_Zlo
|
||||
float dma_rate = CPU_CLOCK_FREQ / 2 / DTMF_DOLPHIN_HAL_DMA_PRESCALER /
|
||||
(DTMF_DOLPHIN_HAL_DMA_AUTORELOAD + 1);
|
||||
|
||||
// Using a constant scaling modifier, which likely represents
|
||||
// the combined system overhead and isr latency.
|
||||
return (uint16_t)dma_rate * 2 / freq * 0.801923;
|
||||
}
|
||||
|
||||
void osc_generate_lookup_table(DTMFDolphinOsc* osc, float freq) {
|
||||
if(osc->lookup_table != NULL) {
|
||||
free(osc->lookup_table);
|
||||
}
|
||||
osc->offset = 0;
|
||||
osc->cached_freq = freq;
|
||||
osc->period = calc_waveform_period(freq);
|
||||
if(!osc->period) {
|
||||
osc->lookup_table = NULL;
|
||||
return;
|
||||
}
|
||||
osc->lookup_table = malloc(sizeof(float) * osc->period);
|
||||
|
||||
for(size_t i = 0; i < osc->period; i++) {
|
||||
osc->lookup_table[i] = sin(i * PERIOD_2_PI / osc->period) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void filter_generate_lookup_table(
|
||||
DTMFDolphinPulseFilter* pf,
|
||||
uint16_t pulses,
|
||||
uint16_t pulse_ms,
|
||||
uint16_t gap_ms) {
|
||||
if(pf->lookup_table != NULL) {
|
||||
free(pf->lookup_table);
|
||||
}
|
||||
pf->offset = 0;
|
||||
|
||||
uint16_t gap_period = calc_waveform_period(1000 / (float)gap_ms);
|
||||
uint16_t pulse_period = calc_waveform_period(1000 / (float)pulse_ms);
|
||||
pf->period = pulse_period + gap_period;
|
||||
|
||||
if(!pf->period) {
|
||||
pf->lookup_table = NULL;
|
||||
return;
|
||||
}
|
||||
pf->duration = pf->period * pulses;
|
||||
pf->lookup_table = malloc(sizeof(bool) * pf->duration);
|
||||
|
||||
for(size_t i = 0; i < pf->duration; i++) {
|
||||
pf->lookup_table[i] = i % pf->period < pulse_period;
|
||||
}
|
||||
}
|
||||
|
||||
float sample_frame(DTMFDolphinOsc* osc) {
|
||||
float frame = 0.0;
|
||||
|
||||
if(osc->period) {
|
||||
frame = osc->lookup_table[osc->offset];
|
||||
osc->offset = (osc->offset + 1) % osc->period;
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
bool sample_filter(DTMFDolphinPulseFilter* pf) {
|
||||
bool frame = true;
|
||||
|
||||
if(pf->duration) {
|
||||
if(pf->offset < pf->duration) {
|
||||
frame = pf->lookup_table[pf->offset];
|
||||
pf->offset = pf->offset + 1;
|
||||
} else {
|
||||
frame = false;
|
||||
}
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
void dtmf_dolphin_osc_free(DTMFDolphinOsc* osc) {
|
||||
if(osc->lookup_table != NULL) {
|
||||
free(osc->lookup_table);
|
||||
}
|
||||
free(osc);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_filter_free(DTMFDolphinPulseFilter* pf) {
|
||||
if(pf->lookup_table != NULL) {
|
||||
free(pf->lookup_table);
|
||||
}
|
||||
free(pf);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_audio_free(DTMFDolphinAudio* player) {
|
||||
furi_message_queue_free(player->queue);
|
||||
dtmf_dolphin_osc_free(player->osc1);
|
||||
dtmf_dolphin_osc_free(player->osc2);
|
||||
dtmf_dolphin_filter_free(player->filter);
|
||||
free(player->sample_buffer);
|
||||
free(player);
|
||||
current_player = NULL;
|
||||
}
|
||||
|
||||
bool generate_waveform(DTMFDolphinAudio* player, uint16_t buffer_index) {
|
||||
uint16_t* sample_buffer_start = &player->sample_buffer[buffer_index];
|
||||
|
||||
for(size_t i = 0; i < player->half_buffer_length; i++) {
|
||||
float data = 0;
|
||||
if(player->osc2->period) {
|
||||
data = (sample_frame(player->osc1) / 2) + (sample_frame(player->osc2) / 2);
|
||||
} else {
|
||||
data = (sample_frame(player->osc1));
|
||||
}
|
||||
data *= sample_filter(player->filter) ? player->volume : 0.0;
|
||||
data *= UINT8_MAX / 2; // scale -128..127
|
||||
data += UINT8_MAX / 2; // to unsigned
|
||||
|
||||
if(data < 0) {
|
||||
data = 0;
|
||||
}
|
||||
|
||||
if(data > 255) {
|
||||
data = 255;
|
||||
}
|
||||
|
||||
sample_buffer_start[i] = data;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_audio_play_tones(
|
||||
float freq1,
|
||||
float freq2,
|
||||
uint16_t pulses,
|
||||
uint16_t pulse_ms,
|
||||
uint16_t gap_ms) {
|
||||
if(current_player != NULL && current_player->playing) {
|
||||
// Cannot start playing while still playing something else
|
||||
return false;
|
||||
}
|
||||
current_player = dtmf_dolphin_audio_alloc();
|
||||
|
||||
osc_generate_lookup_table(current_player->osc1, freq1);
|
||||
osc_generate_lookup_table(current_player->osc2, freq2);
|
||||
filter_generate_lookup_table(current_player->filter, pulses, pulse_ms, gap_ms);
|
||||
|
||||
generate_waveform(current_player, 0);
|
||||
generate_waveform(current_player, current_player->half_buffer_length);
|
||||
|
||||
dtmf_dolphin_speaker_init();
|
||||
dtmf_dolphin_dma_init((uint32_t)current_player->sample_buffer, current_player->buffer_length);
|
||||
|
||||
furi_hal_interrupt_set_isr(
|
||||
FuriHalInterruptIdDma1Ch1, dtmf_dolphin_audio_dma_isr, current_player->queue);
|
||||
|
||||
dtmf_dolphin_dma_start();
|
||||
dtmf_dolphin_speaker_start();
|
||||
current_player->playing = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_audio_stop_tones() {
|
||||
if(current_player != NULL && !current_player->playing) {
|
||||
// Can't stop a player that isn't playing.
|
||||
return false;
|
||||
}
|
||||
while(current_player->filter->offset > 0 &&
|
||||
current_player->filter->offset < current_player->filter->duration) {
|
||||
// run remaining ticks if needed to complete filter sequence
|
||||
dtmf_dolphin_audio_handle_tick();
|
||||
}
|
||||
dtmf_dolphin_speaker_stop();
|
||||
dtmf_dolphin_dma_stop();
|
||||
|
||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL);
|
||||
|
||||
dtmf_dolphin_audio_free(current_player);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_audio_handle_tick() {
|
||||
bool handled = false;
|
||||
|
||||
if(current_player) {
|
||||
DTMFDolphinCustomEvent event;
|
||||
if(furi_message_queue_get(current_player->queue, &event, 250) == FuriStatusOk) {
|
||||
if(event.type == DTMFDolphinEventDMAHalfTransfer) {
|
||||
generate_waveform(current_player, 0);
|
||||
handled = true;
|
||||
} else if(event.type == DTMFDolphinEventDMAFullTransfer) {
|
||||
generate_waveform(current_player, current_player->half_buffer_length);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
54
applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.h
Normal file
54
applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
// #include "dtmf_dolphin_i.h"
|
||||
#include "dtmf_dolphin_event.h"
|
||||
#include "dtmf_dolphin_hal.h"
|
||||
|
||||
#define SAMPLE_BUFFER_LENGTH 8192
|
||||
#define PERIOD_2_PI 6.2832
|
||||
#define CPU_CLOCK_FREQ 64000000
|
||||
|
||||
typedef struct {
|
||||
float cached_freq;
|
||||
size_t period;
|
||||
float* lookup_table;
|
||||
uint16_t offset;
|
||||
} DTMFDolphinOsc;
|
||||
|
||||
typedef struct {
|
||||
float duration;
|
||||
size_t period;
|
||||
bool* lookup_table;
|
||||
uint16_t offset;
|
||||
} DTMFDolphinPulseFilter;
|
||||
|
||||
typedef struct {
|
||||
size_t buffer_length;
|
||||
size_t half_buffer_length;
|
||||
uint8_t* buffer_buffer;
|
||||
uint16_t* sample_buffer;
|
||||
float volume;
|
||||
FuriMessageQueue* queue;
|
||||
DTMFDolphinOsc* osc1;
|
||||
DTMFDolphinOsc* osc2;
|
||||
DTMFDolphinPulseFilter* filter;
|
||||
bool playing;
|
||||
} DTMFDolphinAudio;
|
||||
|
||||
DTMFDolphinOsc* dtmf_dolphin_osc_alloc();
|
||||
|
||||
DTMFDolphinAudio* dtmf_dolphin_audio_alloc();
|
||||
|
||||
void dtmf_dolphin_audio_free(DTMFDolphinAudio* player);
|
||||
|
||||
void dtmf_dolphin_osc_free(DTMFDolphinOsc* osc);
|
||||
|
||||
bool dtmf_dolphin_audio_play_tones(
|
||||
float freq1,
|
||||
float freq2,
|
||||
uint16_t pulses,
|
||||
uint16_t pulse_ms,
|
||||
uint16_t gap_ms);
|
||||
|
||||
bool dtmf_dolphin_audio_stop_tones();
|
||||
|
||||
bool dtmf_dolphin_audio_handle_tick();
|
||||
207
applications/plugins/dtmf_dolphin/dtmf_dolphin_data.c
Normal file
207
applications/plugins/dtmf_dolphin/dtmf_dolphin_data.c
Normal file
@@ -0,0 +1,207 @@
|
||||
#include "dtmf_dolphin_data.h"
|
||||
|
||||
typedef struct {
|
||||
const uint8_t row;
|
||||
const uint8_t col;
|
||||
const uint8_t span;
|
||||
} DTMFDolphinTonePos;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
const float frequency_1;
|
||||
const float frequency_2;
|
||||
const DTMFDolphinTonePos pos;
|
||||
const uint16_t pulses; // for Redbox
|
||||
const uint16_t pulse_ms; // for Redbox
|
||||
const uint16_t gap_duration; // for Redbox
|
||||
} DTMFDolphinTones;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
DTMFDolphinToneSection block;
|
||||
uint8_t tone_count;
|
||||
DTMFDolphinTones tones[DTMF_DOLPHIN_MAX_TONE_COUNT];
|
||||
} DTMFDolphinSceneData;
|
||||
|
||||
DTMFDolphinSceneData DTMFDolphinSceneDataDialer = {
|
||||
.name = "Dialer",
|
||||
.block = DTMF_DOLPHIN_TONE_BLOCK_DIALER,
|
||||
.tone_count = 16,
|
||||
.tones = {
|
||||
{"1", 697.0, 1209.0, {0, 0, 1}, 0, 0, 0},
|
||||
{"2", 697.0, 1336.0, {0, 1, 1}, 0, 0, 0},
|
||||
{"3", 697.0, 1477.0, {0, 2, 1}, 0, 0, 0},
|
||||
{"A", 697.0, 1633.0, {0, 3, 1}, 0, 0, 0},
|
||||
{"4", 770.0, 1209.0, {1, 0, 1}, 0, 0, 0},
|
||||
{"5", 770.0, 1336.0, {1, 1, 1}, 0, 0, 0},
|
||||
{"6", 770.0, 1477.0, {1, 2, 1}, 0, 0, 0},
|
||||
{"B", 770.0, 1633.0, {1, 3, 1}, 0, 0, 0},
|
||||
{"7", 852.0, 1209.0, {2, 0, 1}, 0, 0, 0},
|
||||
{"8", 852.0, 1336.0, {2, 1, 1}, 0, 0, 0},
|
||||
{"9", 852.0, 1477.0, {2, 2, 1}, 0, 0, 0},
|
||||
{"C", 852.0, 1633.0, {2, 3, 1}, 0, 0, 0},
|
||||
{"*", 941.0, 1209.0, {3, 0, 1}, 0, 0, 0},
|
||||
{"0", 941.0, 1336.0, {3, 1, 1}, 0, 0, 0},
|
||||
{"#", 941.0, 1477.0, {3, 2, 1}, 0, 0, 0},
|
||||
{"D", 941.0, 1633.0, {3, 3, 1}, 0, 0, 0},
|
||||
}};
|
||||
|
||||
DTMFDolphinSceneData DTMFDolphinSceneDataBluebox = {
|
||||
.name = "Bluebox",
|
||||
.block = DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX,
|
||||
.tone_count = 13,
|
||||
.tones = {
|
||||
{"1", 700.0, 900.0, {0, 0, 1}, 0, 0, 0},
|
||||
{"2", 700.0, 1100.0, {0, 1, 1}, 0, 0, 0},
|
||||
{"3", 900.0, 1100.0, {0, 2, 1}, 0, 0, 0},
|
||||
{"4", 700.0, 1300.0, {1, 0, 1}, 0, 0, 0},
|
||||
{"5", 900.0, 1300.0, {1, 1, 1}, 0, 0, 0},
|
||||
{"6", 1100.0, 1300.0, {1, 2, 1}, 0, 0, 0},
|
||||
{"7", 700.0, 1500.0, {2, 0, 1}, 0, 0, 0},
|
||||
{"8", 900.0, 1500.0, {2, 1, 1}, 0, 0, 0},
|
||||
{"9", 1100.0, 1500.0, {2, 2, 1}, 0, 0, 0},
|
||||
{"0", 1300.0, 1500.0, {3, 1, 1}, 0, 0, 0},
|
||||
{"KP", 1100.0, 1700.0, {0, 3, 2}, 0, 0, 0},
|
||||
{"ST", 1500.0, 1700.0, {1, 3, 2}, 0, 0, 0},
|
||||
{"2600", 2600.0, 0.0, {3, 2, 3}, 0, 0, 0},
|
||||
}};
|
||||
|
||||
DTMFDolphinSceneData DTMFDolphinSceneDataRedboxUS = {
|
||||
.name = "Redbox (US)",
|
||||
.block = DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US,
|
||||
.tone_count = 4,
|
||||
.tones = {
|
||||
{"Nickel", 1700.0, 2200.0, {0, 0, 5}, 1, 66, 0},
|
||||
{"Dime", 1700.0, 2200.0, {1, 0, 5}, 2, 66, 66},
|
||||
{"Quarter", 1700.0, 2200.0, {2, 0, 5}, 5, 33, 33},
|
||||
{"Dollar", 1700.0, 2200.0, {3, 0, 5}, 1, 650, 0},
|
||||
}};
|
||||
|
||||
DTMFDolphinSceneData DTMFDolphinSceneDataRedboxUK = {
|
||||
.name = "Redbox (UK)",
|
||||
.block = DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK,
|
||||
.tone_count = 2,
|
||||
.tones = {
|
||||
{"10p", 1000.0, 0.0, {0, 0, 5}, 1, 200, 0},
|
||||
{"50p", 1000.0, 0.0, {1, 0, 5}, 1, 350, 0},
|
||||
}};
|
||||
|
||||
DTMFDolphinSceneData DTMFDolphinSceneDataMisc = {
|
||||
.name = "Misc",
|
||||
.block = DTMF_DOLPHIN_TONE_BLOCK_MISC,
|
||||
.tone_count = 3,
|
||||
.tones = {
|
||||
{"CCITT 11", 700.0, 1700.0, {0, 0, 5}, 0, 0, 0},
|
||||
{"CCITT 12", 900.0, 1700.0, {1, 0, 5}, 0, 0, 0},
|
||||
{"CCITT KP2", 1300.0, 1700.0, {2, 0, 5}, 0, 0, 0},
|
||||
}};
|
||||
|
||||
DTMFDolphinToneSection current_section;
|
||||
DTMFDolphinSceneData* current_scene_data;
|
||||
|
||||
void dtmf_dolphin_data_set_current_section(DTMFDolphinToneSection section) {
|
||||
current_section = section;
|
||||
|
||||
switch(current_section) {
|
||||
case DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX:
|
||||
current_scene_data = &DTMFDolphinSceneDataBluebox;
|
||||
break;
|
||||
case DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US:
|
||||
current_scene_data = &DTMFDolphinSceneDataRedboxUS;
|
||||
break;
|
||||
case DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK:
|
||||
current_scene_data = &DTMFDolphinSceneDataRedboxUK;
|
||||
break;
|
||||
case DTMF_DOLPHIN_TONE_BLOCK_MISC:
|
||||
current_scene_data = &DTMFDolphinSceneDataMisc;
|
||||
break;
|
||||
default: // DTMF_DOLPHIN_TONE_BLOCK_DIALER:
|
||||
current_scene_data = &DTMFDolphinSceneDataDialer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DTMFDolphinToneSection dtmf_dolphin_data_get_current_section() {
|
||||
return current_section;
|
||||
}
|
||||
|
||||
DTMFDolphinSceneData* dtmf_dolphin_data_get_current_scene_data() {
|
||||
return current_scene_data;
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_data_get_tone_frequencies(float* freq1, float* freq2, uint8_t row, uint8_t col) {
|
||||
for(size_t i = 0; i < current_scene_data->tone_count; i++) {
|
||||
DTMFDolphinTones tones = current_scene_data->tones[i];
|
||||
if(tones.pos.row == row && tones.pos.col == col) {
|
||||
freq1[0] = tones.frequency_1;
|
||||
freq2[0] = tones.frequency_2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_data_get_filter_data(
|
||||
uint16_t* pulses,
|
||||
uint16_t* pulse_ms,
|
||||
uint16_t* gap_ms,
|
||||
uint8_t row,
|
||||
uint8_t col) {
|
||||
for(size_t i = 0; i < current_scene_data->tone_count; i++) {
|
||||
DTMFDolphinTones tones = current_scene_data->tones[i];
|
||||
if(tones.pos.row == row && tones.pos.col == col) {
|
||||
pulses[0] = tones.pulses;
|
||||
pulse_ms[0] = tones.pulse_ms;
|
||||
gap_ms[0] = tones.gap_duration;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* dtmf_dolphin_data_get_tone_name(uint8_t row, uint8_t col) {
|
||||
for(size_t i = 0; i < current_scene_data->tone_count; i++) {
|
||||
DTMFDolphinTones tones = current_scene_data->tones[i];
|
||||
if(tones.pos.row == row && tones.pos.col == col) {
|
||||
return tones.name;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* dtmf_dolphin_data_get_current_section_name() {
|
||||
if(current_scene_data) {
|
||||
return current_scene_data->name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dtmf_dolphin_tone_get_max_pos(uint8_t* max_rows, uint8_t* max_cols, uint8_t* max_span) {
|
||||
max_rows[0] = 0;
|
||||
max_cols[0] = 0;
|
||||
max_span[0] = 0;
|
||||
uint8_t tmp_rowspan[5] = {0, 0, 0, 0, 0};
|
||||
for(size_t i = 0; i < current_scene_data->tone_count; i++) {
|
||||
DTMFDolphinTones tones = current_scene_data->tones[i];
|
||||
if(tones.pos.row > max_rows[0]) {
|
||||
max_rows[0] = tones.pos.row;
|
||||
}
|
||||
if(tones.pos.col > max_cols[0]) {
|
||||
max_cols[0] = tones.pos.col;
|
||||
}
|
||||
tmp_rowspan[tones.pos.row] += tones.pos.span;
|
||||
if(tmp_rowspan[tones.pos.row] > max_span[0]) max_span[0] = tmp_rowspan[tones.pos.row];
|
||||
}
|
||||
max_rows[0]++;
|
||||
max_cols[0]++;
|
||||
}
|
||||
|
||||
uint8_t dtmf_dolphin_get_tone_span(uint8_t row, uint8_t col) {
|
||||
for(size_t i = 0; i < current_scene_data->tone_count; i++) {
|
||||
DTMFDolphinTones tones = current_scene_data->tones[i];
|
||||
if(tones.pos.row == row && tones.pos.col == col) {
|
||||
return tones.pos.span;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
35
applications/plugins/dtmf_dolphin/dtmf_dolphin_data.h
Normal file
35
applications/plugins/dtmf_dolphin/dtmf_dolphin_data.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define DTMF_DOLPHIN_MAX_TONE_COUNT 16
|
||||
|
||||
typedef enum {
|
||||
DTMF_DOLPHIN_TONE_BLOCK_DIALER,
|
||||
DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX,
|
||||
DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US,
|
||||
DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK,
|
||||
DTMF_DOLPHIN_TONE_BLOCK_MISC,
|
||||
} DTMFDolphinToneSection;
|
||||
|
||||
void dtmf_dolphin_data_set_current_section(DTMFDolphinToneSection section);
|
||||
|
||||
DTMFDolphinToneSection dtmf_dolphin_data_get_current_section();
|
||||
|
||||
bool dtmf_dolphin_data_get_tone_frequencies(float* freq1, float* freq2, uint8_t row, uint8_t col);
|
||||
|
||||
bool dtmf_dolphin_data_get_filter_data(
|
||||
uint16_t* pulses,
|
||||
uint16_t* pulse_ms,
|
||||
uint16_t* gap_ms,
|
||||
uint8_t row,
|
||||
uint8_t col);
|
||||
|
||||
const char* dtmf_dolphin_data_get_tone_name(uint8_t row, uint8_t col);
|
||||
|
||||
const char* dtmf_dolphin_data_get_current_section_name();
|
||||
|
||||
void dtmf_dolphin_tone_get_max_pos(uint8_t* max_rows, uint8_t* max_cols, uint8_t* max_span);
|
||||
|
||||
uint8_t dtmf_dolphin_get_tone_span(uint8_t row, uint8_t col);
|
||||
20
applications/plugins/dtmf_dolphin/dtmf_dolphin_event.h
Normal file
20
applications/plugins/dtmf_dolphin/dtmf_dolphin_event.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
DTMFDolphinEventVolumeUp = 0,
|
||||
DTMFDolphinEventVolumeDown,
|
||||
DTMFDolphinDialerOkCB,
|
||||
DTMFDolphinEventStartDialer,
|
||||
DTMFDolphinEventStartBluebox,
|
||||
DTMFDolphinEventStartRedboxUS,
|
||||
DTMFDolphinEventStartRedboxUK,
|
||||
DTMFDolphinEventStartMisc,
|
||||
DTMFDolphinEventPlayTones,
|
||||
DTMFDolphinEventStopTones,
|
||||
DTMFDolphinEventDMAHalfTransfer,
|
||||
DTMFDolphinEventDMAFullTransfer,
|
||||
} DTMFDolphinEvent;
|
||||
|
||||
typedef struct {
|
||||
DTMFDolphinEvent type;
|
||||
} DTMFDolphinCustomEvent;
|
||||
52
applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.c
Normal file
52
applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "dtmf_dolphin_hal.h"
|
||||
|
||||
void dtmf_dolphin_speaker_init() {
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
TIM_InitStruct.Prescaler = DTMF_DOLPHIN_HAL_DMA_PRESCALER;
|
||||
TIM_InitStruct.Autoreload = DTMF_DOLPHIN_HAL_DMA_AUTORELOAD;
|
||||
LL_TIM_Init(FURI_HAL_SPEAKER_TIMER, &TIM_InitStruct);
|
||||
|
||||
LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0};
|
||||
TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;
|
||||
TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_ENABLE;
|
||||
TIM_OC_InitStruct.CompareValue = 127;
|
||||
LL_TIM_OC_Init(FURI_HAL_SPEAKER_TIMER, FURI_HAL_SPEAKER_CHANNEL, &TIM_OC_InitStruct);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_speaker_start() {
|
||||
LL_TIM_EnableAllOutputs(FURI_HAL_SPEAKER_TIMER);
|
||||
LL_TIM_EnableCounter(FURI_HAL_SPEAKER_TIMER);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_speaker_stop() {
|
||||
LL_TIM_DisableAllOutputs(FURI_HAL_SPEAKER_TIMER);
|
||||
LL_TIM_DisableCounter(FURI_HAL_SPEAKER_TIMER);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_dma_init(uint32_t address, size_t size) {
|
||||
uint32_t dma_dst = (uint32_t) & (FURI_HAL_SPEAKER_TIMER->CCR1);
|
||||
|
||||
LL_DMA_ConfigAddresses(DMA_INSTANCE, address, dma_dst, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
|
||||
LL_DMA_SetDataLength(DMA_INSTANCE, size);
|
||||
|
||||
LL_DMA_SetPeriphRequest(DMA_INSTANCE, LL_DMAMUX_REQ_TIM16_UP);
|
||||
LL_DMA_SetDataTransferDirection(DMA_INSTANCE, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
|
||||
LL_DMA_SetChannelPriorityLevel(DMA_INSTANCE, LL_DMA_PRIORITY_VERYHIGH);
|
||||
LL_DMA_SetMode(DMA_INSTANCE, LL_DMA_MODE_CIRCULAR);
|
||||
LL_DMA_SetPeriphIncMode(DMA_INSTANCE, LL_DMA_PERIPH_NOINCREMENT);
|
||||
LL_DMA_SetMemoryIncMode(DMA_INSTANCE, LL_DMA_MEMORY_INCREMENT);
|
||||
LL_DMA_SetPeriphSize(DMA_INSTANCE, LL_DMA_PDATAALIGN_HALFWORD);
|
||||
LL_DMA_SetMemorySize(DMA_INSTANCE, LL_DMA_MDATAALIGN_HALFWORD);
|
||||
|
||||
LL_DMA_EnableIT_TC(DMA_INSTANCE);
|
||||
LL_DMA_EnableIT_HT(DMA_INSTANCE);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_dma_start() {
|
||||
LL_DMA_EnableChannel(DMA_INSTANCE);
|
||||
LL_TIM_EnableDMAReq_UPDATE(FURI_HAL_SPEAKER_TIMER);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_dma_stop() {
|
||||
LL_DMA_DisableChannel(DMA_INSTANCE);
|
||||
}
|
||||
33
applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.h
Normal file
33
applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <stm32wb55xx.h>
|
||||
#include <stm32wbxx_ll_tim.h>
|
||||
#include <stm32wbxx_ll_dma.h>
|
||||
|
||||
#define FURI_HAL_SPEAKER_TIMER TIM16
|
||||
#define FURI_HAL_SPEAKER_CHANNEL LL_TIM_CHANNEL_CH1
|
||||
#define DMA_INSTANCE DMA1, LL_DMA_CHANNEL_1
|
||||
|
||||
#define DTMF_DOLPHIN_HAL_DMA_PRESCALER 4
|
||||
#define DTMF_DOLPHIN_HAL_DMA_AUTORELOAD 255
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void dtmf_dolphin_speaker_init();
|
||||
|
||||
void dtmf_dolphin_speaker_start();
|
||||
|
||||
void dtmf_dolphin_speaker_stop();
|
||||
|
||||
void dtmf_dolphin_dma_init(uint32_t address, size_t size);
|
||||
|
||||
void dtmf_dolphin_dma_start();
|
||||
|
||||
void dtmf_dolphin_dma_stop();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
41
applications/plugins/dtmf_dolphin/dtmf_dolphin_i.h
Normal file
41
applications/plugins/dtmf_dolphin/dtmf_dolphin_i.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "scenes/dtmf_dolphin_scene.h"
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
// #include <gui/modules/submenu.h>
|
||||
// #include <gui/modules/widget.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <input/input.h>
|
||||
|
||||
#include "dtmf_dolphin_event.h"
|
||||
|
||||
#include "views/dtmf_dolphin_dialer.h"
|
||||
|
||||
#define TAG "DTMFDolphin"
|
||||
|
||||
enum DTMFDolphinSceneState {
|
||||
DTMFDolphinSceneStateDialer,
|
||||
DTMFDolphinSceneStateBluebox,
|
||||
DTMFDolphinSceneStateRedboxUS,
|
||||
DTMFDolphinSceneStateRedboxUK,
|
||||
DTMFDolphinSceneStateMisc,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
VariableItemList* main_menu_list;
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer;
|
||||
|
||||
Gui* gui;
|
||||
// ButtonPanel* dialer_button_panel;
|
||||
// ButtonPanel* bluebox_button_panel;
|
||||
// ButtonPanel* redbox_button_panel;
|
||||
NotificationApp* notification;
|
||||
} DTMFDolphinApp;
|
||||
|
||||
typedef enum { DTMFDolphinViewMainMenu, DTMFDolphinViewDialer } DTMFDolphinView;
|
||||
BIN
applications/plugins/dtmf_dolphin/phone.png
Normal file
BIN
applications/plugins/dtmf_dolphin/phone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 306 B |
BIN
applications/plugins/dtmf_dolphin/pics/dialer.jpg
Normal file
BIN
applications/plugins/dtmf_dolphin/pics/dialer.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
@@ -0,0 +1,30 @@
|
||||
#include "dtmf_dolphin_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const dtmf_dolphin_scene_on_enter_handlers[])(void*) = {
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const dtmf_dolphin_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const dtmf_dolphin_scene_on_exit_handlers[])(void* context) = {
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers dtmf_dolphin_scene_handlers = {
|
||||
.on_enter_handlers = dtmf_dolphin_scene_on_enter_handlers,
|
||||
.on_event_handlers = dtmf_dolphin_scene_on_event_handlers,
|
||||
.on_exit_handlers = dtmf_dolphin_scene_on_exit_handlers,
|
||||
.scene_num = DTMFDolphinSceneNum,
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) DTMFDolphinScene##id,
|
||||
typedef enum {
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
DTMFDolphinSceneNum,
|
||||
} DTMFDolphinScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers dtmf_dolphin_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "dtmf_dolphin_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
@@ -0,0 +1,2 @@
|
||||
ADD_SCENE(dtmf_dolphin, start, Start)
|
||||
ADD_SCENE(dtmf_dolphin, dialer, Dialer)
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "../dtmf_dolphin_i.h"
|
||||
// #include "../dtmf_dolphin_data.h"
|
||||
// #include "../dtmf_dolphin_audio.h"
|
||||
|
||||
void dtmf_dolphin_scene_dialer_on_enter(void* context) {
|
||||
DTMFDolphinApp* app = context;
|
||||
DTMFDolphinScene scene_id = DTMFDolphinSceneDialer;
|
||||
enum DTMFDolphinSceneState state = scene_manager_get_scene_state(app->scene_manager, scene_id);
|
||||
|
||||
switch(state) {
|
||||
case DTMFDolphinSceneStateBluebox:
|
||||
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX);
|
||||
break;
|
||||
case DTMFDolphinSceneStateRedboxUS:
|
||||
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US);
|
||||
break;
|
||||
case DTMFDolphinSceneStateRedboxUK:
|
||||
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK);
|
||||
break;
|
||||
case DTMFDolphinSceneStateMisc:
|
||||
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_MISC);
|
||||
break;
|
||||
default:
|
||||
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_DIALER);
|
||||
break;
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DTMFDolphinViewDialer);
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_scene_dialer_on_event(void* context, SceneManagerEvent event) {
|
||||
DTMFDolphinApp* app = context;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
bool consumed = false;
|
||||
|
||||
// if(event.type == SceneManagerEventTypeTick) {
|
||||
// consumed = true;
|
||||
// }
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void dtmf_dolphin_scene_dialer_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "../dtmf_dolphin_i.h"
|
||||
|
||||
static void dtmf_dolphin_scene_start_main_menu_enter_callback(void* context, uint32_t index) {
|
||||
DTMFDolphinApp* app = context;
|
||||
uint8_t cust_event = 255;
|
||||
switch(index) {
|
||||
case 0:
|
||||
cust_event = DTMFDolphinEventStartDialer;
|
||||
break;
|
||||
case 1:
|
||||
cust_event = DTMFDolphinEventStartBluebox;
|
||||
break;
|
||||
case 2:
|
||||
cust_event = DTMFDolphinEventStartRedboxUS;
|
||||
break;
|
||||
case 3:
|
||||
cust_event = DTMFDolphinEventStartRedboxUK;
|
||||
break;
|
||||
case 4:
|
||||
cust_event = DTMFDolphinEventStartMisc;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, cust_event);
|
||||
}
|
||||
|
||||
void dtmf_dolphin_scene_start_on_enter(void* context) {
|
||||
DTMFDolphinApp* app = context;
|
||||
VariableItemList* var_item_list = app->main_menu_list;
|
||||
|
||||
// VariableItem* item;
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, dtmf_dolphin_scene_start_main_menu_enter_callback, app);
|
||||
|
||||
variable_item_list_add(var_item_list, "Dialer", 0, NULL, context);
|
||||
variable_item_list_add(var_item_list, "Bluebox", 0, NULL, context);
|
||||
variable_item_list_add(var_item_list, "Redbox (US)", 0, NULL, context);
|
||||
variable_item_list_add(var_item_list, "Redbox (UK)", 0, NULL, context);
|
||||
variable_item_list_add(var_item_list, "Misc", 0, NULL, context);
|
||||
|
||||
variable_item_list_set_selected_item(
|
||||
var_item_list, scene_manager_get_scene_state(app->scene_manager, DTMFDolphinSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DTMFDolphinViewMainMenu);
|
||||
}
|
||||
|
||||
bool dtmf_dolphin_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
DTMFDolphinApp* app = context;
|
||||
UNUSED(app);
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
uint8_t sc_state;
|
||||
|
||||
switch(event.event) {
|
||||
case DTMFDolphinEventStartDialer:
|
||||
sc_state = DTMFDolphinSceneStateDialer;
|
||||
break;
|
||||
case DTMFDolphinEventStartBluebox:
|
||||
sc_state = DTMFDolphinSceneStateBluebox;
|
||||
break;
|
||||
case DTMFDolphinEventStartRedboxUS:
|
||||
sc_state = DTMFDolphinSceneStateRedboxUS;
|
||||
break;
|
||||
case DTMFDolphinEventStartRedboxUK:
|
||||
sc_state = DTMFDolphinSceneStateRedboxUK;
|
||||
break;
|
||||
case DTMFDolphinEventStartMisc:
|
||||
sc_state = DTMFDolphinSceneStateMisc;
|
||||
break;
|
||||
default:
|
||||
return consumed;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, DTMFDolphinSceneDialer, sc_state);
|
||||
scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneDialer);
|
||||
|
||||
consumed = true;
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void dtmf_dolphin_scene_start_on_exit(void* context) {
|
||||
DTMFDolphinApp* app = context;
|
||||
variable_item_list_reset(app->main_menu_list);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "../dtmf_dolphin_event.h"
|
||||
#include "../dtmf_dolphin_data.h"
|
||||
#include "../dtmf_dolphin_audio.h"
|
||||
|
||||
#define DTMF_DOLPHIN_NUMPAD_X 1
|
||||
#define DTMF_DOLPHIN_NUMPAD_Y 14
|
||||
#define DTMF_DOLPHIN_BUTTON_WIDTH 13
|
||||
#define DTMF_DOLPHIN_BUTTON_HEIGHT 13
|
||||
#define DTMF_DOLPHIN_BUTTON_PADDING 1 // all sides
|
||||
350
applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.c
Normal file
350
applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.c
Normal file
@@ -0,0 +1,350 @@
|
||||
#include "dtmf_dolphin_dialer.h"
|
||||
|
||||
#include <gui/elements.h>
|
||||
|
||||
typedef struct DTMFDolphinDialer {
|
||||
View* view;
|
||||
DTMFDolphinDialerOkCallback callback;
|
||||
void* context;
|
||||
} DTMFDolphinDialer;
|
||||
|
||||
typedef struct {
|
||||
DTMFDolphinToneSection section;
|
||||
uint8_t row;
|
||||
uint8_t col;
|
||||
float freq1;
|
||||
float freq2;
|
||||
bool playing;
|
||||
uint16_t pulses;
|
||||
uint16_t pulse_ms;
|
||||
uint16_t gap_ms;
|
||||
} DTMFDolphinDialerModel;
|
||||
|
||||
static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_dialer);
|
||||
static bool dtmf_dolphin_dialer_process_down(DTMFDolphinDialer* dtmf_dolphin_dialer);
|
||||
static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer);
|
||||
static bool dtmf_dolphin_dialer_process_right(DTMFDolphinDialer* dtmf_dolphin_dialer);
|
||||
static bool
|
||||
dtmf_dolphin_dialer_process_ok(DTMFDolphinDialer* dtmf_dolphin_dialer, InputEvent* event);
|
||||
|
||||
void draw_button(Canvas* canvas, uint8_t row, uint8_t col, bool invert) {
|
||||
uint8_t left = DTMF_DOLPHIN_NUMPAD_X + // ((col + 1) * DTMF_DOLPHIN_BUTTON_PADDING) +
|
||||
(col * DTMF_DOLPHIN_BUTTON_WIDTH);
|
||||
// (col * DTMF_DOLPHIN_BUTTON_PADDING);
|
||||
uint8_t top = DTMF_DOLPHIN_NUMPAD_Y + // ((row + 1) * DTMF_DOLPHIN_BUTTON_PADDING) +
|
||||
(row * DTMF_DOLPHIN_BUTTON_HEIGHT);
|
||||
// (row * DTMF_DOLPHIN_BUTTON_PADDING);
|
||||
|
||||
uint8_t span = dtmf_dolphin_get_tone_span(row, col);
|
||||
|
||||
if(span == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
|
||||
if(invert)
|
||||
canvas_draw_rbox(
|
||||
canvas,
|
||||
left,
|
||||
top,
|
||||
(DTMF_DOLPHIN_BUTTON_WIDTH * span) - (DTMF_DOLPHIN_BUTTON_PADDING * 2),
|
||||
DTMF_DOLPHIN_BUTTON_HEIGHT - (DTMF_DOLPHIN_BUTTON_PADDING * 2),
|
||||
2);
|
||||
else
|
||||
canvas_draw_rframe(
|
||||
canvas,
|
||||
left,
|
||||
top,
|
||||
(DTMF_DOLPHIN_BUTTON_WIDTH * span) - (DTMF_DOLPHIN_BUTTON_PADDING * 2),
|
||||
DTMF_DOLPHIN_BUTTON_HEIGHT - (DTMF_DOLPHIN_BUTTON_PADDING * 2),
|
||||
2);
|
||||
|
||||
if(invert) canvas_invert_color(canvas);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
// canvas_set_color(canvas, invert ? ColorWhite : ColorBlack);
|
||||
canvas_draw_str_aligned(
|
||||
canvas,
|
||||
left - 1 + (int)((DTMF_DOLPHIN_BUTTON_WIDTH * span) / 2),
|
||||
top + (int)(DTMF_DOLPHIN_BUTTON_HEIGHT / 2),
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
dtmf_dolphin_data_get_tone_name(row, col));
|
||||
|
||||
if(invert) canvas_invert_color(canvas);
|
||||
}
|
||||
|
||||
void draw_dialer(Canvas* canvas, void* _model) {
|
||||
DTMFDolphinDialerModel* model = _model;
|
||||
uint8_t max_rows;
|
||||
uint8_t max_cols;
|
||||
uint8_t max_span;
|
||||
dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
|
||||
for(int r = 0; r < max_rows; r++) {
|
||||
for(int c = 0; c < max_cols; c++) {
|
||||
if(model->row == r && model->col == c)
|
||||
draw_button(canvas, r, c, true);
|
||||
else
|
||||
draw_button(canvas, r, c, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_frequencies(DTMFDolphinDialerModel* model) {
|
||||
dtmf_dolphin_data_get_tone_frequencies(&model->freq1, &model->freq2, model->row, model->col);
|
||||
dtmf_dolphin_data_get_filter_data(
|
||||
&model->pulses, &model->pulse_ms, &model->gap_ms, model->row, model->col);
|
||||
}
|
||||
|
||||
static void dtmf_dolphin_dialer_draw_callback(Canvas* canvas, void* _model) {
|
||||
DTMFDolphinDialerModel* model = _model;
|
||||
if(model->playing) {
|
||||
// Leverage the prioritized draw callback to handle
|
||||
// the DMA so that it doesn't skip.
|
||||
dtmf_dolphin_audio_handle_tick();
|
||||
// Don't do any drawing if audio is playing.
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text_aligned(
|
||||
canvas,
|
||||
canvas_width(canvas) / 2,
|
||||
canvas_height(canvas) / 2,
|
||||
AlignCenter,
|
||||
AlignCenter,
|
||||
"Playing Tones");
|
||||
return;
|
||||
}
|
||||
update_frequencies(model);
|
||||
uint8_t max_rows = 0;
|
||||
uint8_t max_cols = 0;
|
||||
uint8_t max_span = 0;
|
||||
dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text(canvas, 2, 10, dtmf_dolphin_data_get_current_section_name());
|
||||
canvas_draw_line(
|
||||
canvas,
|
||||
(max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 1,
|
||||
0,
|
||||
(max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 1,
|
||||
canvas_height(canvas));
|
||||
elements_multiline_text(canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 10, "Detail");
|
||||
canvas_draw_line(
|
||||
canvas, 0, DTMF_DOLPHIN_NUMPAD_Y - 3, canvas_width(canvas), DTMF_DOLPHIN_NUMPAD_Y - 3);
|
||||
// elements_multiline_text_aligned(canvas, 64, 2, AlignCenter, AlignTop, "Dialer Mode");
|
||||
|
||||
draw_dialer(canvas, model);
|
||||
|
||||
FuriString* output = furi_string_alloc();
|
||||
|
||||
if(model->freq1 && model->freq2) {
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"Dual Tone\nF1: %u Hz\nF2: %u Hz\n",
|
||||
(unsigned int)model->freq1,
|
||||
(unsigned int)model->freq2);
|
||||
} else if(model->freq1) {
|
||||
furi_string_cat_printf(output, "Single Tone\nF: %u Hz\n", (unsigned int)model->freq1);
|
||||
}
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
if(model->pulse_ms) {
|
||||
furi_string_cat_printf(output, "P: %u * %u ms\n", model->pulses, model->pulse_ms);
|
||||
}
|
||||
if(model->gap_ms) {
|
||||
furi_string_cat_printf(output, "Gaps: %u ms\n", model->gap_ms);
|
||||
}
|
||||
elements_multiline_text(
|
||||
canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 21, furi_string_get_cstr(output));
|
||||
|
||||
furi_string_free(output);
|
||||
}
|
||||
|
||||
static bool dtmf_dolphin_dialer_input_callback(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyRight) {
|
||||
consumed = dtmf_dolphin_dialer_process_right(dtmf_dolphin_dialer);
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
consumed = dtmf_dolphin_dialer_process_left(dtmf_dolphin_dialer);
|
||||
} else if(event->key == InputKeyUp) {
|
||||
consumed = dtmf_dolphin_dialer_process_up(dtmf_dolphin_dialer);
|
||||
} else if(event->key == InputKeyDown) {
|
||||
consumed = dtmf_dolphin_dialer_process_down(dtmf_dolphin_dialer);
|
||||
}
|
||||
|
||||
} else if(event->key == InputKeyOk) {
|
||||
consumed = dtmf_dolphin_dialer_process_ok(dtmf_dolphin_dialer, event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
uint8_t span = 0;
|
||||
uint8_t cursor = model->row;
|
||||
while(span == 0 && cursor > 0) {
|
||||
cursor--;
|
||||
span = dtmf_dolphin_get_tone_span(cursor, model->col);
|
||||
}
|
||||
if(span != 0) {
|
||||
model->row = cursor;
|
||||
}
|
||||
},
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dtmf_dolphin_dialer_process_down(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
||||
uint8_t max_rows = 0;
|
||||
uint8_t max_cols = 0;
|
||||
uint8_t max_span = 0;
|
||||
dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
|
||||
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
uint8_t span = 0;
|
||||
uint8_t cursor = model->row;
|
||||
while(span == 0 && cursor < max_rows - 1) {
|
||||
cursor++;
|
||||
span = dtmf_dolphin_get_tone_span(cursor, model->col);
|
||||
}
|
||||
if(span != 0) {
|
||||
model->row = cursor;
|
||||
}
|
||||
},
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
uint8_t span = 0;
|
||||
uint8_t cursor = model->col;
|
||||
while(span == 0 && cursor > 0) {
|
||||
cursor--;
|
||||
span = dtmf_dolphin_get_tone_span(model->row, cursor);
|
||||
}
|
||||
if(span != 0) {
|
||||
model->col = cursor;
|
||||
}
|
||||
},
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dtmf_dolphin_dialer_process_right(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
||||
uint8_t max_rows = 0;
|
||||
uint8_t max_cols = 0;
|
||||
uint8_t max_span = 0;
|
||||
dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
|
||||
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
uint8_t span = 0;
|
||||
uint8_t cursor = model->col;
|
||||
while(span == 0 && cursor < max_cols - 1) {
|
||||
cursor++;
|
||||
span = dtmf_dolphin_get_tone_span(model->row, cursor);
|
||||
}
|
||||
if(span != 0) {
|
||||
model->col = cursor;
|
||||
}
|
||||
},
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
dtmf_dolphin_dialer_process_ok(DTMFDolphinDialer* dtmf_dolphin_dialer, InputEvent* event) {
|
||||
bool consumed = false;
|
||||
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
if(event->type == InputTypePress) {
|
||||
model->playing = dtmf_dolphin_audio_play_tones(
|
||||
model->freq1, model->freq2, model->pulses, model->pulse_ms, model->gap_ms);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
model->playing = !dtmf_dolphin_audio_stop_tones();
|
||||
}
|
||||
},
|
||||
true);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
static void dtmf_dolphin_dialer_enter_callback(void* context) {
|
||||
furi_assert(context);
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer = context;
|
||||
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
model->col = 0;
|
||||
model->row = 0;
|
||||
model->section = 0;
|
||||
model->freq1 = 0.0;
|
||||
model->freq2 = 0.0;
|
||||
model->playing = false;
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer_alloc() {
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer = malloc(sizeof(DTMFDolphinDialer));
|
||||
|
||||
dtmf_dolphin_dialer->view = view_alloc();
|
||||
view_allocate_model(
|
||||
dtmf_dolphin_dialer->view, ViewModelTypeLocking, sizeof(DTMFDolphinDialerModel));
|
||||
|
||||
with_view_model(
|
||||
dtmf_dolphin_dialer->view,
|
||||
DTMFDolphinDialerModel * model,
|
||||
{
|
||||
model->col = 0;
|
||||
model->row = 0;
|
||||
model->section = 0;
|
||||
model->freq1 = 0.0;
|
||||
model->freq2 = 0.0;
|
||||
model->playing = false;
|
||||
},
|
||||
true);
|
||||
|
||||
view_set_context(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer);
|
||||
view_set_draw_callback(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer_draw_callback);
|
||||
view_set_input_callback(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer_input_callback);
|
||||
view_set_enter_callback(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer_enter_callback);
|
||||
return dtmf_dolphin_dialer;
|
||||
}
|
||||
|
||||
void dtmf_dolphin_dialer_free(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
||||
furi_assert(dtmf_dolphin_dialer);
|
||||
view_free(dtmf_dolphin_dialer->view);
|
||||
free(dtmf_dolphin_dialer);
|
||||
}
|
||||
|
||||
View* dtmf_dolphin_dialer_get_view(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
||||
furi_assert(dtmf_dolphin_dialer);
|
||||
return dtmf_dolphin_dialer->view;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
#include "dtmf_dolphin_common.h"
|
||||
|
||||
typedef struct DTMFDolphinDialer DTMFDolphinDialer;
|
||||
typedef void (*DTMFDolphinDialerOkCallback)(InputType type, void* context);
|
||||
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer_alloc();
|
||||
|
||||
void dtmf_dolphin_dialer_free(DTMFDolphinDialer* dtmf_dolphin_dialer);
|
||||
|
||||
View* dtmf_dolphin_dialer_get_view(DTMFDolphinDialer* dtmf_dolphin_dialer);
|
||||
|
||||
void dtmf_dolphin_dialer_set_ok_callback(
|
||||
DTMFDolphinDialer* dtmf_dolphin_dialer,
|
||||
DTMFDolphinDialerOkCallback callback,
|
||||
void* context);
|
||||
@@ -12,10 +12,10 @@
|
||||
#define FLAPPY_BIRD_WIDTH 10
|
||||
|
||||
#define FLAPPY_PILAR_MAX 6
|
||||
#define FLAPPY_PILAR_DIST 40
|
||||
#define FLAPPY_PILAR_DIST 35
|
||||
|
||||
#define FLAPPY_GAB_HEIGHT 25
|
||||
#define FLAPPY_GAB_WIDTH 5
|
||||
#define FLAPPY_GAB_WIDTH 10
|
||||
|
||||
#define FLAPPY_GRAVITY_JUMP -1.1
|
||||
#define FLAPPY_GRAVITY_TICK 0.15
|
||||
@@ -100,10 +100,6 @@ static void flappy_game_state_init(GameState* const game_state) {
|
||||
flappy_game_random_pilar(game_state);
|
||||
}
|
||||
|
||||
// static void flappy_game_reset(GameState* const game_state) {
|
||||
// FURI_LOG_I(TAG, "Reset Game State\r\n"); // Resetting State
|
||||
// }
|
||||
|
||||
static void flappy_game_tick(GameState* const game_state) {
|
||||
if(game_state->state == GameStateLife) {
|
||||
if(!game_state->debug) {
|
||||
@@ -136,11 +132,12 @@ static void flappy_game_tick(GameState* const game_state) {
|
||||
}
|
||||
if(pilar->point.x < -FLAPPY_GAB_WIDTH) pilar->visible = 0;
|
||||
|
||||
// Checking out of bounds
|
||||
if(game_state->bird.point.y < 0 - FLAPPY_BIRD_WIDTH ||
|
||||
game_state->bird.point.y > FLIPPER_LCD_HEIGHT) {
|
||||
game_state->state = GameStateGameOver;
|
||||
break;
|
||||
if(game_state->bird.point.y <= 0 - FLAPPY_BIRD_WIDTH) {
|
||||
game_state->bird.point.y = 64;
|
||||
}
|
||||
|
||||
if(game_state->bird.point.y > 64 - FLAPPY_BIRD_WIDTH) {
|
||||
game_state->bird.point.y = FLIPPER_LCD_HEIGHT - FLAPPY_BIRD_WIDTH;
|
||||
}
|
||||
|
||||
// Bird inbetween pipes
|
||||
@@ -237,10 +234,6 @@ static void flappy_game_render_callback(Canvas* const canvas, void* ctx) {
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 37, 31, "Game Over");
|
||||
|
||||
/*if(game_state->points != 0 && game_state->points % 5 == 0) {
|
||||
DOLPHIN_DEED(getRandomDeed());
|
||||
}*/
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
char buffer[12];
|
||||
snprintf(buffer, sizeof(buffer), "Score: %u", game_state->points);
|
||||
@@ -304,16 +297,16 @@ int32_t flappy_game_app(void* p) {
|
||||
if(event.input.type == InputTypePress) {
|
||||
switch(event.input.key) {
|
||||
case InputKeyUp:
|
||||
game_state->bird.point.y--;
|
||||
if(game_state->state == GameStateLife) {
|
||||
flappy_game_flap(game_state);
|
||||
}
|
||||
|
||||
break;
|
||||
case InputKeyDown:
|
||||
game_state->bird.point.y++;
|
||||
break;
|
||||
case InputKeyRight:
|
||||
game_state->bird.point.x++;
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
game_state->bird.point.x--;
|
||||
break;
|
||||
case InputKeyOk:
|
||||
if(game_state->state == GameStateGameOver) {
|
||||
|
||||
@@ -11,6 +11,7 @@ This is a Minesweeper implementation for the Flipper Zero device.
|
||||
- Arrow buttons to move
|
||||
- Push center button to open field
|
||||
- Hold center button to toggle flag
|
||||
- Push center button on an already open field that has the correct amount of flags surrounding it to auto-open the remaining ones (thanks @gelin!)
|
||||
|
||||
## Compiling
|
||||
|
||||
|
||||
@@ -42,10 +42,7 @@ typedef enum {
|
||||
TileTypeMine
|
||||
} TileType;
|
||||
|
||||
typedef enum {
|
||||
FieldEmpty, // <-- same goes for this
|
||||
FieldMine
|
||||
} Field;
|
||||
typedef enum { FieldEmpty, FieldMine } Field;
|
||||
|
||||
typedef struct {
|
||||
Field minefield[PLAYFIELD_WIDTH][PLAYFIELD_HEIGHT];
|
||||
@@ -99,6 +96,8 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
||||
furi_string_printf(timeStr, "%01d:%02d", minutes, seconds);
|
||||
canvas_draw_str_aligned(canvas, 128, 0, AlignRight, AlignTop, furi_string_get_cstr(timeStr));
|
||||
|
||||
uint8_t* tile_to_draw;
|
||||
|
||||
for(int y = 0; y < PLAYFIELD_HEIGHT; y++) {
|
||||
for(int x = 0; x < PLAYFIELD_WIDTH; x++) {
|
||||
if(x == minesweeper_state->cursor_x && y == minesweeper_state->cursor_y) {
|
||||
@@ -106,114 +105,53 @@ static void render_callback(Canvas* const canvas, void* ctx) {
|
||||
}
|
||||
switch(minesweeper_state->playfield[x][y]) {
|
||||
case TileType0:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_0_bits);
|
||||
tile_to_draw = tile_0_bits;
|
||||
break;
|
||||
case TileType1:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_1_bits);
|
||||
tile_to_draw = tile_1_bits;
|
||||
break;
|
||||
case TileType2:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_2_bits);
|
||||
tile_to_draw = tile_2_bits;
|
||||
break;
|
||||
case TileType3:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_3_bits);
|
||||
tile_to_draw = tile_3_bits;
|
||||
break;
|
||||
case TileType4:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_4_bits);
|
||||
tile_to_draw = tile_4_bits;
|
||||
break;
|
||||
case TileType5:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_5_bits);
|
||||
tile_to_draw = tile_5_bits;
|
||||
break;
|
||||
case TileType6:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_6_bits);
|
||||
tile_to_draw = tile_6_bits;
|
||||
break;
|
||||
case TileType7:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_7_bits);
|
||||
tile_to_draw = tile_7_bits;
|
||||
break;
|
||||
case TileType8:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_8_bits);
|
||||
tile_to_draw = tile_8_bits;
|
||||
break;
|
||||
case TileTypeFlag:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_flag_bits);
|
||||
tile_to_draw = tile_flag_bits;
|
||||
break;
|
||||
case TileTypeUncleared:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_uncleared_bits);
|
||||
tile_to_draw = tile_uncleared_bits;
|
||||
break;
|
||||
case TileTypeMine:
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_mine_bits);
|
||||
tile_to_draw = tile_mine_bits;
|
||||
break;
|
||||
default:
|
||||
// this should never happen
|
||||
tile_to_draw = tile_mine_bits;
|
||||
break;
|
||||
}
|
||||
canvas_draw_xbm(
|
||||
canvas,
|
||||
x * TILE_HEIGHT, // x
|
||||
8 + (y * TILE_WIDTH), // y
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
tile_to_draw);
|
||||
if(x == minesweeper_state->cursor_x && y == minesweeper_state->cursor_y) {
|
||||
canvas_invert_color(canvas);
|
||||
}
|
||||
@@ -279,6 +217,10 @@ static bool game_lost(Minesweeper* minesweeper_state) {
|
||||
|
||||
dialog_message_set_icon(message, NULL, 0, 10);
|
||||
|
||||
// Set cursor to initial position
|
||||
minesweeper_state->cursor_x = 0;
|
||||
minesweeper_state->cursor_y = 0;
|
||||
|
||||
NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notifications, &sequence_set_vibro_on);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
@@ -311,7 +253,6 @@ static bool game_won(Minesweeper* minesweeper_state) {
|
||||
dialog_message_set_text(
|
||||
message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_message_set_buttons(message, NULL, "Play again", NULL);
|
||||
// TODO: create icon
|
||||
dialog_message_set_icon(message, NULL, 72, 17);
|
||||
|
||||
DialogMessageButton choice = dialog_message_show(dialogs, message);
|
||||
@@ -321,18 +262,23 @@ static bool game_won(Minesweeper* minesweeper_state) {
|
||||
return choice == DialogMessageButtonCenter;
|
||||
}
|
||||
|
||||
// returns false if the move loses the game - otherwise true
|
||||
static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y) {
|
||||
if(minesweeper_state->playfield[cursor_x][cursor_y] != TileTypeUncleared) {
|
||||
// we're on an already uncovered field
|
||||
if(minesweeper_state->playfield[cursor_x][cursor_y] == TileTypeFlag) {
|
||||
// we're on a flagged field, do nothing
|
||||
return true;
|
||||
}
|
||||
if(minesweeper_state->minefield[cursor_x][cursor_y] == FieldMine) {
|
||||
// TODO: player loses!
|
||||
// player loses - draw mine
|
||||
minesweeper_state->playfield[cursor_x][cursor_y] = TileTypeMine;
|
||||
return false;
|
||||
} else {
|
||||
// get number of surrounding mines.
|
||||
int hint = 0;
|
||||
}
|
||||
|
||||
if(minesweeper_state->playfield[cursor_x][cursor_y] >= TileType1 &&
|
||||
minesweeper_state->playfield[cursor_x][cursor_y] <= TileType8) {
|
||||
// click on a cleared cell with a number
|
||||
// count the flags around
|
||||
int flags = 0;
|
||||
for(int y = cursor_y - 1; y <= cursor_y + 1; y++) {
|
||||
for(int x = cursor_x - 1; x <= cursor_x + 1; x++) {
|
||||
if(x == cursor_x && y == cursor_y) {
|
||||
@@ -341,18 +287,15 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
|
||||
}
|
||||
// make sure we don't go OOB
|
||||
if(x >= 0 && x < PLAYFIELD_WIDTH && y >= 0 && y < PLAYFIELD_HEIGHT) {
|
||||
if(minesweeper_state->minefield[x][y] == FieldMine) {
|
||||
hint++;
|
||||
if(minesweeper_state->playfield[x][y] == TileTypeFlag) {
|
||||
flags++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 〜( ̄▽ ̄〜) don't judge me (〜 ̄▽ ̄)〜
|
||||
minesweeper_state->playfield[cursor_x][cursor_y] = hint;
|
||||
minesweeper_state->fields_cleared++;
|
||||
FURI_LOG_D("Minesweeper", "Setting %d,%d to %d", cursor_x, cursor_y, hint);
|
||||
if(hint == 0) {
|
||||
// auto open surrounding fields.
|
||||
int mines = minesweeper_state->playfield[cursor_x][cursor_y]; // ¯\_(ツ)_/¯
|
||||
if(flags == mines) {
|
||||
// auto uncover all non-flags around (to win faster ;)
|
||||
for(int auto_y = cursor_y - 1; auto_y <= cursor_y + 1; auto_y++) {
|
||||
for(int auto_x = cursor_x - 1; auto_x <= cursor_x + 1; auto_x++) {
|
||||
if(auto_x == cursor_x && auto_y == cursor_y) {
|
||||
@@ -361,14 +304,57 @@ static bool play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
|
||||
if(auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 &&
|
||||
auto_y < PLAYFIELD_HEIGHT) {
|
||||
if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) {
|
||||
play_move(minesweeper_state, auto_x, auto_y);
|
||||
if(!play_move(minesweeper_state, auto_x, auto_y)) {
|
||||
// flags were wrong, we got a mine!
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// we're done without hitting a mine - so return
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// calculate number of surrounding mines.
|
||||
int hint = 0;
|
||||
for(int y = cursor_y - 1; y <= cursor_y + 1; y++) {
|
||||
for(int x = cursor_x - 1; x <= cursor_x + 1; x++) {
|
||||
if(x == cursor_x && y == cursor_y) {
|
||||
// we're on the cell the user selected, so ignore.
|
||||
continue;
|
||||
}
|
||||
// make sure we don't go OOB
|
||||
if(x >= 0 && x < PLAYFIELD_WIDTH && y >= 0 && y < PLAYFIELD_HEIGHT) {
|
||||
if(minesweeper_state->minefield[x][y] == FieldMine) {
|
||||
hint++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 〜( ̄▽ ̄〜) don't judge me (〜 ̄▽ ̄)〜
|
||||
minesweeper_state->playfield[cursor_x][cursor_y] = hint;
|
||||
minesweeper_state->fields_cleared++;
|
||||
FURI_LOG_D("Minesweeper", "Setting %d,%d to %d", cursor_x, cursor_y, hint);
|
||||
if(hint == 0) {
|
||||
// the field is "empty"
|
||||
// auto open surrounding fields.
|
||||
for(int auto_y = cursor_y - 1; auto_y <= cursor_y + 1; auto_y++) {
|
||||
for(int auto_x = cursor_x - 1; auto_x <= cursor_x + 1; auto_x++) {
|
||||
if(auto_x == cursor_x && auto_y == cursor_y) {
|
||||
continue;
|
||||
}
|
||||
if(auto_x >= 0 && auto_x < PLAYFIELD_WIDTH && auto_y >= 0 &&
|
||||
auto_y < PLAYFIELD_HEIGHT) {
|
||||
if(minesweeper_state->playfield[auto_x][auto_y] == TileTypeUncleared) {
|
||||
play_move(minesweeper_state, auto_x, auto_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void minesweeper_state_init(Minesweeper* const minesweeper_state) {
|
||||
@@ -435,25 +421,25 @@ int32_t minesweeper_app(void* p) {
|
||||
case InputKeyUp:
|
||||
minesweeper_state->cursor_y--;
|
||||
if(minesweeper_state->cursor_y < 0) {
|
||||
minesweeper_state->cursor_y = 0;
|
||||
minesweeper_state->cursor_y = PLAYFIELD_HEIGHT - 1;
|
||||
}
|
||||
break;
|
||||
case InputKeyDown:
|
||||
minesweeper_state->cursor_y++;
|
||||
if(minesweeper_state->cursor_y >= PLAYFIELD_HEIGHT) {
|
||||
minesweeper_state->cursor_y = PLAYFIELD_HEIGHT - 1;
|
||||
minesweeper_state->cursor_y = 0;
|
||||
}
|
||||
break;
|
||||
case InputKeyRight:
|
||||
minesweeper_state->cursor_x++;
|
||||
if(minesweeper_state->cursor_x >= PLAYFIELD_WIDTH) {
|
||||
minesweeper_state->cursor_x = PLAYFIELD_WIDTH - 1;
|
||||
minesweeper_state->cursor_x = 0;
|
||||
}
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
minesweeper_state->cursor_x--;
|
||||
if(minesweeper_state->cursor_x < 0) {
|
||||
minesweeper_state->cursor_x = 0;
|
||||
minesweeper_state->cursor_x = PLAYFIELD_WIDTH - 1;
|
||||
}
|
||||
break;
|
||||
case InputKeyOk:
|
||||
@@ -510,6 +496,9 @@ int32_t minesweeper_app(void* p) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// event timeout
|
||||
;
|
||||
}
|
||||
view_port_update(view_port);
|
||||
release_mutex(&state_mutex, minesweeper_state);
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
#include "../../services/config/config.h"
|
||||
#include "../scene_director.h"
|
||||
#include "../totp_scenes_enum.h"
|
||||
#include "../../services/crypto/crypto.h"
|
||||
|
||||
#define MAX_CODE_LENGTH TOTP_IV_SIZE
|
||||
#define CRYPTO_VERIFY_KEY "FFF_Crypto_pass"
|
||||
#define CRYPTO_VERIFY_KEY_LENGTH 16
|
||||
|
||||
typedef struct {
|
||||
uint8_t code_input[MAX_CODE_LENGTH];
|
||||
@@ -111,52 +110,10 @@ bool totp_scene_authenticate_handle_event(PluginEvent* const event, PluginState*
|
||||
}
|
||||
break;
|
||||
case InputKeyOk:
|
||||
if(plugin_state->crypto_verify_data == NULL) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Generating new IV");
|
||||
furi_hal_random_fill_buf(&plugin_state->base_iv[0], TOTP_IV_SIZE);
|
||||
}
|
||||
totp_crypto_seed_iv(
|
||||
plugin_state, &scene_state->code_input[0], scene_state->code_length);
|
||||
|
||||
memcpy(&plugin_state->iv[0], &plugin_state->base_iv[0], TOTP_IV_SIZE);
|
||||
for(uint8_t i = 0; i < scene_state->code_length; i++) {
|
||||
plugin_state->iv[i] = plugin_state->iv[i] ^
|
||||
(uint8_t)(scene_state->code_input[i] * (i + 1));
|
||||
}
|
||||
|
||||
if(plugin_state->crypto_verify_data == NULL) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Generating crypto verify data");
|
||||
plugin_state->crypto_verify_data = malloc(CRYPTO_VERIFY_KEY_LENGTH);
|
||||
plugin_state->crypto_verify_data_length = CRYPTO_VERIFY_KEY_LENGTH;
|
||||
Storage* storage = totp_open_storage();
|
||||
FlipperFormat* config_file = totp_open_config_file(storage);
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, &plugin_state->iv[0]);
|
||||
furi_hal_crypto_encrypt(
|
||||
(uint8_t*)CRYPTO_VERIFY_KEY,
|
||||
plugin_state->crypto_verify_data,
|
||||
CRYPTO_VERIFY_KEY_LENGTH);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
flipper_format_insert_or_update_hex(
|
||||
config_file, TOTP_CONFIG_KEY_BASE_IV, plugin_state->base_iv, TOTP_IV_SIZE);
|
||||
flipper_format_insert_or_update_hex(
|
||||
config_file,
|
||||
TOTP_CONFIG_KEY_CRYPTO_VERIFY,
|
||||
plugin_state->crypto_verify_data,
|
||||
CRYPTO_VERIFY_KEY_LENGTH);
|
||||
totp_close_config_file(config_file);
|
||||
totp_close_storage();
|
||||
}
|
||||
|
||||
uint8_t decrypted_key[CRYPTO_VERIFY_KEY_LENGTH];
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, &plugin_state->iv[0]);
|
||||
furi_hal_crypto_decrypt(
|
||||
plugin_state->crypto_verify_data, &decrypted_key[0], CRYPTO_VERIFY_KEY_LENGTH);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
|
||||
bool key_valid = true;
|
||||
for(uint8_t i = 0; i < CRYPTO_VERIFY_KEY_LENGTH && key_valid; i++) {
|
||||
if(decrypted_key[i] != CRYPTO_VERIFY_KEY[i]) key_valid = false;
|
||||
}
|
||||
|
||||
if(key_valid) {
|
||||
if(totp_crypto_verify_key(plugin_state)) {
|
||||
FURI_LOG_D(LOGGING_TAG, "PIN is valid");
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL);
|
||||
} else {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../../services/ui/constants.h"
|
||||
#include "../../services/totp/totp.h"
|
||||
#include "../../services/config/config.h"
|
||||
#include "../../services/crypto/crypto.h"
|
||||
#include "../scene_director.h"
|
||||
#include "../token_menu/totp_scene_token_menu.h"
|
||||
|
||||
@@ -156,24 +157,22 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_
|
||||
plugin_state->tokens_list, scene_state->current_token_index)
|
||||
->data);
|
||||
|
||||
uint8_t* key = malloc(tokenInfo->token_length);
|
||||
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, &plugin_state->iv[0]);
|
||||
furi_hal_crypto_decrypt(tokenInfo->token, key, tokenInfo->token_length);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
uint8_t key_length;
|
||||
uint8_t* key = totp_crypto_decrypt(
|
||||
tokenInfo->token, tokenInfo->token_length, &plugin_state->iv[0], &key_length);
|
||||
|
||||
i_token_to_str(
|
||||
totp_at(
|
||||
get_totp_algo_impl(tokenInfo->algo),
|
||||
token_info_get_digits_count(tokenInfo),
|
||||
key,
|
||||
tokenInfo->token_length,
|
||||
key_length,
|
||||
curr_ts,
|
||||
plugin_state->timezone_offset,
|
||||
TOKEN_LIFETIME),
|
||||
scene_state->last_code,
|
||||
tokenInfo->digits);
|
||||
memset(key, 0, tokenInfo->token_length);
|
||||
memset(key, 0, key_length);
|
||||
free(key);
|
||||
|
||||
if(is_new_token_time) {
|
||||
|
||||
@@ -199,6 +199,7 @@ void totp_full_save_config_file(PluginState* const plugin_state) {
|
||||
plugin_state->crypto_verify_data_length);
|
||||
flipper_format_write_float(
|
||||
fff_data_file, TOTP_CONFIG_KEY_TIMEZONE, &plugin_state->timezone_offset, 1);
|
||||
flipper_format_write_bool(fff_data_file, TOTP_CONFIG_KEY_PINSET, &plugin_state->pin_set, 1);
|
||||
ListNode* node = plugin_state->tokens_list;
|
||||
while(node != NULL) {
|
||||
TokenInfo* token_info = node->data;
|
||||
@@ -272,7 +273,8 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
|
||||
flipper_format_rewind(fff_data_file);
|
||||
|
||||
uint32_t crypto_size;
|
||||
if(flipper_format_get_value_count(fff_data_file, TOTP_CONFIG_KEY_CRYPTO_VERIFY, &crypto_size)) {
|
||||
if(flipper_format_get_value_count(fff_data_file, TOTP_CONFIG_KEY_CRYPTO_VERIFY, &crypto_size) &&
|
||||
crypto_size > 0) {
|
||||
plugin_state->crypto_verify_data = malloc(sizeof(uint8_t) * crypto_size);
|
||||
plugin_state->crypto_verify_data_length = crypto_size;
|
||||
if(!flipper_format_read_hex(
|
||||
@@ -283,7 +285,11 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Missing crypto verify token");
|
||||
free(plugin_state->crypto_verify_data);
|
||||
plugin_state->crypto_verify_data = NULL;
|
||||
plugin_state->crypto_verify_data_length = 0;
|
||||
}
|
||||
} else {
|
||||
plugin_state->crypto_verify_data = NULL;
|
||||
plugin_state->crypto_verify_data_length = 0;
|
||||
}
|
||||
|
||||
flipper_format_rewind(fff_data_file);
|
||||
@@ -294,6 +300,13 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Missing timezone offset information, defaulting to 0");
|
||||
}
|
||||
|
||||
flipper_format_rewind(fff_data_file);
|
||||
|
||||
if(!flipper_format_read_bool(
|
||||
fff_data_file, TOTP_CONFIG_KEY_PINSET, &plugin_state->pin_set, 1)) {
|
||||
plugin_state->pin_set = true;
|
||||
}
|
||||
|
||||
furi_string_free(temp_str);
|
||||
totp_close_config_file(fff_data_file);
|
||||
totp_close_storage();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define TOTP_CONFIG_KEY_TOKEN_DIGITS "TokenDigits"
|
||||
#define TOTP_CONFIG_KEY_CRYPTO_VERIFY "Crypto"
|
||||
#define TOTP_CONFIG_KEY_BASE_IV "BaseIV"
|
||||
#define TOTP_CONFIG_KEY_PINSET "PinIsSet"
|
||||
|
||||
#define TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME "sha1"
|
||||
#define TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME "sha256"
|
||||
|
||||
134
applications/plugins/totp/services/crypto/crypto.c
Normal file
134
applications/plugins/totp/services/crypto/crypto.c
Normal file
@@ -0,0 +1,134 @@
|
||||
#include "crypto.h"
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include "../config/config.h"
|
||||
#include "../../types/common.h"
|
||||
|
||||
#define CRYPTO_KEY_SLOT 2
|
||||
#define CRYPTO_VERIFY_KEY "FFF_Crypto_pass"
|
||||
#define CRYPTO_VERIFY_KEY_LENGTH 16
|
||||
#define CRYPTO_ALIGNMENT_FACTOR 16
|
||||
|
||||
uint8_t* totp_crypto_encrypt(
|
||||
const uint8_t* plain_data,
|
||||
const uint8_t plain_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* encrypted_data_length) {
|
||||
uint8_t* encrypted_data;
|
||||
size_t remain = plain_data_length % CRYPTO_ALIGNMENT_FACTOR;
|
||||
if(remain) {
|
||||
uint8_t plain_data_aligned_length = plain_data_length - remain + CRYPTO_ALIGNMENT_FACTOR;
|
||||
uint8_t* plain_data_aligned = malloc(plain_data_aligned_length);
|
||||
memset(plain_data_aligned, 0, plain_data_aligned_length);
|
||||
memcpy(plain_data_aligned, plain_data, plain_data_length);
|
||||
|
||||
encrypted_data = malloc(plain_data_aligned_length);
|
||||
*encrypted_data_length = plain_data_aligned_length;
|
||||
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, iv);
|
||||
furi_hal_crypto_encrypt(plain_data_aligned, encrypted_data, plain_data_aligned_length);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
|
||||
memset(plain_data_aligned, 0, plain_data_aligned_length);
|
||||
free(plain_data_aligned);
|
||||
} else {
|
||||
encrypted_data = malloc(plain_data_length);
|
||||
*encrypted_data_length = plain_data_length;
|
||||
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, iv);
|
||||
furi_hal_crypto_encrypt(plain_data, encrypted_data, plain_data_length);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
}
|
||||
|
||||
return encrypted_data;
|
||||
}
|
||||
|
||||
uint8_t* totp_crypto_decrypt(
|
||||
const uint8_t* encrypted_data,
|
||||
const uint8_t encrypted_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* decrypted_data_length) {
|
||||
*decrypted_data_length = encrypted_data_length;
|
||||
uint8_t* decrypted_data = malloc(*decrypted_data_length);
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, iv);
|
||||
furi_hal_crypto_decrypt(encrypted_data, decrypted_data, encrypted_data_length);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
return decrypted_data;
|
||||
}
|
||||
|
||||
void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_length) {
|
||||
if(plugin_state->crypto_verify_data == NULL) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Generating new IV");
|
||||
furi_hal_random_fill_buf(&plugin_state->base_iv[0], TOTP_IV_SIZE);
|
||||
}
|
||||
|
||||
memcpy(&plugin_state->iv[0], &plugin_state->base_iv[0], TOTP_IV_SIZE);
|
||||
if(pin != NULL && pin_length > 0) {
|
||||
uint8_t max_i;
|
||||
if(pin_length > TOTP_IV_SIZE) {
|
||||
max_i = TOTP_IV_SIZE;
|
||||
} else {
|
||||
max_i = pin_length;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < max_i; i++) {
|
||||
plugin_state->iv[i] = plugin_state->iv[i] ^ (uint8_t)(pin[i] * (i + 1));
|
||||
}
|
||||
} else {
|
||||
uint8_t max_i;
|
||||
size_t uid_size = furi_hal_version_uid_size();
|
||||
if(uid_size > TOTP_IV_SIZE) {
|
||||
max_i = TOTP_IV_SIZE;
|
||||
} else {
|
||||
max_i = uid_size;
|
||||
}
|
||||
|
||||
const uint8_t* uid = furi_hal_version_uid();
|
||||
for(uint8_t i = 0; i < max_i; i++) {
|
||||
plugin_state->iv[i] = plugin_state->iv[i] ^ uid[i];
|
||||
}
|
||||
}
|
||||
|
||||
if(plugin_state->crypto_verify_data == NULL) {
|
||||
FURI_LOG_D(LOGGING_TAG, "Generating crypto verify data");
|
||||
plugin_state->crypto_verify_data = malloc(CRYPTO_VERIFY_KEY_LENGTH);
|
||||
plugin_state->crypto_verify_data_length = CRYPTO_VERIFY_KEY_LENGTH;
|
||||
Storage* storage = totp_open_storage();
|
||||
FlipperFormat* config_file = totp_open_config_file(storage);
|
||||
|
||||
plugin_state->crypto_verify_data = totp_crypto_encrypt(
|
||||
(uint8_t*)CRYPTO_VERIFY_KEY,
|
||||
CRYPTO_VERIFY_KEY_LENGTH,
|
||||
&plugin_state->iv[0],
|
||||
&plugin_state->crypto_verify_data_length);
|
||||
|
||||
flipper_format_insert_or_update_hex(
|
||||
config_file, TOTP_CONFIG_KEY_BASE_IV, plugin_state->base_iv, TOTP_IV_SIZE);
|
||||
flipper_format_insert_or_update_hex(
|
||||
config_file,
|
||||
TOTP_CONFIG_KEY_CRYPTO_VERIFY,
|
||||
plugin_state->crypto_verify_data,
|
||||
CRYPTO_VERIFY_KEY_LENGTH);
|
||||
plugin_state->pin_set = pin != NULL && pin_length > 0;
|
||||
flipper_format_insert_or_update_bool(
|
||||
config_file, TOTP_CONFIG_KEY_PINSET, &plugin_state->pin_set, 1);
|
||||
totp_close_config_file(config_file);
|
||||
totp_close_storage();
|
||||
}
|
||||
}
|
||||
|
||||
bool totp_crypto_verify_key(const PluginState* plugin_state) {
|
||||
uint8_t decrypted_key_length;
|
||||
uint8_t* decrypted_key = totp_crypto_decrypt(
|
||||
plugin_state->crypto_verify_data,
|
||||
plugin_state->crypto_verify_data_length,
|
||||
&plugin_state->iv[0],
|
||||
&decrypted_key_length);
|
||||
|
||||
bool key_valid = true;
|
||||
for(uint8_t i = 0; i < CRYPTO_VERIFY_KEY_LENGTH && key_valid; i++) {
|
||||
if(decrypted_key[i] != CRYPTO_VERIFY_KEY[i]) key_valid = false;
|
||||
}
|
||||
|
||||
return key_valid;
|
||||
}
|
||||
16
applications/plugins/totp/services/crypto/crypto.h
Normal file
16
applications/plugins/totp/services/crypto/crypto.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../types/plugin_state.h"
|
||||
|
||||
uint8_t* totp_crypto_encrypt(
|
||||
const uint8_t* plain_data,
|
||||
const uint8_t plain_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* encrypted_data_length);
|
||||
uint8_t* totp_crypto_decrypt(
|
||||
const uint8_t* encrypted_data,
|
||||
const uint8_t encrypted_data_length,
|
||||
const uint8_t* iv,
|
||||
uint8_t* decrypted_data_length);
|
||||
void totp_crypto_seed_iv(PluginState* plugin_state, uint8_t* pin, uint8_t pin_length);
|
||||
bool totp_crypto_verify_key(const PluginState* plugin_state);
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "types/event_type.h"
|
||||
#include "types/common.h"
|
||||
#include "scenes/scene_director.h"
|
||||
#include "services/ui/constants.h"
|
||||
#include "services/crypto/crypto.h"
|
||||
|
||||
#define IDLE_TIMEOUT 60000
|
||||
|
||||
@@ -35,14 +37,58 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void totp_state_init(PluginState* const plugin_state) {
|
||||
static bool totp_state_init(PluginState* const plugin_state) {
|
||||
plugin_state->gui = furi_record_open(RECORD_GUI);
|
||||
plugin_state->notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
plugin_state->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
totp_config_file_load_base(plugin_state);
|
||||
|
||||
totp_scene_director_init_scenes(plugin_state);
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneAuthentication, NULL);
|
||||
|
||||
if(plugin_state->crypto_verify_data == NULL) {
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
dialog_message_set_buttons(message, "No", NULL, "Yes");
|
||||
dialog_message_set_text(
|
||||
message,
|
||||
"Would you like to setup PIN?",
|
||||
SCREEN_WIDTH_CENTER,
|
||||
SCREEN_HEIGHT_CENTER,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
DialogMessageButton dialog_result = dialog_message_show(plugin_state->dialogs, message);
|
||||
dialog_message_free(message);
|
||||
if(dialog_result == DialogMessageButtonRight) {
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneAuthentication, NULL);
|
||||
} else {
|
||||
totp_crypto_seed_iv(plugin_state, NULL, 0);
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL);
|
||||
}
|
||||
} else if(plugin_state->pin_set) {
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneAuthentication, NULL);
|
||||
} else {
|
||||
totp_crypto_seed_iv(plugin_state, NULL, 0);
|
||||
if(totp_crypto_verify_key(plugin_state)) {
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL);
|
||||
} else {
|
||||
FURI_LOG_E(
|
||||
LOGGING_TAG,
|
||||
"Digital signature verification failed. Looks like conf file was created on another flipper and can't be used on any other");
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
dialog_message_set_buttons(message, "Exit", NULL, NULL);
|
||||
dialog_message_set_text(
|
||||
message,
|
||||
"Digital signature verification failed",
|
||||
SCREEN_WIDTH_CENTER,
|
||||
SCREEN_HEIGHT_CENTER,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
dialog_message_show(plugin_state->dialogs, message);
|
||||
dialog_message_free(message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void dispose_plugin_state(PluginState* plugin_state) {
|
||||
@@ -74,7 +120,11 @@ int32_t totp_app() {
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
|
||||
PluginState* plugin_state = malloc(sizeof(PluginState));
|
||||
|
||||
totp_state_init(plugin_state);
|
||||
if(!totp_state_init(plugin_state)) {
|
||||
FURI_LOG_E(LOGGING_TAG, "App state initialization failed\r\n");
|
||||
dispose_plugin_state(plugin_state);
|
||||
return 254;
|
||||
}
|
||||
|
||||
ValueMutex state_mutex;
|
||||
if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) {
|
||||
@@ -107,7 +157,7 @@ int32_t totp_app() {
|
||||
|
||||
processing = totp_scene_director_handle_event(&event, plugin_state);
|
||||
} else if(
|
||||
plugin_state->current_scene != TotpSceneAuthentication &&
|
||||
plugin_state->pin_set && plugin_state->current_scene != TotpSceneAuthentication &&
|
||||
furi_get_tick() - last_user_interaction_time > IDLE_TIMEOUT) {
|
||||
totp_scene_director_activate_scene(plugin_state, TotpSceneAuthentication, NULL);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define LOGGING_TAG "TOTP APP"
|
||||
#define CRYPTO_KEY_SLOT 2
|
||||
|
||||
@@ -23,6 +23,7 @@ typedef struct {
|
||||
|
||||
uint8_t* crypto_verify_data;
|
||||
uint8_t crypto_verify_data_length;
|
||||
bool pin_set;
|
||||
uint8_t iv[TOTP_IV_SIZE];
|
||||
uint8_t base_iv[TOTP_IV_SIZE];
|
||||
} PluginState;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "stdlib.h"
|
||||
#include "common.h"
|
||||
#include "../services/base32/base32.h"
|
||||
#include "../services/crypto/crypto.h"
|
||||
|
||||
TokenInfo* token_info_alloc() {
|
||||
TokenInfo* tokenInfo = malloc(sizeof(TokenInfo));
|
||||
@@ -27,25 +28,11 @@ void token_info_set_secret(
|
||||
uint8_t* plain_secret = malloc(token_secret_length);
|
||||
int plain_secret_length =
|
||||
base32_decode((uint8_t*)base32_token_secret, plain_secret, token_secret_length);
|
||||
token_info->token_length = plain_secret_length;
|
||||
|
||||
size_t remain = token_info->token_length % 16;
|
||||
if(remain) {
|
||||
token_info->token_length = token_info->token_length - remain + 16;
|
||||
uint8_t* plain_secret_aligned = malloc(token_info->token_length);
|
||||
memcpy(plain_secret_aligned, plain_secret, plain_secret_length);
|
||||
memset(plain_secret, 0, plain_secret_length);
|
||||
free(plain_secret);
|
||||
plain_secret = plain_secret_aligned;
|
||||
}
|
||||
token_info->token =
|
||||
totp_crypto_encrypt(plain_secret, plain_secret_length, iv, &token_info->token_length);
|
||||
|
||||
token_info->token = malloc(token_info->token_length);
|
||||
|
||||
furi_hal_crypto_store_load_key(CRYPTO_KEY_SLOT, iv);
|
||||
furi_hal_crypto_encrypt(plain_secret, token_info->token, token_info->token_length);
|
||||
furi_hal_crypto_store_unload_key(CRYPTO_KEY_SLOT);
|
||||
|
||||
memset(plain_secret, 0, token_info->token_length);
|
||||
memset(plain_secret, 0, token_secret_length);
|
||||
free(plain_secret);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,11 @@ static uint16_t bt_serial_event_callback(SerialServiceEvent event, void* context
|
||||
ret = rpc_session_get_available_size(bt->rpc_session);
|
||||
} else if(event.event == SerialServiceEventTypeDataSent) {
|
||||
furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_BUFF_SENT);
|
||||
} else if(event.event == SerialServiceEventTypesBleResetRequest) {
|
||||
FURI_LOG_I(TAG, "BLE restart request received");
|
||||
BtMessage message = {.type = BtMessageTypeSetProfile, .data.profile = BtProfileSerial};
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -226,6 +231,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
||||
rpc_session_set_context(bt->rpc_session, bt);
|
||||
furi_hal_bt_serial_set_event_callback(
|
||||
RPC_BUFFER_SIZE, bt_serial_event_callback, bt);
|
||||
furi_hal_bt_serial_set_rpc_status(FuriHalBtSerialRpcStatusActive);
|
||||
} else {
|
||||
FURI_LOG_W(TAG, "RPC is busy, failed to open new session");
|
||||
}
|
||||
@@ -241,6 +247,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
||||
} else if(event.type == GapEventTypeDisconnected) {
|
||||
if(bt->profile == BtProfileSerial && bt->rpc_session) {
|
||||
FURI_LOG_I(TAG, "Close RPC connection");
|
||||
furi_hal_bt_serial_set_rpc_status(FuriHalBtSerialRpcStatusNotActive);
|
||||
furi_event_flag_set(bt->rpc_event, BT_RPC_EVENT_DISCONNECTED);
|
||||
rpc_session_close(bt->rpc_session);
|
||||
furi_hal_bt_serial_set_event_callback(0, NULL, NULL);
|
||||
@@ -330,14 +337,20 @@ static void bt_change_profile(Bt* bt, BtMessage* message) {
|
||||
}
|
||||
furi_hal_bt_set_key_storage_change_callback(bt_on_key_storage_change_callback, bt);
|
||||
bt->profile = message->data.profile;
|
||||
*message->result = true;
|
||||
if(message->result) {
|
||||
*message->result = true;
|
||||
}
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Failed to start Bt App");
|
||||
*message->result = false;
|
||||
if(message->result) {
|
||||
*message->result = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bt_show_warning(bt, "Radio stack doesn't support this app");
|
||||
*message->result = false;
|
||||
if(message->result) {
|
||||
*message->result = false;
|
||||
}
|
||||
}
|
||||
furi_event_flag_set(bt->api_event, BT_API_UNLOCK_EVENT);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ static const DolphinDeedWeight dolphin_deed_weights[] = {
|
||||
{2, DolphinAppIbutton}, // DolphinDeedIbuttonAdd
|
||||
|
||||
{3, DolphinAppBadusb}, // DolphinDeedBadUsbPlayScript
|
||||
{3, DolphinAppU2f}, // DolphinDeedU2fAuthorized
|
||||
{3, DolphinAppPlugin}, // DolphinDeedU2fAuthorized
|
||||
|
||||
{1, DolphinAppGpio}, // DolphinDeedGpioUartBridge
|
||||
{1, DolphinAppPlugin}, // DolphinDeedGpioUartBridge
|
||||
|
||||
{1, DolphinAppPlugin}, // DolphinDeedPluginStart
|
||||
{1, DolphinAppPlugin}, // DolphinDeedPluginGameStart
|
||||
@@ -51,8 +51,6 @@ static uint8_t dolphin_deed_limits[] = {
|
||||
20, // DolphinAppIr
|
||||
20, // DolphinAppIbutton
|
||||
20, // DolphinAppBadusb
|
||||
20, // DolphinAppU2f
|
||||
20, // DolphinAppGpio
|
||||
20, // DolphinAppPlugin
|
||||
};
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ typedef enum {
|
||||
DolphinAppIr,
|
||||
DolphinAppIbutton,
|
||||
DolphinAppBadusb,
|
||||
DolphinAppU2f,
|
||||
DolphinAppGpio,
|
||||
DolphinAppPlugin,
|
||||
DolphinAppMAX,
|
||||
} DolphinApp;
|
||||
@@ -55,7 +53,6 @@ typedef enum {
|
||||
DolphinDeedBadUsbPlayScript,
|
||||
|
||||
DolphinDeedU2fAuthorized,
|
||||
|
||||
DolphinDeedGpioUartBridge,
|
||||
|
||||
DolphinDeedPluginStart,
|
||||
|
||||
@@ -11,9 +11,16 @@ static bool favorite_fap_selector_item_callback(
|
||||
uint8_t** icon_ptr,
|
||||
FuriString* item_name) {
|
||||
UNUSED(context);
|
||||
#ifdef APP_FAP_LOADER
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool success = fap_loader_load_name_and_icon(file_path, storage, icon_ptr, item_name);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
#else
|
||||
UNUSED(file_path);
|
||||
UNUSED(icon_ptr);
|
||||
UNUSED(item_name);
|
||||
bool success = false;
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -113,6 +120,7 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
}
|
||||
}
|
||||
|
||||
submenu_reset(app->submenu);
|
||||
if(dialog_file_browser_show(app->dialogs, temp_path, temp_path, &browser_options)) {
|
||||
if(primary_favorite) {
|
||||
app->settings.favorite_primary.is_external = true;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
Filetype: IR library file
|
||||
Version: 1
|
||||
# Last Updated 4th Oct, 2022
|
||||
# Last Updated 15th Oct, 2022
|
||||
#
|
||||
name: MUTE
|
||||
type: parsed
|
||||
protocol: NECext
|
||||
address: BA A0 00 00
|
||||
command: 01 FE 00 00
|
||||
#
|
||||
name: POWER
|
||||
type: raw
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
Filetype: IR library file
|
||||
Version: 1
|
||||
# Last Updated 30th Sept, 2022
|
||||
# Last Updated 15th Oct, 2022
|
||||
#
|
||||
# ON
|
||||
name: POWER
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9096 4436 620 505 647 478 648 501 623 1599 647 1624 623 502 623 503 621 504 619 1628 618 507 617 507 617 1630 617 508 616 1630 617 1630 617 1631 616 508 616 508 617 508 616 1631 616 508 617 508 617 508 616 508 616 1630 616 1630 616 1631 616 508 616 1630 617 1630 617 1630 617 1631 617 509 616 508 616 509 616 509 616 509 616 509 615 509 616 508 617 1631 616 1631 615 1631 616 1631 616 1631 616 1631 616 1631 615 1631 616 14435 9093 2186 615 96359 9095 2184 617
|
||||
#
|
||||
name: VOL+
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9091 4465 594 530 595 530 594 530 594 1651 595 1652 595 529 621 504 620 504 619 1628 618 507 617 508 616 1631 616 509 615 1631 616 1631 616 1632 615 509 616 509 616 509 615 1631 616 509 616 508 616 1631 616 509 616 1631 615 1631 616 1631 617 508 616 1631 616 1631 616 508 616 1631 617 508 617 509 616 509 616 509 616 509 616 509 616 509 616 509 616 1631 616 1631 616 1631 616 1631 616 1631 615 1631 615 1631 615 1631 616 14435 9090 2190 615
|
||||
#
|
||||
name: VOL-
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9092 4439 620 506 619 506 618 530 593 1627 620 1630 643 504 620 505 618 506 617 1630 617 508 616 508 616 1632 616 508 617 1631 616 1631 616 1631 616 1631 616 509 616 508 616 1631 616 509 616 509 615 1632 616 509 616 508 616 1631 616 1631 616 508 616 1631 615 1631 616 509 615 1632 615 509 616 509 616 509 616 509 616 509 616 510 615 509 616 509 616 1631 616 1631 615 1631 616 1631 615 1631 615 1631 615 1631 615 1631 615 14434 9088 2191 615 96339 9115 2189 616 96343 9117 2189 616 96343 9114 2189 616
|
||||
# AV-MUTE
|
||||
name: MUTE
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9092 4439 620 506 618 506 618 530 594 1627 619 1629 643 505 619 505 619 506 617 1629 617 508 616 508 616 1631 616 508 616 1630 616 1630 616 1630 617 1630 616 1630 616 1631 616 508 616 508 616 508 616 1631 616 508 617 508 616 508 616 508 616 1630 616 1631 615 1631 616 508 616 1631 616 508 617 508 616 509 615 509 616 508 616 509 615 509 616 508 616 1631 615 1631 615 1631 616 1631 615 1631 615 1631 615 1631 615 1631 616 14433 9088 2191 615
|
||||
#
|
||||
name: POWER
|
||||
type: raw
|
||||
@@ -445,4 +470,10 @@ type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3523 1701 472 426 444 1269 472 426 444 426 442 429 443 427 443 426 444 426 444 426 443 427 442 429 440 430 439 432 438 1304 437 433 437 432 438 432 438 433 437 433 437 433 437 433 437 433 437 433 437 1304 437 433 437 433 437 433 437 1304 437 433 437 433 437 1304 437 433 437 434 436 433 437 434 436 434 436 434 436 433 437 433 437 434 436 1304 437 1305 436 1305 436 1305 436 1305 436 1305 436 434 436 434 436 1305 436 1305 436 1305 436 434 436 1305 436 1305 436 1306 435 1306 435 74393 3515 1736 437 433 437 1304 437 433 437 433 437 433 437 433 437 433 437 433 437 433 437 434 436 433 437 434 436 434 436 1304 437 434 436 434 436 434 436 434 436 434 436 434 436 434 436 434 436 434 436 1305 436 434 436 434 436 434 436 1305 436 434 436 434 436 1306 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 436 434 435 435 1307 434 1331 410 1307 434 1307 434 1330 411 1307 434 460 410 460 410 1331 410 1331 410 1331 410 460 410 1331 410 1331 410 1331 410 1331 410 74393 3515 1736 437 433 437 1304 437 433 437 433 437 433 437 433 437 433 437 433 437 433 437 434 436 434 436 433 437 433 437 1304 437 434 436 434 436 434 437 434 436 434 436 434 436 434 436 434 436 434 436 1305 436 434 436 434 436 434 436 1305 436 435 435 434 436 1305 436 434 436 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 1307 434 1306 435 1307 434 1307 434 1307 434 1331 410 460 410 460 410 1331 410 1331 410 1331 410 460 410 1331 410 1331 410 1331 410 1331 410 74393 3515 1736 437 433 437 1304 437 433 437 433 437 433 437 433 437 433 437 433 437 433 437 433 437 433 437 434 436 433 437 1304 437 433 437 434 436 434 436 434 436 434 436 434 436 434 436 434 436 434 437 1305 436 434 436 434 436 434 436 1305 436 434 436 434 436 1306 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 1307 434 1330 411 1330 411 1330 411 1330 411 1330 411 460 410 460 410 1331 410 1331 410 1331 410 460 410 1331 410 1331 410 1331 410 1331 410
|
||||
# Standby/Off
|
||||
name: POWER
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9093 4441 620 507 618 530 594 531 593 1652 595 1653 620 505 620 505 619 506 617 1630 616 508 616 508 616 1632 615 509 615 1631 616 1632 615 1632 615 510 615 509 615 1632 615 509 615 1632 615 510 615 510 614 509 615 1632 614 1633 614 509 615 1633 614 509 615 1632 615 1632 614 1633 614 510 614 510 615 510 615 510 614 510 614 510 615 510 615 510 614 1632 615 1632 614 1632 615 1632 615 1632 615 1632 615 1632 615 1633 614 14439 9088 2192 614 96349 9112 2190 616
|
||||
#
|
||||
|
||||
@@ -1,6 +1,42 @@
|
||||
Filetype: IR library file
|
||||
Version: 1
|
||||
# Last Updated 4th Oct, 2022
|
||||
# Last Updated 15th Oct, 2022
|
||||
#
|
||||
name: POWER
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3562 1687 494 382 493 1257 493 382 492 382 493 383 492 383 492 384 491 384 490 384 491 384 491 384 491 384 491 384 490 1260 491 383 492 384 491 384 491 384 491 384 491 384 491 384 491 383 492 383 492 1259 491 383 492 384 491 384 491 384 491 384 491 384 490 384 491 384 491 1260 490 384 491 1260 490 1259 492 1259 490 1260 490 384 490 384 491 1260 490 383 492 1259 491 1259 491 1259 491 1259 491 384 490 1259 491 75054 3561 1687 494 381 494 1256 494 382 492 382 493 383 492 383 491 383 492 384 490 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 383 492 384 491 384 491 384 491 383 492 383 492 383 492 384 491 1259 491 383 492 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 1259 491 1259 491 1259 491 1259 491 384 491 384 491 1259 491 383 492 1259 491 1259 491 1259 491 1259 491 384 491 1259 491 75053 3560 1688 493 382 492 1258 492 383 492 384 491 384 491 384 491 384 491 384 491 384 491 383 492 384 491 384 491 384 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 383 492 384 491 384 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 1259 491 1259 491 1259 491 1259 491 384 491 384 491 1259 492 383 492 1259 491 1259 491 1259 491 1259 491 384 491 1259 491
|
||||
#
|
||||
name: VOL+
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3565 1685 496 380 494 1255 495 381 493 381 494 381 493 382 492 382 493 382 492 383 492 383 492 383 492 384 491 383 491 1260 491 384 491 384 491 384 491 384 491 384 491 384 491 384 490 384 491 384 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 490 385 490 384 491 384 491 384 491 1260 490 384 491 384 491 384 491 384 490 384 491 384 491 384 491 1260 490 384 491 1259 491 74918 3534 1690 491 383 492 1259 491 383 492 384 490 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 490 385 490 384 491 384 491 1260 491 384 491 384 491 384 491 385 490 384 491 384 491 384 491 385 490 384 491 385 490 384 490 384 491 385 490 1260 490 384 491 385 490 384 490 384 491 384 491 384 491 385 490 1260 490 385 490 1260 490
|
||||
#
|
||||
name: VOL-
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3563 1686 495 381 494 1256 493 381 494 382 492 382 493 382 493 383 491 383 491 384 491 383 491 384 491 384 491 384 491 1260 490 384 491 384 490 385 490 384 491 385 490 385 490 384 491 385 490 384 491 1260 490 385 490 385 490 384 491 385 490 385 490 384 490 385 490 385 490 1260 490 385 490 385 490 385 490 385 490 1261 489 385 490 386 489 1260 490 385 490 385 490 385 490 385 490 1260 490 385 490 1261 489 75231 3533 1690 491 385 490 1260 490 384 491 384 491 384 491 384 491 384 491 384 490 385 490 384 490 385 490 385 489 385 490 1260 490 385 490 384 491 384 491 385 490 385 490 385 490 384 491 385 490 385 490 1260 490 385 490 385 490 385 490 384 491 384 491 385 490 385 490 385 490 1261 489 385 490 385 489 385 490 385 490 1260 490 385 490 385 490 1260 490 385 490 385 490 385 490 385 490 1260 490 385 490 1260 491
|
||||
#
|
||||
name: MUTE
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3570 1654 527 375 499 1224 526 376 499 376 498 377 497 377 497 378 496 378 496 379 495 379 495 380 494 380 494 381 493 1256 494 381 493 382 492 383 492 383 492 383 492 383 492 383 492 383 492 383 492 1259 491 383 492 383 492 383 492 383 492 383 492 383 492 383 492 383 492 383 492 1258 492 383 492 383 492 1259 491 1259 491 383 492 383 492 383 492 1259 492 383 492 383 492 1259 491 1258 492 383 492 1259 491 74993 3561 1688 493 382 492 1258 492 383 492 383 492 383 492 383 492 383 492 383 492 383 492 383 492 384 491 384 491 384 491 1259 491 384 491 384 491 383 492 383 492 384 491 384 491 384 491 384 491 384 491 1259 492 383 492 383 491 384 491 383 492 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 384 491 1259 491 1259 491 384 491 384 491 384 491 1259 491 384 491 384 491 1259 491 1259 491 384 491 1259 491
|
||||
#
|
||||
name: CH+
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3568 1655 526 376 498 1226 524 377 497 378 496 379 495 379 496 379 495 380 494 381 493 381 493 381 493 382 493 382 492 1258 492 383 492 383 492 383 492 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 384 491 383 492 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 1259 491 1259 491 384 491 383 492 384 491 384 491 1259 491 384 491 1259 491 1259 491 384 491 1259 491 74991 3558 1689 492 383 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 384 491 384 491 384 491 384 490 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 1260 490 1260 491 384 490 384 491 384 491 384 491 1260 490 384 491 1260 490 1260 490 384 491 1260 490 74966 3559 1689 492 383 492 1259 491 383 492 383 492 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 383 492 383 492 384 491 384 491 384 491 384 491 384 490 384 491 384 491 1260 490 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 1259 491 1260 490 384 491 384 491 384 491 384 491 1260 490 384 491 1260 490 1260 490 384 491 1260 490 74966 3559 1690 491 383 492 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 384 491 384 491 384 491 385 490 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 1260 490 1260 490 384 491 384 491 384 491 384 491 1260 490 384 491 1260 490 1260 490 385 490 1260 491 75014 3535 1690 491 383 492 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1259 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 384 491 1260 490 384 491 1260 490 1260 490 384 491 384 491 384 491 385 490 1260 490 384 491 1260 490 1260 490 384 491 1260 490
|
||||
#
|
||||
name: CH-
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 3568 1655 526 376 498 1223 553 349 499 376 498 377 498 377 498 377 497 377 498 377 497 377 497 378 496 378 496 379 495 1255 494 381 493 382 492 383 491 384 491 385 489 385 490 385 490 385 490 385 490 1260 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 1261 489 385 490 1261 489 385 490 1261 489 1261 489 386 489 385 490 1261 489 385 490 1261 489 386 489 1261 489 1261 489 386 489 1261 489 74774 3560 1690 491 383 491 1260 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 1260 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 1261 489 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 1261 489 385 490 1261 489 386 489 1262 488 1261 489 386 489 386 489 1261 489 386 489 1261 489 386 489 1261 489 1262 488 386 489 1287 463 74751 3559 1690 491 384 490 1260 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 1261 489 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 385 490 1261 489 385 490 385 490 385 490 385 490 386 489 386 489 385 490 386 489 1261 489 386 489 1261 489 386 489 1261 489 1261 489 386 489 386 489 1261 489 386 489 1262 488 387 488 1262 488 1262 488 386 489 1262 488
|
||||
#
|
||||
name: POWER
|
||||
type: raw
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 933 B |
@@ -4044,17 +4044,17 @@ Function,+,view_port_alloc,ViewPort*,
|
||||
Function,+,view_port_draw_callback_set,void,"ViewPort*, ViewPortDrawCallback, void*"
|
||||
Function,+,view_port_enabled_set,void,"ViewPort*, _Bool"
|
||||
Function,+,view_port_free,void,ViewPort*
|
||||
Function,-,view_port_get_height,uint8_t,ViewPort*
|
||||
Function,+,view_port_get_height,uint8_t,ViewPort*
|
||||
Function,+,view_port_get_orientation,ViewPortOrientation,const ViewPort*
|
||||
Function,+,view_port_get_width,uint8_t,ViewPort*
|
||||
Function,+,view_port_input_callback_set,void,"ViewPort*, ViewPortInputCallback, void*"
|
||||
Function,+,view_port_is_enabled,_Bool,ViewPort*
|
||||
Function,-,view_port_set_height,void,"ViewPort*, uint8_t"
|
||||
Function,+,view_port_set_height,void,"ViewPort*, uint8_t"
|
||||
Function,+,view_port_set_orientation,void,"ViewPort*, ViewPortOrientation"
|
||||
Function,+,view_port_set_width,void,"ViewPort*, uint8_t"
|
||||
Function,+,view_port_update,void,ViewPort*
|
||||
Function,+,view_set_context,void,"View*, void*"
|
||||
Function,-,view_set_custom_callback,void,"View*, ViewCustomCallback"
|
||||
Function,+,view_set_custom_callback,void,"View*, ViewCustomCallback"
|
||||
Function,+,view_set_draw_callback,void,"View*, ViewDrawCallback"
|
||||
Function,+,view_set_enter_callback,void,"View*, ViewCallback"
|
||||
Function,+,view_set_exit_callback,void,"View*, ViewCallback"
|
||||
|
||||
|
@@ -11,6 +11,7 @@ typedef struct {
|
||||
uint16_t rx_char_handle;
|
||||
uint16_t tx_char_handle;
|
||||
uint16_t flow_ctrl_char_handle;
|
||||
uint16_t rpc_status_char_handle;
|
||||
FuriMutex* buff_size_mtx;
|
||||
uint32_t buff_size;
|
||||
uint16_t bytes_ready_to_receive;
|
||||
@@ -28,6 +29,8 @@ static const uint8_t char_rx_uuid[] =
|
||||
{0x00, 0x00, 0xfe, 0x62, 0x8e, 0x22, 0x45, 0x41, 0x9d, 0x4c, 0x21, 0xed, 0xae, 0x82, 0xed, 0x19};
|
||||
static const uint8_t flow_ctrl_uuid[] =
|
||||
{0x00, 0x00, 0xfe, 0x63, 0x8e, 0x22, 0x45, 0x41, 0x9d, 0x4c, 0x21, 0xed, 0xae, 0x82, 0xed, 0x19};
|
||||
static const uint8_t rpc_status_uuid[] =
|
||||
{0x00, 0x00, 0xfe, 0x64, 0x8e, 0x22, 0x45, 0x41, 0x9d, 0x4c, 0x21, 0xed, 0xae, 0x82, 0xed, 0x19};
|
||||
|
||||
static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void* event) {
|
||||
SVCCTL_EvtAckStatus_t ret = SVCCTL_EvtNotAck;
|
||||
@@ -67,6 +70,17 @@ static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void* event) {
|
||||
furi_check(furi_mutex_release(serial_svc->buff_size_mtx) == FuriStatusOk);
|
||||
}
|
||||
ret = SVCCTL_EvtAckFlowEnable;
|
||||
} else if(attribute_modified->Attr_Handle == serial_svc->rpc_status_char_handle + 1) {
|
||||
SerialServiceRpcStatus* rpc_status =
|
||||
(SerialServiceRpcStatus*)attribute_modified->Attr_Data;
|
||||
if(*rpc_status == SerialServiceRpcStatusNotActive) {
|
||||
if(serial_svc->callback) {
|
||||
SerialServiceEvent event = {
|
||||
.event = SerialServiceEventTypesBleResetRequest,
|
||||
};
|
||||
serial_svc->callback(event, serial_svc->context);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) {
|
||||
FURI_LOG_T(TAG, "Ack received");
|
||||
@@ -82,6 +96,18 @@ static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void* event) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void serial_svc_update_rpc_char(SerialServiceRpcStatus status) {
|
||||
tBleStatus ble_status = aci_gatt_update_char_value(
|
||||
serial_svc->svc_handle,
|
||||
serial_svc->rpc_status_char_handle,
|
||||
0,
|
||||
sizeof(SerialServiceRpcStatus),
|
||||
(uint8_t*)&status);
|
||||
if(ble_status) {
|
||||
FURI_LOG_E(TAG, "Failed to update RPC status char: %d", ble_status);
|
||||
}
|
||||
}
|
||||
|
||||
void serial_svc_start() {
|
||||
tBleStatus status;
|
||||
serial_svc = malloc(sizeof(SerialSvc));
|
||||
@@ -90,7 +116,7 @@ void serial_svc_start() {
|
||||
|
||||
// Add service
|
||||
status = aci_gatt_add_service(
|
||||
UUID_TYPE_128, (Service_UUID_t*)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle);
|
||||
UUID_TYPE_128, (Service_UUID_t*)service_uuid, PRIMARY_SERVICE, 12, &serial_svc->svc_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(TAG, "Failed to add Serial service: %d", status);
|
||||
}
|
||||
@@ -141,6 +167,22 @@ void serial_svc_start() {
|
||||
if(status) {
|
||||
FURI_LOG_E(TAG, "Failed to add Flow Control characteristic: %d", status);
|
||||
}
|
||||
// Add RPC status characteristic
|
||||
status = aci_gatt_add_char(
|
||||
serial_svc->svc_handle,
|
||||
UUID_TYPE_128,
|
||||
(const Char_UUID_t*)rpc_status_uuid,
|
||||
sizeof(SerialServiceRpcStatus),
|
||||
CHAR_PROP_READ | CHAR_PROP_WRITE | CHAR_PROP_NOTIFY,
|
||||
ATTR_PERMISSION_AUTHEN_READ | ATTR_PERMISSION_AUTHEN_WRITE,
|
||||
GATT_NOTIFY_ATTRIBUTE_WRITE,
|
||||
10,
|
||||
CHAR_VALUE_LEN_CONSTANT,
|
||||
&serial_svc->rpc_status_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(TAG, "Failed to add RPC status characteristic: %d", status);
|
||||
}
|
||||
serial_svc_update_rpc_char(SerialServiceRpcStatusNotActive);
|
||||
// Allocate buffer size mutex
|
||||
serial_svc->buff_size_mtx = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
}
|
||||
@@ -198,6 +240,10 @@ void serial_svc_stop() {
|
||||
if(status) {
|
||||
FURI_LOG_E(TAG, "Failed to delete Flow Control characteristic: %d", status);
|
||||
}
|
||||
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rpc_status_char_handle);
|
||||
if(status) {
|
||||
FURI_LOG_E(TAG, "Failed to delete RPC Status characteristic: %d", status);
|
||||
}
|
||||
// Delete service
|
||||
status = aci_gatt_del_service(serial_svc->svc_handle);
|
||||
if(status) {
|
||||
@@ -242,3 +288,8 @@ bool serial_svc_update_tx(uint8_t* data, uint16_t data_len) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void serial_svc_set_rpc_status(SerialServiceRpcStatus status) {
|
||||
furi_assert(serial_svc);
|
||||
serial_svc_update_rpc_char(status);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SerialServiceRpcStatusNotActive = 0UL,
|
||||
SerialServiceRpcStatusActive = 1UL,
|
||||
} SerialServiceRpcStatus;
|
||||
|
||||
typedef enum {
|
||||
SerialServiceEventTypeDataReceived,
|
||||
SerialServiceEventTypeDataSent,
|
||||
SerialServiceEventTypesBleResetRequest,
|
||||
} SerialServiceEventType;
|
||||
|
||||
typedef struct {
|
||||
@@ -34,6 +40,8 @@ void serial_svc_set_callbacks(
|
||||
SerialServiceEventCallback callback,
|
||||
void* context);
|
||||
|
||||
void serial_svc_set_rpc_status(SerialServiceRpcStatus status);
|
||||
|
||||
void serial_svc_notify_buffer_is_empty();
|
||||
|
||||
void serial_svc_stop();
|
||||
|
||||
@@ -31,6 +31,16 @@ void furi_hal_bt_serial_notify_buffer_is_empty() {
|
||||
serial_svc_notify_buffer_is_empty();
|
||||
}
|
||||
|
||||
void furi_hal_bt_serial_set_rpc_status(FuriHalBtSerialRpcStatus status) {
|
||||
SerialServiceRpcStatus st;
|
||||
if(status == FuriHalBtSerialRpcStatusActive) {
|
||||
st = SerialServiceRpcStatusActive;
|
||||
} else {
|
||||
st = SerialServiceRpcStatusNotActive;
|
||||
}
|
||||
serial_svc_set_rpc_status(st);
|
||||
}
|
||||
|
||||
bool furi_hal_bt_serial_tx(uint8_t* data, uint16_t size) {
|
||||
if(size > FURI_HAL_BT_SERIAL_PACKET_SIZE_MAX) {
|
||||
return false;
|
||||
|
||||
@@ -8,6 +8,11 @@ extern "C" {
|
||||
|
||||
#define FURI_HAL_BT_SERIAL_PACKET_SIZE_MAX SERIAL_SVC_DATA_LEN_MAX
|
||||
|
||||
typedef enum {
|
||||
FuriHalBtSerialRpcStatusNotActive,
|
||||
FuriHalBtSerialRpcStatusActive,
|
||||
} FuriHalBtSerialRpcStatus;
|
||||
|
||||
/** Serial service callback type */
|
||||
typedef SerialServiceEventCallback FuriHalBtSerialCallback;
|
||||
|
||||
@@ -30,6 +35,12 @@ void furi_hal_bt_serial_set_event_callback(
|
||||
FuriHalBtSerialCallback callback,
|
||||
void* context);
|
||||
|
||||
/** Set BLE RPC status
|
||||
*
|
||||
* @param status FuriHalBtSerialRpcStatus instance
|
||||
*/
|
||||
void furi_hal_bt_serial_set_rpc_status(FuriHalBtSerialRpcStatus status);
|
||||
|
||||
/** Notify that application buffer is empty
|
||||
*/
|
||||
void furi_hal_bt_serial_notify_buffer_is_empty();
|
||||
|
||||
@@ -44,7 +44,10 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
|
||||
do {
|
||||
if(dict_type == MfClassicDictTypeFlipper) {
|
||||
if(!buffered_file_stream_open(
|
||||
dict->stream, MF_CLASSIC_DICT_FLIPPER_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
dict->stream,
|
||||
MF_CLASSIC_DICT_FLIPPER_PATH,
|
||||
FSAM_READ_WRITE,
|
||||
FSOM_OPEN_EXISTING)) {
|
||||
buffered_file_stream_close(dict->stream);
|
||||
break;
|
||||
}
|
||||
@@ -59,12 +62,24 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
|
||||
dict->stream,
|
||||
MF_CLASSIC_DICT_UNIT_TEST_PATH,
|
||||
FSAM_READ_WRITE,
|
||||
FSOM_CREATE_ALWAYS)) {
|
||||
FSOM_OPEN_ALWAYS)) {
|
||||
buffered_file_stream_close(dict->stream);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for new line ending
|
||||
if(!stream_eof(dict->stream)) {
|
||||
if(!stream_seek(dict->stream, -1, StreamOffsetFromEnd)) break;
|
||||
uint8_t last_char = 0;
|
||||
if(stream_read(dict->stream, &last_char, 1) != 1) break;
|
||||
if(last_char != '\n') {
|
||||
FURI_LOG_D(TAG, "Adding new line ending");
|
||||
if(stream_write_char(dict->stream, '\n') != 1) break;
|
||||
}
|
||||
if(!stream_rewind(dict->stream)) break;
|
||||
}
|
||||
|
||||
// Read total amount of keys
|
||||
FuriString* next_line;
|
||||
next_line = furi_string_alloc();
|
||||
@@ -73,14 +88,13 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
|
||||
FURI_LOG_T(TAG, "No keys left in dict");
|
||||
break;
|
||||
}
|
||||
furi_string_trim(next_line);
|
||||
FURI_LOG_T(
|
||||
TAG,
|
||||
"Read line: %s, len: %d",
|
||||
furi_string_get_cstr(next_line),
|
||||
furi_string_size(next_line));
|
||||
if(furi_string_get_char(next_line, 0) == '#') continue;
|
||||
if(furi_string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN - 1) continue;
|
||||
if(furi_string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN) continue;
|
||||
dict->total_keys++;
|
||||
}
|
||||
furi_string_free(next_line);
|
||||
|
||||
@@ -216,16 +216,11 @@ void mf_classic_get_read_sectors_and_keys(
|
||||
bool mf_classic_is_card_read(MfClassicData* data) {
|
||||
furi_assert(data);
|
||||
|
||||
bool card_read = false;
|
||||
do {
|
||||
uint8_t sectors_total = mf_classic_get_total_sectors_num(data->type);
|
||||
uint8_t sectors_read = 0;
|
||||
uint8_t keys_found = 0;
|
||||
mf_classic_get_read_sectors_and_keys(data, §ors_read, &keys_found);
|
||||
if(sectors_read != sectors_total) break;
|
||||
if(keys_found != sectors_total * 2) break;
|
||||
card_read = true;
|
||||
} while(false);
|
||||
uint8_t sectors_total = mf_classic_get_total_sectors_num(data->type);
|
||||
uint8_t sectors_read = 0;
|
||||
uint8_t keys_found = 0;
|
||||
mf_classic_get_read_sectors_and_keys(data, §ors_read, &keys_found);
|
||||
bool card_read = (sectors_read == sectors_total) && (keys_found == sectors_total * 2);
|
||||
|
||||
return card_read;
|
||||
}
|
||||
|
||||
@@ -151,10 +151,18 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc
|
||||
instance->manufacture_name = "";
|
||||
}
|
||||
|
||||
// Nice Smilo, MHouse, JCM has 8bit serial - simple learning
|
||||
// DTM Neo uses 12bit -> simple learning -- FAAC_RC,XT , Mutanco_Mutancode -> 12bit normal learning
|
||||
if((strcmp(instance->manufacture_name, "DTM_Neo") == 0) ||
|
||||
(strcmp(instance->manufacture_name, "FAAC_RC,XT") == 0) ||
|
||||
(strcmp(instance->manufacture_name, "Mutanco_Mutancode") == 0)) {
|
||||
decrypt = btn << 28 | (instance->generic.serial & 0xFFF) << 16 | instance->generic.cnt;
|
||||
}
|
||||
|
||||
// Nice Smilo, MHouse, JCM, Normstahl -> 8bit serial - simple learning
|
||||
if((strcmp(instance->manufacture_name, "NICE_Smilo") == 0) ||
|
||||
(strcmp(instance->manufacture_name, "NICE_MHOUSE") == 0) ||
|
||||
(strcmp(instance->manufacture_name, "JCM_Tech") == 0)) {
|
||||
(strcmp(instance->manufacture_name, "JCM_Tech") == 0) ||
|
||||
(strcmp(instance->manufacture_name, "Normstahl") == 0)) {
|
||||
decrypt = btn << 28 | (instance->generic.serial & 0xFF) << 16 | instance->generic.cnt;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,10 +80,7 @@ def BuildAppElf(env, app):
|
||||
*lib_def.cflags,
|
||||
],
|
||||
CPPDEFINES=lib_def.cdefines,
|
||||
CPPPATH=list(
|
||||
os.path.join(app._appdir.path, cinclude)
|
||||
for cinclude in lib_def.cincludes
|
||||
),
|
||||
CPPPATH=list(map(app._appdir.Dir, lib_def.cincludes)),
|
||||
)
|
||||
|
||||
lib = private_lib_env.StaticLibrary(
|
||||
|
||||
@@ -78,8 +78,12 @@ class Main(App):
|
||||
|
||||
def generate(self):
|
||||
stage_basename = "updater.bin" # used to be basename(self.args.stage)
|
||||
dfu_basename = "firmware.dfu" # used to be basename(self.args.dfu)
|
||||
radiobin_basename = "radio.bin" # used to be basename(self.args.radiobin)
|
||||
dfu_basename = (
|
||||
"firmware.dfu" if self.args.dfu else ""
|
||||
) # used to be basename(self.args.dfu)
|
||||
radiobin_basename = (
|
||||
"radio.bin" if self.args.radiobin else ""
|
||||
) # used to be basename(self.args.radiobin)
|
||||
resources_basename = ""
|
||||
|
||||
radio_version = 0
|
||||
|
||||
Reference in New Issue
Block a user