New Android App: Provision Argon Wi-Fi Credentials via BLE

Hello Particle Community!

I have created an Android app that will allow you or any person (even your customers!) to configure the Wi-Fi credentials of an Argon from an Android device.

It complements the BLE WiFi Setup Manager Library created by @Dan-Kouba , posted here.

You can see it in action here:

You can install it on your Android device from Google Play:


Below there is an example firmware that overcomes one limitation of the library flagged by @steeves in this post:

Also flagged by @melt777 here:

Here's the example firmware:

#include "Particle.h"
#include "ble_wifi_setup_manager.h"

// This example does not require the cloud so you can run it in manual mode or
// normal cloud-connected mode
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);

SerialLogHandler logHandler(LOG_LEVEL_WARN, {
                                                {"app", LOG_LEVEL_ALL},
                                                {"system.ctrl.ble", LOG_LEVEL_ALL},
                                                {"wiring.ble", LOG_LEVEL_ALL},
                                            });

BLEWiFiSetupManager wifi_manager;

// callback for when the wifi credentials are set by the app or library
void provisionCallback()
{
    // avoid a timeout error on the app side
    // this gives time to the app to disconnect on its own
    delay(1000);

    System.reset();
}

void setup()
{
    // set some default credentials in case things go wrong
    // with this, the user can create a hotspot and the sensor can connect to it
    // so the library can provision the device
    WiFi.setCredentials("sensor", "sensor123");

    wifi_manager.setup();
    wifi_manager.setProvisionCallback(provisionCallback);
}

void loop()
{
    wifi_manager.loop();
}

The trick is to create a hotspot on your phone (with credentials sensor/sensor123), so the Argon can connect and the library can run.

Tested Android 12 on a Pixel 5, Pixel 3, and an Amazon Fire 7" tablet.

Anyone can install the app from Google Play.

Cheers!
Gustavo.

5 Likes

Wow Gus you the man, I cant wait to test this.

1 Like

Wow, it’s really great to share. I’m looking forward to the results after the test

@gusgonnet would it be possible to have the ssid and password be a variable with corresponding input fields in the app so the customer can enter their existing phone Hotspot information instead of changing their Hotspot credentials?

Hey Mike, good idea!
However, while trying to answer and running the flow in my mind, I hit a roadblock.

Let me explain:
the Particle library NEEDS the Argon to be connected to some Wi-Fi in order to run the code.
If not connected to anything, the code does not run and the Android app cannot connect to it.
Hence, there wouldn’t be a chance for the app to send the user entered credentials.
End of the road :skull:

I’m hopeful the Photon 2 has this flow improved. The hotspot wouldn’t be needed and usability would be much better and a lot simpler.
Cheers!

1 Like

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