feat: discord call api #1
@ -2,7 +2,7 @@
|
||||
#define PROGRAM_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
#include "DiscordAPI.h"
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecureBearSSL.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
class DiscordAPI{
|
||||
public:
|
||||
@ -16,7 +17,7 @@ public:
|
||||
|
||||
bool sendMessage(String message);
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* @brief webhook URL
|
||||
*/
|
||||
@ -24,14 +25,14 @@ private:
|
||||
|
||||
/**
|
||||
* @brief http client
|
||||
*
|
||||
*/
|
||||
HTTPClient* httpClient;
|
||||
|
||||
//WiFiClient* wifiClient;
|
||||
|
||||
/**
|
||||
* @brief wifi client (for https)
|
||||
*/
|
||||
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 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->addHeader("Content-Type", "application/json");
|
||||
@ -25,4 +26,4 @@ bool DiscordAPI::sendMessage(String message){
|
||||
}
|
||||
this->httpClient->end();
|
||||
return sortie;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user