Argon Listening Mode WiFi Setup

I’m building a product that will use an Argon, and I need a way for the end user to give credentials for their WiFi network to their device. I assume the way to do this is to put the Argon into listening mode whenever it doesn’t have credentials, and send them over BLE somehow. I have an app that I’d like to use to send credentials (the user will enter them after the device is found and signaled), and I am able to see that the Argon is advertising when put into listening mode, but I’m not able to find documentation on how to format the credentials or send them. I see that there is one advertised service, which I assume is used for this, but I’d like some clarification on the specifics.

I’d suggest taking a look at: GitHub - Dan-Kouba/ble-wifi-setup-manager

It does not use listening mode unfortunately - that requires the Particle app to setup the WiFi credentials.

1 Like

There is currently no mobile device example code or library that is equivalent to the Device Setup SDK for iOS and Android used with Wi-Fi setup the Photon and P1. This will make it very difficult to set up Argons in a product at this time.

A solution for BLE-based setup of Wi-Fi credentials in white-label mobile apps is planned; stay tuned for the official announcement.

1 Like

That library works great; there are a couple of things I had to change (for instance it doesn’t exit listening mode after setup, and there’s no built in way to tell if credentials are incorrect), but it has solved the problem. Thanks!

Hey, would you be able to share your changes? It’ll be nice to avoid issues you solved if you do not mind.
Thanks!

Certainly, but the changes were pretty minimal; I called WiFi.listen(false) after the device connects to the Particle cloud to stop listening, and I disconnect from the central after the WiFi network is successfully joined, which tells the central that the network was joined and the credentials were correct with BLE.disconnect() and BLE.stopAdvertising(). I gave the app I’m writing as the central a timeout so that if the peripheral is still connected two minutes after the credentials were sent it’s safe to assume that either the password was incorrect or another error occurred, and it asks for a different password. One thing I would love to see at some point is a way to know very quickly if a WiFi password is incorrect; I was unable to find how to do this in the Device OS documentation, but I assume it’s possible since the Particle app has this functionality (I’m no expert on WiFi though).

What I really like about this library is how it implements WiFi setup with a generalizable messaging system of JSON over BLE; it’s great for exchanging information with another device locally about anything, which I’ve found very useful.

2 Likes

One weird behavior I’ve run into since working on edge cases of this: the Argon seems to be unable to scan for WiFi networks while it’s trying to connect to any of them. Is there a way around this? If not, how do I force the device to stop attempting to connect (calling WiFi.disconnect() doesn’t seem to do it, though I’ll keep experimenting with it)? The particular edge case I’m interested in is when a user inputs an incorrect password, closes the WiFi setup dialog (causing the app to forget which access points are available to the Argon), and attempts to start over and enter the correct password. This results in the app asking the Argon to scan for access points, which it can’t do for some reason.

Wifi.off() should force it to stop connecting?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.