|
|
@ -21,8 +21,6 @@ |
|
|
|
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */ |
|
|
|
#define NUS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the Nordic UART Service (vendor specific). */ |
|
|
|
|
|
|
|
#define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */ |
|
|
|
#define APP_ADV_DURATION 18000 /**< The advertising duration (180 seconds) in units of 10 milliseconds. */ |
|
|
|
BLE_ADVERTISING_DEF(m_advertising); /**< Advertising module instance. */ |
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
@ -129,14 +127,18 @@ static void on_conn_params_evt(ble_conn_params_evt_t *p_evt) |
|
|
|
static void conn_params_error_handler(uint32_t nrf_error) { APP_ERROR_HANDLER(nrf_error); } |
|
|
|
static void on_adv_evt(ble_adv_evt_t ble_adv_evt) |
|
|
|
{ |
|
|
|
|
|
|
|
switch (ble_adv_evt) |
|
|
|
{ |
|
|
|
case BLE_ADV_EVT_FAST: |
|
|
|
// err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING); |
|
|
|
// ZERROR_CHECK(err_code); |
|
|
|
ZLOGI("Fast advertising"); |
|
|
|
break; |
|
|
|
case BLE_ADV_EVT_SLOW: |
|
|
|
ZLOGI("Slow advertising"); |
|
|
|
break; |
|
|
|
|
|
|
|
case BLE_ADV_EVT_IDLE: |
|
|
|
// sleep_mode_enter(); |
|
|
|
ZLOGI("Advertising stopped"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
@ -236,13 +238,13 @@ NRF_SDH_STATE_OBSERVER(m_buttonless_dfu_state_obs, 0) = { |
|
|
|
.handler = buttonless_dfu_sdh_state_observer, |
|
|
|
}; |
|
|
|
|
|
|
|
static void advertising_config_get(ble_adv_modes_config_t *p_config) |
|
|
|
static void dfu_advertising_config_get(ble_adv_modes_config_t *p_config) |
|
|
|
{ |
|
|
|
memset(p_config, 0, sizeof(ble_adv_modes_config_t)); |
|
|
|
|
|
|
|
p_config->ble_adv_fast_enabled = true; |
|
|
|
p_config->ble_adv_fast_interval = APP_ADV_INTERVAL; |
|
|
|
p_config->ble_adv_fast_timeout = APP_ADV_DURATION; |
|
|
|
p_config->ble_adv_fast_interval = 64; |
|
|
|
p_config->ble_adv_fast_timeout = 3000;//30s |
|
|
|
} |
|
|
|
|
|
|
|
static void disconnect(uint16_t conn_handle, void *p_context) |
|
|
@ -275,7 +277,7 @@ static void ble_dfu_evt_handler(ble_dfu_buttonless_evt_type_t event) |
|
|
|
|
|
|
|
// Prevent device from advertising on disconnect. |
|
|
|
ble_adv_modes_config_t config; |
|
|
|
advertising_config_get(&config); |
|
|
|
dfu_advertising_config_get(&config); |
|
|
|
config.ble_adv_on_disconnect_disabled = true; |
|
|
|
ble_advertising_modes_config_set(&m_advertising, &config); |
|
|
|
|
|
|
@ -399,9 +401,15 @@ void zble_module_init(zble_module_cfg_t *cfg) |
|
|
|
init.srdata.uuids_complete.uuid_cnt = 0; |
|
|
|
init.srdata.uuids_complete.p_uuids = NULL; |
|
|
|
|
|
|
|
|
|
|
|
init.config.ble_adv_fast_enabled = true; |
|
|
|
init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; |
|
|
|
init.config.ble_adv_fast_timeout = 0; |
|
|
|
init.config.ble_adv_fast_interval = 64; //*0.625ms |
|
|
|
init.config.ble_adv_fast_timeout = 500; //*10ms |
|
|
|
|
|
|
|
init.config.ble_adv_slow_enabled = true; |
|
|
|
init.config.ble_adv_slow_interval = 32*100;//*0.625ms |
|
|
|
init.config.ble_adv_slow_timeout =0 ;//*10ms |
|
|
|
|
|
|
|
init.evt_handler = on_adv_evt; |
|
|
|
|
|
|
|
err_code = ble_advertising_init(&m_advertising, &init); |
|
|
|