1. BLE Power Optimization
1.1 Introduction
Bluetooth Low Energy (BLE) in Amazon Sidewalk provides local connectivity and serves as a bridge to cloud services. This chapter focuses on power optimization through proper configuration of and options.
1.2 BLE Configuration Options
1.2.1 SID_OPTION_BLE_USER_CONFIG
The option provides full customizable parameter configuration for BLE operations, allowing fine-tuned power optimization:
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,
};
1.2.2 SID_OPTION_BLE_CONNECTION_POLICY
The option provides pre-configured settings (overridable with ) 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:
// 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, // Adjust based on discovery requirements
.fast_timeout = 3000, // Tune for your application
.slow_interval = 3200, // Balance power vs discoverability
.slow_timeout = 0 // 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, // Adjust based on data rate needs
.max_conn_interval = 800, // Longer intervals = lower power
.slave_latency = 9, // Higher latency = lower power
.conn_sup_timeout = 6000 // Set appropriate for application
}
};
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 maintains connection longer, reducing overall power consumption.
1.5 Inactivity Timeout Configuration
1.5.1 Inactivity Timeout 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(sid_handle_t 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(sid_handle_t 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, .slave_latency = 9 }
};
sid_option(handle, SID_OPTION_BLE_USER_CONFIG, &config, sizeof(config));
}