This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

bugfix request: fix eddystone advertisement durations

the duration field in ble_gap_adv_params_t should be set in in 10 ms units, but currently the timeouts are implemented wrong. APP_CFG_NON_CONN_ADV_TIMEOUT is set in seconds but APP_CFG_CONNECTABLE_ADV_TIMEOUT is set in milliseconds which is not consistent. I suggest the following changes in components/ble/ble_services/eddystone/es_adv.c and examples/ble_peripheral/ble_app_eddystone/es_app_config.h:

 static void get_adv_params(ble_gap_adv_params_t * p_adv_params,
                            bool                   non_connectable,
                            bool                   remain_connectable)
 {
     // Initialize advertising parameters (used when starting advertising).
     memset(p_adv_params, 0, sizeof(ble_gap_adv_params_t));

     // Non-connectable
     p_adv_params->properties.type = non_connectable
                                   ? BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED
                                   : BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
     p_adv_params->p_peer_addr     = NULL; // Undirected advertisement.
     p_adv_params->filter_policy   = BLE_GAP_ADV_FP_ANY;
     p_adv_params->interval        = non_connectable ? m_adv_interval : APP_CFG_CONNECTABLE_ADV_INTERVAL_MS;
     p_adv_params->duration        = non_connectable
-                                  ? APP_CFG_NON_CONN_ADV_TIMEOUT
-                                  : (remain_connectable ? 0 : APP_CFG_CONNECTABLE_ADV_TIMEOUT);
+                                  ? APP_CFG_NON_CONN_ADV_TIMEOUT * 100
+                                  : (remain_connectable ? 0 : APP_CFG_CONNECTABLE_ADV_TIMEOUT * 100);
     p_adv_params->primary_phy     = BLE_GAP_PHY_1MBPS;
 }
 #define APP_CFG_NON_CONN_ADV_TIMEOUT                        0                           //!< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables the time-out.
 #define APP_CFG_NON_CONN_ADV_INTERVAL_MS                    1000                        //!< The advertising interval for non-connectable advertisement (in milliseconds). This value can vary between 100 ms and 10.24 s.
-#define APP_CFG_CONNECTABLE_ADV_TIMEOUT                     6000                        //!< Time for which the device must be advertising in connectable mode (in milliseconds). 0 disables the time-out.
+#define APP_CFG_CONNECTABLE_ADV_TIMEOUT                     60                          //!< Time for which the device must be advertising in connectable mode (in seconds). 0 disables the time-out.
 #define APP_CFG_CONNECTABLE_ADV_INTERVAL_MS                 100                         //!< The advertising interval for connectable advertisement (in milliseconds). This value can vary between 20 ms and 10.24 s.
Related