How do I dynamically change the SSID and write the new value into the DCT so it remains upon reboot?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

How do I dynamically change the SSID and write the new value into the DCT so it remains upon reboot?

I need a code snippet that does this. In my use case, it can be done before or after the wiced_network_up().

0 Likes
1 Solution
MiDe_2164101
Level 3
Level 3
Welcome! First question asked First solution authored

Something like this.  Few bits and pieces of my code cut out.

     wiced_result_t   result;

     platform_dct_wifi_config_t* wifi_config_dct_local = NULL;

     char new_ssid[33] = "mynewssid";

     /* Read the Wi-Fi config from the DCT */

     result = wiced_dct_read_lock( (void**) &wifi_config_dct_local, WICED_TRUE, DCT_WIFI_CONFIG_SECTION, 0, sizeof( platform_dct_wifi_config_t ) );

     if ( result != WICED_SUCCESS )

     {

         return result;

     }

     memcpy((char*)wifi_config_dct_local->soft_ap_settings.SSID.value, (char*)new_ssid, strlen(new_ssid));

     wifi_config_dct_local->soft_ap_settings.SSID.length =  strlen(new_ssid);

     /* Write the modified config back into the DCT */

     result = wiced_dct_write ( (const void*)wifi_config_dct_local, DCT_WIFI_CONFIG_SECTION, 0, sizeof (platform_dct_wifi_config_t) );

     wiced_dct_read_unlock( (void*)wifi_config_dct_local, WICED_TRUE );

     if ( result != WICED_SUCCESS )

     {

    printf("Error writing DCT\r\n");

         return result;

     } else {

    printf("Success writing DCT\r\n");

     }

View solution in original post

1 Reply
MiDe_2164101
Level 3
Level 3
Welcome! First question asked First solution authored

Something like this.  Few bits and pieces of my code cut out.

     wiced_result_t   result;

     platform_dct_wifi_config_t* wifi_config_dct_local = NULL;

     char new_ssid[33] = "mynewssid";

     /* Read the Wi-Fi config from the DCT */

     result = wiced_dct_read_lock( (void**) &wifi_config_dct_local, WICED_TRUE, DCT_WIFI_CONFIG_SECTION, 0, sizeof( platform_dct_wifi_config_t ) );

     if ( result != WICED_SUCCESS )

     {

         return result;

     }

     memcpy((char*)wifi_config_dct_local->soft_ap_settings.SSID.value, (char*)new_ssid, strlen(new_ssid));

     wifi_config_dct_local->soft_ap_settings.SSID.length =  strlen(new_ssid);

     /* Write the modified config back into the DCT */

     result = wiced_dct_write ( (const void*)wifi_config_dct_local, DCT_WIFI_CONFIG_SECTION, 0, sizeof (platform_dct_wifi_config_t) );

     wiced_dct_read_unlock( (void*)wifi_config_dct_local, WICED_TRUE );

     if ( result != WICED_SUCCESS )

     {

    printf("Error writing DCT\r\n");

         return result;

     } else {

    printf("Success writing DCT\r\n");

     }