mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 15:00:46 +00:00
[FL-1748] NFC, iButton edit fix (#680)
* nfc: fix edit UID without confirmation * ibutton: fix key edit * nfc: fix nfc uid edition * nfc: fix structure type name
This commit is contained in:
parent
ae08c88bd6
commit
4b7d9b79a9
5 changed files with 12 additions and 10 deletions
11
applications/ibutton/scene/ibutton-scene-add-value.cpp
Normal file → Executable file
11
applications/ibutton/scene/ibutton-scene-add-value.cpp
Normal file → Executable file
|
@ -8,14 +8,9 @@ void iButtonSceneAddValue::on_enter(iButtonApp* app) {
|
||||||
iButtonAppViewManager* view_manager = app->get_view_manager();
|
iButtonAppViewManager* view_manager = app->get_view_manager();
|
||||||
ByteInput* byte_input = view_manager->get_byte_input();
|
ByteInput* byte_input = view_manager->get_byte_input();
|
||||||
auto callback = cbc::obtain_connector(this, &iButtonSceneAddValue::byte_input_callback);
|
auto callback = cbc::obtain_connector(this, &iButtonSceneAddValue::byte_input_callback);
|
||||||
|
memcpy(this->new_key_data, app->get_key()->get_data(), app->get_key()->get_type_data_size());
|
||||||
byte_input_set_result_callback(
|
byte_input_set_result_callback(
|
||||||
byte_input,
|
byte_input, callback, NULL, app, this->new_key_data, app->get_key()->get_type_data_size());
|
||||||
callback,
|
|
||||||
NULL,
|
|
||||||
app,
|
|
||||||
app->get_key()->get_data(),
|
|
||||||
app->get_key()->get_type_data_size());
|
|
||||||
byte_input_set_header_text(byte_input, "Enter the key");
|
byte_input_set_header_text(byte_input, "Enter the key");
|
||||||
|
|
||||||
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewByteInput);
|
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewByteInput);
|
||||||
|
@ -45,6 +40,6 @@ void iButtonSceneAddValue::byte_input_callback(void* context) {
|
||||||
iButtonEvent event;
|
iButtonEvent event;
|
||||||
|
|
||||||
event.type = iButtonEvent::Type::EventTypeByteEditResult;
|
event.type = iButtonEvent::Type::EventTypeByteEditResult;
|
||||||
|
memcpy(app->get_key()->get_data(), this->new_key_data, app->get_key()->get_type_data_size());
|
||||||
app->get_view_manager()->send_event(&event);
|
app->get_view_manager()->send_event(&event);
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ibutton-scene-generic.h"
|
#include "ibutton-scene-generic.h"
|
||||||
|
#include "../ibutton-key.h"
|
||||||
|
|
||||||
class iButtonSceneAddValue : public iButtonScene {
|
class iButtonSceneAddValue : public iButtonScene {
|
||||||
public:
|
public:
|
||||||
|
@ -9,4 +10,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void byte_input_callback(void* context);
|
void byte_input_callback(void* context);
|
||||||
|
uint8_t new_key_data[IBUTTON_KEY_DATA_SIZE] = {};
|
||||||
};
|
};
|
|
@ -35,6 +35,7 @@ struct Nfc {
|
||||||
NotificationApp* notifications;
|
NotificationApp* notifications;
|
||||||
SceneManager* scene_manager;
|
SceneManager* scene_manager;
|
||||||
NfcDevice dev;
|
NfcDevice dev;
|
||||||
|
NfcDeviceCommonData dev_edit_data;
|
||||||
|
|
||||||
char text_store[NFC_TEXT_STORE_SIZE + 1];
|
char text_store[NFC_TEXT_STORE_SIZE + 1];
|
||||||
string_t text_box_store;
|
string_t text_box_store;
|
||||||
|
|
|
@ -40,6 +40,9 @@ const bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event)
|
||||||
if(nfc->dev.dev_name) {
|
if(nfc->dev.dev_name) {
|
||||||
nfc_device_delete(&nfc->dev);
|
nfc_device_delete(&nfc->dev);
|
||||||
}
|
}
|
||||||
|
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetUid)) {
|
||||||
|
nfc->dev.dev_data.nfc_data = nfc->dev_edit_data;
|
||||||
|
}
|
||||||
memcpy(&nfc->dev.dev_name, nfc->text_store, strlen(nfc->text_store));
|
memcpy(&nfc->dev.dev_name, nfc->text_store, strlen(nfc->text_store));
|
||||||
if(nfc_device_save(&nfc->dev, nfc->text_store)) {
|
if(nfc_device_save(&nfc->dev, nfc->text_store)) {
|
||||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
|
||||||
|
|
|
@ -14,13 +14,14 @@ const void nfc_scene_set_uid_on_enter(void* context) {
|
||||||
// Setup view
|
// Setup view
|
||||||
ByteInput* byte_input = nfc->byte_input;
|
ByteInput* byte_input = nfc->byte_input;
|
||||||
byte_input_set_header_text(byte_input, "Enter uid in hex");
|
byte_input_set_header_text(byte_input, "Enter uid in hex");
|
||||||
|
nfc->dev_edit_data = nfc->dev.dev_data.nfc_data;
|
||||||
byte_input_set_result_callback(
|
byte_input_set_result_callback(
|
||||||
byte_input,
|
byte_input,
|
||||||
nfc_scene_set_uid_byte_input_callback,
|
nfc_scene_set_uid_byte_input_callback,
|
||||||
NULL,
|
NULL,
|
||||||
nfc,
|
nfc,
|
||||||
nfc->dev.dev_data.nfc_data.uid,
|
nfc->dev_edit_data.uid,
|
||||||
nfc->dev.dev_data.nfc_data.uid_len);
|
nfc->dev_edit_data.uid_len);
|
||||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewByteInput);
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewByteInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue