WiFi Station crashes after HTTP request

aaquilina
Posts: 43
Joined: Fri Jan 20, 2017 3:10 pm

WiFi Station crashes after HTTP request

Postby aaquilina » Fri Jul 14, 2017 7:21 am

Hi,

I have recently upgraded my framework to the latest version and the code I had written to handle TCP and HTTP over WiFi keeps crashing after a couple of HTTP requests. I'm getting an "bcn_timout, ap_probe_send_start" log. I attached the log below. I also have Ethernet code which works perfectly and uses the same event handler/TCP/HTTP tasks. The only difference (as far as I can see) is the different initialization tasks for the physical layer. Is there anything wrong with my WiFi initialisation code? First networkInit() is called followed by networkConnect(). Any thoughts on what I can try to troubleshoot the issue?

PS As can be seen in the log the GET requests come in, the file which is required to service is read from memory but it is either completely not transmitted or partly not transmitted.

Code: Select all

void networkInit()
{
    ESP_LOGI(TAG, "networkInit");
    ESP_ERROR_CHECK( esp_event_loop_init(eventHandler, NULL) );
    tcpip_adapter_init();
    sEventGroup = xEventGroupCreate();
	/* Was the event group created successfully? */
    if( sEventGroup == NULL )
    {
        /* The event group was not created because there was insufficient
        FreeRTOS heap available. */
		ESP_LOGE(TAG,"networkInit: sEventGroup could not be created due to insufficient heap");
		esp_restart();
    }
    else
    {
		ESP_LOGI(TAG, "networkInit: Successfully created sEventGroup");
        /* The event group was created. */
    }
}

Code: Select all

void networkConnect(const char *ssid, const char *wifien, const char *password, const char *ip, const char *dgw, const char *snm)
{
	esp_err_t err = ESP_OK;
	uint8_t sta_wifien = atoi(wifien);
	BaseType_t xReturned;
    ESP_LOGI(TAG, "networkConnect %s", ssid);
	if (sta_wifien == 1)
	{		
		// Reduce noise caused by Ethernet clock
		phy_device_power_enable_via_gpio(false);
		tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); // Don't run a DHCP client

		inet_pton(AF_INET, &ip[0], &ipInfo.ip);
		inet_pton(AF_INET, &dgw[0], &ipInfo.gw);
		inet_pton(AF_INET, &snm[0], &ipInfo.netmask);
		tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &ipInfo);

		wifi_init_config_t wlanInitConfig = WIFI_INIT_CONFIG_DEFAULT();
		ESP_ERROR_CHECK(esp_wifi_init(&wlanInitConfig));
		ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));
		wifi_config_t wlanStaConfig;
		strncpy((char*)wlanStaConfig.sta.ssid, ssid, sizeof(wlanStaConfig.sta.ssid) / sizeof(char));
		strncpy((char*)wlanStaConfig.sta.password, password, sizeof(wlanStaConfig.sta.password) / sizeof(char));
		wlanStaConfig.sta.bssid_set = false;
		ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
		ESP_ERROR_CHECK(esp_wifi_set_country(WIFI_COUNTRY_EU));
		ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wlanStaConfig));
		ESP_ERROR_CHECK(esp_wifi_start());
	}
Image

Who is online

Users browsing this forum: Baidu [Spider], YaCy [Bot] and 145 guests