Fix some WiFi issues (#5395)
* Add back ARDUINO_EVENT_WIFI_READY Fixes: https://github.com/espressif/arduino-esp32/issues/5315 * use strncpy and strncmp for WiFi SSID and Password in AP and STA Fixes: https://github.com/espressif/arduino-esp32/issues/5367 * Implement timeout for waitForConnectResult Fixes: https://github.com/espressif/arduino-esp32/issues/5330 * Remove old definition of "reverse" from stdlib_noniso Fixes: https://github.com/espressif/arduino-esp32/issues/5045 * Make "reverse" noniso conditional on ESP_DSP
This commit is contained in:
parent
cf6ab9c8a3
commit
dd25e2b9d6
@ -28,7 +28,9 @@
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "stdlib_noniso.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
#if !CONFIG_DSP_ANSI && !CONFIG_DSP_OPTIMIZED
|
||||
void reverse(char* begin, char* end) {
|
||||
char *is = begin;
|
||||
char *ie = end - 1;
|
||||
@ -40,6 +42,9 @@ void reverse(char* begin, char* end) {
|
||||
--ie;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void reverse(char* begin, char* end);
|
||||
#endif
|
||||
|
||||
char* ltoa(long value, char* result, int base) {
|
||||
if(base < 2 || base > 16) {
|
||||
|
||||
@ -60,10 +60,10 @@ static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& r
|
||||
*/
|
||||
static bool softap_config_equal(const wifi_config_t& lhs, const wifi_config_t& rhs)
|
||||
{
|
||||
if(strcmp(reinterpret_cast<const char*>(lhs.ap.ssid), reinterpret_cast<const char*>(rhs.ap.ssid)) != 0) {
|
||||
if(strncmp(reinterpret_cast<const char*>(lhs.ap.ssid), reinterpret_cast<const char*>(rhs.ap.ssid), 32) != 0) {
|
||||
return false;
|
||||
}
|
||||
if(strcmp(reinterpret_cast<const char*>(lhs.ap.password), reinterpret_cast<const char*>(rhs.ap.password)) != 0) {
|
||||
if(strncmp(reinterpret_cast<const char*>(lhs.ap.password), reinterpret_cast<const char*>(rhs.ap.password), 64) != 0) {
|
||||
return false;
|
||||
}
|
||||
if(lhs.ap.channel != rhs.ap.channel) {
|
||||
@ -98,12 +98,12 @@ void wifi_softap_config(wifi_config_t *wifi_config, const char * ssid=NULL, cons
|
||||
wifi_config->ap.password[0] = 0;
|
||||
wifi_config->ap.ftm_responder = ftm_responder;
|
||||
if(ssid != NULL && ssid[0] != 0){
|
||||
snprintf((char*)wifi_config->ap.ssid, 32, ssid);
|
||||
strncpy((char*)wifi_config->ap.ssid, ssid, 32);
|
||||
wifi_config->ap.ssid_len = strlen(ssid);
|
||||
if(password != NULL && password[0] != 0){
|
||||
wifi_config->ap.authmode = authmode;
|
||||
wifi_config->ap.pairwise_cipher = WIFI_CIPHER_TYPE_CCMP; // Disable by default enabled insecure TKIP and use just CCMP.
|
||||
snprintf((char*)wifi_config->ap.password, 64, password);
|
||||
strncpy((char*)wifi_config->ap.password, password, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -567,6 +567,11 @@ bool wifiLowLevelInit(bool persistent){
|
||||
if(!persistent){
|
||||
lowLevelInitDone = esp_wifi_set_storage(WIFI_STORAGE_RAM) == ESP_OK;
|
||||
}
|
||||
if(lowLevelInitDone){
|
||||
arduino_event_t arduino_event;
|
||||
arduino_event.event_id = ARDUINO_EVENT_WIFI_READY;
|
||||
postArduinoEvent(&arduino_event);
|
||||
}
|
||||
}
|
||||
return lowLevelInitDone;
|
||||
}
|
||||
|
||||