WiFi Direct for multiple devices

2020-03-25 07:21发布

I am trying to establish file transfer (between 3 devices) through Wifi Direct from the tutorial given in

http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html

This has explained how to manage connections between 2 devices. After going through some posts on stackoverflow, this post - WiFi Direct (Android 4.0) with multiple (3+) devices has explained how to connect 3 devices in a manner where A->B and C->B, where I've considered B as my Group Owner. I wanted to know if there is any way in which I can transfer a file in a manner where B->A and B->C simultaneously.

Thanks for all your help! :)

1条回答
相关推荐>>
2楼-- · 2020-03-25 07:27

Since B is the group owner(GO) and A and C are clients, B can get clients' address by the callback function of WifiP2pManager.requestGroupInfo() .

Request group info after connected like this.

mWifiP2pManager.requestGroupInfo(mChannel,new WifiP2pManager.GroupInfoListener() {
        @Override
        public void onGroupInfoAvailable(WifiP2pGroup wifiP2pGroup) {
            Collection<WifiP2pDevice> peerList = wifiP2pGroup.getClientList();
            ArrayList<WifiP2pDevice> list = new ArrayList<WifiP2pDevice>(peerList);
            String host;
            for (int i = 1; i < list.size(); i++) {
                host = list.get(i).deviceAddress;
                /** transferFile here **/
            }
        }
    });
查看更多
登录 后发表回答