From fe64723f855f4ea1a9ca9f5f757734d47d63ce43 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sun, 24 Jan 2021 21:17:44 +0100
Subject: [PATCH] change(ble): add epic call to set an attribute

---
 epicardium/ble/epic_att_api.c           | 7 +++++++
 epicardium/epicardium.h                 | 2 +-
 pycardium/modules/modbluetooth_card10.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/epicardium/ble/epic_att_api.c b/epicardium/ble/epic_att_api.c
index a0da6a219..9dfa44dcd 100644
--- a/epicardium/ble/epic_att_api.c
+++ b/epicardium/ble/epic_att_api.c
@@ -265,3 +265,10 @@ int epic_ble_atts_set_buffer(uint16_t value_handle, size_t len, bool append)
 {
 	return AttsDynResize(value_handle, len);
 }
+
+int epic_ble_atts_set_attr(
+	uint16_t handle, const uint8_t *value, uint16_t value_len
+) {
+	uint8_t ret = AttsSetAttr(handle, value_len, (uint8_t *)value);
+	return ret;
+}
diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h
index a63784e40..50632e5bf 100644
--- a/epicardium/epicardium.h
+++ b/epicardium/epicardium.h
@@ -2597,7 +2597,7 @@ API(API_BLE_ATTS_DYN_ADD_CHARACTERISTIC, int epic_atts_dyn_add_characteristic(vo
 
 API(API_BLE_ATTS_SEND_SERVICE_CHANGED_IND, int epic_atts_dyn_send_service_changed_ind(void));
 
-API(API_BLE_ATTS_SET_ATTR, uint8_t AttsSetAttr(uint16_t handle, uint16_t valueLen, uint8_t *pValue));
+API(API_BLE_ATTS_SET_ATTR, int epic_ble_atts_set_attr(uint16_t handle, const uint8_t *value, uint16_t value_len));
 API(API_BLE_ATTS_GET_ATTR, uint8_t AttsGetAttr(uint16_t handle, uint16_t *pLen, uint8_t **pValue));
 API(API_BLE_ATTS_HANDLE_VALUE_NTF, int epic_ble_atts_handle_value_ntf(uint8_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue));
 API(API_BLE_ATTS_HANDLE_VALUE_IND, int epic_ble_atts_handle_value_ind(uint8_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue));
diff --git a/pycardium/modules/modbluetooth_card10.c b/pycardium/modules/modbluetooth_card10.c
index 3aa760ff5..25b9e2e42 100644
--- a/pycardium/modules/modbluetooth_card10.c
+++ b/pycardium/modules/modbluetooth_card10.c
@@ -510,7 +510,7 @@ int mp_bluetooth_gatts_write(
 ) {
 	// TODO: which return value to choose?
 	mp_bluetooth_gatts_db_write(GATTS_DB, value_handle, value, value_len);
-	uint8_t ret = AttsSetAttr(value_handle, value_len, (uint8_t *)value);
+	int ret = epic_ble_atts_set_attr(value_handle, value, value_len);
 	return ret;
 }
 // Notify the central that it should do a read.
-- 
GitLab