View Source LibNFC.Mock (LibNFC v0.1.0)
NFC device emulation for testing purposes without physical interaction with a NFC device.
This module allows to emulate the presence of NFC targets in range of a "mock" device.
LibNFC.Mock
is a GenServer (to be spawned within a supervision tree) that holds the status
of NFC targets in range. Functions on LibNFC
accepting a :mock
parameter instead of the
NFC device reference will fetch data from this server instead of actually talking to libnfc.
Summary
Types
@type modulation() :: atom()
@type server_options() :: [ nif_delay: non_neg_integer() | false, nif_delay_jitter: non_neg_integer() ]
Server options
nif_delay
emulates delay of NIF calls (default: 400)nif_delay_jitter
jitter factor for delay (default: 0.5)
@type target() :: %{modulation: modulation(), target_info: target_info()}
Functions
@spec clear_target() :: :ok
Removes the NFC target.
Link to this function
put_target(target_info \\ %{"uid" => :rand.bytes(4)}, modulation \\ :iso14443a)
View Source (since 0.1.0)@spec put_target(target_info(), modulation()) :: :ok
Puts a NFC target in range.
@spec start_link(server_options()) :: GenServer.on_start()
Starts the mock process.