I am struggling to connect to an ESP32-Wrover-B's softAP.
I have PIN 17 and PIN 19 acting as TX, respectively as RX. They are connected to a CubeOrange flight controller as I am trying to establish a serial communication.
And whenever they are connected, the softAP won't assign an IP address to the device that I am trying to connect with.
But, it works properly when I do not have any GPIO connections.
The drone Serial Port has 3v3 signals: https://github.com/ArduPilot/ardupilot/ ... /CubeBlack I am using PIN17 and PIN19 as they are labeled on the board.
In code they are written as GPIO_NUM_17 and GPIO_NUM_19.
First question: are they the same on the Wrover ? Is PIN17 the same as GPIO17 ? The same with 19.
I am asking this because I have tried using PIN16(as labeled on the board) as GPIO_NUM_16 an it did not work.
Second question: can the GPIOs state affect WiFi in some way ?
softAP starts and then stops without giving the device that I am trying to connect with an IP address.
Code: Select all
I (112188) wifi: new:<1,0>, old:<1,0>, ap:<1,0>, sta:<255,255>, prof:1
I (112188) wifi: station: 2e:fa:09:ac:34:43 join, AID=1, b, 20
␛[0;32mI (112268) DB_ESP32: Wifi AP started!␛[0m
I (130488) wifi: station: 2e:fa:09:ac:34:43 leave, AID = 1, bss_flags is 131121, bss:0x3ffc935c
I (130488) wifi: new:<1,0>, old:<1,0>, ap:<1,0>, sta:<255,255>, prof:1
␛[0;32mI (130488) DB_ESP32: Wifi AP stopped!␛[0m
It is not my code.
Code: Select all
static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
{
wifi_event_ap_staconnected_t *event;
wifi_event_ap_stadisconnected_t* evente;
switch (event_id) {
case SYSTEM_EVENT_AP_START:
ESP_LOGI(TAG, "Wifi AP started!");
xEventGroupSetBits(wifi_event_group, BIT2);
break;
case SYSTEM_EVENT_AP_STOP:
ESP_LOGI(TAG, "Wifi AP stopped!");
break;
case SYSTEM_EVENT_AP_STACONNECTED:
event = (wifi_event_ap_staconnected_t *) event_data;
ESP_LOGI(TAG, "Client connected - station:"MACSTR", AID=%d", MAC2STR(event->mac), event->aid);
break;
case SYSTEM_EVENT_AP_STADISCONNECTED:
evente = (wifi_event_ap_stadisconnected_t*) event_data;
ESP_LOGI(TAG, "Client disconnected - station:"MACSTR", AID=%d",
MAC2STR(evente->mac), evente->aid);
break;
default:
break;
}
}
void start_mdns_service()
{
xEventGroupWaitBits(wifi_event_group, BIT2, false, true, portMAX_DELAY);
//initialize mDNS service
esp_err_t err = mdns_init();
if (err) {
printf("MDNS Init failed: %d\n", err);
return;
}
ESP_ERROR_CHECK(mdns_hostname_set("dronebridge"));
ESP_ERROR_CHECK(mdns_instance_name_set("DroneBridge for ESP32"));
ESP_ERROR_CHECK(mdns_service_add(NULL, "_http", "_tcp", 80, NULL, 0));
ESP_ERROR_CHECK(mdns_service_add(NULL, "_db_proxy", "_tcp", APP_PORT_PROXY, NULL, 0));
ESP_ERROR_CHECK(mdns_service_add(NULL, "_db_comm", "_tcp", APP_PORT_COMM, NULL, 0));
ESP_ERROR_CHECK(mdns_service_instance_name_set("_http", "_tcp", "DroneBridge for ESP32"));
}
void init_wifi(){
wifi_event_group = xEventGroupCreate();
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_create_default());
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
wifi_config_t ap_config = {
.ap = {
.ssid = "Init DroneBridge ESP32",
.ssid_len = 0,
.authmode = WIFI_AUTH_WPA_PSK,
.channel = DEFAULT_CHANNEL,
.ssid_hidden = 0,
.beacon_interval = 100,
.max_connection = 10
},
};
xthal_memcpy(ap_config.ap.ssid, DEFAULT_SSID, 32);
xthal_memcpy(ap_config.ap.password, DEFAULT_PWD, 64);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_protocol(ESP_IF_WIFI_AP, WIFI_PROTOCOL_11B));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));
wifi_country_t wifi_country = {.cc = "XX", .schan = 1, .nchan = 13, .policy = WIFI_COUNTRY_POLICY_MANUAL};
ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country));
ESP_ERROR_CHECK(esp_wifi_start());
ESP_ERROR_CHECK(tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_AP, "DBESP32"));
ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
tcpip_adapter_ip_info_t ip_info;
IP4_ADDR(&ip_info.ip, 192,168,2,1);
IP4_ADDR(&ip_info.gw, 192,168,2,1);
IP4_ADDR(&ip_info.netmask, 255,255,255,0);
ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &ip_info));
ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP));
}