From 223c5bbd64cb1c9b5380d85d6208ad04abf81a37 Mon Sep 17 00:00:00 2001
From: Martin/Geno <geno+dev@fireorbit.de>
Date: Mon, 19 Aug 2019 02:40:55 +0200
Subject: [PATCH] ble: make set time easier

---
 epicardium/ble/card10.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/epicardium/ble/card10.c b/epicardium/ble/card10.c
index 050ad60c..cc08dec7 100644
--- a/epicardium/ble/card10.c
+++ b/epicardium/ble/card10.c
@@ -504,19 +504,16 @@ static void *addCard10GroupDyn(void)
 /*
  * Set the time given in milliseconds since 1.1.1970 as 64 bit integer.
  */
-static uint8_t setTime(uint8_t *pValue, uint16_t len)
+static uint8_t setTime(uint8_t *pValue)
 {
 	uint64_t timeNet;
 	uint64_t time;
 
-	if (len < sizeof(uint64_t)) {
-		return ATT_ERR_LENGTH;
-	}
 	memcpy(&timeNet, pValue, sizeof(timeNet));
-
 	time = __bswap64(timeNet);
 	epic_rtc_set_milliseconds(time);
 
+	APP_TRACE_INFO1("set time to: %d\n", time);
 	return ATT_SUCCESS;
 }
 
@@ -539,13 +536,7 @@ static uint8_t writeCard10CB(
 	switch (handle) {
 	// time
 	case CARD10_TIME_UPDATE_VAL_HDL:
-		if (operation == ATT_PDU_PREP_WRITE_REQ) {
-			if (len < sizeof(uint64_t)) {
-				return ATT_ERR_LENGTH;
-			}
-			return ATT_SUCCESS;
-		}
-		return setTime(pValue, len);
+		return setTime(pValue);
 	// vibra
 	case CARD10_VIBRA_VAL_HDL:
 		BYTES_TO_UINT16(ui16, pValue);
-- 
GitLab