feat: add check if wifi connected
This commit is contained in:
parent
908ca96c39
commit
46d3edef1d
@ -2,7 +2,7 @@
|
|||||||
#define PROGRAM_H
|
#define PROGRAM_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
#include "DiscordAPI.h"
|
#include "DiscordAPI.h"
|
||||||
|
|
||||||
|
@ -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:
|
||||||
@ -16,7 +17,7 @@ public:
|
|||||||
|
|
||||||
bool sendMessage(String message);
|
bool sendMessage(String message);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief webhook URL
|
* @brief webhook URL
|
||||||
*/
|
*/
|
||||||
@ -24,14 +25,14 @@ private:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief http client
|
* @brief http client
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
HTTPClient* httpClient;
|
HTTPClient* httpClient;
|
||||||
|
|
||||||
//WiFiClient* wifiClient;
|
/**
|
||||||
|
* @brief wifi client (for https)
|
||||||
|
*/
|
||||||
BearSSL::WiFiClientSecure* wifiClient;
|
BearSSL::WiFiClientSecure* wifiClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //DISCORD_API_H
|
#endif //DISCORD_API_H
|
||||||
|
@ -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");
|
||||||
@ -25,4 +26,4 @@ bool DiscordAPI::sendMessage(String message){
|
|||||||
}
|
}
|
||||||
this->httpClient->end();
|
this->httpClient->end();
|
||||||
return sortie;
|
return sortie;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user