Shop OBEX P1 Docs P2 Docs Learn Events
WX WiFi module serial interface doesn't like commas in SSID or password — Parallax Forums

WX WiFi module serial interface doesn't like commas in SSID or password

Ding-BattyDing-Batty Posts: 305
edited 2025-05-10 20:28 in Accessories

This had me puzzled for a while.

Trying to join my home network using the WX_WiFi_Module_Setup_for_FLiP_Protoboard.spin program to set the SSID and password just would not work. Joining a different network (SSID and password) worked that way fine, and using the Web interface (in AP mode) for the module also worked fine for my home network SSID and password.

It seems that the WX firmware doesn't like commas in the serial command arguments, because it uses the comma to separate the arguments for a command, and there is no character escape mechanism for parsing the serial command.

So, if you have a comma in your WiFi password (or in the SSID), you cannot use the serial "JOIN" command to set the SSID and password; you have to use the Web interface with the WX WiFi board in AP mode. (In fact, the serial command interface doesn't like commas anywhere in any arguments, period.)

More details:
The serial command arguments are broken up at the commas in the following code for the ESP8266 (Both the Parallax version and The VonSzarvas version:
https://github.com/parallaxinc/Parallax-ESP/blob/f6e49a2c4132bdf364697d486b58d9062e72796b/parallax/sscp.c#L372
https://github.com/VonSzarvas/Parallax-ESP/blob/4e44e2bd22eabb812083d76d639be58e5cb7537b/parallax/sscp.c#L374

Possible solutions:
1. Add an escape character, such as "\", so the command might be JOIN:MyNet,Good\, and Bad
2. Add the knowledge of exactly how many arguments each command takes, and stop looking for commas when you find the start of the last one. This loses the ability to catch the "too many args" condition.
3. Do nothing, and require use of the Web interface for these kinds of networks. But document that limitation/condition.

(I can add this as a reported issue to either or both of the GitHub projects, if you like.)
[Edit: added bold attribute to the Spin program name.]

Comments

  • when implementing option1 (escape characters) you have to make sure to also escape the escape character when used, i.e. any occurance of \ and , must be escaped, as an SSID can contain ANY data (unspecified or UTF-8) in a 32 bytes NULL terminated string.

    "\this is, my ssid"
    

    becomes

    "\\this is \, my ssid"
    

    This is also the behavior in the espressif AT command set : https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/AT_Command_Set/Wi-Fi_AT_Commands.html#cmd-jap

    Another option would be to hex encode the arguments

  • Yes, escape character use causes a lot more boundary cases, e.g. what if a lone escape character is the last character of the string -- it probably should not "escape" the zero byte at the end (unless that is what you want).

    Also, you can't use the simple "strchr()" call (in this case, "os_strchr()") to find the next separator, since you are looking for any of ",", "\", or end of string. You might be able to use the "strpbrk()" function if it is available, otherwise you have to roll your own character- by-character scan of the string.

  • Well, to be fair, the documentation of the "Serial Command Format" in the file 32420-Parallax-Wi-Fi-Module-API-v1.0.pdf does say the following:

    Text form is easier to read and type on a terminal, with required colon ':' and comma ',' delimiters, and token form is convenient for a microcontroller to transmit (extra characters and delimiters are eliminated).

    It is easy to read this as "the extra colons and commas are eliminated when using token form", but not when using text form.

    I'm going to try to make some improvements to the WX_WiFi_Module_Setup_for_FLiP_Protoboard.spin to better report failures of the individual commands.

    It may even be possible to use the pass-through feature (anything not appearing between the Begin and End markers) to talk directly to the ESP8266 -- I may have to try that as well.

Sign In or Register to comment.