mirror of https://github.com/ARMmbed/mbed-os.git
ignore offset, replace whole value of attr in auth callback
parent
55ffb176d5
commit
17bf70989d
|
@ -1692,6 +1692,10 @@ public:
|
||||||
* @note The params->len parameter initially contains the maximum length of
|
* @note The params->len parameter initially contains the maximum length of
|
||||||
* data that can be returned. Set it to the length of your data but it must
|
* data that can be returned. Set it to the length of your data but it must
|
||||||
* not be larger than the original value.
|
* not be larger than the original value.
|
||||||
|
*
|
||||||
|
* @note You must also take into account the offset provided in params->offset.
|
||||||
|
* The params->len you provide must be larger then the offset as the read operation
|
||||||
|
* will attempt to read at that offset.
|
||||||
*/
|
*/
|
||||||
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
|
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1148,8 +1148,9 @@ uint8_t GattServer::atts_read_cb(
|
||||||
|
|
||||||
/* if new data provided copy into the attribute value buffer */
|
/* if new data provided copy into the attribute value buffer */
|
||||||
if (read_auth_params.data) {
|
if (read_auth_params.data) {
|
||||||
if (read_auth_params.offset + read_auth_params.len > pAttr->maxLen) {
|
if (read_auth_params.len > pAttr->maxLen || offset >= read_auth_params.len) {
|
||||||
tr_error("Read authorisation callback set length larger than maximum attribute length. Cannot copy data");
|
tr_error("Read authorisation callback set length larger than maximum attribute length "
|
||||||
|
"or current offset is beyond new length. Cannot copy data");
|
||||||
|
|
||||||
GattReadCallbackParams read_params = {
|
GattReadCallbackParams read_params = {
|
||||||
connId,
|
connId,
|
||||||
|
@ -1164,7 +1165,7 @@ uint8_t GattServer::atts_read_cb(
|
||||||
return ATT_ERR_UNLIKELY;
|
return ATT_ERR_UNLIKELY;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pAttr->pValue + read_auth_params.offset, read_auth_params.data, read_auth_params.len);
|
memcpy(pAttr->pValue, read_auth_params.data, read_auth_params.len);
|
||||||
*pAttr->pLen = read_auth_params.len;
|
*pAttr->pLen = read_auth_params.len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue