Go Down

Topic: Can WiFi SSID be set after download (Read 19 times) previous topic - next topic

dduehren

I am using the Nano33IOT for a project where I would like to have the user configure the wifi to connect to whatever network is available.  All of the examples with the WifiNINA library, etc use a compile time set SSID and password.  The Wifi.begin function takes const char* ptr which only seems to work if the thing that is being pointed to is a compiled string.  (ie one in "quotes"). 

So this isn't specifically about the Nano I'm wondering if anyone has figured out a work-around this.  For example is there a modified library that allows a more general char or string to be passed, even by value?


dduehren

I figured it out.  I can do this with a const char* pointers to a char array.  My problem that I'm still working on is that the string.length() is giving me the wrong result.

dduehren

Here's the code I eventually settled on.  curid and curpwd are strings.  the buffer declarations are ssid[30] and pass[30].

Code: [Select]
       if(curid.length()<=curid.indexOf(0x0D)){
          clen = curid.length();
              } else {
          clen = curid.indexOf(0x0D);
            }
        if(curpwd.length()<=curid.indexOf(0x0D)){
          plen = curpwd.length();
            } else {
          plen = curpwd.indexOf(0x0D);
              }
        curid.toCharArray(ssid,clen+1);
        curpwd.toCharArray(pass,plen+1);

Go Up