bt_adv_config()
Description
Configures advertisement module.
Syntax
bt_adv_config(advertise_options, min_interval, max_interval);
Parameters
Variable | Possible input |
| Possible inputs for advertisement options are: BT_ADV_OPT_NONE - Convenience value when no options are specified. BT_ADV_OPT_CONNECTABLE - Deprecated. Use bt_adv_conn_data_set() and bt_adv_conn_start() to setup and start connectable advertising with pre-configured parameters. BT_ADV_OPT_ONE_TIME - Advertise one time. BT_ADV_OPT_USE_IDENTITY - Advertise using identity address. If the GATT server is enabled, the script advertisement and the connectable message will be advertised using the same MAC address. BT_ADV_OPT_USE_NAME - Advertise using GAP device name. BT_ADV_OPT_DIR_MODE_LOW_DUTY - Low duty cycle directed advertising. Use low duty directed advertising mode, otherwise high duty mode will be used. BT_ADV_OPT_DIR_ADDR_RPA - Directed advertising to privacy-enabled peer. BT_ADV_OPT_FILTER_SCAN_REQ - Use filter accept list to filter devices that can request scan response data. BT_ADV_OPT_FILTER_CONN - Use filter accept list to filter devices that can connect. BT_ADV_OPT_NOTIFY_SCAN_REQ - Notify the application when a scan response data has been sent to an active scanner (feature pending). BT_ADV_OPT_SCANNABLE - Support scan response data. Must be used if advertisement name functionality is needed. BT_ADV_OPT_EXT_ADV - Advertise with extended advertising. BT_ADV_OPT_NO_2M - Disable use of LE 2M PHY on the secondary advertising channel. BT_ADV_OPT_CODED - Advertise on the LE Coded PHY (Long Range). BT_ADV_OPT_ANONYMOUS - Advertise without a device address (identity or RPA). BT_ADV_OPT_USE_TX_POWER - Advertise with transmit power. BT_ADV_OPT_DISABT_CHAN_37 - Disable advertising on channel index 37. BT_ADV_OPT_DISABLE_CHAN_38 - Disable advertising on channel index 38. BT_ADV_OPT_DISABLE_CHAN_39 - Disable advertising on channel index 39. BT_ADV_OPT_FORCE_NAME_IN_AD - Put GAP device name into advert data. |
| The minimum interval should fall within the range of N = 0x0020 to 0x4000. For single advertising, the formula is: (N * 0.625 milliseconds). For periodic advertising, the formula is: (N * 1.25 milliseconds). To facilitate quick initialization, the following convenience values have been included: BT_GAP_ADV_INT_FAST_MIN_1 - Minimum advertising interval 30 ms. BT_GAP_ADV_INT_FAST_MIN_2 - Minimum advertising interval 100 ms. BT_GAP_ADV_INT_SLOW_MIN - Minimum advertising interval 1 s. BT_GAP_PER_ADV_INT_FAST_MIN_1 - Minimum periodic advertising interval 30 ms. BT_GAP_PER_ADV_INT_FAST_MIN_2 - Minimum periodic advertising interval 100 ms. BT_GAP_PER_ADV_INT_SLOW_MIN - Minimum periodic advertising interval 1 s. |
| The maximum interval should fall within the range of N = 0x0020 to 0x4000. For single advertising, the formula is: (N * 0.625 milliseconds). For periodic advertising, the formula is: (N * 1.25 milliseconds). To facilitate quick initialization, the following convenience values have been included: BT_GAP_ADV_INT_FAST_MAX_1 - Minimum advertising interval 30 ms. BT_GAP_ADV_INT_FAST_MAX_2 - Minimum advertising interval 100 ms. BT_GAP_ADV_INT_SLOW_MAX - Minimum advertising interval 1 s. BT_GAP_PER_ADV_INT_FAST_MAX_1 - Minimum periodic advertising interval 30 ms. BT_GAP_PER_ADV_INT_FAST_MAX_2 - Minimum periodic advertising interval 100 ms. BT_GAP_PER_ADV_INT_SLOW_MAX - Minimum periodic advertising interval 1 s. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Successfully managed to send advertisement configuration. |
SCRIPT_OPERATION_FAILED | Failed to send advertisement configuration. |
SCRIPT_PARAM_INVALID | Invalid parameters. This error indicates that one or more incorrect parameters were passed into the function. |
SCRIPT_NO_ACCESS | This error signifies that Bluetooth communication was not initialized. |
Function call example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
#include <bluetooth>
main()
{
bt_init();
bt_adv_config(BT_ADV_OPT_USE_IDENTITY, BT_GAP_ADV_INT_FAST_MIN_2, BT_GAP_ADV_INT_FAST_MAX_2);
for(;;)
{
Delay(100);
}
}Notes and Warnings
Advertising options can be combined using the '|' symbol to integrate multiple options. For instance: BT_ADV_OPT_USE_NAME | BT_ADV_OPT_ONE_TIME. However, it is important to note that not all options can be combined together, and certain combinations may result in Bluetooth not advertising at all.