1. BLE Power Optimization
1.1 Introduction
Bluetooth Low Energy (BLE) connects the device to a nearby Sidewalk Gateway, which forwards traffic to the cloud. This page covers power optimization through the SID_OPTION_BLE_USER_CONFIG and SID_OPTION_BLE_CONNECTION_POLICY options.
1.2 BLE configuration options
1.2.1 SID_OPTION_BLE_USER_CONFIG
SID_OPTION_BLE_USER_CONFIG lets you set each BLE parameter individually, so you can tune each parameter for power:
typedef struct sid_ble_user_config {
sid_ble_cfg_adv_param_t adv_param;
sid_ble_cfg_conn_param_t conn_param;
bool is_set; // True: Set, False: Get
enum sid_ble_user_config_type cfg_type; // Configuration type
uint32_t inactivity_timeout;
} sid_ble_user_config_t;
enum sid_ble_user_config_type {
SID_BLE_USER_CFG_ADV,
SID_BLE_USER_CFG_CONN,
SID_BLE_USER_CFG_ADV_AND_CONN,
SID_BLE_USER_CFG_INACTIVITY_TIMEOUT,
};
To read the current configuration, set is_set to false and cfg_type to the configuration you want. sid_option() fills in the structure with the current values.
1.2.2 SID_OPTION_BLE_CONNECTION_POLICY
SID_OPTION_BLE_CONNECTION_POLICY provides pre-configured settings (overridable with SID_OPTION_BLE_USER_CONFIG) and long-lived connection policies to reduce frequent advertising and connection establishment overhead:
typedef struct sid_ble_connection_policy {
bool is_set;
enum sid_ble_llc_optimization_policy llc_policy;
enum sid_ble_conn_policy conn_policy;
} sid_ble_connection_policy_t;
enum sid_ble_llc_optimization_policy {
SID_BLE_LLC_POWER_OPTIMIZED,
SID_BLE_LLC_LATENCY_OPTIMIZED,
};
enum sid_ble_conn_policy {
SID_BLE_CONN_POLICY_DEFAULT,
SID_BLE_CONN_POLICY_LONG_LIVED_CONNECTION,
SID_BLE_CONN_POLICY_OPTIMAL_ADVERTISING,
};
1.3 Advertisement power optimization
1.3.1 Advertisement interval configuration
Advertisement intervals should be configured based on application requirements and power constraints. In the examples on this page, handle is the Sidewalk handle returned by sid_init().
// Example advertisement configuration - tune for your application
sid_ble_user_config_t adv_config = {
.is_set = true,
.cfg_type = SID_BLE_USER_CFG_ADV,
.adv_param = {
.fast_interval = 800, // 0.625 ms units: 800 = 500 ms. Adjust based on discovery requirements
.fast_timeout = 3000, // 10 ms units: 3000 = 30 s. Tune for your application
.slow_interval = 3200, // 0.625 ms units: 3200 = 2 s. Balance power vs discoverability
.slow_timeout = 0 // 10 ms units. Set timeout as needed
}
};
// Apply configuration
sid_error_t err = sid_option(handle, SID_OPTION_BLE_USER_CONFIG,
&adv_config, sizeof(adv_config));
: Custom advertisement intervals allow balancing discovery time vs power consumption based on specific application needs.
1.4 Connection power management
1.4.1 Connection parameter configuration
Connection parameters should be configured based on application data rate and power requirements:
// Example connection parameters - adjust for your use case
sid_ble_user_config_t conn_config = {
.is_set = true,
.cfg_type = SID_BLE_USER_CFG_CONN,
.conn_param = {
.min_conn_interval = 400, // 1.25 ms units: 400 = 500 ms. Adjust based on data rate needs
.max_conn_interval = 800, // 1.25 ms units: 800 = 1 s. Longer intervals = lower power
.slave_latency = 9, // Connection events the device may skip. Higher latency = lower power
.conn_sup_timeout = 6000 // 10 ms units: 6000 = 60 s (must exceed (1 + latency) x max interval x 2 = 20 s)
}
};
sid_error_t err = sid_option(handle, SID_OPTION_BLE_USER_CONFIG,
&conn_config, sizeof(conn_config));
1.4.2 Connection policy configuration
Select pre-configured policies based on application usage patterns:
// Example connection policy - choose based on usage
sid_ble_connection_policy_t policy_config = {
.is_set = true,
.llc_policy = SID_BLE_LLC_POWER_OPTIMIZED, // vs SID_BLE_LLC_LATENCY_OPTIMIZED
.conn_policy = SID_BLE_CONN_POLICY_LONG_LIVED_CONNECTION // Choose based on needs
};
sid_error_t err = sid_option(handle, SID_OPTION_BLE_CONNECTION_POLICY,
&policy_config, sizeof(policy_config));
: Long-lived connections avoid frequent advertising and connection establishment, which are power-intensive operations. The device keeps the connection open longer, reducing overall power consumption.
1.5 Inactivity timeout configuration
1.5.1 Example configuration
Configure automatic disconnection when BLE has no activity:
// Configure inactivity timeout
sid_ble_user_config_t timeout_config = {
.is_set = true,
.cfg_type = SID_BLE_USER_CFG_INACTIVITY_TIMEOUT,
.inactivity_timeout = 30000 // Tune based on usage patterns
};
sid_error_t err = sid_option(handle, SID_OPTION_BLE_USER_CONFIG,
&timeout_config, sizeof(timeout_config));
: Automatically breaks BLE connections when inactive, preventing unnecessary power drain from maintaining idle connections.
1.6 Configuration strategy
1.6.1 Policy vs custom configuration
Choose between pre-configured policies and custom parameters:
// Option 1: Use pre-configured policy (recommended for most cases)
void use_preconfigured_policy(struct sid_handle *handle) {
sid_ble_connection_policy_t policy = {
.is_set = true,
.llc_policy = SID_BLE_LLC_POWER_OPTIMIZED,
.conn_policy = SID_BLE_CONN_POLICY_LONG_LIVED_CONNECTION
};
sid_option(handle, SID_OPTION_BLE_CONNECTION_POLICY, &policy, sizeof(policy));
}
// Option 2: Override with custom parameters for specific needs
void override_with_custom_config(struct sid_handle *handle) {
// Custom config overrides policy settings
sid_ble_user_config_t config = {
.is_set = true,
.cfg_type = SID_BLE_USER_CFG_ADV_AND_CONN,
.adv_param = { .fast_interval = 1600, .slow_interval = 8000 },
.conn_param = {
.min_conn_interval = 400,
.max_conn_interval = 800,
.slave_latency = 9,
.conn_sup_timeout = 6000
}
};
sid_option(handle, SID_OPTION_BLE_USER_CONFIG, &config, sizeof(config));
}