- Clone this repo
- Flash the app from
firmware
directory to an Argon or P2 against at least Device OS 3.3.0 (previous versions didn't include the provisioning mode). - Scan the QR code from the device. It will contain two lines of text
- first line contains the serial number. Take the last six characters and update the
setupCode
constant - second line contains the mobile secret. Take it and update the
mobileSecret
constant
- first line contains the serial number. Take the last six characters and update the
- Make sure you have Android Studio installed and configured
- Make sure your Android device is set up for development. The app requires at least Android 10 (API version 30)
- Open this repo in Android Studio and run the app on the device
Note: this app uses custom BLE UUIDs meaning it won't work with stock Listening Mode without flashing the firmware above. You can update this app to use the default UUIDs but it's recommended to use unique UUIDs for your products to avoid picking up Particle dev kits when setting up your devices.
The app goes through following steps:
- Sets up and ensures all necessary BLE permissions
- Looks for devices with
name
ormanufacturerData
ending with hardcodedsetupCode
- Connects to the first device found
- Looks for exposed service with hardcoded UUID
- Lists its characteristics and ensures that it contains all the necessary ones
- Checks if version characteristic has matching UUID AND is readable
- Checks if read characteristic has matching UUID AND is notifying
- Checks if write characteristic has matching UUID AND is writable
- Checks if the protocol version equals
2
- Send echo request
- Send scan wifi networks request
The firmwareprotos
directory contains generated Java definitions for the device-os-protobuf
declarations. It allows easy encoding/decoding of the request/reply messages.
import io.particle.firmwareprotos.ctrl.wifi.WifiNew;
void scanWiFiNetworks() {
WifiNew.ScanNetworksRequest request = WifiNew.ScanNetworksRequest.newBuilder().build();
sendRequest(request.toByteArray());
}
import io.particle.firmwareprotos.ctrl.wifi.WifiNew;
void receivedScanWiFiNetworksReply(byte[] replyData) {
WifiNew.ScanNetworksReply reply = WifiNew.ScanNetworksReply.parseFrom(replyData);
log("Found " + reply.getNetworksCount() + " networks");
for (WifiNew.ScanNetworksReply.Network network: reply.getNetworksList()) {
log(" " + network.getSsid() + " [" + network.getBssid() + "] " + network.getRssi() + "dB");
}
}