Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic wifi_country_t.cc is not a modifiable lvalue (Read 1225 times)
The_Specialist
Full Member
***
Offline


Posts: 228
Joined: Jul 1st, 2020
wifi_country_t.cc is not a modifiable lvalue
Nov 6th, 2022 at 1:37pm
Print Post  
intellisens: C++ expression must be a modifiable lvalue

Code (C++)
Select All
#include "esp_wifi.h" (part of IDF (C) component in Arduino ESP32)

    wifi_country_t wifi_country;
    char code[3] = "US";
    //char *code = "US";
    wifi_country.cc = &code;//char[3]country code string 



The typdef

Code (C++)
Select All
/** @brief Structure describing WiFi country-based regional restrictions. */
typedef struct {
    char                  cc[3];   /**< country code string */
    uint8_t               schan;   /**< start channel */
    uint8_t               nchan;   /**< total channel number */
    int8_t                max_tx_power;   /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */
    wifi_country_policy_t policy;  /**< country policy */
} wifi_country_t; 



if I change the typdef of cc to a pointer the problem disapears. I think it is because the size or the array is after the name of the array in a structure.
« Last Edit: Nov 9th, 2022 at 9:51am by The_Specialist »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: wifi_country_t.cc is not a modifiable lvalue
Reply #1 - Nov 7th, 2022 at 2:26am
Print Post  
Is this a build or an intellisense problem?
  
Back to top
IP Logged
 
The_Specialist
Full Member
***
Offline


Posts: 228
Joined: Jul 1st, 2020
Re: wifi_country_t.cc is not a modifiable lvalue
Reply #2 - Nov 9th, 2022 at 9:49am
Print Post  
intellisense and build problem. In the rc version I have it too with this output when building.

esp32-WiFi.h: 279:23: error: invalid array assignment
Error compiling project sources
   wifi_country.cc = code;\\char[3]country code string
Debug build failed for project 'Sketch2'
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: wifi_country_t.cc is not a modifiable lvalue
Reply #3 - Nov 9th, 2022 at 11:57am
Print Post  
Thanks for the report.

Reviewing the ESP32 API documentation, they suggest these values are best not set individually by the user (assuming it is being passed into this function eventually):
Code
Select All
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv420esp_wifi_set_countryPK14wifi_country_t 



The country code is best set using the set country code function:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/networ...

But this can be done if required when creating the variable:
Code
Select All
wifi_country_t wifi_country = { .cc = "01", .schan = 1, .nchan = 11, .policy = WIFI_COUNTRY_POLICY_AUTO }; 

  
Back to top
IP Logged
 
The_Specialist
Full Member
***
Offline


Posts: 228
Joined: Jul 1st, 2020
Re: wifi_country_t.cc is not a modifiable lvalue
Reply #4 - Nov 9th, 2022 at 12:32pm
Print Post  
I didn't try to set them, I was just trying the get. 

Code (C++)
Select All
void setCountry() {
    ////before esp_wifi_start
    esp_err_t err;
    wifi_country_policy_t wifi_country_policy;
    //wifi_country_policy = WIFI_COUNTRY_POLICY_AUTO;//WIFI_COUNTRY_POLICY_MANUAL
    //wifi_country_t wifi_country;
    //char code[3] = "US";
    ////char *code = "US";
    //wifi_country.cc = code;//char[3]country code string
    //wifi_country.schan = 0;//uint8_t start channel
    //wifi_country.nchan = 13;//uint8_t total channel number
    ////wifi_country.max_tx_power = esp_wifi_set_max_tx_power;//int8_t esp_wifi_set_max_tx_power to set the maximum transmitting power

    wifi_country_t wifi_country = { .cc = "US", .schan = 1, .nchan = 11, .policy = WIFI_COUNTRY_POLICY_AUTO };

    err = esp_wifi_set_country(&wifi_country);
} 




But it works now by defining it in an array. It's recognized and compiling now. Thanks!

It's amazing how I can program with extern C now. It is indeed a big improvement! Cheesy
« Last Edit: Nov 11th, 2022 at 1:07am by The_Specialist »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: wifi_country_t.cc is not a modifiable lvalue
Reply #5 - Dec 22nd, 2022 at 11:03pm
Print Post  
This Topic was moved here from Visual Studio 2017, 2019, 2022 [move by] Tim@Visual Micro.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint