[SoftAP] configure-ap command fails with code -3

I am having a similar issue to this thread, where I am attempting to use a node app running on my laptop to configure the Photon via SoftAP, however I am getting a response of {"r":-3} when I attempt the configure-ap command.

It seems to have no issue with the public-key command, or scan-ap command. As documented in the example here I run rsa.setPublic() on the retrieved public key and then rsa.encrypt() on the entered password for the network.

However when I then send the configure-ap command with data postData = { "idx": 0, "ssid": SSID, "sec": SEC, "ch": CH, "pwd": rsa.encrypt(password) } , I get the response {"r":-3} and am not sure what this means?

The only user application on the Photon is the “Blink an LED” example, so I don’t believe there is any SYSTEM_THREAD enabled. I am running Photon firmware version 0.7.0.

Any suggestions for what I may be doing wrong?

Any suggestions? Or does anyone at least know where I can look up what the configure-ap error code {"r":-3} (or any other configure-ap error code) means?

I would follow the steps here to do it manually using curl, then compare the output piece by piece until you can see what the difference is.

I don’t know what -3 means, other than “an error.”

Hi @rickkas7, thank you for the response. I am really scratching my head on this one…

I followed through the steps in your guide under “Set up Wi-Fi”, but I was still getting the {"r":-3} response to the configure-ap command. This was the case whether I would use my own node app or curl with the wifipass.js node program you created to encrypt the password. I even tried it on multiple Photons running 0.7.0 but all with the same result.

When I send the configure-ap command, I see the blinking blue LED freeze up for a moment, then continue back to blinking once I get the error response.

I then tried downgrading a Photon back to 0.6.3, and this actually gives me {"r":0} !! But, even still I’m not sure it is quite working properly. Despite the success response, the LED would just go back to blinking blue (or breathing dark blue), so it doesn’t seem like the sent credentials are actually sticking.

I then tried upgrading to the brand new 1.0.0 firmware, but it went back to {"r":-3}. And I can confirm downgrading once again returned it to {"r":0} (but Photon still not actually connecting).

The network I am trying to connect to is WPA2 with AES encryption, just a home network. I know the network password and have tried more than enough times to confirm it’s not just a password typo or something.

My POST data for the configure-ap command is:

idx:0 ssid:MY_NETWORK sec:4194308 ch:1 pwd:<encrypted password> , of course with ssid, sec, and ch all pulled in exactly from the scan-ap command.

All other commands (device-id, public-key, scan-ap, connect-ap) are responding with correct {"r":0}.

Running through particle serial wifi seems to work fine and the Photon connects, but my goal is to accomplish the Wi-Fi setup from my own node app.

Does this info give you any ideas?

I tried taking a brand new Photon out of the box, plugged it in so it was blinking blue, connected to the “Photon-XXXX” AP, and attempted curl but got a “port 80 connection refused” error. Should that command work right out of the box? Or are there some other initial steps that must be done first?

Hi, could it be the body of the POST message you composed is missing the commas?

I have a photon on Device OS 1.0.1 and I was experiencing the same -3 response.
As it turns out, I was NOT formatting properly the body of the configure-ap when I inspected it closely.

I had something like this (which is missing commas and it’s adding spaces due to my fault and the way I formatted this on my javascript code!):

{"idx": 0,            "ssid":"canada             "sec":"4194308        
  "ch":"11         "pwd":"the_encrypted_password" }

But I fixed it to look like this - I removed spaces and added commas in the right paces:

{"idx":0,"ssid":"canada,"sec":"4194308,"ch":"11,"pwd":"the_encrypted_password" }

Boom! Got the expected response:


Million thanks @rickkas7 for the guide you wrote. It’s been invaluable to me.


It turns out my issue was because I was using jQuery .ajax() to send the POST request for the configure-ap command, and the data was being sent as a JSON object.

If instead I convert the entire data object to a single string first {"idx":0,"ssid":"..... and then only send this string, it works!

Took me a while to find this issue because I would print out a console log of the sent data and it looked perfect. But when I examined the command sent by the photonsetup.html file (this is the file that downloads from Particle’s website when setting up a dev Photon the typical way), I noticed the difference how the command data was all combined into a single string before sending.

1 Like