ESP8266 Developer Zone The Official ESP8266 Forum 2017-05-18T01:45:20+08:00 https://bbs.espressif.com:443/feed.php?f=66&t=4248 2017-05-18T01:45:20+08:00 2017-05-18T01:45:20+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13208#p13208 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]> Statistics: Posted by gustavomassa — Thu May 18, 2017 1:45 am


]]>
2017-05-16T21:19:29+08:00 2017-05-16T21:19:29+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13174#p13174 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]>
Thank you for updating the manual this is helpful : )

Statistics: Posted by curiousmuch — Tue May 16, 2017 9:19 pm


]]>
2017-05-16T13:24:25+08:00 2017-05-16T13:24:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13156#p13156 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]>
The documentation has been updated, please refer to the Section 2.2 of 20A-ESP8266__RTOS_SDK__Programming Guide.

Thanks for your reporting!

Statistics: Posted by ESP_Faye — Tue May 16, 2017 1:24 pm


]]>
2017-05-16T09:53:08+08:00 2017-05-16T09:53:08+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13148#p13148 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]> Statistics: Posted by curiousmuch — Tue May 16, 2017 9:53 am


]]>
2017-05-15T21:54:25+08:00 2017-05-15T21:54:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13136#p13136 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]>

while(1); should not be used, if the task is always in RUNNING state, the other tasks of which priority is lower will not execute.
You need to suspend it or block it. http://www.freertos.org/RTOS-task-states.html
Usually, messages will be used for task.


Opps. I just noticed the extra semi-colon. Thanks! : ) This should have been the following:

Code:

while(1)
   vTaskDelay(1000);


The task should unblock now. Nevertheless, I believe Espressif has the priority for system tasks too low.

System tasks should have the highest priority and if they're not the highest priority Espressif should specify what the priority of the tasks are so developers don't have to spend significant time dicking around creating test cases to determine themselves. I don't understand why they would specify users can create tasks with priorities 1-9, but then create tasks crucial to the SDK operation at priorities lower than 9.

Statistics: Posted by curiousmuch — Mon May 15, 2017 9:54 pm


]]>
2017-05-15T17:05:13+08:00 2017-05-15T17:05:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13131#p13131 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]> You need to suspend it or block it. http://www.freertos.org/RTOS-task-states.html
Usually, messages will be used for task.

Statistics: Posted by Her Mary — Mon May 15, 2017 5:05 pm


]]>
2017-05-14T00:54:33+08:00 2017-05-14T00:54:33+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13063#p13063 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]> Statistics: Posted by curiousmuch — Sun May 14, 2017 12:54 am


]]>
2017-05-12T04:26:28+08:00 2017-05-12T04:26:28+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13001#p13001 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]> )

I'm sorry I cannot attach binaries. There forum doesn't appear to support it.

Code:

/*
 * ESPRSSIF MIT License
 *
 * Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
 *
 * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
 * it is free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#include "esp_common.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"

void wifi_handle_event_cb(System_Event_t *evt);


/******************************************************************************
 * FunctionName : user_rf_cal_sector_set
 * Description  : SDK just reversed 4 sectors, used for rf init data and paramters.
 *                We add this function to force users to set rf cal sector, since
 *                we don't know which sector is free in user's application.
 *                sector map for last several sectors : ABCCC
 *                A : rf cal
 *                B : rf init data
 *                C : sdk parameters
 * Parameters   : none
 * Returns      : rf cal sector
*******************************************************************************/
uint32 user_rf_cal_sector_set(void)
{
    flash_size_map size_map = system_get_flash_size_map();
    uint32 rf_cal_sec = 0;

    switch (size_map) {
        case FLASH_SIZE_4M_MAP_256_256:
            rf_cal_sec = 128 - 5;
            break;

        case FLASH_SIZE_8M_MAP_512_512:
            rf_cal_sec = 256 - 5;
            break;

        case FLASH_SIZE_16M_MAP_512_512:
        case FLASH_SIZE_16M_MAP_1024_1024:
            rf_cal_sec = 512 - 5;
            break;

        case FLASH_SIZE_32M_MAP_512_512:
        case FLASH_SIZE_32M_MAP_1024_1024:
            rf_cal_sec = 1024 - 5;
            break;

        default:
            rf_cal_sec = 0;
            break;
    }

    return rf_cal_sec;
}

/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
#include "uart.h"
#include "gpio.h"

void wifi_handle_event_cb(System_Event_t *evt)
{
    os_printf("Inside Custom Event Handler\n");
    switch (evt->event_id) {
         case EVENT_STAMODE_CONNECTED:
         {
             printf("connect to ssid %s, channel %d\n",
             evt->event_info.connected.ssid,
             evt->event_info.connected.channel);
             break;
         }
         case EVENT_STAMODE_DISCONNECTED:
             printf("disconnect from ssid %s, reason %d\n",
             evt->event_info.disconnected.ssid,
             evt->event_info.disconnected.reason);
             break;
         case EVENT_STAMODE_AUTHMODE_CHANGE:
             printf("mode: %d -> %d\n",
             evt->event_info.auth_change.old_mode,
             evt->event_info.auth_change.new_mode);
             break;
         case EVENT_STAMODE_GOT_IP:
             printf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
             IP2STR(&evt->event_info.got_ip.ip),
             IP2STR(&evt->event_info.got_ip.mask),
             IP2STR(&evt->event_info.got_ip.gw));
             printf("\n");
             break;
         case EVENT_SOFTAPMODE_STACONNECTED:
             printf("station: " MACSTR "join, AID = %d\n",
             MAC2STR(evt->event_info.sta_connected.mac),
             evt->event_info.sta_connected.aid);
             break;
         case EVENT_SOFTAPMODE_STADISCONNECTED:
             printf("station: " MACSTR "leave, AID = %d\n",
             MAC2STR(evt->event_info.sta_disconnected.mac),
             evt->event_info.sta_disconnected.aid);
             break;
         default:
             break;
 }
}

#define MAX_STATIONS 5
#define DEFAULT_SSID "curiousmuch?"
#define DEFAULT_PASSWORD "MBg4Nqd8"

void wifi_controller(void *pvParameters)
{
    printf("Starting Wi-Fi Controller...\n");

    // setup inital Wi-Fi parameters
    struct station_config * config =   (struct   station_config   *)zalloc(sizeof(struct
        station_config));
    sprintf(config->ssid, DEFAULT_SSID);
    sprintf(config->password, DEFAULT_PASSWORD);

    wifi_set_event_handler_cb(wifi_handle_event_cb);
    wifi_station_ap_number_set(MAX_STATIONS);
    wifi_set_opmode(STATION_MODE);
    wifi_station_set_config(config);
    free(config);
    wifi_station_connect();

    while(1);
        vTaskDelay(100000);
}


#include "uart.h"

void user_init(void)
{
    uart_init_new();  // initial UART (move to main or user config)
    printf("SDK version:%s :)\n\r", system_get_sdk_version());

    // functions which must be called in user_init()
    wifi_station_set_auto_connect(false);
    wifi_station_set_reconnect_policy(false);


    printf("Creating Task(s)\n");
    xTaskCreate(wifi_controller, "wifi_contoller", 500, NULL, 6, NULL);

}

Statistics: Posted by curiousmuch — Fri May 12, 2017 4:26 am


]]>
2017-05-12T04:08:36+08:00 2017-05-12T04:08:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=13000#p13000 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]>
ESP_Faye wrote:
Hi,

Sorry that we cannot duplicate your problem, could you provide your test code which can duplicate the problem?

Thanks for your interest in ESP8266!


Absolutely! I'll post code soon along with binaries. Thank you for the response!

Statistics: Posted by curiousmuch — Fri May 12, 2017 4:08 am


]]>
2017-05-09T09:47:20+08:00 2017-05-09T09:47:20+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=12912#p12912 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]>
Sorry that we cannot duplicate your problem, could you provide your test code which can duplicate the problem?

Thanks for your interest in ESP8266!

Statistics: Posted by ESP_Faye — Tue May 09, 2017 9:47 am


]]>
2017-05-06T14:54:34+08:00 2017-05-06T14:54:34+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=12842#p12842 <![CDATA[Re: RTOS 1.5 Bug wifi_set_event_handler_cb]]> Statistics: Posted by curiousmuch — Sat May 06, 2017 2:54 pm


]]>
2017-05-04T03:58:30+08:00 2017-05-04T03:58:30+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4248&p=12759#p12759 <![CDATA[RTOS 1.5 Bug wifi_set_event_handler_cb]]>
The wifi_set_event_handler_cb() will not set the callback function if a task with a priority of 6 is started in the user_init(). I have yet to try a higher task priorities yet. The documentation lists that users can set task priority to be from 1-9?

Can Espressif please specify what are the priorities for system tasks or provide a fix.

Thanks guys!

Statistics: Posted by curiousmuch — Thu May 04, 2017 3:58 am


]]>