1 local getopt
= require('getopt')
2 local cmds
= require('commands')
9 Perform bulk enrollment of 26 bit IO Prox / Kantech style RFID Tags
11 For more info, check the comments in the code
15 script run lf_ioprox_bulkclone.lua -f 1 -b 1000
18 script run lf_ioprox_bulkclone.lua -f facility -b base_id_num
28 -- A debug printout-function
29 local function dbg(args
)
30 if not DEBUG
then return end
31 if type(args
) == 'table' then
42 -- This is only meant to be used when errors occur
43 local function oops(err
)
45 core
.clearCommandBuffer()
55 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
57 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
59 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
64 local function exitMsg(msg
)
65 print( string.rep('--',20) )
66 print( string.rep('--',20) )
71 local function main(args
)
73 print( string.rep('--',20) )
74 print( string.rep('--',20) )
77 if #args
== 0 then return help() end
79 for o
, a
in getopt
.getopt(args
, 'f:b:h') do
80 if o
== 'h' then return help() end
83 print('You did not supply a facility code, using 0')
90 if isempty(a
) then return oops('You must supply the flag -b (starting card number)') end
95 local successful_writes
= {}
96 local timestamp
= os
.date('%Y-%m-%d %H:%M:%S', os
.time())
99 print(string.format("Setting fob to Facility Code: %d, Card Number: %d", fc
, cn
))
101 -- Writing to block 0 with the specific data for ioProx card format
102 core
.console("lf t55xx write -b 0 -d 00147040")
104 -- Command to set facility code and card number on the fob
105 local command
= string.format("lf io clone --vn 2 --fc %d --cn %d", fc
, cn
)
106 core
.console(command
)
108 table.insert(successful_writes
, string.format("%d,%d", fc
, cn
))
109 print("Fob created successfully.")
111 print("Press Enter to create the next fob, type 'r' and press Enter to retry, or type 'q' and press Enter to quit.")
112 local user_input
= io
.read()
114 if user_input
:lower() == 'q' then
115 print("Timestamp: ", timestamp
)
116 print("Successful Writes:")
117 for _
, v
in ipairs(successful_writes
) do print(v
) end
119 elseif user_input
:lower() ~= 'r' then