mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
refactoring NG
This commit is contained in:
parent
9bf961cb8a
commit
3c533db308
2 changed files with 20 additions and 29 deletions
|
@ -108,9 +108,16 @@ local function waitFor14443b()
|
||||||
return nil, 'Aborted by user'
|
return nil, 'Aborted by user'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- turns on the HF field.
|
||||||
|
local function connect14443b()
|
||||||
|
local c = Command:newMIX{cmd = cmds.CMD_ISO_14443B_COMMAND, arg1 = ISO14B_COMMAND.ISO14B_CONNECT}
|
||||||
|
return c.sendMIX(true)
|
||||||
|
end
|
||||||
|
---
|
||||||
-- Sends an instruction to do nothing, only disconnect
|
-- Sends an instruction to do nothing, only disconnect
|
||||||
local function disconnect14443b()
|
local function disconnect14443b()
|
||||||
local c = Command:newMIX{cmd = cmds.CMD_READER_ISO_14443b}
|
local c = Command:newMIX{cmd = cmds.CMD_ISO_14443B_COMMAND, arg1 = ISO14B_COMMAND.ISO14B_DISCONNECT}
|
||||||
-- We can ignore the response here, no ACK is returned for this command
|
-- We can ignore the response here, no ACK is returned for this command
|
||||||
-- Check /armsrc/iso14443b.c, ReaderIso14443b() for details
|
-- Check /armsrc/iso14443b.c, ReaderIso14443b() for details
|
||||||
return c.sendMIX(true)
|
return c.sendMIX(true)
|
||||||
|
@ -120,6 +127,7 @@ local library = {
|
||||||
read = read14443b,
|
read = read14443b,
|
||||||
waitFor14443b = waitFor14443b,
|
waitFor14443b = waitFor14443b,
|
||||||
parse1443b = parse1443b,
|
parse1443b = parse1443b,
|
||||||
|
connect = connect14443b,
|
||||||
disconnect = disconnect14443b,
|
disconnect = disconnect14443b,
|
||||||
ISO14B_COMMAND = ISO14B_COMMAND,
|
ISO14B_COMMAND = ISO14B_COMMAND,
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,21 +28,6 @@ Check there for details about data format and how commands are interpreted on th
|
||||||
device-side.
|
device-side.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
---
|
|
||||||
--
|
|
||||||
local function calypso_switch_on_field()
|
|
||||||
local flags = lib14b.ISO14B_COMMAND.ISO14B_CONNECT
|
|
||||||
local c = Command:new{cmd = cmds.CMD_ISO_14443B_COMMAND, arg1 = flags}
|
|
||||||
return lib14b.sendToDevice(c, true)
|
|
||||||
end
|
|
||||||
---
|
|
||||||
-- Disconnect (poweroff) the antenna forcing a disconnect of a 14b tag.
|
|
||||||
local function calypso_switch_off_field()
|
|
||||||
local flags = lib14b.ISO14B_COMMAND.ISO14B_DISCONNECT
|
|
||||||
local c = Command:new{cmd = cmds.CMD_ISO_14443B_COMMAND, arg1 = flags}
|
|
||||||
return lib14b.sendToDevice(c, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function calypso_parse(result)
|
local function calypso_parse(result)
|
||||||
local r = Command.parse(result)
|
local r = Command.parse(result)
|
||||||
local len = r.arg2 * 2
|
local len = r.arg2 * 2
|
||||||
|
@ -71,7 +56,7 @@ end
|
||||||
-- This is only meant to be used when errors occur
|
-- This is only meant to be used when errors occur
|
||||||
local function oops(err)
|
local function oops(err)
|
||||||
print('ERROR: ', err)
|
print('ERROR: ', err)
|
||||||
calypso_switch_off_field()
|
lib14b.disconnect()
|
||||||
return nil, err
|
return nil, err
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
|
@ -128,15 +113,13 @@ local function calypso_send_cmd_raw(data, ignoreresponse )
|
||||||
|
|
||||||
data = data or "00"
|
data = data or "00"
|
||||||
|
|
||||||
command = Command:new{cmd = cmds.CMD_ISO_14443B_COMMAND,
|
command = Command:newMIX{
|
||||||
arg1 = flags,
|
cmd = cmds.CMD_ISO_14443B_COMMAND,
|
||||||
arg2 = #data/2, -- LEN of data, half the length of the ASCII-string hex string
|
arg1 = flags,
|
||||||
arg3 = 0,
|
arg2 = #data/2, -- LEN of data, half the length of the ASCII-string hex string
|
||||||
data = data} -- data bytes (commands etc)
|
data = data} -- data bytes (commands etc)
|
||||||
result, err = lib14b.sendToDevice(command, false)
|
|
||||||
|
result, err = command:sendMIX(ignoreresponse)
|
||||||
if ignoreresponse then return response, err end
|
|
||||||
|
|
||||||
if result then
|
if result then
|
||||||
local r = calypso_parse(result)
|
local r = calypso_parse(result)
|
||||||
return r, nil
|
return r, nil
|
||||||
|
@ -228,8 +211,8 @@ function main(args)
|
||||||
if o == 'b' then bytes = a end
|
if o == 'b' then bytes = a end
|
||||||
end
|
end
|
||||||
|
|
||||||
calypso_switch_on_field()
|
lib14b.connect()
|
||||||
|
|
||||||
-- Select 14b tag.
|
-- Select 14b tag.
|
||||||
card, err = lib14b.waitFor14443b()
|
card, err = lib14b.waitFor14443b()
|
||||||
if not card then return oops(err) end
|
if not card then return oops(err) end
|
||||||
|
@ -264,7 +247,7 @@ function main(args)
|
||||||
print('<< no answer')
|
print('<< no answer')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
calypso_switch_off_field()
|
lib14b.disconnect()
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- a simple selftest function, tries to convert
|
-- a simple selftest function, tries to convert
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue