View Source BlueHeron.AdvertisingData (blue_heron v0.5.3)

Handles building AD structures for AdvertiseingData and ScanResponseData

Summary

Functions

Compose list of UUIDs AD structure

Compose CompleteName AD from a string

Compose flags AD from a list

Compose list of UUIDs AD structure

Compose ManufacturerSpecificData AD. Company ID must be encoded in Value.

Compose ShortName AD from a string

Types

ad()

@type ad() :: <<_::16, _::_*8>>

flag()

@type flag() ::
  :le_limited_discoverable_mode
  | :le_general_discoverable_mode
  | :br_edr_not_supported
  | :br_edr_le_supported

Functions

complete_list_of_service_uuids(list)

Compose list of UUIDs AD structure

iex()> BlueHeron.AdvertisingData.complete_list_of_service_uuids([0x12, 0xab])
<<5, 3, 171, 0, 18, 0>>

complete_name(value)

Compose CompleteName AD from a string

iex()> BlueHeron.AdvertisingData.complete_name("nerves")
<<0x7, 0x9, 0x6E, 0x65, 0x72, 0x76, 0x65, 0x73>>

flags(list)

@spec flags([{flag(), boolean()}]) :: ad()

Compose flags AD from a list

iex()> BlueHeron.AdvertisingData.flags([le_general_discoverable_mode: true, br_edr_not_supported: true])
<<2, 1, 6>>

incomplete_list_of_service_uuids(list)

@spec incomplete_list_of_service_uuids([0 | pos_integer()]) :: ad()

Compose list of UUIDs AD structure

iex()> BlueHeron.AdvertisingData.incomplete_list_of_service_uuids([0x12, 0xab])
<<5, 2, 171, 0, 18, 0>>

iex()> BlueHeron.AdvertisingData.incomplete_list_of_service_uuids([0xF018E00E0ECE45B09617B744833D89BA])
<<17, 6, 186, 137, 61, 131, 68, 183, 23, 150, 176, 69, 206, 14, 14, 224, 24,
  240>>

manufacturer_specific_data(value)

@spec manufacturer_specific_data(binary()) :: ad()

Compose ManufacturerSpecificData AD. Company ID must be encoded in Value.

iex()> ibeacon = BlueHeron.AdvertisingData.IBeacon.new(<<0xF018E00E0ECE45B09617B744833D89BA>>, 1, 2, -50)
<<76, 0, 2, 21, 186, 0, 1, 0, 2, 206>>
iex()> BlueHeron.AdvertisingData.manufacturer_specific_data(ibeacon)
<<11, 255, 76, 0, 2, 21, 186, 0, 1, 0, 2, 206>>

short_name(value)

@spec short_name(String.t()) :: ad()

Compose ShortName AD from a string

iex()> BlueHeron.AdvertisingData.short_name("nerves")
<<0x7, 0x8, 0x6E, 0x65, 0x72, 0x76, 0x65, 0x73>>