View Source Grizzly.ZWave.Utils (grizzly v6.8.1)

Utility functions for encoding and decoding parts of Z-Wave frames.

Summary

Functions

Converts a bit into a boolean.

Converts a boolean into a bit.

Decodes a 128-bit binary into an IPv6 address tuple.

Encodes an IPv6 address tuple into a 128-bit binary.

Functions

@spec bit_to_bool(0 | 1) :: boolean()

Converts a bit into a boolean.

Examples

iex> bit_to_bool(1)
true
iex> bit_to_bool(0)
false
@spec bool_to_bit(boolean()) :: 0 | 1

Converts a boolean into a bit.

Examples

iex> bool_to_bit(true)
1
iex> bool_to_bit(false)
0
Link to this function

decode_ipv6_address(binary)

View Source
@spec decode_ipv6_address(binary()) :: :inet.ip6_address()

Decodes a 128-bit binary into an IPv6 address tuple.

Examples

iex> decode_ipv6_address(<<0xfd00::16, 0xaaaa::16, 0::16, 0::16, 0::16, 0::16, 0::16, 2::16>>)
{0xfd00, 0xaaaa, 0, 0, 0, 0, 0, 2}
Link to this function

encode_ipv6_address(ipv6_address)

View Source
@spec encode_ipv6_address(:inet.ip6_address()) :: binary()

Encodes an IPv6 address tuple into a 128-bit binary.

Examples

iex> encode_ipv6_address({0xfd00, 0xaaaa, 0, 0, 0, 0, 0, 2})
<<0xfd00::16, 0xaaaa::16, 0::16, 0::16, 0::16, 0::16, 0::16, 2::16>>