Android Question Wifidirect conflict?

RJB

Active Member
Licensed User
Longtime User
I've spent a few days trying to get wifidirect to work without much luck. I'm using android 4.4.2 for testing and there seems to be a built in 'wifidirect manager' permanently running. Occasionally an 'Invitation to connect' pops up. Is there a conflict here? If so is there any way to turn off the built in 'manager' to avoid it?
(The 'search for devices' entry in the Wi-Fi Direct menu seems to lock permanently on 'searchin...' or at least stays on for a very long time with no way of cancelling it, if that has any bearing on the problem).
 

RJB

Active Member
Licensed User
Longtime User
That may be the case but I have checked on another four devices and they all have the same menu/ submenu in the wifi setup and all work in exactly the same way so it seem a bit strange. I presume all six devices are from different manufacturers. The additional four are: an MX TV box running 4.2.2, a CX919 'stick' running 4.2.2, another generic 'stick' running 4.4.2 and a phone running 4.2.2.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
I wasn't, but I have run it and the screenshots are attached showing the menus and dialogue:
WifiDirect Example small.png
WifiDirect Example small.png
Wifi Menu small.png
WifiDirect Screen small.png
Invitation to connect small.png
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Sorry but I don't understand.
The wi-fidirect settings and the 'Invitation to connect', that pops up when you try to connect, have nothing to do with wifi direct?
Am I missing something?
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
OK, a final question and an observation then:

Question:
Can you tell me what 'connected' indicates in the '_ConnectionChanged' event? i.e. when it is raised by .initiliaize, .connect, etc.?

Observation:
Using the example from the tutorial (which I presume follows the steps given) and run it on two devices. Unknown to us a third device within wifi range is searching from its built-in wi-fidirect.
Press 'discover' on both of our devices and they immediately show 'Peered Devices: 1'. Press 'connect' on one of them before it discovers our second device and it tries to connect to the third, unknown to us, device. That device now shows the 'Invitation to connect' prompt.
So presumably we have to know in advance the name of the device we are trying to connect to so that we can search the 'devices' list and only try to connect if we find it.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Thanks

Just to check my understanding:
on '.intitiatize' _EnabledChanged is called with 'enabled' true, AND
_ConnectionChanged is called with 'connected' false
on '.connect' _ConnectionChanged is called with 'connected' true if successful and false otherwise
if an existing, successful connection breaks then _ConnectionChanged is called with 'connected' = false and you should re-establish the connection as it won't automatically re-connect.
on '.GetCurrentStatus' _ConnectionChanged and _EnabledChanged are both called, with 'enabled' and 'connected' set accordingly.

Is the source for the wificonnect library available - it might clarify what's happening?

Thanks again
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Final notes:
1. I personally think there is a conflict which causes erratic behaviour in wifidirect under some circumstances. This may account for some people noting that wifidirect is unreliable. I can't prove it without being able to turn off the built in 'wifi direct manager'. I'll have to find another way to do what I wanted to do.
2. It might be obvious but possibly worth pointing out: in _PeersDiscovered, 'Devices As List' is not initialised unless 'success' is true.
3. Its a real pain that logging doesn't work any more and a shame that bookmarks aren't available.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
I thought I read somewhere that Google had made changes that meant that logging would no longer work?
Via wireless and B4a-Bridge, in debug mode the following:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
Log("test")
End Sub

Sub Activity_Resume
Log("test")
Msgbox("OK","")
End Sub

just brings up the messagebox and the only thing in the log is "LogCat connected to: B4A-Bridge: Jlinksz MT13"

B4a version 5.50
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
The 'problem' with logging was my fault. On one device I hadn't enabled 'USB Debugging' and on another I had an old version of the B4A-Bridge!!
 
Upvote 0
Top