-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fill in missing high level typespecs and documentation for user facing modules and functions.
- Loading branch information
1 parent
d3b09f1
commit 9da571c
Showing
30 changed files
with
403 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,80 @@ | ||
defmodule Jeff do | ||
alias Jeff.ACU | ||
@moduledoc """ | ||
Control an Access Control Unit (ACU) and send commands to a Peripheral Device (PD) | ||
""" | ||
|
||
alias Jeff.{ACU, Command, Device, Reply} | ||
|
||
@type acu() :: GenServer.server() | ||
@type device_opt() :: ACU.device_opt() | ||
@type osdp_address() :: 0x00..0x7F | ||
|
||
@doc """ | ||
Start an ACU process. | ||
""" | ||
@spec start_acu([ACU.start_opt()]) :: GenServer.on_start() | ||
def start_acu(opts \\ []) do | ||
ACU.start_link(opts) | ||
end | ||
|
||
@doc """ | ||
Register a peripheral device on the ACU communication bus. | ||
""" | ||
@spec add_pd(acu(), osdp_address(), [device_opt()]) :: Device.t() | ||
def add_pd(acu, address, opts \\ []) do | ||
ACU.add_device(acu, address, opts) | ||
end | ||
|
||
@doc """ | ||
Requests the return of the PD ID Report. | ||
""" | ||
@spec id_report(acu(), osdp_address()) :: Reply.IdReport.t() | Reply.ErrorCode.t() | ||
def id_report(acu, address) do | ||
ACU.send_command(acu, address, ID) | ||
ACU.send_command(acu, address, ID).data | ||
end | ||
|
||
@doc """ | ||
Requests the PD to return a list of its functional capabilities, such as the | ||
type and number of input points, outputs points, reader ports, etc. | ||
""" | ||
@spec capabilities(acu(), osdp_address()) :: [Reply.Capability.t()] | Reply.ErrorCode.t() | ||
def capabilities(acu, address) do | ||
ACU.send_command(acu, address, CAP) | ||
ACU.send_command(acu, address, CAP).data | ||
end | ||
|
||
@doc """ | ||
Instructs the PD to reply with a local status report. | ||
""" | ||
@spec local_status(acu(), osdp_address()) :: Reply.LocalStatus.t() | Reply.ErrorCode.t() | ||
def local_status(acu, address) do | ||
ACU.send_command(acu, address, LSTAT) | ||
end | ||
|
||
def input_status(acu, address) do | ||
ACU.send_command(acu, address, ISTAT) | ||
ACU.send_command(acu, address, LSTAT).data | ||
end | ||
|
||
@doc """ | ||
Controls the LEDs associated with one or more readers. | ||
""" | ||
@spec set_led(acu(), osdp_address(), Command.LedSettings.params()) :: | ||
Reply.ACK | Reply.ErrorCode.t() | ||
def set_led(acu, address, params) do | ||
ACU.send_command(acu, address, LED, params) | ||
ACU.send_command(acu, address, LED, params).data | ||
end | ||
|
||
@doc """ | ||
Defines commands to a single, monotone audible annunciator (beeper or buzzer) | ||
that may be associated with a reader. | ||
""" | ||
@spec set_buzzer(acu(), osdp_address(), Command.BuzzerSettings.params()) :: | ||
Reply.ACK | Reply.ErrorCode.t() | ||
def set_buzzer(acu, address, params) do | ||
ACU.send_command(acu, address, BUZ, params) | ||
ACU.send_command(acu, address, BUZ, params).data | ||
end | ||
|
||
@doc """ | ||
Sets the PD's communication parameters. | ||
""" | ||
@spec set_com(acu(), osdp_address(), Command.ComSettings.params()) :: | ||
Reply.ComData.t() | Reply.ErrorCode.t() | ||
def set_com(acu, address, params) do | ||
ACU.send_command(acu, address, COMSET, params) | ||
end | ||
|
||
def set_key(acu, address, params) do | ||
ACU.send_command(acu, address, KEYSET, params) | ||
end | ||
|
||
def abort(acu, address) do | ||
ACU.send_command(acu, address, ABORT) | ||
ACU.send_command(acu, address, COMSET, params).data | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
defmodule Jeff.Bus do | ||
@moduledoc false | ||
|
||
alias Jeff.Device | ||
|
||
defstruct registry: %{}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
defmodule Jeff.Command.ChallengeData do | ||
@moduledoc false | ||
|
||
def encode(server_rnd: rnd), do: rnd | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
defmodule Jeff.Command.EncryptionServer do | ||
@moduledoc false | ||
def encode(cryptogram: cryptogram), do: cryptogram | ||
end |
Oops, something went wrong.