Help using wifi_set_event_handler_cb with esp_open_rtos

202 views
Skip to first unread message

desha....@gmail.com

unread,
Oct 30, 2016, 1:50:55 AM10/30/16
to esp-open-rtos mailing list
Hi Forum,

I am new to esp-open-rtos and keen to learn how to use it.  I would like to create an example that allows me to see the state of the wifi connection.  After reading the espressif RTOS SDK I saw the wifi_set_event_handler_cb callback and I thought I would try to get an exampled working using esp-open-rtos.

However, I cannot figure out the include files to use for the System_Event_t type.  I tried user_interface.h but this go more errors, about already defined types.

Could some point me towards what include files I should use?

Please find attached the basic code I tried to comiple using make flash -j4 -C examples/test/ ESPPORT=/dev/ttyUSB0

example/test/test.c

#include "espressif/esp_common.h"
#include "esp/uart.h"
#include "FreeRTOS.h"
#include "ssid_config.h"

void broadcast_temperature(void *pvParameters)
{
    while (1){}
}

void wifi_cb(System_Event_t *evt)
{
  os_printf("event %x\n", evt->event);
  switch (evt->event) {
    case EVENT_STAMODE_CONNECTED:
        os_printf("connect to ssid %s, channel %d\n",
                evt->event_info.connected.ssid,
                evt->event_info.connected.channel);
        break;
    case EVENT_STAMODE_DISCONNECTED:
        os_printf("disconnect from ssid %s, reason %d\n",
                evt->event_info.disconnected.ssid,
                evt->event_info.disconnected.reason);
        break;
    case EVENT_STAMODE_AUTHMODE_CHANGE:
        os_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:
        os_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));
        os_printf("\n");
        break;
    default:
        break;
    }
}

void  user_init()
{
    uart_set_baud(0, 115200);
    printf("SDK version:%s\n", sdk_system_get_sdk_version());

    struct sdk_station_config config = {
        .ssid = WIFI_SSID,
        .password = WIFI_PASS,
    };
    sdk_wifi_set_opmode(STATION_MODE);
    sdk_wifi_station_set_config(&config);

    wifi_set_event_handler_cb(wifi_cb);

    xTaskCreate(&broadcast_temperature, "broadcast_temperature", 256, NULL, 2, NULL);
}

Thanks

Densha

nishant agrawal

unread,
Nov 7, 2016, 5:20:28 AM11/7/16
to esp-open-rtos mailing list
I don't think it has a similar function. You can use sdk_wifi_station_get_connect_status to get the status and work further.
Reply all
Reply to author
Forward
0 new messages