mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 09:48:35 -07:00
Jetpack joyride and NFC Maker apps
This commit is contained in:
30
applications/external/nfc_maker/scenes/nfc_maker_scene.c
vendored
Normal file
30
applications/external/nfc_maker/scenes/nfc_maker_scene.c
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "nfc_maker_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const nfc_maker_on_enter_handlers[])(void*) = {
|
||||
#include "nfc_maker_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 nfc_maker_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "nfc_maker_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 nfc_maker_on_exit_handlers[])(void* context) = {
|
||||
#include "nfc_maker_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers nfc_maker_scene_handlers = {
|
||||
.on_enter_handlers = nfc_maker_on_enter_handlers,
|
||||
.on_event_handlers = nfc_maker_on_event_handlers,
|
||||
.on_exit_handlers = nfc_maker_on_exit_handlers,
|
||||
.scene_num = NfcMakerSceneNum,
|
||||
};
|
||||
29
applications/external/nfc_maker/scenes/nfc_maker_scene.h
vendored
Normal file
29
applications/external/nfc_maker/scenes/nfc_maker_scene.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) NfcMakerScene##id,
|
||||
typedef enum {
|
||||
#include "nfc_maker_scene_config.h"
|
||||
NfcMakerSceneNum,
|
||||
} NfcMakerScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers nfc_maker_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "nfc_maker_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 "nfc_maker_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 "nfc_maker_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
57
applications/external/nfc_maker/scenes/nfc_maker_scene_bluetooth.c
vendored
Normal file
57
applications/external/nfc_maker/scenes/nfc_maker_scene_bluetooth.c
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum ByteInputResult {
|
||||
ByteInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_bluetooth_byte_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, ByteInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_bluetooth_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
ByteInput* byte_input = app->byte_input;
|
||||
|
||||
byte_input_set_header_text(byte_input, "Enter Bluetooth MAC:");
|
||||
|
||||
for(size_t i = 0; i < GAP_MAC_ADDR_SIZE; i++) {
|
||||
app->mac_buf[i] = 0x69;
|
||||
}
|
||||
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
nfc_maker_scene_bluetooth_byte_input_callback,
|
||||
NULL,
|
||||
app,
|
||||
app->mac_buf,
|
||||
GAP_MAC_ADDR_SIZE);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewByteInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_bluetooth_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case ByteInputResultOk:
|
||||
furi_hal_bt_reverse_mac_addr(app->mac_buf);
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_bluetooth_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
byte_input_set_result_callback(app->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(app->byte_input, "");
|
||||
}
|
||||
13
applications/external/nfc_maker/scenes/nfc_maker_scene_config.h
vendored
Normal file
13
applications/external/nfc_maker/scenes/nfc_maker_scene_config.h
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
ADD_SCENE(nfc_maker, menu, Menu)
|
||||
ADD_SCENE(nfc_maker, bluetooth, Bluetooth)
|
||||
ADD_SCENE(nfc_maker, https, Https)
|
||||
ADD_SCENE(nfc_maker, mail, Mail)
|
||||
ADD_SCENE(nfc_maker, phone, Phone)
|
||||
ADD_SCENE(nfc_maker, text, Text)
|
||||
ADD_SCENE(nfc_maker, url, Url)
|
||||
ADD_SCENE(nfc_maker, wifi, Wifi)
|
||||
ADD_SCENE(nfc_maker, wifi_auth, WifiAuth)
|
||||
ADD_SCENE(nfc_maker, wifi_encr, WifiEncr)
|
||||
ADD_SCENE(nfc_maker, wifi_pass, WifiPass)
|
||||
ADD_SCENE(nfc_maker, name, Name)
|
||||
ADD_SCENE(nfc_maker, result, Result)
|
||||
53
applications/external/nfc_maker/scenes/nfc_maker_scene_https.c
vendored
Normal file
53
applications/external/nfc_maker/scenes/nfc_maker_scene_https.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_https_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_https_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter HTTPS Link:");
|
||||
|
||||
strlcpy(app->text_buf, "google.com", TEXT_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_https_text_input_callback,
|
||||
app,
|
||||
app->text_buf,
|
||||
TEXT_INPUT_LEN,
|
||||
true);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_https_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_https_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
53
applications/external/nfc_maker/scenes/nfc_maker_scene_mail.c
vendored
Normal file
53
applications/external/nfc_maker/scenes/nfc_maker_scene_mail.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_mail_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_mail_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter EMail Address:");
|
||||
|
||||
strlcpy(app->text_buf, "ben.dover@example.com", TEXT_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_mail_text_input_callback,
|
||||
app,
|
||||
app->text_buf,
|
||||
TEXT_INPUT_LEN,
|
||||
true);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_mail_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_mail_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
61
applications/external/nfc_maker/scenes/nfc_maker_scene_menu.c
vendored
Normal file
61
applications/external/nfc_maker/scenes/nfc_maker_scene_menu.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
void nfc_maker_scene_menu_submenu_callback(void* context, uint32_t index) {
|
||||
NfcMaker* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_menu_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_set_header(submenu, "NFC Tag Maker:");
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Bluetooth MAC",
|
||||
NfcMakerSceneBluetooth,
|
||||
nfc_maker_scene_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "HTTPS Link", NfcMakerSceneHttps, nfc_maker_scene_menu_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "Mail Address", NfcMakerSceneMail, nfc_maker_scene_menu_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "Phone Number", NfcMakerScenePhone, nfc_maker_scene_menu_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "Text Note", NfcMakerSceneText, nfc_maker_scene_menu_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "Plain URL", NfcMakerSceneUrl, nfc_maker_scene_menu_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "WiFi Login", NfcMakerSceneWifi, nfc_maker_scene_menu_submenu_callback, app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, NfcMakerSceneMenu));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewSubmenu);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, NfcMakerSceneMenu, event.event);
|
||||
consumed = true;
|
||||
scene_manager_next_scene(app->scene_manager, event.event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_menu_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
57
applications/external/nfc_maker/scenes/nfc_maker_scene_name.c
vendored
Normal file
57
applications/external/nfc_maker/scenes/nfc_maker_scene_name.c
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_name_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_name_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Name the NFC tag:");
|
||||
|
||||
set_random_name(app->name_buf, TEXT_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_name_text_input_callback,
|
||||
app,
|
||||
app->name_buf,
|
||||
TEXT_INPUT_LEN,
|
||||
true);
|
||||
|
||||
ValidatorIsFile* validator_is_file =
|
||||
validator_is_file_alloc_init(NFC_APP_FOLDER, NFC_APP_EXTENSION, NULL);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_name_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneResult);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_name_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
53
applications/external/nfc_maker/scenes/nfc_maker_scene_phone.c
vendored
Normal file
53
applications/external/nfc_maker/scenes/nfc_maker_scene_phone.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_phone_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_phone_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter Phone Number:");
|
||||
|
||||
strlcpy(app->text_buf, "+", TEXT_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_phone_text_input_callback,
|
||||
app,
|
||||
app->text_buf,
|
||||
TEXT_INPUT_LEN,
|
||||
false);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_phone_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_phone_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
359
applications/external/nfc_maker/scenes/nfc_maker_scene_result.c
vendored
Normal file
359
applications/external/nfc_maker/scenes/nfc_maker_scene_result.c
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum PopupEvent {
|
||||
PopupEventExit,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_result_popup_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, PopupEventExit);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_result_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
Popup* popup = app->popup;
|
||||
bool success = false;
|
||||
|
||||
FlipperFormat* file = flipper_format_file_alloc(furi_record_open(RECORD_STORAGE));
|
||||
FuriString* path = furi_string_alloc();
|
||||
furi_string_printf(path, NFC_APP_FOLDER "/%s" NFC_APP_EXTENSION, app->name_buf);
|
||||
do {
|
||||
if(!flipper_format_file_open_new(file, furi_string_get_cstr(path))) break;
|
||||
|
||||
uint32_t pages = 42;
|
||||
size_t size = pages * 4;
|
||||
uint8_t* buf = malloc(size);
|
||||
|
||||
if(!flipper_format_write_header_cstr(file, "Flipper NFC device", 3)) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Device type", "NTAG203")) break;
|
||||
|
||||
// Serial number
|
||||
buf[0] = 0x04;
|
||||
furi_hal_random_fill_buf(&buf[1], 8);
|
||||
uint8_t uid[7];
|
||||
memcpy(&uid[0], &buf[0], 3);
|
||||
memcpy(&uid[3], &buf[4], 4);
|
||||
|
||||
if(!flipper_format_write_hex(file, "UID", uid, sizeof(uid))) break;
|
||||
if(!flipper_format_write_string_cstr(file, "ATQA", "00 44")) break;
|
||||
if(!flipper_format_write_string_cstr(file, "SAK", "00")) break;
|
||||
// TODO: Maybe randomize?
|
||||
if(!flipper_format_write_string_cstr(
|
||||
file,
|
||||
"Signature",
|
||||
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"))
|
||||
break;
|
||||
if(!flipper_format_write_string_cstr(file, "Mifare version", "00 00 00 00 00 00 00 00"))
|
||||
break;
|
||||
|
||||
if(!flipper_format_write_string_cstr(file, "Counter 0", "0")) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Tearing 0", "00")) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Counter 1", "0")) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Tearing 1", "00")) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Counter 2", "0")) break;
|
||||
if(!flipper_format_write_string_cstr(file, "Tearing 2", "00")) break;
|
||||
if(!flipper_format_write_uint32(file, "Pages total", &pages, 1)) break;
|
||||
|
||||
// Static data
|
||||
buf[9] = 0x48; // Internal
|
||||
buf[10] = 0x00; // Lock bytes
|
||||
buf[11] = 0x00; // ...
|
||||
buf[12] = 0xE1; // Capability container
|
||||
buf[13] = 0x10; // ...
|
||||
buf[14] = 0x12; // ...
|
||||
buf[15] = 0x00; // ...
|
||||
buf[16] = 0x01; // ...
|
||||
buf[17] = 0x03; // ...
|
||||
buf[18] = 0xA0; // ...
|
||||
buf[19] = 0x10; // ...
|
||||
buf[20] = 0x44; // ...
|
||||
buf[21] = 0x03; // Message flags
|
||||
|
||||
size_t msg_len = 0;
|
||||
switch(scene_manager_get_scene_state(app->scene_manager, NfcMakerSceneMenu)) {
|
||||
case NfcMakerSceneBluetooth: {
|
||||
msg_len = 0x2B;
|
||||
|
||||
buf[23] = 0xD2;
|
||||
buf[24] = 0x20;
|
||||
buf[25] = 0x08;
|
||||
buf[26] = 0x61;
|
||||
buf[27] = 0x70;
|
||||
|
||||
buf[28] = 0x70;
|
||||
buf[29] = 0x6C;
|
||||
buf[30] = 0x69;
|
||||
buf[31] = 0x63;
|
||||
|
||||
buf[32] = 0x61;
|
||||
buf[33] = 0x74;
|
||||
buf[34] = 0x69;
|
||||
buf[35] = 0x6F;
|
||||
|
||||
buf[36] = 0x6E;
|
||||
buf[37] = 0x2F;
|
||||
buf[38] = 0x76;
|
||||
buf[39] = 0x6E;
|
||||
|
||||
buf[40] = 0x64;
|
||||
buf[41] = 0x2E;
|
||||
buf[42] = 0x62;
|
||||
buf[43] = 0x6C;
|
||||
|
||||
buf[44] = 0x75;
|
||||
buf[45] = 0x65;
|
||||
buf[46] = 0x74;
|
||||
buf[47] = 0x6F;
|
||||
|
||||
buf[48] = 0x6F;
|
||||
buf[49] = 0x74;
|
||||
buf[50] = 0x68;
|
||||
buf[51] = 0x2E;
|
||||
|
||||
buf[52] = 0x65;
|
||||
buf[53] = 0x70;
|
||||
buf[54] = 0x2E;
|
||||
buf[55] = 0x6F;
|
||||
|
||||
buf[56] = 0x6F;
|
||||
buf[57] = 0x62;
|
||||
buf[58] = 0x08;
|
||||
buf[59] = 0x00;
|
||||
|
||||
memcpy(&buf[60], app->mac_buf, GAP_MAC_ADDR_SIZE);
|
||||
break;
|
||||
}
|
||||
case NfcMakerSceneHttps: {
|
||||
uint8_t data_len = strnlen(app->text_buf, TEXT_INPUT_LEN);
|
||||
msg_len = data_len + 5;
|
||||
|
||||
buf[23] = 0xD1;
|
||||
buf[24] = 0x01;
|
||||
buf[25] = data_len + 1;
|
||||
buf[26] = 0x55;
|
||||
|
||||
buf[27] = 0x04; // Prepend "https://"
|
||||
memcpy(&buf[28], app->text_buf, data_len);
|
||||
break;
|
||||
}
|
||||
case NfcMakerSceneMail: {
|
||||
uint8_t data_len = strnlen(app->text_buf, TEXT_INPUT_LEN);
|
||||
msg_len = data_len + 5;
|
||||
|
||||
buf[23] = 0xD1;
|
||||
buf[24] = 0x01;
|
||||
buf[25] = data_len + 1;
|
||||
buf[26] = 0x55;
|
||||
|
||||
buf[27] = 0x06; // Prepend "mailto:"
|
||||
memcpy(&buf[28], app->text_buf, data_len);
|
||||
break;
|
||||
}
|
||||
case NfcMakerScenePhone: {
|
||||
uint8_t data_len = strnlen(app->text_buf, TEXT_INPUT_LEN);
|
||||
msg_len = data_len + 5;
|
||||
|
||||
buf[23] = 0xD1;
|
||||
buf[24] = 0x01;
|
||||
buf[25] = data_len + 1;
|
||||
buf[26] = 0x55;
|
||||
|
||||
buf[27] = 0x05; // Prepend "tel:"
|
||||
memcpy(&buf[28], app->text_buf, data_len);
|
||||
break;
|
||||
}
|
||||
case NfcMakerSceneText: {
|
||||
uint8_t data_len = strnlen(app->text_buf, TEXT_INPUT_LEN);
|
||||
msg_len = data_len + 7;
|
||||
|
||||
buf[23] = 0xD1;
|
||||
buf[24] = 0x01;
|
||||
buf[25] = data_len + 3;
|
||||
buf[26] = 0x54;
|
||||
|
||||
buf[27] = 0x02;
|
||||
buf[28] = 0x65; // e
|
||||
buf[29] = 0x6E; // n
|
||||
memcpy(&buf[30], app->text_buf, data_len);
|
||||
break;
|
||||
}
|
||||
case NfcMakerSceneUrl: {
|
||||
uint8_t data_len = strnlen(app->text_buf, TEXT_INPUT_LEN);
|
||||
msg_len = data_len + 5;
|
||||
|
||||
buf[23] = 0xD1;
|
||||
buf[24] = 0x01;
|
||||
buf[25] = data_len + 1;
|
||||
buf[26] = 0x55;
|
||||
|
||||
buf[27] = 0x00; // No prepend
|
||||
memcpy(&buf[28], app->text_buf, data_len);
|
||||
break;
|
||||
}
|
||||
case NfcMakerSceneWifi: {
|
||||
uint8_t ssid_len = strnlen(app->text_buf, WIFI_INPUT_LEN);
|
||||
uint8_t pass_len = strnlen(app->pass_buf, WIFI_INPUT_LEN);
|
||||
uint8_t data_len = ssid_len + pass_len;
|
||||
msg_len = data_len + 73;
|
||||
|
||||
buf[23] = 0xD2;
|
||||
buf[24] = 0x17;
|
||||
buf[25] = data_len + 47;
|
||||
buf[26] = 0x61;
|
||||
buf[27] = 0x70;
|
||||
|
||||
buf[28] = 0x70;
|
||||
buf[29] = 0x6C;
|
||||
buf[30] = 0x69;
|
||||
buf[31] = 0x63;
|
||||
|
||||
buf[32] = 0x61;
|
||||
buf[33] = 0x74;
|
||||
buf[34] = 0x69;
|
||||
buf[35] = 0x6F;
|
||||
|
||||
buf[36] = 0x6E;
|
||||
buf[37] = 0x2F;
|
||||
buf[38] = 0x76;
|
||||
buf[39] = 0x6E;
|
||||
|
||||
buf[40] = 0x64;
|
||||
buf[41] = 0x2E;
|
||||
buf[42] = 0x77;
|
||||
buf[43] = 0x66;
|
||||
|
||||
buf[44] = 0x61;
|
||||
buf[45] = 0x2E;
|
||||
buf[46] = 0x77;
|
||||
buf[47] = 0x73;
|
||||
|
||||
buf[48] = 0x63;
|
||||
buf[49] = 0x10;
|
||||
buf[50] = 0x0E;
|
||||
buf[51] = 0x00;
|
||||
|
||||
buf[52] = data_len + 43;
|
||||
buf[53] = 0x10;
|
||||
buf[54] = 0x26;
|
||||
buf[55] = 0x00;
|
||||
|
||||
buf[56] = 0x01;
|
||||
buf[57] = 0x01;
|
||||
buf[58] = 0x10;
|
||||
buf[59] = 0x45;
|
||||
|
||||
buf[60] = 0x00;
|
||||
buf[61] = ssid_len;
|
||||
memcpy(&buf[62], app->text_buf, ssid_len);
|
||||
size_t ssid = 62 + ssid_len;
|
||||
buf[ssid + 0] = 0x10;
|
||||
buf[ssid + 1] = 0x03;
|
||||
|
||||
buf[ssid + 2] = 0x00;
|
||||
buf[ssid + 3] = 0x02;
|
||||
buf[ssid + 4] = 0x00;
|
||||
buf[ssid + 5] =
|
||||
scene_manager_get_scene_state(app->scene_manager, NfcMakerSceneWifiAuth);
|
||||
|
||||
buf[ssid + 6] = 0x10;
|
||||
buf[ssid + 7] = 0x0F;
|
||||
buf[ssid + 8] = 0x00;
|
||||
buf[ssid + 9] = 0x02;
|
||||
|
||||
buf[ssid + 10] = 0x00;
|
||||
buf[ssid + 11] =
|
||||
scene_manager_get_scene_state(app->scene_manager, NfcMakerSceneWifiEncr);
|
||||
buf[ssid + 12] = 0x10;
|
||||
buf[ssid + 13] = 0x27;
|
||||
|
||||
buf[ssid + 14] = 0x00;
|
||||
buf[ssid + 15] = pass_len;
|
||||
memcpy(&buf[ssid + 16], app->pass_buf, pass_len);
|
||||
size_t pass = ssid + 16 + pass_len;
|
||||
buf[pass + 0] = 0x10;
|
||||
buf[pass + 1] = 0x20;
|
||||
|
||||
buf[pass + 2] = 0x00;
|
||||
buf[pass + 3] = 0x06;
|
||||
buf[pass + 4] = 0xFF;
|
||||
buf[pass + 5] = 0xFF;
|
||||
|
||||
buf[pass + 6] = 0xFF;
|
||||
buf[pass + 7] = 0xFF;
|
||||
buf[pass + 8] = 0xFF;
|
||||
buf[pass + 9] = 0xFF;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Message length and terminator
|
||||
buf[22] = msg_len;
|
||||
size_t msg_end = 23 + msg_len;
|
||||
buf[msg_end] = 0xFE;
|
||||
|
||||
// Padding
|
||||
for(size_t i = msg_end + 1; i < size; i++) {
|
||||
buf[i] = 0x00;
|
||||
}
|
||||
|
||||
char str[16];
|
||||
bool ok = true;
|
||||
for(size_t page = 0; page < pages; page++) {
|
||||
snprintf(str, sizeof(str), "Page %u", page);
|
||||
if(!flipper_format_write_hex(file, str, &buf[page * 4], 4)) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!ok) break;
|
||||
|
||||
free(buf);
|
||||
success = true;
|
||||
|
||||
} while(false);
|
||||
furi_string_free(path);
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
if(success) {
|
||||
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
|
||||
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
|
||||
} else {
|
||||
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
|
||||
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
|
||||
}
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, app);
|
||||
popup_set_callback(popup, nfc_maker_scene_result_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewPopup);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_result_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case PopupEventExit:
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, NfcMakerSceneMenu);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_result_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
popup_reset(app->popup);
|
||||
}
|
||||
53
applications/external/nfc_maker/scenes/nfc_maker_scene_text.c
vendored
Normal file
53
applications/external/nfc_maker/scenes/nfc_maker_scene_text.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_text_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_text_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter Text Note:");
|
||||
|
||||
strlcpy(app->text_buf, "Lorem ipsum", TEXT_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_text_text_input_callback,
|
||||
app,
|
||||
app->text_buf,
|
||||
TEXT_INPUT_LEN,
|
||||
true);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_text_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_text_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
53
applications/external/nfc_maker/scenes/nfc_maker_scene_url.c
vendored
Normal file
53
applications/external/nfc_maker/scenes/nfc_maker_scene_url.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_url_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_url_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter Plain URL:");
|
||||
|
||||
strlcpy(app->text_buf, "https://google.com", TEXT_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_url_text_input_callback,
|
||||
app,
|
||||
app->text_buf,
|
||||
TEXT_INPUT_LEN,
|
||||
true);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_url_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_url_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
55
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi.c
vendored
Normal file
55
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_wifi_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter WiFi SSID:");
|
||||
|
||||
strlcpy(app->text_buf, "Bill Wi the Science Fi", WIFI_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_wifi_text_input_callback,
|
||||
app,
|
||||
app->text_buf,
|
||||
WIFI_INPUT_LEN,
|
||||
true);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_wifi_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, NfcMakerSceneWifiAuth, WifiAuthenticationWpa2Personal);
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneWifiAuth);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
83
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi_auth.c
vendored
Normal file
83
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi_auth.c
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
void nfc_maker_scene_wifi_auth_submenu_callback(void* context, uint32_t index) {
|
||||
NfcMaker* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_auth_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_set_header(submenu, "Authentication Type:");
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "Open", WifiAuthenticationOpen, nfc_maker_scene_wifi_auth_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"WPA 2 Personal",
|
||||
WifiAuthenticationWpa2Personal,
|
||||
nfc_maker_scene_wifi_auth_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"WPA 2 Enterprise",
|
||||
WifiAuthenticationWpa2Enterprise,
|
||||
nfc_maker_scene_wifi_auth_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"WPA Personal",
|
||||
WifiAuthenticationWpaPersonal,
|
||||
nfc_maker_scene_wifi_auth_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"WPA Enterprise",
|
||||
WifiAuthenticationWpaEnterprise,
|
||||
nfc_maker_scene_wifi_auth_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Shared",
|
||||
WifiAuthenticationShared,
|
||||
nfc_maker_scene_wifi_auth_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, NfcMakerSceneWifiAuth));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewSubmenu);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_wifi_auth_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, NfcMakerSceneWifiAuth, event.event);
|
||||
consumed = true;
|
||||
if(event.event == WifiAuthenticationOpen) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, NfcMakerSceneWifiEncr, WifiEncryptionNone);
|
||||
strcpy(app->pass_buf, "");
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
} else {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, NfcMakerSceneWifiEncr, WifiEncryptionAes);
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneWifiEncr);
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_auth_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
48
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi_encr.c
vendored
Normal file
48
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi_encr.c
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
void nfc_maker_scene_wifi_encr_submenu_callback(void* context, uint32_t index) {
|
||||
NfcMaker* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_encr_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_set_header(submenu, "Encryption Type:");
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "AES", WifiEncryptionAes, nfc_maker_scene_wifi_encr_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "WEP", WifiEncryptionWep, nfc_maker_scene_wifi_encr_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "TKIP", WifiEncryptionTkip, nfc_maker_scene_wifi_encr_submenu_callback, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "None", WifiEncryptionNone, nfc_maker_scene_wifi_encr_submenu_callback, app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, NfcMakerSceneWifiEncr));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewSubmenu);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_wifi_encr_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, NfcMakerSceneWifiEncr, event.event);
|
||||
consumed = true;
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneWifiPass);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_encr_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
53
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi_pass.c
vendored
Normal file
53
applications/external/nfc_maker/scenes/nfc_maker_scene_wifi_pass.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "../nfc_maker.h"
|
||||
|
||||
enum TextInputResult {
|
||||
TextInputResultOk,
|
||||
};
|
||||
|
||||
static void nfc_maker_scene_wifi_pass_text_input_callback(void* context) {
|
||||
NfcMaker* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_pass_on_enter(void* context) {
|
||||
NfcMaker* app = context;
|
||||
TextInput* text_input = app->text_input;
|
||||
|
||||
text_input_set_header_text(text_input, "Enter WiFi Password:");
|
||||
|
||||
strlcpy(app->pass_buf, "244466666", WIFI_INPUT_LEN);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
nfc_maker_scene_wifi_pass_text_input_callback,
|
||||
app,
|
||||
app->pass_buf,
|
||||
WIFI_INPUT_LEN,
|
||||
true);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
|
||||
}
|
||||
|
||||
bool nfc_maker_scene_wifi_pass_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcMaker* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case TextInputResultOk:
|
||||
scene_manager_next_scene(app->scene_manager, NfcMakerSceneName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_maker_scene_wifi_pass_on_exit(void* context) {
|
||||
NfcMaker* app = context;
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
Reference in New Issue
Block a user