Author Topic: Issues with changing Wifi?  (Read 11707 times)

emardee

  • Full Member
  • ***
  • Posts: 135
Issues with changing Wifi?
« on: August 17, 2016, 04:37:44 am »
I'm having problems changing wifi on some working Oaks. I'm, hoping it is just me doing something silly, rather than an actual problem.

I'm following these instructions:
https://digistump.com/wiki/oak/tutorials/wificonfig

Despite trying multiple times on multiple Oaks, with credentials for new wifi AP, all I get is, "saving to device" and it just stays on that screen forever.

I know the Particle credentials are correct, because it won't let me proceed if they are wrong. I know the wifi credentials are correct as I've tried multiple times, changed the pre-shared key on the AP, and even created a new SSID just for testing on. Always with the same result. I've also tried using the manually enter SSID option in case it was the detection step that was fooling it and it didn't help. The oak seemingly has no problem detecting the SSID correctly, and happily displays all the wifi networks present.
I've tried running the routine in a location at far end of house from wifi, in case it is interruptions.

When I turn on the old wifi AP they spring into life and happily connect to Particle cloud as fully working Oaks. The problem is I'm trying to end-of-life that old Wifi AP, but I can't get the Oaks to accept a config to a new wifi.

Any ideas?

I think I'm using v1.0.1 on those Oaks right now. They drop into triple blink happily and allow connection to their acorn AP.

I've tried using a Laptop, and two Android phones.

I'm sure it just worked first time when I tried it before (several months ago).

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #1 on: August 19, 2016, 08:46:51 pm »
Still having this problem. I've had to leave the old AP connected for now as I can't get them to save a new wifi config on currently. A bit frustrating really.

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Issues with changing Wifi?
« Reply #2 on: August 20, 2016, 02:00:23 am »
Hey emardee, so you only get the 'saving to device' animated progress bar? You don't get the next screen saying your oak is rebooting?

I'm afraid I can't say I've had any problems with that, other than the issues I was having when first provisioning the Oaks, which seemed to be related to the device  (laptop) I was using to configure them with. Now that I use my tablet all the time for Oak-figuring, once it's connected all is good. I tried switching my usual test subject between my regular and a travel router I have, and it switch to and back without any dramas. This is with system version 10 (firmware 1.0.5), but I don't think anything major happened around the wireless config section, so that shouldn't have any bearing on this.

jjlink

  • Newbie
  • *
  • Posts: 1
Re: Issues with changing Wifi?
« Reply #3 on: August 21, 2016, 04:05:42 pm »
I have the same issue; it say this and that all:

Oak WiFi Config
Saving settings to your device...

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #4 on: August 21, 2016, 04:24:10 pm »
Sort-of encouraging to hear someone else has the same problem. Yup, mine just sits there saying:
Quote
   Oak WiFi Config
   Saving settings to your device...

...and never gets any further. It is a weird one.

Peter: If you have a couple of spare minutes, could you try putting in a deliberately wrong Pre-Shared Key when switching to a new Wifi connection. I'm interested to see if there is any obvious reason why it doesn't finish saving. Pretty sure it wouldn't be checking the WIFI connection was valid before finalising... and if it was, it really should be sending an error message to say so. Be good to rule it out though.... (admittedly I'm just clutching at straws here).

Not sure what else to try at this end... think I have tried pretty much everything I can think of. Multiple Computers/Phones. Multiple Browsers on said devices. Multiple Oaks. Multiple Wifi points. etc.....

Thanks

Mike

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Issues with changing Wifi?
« Reply #5 on: August 21, 2016, 08:19:24 pm »
You're right in your thinking emardee... SoftAP just sends the new config data to the Oak to be saved, and then tells the Oak to reboot, so there is zero checking there for an established connection.

I did try entering an invalid PSK (on a WPA2 network) and all that happened was a reboot and no connection! 8) Rebooted into safe mode again, put in correct PSK, and then the Oak was online again. I did get one momentary hiccup when saving the settings (red warning text), but it told me to simply retry again after checking the connection to the Oak.

I was going to suggest a more brute-force method of bashing the Oak into accepting your new wireless config, but after looking at the configure-ap stuff, I decided it was all a bit beyound me! Dr kh may be able to decipher that, but I lost it at most and least significant nibble encoding  :o ;D

Hopefully you and jjlink can work out some commonality in what's behind the issue. Things like wireless setup (security, channel, chipset, naming), device used to configure, and the oak firmware version (check what the version number is at the bottom of the wireless configuration page), or at 192.168.0.1/info when you are connected to the Oaks AP.


emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #6 on: August 22, 2016, 12:03:50 am »
Thanks for checking. That rules that out as another cause, and further narrows the remaining possibilities.

I'll have a further think in the next 24 hours or so, to see if I can work out what is going on and if I've missed anything obvious.

If anyone else has any ideas, I'm totally open to suggestions or running some tests.

Thanks again

Mike

kh

  • Jr. Member
  • **
  • Posts: 64
  • OakTerm developer
Re: Issues with changing Wifi?
« Reply #7 on: August 22, 2016, 08:52:21 pm »
all I get is, "saving to device" and it just stays on that screen forever.

I took a look at the OakSoftAP code. It shouldn't be staying on that screen forever...it should either proceed or give you an error, so I suspect there's a bug in SoftAP code. If you open the Javascript console in your browser (hit F12), does it happen to log any errors while it's "saving to device"?

A few other thoughts:
  • What Wifi security mode are you using, e.g WEP, WPA, WPA2? (if it's something unusual, the Oak might possibly have a problem with it)
  • How many characters are in your passcode? (if it's more than 63 characters, that might be problematic too)

If your ssid and passcode actually have been saved to the device, then you can manually force the next step.  First, make sure you're connected to the ACORN_nnnnnn wifi network, then in a web browser, go to the url:

http://192.168.0.1/connect-ap

This is what OakSoftAP is supposed to do, and the Oak is supposed to respond by rebooting and connecting to the new wifi network. Does your wifi router provide a list of connected devices? If so, that's a good way to confirm whether or not the Oak sucessfully connected.


If this doesn't work, you can manually set the ssid and passcode, but it's quite involved because the Oak expects the passcode to be encrypted. Here's what to do:

(I'm assuming you're running Windows. If not, let me know.)

1. Download and install Git for Windows version 2 or later if you don't have it already, then open a Git Bash Shell and type the commands below (We don't actually use git itself, but it provides all the tools needed in one easy to install package).

2. Connect to the ACORN_nnnnnn wifi network

3. Get your Oak's public key by running the following commands (the public key is needed to encrypt the wifi passcode):
Code: [Select]
mkdir ~/OakDebugging
cd ~/OakDebugging
curl -s http://192.168.0.1/public-key | sed 's/^.*"b":"\([^"]*\)".*$/\1/' | xxd -r -p - > oak_pubkey.der

4. Encrypt your wifi passcode with the following command:
Code: [Select]
echo -n "YourPasscodeHere" | openssl rsautl -pubin -keyform DER -inkey oak_pubkey.der -encrypt -pkcs | xxd -p - | tr -d '\n'This will print out a string of hexadecimal digits something like this:
Code: [Select]
a3f0a0d1819647fdc792ad74955af52115a89f387b2b9af06331a7f0402cf9d7d6dea4a608a1f5ee05bab62cb0261c283d875fd2852cfcad67b30f66ca1424f2d15adba60c701a6ebe47a49c2a584dc36f2e334e98a4bc5bafa0302903330835e50c553f4633b82e3e0a7fab7e7b19b0f4df4a5fc77043e6f5262aa30d0a3c02(FYI, every time you run this command, the hexadecimal digits will be different - this is a normal consequence of the encryption process)

5. Copy and paste into the url below your wifi ssid (in place of YourSSID) and the string of hexadecimal digits (in place of the ones above). Then copy and paste the completed url into your web browser.
Code: [Select]
http://192.168.0.1/configure-ap?plain={"ssid":"YourSSID","pwd":"a3f0a0d1819647fdc792ad74955af52115a89f387b2b9af06331a7f0402cf9d7d6dea4a608a1f5ee05bab62cb0261c283d875fd2852cfcad67b30f66ca1424f2d15adba60c701a6ebe47a49c2a584dc36f2e334e98a4bc5bafa0302903330835e50c553f4633b82e3e0a7fab7e7b19b0f4df4a5fc77043e6f5262aa30d0a3c02","sec":1}This sets the SSID and passcode on your Oak. If it's successful, you should see {"r":0} in your browser. If there's an error, it should be {"r":-1}.

6. Finally, click this url to tell your Oak to reboot and try to connect to the new wifi network: http://192.168.0.1/connect-ap


(Note that this process only sets the wifi ssid and passcode. It will not work for the first setup of a new Oak as OakSoftAP does other things such as initiate a firmware update and negotiate a claim with the Particle Cloud.)
« Last Edit: August 22, 2016, 09:54:40 pm by kh »

kh

  • Jr. Member
  • **
  • Posts: 64
  • OakTerm developer
Re: Issues with changing Wifi?
« Reply #8 on: August 22, 2016, 09:07:45 pm »
If the above doesn't get you anywhere and you have a USB to serial adapter, one final debugging step is to dump the config sector from your Oak and see what, if anything, is being saved there (see my other post for instructions on how to install Python, and OakRestore, which provides esptool):

Code: [Select]
python esptool.py --baud 115200 --port YOUR_COM_PORT read_flash 0x100000 3398 config.bin
You can inspect the bin file with xxd in a Git Bash Shell:

Code: [Select]
xxd config.bin | less
The SSID should be at offset 0xB1D, and the passcode at 0xB3E.

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #9 on: August 22, 2016, 10:15:16 pm »
Awesome. Thanks kh. I'll try these steps tonight, and see where I get to. (I'm at work right now)

The process clearly never finishes sending the new SSID and Pre-Shared Key to the Oaks, because when I finally give up and disconnect from the Acorn wifi, and reboot the OAK (then power up the old wifi AP) the Oaks all merrily hop online on that Wifi AP immediately and report themselves as being online in Particle Cloud... so those old wifi credentials clearly never get over-written for some reason!

I'm using WPA2-PSK. Password for new Wifi AP is either 10 or 14 characters long (tried several different SSID and Pre-Shared key combos).

Will run the javascript console first to see what enlightenment that offers then work from there.

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #10 on: August 23, 2016, 01:27:11 am »
Well console is giving me some info which might help with debugging:
Code: [Select]
Password fields present on an insecure (http://) page. This is a security risk that allows user login credentials to be stolen.[Learn More]config.html
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead.   config.html:76:31440
Error:    config.html:970:1767
[238]</t.exports.newInvalidAsn1Error()   config.html:970
[240]</</n.prototype.readString()   config.html:970
[251]</</t.exports.publicImport()   config.html:972
[250]</t.exports.detectAndImport()   config.html:972
[245]</</t.exports</e.prototype.importKey()   config.html:971
e()   config.html:971
t()   config.html:973
bound t()
self-hosted
o()   config.html:973
[260]</</i.prototype.__httpRequest/n</<()   config.html:973
[201]</n.prototype.emit()   config.html:968
S()   config.html:968
r/<()    config.html:969
[205]</o.prototype.run()    config.html:968
i()    config.html:968

Do those errors mean anything to you? I haven't looked at the code being run, so it is meaningless to me currently...

This is Windows 10 with Firefox 48.0 (although 48.0.1 is pending install, so I'll test with that too).

It says "Version 6" at the bottom. (Which I think from memory confirms it is v1.0.1 firmware).

« Last Edit: August 23, 2016, 02:07:33 am by emardee »

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #11 on: August 23, 2016, 06:35:27 pm »
Hmmm... the version number on one of the links showed v1.0.0 (not v1.0.1). That might be my bad memory....

Does anyone know which version of firmware (eg v.1.0.?) is called v6 on the wifi change screen?

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Issues with changing Wifi?
« Reply #12 on: August 23, 2016, 08:22:47 pm »
That should be 1.0.0  (as can be seen in the changes made to particle_globals.h in this commit - look at OAK_SYSTEM_VERSION_INTEGER). However, I can't see a commit for 1.0.1 any more (which I think was pulled as it was causing problems), and 1.0.2 increments to 7, so there is a good chance that 1.0.0 and 1.0.1 had the same system version.
« Last Edit: August 23, 2016, 08:24:27 pm by PeterF »

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Issues with changing Wifi?
« Reply #13 on: August 23, 2016, 10:18:05 pm »
Hmmm... my memory had 1.0.2 being the version that was pulled offline (along with 1.03 and 1.04).

v1.0.1 was the version that introduced manual mode. (but was otherwise only a minor tweak of v1.0.0). This was the best and most stable release until v1.0.5 came out about 6 weeks ago (which fixes some particle cloud bugs which had been there through the earlier stable releases and is also the first stable release of OakTerm).

The other version numbering though makes it all very confusing! This is especially true if we really did have two firmwares versions both reporting themselves as "System Version 6" (eg v1.0.0 and v1.0.1 - is that true? or was v1.0.1 called "System Version 7"?).

Even more confusing if we now have v1.0.5 is using "System Version 5" in some places!!! (although I think that is meant to be less confusing as it is intended to be reported as Major version 10, Minor Version 5 maybe?)

But I digress... back to the topic on-hand:

Anyone got any thoughts on my error logs? (Three posts above this)

Note I also tried this is MS Edge browser where is did the same thing on screen (never get beyond "saving config" message, but logged no errors in F12 Console (whereas is had on Firefox).

So list of definitely tried devices that get stuck saying "saving config" on screen and never progress:
  • Firefox v48.0.0 on Windows 10.
  • Firefox v48.0.1 on Windows 10.
  • MS Edge Browser on Windows 10.
  • Android phone with Firefox Browser.

However, wouldn't run at all on Stock Android Browser. (Would need to try that again to be sure of how it didn't work...)

All of these are with ESET Anti-virus protection turned off, and ESET Firewall set to disabled (in case that was the problem).

kh

  • Jr. Member
  • **
  • Posts: 64
  • OakTerm developer
Re: Issues with changing Wifi?
« Reply #14 on: August 23, 2016, 10:21:38 pm »
Code: [Select]
Error:    config.html:970:1767
[238]</t.exports.newInvalidAsn1Error()   config.html:970
[240]</</n.prototype.readString()   config.html:970
[251]</</t.exports.publicImport()   config.html:972
[250]</t.exports.detectAndImport()   config.html:972
[245]</</t.exports</e.prototype.importKey()   config.html:971
e()   config.html:971
t()   config.html:973
bound t()
self-hosted
o()   config.html:973
[260]</</i.prototype.__httpRequest/n</<()   config.html:973
[201]</n.prototype.emit()   config.html:968
S()   config.html:968
r/<()    config.html:969
[205]</o.prototype.run()    config.html:968
i()    config.html:968

I tested this on Win10 with Firefox 45 and 47 and I don't get these error messages. As far as I can tell, they originate from the OakSoftAP code that reads the Oak's public key...the key is in ASN1 format and it appears to be running into an error parsing the data. It makes me wonder if the key on your Oak is corrupted somehow, but I doubt your Oak could communicate with the Particle Cloud with a bad key.

It will be interesting to see what happens when you follow my manual instructions. Check the oak_pubkey.der file you get from step 3. It should be 162 bytes long, and the contents, viewed with "xxd oak_pubkey.der | less" should look like this, with random data in place of the question marks:
Code: [Select]
00000000: 3081 9f30 0d06 092a 8648 86f7 0d01 0101  0..0...*.H......
00000010: 0500 0381 8d00 3081 8902 8181 00?? ????  ......0...??????
00000020: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000030: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000040: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000050: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000060: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000070: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000080: ???? ???? ???? ???? ???? ???? ???? ????  ????????????????
00000090: ???? ???? ???? ???? ???? ???? ??02 0301  ?????????????...
000000a0: 0001                                     ..

It's possible to reset the Oak's public key if it's bad, but I haven't found a way to do it without using a USB to serial adapter.
« Last Edit: August 24, 2016, 09:12:29 am by kh »