From 3a0b7452034ecf7551452a801651b3e9b79231cd Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sun, 15 Sep 2019 20:09:21 +0200
Subject: [PATCH] fix(ble): Increase BLE task priority

Also decrease the time needed to update the LEDs
---
 epicardium/ble/card10.c       | 17 ++++++-----------
 epicardium/ble/filetransfer.c |  4 +---
 epicardium/main.c             |  2 +-
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/epicardium/ble/card10.c b/epicardium/ble/card10.c
index 25697ff4..7f896bfe 100644
--- a/epicardium/ble/card10.c
+++ b/epicardium/ble/card10.c
@@ -776,25 +776,20 @@ static uint8_t writeCard10CB(
 		}
 	// leds above
 	case CARD10_LEDS_ABOVE_VAL_HDL:
+		APP_TRACE_INFO0("ble-card10: update LEDs above");
+
 		for (ui16 = 0; ui16 < 11; ui16++) {
-			epic_leds_set(
-				ui16,
-				pValue[ui16 * 3],
-				pValue[ui16 * 3 + 1],
-				pValue[ui16 * 3 + 2]
-			);
-			APP_TRACE_INFO4(
-				"ble-card10: set led %ld above to #%02x%02x%02x\n",
+			epic_leds_prep(
 				ui16,
 				pValue[ui16 * 3],
 				pValue[ui16 * 3 + 1],
 				pValue[ui16 * 3 + 2]
 			);
 		}
+		epic_leds_update();
+		return ATT_SUCCESS;
 	default:
-		APP_TRACE_INFO1(
-			"ble-card10: unsupported characteristic: %c\n", handle
-		);
+		APP_TRACE_INFO1("ble-card10: unsupported handle: %x\n", handle);
 		return ATT_ERR_HANDLE;
 	}
 }
diff --git a/epicardium/ble/filetransfer.c b/epicardium/ble/filetransfer.c
index 88b31308..df888a74 100644
--- a/epicardium/ble/filetransfer.c
+++ b/epicardium/ble/filetransfer.c
@@ -396,9 +396,7 @@ static uint8_t writeCallback(
 			connId, handle, operation, offset, len, pValue, pAttr
 		);
 	default:
-		LOG_ERR("filetrans",
-			"unsupported characteristic: %c\n",
-			handle);
+		LOG_ERR("filetrans", "unsupported handle: %x\n", handle);
 		return ATT_ERR_HANDLE;
 	}
 }
diff --git a/epicardium/main.c b/epicardium/main.c
index a0c5fad5..4e3e625b 100644
--- a/epicardium/main.c
+++ b/epicardium/main.c
@@ -119,7 +119,7 @@ int main(void)
 			    (const char *)"BLE",
 			    configMINIMAL_STACK_SIZE * 10,
 			    NULL,
-			    tskIDLE_PRIORITY + 1,
+			    tskIDLE_PRIORITY + 3,
 			    NULL) != pdPASS) {
 			LOG_CRIT("startup", "Failed to create %s task!", "BLE");
 			abort();
-- 
GitLab