/
link_policy.ex
47 lines (37 loc) · 1.42 KB
/
link_policy.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
defmodule BlueHeron.HCI.Command.LinkPolicy do
alias __MODULE__, as: LP
@ogf 0x02
@moduledoc """
HCI commands for working with the Link Policy.
* OGF: `#{inspect(@ogf, base: :hex)}`
> The Link Policy Commands provide methods for the Host to affect
> how the Link Manager manages the piconet. When Link Policy Commands are
> used, the LM still controls how Bluetooth piconets and scatternets are
> established and maintained, depending on adjustable policy parameters.
> These policy commands modify the Link Manager behavior that can result
> in changes to the link layer connections with Bluetooth remote devices
Reference: Version 5.2, Vol 4, Part E, 7.2
"""
def __ogf__(), do: @ogf
@doc """
List all available LE Controller command modules
"""
@spec list :: [module()]
def list() do
Application.spec(:blue_heron, :modules)
|> Enum.filter(&match?(["BlueHeron", "HCI", "Command", "LinkPolicy", _mod], Module.split(&1)))
end
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
ocf =
Keyword.get_lazy(opts, :ocf, fn ->
raise ":ocf key required when defining HCI.Command.LinkPolicy.__using__/1"
end)
use BlueHeron.HCI.Command, Keyword.put(opts, :ogf, LP.__ogf__())
@ocf ocf
@opcode BlueHeron.HCI.Command.opcode(LP.__ogf__(), @ocf)
def __ocf__(), do: @ocf
def __opcode__(), do: @opcode
end
end
end