diff --git a/src/TelegramBot.cpp b/src/TelegramBot.cpp index c00846d..06c3931 100755 --- a/src/TelegramBot.cpp +++ b/src/TelegramBot.cpp @@ -7,15 +7,21 @@ #include "TelegramBot.h" -TelegramBot::TelegramBot(const char* token, Client &client) { +TelegramBot::TelegramBot(const char* token, WiFiClientSecure &client) { this->client = &client; this->token=token; } - -void TelegramBot::begin() { +void TelegramBot::begin() { if(!client->connected()){ - client->connect(HOST, SSL_PORT); + client->setInsecure(); + + if(!client->connect(HOST, SSL_PORT)){ + Serial.println("Connection failed."); + } + else{ + Serial.println("Connected"); + } } } @@ -39,8 +45,6 @@ message TelegramBot::getUpdates() { StaticJsonBuffer jsonBuffer; JsonObject & root = jsonBuffer.parseObject(payload); - - if(root.success()){ int update_id = root["result"][0]["update_id"]; diff --git a/src/TelegramBot.h b/src/TelegramBot.h index 1f56cf9..8397403 100755 --- a/src/TelegramBot.h +++ b/src/TelegramBot.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #define HOST "api.telegram.org" @@ -33,7 +33,7 @@ struct message{ class TelegramBot { public: - TelegramBot(const char* token, Client &client); + TelegramBot(const char* token, WiFiClientSecure &client); void begin(); String sendMessage(String chat_id, String text); String sendMessage(String chat_id, String text, TelegramKeyboard &keyboard_markup, bool one_time_keyboard = true, bool resize_keyboard = true); @@ -45,7 +45,7 @@ class TelegramBot const char* token; int last_message_recived; - Client *client; + WiFiClientSecure *client; }; #endif diff --git a/src/TelegramKeyboard.h b/src/TelegramKeyboard.h index 34e7dbc..fac1f92 100755 --- a/src/TelegramKeyboard.h +++ b/src/TelegramKeyboard.h @@ -4,7 +4,6 @@ // TelegramBot library // https://github.com/CasaJasmina/TelegramBot-Library - #ifndef TelegramKeyboard_h #define TelegramKeyboard_h #include