Search code examples
androidnetwork-programmingtcpraspberry-piclient-server

Sending Data from Android Device to a RaspberryPi


I need some help in terms of choosing a design option for my problem.

I currently managed to implement a RaspberryPi acting as a Server and my local machine to act as the client. This client send JSON-Data to the Server which processes these. Everything is working as expected and I am using TCP-Sockets for the communication.

My problem:

The next step of my project will be, that I will use instead of a PC an Android-Device as client. What I want to achieve is, to send data to the server on the go. What I mean by that is, I do not want to restrict the server to be in a special network neither the client. What can be expected, is that server and client are next to each other, like in the range of a bluetooth connection. My question is, is there a relatively simple way to implement this communication? Is TCP a possible solution for this (even working in mobile networks?) or do I need to use Bluetooth, or is the way to go, to create some kind of network the client/server connects to and communicate here?

Sorry for propably stupid questions, but I am new to all this network stuff.

EDIT: Since there were no respones, maybe I can do a more precise question. Is there a proper way to scan a network for a device name? The only way I currently can imagine is to do a bruteforce like check on every IP-Address and resolve the names?


Solution

  • I first tried to let the Pi host an ad-hoc network, but it seems that non-rooted android smartphones do not have the possibility to access ad-hoc networks.

    Therefore I made the Pi acting as an access point.

    The communication now is very simple realized by a tcp server-client system.