Ви не увійшли.
Сторінки 1
Питання знатакам, в скетчі прописано кілька парсерів, вони однотипні, але парсять по протоколу http, не можу зрозуміть чому https не пропускає... може десь помилка? Підскажіть
// link
void getStat() {
WiFiClientSecure client;
Serial.print("connecting to ");
Serial.println(String(serverFuckrussian));
if (!client.connect(serverFuckrussian, httpsPort)) {
Serial.println("connection failed");
return ;
}
String request_fr = String("GET /api/v2/statistics/") + latest + " HTTP/1.1rn"+
"Host: " + serverFuckrussian + "rnUser-Agent: ESP8266HTTPClient/1.1rnConnection: closernrn";
if (!client.connected()) {
Serial.println("connection lost");
return ;
}
client.print(request_fr);
String response = "";
while (client.connected()) {
String line = client.readStringUntil('n');
if (line == "r") {
break;
}
}
// String input;
DynamicJsonDocument doc(1536);
DeserializationError error = deserializeJson(doc, client);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
//const char* message = doc["message"]; // "The data were fetched successfully."
JsonObject data = doc["data"];
//const char* data_date = data["date"]; // "2023-05-05"
//int data_day = data["day"]; // 436
//const char* data_resource = data["resource"];
int data_war_status_code = data["war_status"]["code"]; // 1
const char* data_war_status_alias = data["war_status"]["alias"]; // "in_progress"
JsonObject data_stats = data["stats"];
long data_stats_personnel_units = data_stats["personnel_units"]; // 193210
//int data_stats_tanks = data_stats["tanks"]; // 3710
// int data_stats_armoured_fighting_vehicles = data_stats["armoured_fighting_vehicles"]; // 7224
// int data_stats_artillery_systems = data_stats["artillery_systems"]; // 2978
// int data_stats_mlrs = data_stats["mlrs"]; // 550
// int data_stats_aa_warfare_systems = data_stats["aa_warfare_systems"]; // 304
// int data_stats_planes = data_stats["planes"]; // 308
// int data_stats_helicopters = data_stats["helicopters"]; // 294
// int data_stats_vehicles_fuel_tanks = data_stats["vehicles_fuel_tanks"]; // 5916
// int data_stats_warships_cutters = data_stats["warships_cutters"]; // 18
// int data_stats_cruise_missiles = data_stats["cruise_missiles"]; // 947
// int data_stats_uav_systems = data_stats["uav_systems"]; // 2540
// int data_stats_special_military_equip = data_stats["special_military_equip"]; // 373
// int data_stats_atgm_srbm_systems = data_stats["atgm_srbm_systems"]; // 4
JsonObject data_increase = data["increase"];
int data_increase_personnel_units = data_increase["personnel_units"]; // 620
// int data_increase_tanks = data_increase["tanks"]; // 3
// int data_increase_armoured_fighting_vehicles = data_increase["armoured_fighting_vehicles"]; // 8
// int data_increase_artillery_systems = data_increase["artillery_systems"]; // 16
// int data_increase_mlrs = data_increase["mlrs"]; // 3
// int data_increase_aa_warfare_systems = data_increase["aa_warfare_systems"]; // 0
// int data_increase_planes = data_increase["planes"]; // 0
// int data_increase_helicopters = data_increase["helicopters"]; // 0
// int data_increase_vehicles_fuel_tanks = data_increase["vehicles_fuel_tanks"]; // 30
// int data_increase_warships_cutters = data_increase["warships_cutters"]; // 0
// int data_increase_cruise_missiles = data_increase["cruise_missiles"]; // 0
// int data_increase_uav_systems = data_increase["uav_systems"]; // 17
// int data_increase_special_military_equip = data_increase["special_military_equip"]; // 3
// int data_increase_atgm_srbm_systems = data_increase["atgm_srbm_systems"]; // 0
stat = String("fr " + String(data_stats_personnel_units) + "(+" + String(data_increase_personnel_units + ")"));
Serial.print("Personnel Units: ");
Serial.println(stat);
client.stop();
}
Неактивний
Дякую, зараз розбираюсь.
Додав сертифікат, але чомусь пише що в класі немає такої ф-ції
/Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino: In function 'void getYoutube()':
/Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino:280:15: error: 'class BearSSL::WiFiClientSecure' has no member named 'setCACert'
280 | httpsClient.setCACert(root_ca_cert);
| ^~~~~~~~~
/Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino: In function 'void getStat()':
/Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino:346:15: error: 'class BearSSL::WiFiClientSecure' has no member named 'setCACert'
346 | httpsClient.setCACert(root_ca_cert);
| ^~~~~~~~~
exit status 1
Compilation error: 'class BearSSL::WiFiClientSecure' has no member named 'setCACert'
В мене паралельно на python написаний проект з парсером цьогод сайту, наскільки все просто.
С++ Arduino бібліотеки, омг ну дуже складно все
Остання редакція c_rax (2023-05-07 10:20:37)
Неактивний
Повинно працювати, згідно документації, але нажаль маю цю помилку..
void getStat() {
//WiFiClientSecure httpsClient;
httpsClient.setCACert(root_ca_cert);
//httpsClient.setInsecure();
Serial.print("connecting to ");
Serial.println(serverFuckrussian);
if (!httpsClient.connect(serverFuckrussian, httpsPort)) {
Serial.println("connection failed");
return ;
}
String request = String("GET /api/v2/statistics/") + latest + " HTTP/1.1rn"+
"Host: " + serverFuckrussian + "rnUser-Agent: ESP8266HTTPClient/1.1rnConnection: closernrn";
if (!httpsClient.connected()) {
Serial.println("connection lost");
return ;
}
httpsClient.print(request);
String response = "";
while (httpsClient.connected()) {
String line = httpsClient.readStringUntil('n');
if (line == "r") {
break;
}
}
DynamicJsonDocument doc(1536);
DeserializationError error = deserializeJson(doc, httpsClient);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
//const char* message = doc["message"]; // "The data were fetched successfully."
JsonObject data = doc["data"];
//const char* data_date = data["date"]; // "2023-05-05"
//int data_day = data["day"]; // 436
//const char* data_resource = data["resource"];
int data_war_status_code = data["war_status"]["code"]; // 1
const char* data_war_status_alias = data["war_status"]["alias"]; // "in_progress"
JsonObject data_stats = data["stats"];
long data_stats_personnel_units = data_stats["personnel_units"]; // 193210
//int data_stats_tanks = data_stats["tanks"]; // 3710
// int data_stats_armoured_fighting_vehicles = data_stats["armoured_fighting_vehicles"]; // 7224
// int data_stats_artillery_systems = data_stats["artillery_systems"]; // 2978
// int data_stats_mlrs = data_stats["mlrs"]; // 550
// int data_stats_aa_warfare_systems = data_stats["aa_warfare_systems"]; // 304
// int data_stats_planes = data_stats["planes"]; // 308
// int data_stats_helicopters = data_stats["helicopters"]; // 294
// int data_stats_vehicles_fuel_tanks = data_stats["vehicles_fuel_tanks"]; // 5916
// int data_stats_warships_cutters = data_stats["warships_cutters"]; // 18
// int data_stats_cruise_missiles = data_stats["cruise_missiles"]; // 947
// int data_stats_uav_systems = data_stats["uav_systems"]; // 2540
// int data_stats_special_military_equip = data_stats["special_military_equip"]; // 373
// int data_stats_atgm_srbm_systems = data_stats["atgm_srbm_systems"]; // 4
JsonObject data_increase = data["increase"];
int data_increase_personnel_units = data_increase["personnel_units"]; // 620
// int data_increase_tanks = data_increase["tanks"]; // 3
// int data_increase_armoured_fighting_vehicles = data_increase["armoured_fighting_vehicles"]; // 8
// int data_increase_artillery_systems = data_increase["artillery_systems"]; // 16
// int data_increase_mlrs = data_increase["mlrs"]; // 3
// int data_increase_aa_warfare_systems = data_increase["aa_warfare_systems"]; // 0
// int data_increase_planes = data_increase["planes"]; // 0
// int data_increase_helicopters = data_increase["helicopters"]; // 0
// int data_increase_vehicles_fuel_tanks = data_increase["vehicles_fuel_tanks"]; // 30
// int data_increase_warships_cutters = data_increase["warships_cutters"]; // 0
// int data_increase_cruise_missiles = data_increase["cruise_missiles"]; // 0
// int data_increase_uav_systems = data_increase["uav_systems"]; // 17
// int data_increase_special_military_equip = data_increase["special_military_equip"]; // 3
// int data_increase_atgm_srbm_systems = data_increase["atgm_srbm_systems"]; // 0
string_stat = String("fr " + String(data_stats_personnel_units) + "(+" + String(data_increase_personnel_units + ")"));
Serial.print("Personnel Units: ");
Serial.println(string_stat);
httpsClient.stop();
}
Дякую, зараз розбираюсь.
Додав сертифікат, але чомусь пише що в класі немає такої ф-ції/Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino: In function 'void getYoutube()': /Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino:280:15: error: 'class BearSSL::WiFiClientSecure' has no member named 'setCACert' 280 | httpsClient.setCACert(root_ca_cert); | ^~~~~~~~~ /Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino: In function 'void getStat()': /Users/******/Documents/Arduino/clock_fuckr/clock_fuckr.ino:346:15: error: 'class BearSSL::WiFiClientSecure' has no member named 'setCACert' 346 | httpsClient.setCACert(root_ca_cert); | ^~~~~~~~~ exit status 1 Compilation error: 'class BearSSL::WiFiClientSecure' has no member named 'setCACert'
В мене паралельно на python написаний проект з парсером цьогод сайту, наскільки все просто.
С++ Arduino бібліотеки, омг ну дуже складно все
Неактивний
Сторінки 1