Skip to content

Commit ed61ce8

Browse files
committed
fix card emulator default card
1 parent 00a6adc commit ed61ce8

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

fw/application/src/app/chameleon/app_chameleon.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ void app_chameleon_on_kill(mini_app_inst_t *p_app_inst) {
7979
p_retain->cycle_mode_index = chameleon_view_get_index(p_app_handle->p_chameleon_view);
8080

8181
settings_data_t *settings = settings_get_data();
82-
if (tag_helper_valid_default_slot()) {
82+
if (tag_helper_valid_default_slot() &&
83+
tag_emulation_slot_is_enabled(settings->chameleon_default_slot_index, TAG_SENSE_HF)) {
8384
tag_emulation_change_slot(settings->chameleon_default_slot_index, false);
85+
} else {
86+
settings->chameleon_default_slot_index = INVALID_SLOT_INDEX;
8487
}
8588

8689
tag_emulation_save();

fw/application/src/app/chameleon/port/tag_helper.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,5 @@ bool tag_helper_is_defult_slot() {
201201

202202
bool tag_helper_valid_default_slot(){
203203
settings_data_t *settings = settings_get_data();
204-
return settings->chameleon_default_slot_index != INVALID_SLOT_INDEX
205-
&& tag_emulation_slot_is_enabled(settings->chameleon_default_slot_index, TAG_SENSE_HF);
204+
return settings->chameleon_default_slot_index != INVALID_SLOT_INDEX;
206205
}

fw/application/src/main.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
#include "hal_spi_bus.h"
9393
#include "hal_spi_flash.h"
9494

95+
#include "tag_helper.h"
96+
9597
#include "cache.h"
9698
#include "i18n/language.h"
9799
#include "settings.h"
@@ -195,11 +197,23 @@ static uint32_t check_wakeup_src(void) {
195197
uint32_t rr = nrf_power_resetreas_get();
196198
NRF_LOG_INFO("nrf_power_resetreas_get: 0x%04x", rr);
197199

198-
if (cache_valid()) {
199-
cache_data_t *p_cache = cache_get_data();
200-
ntag_emu_set_tag(&(p_cache->ntag));
200+
// 如果卡模拟器设置了默认卡,这里就不开启模拟NTAG
201+
if (tag_helper_valid_default_slot() && (rr & NRF_POWER_RESETREAS_NFC_MASK)) {
202+
tag_emulation_init();
203+
hal_nfc_set_nrfx_irq_enable(true);
204+
tag_emulation_sense_run();
201205
} else {
202-
cache_clean();
206+
207+
extern const ntag_t default_ntag215;
208+
ret_code_t err_code = ntag_emu_init(&default_ntag215);
209+
APP_ERROR_CHECK(err_code);
210+
211+
if (cache_valid()) {
212+
cache_data_t *p_cache = cache_get_data();
213+
ntag_emu_set_tag(&(p_cache->ntag));
214+
} else {
215+
cache_clean();
216+
}
203217
}
204218

205219
if (rr == 0) {
@@ -255,12 +269,7 @@ int main(void) {
255269
err_code = nrf_sdh_enable_request();
256270
APP_ERROR_CHECK(err_code);
257271

258-
extern const ntag_t default_ntag215;
259-
err_code = ntag_emu_init(&default_ntag215);
260-
APP_ERROR_CHECK(err_code);
261-
262272
// cache_clean(); //FOR TESTING
263-
264273

265274
err_code = settings_init();
266275
// we ignore error here, cause flash may not be presented or settings.bin did not exist

0 commit comments

Comments
 (0)