Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
Diff: nordic/softdevice_handler.cpp
- Revision:
- 37:c29c330d942c
- Parent:
- 0:eff01767de02
- Child:
- 51:63ba3bcf5cd6
--- a/nordic/softdevice_handler.cpp Thu Jul 03 10:01:02 2014 +0100 +++ b/nordic/softdevice_handler.cpp Mon Jul 07 13:43:31 2014 +0100 @@ -21,7 +21,7 @@ #if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD) #include "ant_interface.h" -#elif defined(ANT_STACK_SUPPORT_REQD) +#elif defined(ANT_STACK_SUPPORT_REQD) #include "ant_interface.h" #elif defined(BLE_STACK_SUPPORT_REQD) #include "ble.h" @@ -96,7 +96,7 @@ // Pull event from SOC. err_code = sd_evt_get(&evt_id); - + if (err_code == NRF_ERROR_NOT_FOUND) { no_more_soc_evts = true; @@ -205,7 +205,7 @@ { return NRF_ERROR_INVALID_PARAM; } - + // Check that buffer is correctly aligned. if (!is_word_aligned(p_evt_buffer)) { @@ -214,28 +214,58 @@ m_evt_buffer = (uint8_t *)p_evt_buffer; #else - // The variable p_evt_buffer is not needed if neither BLE Stack nor ANT stack support is + // The variable p_evt_buffer is not needed if neither BLE Stack nor ANT stack support is // required. UNUSED_PARAMETER(p_evt_buffer); #endif -#if defined (BLE_STACK_SUPPORT_REQD) +#if defined (BLE_STACK_SUPPORT_REQD) m_ble_evt_buffer_size = evt_buffer_size; #else // The variable evt_buffer_size is not needed if BLE Stack support is NOT required. UNUSED_PARAMETER(evt_buffer_size); #endif - + m_evt_schedule_func = evt_schedule_func; // Initialize SoftDevice. - + err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler); if (err_code != NRF_SUCCESS) { return err_code; } + /** + * Using this call, the application can select whether to include the + * Service Changed characteristic in the GATT Server. The default in all + * previous releases has been to include the Service Changed characteristic, + * but this affects how GATT clients behave. Specifically, it requires + * clients to subscribe to this attribute and not to cache attribute handles + * between connections unless the devices are bonded. If the application + * does not need to change the structure of the GATT server attributes at + * runtime this adds unnecessary complexity to the interaction with peer + * clients. If the SoftDevice is enabled with the Service Changed + * Characteristics turned off, then clients are allowed to cache attribute + * handles making applications simpler on both sides. + */ + ble_enable_params_t enableParams = { + .gatts_enable_params = { + .service_changed = 0 + } + }; + if ((err_code = sd_ble_enable(&enableParams)) != NRF_SUCCESS) { + return err_code; + } + + ble_gap_addr_t addr; + if ((err_code = sd_ble_gap_address_get(&addr)) != NRF_SUCCESS) { + return err_code; + } + if ((err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr)) != NRF_SUCCESS) { + return err_code; + } + m_softdevice_enabled = true; // Enable BLE event interrupt (interrupt priority has already been set by the stack). return sd_nvic_EnableIRQ(SWI2_IRQn); @@ -245,7 +275,7 @@ uint32_t softdevice_handler_sd_disable(void) { uint32_t err_code = sd_softdevice_disable(); - + m_softdevice_enabled = !(err_code == NRF_SUCCESS); return err_code;