Module for automated bluetooth advertising. Advertising is restarted on disconnect events automatically. Defaults to the following characteristics: More...
Module for automated bluetooth advertising. Advertising is restarted on disconnect events automatically. Defaults to the following characteristics:
Files | |
file | nimble_autoadv.h |
Macros | |
#define | NIMBLE_AUTOADV_DEVICE_NAME NULL |
Name of the device for the advertising procedure. More... | |
#define | NIMBLE_AUTOADV_START_MANUALLY 0 |
If an application is calling functions from nimble, e.g. More... | |
Functions | |
void | nimble_autoadv_init (void) |
Initialize autoadv module. | |
void | nimble_autoadv_set_ble_gap_adv_params (struct ble_gap_adv_params *params) |
Set struct for additional arguments specifying the particulars of the advertising procedure. More... | |
int | nimble_autoadv_add_field (uint8_t type, const void *data, size_t data_len) |
Add a new field to the given advertising data. More... | |
void | nimble_auto_adv_set_adv_duration (int32_t duration_ms) |
Set the duration for the advertising procedure. More... | |
void | nimble_auto_adv_set_gap_cb (ble_gap_event_fn *cb, void *cb_arg) |
Set the callback for gap events. More... | |
void | nimble_autoadv_start (void) |
Start the automated advertising procedure. More... | |
void | nimble_autoadv_stop (void) |
Stop the automated advertising procedure. More... | |
void | nimble_autoadv_reset (void) |
Reset all data regarding the advertising process. More... | |
#define NIMBLE_AUTOADV_DEVICE_NAME NULL |
Name of the device for the advertising procedure.
If this is not defined, it will be defined as NULL, resulting in not configuring a name at all.
Definition at line 43 of file nimble_autoadv.h.
#define NIMBLE_AUTOADV_START_MANUALLY 0 |
If an application is calling functions from nimble, e.g.
ble_svc_gap_device_name_set(), NIMBLE_AUTOADV_START_MANUALLY should be set to 1 and then the application should call nimble_autoadv_start() after all of its nimble calls to prevent errors like BLE_HS_EBUSY.
Defined as 0 by default.
Definition at line 56 of file nimble_autoadv.h.
void nimble_auto_adv_set_adv_duration | ( | int32_t | duration_ms | ) |
Set the duration for the advertising procedure.
If there is an active advertising process, it will be restarted.
[in] | duration_ms | duration of advertising procedure in ms |
void nimble_auto_adv_set_gap_cb | ( | ble_gap_event_fn * | cb, |
void * | cb_arg | ||
) |
Set the callback for gap events.
Callback is used for the logic when to start the advertising procedure.
If there is an active advertising process, it will be restarted.
[in] | cb | The callback to associate with this advertising procedure. If advertising ends, the event is reported through this callback. If advertising results in a connection, the connection inherits this callback as its event-reporting mechanism. |
[in] | cb_arg | The optional argument to pass to the callback function. |
int nimble_autoadv_add_field | ( | uint8_t | type, |
const void * | data, | ||
size_t | data_len | ||
) |
Add a new field to the given advertising data.
If there is an active advertising process, it will be restarted.
[in] | type | field type to add |
[in] | data | payload for the field |
[in] | data_len | length of the payload in bytes |
void nimble_autoadv_reset | ( | void | ) |
Reset all data regarding the advertising process.
Following characteristics will be applied:
void nimble_autoadv_set_ble_gap_adv_params | ( | struct ble_gap_adv_params * | params | ) |
Set struct for additional arguments specifying the particulars of the advertising procedure.
Uses memcpy internally.
If there is an active advertising process, it will be restarted.
[in] | params | struct with customized additional arguments |
void nimble_autoadv_start | ( | void | ) |
Start the automated advertising procedure.
Needs to be called manually when NIMBLE_AUTOADV_START_MANUALLY was set to true and after every call of nimble_autoadv_stop() to start advertising again.
void nimble_autoadv_stop | ( | void | ) |
Stop the automated advertising procedure.
After calling this, you have to call nimble_autoadv_start() manually to restart the process.