drivers/nble: Add initial implementation of on_ble_gatts_write_evt

Change-Id: Ib28d35d6f5aac697dbbbac8e7d01e6bfcf6545c6
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2016-02-04 12:58:19 +02:00 committed by Anas Nashif
commit 922b83ac38
2 changed files with 21 additions and 5 deletions

View file

@ -427,10 +427,27 @@ void on_ble_gattc_value_evt(const struct ble_gattc_value_evt *ev,
BT_DBG(""); BT_DBG("");
} }
void on_ble_gatts_write_evt(const struct ble_gatt_wr_evt *ev, void on_ble_gatts_write_evt(const struct ble_gatt_wr_evt *evt,
const uint8_t *buf, uint8_t buflen) const uint8_t *buf, uint8_t buflen)
{ {
BT_DBG(""); const struct bt_gatt_attr *attr = evt->attr;
struct ble_gatts_rw_reply_params reply_data;
if (attr->write) {
reply_data.status = attr->write(NULL, attr, buf, buflen,
evt->offset);
}
BT_DBG("handle 0x%04x buf %p len %u", attr->handle, buf, buflen);
if (evt->reply) {
reply_data.conn_handle = evt->conn_handle;
reply_data.offset = evt->offset;
reply_data.write_reply = 1;
nble_gatts_rw_authorize_reply_req(&reply_data, NULL,
reply_data.status);
}
} }
void on_ble_gatts_get_attribute_value_rsp(const struct ble_gatts_attribute_response *par, void on_ble_gatts_get_attribute_value_rsp(const struct ble_gatts_attribute_response *par,

View file

@ -93,12 +93,11 @@ enum BLE_GATTS_WR_OPS {
* Write event context data structure. * Write event context data structure.
*/ */
struct ble_gatt_wr_evt { struct ble_gatt_wr_evt {
/**< Attribute mapping indexes */ struct bt_gatt_attr *attr; /**< GATT Attribute */
struct ble_gatt_attr_handle_mapping attr;
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle; /**< Connection handle */
uint16_t attr_handle; /**< handle of attribute to write */ uint16_t attr_handle; /**< handle of attribute to write */
uint16_t offset; /**< offset in attribute buffer */ uint16_t offset; /**< offset in attribute buffer */
uint8_t op; /**< @ref BLE_GATTS_WR_OPS */ uint8_t reply; /**< 1 if reply required, 0 otherwise */
}; };
/** /**