NOTE: GCM is being deprecated by Google before 4/11/2019. Use the secure DscKeypad or Drive remote access type rather than GCM.
This section describes how to use the DscServer with the DscClient over Google Cloud Messaging (GCM).
What is GCM and why would I want it?
Google Cloud Messaging (or GCM) is a service google provides to allow servers to connect with client android devices. Normally this would be for application developers to connect with their apps running on your phone - send ads, alerts, (hack them!) etc.
If you're using the DscServer you're already running your own server. You can sign up to GCM for free (you don't need to sign up for the free trial they offer, that's for servers hosted on the google cloud) and enable the DscServer to connect to your phone using a google cloud service instance that you own and control yourself. No danger of outside access.
Using GCM eliminates the need to configure your router and to use a DDNS service when using the DscClient. Your phone and the DscServer will find each other using your GCM service project number.
GCM is bi-directional, meaning the DscServer can update your phone the DSC status and alarms, and allow you to access your service remotely.
Can I share GCM services with multiple servers?
No, only one server can use a GCM project at one time. They're free, so set up one per server you want to enable.
I'm having problems getting the client to connect, what should I do?
First, confirm that the DSC connection indicator and the GCM indicator on the server widget is green. If it's yellow or gray the server is not connected to the DSC or the GCM service.
You should find the error in the server logs.
For the DSC panel use the troubleshooting instructions on the HowTo page.
For GCM its typically an authorization problem so double check that you've got the correct GCM project number and authorization code (try to use copy/paste rather than typing). Once that's sorted move onto the next steps below.
My GCM client seems to take a while to connect and frequently times out. What gives?
It seems that it may take Google a while to propagate your GCM project throughout it's cloud. if you're sure the server side is properly connected to GCM, double check the project number on your client. Keep trying to connect for a day or two once you get your client registered to see if the connection settles down. You may see some instability when you travel to new locations, but eventually you should find it reasonably fast and very reliable.
What happens when my GCM client loses it's connection?
If the connection is dropped the clients will keep trying to reconnect. When they get through they'll request the latest status from the server to catch up. Alarms and other important asynchronous events are sent to GCM directly by the server without waiting for or needing the clients to connect (if the client is registered and has connected at least once). The events will be delivered as soon as Google sees each client back online. If a client is unregistered it will be dropped from the server's asynchronous notification list.
Ok, how do I set it up?
You first create a Project using your Google account:
For reference or more information: http://developer.android.com/google/gcm/gs.html
How do I connect to the DscServer using the DscClient?
I did all that and now I'm seeing "GCM Connect to <my project number (or not)> failed SASLError using PLAIN: not-authorized" on the server.
This is usually an authentication failure - double check that your GCM project number, server authorization code, and the allowed IP ranges are all correct. If you can login to the GCM developer console from your server device or email there it's easiest to copy/paste rather than trying to type them... I usually leave the IP range (in the developers console) blank unless I'm certain my external (routers) IP address won't change.
What does "GCM ack'd" mean?
It means that Google accepted the message from the client by acknowledging it. GCM will try to deliver it to the server, but the ack does not confirm delivery. if the message is not ack'd it means that the device is not properly connected to GCM - probably a communication issue.
I'm trying to register the client but there are a lot of retries and it doesn't seem to be working.
First confirm that the Server is properly connected to GCM.
On the android version, the indicator beside the GCM project should be green.
On the DscServer java version the message at the bottom for the GCMServer will say “authenticated” or “reconnected”.
If it didn't authenticate, double check the project numbers and the authorization key. The authorization key type has to be “Server”, and it’s usually best to allow IP range 0.0.0.0/24 until you’ve got it running. You can change it later if you know your server IP/range will never change.
Once the server is connected to GCM, double check the project number used in the Client.
If you're sure everything is correct give it a try again every few hours, sometimes it takes a while before the project is properly running through google. Eventually it will succeed.