2

I'll try to keep this as straightforward as possible. This project involves a Raspberry Pi 3, and an Android device.

The Pi

  • Setup as a wireless access point (WiFi) which will have NO internet access (placed in a remote location that the Android device can still connect to).
  • A GPS module is connected, and the data is parsed into a text file under a folder named data. This will contain all coordinates, speed, etc.

Android Device

  • Acts as the "middleman". Will recieve data from the Pi (the textfiles containing GPS information).

  • Will have the sshelper app to allow rSync commands if needed.

  • Unrelated, but the Android device will send the data gathered from the Pi to a server once internet access or cellular data is available.

With the roles of each component out of the way, the plan is to use rsync via SSH to synchronize the data from the raspberry pi and the android device, and send data whenever the android device is connected to the Pi's access point.

How can this be done? I know SSH allows sending data, and we've tested this, however we need to automate this task, therefore would it be possible to use cron and rsync to do this from the Pi? If so, how should we go about this?

I've seen a lot of examples in regards to backing up data from the Android device to the Pi, but not the other way around. Any help would be greatly appreciated.

Thank you!

2

SSHelper is an SSH server for Android, so I would simply set up a cron job on the Pi to run an rsync - making the ssh connetion to SSHelper can all be handled by the rsync command line option

rsync -avz -e "ssh -p 2222" /path/to/files/on/pi/  user@androiddevice.local:/path/to/target/on/android/

Note: The "ssh -p 2222" sets the SSH port to be used to 2222, rather than the standard 22 - SSHelper uses this port if there is no root access. But you may have to change it for your own needs.

Also Note: The androiddevice.local will need changing to whatever you set the device name to. Make sure you keep the .local as SSHelper advertises itself via Avahi/Bonjour, so no need for IP addresses, just use the device.local name.

Also, Also Note: There are a number of rsync specific recommendations for SSHelper on this page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.