esprfid / esp-rfid

ESP8266 RFID (RC522, PN532, Wiegand, RDM6300) Access Control system featuring WebSocket, JSON, NTP Client, Javascript, SPIFFS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pincode saved incorrectly in memory

pvtex opened this issue · comments

commented

the pincode of a user is not read succesfully.
sometimes a pincode form an other user is shown.
looking in the user files in the SPIFFS filesystem the pincodes are right.

image

in the filesystem:

{"command":"userfile","uid":"???????","pincode":"8721","user":"Bjoern","acctype":99,"acctype2":null,"acctype3":null,"acctype4":null,"validsince":0,"validuntil":2145916800}
commented

the pin that you enter in the user mask is active and can be used.
but if you reload the user list all users are showing the same pincode of one random user.

commented

with debugoutputs i can see that the right pins are read in void ICACHE_FLASH_ATTR sendUserList

but on the way through serializeJson and ws to the browser it get lost

commented

the json opject item hold the right pincode.
the jsonarray users has wrong pincodes.

commented

think i found the solution the variable pincode was declared as const char.
const chars are used as pointers in nestedobject.
cast pincode to a string should help

commented

had to change the file wsResponses.esp

line 28-32

String pincode = "";
if(json.containsKey("pincode"))
{
	pincode = String((const char*)json["pincode"]);
}

Thank you very much @pvtex for reporting this bug. I can confirm it.

The problem I think it's earlier than the lines highlighted in your last comment, unfortunately. I was able to reproduce the pincode corruption even by just updating manually a few of the pincodes. I'm going to fix this surely before v2 is done.

Sorry for this and thank you very much for reporting.

You were right @pvtex !

I've applied your fix and that's fine :) I'm going to close this as the fix is in dev.

Thank you 👍