2013-10-31 18:35:03 +08:00
|
|
|
--[[
|
2019-03-09 17:40:45 +08:00
|
|
|
THIS IS WORK IN PROGREESS, very much not finished.
|
2013-10-31 05:10:47 +08:00
|
|
|
|
2019-03-09 17:40:45 +08:00
|
|
|
This library utilises other libraries under the hood, but can be used as a generic reader for 13.56MHz tags.
|
2013-10-31 05:10:47 +08:00
|
|
|
]]
|
|
|
|
|
|
|
|
local reader14443A = require('read14a')
|
2016-03-21 02:34:34 +08:00
|
|
|
local reader14443B = require('read14b')
|
2018-11-30 08:41:39 +08:00
|
|
|
local reader15693 = require('read15')
|
2013-10-31 05:10:47 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
-- This method library can be set waits or a 13.56 MHz tag, and when one is found, returns info about
|
2019-03-09 17:40:45 +08:00
|
|
|
-- what tag it is.
|
|
|
|
--
|
2019-09-14 23:44:58 +08:00
|
|
|
-- @return if successful: an table containing card info
|
|
|
|
-- @return if unsuccessful : nil, error
|
2013-10-31 05:10:47 +08:00
|
|
|
local function waitForTag()
|
2023-12-07 05:16:53 +08:00
|
|
|
print("Waiting for card... press <Enter> to quit")
|
2019-03-09 17:40:45 +08:00
|
|
|
local readers = {reader14443A, reader14443B, reader15693}
|
|
|
|
local i = 0;
|
2019-07-11 19:01:34 +08:00
|
|
|
while not core.kbd_enter_pressed() do
|
2019-03-09 17:40:45 +08:00
|
|
|
i = (i % 3) +1
|
|
|
|
r = readers[i]
|
|
|
|
print("Reading with ",i)
|
|
|
|
res, err = r.read()
|
|
|
|
if res then return res end
|
|
|
|
print(err)
|
|
|
|
-- err means that there was no response from card
|
|
|
|
end
|
|
|
|
return nil, "Aborted by user"
|
2013-10-31 18:35:03 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2019-03-09 17:40:45 +08:00
|
|
|
waitForTag = waitForTag,
|
2019-03-12 07:12:26 +08:00
|
|
|
}
|