Windows - Android direct connection
-
wrote on 9 Oct 2018, 15:03 last edited by aha_1980 10 Sept 2018, 18:45
I was wondering if there is a way to connect and exchange data between a windows Qt app and several Android devices in the same room (Wifi, Direct Wifi, maybe Bluetooth ...). The windows Qt app will play the server role and the devices will be the clients.
I am currently exchanging data through a server (Firebase) but all the devices will be in the same room so I was wondering if there is a simpler and cheapest solution.
Any hint?
-
I was wondering if there is a way to connect and exchange data between a windows Qt app and several Android devices in the same room (Wifi, Direct Wifi, maybe Bluetooth ...). The windows Qt app will play the server role and the devices will be the clients.
I am currently exchanging data through a server (Firebase) but all the devices will be in the same room so I was wondering if there is a simpler and cheapest solution.
Any hint?
wrote on 9 Oct 2018, 16:24 last edited byHi and welcome to devnet forum
With Wifi you can as soon as their IP addresses on an internal network are known you can do. You can simply establish a QTcpServer - QTcpSocket setup and exchange data as you would do with any TCP connection.
The same seem to be possible when looking at the different options for QBlueTooth. Looks like at least a similar procedure as with TCP/IP. However, I have not done that yet.
About direct Wifi I have no experience.
-
wrote on 10 Oct 2018, 00:36 last edited by
Hi, thank you for your reply. I tried to use TCP as it is probably the better option for me.
I am able to run a Tcp Server in Qt following the Fortune Sample in the doc. I also built an Android Tcp Client which is supposed to send messages to my c++ server.
Well, it doesn't work, I've got to be missing something... I'm taking the IP address Ipv4 from the LAN WiFi connection with both my computer and my Android device connected to the same WiFi. Any response. I already tried like 3 custom classes that I found on the web which worked for other people.
Did you ever achieve what I'm trying to do? Can you show me a working example? I'm developing my Android app in Android Studio.
Thanks in advance -
Hi, thank you for your reply. I tried to use TCP as it is probably the better option for me.
I am able to run a Tcp Server in Qt following the Fortune Sample in the doc. I also built an Android Tcp Client which is supposed to send messages to my c++ server.
Well, it doesn't work, I've got to be missing something... I'm taking the IP address Ipv4 from the LAN WiFi connection with both my computer and my Android device connected to the same WiFi. Any response. I already tried like 3 custom classes that I found on the web which worked for other people.
Did you ever achieve what I'm trying to do? Can you show me a working example? I'm developing my Android app in Android Studio.
Thanks in advancewrote on 10 Oct 2018, 07:23 last edited by@Tabanito said in Windows - Android direct connection:
Hi, thank you for your reply. I tried to use TCP as it is probably the better option for me.
I am able to run a Tcp Server in Qt following the Fortune Sample in the doc. I also built an Android Tcp Client which is supposed to send messages to my c++ server.Do you use the fortune example as well?
Well, it doesn't work, I've got to be missing something... I'm taking the IP address Ipv4 from the LAN WiFi connection with both my computer and my Android device connected to the same WiFi. Any response. I already tried like 3 custom classes that I found on the web which worked for other people.
The option with Wifi in an internal network is probably the easiest form. First I would try toget it to work with two Windows sides working. If you have only one Windows PC, you can run both in the same machine. Certainly better to have two independent Windows PCs. I am simply using IPv4 addresses (e.g. 192.168.x.x). With a smartphone you might have the problem that for whatever reason the connection may go through the phone network, which gives you an outside connection. Besides typical AV-interferences I do not see major obstacles.
Did you ever achieve what I'm trying to do? Can you show me a working example? I'm developing my Android app in Android Studio.
Does that mean that you are not using Qt on Android?
In principle that should work as well. However, I am using Qt on Windows and Android for getting the connection. Therefore also my question above about using the Fortune Client on Android. -
wrote on 10 Oct 2018, 20:38 last edited by
Hi, thanks for your reply (again). I detected my problem. After hours (maybe days) of debugging, I found out that the problem is my Windows Firewall. It is blocking my port. I want my server to disable the Firewall just for my app or my port. How can I achieve that?
-
Hi, thanks for your reply (again). I detected my problem. After hours (maybe days) of debugging, I found out that the problem is my Windows Firewall. It is blocking my port. I want my server to disable the Firewall just for my app or my port. How can I achieve that?
@Tabanito Your server should not try to manipulate the firewall. For that you need administrator privileges for a good reason. So, do it on OS level.
-
wrote on 11 Oct 2018, 06:14 last edited by
How can I prompt the user to disable the Firewall then? It should be an easy way
-
wrote on 11 Oct 2018, 08:32 last edited by
Probably the best is to have a note during installation or when you start up the application, in case you want to be thorough. The firewall is prevent attacks from outside in your case. Therefore you need to do it on OS level as recommended by @jsulm
However, it is also not possible to knowabout outside attacks and their blockage.
1/8