feat: add check if wifi connected
This commit is contained in:
parent
908ca96c39
commit
46d3edef1d
@ -5,6 +5,7 @@
|
|||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <WiFiClientSecureBearSSL.h>
|
#include <WiFiClientSecureBearSSL.h>
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
class DiscordAPI{
|
class DiscordAPI{
|
||||||
public:
|
public:
|
||||||
@ -24,12 +25,12 @@ private:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief http client
|
* @brief http client
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
HTTPClient* httpClient;
|
HTTPClient* httpClient;
|
||||||
|
|
||||||
//WiFiClient* wifiClient;
|
/**
|
||||||
|
* @brief wifi client (for https)
|
||||||
|
*/
|
||||||
BearSSL::WiFiClientSecure* wifiClient;
|
BearSSL::WiFiClientSecure* wifiClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,8 +11,9 @@ DiscordAPI::DiscordAPI(String hookUrl){
|
|||||||
bool DiscordAPI::sendMessage(String message){
|
bool DiscordAPI::sendMessage(String message){
|
||||||
bool sortie = true;
|
bool sortie = true;
|
||||||
|
|
||||||
//TODO: faire test si le wifi est bien connecter
|
if(WiFi.status() != WL_CONNECTED){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
this->httpClient->begin(*this->wifiClient, this->hookUrl);
|
this->httpClient->begin(*this->wifiClient, this->hookUrl);
|
||||||
this->httpClient->addHeader("Content-Type", "application/json");
|
this->httpClient->addHeader("Content-Type", "application/json");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user