BlueHeron.DataType.ManufacturerData.Apple (blue_heron v0.2.1) View Source

Serialization module for Apple.

iBeacon

Reference: https://en.wikipedia.org/wiki/IBeacon#Packet_Structure_Byte_Map

Link to this section Summary

Functions

Returns the Company Identifier description associated with this module.

iex> deserialize(<<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2, 3>>)
{:ok, {"iBeacon", %{major: 1, minor: 2, tx_power: 3, uuid: 4}}}

iex> deserialize(<<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2>>)
{:error, <<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2>>}

Returns the iBeacon identifier.

Returns the length of the data following the length byte.

iex> serialize({"iBeacon", %{major: 1, minor: 2, tx_power: 3, uuid: 4}})
{:ok, <<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2, 3>>}

iex> serialize({"iBeacon", %{major: 1, minor: 2, tx_power: 3}})
:error

iex> serialize(false)
:error

Link to this section Functions

Returns the Company Identifier description associated with this module.

iex> company()
"Apple, Inc."
iex> deserialize(<<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2, 3>>)
{:ok, {"iBeacon", %{major: 1, minor: 2, tx_power: 3, uuid: 4}}}

iex> deserialize(<<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2>>)
{:error, <<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2>>}

Returns the iBeacon identifier.

iex> ibeacon_identifier()
0x02

Returns the length of the data following the length byte.

iex> ibeacon_length()
0x15
iex> serialize({"iBeacon", %{major: 1, minor: 2, tx_power: 3, uuid: 4}})
{:ok, <<2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 0, 2, 3>>}

iex> serialize({"iBeacon", %{major: 1, minor: 2, tx_power: 3}})
:error

iex> serialize(false)
:error