Skip to content

Commit 9721102

Browse files
committed
upd nfcmaker
1 parent cde30bb commit 9721102

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed
1.63 KB
Loading
Loading

base_pack/nfc_maker/scenes/nfc_maker_scene_result.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void nfc_maker_scene_result_on_enter(void* context) {
2626
do {
2727
if(!flipper_format_file_open_new(file, furi_string_get_cstr(path))) break;
2828

29-
if(!flipper_format_write_header_cstr(file, "Flipper NFC device", 3)) break;
30-
if(!flipper_format_write_string_cstr(file, "Device type", "NTAG215")) break;
29+
if(!flipper_format_write_header_cstr(file, "Flipper NFC device", 4)) break;
30+
if(!flipper_format_write_string_cstr(file, "Device type", "NTAG/Ultralight")) break;
3131

3232
// Serial number
3333
size_t i = 0;
@@ -41,6 +41,8 @@ void nfc_maker_scene_result_on_enter(void* context) {
4141
if(!flipper_format_write_hex(file, "UID", uid, sizeof(uid))) break;
4242
if(!flipper_format_write_string_cstr(file, "ATQA", "00 44")) break;
4343
if(!flipper_format_write_string_cstr(file, "SAK", "00")) break;
44+
if(!flipper_format_write_string_cstr(file, "Data format version", "2")) break;
45+
if(!flipper_format_write_string_cstr(file, "NTAG/Ultralight type", "NTAG215")) break;
4446
// TODO: Maybe randomize?
4547
if(!flipper_format_write_string_cstr(
4648
file,
@@ -57,6 +59,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
5759
if(!flipper_format_write_string_cstr(file, "Counter 2", "0")) break;
5860
if(!flipper_format_write_string_cstr(file, "Tearing 2", "00")) break;
5961
if(!flipper_format_write_uint32(file, "Pages total", &pages, 1)) break;
62+
if(!flipper_format_write_uint32(file, "Pages read", &pages, 1)) break;
6063

6164
// Static data
6265
buf[i++] = 0x48; // Internal
@@ -68,7 +71,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
6871
buf[i++] = 0x3E; // ...
6972
buf[i++] = 0x00; // ...
7073

71-
buf[i++] = 0x03; // Container flags
74+
buf[i++] = 0x03; // NDEF TLV block
7275

7376
// NDEF Docs: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/nfc/index.html#nfc-data-exchange-format-ndef
7477
uint8_t tnf = 0x00;
@@ -126,7 +129,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
126129
}
127130
case NfcMakerSceneHttps: {
128131
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
129-
type = "\x55";
132+
type = "U";
130133

131134
data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
132135
payload_len = data_len + 1;
@@ -139,7 +142,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
139142
}
140143
case NfcMakerSceneMail: {
141144
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
142-
type = "\x55";
145+
type = "U";
143146

144147
data_len = newstrnlen(app->mail_buf, MAIL_INPUT_LEN);
145148
payload_len = data_len + 1;
@@ -152,7 +155,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
152155
}
153156
case NfcMakerScenePhone: {
154157
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
155-
type = "\x55";
158+
type = "U";
156159

157160
data_len = newstrnlen(app->phone_buf, PHONE_INPUT_LEN);
158161
payload_len = data_len + 1;
@@ -165,22 +168,22 @@ void nfc_maker_scene_result_on_enter(void* context) {
165168
}
166169
case NfcMakerSceneText: {
167170
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
168-
type = "\x54";
171+
type = "T";
169172

170173
data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
171174
payload_len = data_len + 3;
172175
payload = malloc(payload_len);
173176

174177
payload[j++] = 0x02;
175-
payload[j++] = 0x65; // e
176-
payload[j++] = 0x6E; // n
178+
payload[j++] = 'e';
179+
payload[j++] = 'n';
177180
memcpy(&payload[j], app->big_buf, data_len);
178181
j += data_len;
179182
break;
180183
}
181184
case NfcMakerSceneUrl: {
182185
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
183-
type = "\x55";
186+
type = "U";
184187

185188
data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
186189
payload_len = data_len + 1;
@@ -282,15 +285,15 @@ void nfc_maker_scene_result_on_enter(void* context) {
282285

283286
size_t record_len = header_len + payload_len;
284287
if(record_len < 0xFF) {
285-
buf[i++] = record_len; // Record length
288+
buf[i++] = record_len; // TLV length
286289
} else {
287-
buf[i++] = 0xFF; // Record length
290+
buf[i++] = 0xFF; // TLV length
288291
buf[i++] = record_len >> 8; // ...
289292
buf[i++] = record_len & 0xFF; // ...
290293
}
291294
buf[i++] = flags; // Flags and TNF
292295
buf[i++] = type_len; // Type length
293-
if(flags & 1 << 4) { // SR (Short Record)
296+
if(flags & (1 << 4)) { // SR (Short Record)
294297
buf[i++] = payload_len; // Payload length
295298
} else {
296299
buf[i++] = 0x00; // Payload length
@@ -352,6 +355,8 @@ void nfc_maker_scene_result_on_enter(void* context) {
352355
}
353356
if(!ok) break;
354357

358+
if(!flipper_format_write_string_cstr(file, "Failed authentication attempts", "0")) break;
359+
355360
success = true;
356361

357362
} while(false);
@@ -362,11 +367,11 @@ void nfc_maker_scene_result_on_enter(void* context) {
362367
furi_record_close(RECORD_STORAGE);
363368

364369
if(success) {
365-
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
370+
popup_set_icon(popup, 36, 5, &I_DolphinDone_80x58);
366371
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
367372
} else {
368-
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
369-
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
373+
popup_set_icon(popup, 69, 15, &I_WarningDolphinFlip_45x42);
374+
popup_set_header(popup, "Error!", 13, 22, AlignLeft, AlignBottom);
370375
}
371376
popup_set_timeout(popup, 1500);
372377
popup_set_context(popup, app);

0 commit comments

Comments
 (0)