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: nRF51GattServer.cpp
- Revision:
- 1:f84abedbf4fb
- Parent:
- 0:eff01767de02
- Child:
- 2:49e7ee9e88ab
--- a/nRF51GattServer.cpp Wed Mar 26 14:38:17 2014 +0000 +++ b/nRF51GattServer.cpp Thu Apr 03 01:45:38 2014 +0100 @@ -20,6 +20,8 @@ #include "common/common.h" #include "btle/custom/custom_helper.h" +#include "hw/nRF51822n/nRF51Gap.h" + /**************************************************************************/ /*! @brief Adds a new service to the GATT table on the peripheral @@ -138,13 +140,16 @@ /**************************************************************************/ ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len, bool localOnly) { + uint16_t gapConnectionHandle = nRF51Gap::getInstance().getConnectionHandle(); + if (localOnly) { /* Only update locally regardless of notify/indicate */ ASSERT_INT( ERROR_NONE, sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer), BLE_ERROR_PARAM_OUT_OF_RANGE ); } + if ((p_characteristics[charHandle]->properties & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)) && - (m_connectionHandle != BLE_CONN_HANDLE_INVALID) ) + (gapConnectionHandle != BLE_CONN_HANDLE_INVALID) ) { /* HVX update for the characteristic value */ ble_gatts_hvx_params_t hvx_params; @@ -155,7 +160,7 @@ hvx_params.p_data = buffer; hvx_params.p_len = &len; - error_t error = (error_t) sd_ble_gatts_hvx(m_connectionHandle, &hvx_params); + error_t error = (error_t) sd_ble_gatts_hvx(gapConnectionHandle, &hvx_params); /* ERROR_INVALID_STATE, ERROR_BUSY, ERROR_GATTS_SYS_ATTR_MISSING and ERROR_NO_TX_BUFFERS the ATT table has been updated. */ if ( (error != ERROR_NONE ) && (error != ERROR_INVALID_STATE) &&