Provision Argon WiFi Credentials via BLE question

Gooday everyone. I have implemented this lib New Library Example: Provision Argon WiFi Credentials via BLE
from @Dan-Kouba.

Can anyone confirm that it is possible to load Wifi credentials this way while the Argon is in listening mode. I can connect to the Argon in this mode but the scan for networks does not return any networks.

If the Argon is already connected to a network then it scans and updates correctly.

Device OS 2.1.0

Thank you

melt777, I’m curious — what is driving the requirement of being in listening mode? This lib is intended to work in normal operational modes as that is the operational mode of most of my customers’ devices when they need to be configured.

Dan Maybe I got it wrong, I thought this would enable clients to add the Argons to their Wifi without using the Particle App or CLI.
I need to enable the average non technical person on the street to buy an Argon and add it fto their own wifi. We will obviously load , claim and test it on our Wifi it before it ships.

So it should be flashing green when the end user receives it or flashing blue should we decide to reset the wifi parameters.

Is my thinking incorrect?

Hi! I think that is indeed the intent of the library you mention.
However, having the device in listening mode was a need in Photons. There is no need for an Argon to be in listening mode with this lib and this way of settings the wifi credentials. In fact, the Argon needs to be running the code to be able to run the lib code to be able to change its wifi credentials.

As for the state, I leave @Dan-Kouba to answer it.

@gusgonnet, the potential problem with that is tho’ that the Argon will automatically start into Listening Mode when there are no WiFi credentials present already.

This means that the firmware either needs to start in non-AUTOMATIC mode (and refrain from trying to connect when no creds are stored) or you need to provide at least one set of dummy WiFi creds to prevent that from happening.

@ScruffR I have tried the dummy set. So flashing green. Same result the > TX: {“msg_type”:“scan”} is sent from the website but no available networks returned. Just hangs

Is the code using SYSTEM_THEAD(ENABLED)?

yes, I knew there were dragons ahead so I refrained from commenting. Thank you for laying them down and explaining them.

Indeed im using SYSTEM_THEAD(ENABLED) ?

melt777, can you please enable LOG_LEVEL_ALL and post the results? Curious as to whats going on under the hood here.

@Dan-Kouba tried as I might I could not get scan for networks to work today. Even when connected to a network it returns no found SSIDs. yesterday it was working

my terminal, the 3rd line pops up immediately when I press the scan for networks button. Then it just keeps on checking

0000056313 [wiring.ble] TRACE: Connected by Central device.
0000056337 [system.ctrl.ble] TRACE: Connected
0000062396 [wiring.ble] ERROR: Peer device is missing!
0000068008 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000068008 [comm.protocol] TRACE: message id 836 complete with code 0.00
0000068009 [comm.protocol] TRACE: rcv’d message type=13
0000088286 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000088286 [comm.protocol] TRACE: message id 837 complete with code 0.00
0000088287 [comm.protocol] TRACE: rcv’d message type=13
0000108559 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000108560 [comm.protocol] TRACE: message id 838 complete with code 0.00
0000108560 [comm.protocol] TRACE: rcv’d message type=13
0000128816 [comm.protocol] TRACE: Reply recieved: type=2, code=0
0000128817 [comm.protocol] TRACE: message id 839 complete with code 0.00
0000128818 [comm.protocol] TRACE: rcv’d message type=13

What Device OS version are you running? It appears the BLE connection is to blame here — I have not seen that particular error before.

Dan Using IOS 2.2-rc1

I have run some scenarios and terminal trace results below - some interesting results

Wifi Manager lib test results

All Automatic

Scenario 1

already connected to valid network and Pulsing Cyan

**wifi manager works as expected SSIDs are found and passwords accepted with Argon being reset.

0000097908 [system.ctrl.ble] TRACE: Connected

0000098238 [wiring.ble] TRACE: Connected by Central device.

0000102100 [app.BLEWiFiSetupManager] TRACE: Added message to the queue: {“msg_type”:“scan”}0000102526 [app.BLEWiFiSetupManager] TRACE: State Transition: 1 → 2

0000103001 [app.BLEWiFiSetupManager] TRACE: String RX: {“msg_type”:“scan”}

0000103001 [app.BLEWiFiSetupManager] INFO: key=msg_type value=scan

0000105421 [app.BLEWiFiSetupManager] INFO: WiFi Scan Complete

0000105421 [app.BLEWiFiSetupManager] TRACE: State Transition: 2 → 1

0000118033 [app.BLEWiFiSetupManager] TRACE: Added message to the queue: {“msg_type”:“set_creds”,“ssid”:“Asus2.4G”,“password”:“Mxxxxk1”}

0000118232 [app.BLEWiFiSetupManager] TRACE: State Transition: 1 → 2

0000118686 [app.BLEWiFiSetupManager] TRACE: String RX: {“msg_type”:“set_creds”,“ssid”:“Asus2.4G”,“password”:“Mxxxxx1”}

0000118687 [app.BLEWiFiSetupManager] INFO: key=msg_type value=set_creds

0000118688 [app.BLEWiFiSetupManager] INFO: Set WiFi SSID: Asus2.4G

0000118688 [app.BLEWiFiSetupManager] INFO: Set WiFi Password: Mxxxxnk1

0000118754 [app.BLEWiFiSetupManager] INFO: WiFi credentials set

0000118755 [app.BLEWiFiSetupManager] TRACE: State Transition: 2 → 1

Scenario 2

Argon has no network credentials flashing blue (out the box)

*****Nothing gets logged in terminal not even BLE connect

No SSIDs on HTML page found.

Scenario 3

Connected to fake WIFI credentials loaded flashing green

No SSID returned on HTML page however they are picked up in the trace as per below

0000385333 [wiring.ble] TRACE: Connected by Central device.

0000385417 [system.ctrl.ble] TRACE: Connected

0000387831 [app.BLEWiFiSetupManager] TRACE: Added message to the queue: {“msg_type”:“scan”}0000395551 [] TRACE: < +CWJAP:4

0000395551 [] TRACE: < ERROR

0000395552 [net.esp32ncp] TRACE: Failed to connect to WiFi: -170

0000395552 [gsm0710muxer] INFO: Stopping GSM07.10 muxer

0000395553 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer

0000395554 [gsm0710muxer] INFO: Closing all muxed channels

0000395554 [gsm0710muxer] INFO: Closing mux channel 1

0000395555 [gsm0710muxer] INFO: Closing mux channel 2

0000395555 [gsm0710muxer] INFO: Muxed channel 3 already closed

0000395556 [gsm0710muxer] INFO: Muxed channel 4 already closed

0000396822 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)

0000396824 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed


0000396825 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting

0000396825 [gsm0710muxer] INFO: GSM07.10 muxer stopped

0000396826 [net.esp32ncp] TRACE: NCP event 3

0000396827 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_POWERING_DOWN

0000396827 [system.nm] TRACE: Interface 4 power state changed: 3

0000396828 [net.esp32ncp] TRACE: NCP event 3

0000396829 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_DOWN

0000396829 [system.nm] TRACE: Interface 4 power state changed: 1

0000396830 [hal] TRACE: Deinit modem serial.

0000396830 [net.esp32ncp] TRACE: NCP event 3

0000396830 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_POWERING_DOWN

0000396831 [system.nm] TRACE: Interface 4 power state changed: 3

0000396832 [net.esp32ncp] TRACE: NCP event 3

0000396832 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_DOWN

0000396833 [system.nm] TRACE: Interface 4 power state changed: 1

0000396833 [hal] TRACE: NCP state changed: 0

0000396834 [net.esp32ncp] TRACE: NCP event 1

0000396834 [hal] TRACE: Deinit modem serial.

0000396935 [net.esp32ncp] TRACE: NCP event 3

0000396935 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_POWERING_UP

0000396936 [system.nm] TRACE: Interface 4 power state changed: 4

0000398242 [] TRACE: > AT

0000398244 [] TRACE: < OK

0000399244 [hal] TRACE: NCP ready to accept AT commands

0000399244 [] TRACE: > AT+CMUX=0

0000399246 [] TRACE: < OK

0000399247 [gsm0710muxer] INFO: Starting GSM07.10 muxer

0000399247 [gsm0710muxer] INFO: Openning mux channel 0

0000399248 [gsm0710muxer] INFO: GSM07.10 muxer thread started

0000399252 [gsm0710muxer] INFO: Openning mux channel 1

0000399256 [] TRACE: > AT

0000399258 [] TRACE: < OK

0000399259 [] TRACE: > AT+CWDHCP=0,3

0000399264 [] TRACE: < OK

0000399264 [hal] TRACE: NCP state changed: 1

0000399264 [net.esp32ncp] TRACE: NCP event 1

0000399265 [net.esp32ncp] TRACE: NCP event 3

0000399265 [net.esp32ncp] TRACE: NCP power state changed: IF_POWER_STATE_UP

0000399266 [system.nm] TRACE: Interface 4 power state changed: 2

0000399269 [] TRACE: > AT+CWLAP

0000401777 [] TRACE: < +CWLAP:(4,“Asus2.4G”,-45,“1c:7f:2c:9f:20:a0”,1)

0000401778 [] TRACE: < +CWLAP:(4,“CRS”,-46,“1c:7f:2c:9f:20:a1”,1)

0000401780 [] TRACE: < +CWLAP:(4,“Ballito Tracking”,-68,“88:ce:fa:7f:1f:24”,5)

0000401781 [] TRACE: < +CWLAP:(3,“Motolek Ballito Fibre”,-73,“f6:92:bf:e4:8c:e3”,11)

0000401783 [] TRACE: < +CWLAP:(3,“Redsky”,-74,“c0:a0:bb:96:c1:3e”,1)

0000401785 [] TRACE: < +CWLAP:(3,“Balfour Fibre”,-76,“c0:c9:e3:44:90:ac”,10)

0000401786 [] TRACE: < +CWLAP:(3,“Battery Centre”,-80,“fc:ec:da:84:42:20”,6)

0000401787 [] TRACE: < +CWLAP:(4,“Vodacom-5EMJ9Y8”,-81,“a0:1c:8d:bf:ca:58”,1)

0000401788 [] TRACE: < +CWLAP:(3,“HUAWEI-8717”,-84,“88:40:3b:05:87:17”,1)

0000401789 [] TRACE: < +CWLAP:(4,“Motolek Downstairs”,-85,“04:95:e6:26:9d:01”,8)

0000401790 [] TRACE: < +CWLAP:(4,“Supertrack”,-90,“e4:18:6b:1c:54:10”,1)

0000401791 [] TRACE: < +CWLAP:(4,“Veshtirand”,-90,“88:ce:fa:8f:77:b8”,5)

0000401792 [] TRACE: < +CWLAP:(3,“Aquarius Equipment”,-91,“8c:5a:c1:04:5f:8b”,12)

0000401793 [] TRACE: < +CWLAP:(3,“Ballitomagrepairs”,-93,“88:ce:fa:81:c9:30”,5)

0000401794 [] TRACE: < +CWLAP:(3,"",-93,“8c:5a:c1:04:5f:8f”,12)

0000401795 [] TRACE: < OK

0000401795 [gsm0710muxer] INFO: Openning mux channel 2

0000403054 [hal] TRACE: Connecting to “Balfour Fibre”

0000413889 [wiring.ble] TRACE: Disconnected by remote device.

0000413919 [system.ctrl.ble] TRACE: Disconnected

Scenario 4

Putting device in Listening mode - flashing blue (from mode searching for fake WIFI flashing green)

*****Nothing gets logged - not even the BLE connection

No SSIDs returned on HTML page

Scenario 5

Putting in listening mode flashing blue (from connected to WIFI mode pulsing cyan)

*****Nothing gets logged in terminal

Network SSIDs are found on HTML page but password is not set and argon does not reset.


The library is only intended to work in non-listening modes, which your testing confirms is true. It should only work when the Argon is connecting, or connected to a WiFi network.

As far as it not working in Scenario 3, your brower seems to be disconnecting the device prematurely:

0000413889 [wiring.ble] TRACE: Disconnected by remote device.

That’s why nothing shows up on the webpage. I might recommend trying it on another computer or Android device to see if the behavior is replicable.

Dan, I have tried with other devices and the results are the same. The library only works if the Argon is connected to a Wifi already (pulsing Cyan). I will play around a bit on my side but wont get my hopes up. This would be a game changer should we be able to perform WiFi setup from any mode.

I have noticed that in scenario 3 (Argon loaded with fake details, trying to connect). The SSIDs found in the trace has nothing to do with the scan function on the HTML page. Looks like if the Argon cant connect to the the required WiFi with fake password that it scans automatically for all available networks.

as per below where Asus2.4G SSID was loaded with incorrect password

0000007686 [ncp.esp32.client] TRACE: Connecting to “Asus2.4G”
0000024535 [] TRACE: < +CWJAP:4
0000024535 [] TRACE: < ERROR
0000024536 [net.esp32ncp] TRACE: Failed to connect to WiFi: -170
0000024541 [] TRACE: > AT+CWLAP
0000027049 [] TRACE: < +CWLAP:(3,“Robertson”,-45,“40:b0:76:28:ef:d0”,6)
0000027050 [] TRACE: < +CWLAP:(3,“Asus2.4G”,-46,“40:b0:76:28:ef:d1”,6)
0000027051 [] TRACE: < +CWLAP:(3,“76 Zen”,-75,“1c:3b:f3:f7:71:16”,9)
0000027053 [] TRACE: < +CWLAP:(4,“Van Der Linde Wifi”,-93,“d8:32:14:a1:c5:31”,2)
0000027053 [] TRACE: < OK

Would be great if we could get this Lib to work form listening mode like with the CLI setup.

  1. $particle serial wifi
  2. scan + password
  3. restart
  4. $ particle usb setup-done
1 Like

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