Page 1 of 1

String constants

Posted: Sat Dec 16, 2023 8:14 am
by mnfisher
I hit upon an issue trying to get an esp32 to connect to wifi using v5.1.1

I had string constants (local to main) .ssid and.pswd (say "SSID" and "PASSWORD" for example)

Then I call ConnectToSSID(.ssid, .pswd, 60)

This fails to connect - and the error messages output to UART have 'Failed to connect to SSID SSIDPASSWORD Password WORD")

Passing the values in the function (So ConnectToSSID("SSID", "PASSWORD", 60) connects correctly)

The string constants aren't terminated or treated correctly? I didn't test but I suspect adding a terminator ("SSID\0") would fix this?

Martin

Re: String constants

Posted: Sat Dec 16, 2023 7:08 pm
by mnfisher
Just taken a look at the source created and no room is allowed for a termination character.

For example:

Code: Select all

  
  #define FCLsz_SSID 9
  const MX_CHAR FCL_SSID[FCLsz_SSID] = "BT-ZMA6WK";
The string needs to be defined as FCL_SSID[FCLsz_SSID + 1] = "...
or
FCL_SSID[ ]= "BT-

This also affects global string constants.

Just checked in v8 - here we get

#define FCL_SSID "BT- ...

Which works correctly.

Martin