Direct Wifi Communication between android smartpho

2019-03-22 06:18发布

问题:

I want to establish a communication (via WIFI) between an Android device and another device (which is not another android smartphone but a device with wifi implemented using c++). I already found out that android provides direct wifi in order to communicate directly over wifi with two android devices.

How can I communicate over wifi (without a network) with an android device and another c++ device? Especially, I want my app to discover any device which is in the near. So I have to implement some kind of service discovery. What do you guys recommend to implement this?

回答1:

In order for this to work, you must have the computer'shardware properly configured and your software must be written to communicate with this hardware.

In the following guide, they suggest communicating with the hardware via the iwpriv application which handles the p2p information received directly from the Wifi adapter's driver. If you choose to do this, you will need to learn how iwpriv works and can interact with your application.

guide: http://dishingtech.blogspot.com/2012/01/realtek-wi-fi-direct-programming-guide.html

In order to get Wifi Direct working on an Android tablet, I suggest following the Wifi Direct sample which is available in /samples/android-/. This sample allows you to connect direct to other Wifi Direct devices and transfer an image. You can slightly alter this application for your needs, or completely rewrite it if your needs deviate too far from the sample.

accompanying guide (for Android) : http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html

NOTE: you will still need to have a wifi network in order for these devices to communicate



标签: android c++ wifi