mirror of
https://github.com/btclock/btclock_v3.git
synced 2024-11-19 04:40:09 +01:00
Use own data source for price and block data
This commit is contained in:
parent
efaab00fb4
commit
e0283d98ca
2
data
2
data
@ -1 +1 @@
|
|||||||
Subproject commit e47fc066b0608132c44a35f7041be80b263adcff
|
Subproject commit 6ecb4826000e4a34f22d98541d28448f844340f7
|
@ -87,6 +87,11 @@ void setupBlockNotify()
|
|||||||
xQueueSend(workQueue, &blockUpdate, portMAX_DELAY);
|
xQueueSend(workQueue, &blockUpdate, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preferences.getBool("ownDataSource", true))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// std::strcpy(wsServer, String("wss://" + mempoolInstance +
|
// std::strcpy(wsServer, String("wss://" + mempoolInstance +
|
||||||
// "/api/v1/ws").c_str());
|
// "/api/v1/ws").c_str());
|
||||||
|
|
||||||
@ -99,11 +104,11 @@ void setupBlockNotify()
|
|||||||
|
|
||||||
blockNotifyClient = esp_websocket_client_init(&config);
|
blockNotifyClient = esp_websocket_client_init(&config);
|
||||||
esp_websocket_register_events(blockNotifyClient, WEBSOCKET_EVENT_ANY,
|
esp_websocket_register_events(blockNotifyClient, WEBSOCKET_EVENT_ANY,
|
||||||
onWebsocketEvent, blockNotifyClient);
|
onWebsocketBlockEvent, blockNotifyClient);
|
||||||
esp_websocket_client_start(blockNotifyClient);
|
esp_websocket_client_start(blockNotifyClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onWebsocketEvent(void *handler_args, esp_event_base_t base,
|
void onWebsocketBlockEvent(void *handler_args, esp_event_base_t base,
|
||||||
int32_t event_id, void *event_data)
|
int32_t event_id, void *event_data)
|
||||||
{
|
{
|
||||||
esp_websocket_event_data_t *data = (esp_websocket_event_data_t *)event_data;
|
esp_websocket_event_data_t *data = (esp_websocket_event_data_t *)event_data;
|
||||||
@ -124,7 +129,7 @@ void onWebsocketEvent(void *handler_args, esp_event_base_t base,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case WEBSOCKET_EVENT_DATA:
|
case WEBSOCKET_EVENT_DATA:
|
||||||
onWebsocketMessage(data);
|
onWebsocketBlockMessage(data);
|
||||||
break;
|
break;
|
||||||
case WEBSOCKET_EVENT_ERROR:
|
case WEBSOCKET_EVENT_ERROR:
|
||||||
Serial.println(F("Mempool.space WS Connnection error"));
|
Serial.println(F("Mempool.space WS Connnection error"));
|
||||||
@ -135,7 +140,7 @@ void onWebsocketEvent(void *handler_args, esp_event_base_t base,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onWebsocketMessage(esp_websocket_event_data_t *event_data)
|
void onWebsocketBlockMessage(esp_websocket_event_data_t *event_data)
|
||||||
{
|
{
|
||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
void setupBlockNotify();
|
void setupBlockNotify();
|
||||||
|
|
||||||
void onWebsocketEvent(void *handler_args, esp_event_base_t base,
|
void onWebsocketBlockEvent(void *handler_args, esp_event_base_t base,
|
||||||
int32_t event_id, void *event_data);
|
int32_t event_id, void *event_data);
|
||||||
void onWebsocketMessage(esp_websocket_event_data_t *event_data);
|
void onWebsocketBlockMessage(esp_websocket_event_data_t *event_data);
|
||||||
|
|
||||||
void setBlockHeight(uint newBlockHeight);
|
void setBlockHeight(uint newBlockHeight);
|
||||||
uint getBlockHeight();
|
uint getBlockHeight();
|
||||||
|
@ -45,7 +45,7 @@ void setupPriceNotify()
|
|||||||
{
|
{
|
||||||
// currentPrice = preferences.get("lastPrice", 30000);
|
// currentPrice = preferences.get("lastPrice", 30000);
|
||||||
|
|
||||||
if (preferences.getBool("ownPriceSource", true))
|
if (preferences.getBool("ownDataSource", true))
|
||||||
{
|
{
|
||||||
config = {.uri = wsOwnServerPrice,
|
config = {.uri = wsOwnServerPrice,
|
||||||
.user_agent = USER_AGENT};
|
.user_agent = USER_AGENT};
|
||||||
@ -76,6 +76,10 @@ void onWebsocketPriceEvent(void *handler_args, esp_event_base_t base,
|
|||||||
break;
|
break;
|
||||||
case WEBSOCKET_EVENT_DATA:
|
case WEBSOCKET_EVENT_DATA:
|
||||||
onWebsocketPriceMessage(data);
|
onWebsocketPriceMessage(data);
|
||||||
|
if (preferences.getBool("ownDataSource", true))
|
||||||
|
{
|
||||||
|
onWebsocketBlockMessage(data);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WEBSOCKET_EVENT_ERROR:
|
case WEBSOCKET_EVENT_ERROR:
|
||||||
Serial.println(F("Price WS Connnection error"));
|
Serial.println(F("Price WS Connnection error"));
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <esp_websocket_client.h>
|
#include <esp_websocket_client.h>
|
||||||
|
#include "block_notify.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "lib/screen_handler.hpp"
|
#include "lib/screen_handler.hpp"
|
||||||
|
@ -329,7 +329,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json) {
|
|||||||
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
|
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
|
||||||
"mdnsEnabled", "otaEnabled", "stealFocus",
|
"mdnsEnabled", "otaEnabled", "stealFocus",
|
||||||
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
|
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
|
||||||
"suffixPrice", "disableLeds", "ownPriceSource", "flAlwaysOn"};
|
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn"};
|
||||||
|
|
||||||
for (String setting : boolSettings) {
|
for (String setting : boolSettings) {
|
||||||
if (settings.containsKey(setting)) {
|
if (settings.containsKey(setting)) {
|
||||||
@ -425,7 +425,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request) {
|
|||||||
root["hostname"] = getMyHostname();
|
root["hostname"] = getMyHostname();
|
||||||
root["ip"] = WiFi.localIP();
|
root["ip"] = WiFi.localIP();
|
||||||
root["txPower"] = WiFi.getTxPower();
|
root["txPower"] = WiFi.getTxPower();
|
||||||
root["ownPriceSource"] = preferences.getBool("ownPriceSource", true);
|
root["ownDataSource"] = preferences.getBool("ownDataSource", true);
|
||||||
|
|
||||||
#ifdef HAS_FRONTLIGHT
|
#ifdef HAS_FRONTLIGHT
|
||||||
root["hasFrontlight"] = true;
|
root["hasFrontlight"] = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user