![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
AP mode
Dependencies: NetworkSocketAPI WizFi310Interface mbed
Fork of WizFi310_TCP_Echo_Server_Example by
Diff: push.cpp
- Revision:
- 2:8d119e9b8f5a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/push.cpp Mon Oct 02 20:48:08 2017 +0000 @@ -0,0 +1,32 @@ +#include "push.h" +#include "TCPSocket.h" + +bool requestNoti(TCPSocket *socket, char* id, char* buf) +{ + char body[200] = ""; + int len; + int pos = 0; + int bracketCount = 0; + int isEndContent = false; + int isStartContent = false; + printf("\n11\n"); + if (socket->connectSSL("fcm.googleapis.com", 443) == 0) { + printf("\n12\n"); + strcpy(body, "{\"to\": \""); + strcat(body, id); + strcat(body, "\"}\n\n"); + len = strlen(body); + + sprintf(buf, "POST /fcm/send HTTP/1.1\nHost: fcm.googleapis.com\nContent-Type: application/json\nAuthorization: key=AAAA5sg2OQw:APA91bE_cHSew6Je4CcAcFbGq__QmpsXt_jyYMoUQt9vhgMDarqWlE2wopdp3TCSz_FD9mvg_Kjvf_82zcEn9hJ20mNx-FVlNAgc9NND29U9DNGSyBJmmeqfA5gDw-dkpKy2Vt10b_xd\nContent-Length: %d\n\n%s", len, body); + + socket->send(buf, MAX_BUF_SIZE); + socket->recv(buf, MAX_BUF_SIZE); + + printf("Request to FCM server\n"); + return true; + } + else { + printf("FCM Connect Fail\n"); + return false; + } +}