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.
Please find attached the basic code I tried to comiple using make flash -j4 -C examples/test/ ESPPORT=/dev/ttyUSB0
#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),
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);
}