add pool data api discovery
This commit is contained in:
parent
8f1426ac1d
commit
ac6cd6a3f0
@ -32,6 +32,8 @@ unsigned int bitcoin_price=0;
|
|||||||
String current_block = "793261";
|
String current_block = "793261";
|
||||||
global_data gData;
|
global_data gData;
|
||||||
pool_data pData;
|
pool_data pData;
|
||||||
|
String poolAPIUrl;
|
||||||
|
|
||||||
|
|
||||||
void setup_monitor(void){
|
void setup_monitor(void){
|
||||||
/******** TIME ZONE SETTING *****/
|
/******** TIME ZONE SETTING *****/
|
||||||
@ -43,6 +45,10 @@ void setup_monitor(void){
|
|||||||
timeClient.setTimeOffset(3600 * Settings.Timezone);
|
timeClient.setTimeOffset(3600 * Settings.Timezone);
|
||||||
|
|
||||||
Serial.println("TimeClient setup done");
|
Serial.println("TimeClient setup done");
|
||||||
|
#ifdef NERDMINER_T_HMI
|
||||||
|
poolAPIUrl = getPoolAPIUrl();
|
||||||
|
Serial.println("poolAPIUrl: " + poolAPIUrl);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long mGlobalUpdate =0;
|
unsigned long mGlobalUpdate =0;
|
||||||
@ -317,6 +323,36 @@ coin_data getCoinData(unsigned long mElapsed)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getPoolAPIUrl(void) {
|
||||||
|
poolAPIUrl = String(getPublicPool);
|
||||||
|
if (Settings.PoolAddress == "public-pool.io") {
|
||||||
|
poolAPIUrl = "https://public-pool.io:40557/api/client/";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (Settings.PoolAddress == "nerdminers.org") {
|
||||||
|
poolAPIUrl = "https://pool.nerdminers.org/users/";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (Settings.PoolPort) {
|
||||||
|
case 3333:
|
||||||
|
if (Settings.PoolAddress == "pool.vkbit.com")
|
||||||
|
poolAPIUrl = "https://vkbit.com/miner/";
|
||||||
|
else if (Settings.PoolAddress == "pool.sethforprivacy.com")
|
||||||
|
poolAPIUrl = "https://pool.sethforprivacy.com/api/client/";
|
||||||
|
// Add more cases for other addresses with port 3333 if needed
|
||||||
|
break;
|
||||||
|
case 2018:
|
||||||
|
poolAPIUrl = "http://" + Settings.PoolAddress + ":2019/api/client/";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
poolAPIUrl = String(getPublicPool);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return poolAPIUrl;
|
||||||
|
}
|
||||||
|
|
||||||
pool_data getPoolData(void){
|
pool_data getPoolData(void){
|
||||||
//pool_data pData;
|
//pool_data pData;
|
||||||
if((mPoolUpdate == 0) || (millis() - mPoolUpdate > UPDATE_POOL_min * 60 * 1000)){
|
if((mPoolUpdate == 0) || (millis() - mPoolUpdate > UPDATE_POOL_min * 60 * 1000)){
|
||||||
@ -329,7 +365,12 @@ pool_data getPoolData(void){
|
|||||||
String btcWallet = Settings.BtcWallet;
|
String btcWallet = Settings.BtcWallet;
|
||||||
Serial.println(btcWallet);
|
Serial.println(btcWallet);
|
||||||
if (btcWallet.indexOf(".")>0) btcWallet = btcWallet.substring(0,btcWallet.indexOf("."));
|
if (btcWallet.indexOf(".")>0) btcWallet = btcWallet.substring(0,btcWallet.indexOf("."));
|
||||||
|
#ifdef NERDMINER_T_HMI
|
||||||
|
Serial.println("Pool API : " + poolAPIUrl+btcWallet);
|
||||||
|
http.begin(poolAPIUrl+btcWallet);
|
||||||
|
#else
|
||||||
http.begin(String(getPublicPool)+btcWallet);
|
http.begin(String(getPublicPool)+btcWallet);
|
||||||
|
#endif
|
||||||
int httpCode = http.GET();
|
int httpCode = http.GET();
|
||||||
if (httpCode == HTTP_CODE_OK) {
|
if (httpCode == HTTP_CODE_OK) {
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
|
@ -127,6 +127,6 @@ coin_data getCoinData(unsigned long mElapsed);
|
|||||||
pool_data getPoolData(void);
|
pool_data getPoolData(void);
|
||||||
|
|
||||||
clock_data_t getClockData_t(unsigned long mElapsed);
|
clock_data_t getClockData_t(unsigned long mElapsed);
|
||||||
|
String getPoolAPIUrl(void);
|
||||||
|
|
||||||
#endif //MONITOR_API_H
|
#endif //MONITOR_API_H
|
||||||
|
Loading…
Reference in New Issue
Block a user