diff --git a/include/ble_utils/ble_utils.hpp b/include/ble_utils/ble_utils.hpp index 24527c9..16e779e 100644 --- a/include/ble_utils/ble_utils.hpp +++ b/include/ble_utils/ble_utils.hpp @@ -62,10 +62,11 @@ class Characteristic * @return Number of bytes read, or in case of an error * BT_GATT_ERR() with a specific BT_ATT_ERR_* error code. */ - virtual ssize_t read_cb(void *buf, uint16_t len) + virtual ssize_t read_cb(void *buf, uint16_t len, uint16_t offset) { ARG_UNUSED(buf); ARG_UNUSED(len); + ARG_UNUSED(offset); return 0; }; @@ -78,10 +79,12 @@ class Characteristic * @return Number of bytes written, or in case of an error * BT_GATT_ERR() with a specific BT_ATT_ERR_* error code. */ - virtual ssize_t write_cb(const void *buf,uint16_t len) + virtual ssize_t write_cb(const void *buf,uint16_t len, uint16_t offset, uint8_t flags) { ARG_UNUSED(buf); ARG_UNUSED(len); + ARG_UNUSED(offset); + ARG_UNUSED(flags); return 0; } diff --git a/samples/uptime/src/uptime_service.cpp b/samples/uptime/src/uptime_service.cpp index eab680b..d78d95e 100644 --- a/samples/uptime/src/uptime_service.cpp +++ b/samples/uptime/src/uptime_service.cpp @@ -29,8 +29,9 @@ Basic::Basic(): { } -ssize_t Basic::read_cb(void *buf, uint16_t len) +ssize_t Basic::read_cb(void *buf, uint16_t len, uint16_t offset) { + ARG_UNUSED(offset); uint8_t * pUptime = static_cast(buf); pUptime[0] = m_uptime & 0xFF; pUptime[1] = m_uptime>>8 & 0xFF; diff --git a/samples/uptime/src/uptime_service.hpp b/samples/uptime/src/uptime_service.hpp index d8fb254..c1899ed 100644 --- a/samples/uptime/src/uptime_service.hpp +++ b/samples/uptime/src/uptime_service.hpp @@ -42,7 +42,7 @@ class Basic final: public ble_utils::gatt::Characteristic Basic(); void update(uint32_t uptime); private: - ssize_t read_cb(void *buf, uint16_t len) override; + ssize_t read_cb(void *buf, uint16_t len, uint16_t offset) override; uint32_t m_uptime{0}; }; diff --git a/src/ble_utils.cpp b/src/ble_utils.cpp index 7b3790e..997fcfd 100644 --- a/src/ble_utils.cpp +++ b/src/ble_utils.cpp @@ -66,9 +66,8 @@ ssize_t Characteristic::_read_cb(struct bt_conn *conn, uint16_t offset) { ARG_UNUSED(conn); - ARG_UNUSED(offset); auto instance = static_cast(attr->user_data); - return instance->read_cb(buf, len); + return instance->read_cb(buf, len, offset); } ssize_t Characteristic::_write_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr, @@ -78,10 +77,8 @@ ssize_t Characteristic::_write_cb(struct bt_conn *conn, uint8_t flags) { ARG_UNUSED(conn); - ARG_UNUSED(offset); - ARG_UNUSED(flags); auto instance = static_cast(attr->user_data); - return instance->write_cb(buf, len); + return instance->write_cb(buf, len, offset, flags); } Service::Service(const bt_uuid *uuid): @@ -112,6 +109,7 @@ void Service::register_char(const Characteristic * chrc) ICharacteristicCCC::attr_size : Characteristic::attr_size; const auto req_size{m_gatt_service.attr_count + chrc_attr_size}; + ARG_UNUSED(req_size); __ASSERT(req_size <= MAX_ATTR, "Max. attribute size reached"); attrs[m_gatt_service.attr_count++] = chrc->m_attr; attrs[m_gatt_service.attr_count++] = chrc->m_attr_value;