-[[
+--[[
THIS IS WORK IN PROGREESS, very much not finished.
This library utilises other libraries under the hood, but can be used as a generic reader for 13.56MHz tags.
]]
local reader14443A = require('read14a')
+local reader14443B = require('read14b')
+local cmds = require('commands')
+local TIMEOUT = 2000
local function sendToDevice(command, ignoreresponse)
core.clearCommandBuffer()
return nil, err
end
if ignoreresponse then return nil,nil end
-
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
return response,nil
end
-- This will be moved to a separate 14443B library
-------------------------------------------------------
-local function read14443B()
- return nil, "Not implemented"
-end
local reader14443B = {
- read = read14443B
+ read = reader14443B.read14443b()
}
-
-
-------------------------------------------------------
-- This will be moved to a separate 1593 library
-------------------------------------------------------
local function errorString15693(number)
- local errors = {
- 0x01 : "The command is not supported",
- 0x02 : "The command is not recognised",
- 0x03 : "The option is not supported.",
- 0x0f : "Unknown error.",
- 0x10 : "The specified block is not available (doesn’t exist).",
- 0x11 : "The specified block is already -locked and thus cannot be locked again",
- 0x12 : "The specified block is locked and its content cannot be changed.",
- 0x13 : "The specified block was not successfully programmed.",
- 0x14 : "The specified block was not successfully locked.",
- }
+ local errors = {}
+ errors[0x01] = "The command is not supported"
+ errors[0x02] = "The command is not recognised"
+ errors[0x03] = "The option is not supported."
+ errors[0x0f] = "Unknown error."
+ errors[0x10] = "The specified block is not available (doesn’t exist)."
+ errors[0x11] = "The specified block is already -locked and thus cannot be locked again"
+ errors[0x12] = "The specified block is locked and its content cannot be changed."
+ errors[0x13] = "The specified block was not successfully programmed."
+ errors[0x14] = "The specified block was not successfully locked."
+
return errors[number] or "Reserved for Future Use or Custom command error."
end
-------------------------------------------------------
-- The following code is based on cmdhf15.c around line 666 (NoTB!) and onwards
if core.iso15693_crc(data, string.len(data)) ~= 0xF47 then
return nil, "CRC failed"
- else if data[1] % 2 == 1 then
+ elseif data[1] % 2 == 1 then
-- Above is a poor-mans bit check:
-- recv[0] & ISO15_RES_ERROR //(0x01)
local err = "Tag returned error %i: %s"
-------------------------------------------------------
local function read15693()
- [[
+ --[[
We start by trying this command:
proxmark3>
From which we obtain less information than the above one.
- ]]
+ --]]
local command, result, info, err, data
local data = "02"
return info
end
-
-}
local reader15693 = {
read = read15693
}
-- @return if unsuccessfull : nil, error
local function waitForTag()
print("Waiting for card... press any key to quit")
- local readers = [reader14443A, reader14443B, readerISO15693]
- local r
+ local readers = {reader14443A, reader14443B, reader15693}
+ local i = 0;
while not core.ukbhit() do
- for _, r in ipairs(readers) do
- res, err = r.read()
- if res then return res end
+ 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"
-end
\ No newline at end of file
+end
+
+return {
+ waitForTag = waitForTag,
+}
\ No newline at end of file