Skip to content

Commit

Permalink
Add support FCM
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed May 4, 2019
1 parent 930f032 commit 01fa33e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/FirebaseESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3215,7 +3215,7 @@ bool FirebaseESP8266::sendFCMMessage(FirebaseData &dataObj, uint8_t messageType)
if (dataObj._http.http_connected())
forceEndHTTP(dataObj);

res = dataObj.fcm.fcm_connect(dataObj._http, _host, _port);
res = dataObj.fcm.fcm_connect(dataObj._http);

if (!res)
{
Expand Down Expand Up @@ -4623,9 +4623,14 @@ String FCMObject::getSendResult()
return _sendResult.c_str();
}

bool FCMObject::fcm_connect(FirebaseHTTPClient &netClient, const std::string &host, uint16_t port)
bool FCMObject::fcm_connect(FirebaseHTTPClient &netClient)
{
int httpConnected = netClient.http_begin(ESP8266_FIREBASE_STR_120, port);
char *host = new char[100];
memset(host, 0, 100);
strcpy_P(host, ESP8266_FIREBASE_STR_120);
int httpConnected = netClient.http_begin(host, _port);

delete[] host;

if (!httpConnected)
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/FirebaseESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class FCMObject
friend FirebaseData;

private:
bool fcm_connect(FirebaseHTTPClient &netClient, const std::string &host, uint16_t port);
bool fcm_connect(FirebaseHTTPClient &netClient);

bool fcm_send(FirebaseHTTPClient &netClient, int &httpcode, uint8_t messageType);

Expand All @@ -391,6 +391,7 @@ class FCMObject
std::string _sendResult = "";
int _ttl = -1;
uint16_t _index = 0;
uint16_t _port = 443;
std::vector<std::string> _deviceToken;
};

Expand Down

0 comments on commit 01fa33e

Please sign in to comment.