ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER

User avatar
beegee1962
Posts: 11
Joined: Fri Jan 08, 2016 11:11 am
Location: Manila, Philippines
Contact:

ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER

Postby beegee1962 » Mon Feb 01, 2016 5:33 pm

I was looking into a solution to send push notifications from an ESP8266 module to an Android application. I know that this is possible with the Google Cloud Messaging service.

But what I found on the internet is using an external webserver, able to run PHP (or Python) scripts and using a MySQL server to store registration IDs.
ImageImage
So far so good, but why do I need to setup an external server with MySQL and PHP just to send messages to the Android devices. The ESP8266 has server capabilities build-in and has enough storage to save registration IDs in the Flash memory.
What I wanted is:
ImageImage

As I could not find any tutorial or example on the Internet how to achieve this, I started to write the code by myself.
And here is the result:
ESP8266 - Google Cloud Messaging without external server
Of course the code is open source and stored in my Github repository

Hope it helps someone.

wuyunzhou
Posts: 12
Joined: Fri Apr 10, 2015 3:46 pm

Re: ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER

Postby wuyunzhou » Tue Feb 02, 2016 5:17 pm

good job.
yes, if the device can get the gcm api_key, and the android registration id, the device can notify without server.

so the first is to pass the android registration id from app to device,
then make a http request to Gcm server, like this:

POST /gcm/send HTTP/1.1
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: gcm-http.googleapis.com
Accept: */*
Authorization: key=${api_key}
Content-Type: application/json
Content-Length: xx

{"registration_ids":%s,"priority":"%s","time_to_live":%s,"data":%s}

registration_ids is a array with android registration ids.

User avatar
beegee1962
Posts: 11
Joined: Fri Jan 08, 2016 11:11 am
Location: Manila, Philippines
Contact:

Re: ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER

Postby beegee1962 » Tue Feb 02, 2016 8:26 pm

wuyunzhou,
Correct, that is how it works. However I didn't use the "priority" and "time_to_live' keys.

JamesRit
Posts: 2
Joined: Fri May 12, 2017 12:03 am
Location: Latvia
Contact:

ESP8266 GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER

Postby JamesRit » Mon May 22, 2017 4:09 pm

Hi. copying the form of the sample in my test project, allways get the error google is not defined. I can run the sample avobe with no problem, but with my test project, allways the same error. I dont konw why. Thanks.

Tofd8lger
Posts: 2
Joined: Sat May 20, 2017 5:36 am

View first unread post

Postby Tofd8lger » Sun Nov 10, 2019 2:28 pm

I searched for fw20 and did not see anything that I was allowed to see, only one thing in the sale section or somthing which you need a post to view, so tada. Anyway, I have a fw20 deck and when you hit play on either side it usually spins but the left side of the tape just keeps getting eaten up, like maybe only on of the reels is spinning. anyone know how to fix this?


<a href=https://prom-electric.ru/>.</a>

Who is online

Users browsing this forum: No registered users and 3 guests