2017-12-11 18 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が定義されているがこのように:

#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

この1つは私の作品:

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

を修正する点である必要があります。 com/questions/114762/explain-entire-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。あなたのコードに説明的なコメントを詰め込まないようにしてください。これは、コードと説明の両方の可読性を低下させます! – kayess