This WiFiP2P demonstrates the usage of Android WiFi Direct in Xamarin Forms framework.
How it is working?
- Publish project into your android devices, you need at least two devices to see result
- From one of android device, Device A, click 'Find TEAMLEAD', it will list other android devices including your other device, Device B, if B does not show up in A, go to your B setting->Find WiFi direct, then B will show up in A.
- Click device name from A (we choose B name), then B will pop up confirm connection which is done by android OS, you click 'OK'
- From A, you will see 'I am Client', and B will show 'I am Host'
- From A, Click 'Send Message', which send timestamp to B
- From B, Click 'Send Message', which send timestamp to A
- The first time send message, only from client to host, because host doesn't know client IP address unless host received client message.
For simple process, i use Task.Delay(1000) (every one second) to fetch communication result from Andriod to PCL.
Below are links i reference most.
https://developer.android.com/guide/topics/connectivity/wifip2p.html
https://github.com/Cheesebaron/WiFiDirectSample
https://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html