Question

I spent a week looking for a convenient answer to my question. I am trying to connect Android to Arduino through Cloud, Where it has 2 operations:

  1. Arduino can trigger a push notification to the android device anywhere.
  2. Android operates Arduino through Cloud.

now the first point is easy to be done, by having a 3rd party server where Arduino POST user credentials (can be configured when the device is bought) with the message to PHP server then the server will get GCM's Registeration ID from MySQL and POST it through cURL to GCM to push notification to the related Android device. or by using Arduino YUN, we can directly send cURL from Arduino itself.

However for the second point where I am stuck, I can't figure out a way to maintain the IP address of the Arduino without actually making the user to enter the IP address of his Internet in the Android application interface.

The solutions I came up so far:

  1. Connect another Android device to Arduino at all the time using ADK then it will become a communication between Android device with another Android device through GCM and the GCM will handle getting the IP addresses of both.
  2. Using MAC address to get to the Arduino but this is insufficient approach because the MAC addresses are hard coded in Arduino, and then spoofing may occurs.

I am not convinced with the proposed solutions so is there a possible way to use GCM or any similar system like Parse in Arduino and make it have a unique registration ID just like android then I can map the user's Android registeration ID with the related Arduino registration ID. or can anybody give me another solution or method I can follow. Thanks in advance.

P.S: I dont want to use static IP address or Port forwarding, the idea of this project is to create a device that is user friendly and doesn't require a lot of configuration from the customer.

Was it helpful?

Solution

Knowing that your Arduino already communicates with a third-party server, you can take advantage of it and additionally get the IP address of the Arduino device making the GCM id registration (in PHP you'd do this by using $_SERVER['REMOTE_ADDR']).

This way you can keep a 1-to-1 identification of a GCM id and a public IP address to know to which Arduino device to send the signal.

This would need that you implement some timeout process (for instance, implement a keepalive system and if a device doesn't send a POST request each X time, just remove it from whithin the connected devices). Also, if the same device connects from two different IP addresses, just keep the last one so you're not mixing up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top