From ad484ad194a1c4316d5e7f00e26eb8adf8c2ad94 Mon Sep 17 00:00:00 2001 From: md5sum-as Date: Mon, 31 Oct 2022 18:37:46 +0300 Subject: [PATCH 1/2] Saving the PN532 password and PACK in Settings --- tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino b/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino index aaad8602a..68eb3c8c6 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino @@ -85,8 +85,8 @@ struct PN532 { #ifdef USE_PN532_DATA_FUNCTION uint8_t newdata[16]; uint8_t function = 0; - uint32_t pwd_auth=0x64636261; - uint16_t pwd_pack=0x6665; + uint32_t pwd_auth; + uint16_t pwd_pack; uint32_t pwd_auth_new; uint16_t pwd_pack_new; #endif // USE_PN532_DATA_FUNCTION @@ -106,6 +106,8 @@ void PN532_Init(void) { PN532_SAMConfig(); AddLog(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected v%u.%u",(ver>>16) & 0xFF, (ver>>8) & 0xFF); Pn532.present = true; + Pn532.pwd_auth=Settings->pn532_password; + Pn532.pwd_pack=Settings->pn532_pack; } } } @@ -708,6 +710,9 @@ bool PN532_Command(void) { if (ArgC() > 2) { Pn532.pwd_pack=strtoul(ArgV(argument,3),nullptr,0); } + Settings->pn532_password=Pn532.pwd_auth; + Settings->pn532_pack=Pn532.pwd_pack; + serviced = true; } if (!strcmp_P(argument,PSTR("SET_PWD"))) { From a3391ddc2b26fa5179fd7b2d0a528d119806e71f Mon Sep 17 00:00:00 2001 From: md5sum-as Date: Mon, 31 Oct 2022 19:07:03 +0300 Subject: [PATCH 2/2] Fixed a compilation error: added conditional compilation --- tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino b/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino index 68eb3c8c6..4c39f4342 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_40_pn532.ino @@ -106,8 +106,10 @@ void PN532_Init(void) { PN532_SAMConfig(); AddLog(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected v%u.%u",(ver>>16) & 0xFF, (ver>>8) & 0xFF); Pn532.present = true; +#ifdef USE_PN532_DATA_FUNCTION Pn532.pwd_auth=Settings->pn532_password; Pn532.pwd_pack=Settings->pn532_pack; +#endif } } }