Files
Espressif Systems 76a22b42c6 1. memory optimize;
2. support both libminic and libc;
3. fix some fatal exception bugs;
4. remove udhcp related files;
5. sync third_party files;
6. other minor changes;
2015-07-14 11:06:53 +08:00

88 lines
2.4 KiB
C

/******************************************************************************
* Copyright 2013-2014 Espressif Systems (Wuxi)
*
* FileName: user_main.c
*
* Description: entry file of user application
*
* Modification history:
* 2014/12/1, v1.0 create this file.
*******************************************************************************/
#include "esp_common.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
#define server_ip "192.168.101.142"
#define server_port 9669
sc_type SC_Type = 0;
void ICACHE_FLASH_ATTR
smartconfig_done(sc_status status, void *pdata)
{
switch(status) {
case SC_STATUS_WAIT:
printf("SC_STATUS_WAIT\n");
break;
case SC_STATUS_FIND_CHANNEL:
printf("SC_STATUS_FIND_CHANNEL\n");
break;
case SC_STATUS_GETTING_SSID_PSWD:
printf("SC_STATUS_GETTING_SSID_PSWD\n");
break;
case SC_STATUS_LINK:
printf("SC_STATUS_LINK\n");
struct station_config *sta_conf = pdata;
wifi_station_set_config(sta_conf);
wifi_station_disconnect();
wifi_station_connect();
break;
case SC_STATUS_LINK_OVER:
printf("SC_STATUS_LINK_OVER\n");
if (SC_Type == SC_TYPE_ESPTOUCH) {
uint8 phone_ip[4] = {0};
memcpy(phone_ip, (uint8*)pdata, 4);
printf("Phone ip: %d.%d.%d.%d\n",phone_ip[0],phone_ip[1],phone_ip[2],phone_ip[3]);
}
smartconfig_stop();
break;
}
}
void ICACHE_FLASH_ATTR
smartconfig_task(void *pvParameters)
{
SC_Type = SC_TYPE_ESPTOUCH;
smartconfig_start(SC_Type, smartconfig_done);//SC_TYPE_AIRKISS
vTaskDelete(NULL);
}
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_init(void)
{
printf("SDK version:%s\n", system_get_sdk_version());
/* need to set opmode before you set config */
wifi_set_opmode(STATION_MODE);
xTaskCreate(smartconfig_task, "smartconfig_task", 256, NULL, 2, NULL);
}