Previous version which works for my stm32f401 Nucleo board
Fork of X_NUCLEO_IDB0XA1 by
Diff: BlueNRGGattServer.cpp
- Revision:
- 55:0e4db6804c8d
- Parent:
- 54:bae48224c2f9
- Child:
- 58:027c65a54097
--- a/BlueNRGGattServer.cpp Wed Oct 01 05:39:59 2014 +0000 +++ b/BlueNRGGattServer.cpp Wed Oct 01 08:49:52 2014 +0000 @@ -241,7 +241,7 @@ GattCharacteristic *p_char = BlueNRGGattServer::getInstance().getCharacteristicFromHandle(charHandle); if(p_char->getProperties() & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE)) { - BlueNRGGattServer::getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT); + BlueNRGGattServer::getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT, charHandle); } return BLE_ERROR_NONE; @@ -339,149 +339,4 @@ return p_char; } -/**************************************************************************/ -/*! - @brief sets device name characteristic - @param[in] deviceName - pointer to device name to be set - - @returns ble_error_t - - @retval BLE_ERROR_NONE - Everything executed properly - - @section EXAMPLE - - @code - - @endcode -*/ -/**************************************************************************/ -ble_error_t BlueNRGGattServer::setDeviceName(const uint8_t *deviceName) -{ - int ret; - uint8_t nameLen = 0; - - DeviceName = (uint8_t *)deviceName; - //DEBUG("SetDeviceName=%s\n\r", DeviceName); - - nameLen = strlen((const char*)DeviceName); - //DEBUG("DeviceName Size=%d\n\r", nameLen); - - ret = aci_gatt_update_char_value(g_gap_service_handle, - g_device_name_char_handle, - 0, - nameLen, - (tHalUint8 *)DeviceName); - - if(ret){ - DEBUG("device set name failed\n\r"); - return BLE_ERROR_PARAM_OUT_OF_RANGE;//TODO:Wrong error code - } - - return BLE_ERROR_NONE; -} - -/**************************************************************************/ -/*! - @brief gets device name characteristic - - @param[in] deviceName - pointer to device name - - - @param[in] lengthP - pointer to device name length - - @returns ble_error_t - - @retval BLE_ERROR_NONE - Everything executed properly - - @section EXAMPLE - - @code - - @endcode -*/ -/**************************************************************************/ -ble_error_t BlueNRGGattServer::getDeviceName(uint8_t *deviceName, unsigned *lengthP) -{ - int ret; - - if(DeviceName==NULL) - return BLE_ERROR_PARAM_OUT_OF_RANGE; - - strcpy((char*)deviceName, (const char*)DeviceName); - //DEBUG("GetDeviceName=%s\n\r", deviceName); - - *lengthP = strlen((const char*)DeviceName); - //DEBUG("DeviceName Size=%d\n\r", *lengthP); - - return BLE_ERROR_NONE; -} - -/**************************************************************************/ -/*! - @brief sets device appearance characteristic - - @param[in] appearance - device appearance - - @returns ble_error_t - - @retval BLE_ERROR_NONE - Everything executed properly - - @section EXAMPLE - - @code - - @endcode -*/ -/**************************************************************************/ -ble_error_t BlueNRGGattServer::setAppearance(uint16_t appearance) -{ - /* - Tested with GapAdvertisingData::GENERIC_PHONE. - for other appearances BLE Scanner android app is not behaving properly - */ - //char deviceAppearance[2]; - STORE_LE_16(deviceAppearance, appearance); - DEBUG("input: incoming = %d deviceAppearance= 0x%x 0x%x\n\r", appearance, deviceAppearance[1], deviceAppearance[0]); - - aci_gatt_update_char_value(g_gap_service_handle, g_appearance_char_handle, 0, 2, (tHalUint8 *)deviceAppearance); - - return BLE_ERROR_NONE; -} - -/**************************************************************************/ -/*! - @brief gets device appearance - - @param[in] appearance - pointer to device appearance value - - @returns ble_error_t - - @retval BLE_ERROR_NONE - Everything executed properly - - @section EXAMPLE - - @code - - @endcode -*/ -/**************************************************************************/ -ble_error_t BlueNRGGattServer::getAppearance(uint16_t *appearanceP) -{ - uint16_t devP; - if(!appearanceP) return BLE_ERROR_PARAM_OUT_OF_RANGE; - devP = ((uint16_t)(0x0000|deviceAppearance[0])) | (((uint16_t)(0x0000|deviceAppearance[1]))<<8); - strcpy((char*)appearanceP, (const char*)&devP); - - return BLE_ERROR_NONE; -} -