WiFi testing program

I just looked on github and even back to version 1.0.0, that fetchUpdate() function was not commented out. Where did you get a version of the source in which it was commented out?

Yeah, disregard that bit. I was actually seeing the CALLING of the function commented out in settingsApp.cpp in a couple places (where they switched to the EEPROM flag instead). My brain crossed a wire in saying the whole function is commented out. I’ll chalk that one up to sleep deprivation and general mental stress of reading a few hundred pages of code over 6 hours.

Ah, gotcha. Well, in that case, I’m definitely stumped as to the cause of my original issues, because I definitely used a variant of the fetchUpdate() function to no avail. I just used your code above for HTTPS and it worked just fine…who knows what I was screwing up in my prior attempts at this point - my theory is with the CA stuff, which I have since read up on…but it was sooooooooo many hours ago now. lol

Anywho, I have the first working version of self-updating finished. It makes a backup copy of the current version to WiFiTest.v{curVer}.bin, then downloads the latest WiFiTest.bin from the github repo. There’s no version checking (yet), so an update ALWAYS happens. When finished downloading, it will return you to the main Ringo loader so you can relaunch into the new version. Mission accomplished in the most basic of forms.

GitHub has been updated with v1.2.0

Ideally, I’d love to have it actually reflash and launch right back into the updated version, but from what I’m gathering while digging through esp32 source, that would be easier said than done…running an Update() routine flashes the non-running partition, then you next boot into that partition. You can set the next OTA boot partition, but not the next OTA flash partition (since we can’t flash the partition in use, this value appears set at the ESP level on boot based on the boot partition selected).

If I just run the mp.updateFromFS() routine, the user has no way to return to Ringo’s main screen (one partition would contain old running version, other would contain new version - since mp.updateFromFS() obviously flashes the inactive partition, we just overwrote LOADER.BIN :expressionless:). I’ll keep digging into that bit. In the meantime, we have a proper app updater to save pulling the SD card; you just gotta manually relaunch the app after updating. :man_shrugging:

On a side note, I did whip up two handy new functions while building this out, if anyone wants to borrow them from my code for their own use:

  • dblPr(String msg, bool newLine=0)
    to print the same message to both Serial and mp.display (with or without newline) in a handy one-liner:
    dblPr("Hey "); dblPr("there!", 1);

  • copyFile(origFile, destFile)
    to copy one file to another on the SD card. It’s a bool for use in validations:
    if (copyFile("/WiFiTest/WiFiTest.bin", "/WiFiTest/WiFiTest.old.bin")) Serial.println("SUCCESS"); else Serial.println("FAIL");

1 Like

TWM, I found a little gotcha in version 1.2.3 with the update:

Apparently, your logic is to make a copy of the current app, then use http to overwrite the current app. If the current app is version 1.2.3 just downloaded on a Windows machine, it arrives with its “Read-only” attribute set (I think it’s a Windows thing). If I copy that to the SD card and then run it, and then attempt an update, it always gets a good 200 http status, but can’t write the file (0 bytes written) because the file is read only. There are 2 possible solutions to this:

  1. Clear the Read-only attribute on the file written to the SD card from Windows; or…
  2. Change your logic to rename the original bin file so that there is no file named WiFiTest.bin on the SD card, then do the download, and then if the download fails rename the previously renamed file back to WiFiTest.bin.

I was able to do the update after clearing the Read-only attribute.on the file. But that does require a user to take action while 2), it would seem, would not.

What do you think? Did you not run into this yourself (perhaps you’re using a Mac or Linux to download the file and it doesn’t set the Read-only attribute upon download)?

I figured out how the Read-only bit got set. When I downloaded the WiFiTest.bin from github, I accidentally asked Windows to open it with VLC Media Player rather than to just save it in Downloads. If I just save it in downloads, then the Read-only attribute is not set; but if I open it with VLC Media Player (of course it doesn’t play, just gives an error), the downloaded file in a temp directory has its Read-only attribute set. So apparently it depends on how you download the file whether this bit gets set or not; apparently I got “lucky”.

1 Like

GitHub has been updated with v1.2.6

Recent Changes:

  • Added additional debugging output to Serial Monitor and more error reporting
  • Added a Splash screen on app launch that shows current version while everything loads up
  • Added a Tests Menu sub-menu to make room for more stuff
  • Made Chat Server prettier and more useful by telling other clients when new client connects, which client sent an incoming message, and I increased the message buffer to 5k (was only 80 bytes in original example I built from) to prevent fragmentation. You can now send a hefty bit of text before it gets split into multiple messages.

I have some more plans for Chat Server. Like asking for a Name on connect and using that instead of arbitrary ID #s for clients. I may also look to implement a command sequence so clients can do things like, well, change their Name, for starters…or edit, save, and apply new settings to the app…or maybe even upload files to the SD card. Telnet does open a lot of doors.

v1.2.6 looks good TWM.

GitHub has been updated with v1.3.0 (can you tell I’ve been bored lately!?)

Totally revamped Chat Server :innocent::

  • You’re asked for your Name on connect
  • Show a list of connected client Names to everyone when a new client connects
  • Show which client sent the message
  • Better Server messages to clients
  • Better filtering of message data to strip unwanted telnet garbage

Next up, I’m adding command sequence detection. Something simple like:

  • ~N MyNewName - to change your Name
  • ~L - to show you the list of all connected clients

Yeah, I know…I’ve been a little too bored lately and pumping out new code in this like crazy. However, I find this telnet stuff fun and the effort potentially reusable in other projects. I’m sorting out all sorts of crazy little “gotchas” on Arduino and/or Ringo.

Sounds like fun. Before you get too in love with telnet, don’t forget that telnet has been deprecated for years and ssh is the new telnet (with encryption, and thus obviously more complex). Look around the internet and you should find ssh server implementations for Arduino/ESP32. Just in case you’re really bored :slight_smile:

Oh yeah, for sure telnet is a dinosaur and entirely insecure. Meh, I don’t think we need to get that deep, tho. haha Making the user deal with SSH is far from ideal when this is only going to be visible from the local subnet and the Ringo doesn’t exactly house State secrets or anything like that. :rofl:

Besides, once I’m done working up Chat Server, it’s time to move on to the SD Web Server. :stuck_out_tongue_closed_eyes:

GitHub has been updated with v1.3.1

Well, that was way too easy. Command Sequences framework (~X param) is done and there are currently 2 commands available:

  • ~L - List the connected clients; takes no param
  • ~N NewName - Changes your Name to NewName; spaces are allowed in the newName

I wonder what other useful options I could add. :thinking: