3 Replies Latest reply on Jan 4, 2019 6:11 PM by chuntkincaid_3807591

    configure wifi client at run time

    nfindikli_2915566

      In my project, the WiFi credentials will be changed in the field (by programming a configuration file via USB at installation time).  I cannot find any API or example that updates the WiFi credentials for automatic re-connection.

       

      All I can come up with is to use wiced_wifi_scan_networks(), finding the network(s) configured in the field, and connecting to a network using wwd_wifi_join_specific().

       

      Questions:

      1. Is there a better way to change (or add to) the credentials read from wifi_config_dct.h?
      2. Is "join" sticky?  I.e. will the stack re-connect to that AP if connection is lost?
      3. Even if the answer to #2 is "yes", it seems like the device will be stuck with a single network; losing the ability to fall back f that network goes down.  Unless I build my own scan-reconnect on every disconnection.

       

      thank you

        • 1. Re: configure wifi client at run time
          RaktimR_11

          You may find this How to switch AP connection in an application useful for your use-case.

          1 of 1 people found this helpful
          • 2. Re: configure wifi client at run time
            nfindikli_2915566

            Thank you, I can see how to update the DCT file.

            When I look at the structure that is used, I see an array of AP entries: 

            typedef struct

            {

               :

               wiced_config_ap_entry_t   stored_ap_list[CONFIG_AP_LIST_SIZE];

               :

            } platform_dct_wifi_config_t;

             

            Questions:

            1. I have not seen any format that allows multiple entries to be specified in wifi_config_dct.h; how would I do that?
            2. OR is it the case that multiple entries can only be defined via code?
            3. the definition of platform_dct_wifi_config_t has a warning about changing it will break OTA2.  Will increasing CONFIG_AP_LIST_SIZE also break OTA2?

             

            thank you

            • 3. Re: configure wifi client at run time
              chuntkincaid_3807591

              Hey I saw this and I found a post a while back that had a solution for your first and second questions - I cant find it so ill just tell you what I integrated into my app.

               

              the wifi_config_dct.h file has provisions for multiple entries already. You can define a second AP like this:

               

              #define CLIENT_AP_2_SSID                      "genericssid"

              #define CLIENT_AP_2_PASSPHRASE      "generic pass"

              #define CLIENT_AP_2_BSS_TYPE             WICED_BSS_TYPE_INFRASTRUCTURE

              #define CLIENT_AP_2_SECURITY             WICED_SECURITY_WPA2_MIXED_PSK

              #define CLIENT_AP_2_CHANNEL              1

              #define CLIENT_AP_2_BAND                      WICED_802_11_BAND_5GHZ

               

              as you can see, pretty easy. Now the limit if 2 is imposed in the WICE/internal/unit/dct.c file. if you want to add more entries you can add some lines in here. find the line <#if defined(CLIENT_AP_2_SSID)> and under that sections endif, add these lines:

               

              #if defined(CLIENT_AP_3_SSID)

              #define DEFAULT_AP_LIST_ENTRY_3 \

                  [2] = \

                  {     \

                      .details = {{sizeof(CLIENT_AP_3_SSID)-1, CLIENT_AP_3_SSID},{{0,0,0,0,0,0}}, 0, 0, CLIENT_AP_3_BSS_TYPE, CLIENT_AP_3_SECURITY, CLIENT_AP_3_CHANNEL, CLIENT_AP_3_BAND}, \

                      .security_key_length = sizeof(CLIENT_AP_3_PASSPHRASE)-1, \

                      .security_key = CLIENT_AP_3_PASSPHRASE \

                  },

               

               

              #else

              #define DEFAULT_AP_LIST_ENTRY_3

              #endif

               

              then, right below that you should see a line <#define DEFAULT_AP_LIST  \>, in that section, under <DEFAULT_AP_LIST_ENTRY_2 \>, add the line:

               

              DEFAULT_AP_LIST_ENTRY_3 \

               

              and thats the whole process for adding another AP entry. For the third entry in the config_dct, just change the 2's to 3's.

               

              The behavior on calling wiced_network_up() is a bit different - if it should fail to join the first network, it will try the second, then third, and so on if they keep failing, so keep that in mind -> that isn't necessarily a good thing all the time (as in my case), and if you used this method you would still need to swap the dct entries everytime you wanted to change networks, so I went a different way and it uses the method in the post that RaktimR_11 mentioned above -  add a few #defines with all your different AP names and pass them to the read_write_dct function after you've disconnected from the prev network.

               

              As for if this breaks OTA2 support, I have no idea, and id also be curious to know. RaktimR_11 , any ideas?