AP mode

Dependencies:   NetworkSocketAPI WizFi310Interface mbed

Fork of WizFi310_TCP_Echo_Server_Example by WIZnet

Committer:
maru536
Date:
Mon Oct 02 20:48:08 2017 +0000
Revision:
2:8d119e9b8f5a
AP mode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maru536 2:8d119e9b8f5a 1 #include "push.h"
maru536 2:8d119e9b8f5a 2 #include "TCPSocket.h"
maru536 2:8d119e9b8f5a 3
maru536 2:8d119e9b8f5a 4 bool requestNoti(TCPSocket *socket, char* id, char* buf)
maru536 2:8d119e9b8f5a 5 {
maru536 2:8d119e9b8f5a 6 char body[200] = "";
maru536 2:8d119e9b8f5a 7 int len;
maru536 2:8d119e9b8f5a 8 int pos = 0;
maru536 2:8d119e9b8f5a 9 int bracketCount = 0;
maru536 2:8d119e9b8f5a 10 int isEndContent = false;
maru536 2:8d119e9b8f5a 11 int isStartContent = false;
maru536 2:8d119e9b8f5a 12 printf("\n11\n");
maru536 2:8d119e9b8f5a 13 if (socket->connectSSL("fcm.googleapis.com", 443) == 0) {
maru536 2:8d119e9b8f5a 14 printf("\n12\n");
maru536 2:8d119e9b8f5a 15 strcpy(body, "{\"to\": \"");
maru536 2:8d119e9b8f5a 16 strcat(body, id);
maru536 2:8d119e9b8f5a 17 strcat(body, "\"}\n\n");
maru536 2:8d119e9b8f5a 18 len = strlen(body);
maru536 2:8d119e9b8f5a 19
maru536 2:8d119e9b8f5a 20 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);
maru536 2:8d119e9b8f5a 21
maru536 2:8d119e9b8f5a 22 socket->send(buf, MAX_BUF_SIZE);
maru536 2:8d119e9b8f5a 23 socket->recv(buf, MAX_BUF_SIZE);
maru536 2:8d119e9b8f5a 24
maru536 2:8d119e9b8f5a 25 printf("Request to FCM server\n");
maru536 2:8d119e9b8f5a 26 return true;
maru536 2:8d119e9b8f5a 27 }
maru536 2:8d119e9b8f5a 28 else {
maru536 2:8d119e9b8f5a 29 printf("FCM Connect Fail\n");
maru536 2:8d119e9b8f5a 30 return false;
maru536 2:8d119e9b8f5a 31 }
maru536 2:8d119e9b8f5a 32 }