From 849e5ce4392de328a126eafe1e383bd6284f0804 Mon Sep 17 00:00:00 2001
From: Djuri Baars <dsbaars@users.noreply.github.com>
Date: Mon, 9 Sep 2024 15:13:41 +0200
Subject: [PATCH] Finish V2 MsgPack WebSocket API implementation

---
 data                       | 2 +-
 dependencies.lock          | 2 +-
 src/lib/block_notify.cpp   | 2 +-
 src/lib/screen_handler.cpp | 9 +++++----
 src/lib/v2_notify.cpp      | 2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/data b/data
index 2fffb3e..1fa62ca 160000
--- a/data
+++ b/data
@@ -1 +1 @@
-Subproject commit 2fffb3ef0284b4262ca97a81eb979259186604e5
+Subproject commit 1fa62ca88dc9cf85109712082e2b0d3916d03323
diff --git a/dependencies.lock b/dependencies.lock
index 6400884..f47f33d 100644
--- a/dependencies.lock
+++ b/dependencies.lock
@@ -4,6 +4,6 @@ dependencies:
     source:
       type: idf
     version: 4.4.7
-manifest_hash: 615d994fdba8799111cf7825a85adb23ca6a2ae02b2335b53fde1188ff862f23
+manifest_hash: 3117ab97df715ceaa7b9cacfc3cc7071408d26f122740eea130b5286dc5cd988
 target: esp32s3
 version: 1.0.0
diff --git a/src/lib/block_notify.cpp b/src/lib/block_notify.cpp
index dad6ad1..19f1893 100644
--- a/src/lib/block_notify.cpp
+++ b/src/lib/block_notify.cpp
@@ -2,7 +2,7 @@
 
 char *wsServer;
 esp_websocket_client_handle_t blockNotifyClient = NULL;
-uint currentBlockHeight = 840000;
+uint currentBlockHeight = 860000;
 uint blockMedianFee = 1;
 bool blockNotifyInit = false;
 unsigned long int lastBlockUpdate;
diff --git a/src/lib/screen_handler.cpp b/src/lib/screen_handler.cpp
index 95a8682..13e93b5 100644
--- a/src/lib/screen_handler.cpp
+++ b/src/lib/screen_handler.cpp
@@ -8,14 +8,13 @@ TaskHandle_t workerTaskHandle;
 esp_timer_handle_t screenRotateTimer;
 esp_timer_handle_t minuteTimer;
 
-std::array<std::string, NUM_SCREENS> taskEpdContent = {"", "", "", "",
-                                                       "", "", ""};
+std::array<std::string, NUM_SCREENS> taskEpdContent = {};
 std::string priceString;
 
 #define WORK_QUEUE_SIZE 10
 QueueHandle_t workQueue = NULL;
 
-uint currentScreen;
+uint currentScreen = SCREEN_BLOCK_HEIGHT;
 uint currentCurrency = CURRENCY_USD;
 
 void workerTask(void *pvParameters) {
@@ -158,7 +157,9 @@ void setupTasks() {
               &taskScreenRotateTaskHandle);
 
   waitUntilNoneBusy();
-  setCurrentScreen(preferences.getUInt("currentScreen", DEFAULT_CURRENT_SCREEN));
+
+  if (findScreenIndexByValue(preferences.getUInt("currentScreen", DEFAULT_CURRENT_SCREEN)) != -1)
+    setCurrentScreen(preferences.getUInt("currentScreen", DEFAULT_CURRENT_SCREEN));
 }
 
 void setupTimeUpdateTimer(void *pvParameters) {
diff --git a/src/lib/v2_notify.cpp b/src/lib/v2_notify.cpp
index a2f9744..e23c0af 100644
--- a/src/lib/v2_notify.cpp
+++ b/src/lib/v2_notify.cpp
@@ -15,7 +15,7 @@ void setupV2Notify()
     webSocket.onEvent(onWebsocketV2Event);
     webSocket.setReconnectInterval(5000);
     webSocket.enableHeartbeat(15000, 3000, 2);
-
+    
     setupV2NotifyTask();
 }