Statistics: Posted by curiousmuch — Tue May 16, 2017 9:19 pm
Statistics: Posted by ESP_Faye — Tue May 16, 2017 1:24 pm
Code:
while(1)
vTaskDelay(1000);
Statistics: Posted by curiousmuch — Mon May 15, 2017 9:54 pm
Statistics: Posted by Her Mary — Mon May 15, 2017 5:05 pm
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
Statistics: Posted by curiousmuch — Fri May 12, 2017 4:08 am
Statistics: Posted by ESP_Faye — Tue May 09, 2017 9:47 am
Statistics: Posted by curiousmuch — Thu May 04, 2017 3:58 am