Categories
Raspberry Pi User Help

How to connect an Android phone and a raspberry pi through wifi direct programmatically

so I have been working on the task of connecting a pi to an android via wifi direct for a while, and I was able to get it to work, using the information given in this question: Issue connecting raspberry pi to android via Wifi p2p.

I now want to write some code, preferably using python and some command line libraries that automates the connection. My goal is that the connection should be completely automated as if the pi is an obfuscated IoT product, so the end user would not have to interact with the innards of the pi in any way, and could make the connection just using their phone.

This is hard to do, because the connection procedure as I understand it, requires the pi to find devices, then the user has to invite the pi on their android, and then the pi has to initiate the connection on the command line.

Is there a way to have the pi listen for invitations and initiate the connection automatically? If not, does anyone have any ideas for how I can get this to work?

One way I could do it is connect the pi to a button and have the button run the connect command, but that is not the best solution because it would be confusing and inconvenient for a user, and the pi might choose the wrong device to connect to if it finds multiple. If I go this route I would probably need a way for the user to input their device name/ mac address, perhaps with a local web server.

Thanks!

also tagging @Ingo and @Seamus. No pressure, but let me know if you guys have any ideas!

Leave a Reply

Your email address will not be published. Required fields are marked *