2017-12-11 16 views
1

내가 이해하지 못하는 구조가 있습니다의 구조를 설명 ESP32 변수

typedef struct { 
    uint8_t ssid[32]; /**< SSID of target AP*/ 
    uint8_t password[64]; /**< password of target AP*/ 
    wifi_scan_method_t scan_method; /**< do all channel scan or fast scan */ 
    bool bssid_set; 
    /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/ 
    uint8_t bssid[6]; /**< MAC address of target AP*/ 
    uint8_t channel; 
    /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/ 
    wifi_sort_method_t sort_method; 
    /**< sort the connect AP in the list by rssi or security mode */ 
    wifi_fast_scan_threshold_t threshold; 
    /**< When scan_method is set to WIFI_FAST_SCAN, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */ 
} wifi_sta_config_t; 

가 "#define에 의해 정의"값을 할당하여 initualized된다

wifi_config_t wifi_config = { 
    .sta = { 
    .ssid = WIFI_AP_NAME, 
    .password = WIFI_AP_PASS, 
    .bssid_set = 0 
    }, 
}; 

WIFI_AP_NAMEWIFI_AP_PASS이 정의를 like :

#define WIFI_AP_NAME CONFIG_WIFI_SSID 
#define CONFIG_WIFI_SSID "myssid" 

이제 :

char *wifi_ssid=mynvs_read(WIFI_SSID_TYPE); 
char *wifi_pass=mynvs_read(WIFI_PASS_TYPE); 

는 그리고 나는 wifi_config 구조 .ssid.password에이 값을 할당해야합니다.

어떻게 수행하나요? 간단한 할당 오류가 발생하기 때문에 :

wifi_config_t wifi_config = { 
    .sta = { 
    .ssid = wifi_ssid, 
    .password = wifi_pass, 
    .bssid_set = 0 
    }, 
}; 

error: missing braces around initializer [-Werror=missing-braces]

내가 strcpy를 값으로 할 때, 내가 가지고 :

bssid_set = 0 
:

답변

0

구조 정의 마렉

error: pointer targets in passing argument 1 of 'strcpy' differ in signedness [-Werror=pointer-sign] 
     strcpy(wifi_config.sta.password,wifi_pass); 

안부

너의 코드 :

.bssid_set = 0 

어떤 차이가 있습니까?

+0

네,이 코드는 [설명 포함] 문제를 해결할 수 있지만 내가 // meta.stackexchange (이 – user2018761

0

이 사람은 나를 위해 작동 :

strcpy((unsigned char)wifi_config.sta.ssid,(unsigned char)mynvs_wifi_ssid); 
+0

를 해결하는 점이 있어야한다. com/questions/114762/explain-entire-code-based-answers)은 게시물의 품질을 향상시키는 데 정말로 도움이됩니다. 앞으로 독자의 질문에 답하고 있으며 코드 제안의 이유를 알지 못할 수도 있습니다. 또한 주석을 설명하기 위해 코드를 군중시키지 마십시오. 그러면 코드와 설명 모두 가독성이 떨어집니다! – kayess