kirillzyusko / react-native-wifi-p2p

Library that provide access for working with wi-fi direct (p2p) module in android.
174 stars 32 forks source link

getAvailablePeers() always return empty array #86

Closed ForamPattha closed 1 year ago

ForamPattha commented 1 year ago

const initialiseP2P = async () => { const init = await initialize() console.log('In initialiseP2P', init); // since it's required in Android >= 6.0 const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, { title: 'Access to wi-fi P2P mode', message: 'ACCESS_FINE_LOCATION', }, ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { onStartDiscoveringPeers() } else { Alert.alert('Warning', 'Permission denied: p2p mode will not work') } };

const onStartDiscoveringPeers = async () => { await startDiscoveringPeers() .then(() => getAvailablePeers()) .then(({devices}) => console.log('Available Devices:', devices),

); };

Use above code but not getting near by device list ..I have tested this with 2 to 3 android device which Android version is 10 or up. There is no error log in logcat . Any help would be appreciated...thanks in advance.

kirillzyusko commented 1 year ago

@ForamPattha please, attach logcat output just for period of time when you've tried to perform your actions. I can't help just based on the code you've attached 😔

ForamPattha commented 1 year ago

@kirillzyusko can you please check this attach ss .

Screenshot 2023-07-13 at 9 30 29 AM

You can also see that in native file I also got empty array.

kirillzyusko commented 1 year ago

@ForamPattha You've attached logs only for 100ms... Can you attach from time when you initialize module till the time when it returns an empty array?