From 67aae770526b1cf24d22598a8abe0ecda4935a2b Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Sat, 9 May 2020 18:47:00 +0200 Subject: [PATCH] fix(ess): Show how to update a characteristic without a callback --- epicardium/ble/ble_api.h | 3 ++- epicardium/ble/ess.c | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/epicardium/ble/ble_api.h b/epicardium/ble/ble_api.h index d46b0fe8e..8a74f0d7a 100644 --- a/epicardium/ble/ble_api.h +++ b/epicardium/ble/ble_api.h @@ -22,7 +22,8 @@ /*************************************************************************************************/ void BleStart(void); - /* ATT client module interface. Used by main BLE module */ void bleValueUpdate(attEvt_t *pMsg); void bleDiscCback(dmConnId_t connId, uint8_t status); + +void bleESS_update(); diff --git a/epicardium/ble/ess.c b/epicardium/ble/ess.c index e45766412..a9b58a837 100644 --- a/epicardium/ble/ess.c +++ b/epicardium/ble/ess.c @@ -70,7 +70,7 @@ static const attsAttr_t ESSSvcAttrList[] = { .pValue = initTemperatureValue, .pLen = &initTemperatureLen, .maxLen = sizeof(initTemperatureValue), - .settings = ATTS_SET_READ_CBACK, + //.settings = ATTS_SET_READ_CBACK, .permissions = ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH, }, @@ -80,10 +80,14 @@ static const attsAttr_t ESSSvcAttrList[] = { WSF_CT_ASSERT( ((sizeof(ESSSvcAttrList) / sizeof(ESSSvcAttrList[0])) == ESS_END_HDL - ESS_START_HDL + 1)); + +#if 0 /* * BLE ESS read callback. + * + * Disabled at the moment as no dynamic handling of read requests + * is needed and all fields are updated by bleESS_update() */ - static uint8_t readESSCB( dmConnId_t connId, uint16_t handle, @@ -95,29 +99,35 @@ static uint8_t readESSCB( switch (handle) { // Temperature case ESS_TEMPERATURE_VAL_HDL: - //pAttr->pValue[0] = i16 & 0xFF; //pAttr->pValue[1] = i16 >> 8; - *((int16_t *)pAttr->pValue) = i16; - APP_TRACE_INFO1("ble-ess: read temperature: %d\n", i16); + //*((int16_t *)pAttr->pValue) = i16; + //APP_TRACE_INFO1("ble-ess: read temperature: %d\n", i16); return ATT_SUCCESS; default: APP_TRACE_INFO0("ble-card10: read no handler found\n"); return ATT_ERR_HANDLE; } } +#endif static attsGroup_t svcESSGroup = { .pNext = NULL, .pAttr = (attsAttr_t *)ESSSvcAttrList, - .readCback = readESSCB, + .readCback = NULL, + //.readCback = readESSCB, .writeCback = NULL, .startHandle = ESS_START_HDL, .endHandle = ESS_END_HDL, }; +void bleESS_update(void) +{ + uint16_t i16 = 0; + AttsSetAttr(ESS_TEMPERATURE_VAL_HDL, sizeof(i16), (uint8_t *)&i16); +} + /* - * This registers and starts the BLE card10 service. + * This registers and starts the ESS service. */ - void bleESS_init(void) { AttsAddGroup(&svcESSGroup); -- GitLab