Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED]How can i find and communicate with android phones in a local network
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]How can i find and communicate with android phones in a local network

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 3 Posters 8.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QPerson
    wrote on last edited by
    #1

    I need to search for and find my phone in my local network and then communicate with it. so how should i go about doing it. I think i should be using TCP to transfer the data to the phone, but how do i find the phone in the first place.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      daliusd
      wrote on last edited by
      #2

      Technically that would be security hole in smartphone OS if you could find phones in local network (be it home, work or public network). As network owner you could find connected devices but that requires some extra software in your router (e.g. OpenWRT based router could expose connected devices) - still you will have extra problem identifying if device is phone or something different.

      Basically phone must somehow expose itself and be active here. One option is bluetooth - I'm not sure however if you can hook into bluetooth listener. Usually phones keep bluetooth in hidden mode and you will not find them. One correct solution is NFC: that's what NFC was basically created for. You use it to initiate communication between two devices (by touching them) so they can exchange information using Bluetooth (e.g. Nokia and BB10 successfully can exchange photos using NFC or you can use two NFC enabled phones to initiate gaming using two devices in some games, Angry Birds Magic one example).

      Another solution is to have server. Phone could send to server its local IP address. Server will see phone's external address. If external IP address masked using 255.255.255.0 and local address masked 255.255.0.0 matches you can assume that two devices are in the same network. That's not very safe assumption but I guess in 90% cases that would work. After that you can make one phone run server (e.g. using sockets or HTTP library) and other client. While if you have external server I doubt you need another local server.

      That's just some ideas but none of them are Qt specific.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QPerson
        wrote on last edited by
        #3

        sorry but i should have been more clear. both the pc and the phone are in the same local network and both have qt apps on it. now i need these two apps to communicate with each other, but the problem is how do i find out the ip address of the other device.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          daliusd
          wrote on last edited by
          #4

          One option is (UDP) broadcast.

          Another option: if you have PC and phone. Make PC server, show PC IP address in app, run server on PC and connect to it from phone. Actually you can even use HTTP what would be much easier in this case (IMHO).

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QPerson
            wrote on last edited by
            #5

            I will try the broadcast option. it's better than asking the user to type in ip addresses

            1 Reply Last reply
            0
            • D Offline
              D Offline
              daliusd
              wrote on last edited by
              #6

              I personally would recommend looking into multicast as well. IPv6 supports multicast only and there are some good reasons why IPv6 will finally become more popular.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                mdns/bonjour/rondezvous might also be an option for device discovery. If that is available on android that is.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  daliusd
                  wrote on last edited by
                  #8

                  Tobias, good point. Your advice pointed to: http://developer.android.com/training/connect-devices-wirelessly/nsd.html

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved