View Source BlueHeron.Broadcaster (blue_heron v0.5.0)

Handles Advertisement and Broadcasting

Advertisement Data and Scan Response Data

both set_advertising_data and set_scan_response_data take the same binary data as an argument. The format is called AdvertisingData or AD for short in the official BLE spec. The format is

<<length, param, data::binary-size(byte_size(data))>>

Where param can be one of many values defined in the official BLE spec suplement, and each param has it's own data. Both params have a hard limit of 31 bytes total.

Summary

Functions

Returns a specification to start this module under a supervisor.

Sets Advertising Data for a peripheral. Must be called before start_advertising or after stop_advertising.

Sets Advertising Parameters for a peripheral. Must be called before start_advertising or after stop_advertising.

Sets Scan Response Data for a peripheral. Must be called before start_advertising or after stop_advertising.

Enable advertisement

Disable advertisement

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

set_advertising_data(data)

@spec set_advertising_data(binary()) ::
  :ok | {:error, :setup_incomplete} | {:error, BlueHeron.ErrorCode.name()}

Sets Advertising Data for a peripheral. Must be called before start_advertising or after stop_advertising.

see [Vol 3] Part C, Section 11 of the BLE core specification. Additionally see: Core Specification Supplement, Part A, Data Types Specification

set_advertising_parameters(params)

@spec set_advertising_parameters(binary()) ::
  :ok | {:error, :setup_incomplete} | {:error, BlueHeron.ErrorCode.name()}

Sets Advertising Parameters for a peripheral. Must be called before start_advertising or after stop_advertising.

see [Vol 3] Part C, Section 11 of the BLE core specification. Additionally see: Core Specification Supplement, Part A, Data Types Specification

set_scan_response_data(data)

@spec set_scan_response_data(binary()) ::
  :ok | {:error, :setup_incomplete} | {:error, BlueHeron.ErrorCode.name()}

Sets Scan Response Data for a peripheral. Must be called before start_advertising or after stop_advertising.

see [Vol 3] Part C, Section 11 of the BLE core specification. Additionally see: Core Specification Supplement, Part A, Data Types Specification

start_advertising()

@spec start_advertising() ::
  :ok | {:error, :setup_incomplete} | {:error, BlueHeron.ErrorCode.name()}

Enable advertisement

stop_advertising()

@spec stop_advertising() ::
  :ok | {:error, :setup_incomplete} | {:error, BlueHeron.ErrorCode.name()}

Disable advertisement