资料 淘宝 没啥用 其实还是百度吧
直接上电 USB连接 串口 按一下复位 LED蓝色闪烁一下
前面的乱码 是不同的波特率输出的
开始学校
开始准备环境
https://docs.ai-thinker.com/esp8266/boards/nodemcu
https://blog.csdn.net/Boantong_/article/details/106229281
1--卸载本地python3 因为它需要2.8 自动安装的
2--一路 AiThinkerIDE_V1.5.2.exe 【不在C盘!!!!后面管理员权限是麻烦】
下图无所谓并且下图不好 好是直接无脑C盘比较好 下下图看到OK
自动打开
文字写的很差劲 参考下文可以成功
https://blog.csdn.net/felix_tao/article/details/106698643
https://docs.ai-thinker.com/ai_ide_use 也可以看看
make COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=DIO SPI_SIZE_MAP=6
FLASH按键一次 即可下载 甚至不需要手工按!!全自动!!WHY 因为我的板子是自动的!!!阅读下文
https://blog.csdn.net/iotisan/article/details/84928341
工具包
测试一下 不要GPIO2 用自己LED
用GPIO4
外接一个LED 灌电流 拉电流 都可以OK 板载蓝色的是灌电流
void delay_ms(int a)
{
while(a--)
os_delay_us(1000);
}
#define LED_IO 4
void ICACHE_FLASH_ATTR
user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
os_printf("HELLO KOSON 2021\n");
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);
GPIO_OUTPUT_SET(GPIO_ID_PIN(LED_IO),0);
#if 0
while(1)
{
delay_ms(500);
GPIO_OUTPUT_SET(GPIO_ID_PIN(LED_IO),0);
delay_ms(500);
GPIO_OUTPUT_SET(GPIO_ID_PIN(LED_IO),1);
system_soft_wdt_feed();
}
#endif
}
0-----按键 2---LED 【板子】
按键
void delay_ms(int a)
{
while(a--)
os_delay_us(1000);
}
#define LED_IO 2
bool ledon=true;
void led_blink(void)
{
ledon = !ledon;
GPIO_OUTPUT_SET(GPIO_ID_PIN(LED_IO),ledon);
}
void led_on(void)
{
ledon=true;
GPIO_OUTPUT_SET(GPIO_ID_PIN(LED_IO),0);
}
void KeyInitConfig(void)
{
//1.设置按键所对应的GPIO0口为IO口模式 -- 详见文档3.3.1.1章节
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); // GPIO0设为IO口
//2.由于GPIO0通过R3进行电源上拉,所以GPIO0默认为高电平状态,在这里要将内部拉高取消
PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO0_U);
//3.设定GPIO0引脚为输入模式
GPIO_DIS_OUTPUT(GPIO_ID_PIN(0));
}
//原文链接:https://blog.csdn.net/gyscjl/article/details/82913661
void ICACHE_FLASH_ATTR
user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
os_printf("HELLO KOSON 2021\n");
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U,FUNC_GPIO2);//led
GPIO_OUTPUT_SET(GPIO_ID_PIN(LED_IO),0);
KeyInitConfig();
char key_status=0;
while(1)
{
key_status= GPIO_INPUT_GET(GPIO_ID_PIN(0));
//if(key_status==0)
if(GPIO_INPUT_GET(GPIO_ID_PIN(0))==0)
{led_on(); os_printf("if\n");}
else
{led_blink(); os_printf("else\n");}
delay_ms(300);
system_soft_wdt_feed();
}
}
按键控制LED
使用软件定时器控制
void delay_ms(int a)
{
while(a--)
os_delay_us(1000);
}
#define USE_US_TIMER
os_timer_t stimer;
char led_status=0;
void stimer_cb(void)
{
static int cnt=0;
led_status = !led_status;
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),led_status);
if(++cnt==5) os_timer_disarm(&stimer);
}
void stimer_init(void)
{
os_timer_disarm(&stimer);
os_timer_setfn(&stimer,(os_timer_func_t *)stimer_cb,NULL);
os_timer_arm_us(&stimer,500000,1);
}
void led_init(void)
{
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),1);
led_status=1;
}
void ICACHE_FLASH_ATTR
user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
os_printf("HELLO KOSON 2021\n");
system_timer_reinit();
led_init();
stimer_init();
}
测试AP没有成功 会复位 可能和板子里面估计有关系 一直在搞DHCP 还是led效果
void delay_ms(int a)
{
while(a--)
os_delay_us(1000);
}
#define USE_US_TIMER
os_timer_t stimer;
char led_status=0;
struct station_info *info;
void stimer_cb(void)
{
static int cnt=0;
led_status = !led_status;
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),led_status);
if(++cnt==10) os_timer_disarm(&stimer);
os_printf("--%s--%d--\r\n",__FUNCTION__,__LINE__);
// if(info)
if(0)
{
os_printf("%x.%x.%x.%x.%x.%x is connected!\r\n",\
info->bssid[0],\
info->bssid[1],\
info->bssid[2],\
info->bssid[3],\
info->bssid[4],\
info->bssid[5]);
}
}
void stimer_init(void)
{
os_timer_disarm(&stimer);
os_timer_setfn(&stimer,(os_timer_func_t *)stimer_cb,NULL);
os_timer_arm_us(&stimer,500000,1);
}
void led_init(void)
{
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),1);
led_status=1;
}
void softap_init(void)
{
struct softap_config config;
os_strcpy(config.ssid,"koson");
os_strcpy(config.password,"123456");
config.ssid_len = os_strlen(config.ssid);
config.channel=1;
config.authmode=AUTH_WPA_PSK;
config.ssid_hidden = 0;
config.max_connection=4;
config.beacon_interval=100;
wifi_softap_set_config(&config);
}
void ICACHE_FLASH_ATTR
user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
os_printf("HELLO KOSON 2021\n");
system_timer_reinit();
//uart_init(115200,115200);
os_delay_us(1000);
led_init();
//softap_init();
stimer_init();
#if 0
while(1)
{
delay_ms(500);
system_soft_wdt_feed();
}
#endif
}
此时基本没有程序了
测试还是不行 需要烧4个BIN
跑起来是
https://blog.csdn.net/d521000121/article/details/70196896/
没有写好
发现代码work了!就是wifi的名字没有修改!!!!
手机
为什么名字不OK?看看文字 好了
https://blog.csdn.net/qq_33215476/article/details/100052806
下面是OK的
void delay_ms(int a)
{
while(a--)
os_delay_us(1000);
}
#define USE_US_TIMER
os_timer_t stimer;
char led_status=0;
static struct station_info *info=NULL;
void stimer_cb(void)
{
static int cnt=0;
led_status = !led_status;
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),led_status);
// if(++cnt==10) os_timer_disarm(&stimer);
os_printf("--%s--%d--\r\n",__FUNCTION__,__LINE__);
info = wifi_softap_get_station_info();
if(info)
{
os_printf("[%x.%x.%x.%x.%x.%x] is connected!\r\n",\
info->bssid[0],\
info->bssid[1],\
info->bssid[2],\
info->bssid[3],\
info->bssid[4],\
info->bssid[5]);
}
}
void stimer_init(void)
{
os_timer_disarm(&stimer);
os_timer_setfn(&stimer,(os_timer_func_t *)stimer_cb,NULL);
os_timer_arm_us(&stimer,500000,1);
}
void led_init(void)
{
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),1);
led_status=1;
}
void softap_init(void)
{
struct softap_config config;
os_strcpy(config.ssid,"GKoson");
os_strcpy(config.password,"123456");
config.ssid_len = os_strlen(config.ssid);
config.channel=1;
config.authmode=AUTH_OPEN;//AUTH_WPA_PSK;
config.ssid_hidden = 0;
config.max_connection=4;
config.beacon_interval=100;
wifi_softap_set_config(&config);
}
void ICACHE_FLASH_ATTR
user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
os_printf("HELLO KOSON 2021\n");
system_timer_reinit();
//uart_init(115200,115200);
os_delay_us(1000);
led_init();
softap_init();
stimer_init();
#if 0
while(1)
{
delay_ms(500);
system_soft_wdt_feed();
}
#endif
}
测试的时候 不知道怎么办 手机连接WIFI 使用 APP 现在不行
回答 难度是 UDP服务器--UDP客服端-TCP服务器-TCP客户端
我下面代码是板子作为UDP服务器的 参数只要一个本地PORT即可
手机连接这个WIFI 名字是GKOSON 可以看到 板子自己的ip默认是192.168.4.1 手机进来 手机IP是192.168.4.2 手机APP可以TXRX了
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2016 <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 "ets_sys.h"
#include "osapi.h"
#include "ip_addr.h"
#include "espconn.h"
#include "mem.h"
#include "user_interface.h"
#include "smartconfig.h"
#include "airkiss.h"
#include "driver/uart.h"
#define DEVICE_TYPE "gh_9e2cff3dfa51" //wechat public number
#define DEVICE_ID "122475" //model ID
#define DEFAULT_LAN_PORT 12476
#if ((SPI_FLASH_SIZE_MAP == 0) || (SPI_FLASH_SIZE_MAP == 1))
#error "The flash map is not supported"
#elif (SPI_FLASH_SIZE_MAP == 2)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x81000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0xfb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0xfc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0xfd000
#elif (SPI_FLASH_SIZE_MAP == 3)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x81000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x1fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x1fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x1fd000
#elif (SPI_FLASH_SIZE_MAP == 4)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x81000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x3fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x3fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x3fd000
#elif (SPI_FLASH_SIZE_MAP == 5)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x101000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x1fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x1fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x1fd000
#elif (SPI_FLASH_SIZE_MAP == 6)
#define SYSTEM_PARTITION_OTA_SIZE 0x6A000
#define SYSTEM_PARTITION_OTA_2_ADDR 0x101000
#define SYSTEM_PARTITION_RF_CAL_ADDR 0x3fb000
#define SYSTEM_PARTITION_PHY_DATA_ADDR 0x3fc000
#define SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR 0x3fd000
#else
#error "The flash map is not supported"
#endif
static const partition_item_t at_partition_table[] = {
{ SYSTEM_PARTITION_BOOTLOADER, 0x0, 0x1000},
{ SYSTEM_PARTITION_OTA_1, 0x1000, SYSTEM_PARTITION_OTA_SIZE},
{ SYSTEM_PARTITION_OTA_2, SYSTEM_PARTITION_OTA_2_ADDR, SYSTEM_PARTITION_OTA_SIZE},
{ SYSTEM_PARTITION_RF_CAL, SYSTEM_PARTITION_RF_CAL_ADDR, 0x1000},
{ SYSTEM_PARTITION_PHY_DATA, SYSTEM_PARTITION_PHY_DATA_ADDR, 0x1000},
{ SYSTEM_PARTITION_SYSTEM_PARAMETER, SYSTEM_PARTITION_SYSTEM_PARAMETER_ADDR, 0x3000},
};
LOCAL esp_udp ssdp_udp;
LOCAL struct espconn pssdpudpconn;
LOCAL os_timer_t ssdp_time_serv;
uint8_t lan_buf[200];
uint16_t lan_buf_len;
uint8 udp_sent_cnt = 0;
const airkiss_config_t akconf =
{
(airkiss_memset_fn)&memset,
(airkiss_memcpy_fn)&memcpy,
(airkiss_memcmp_fn)&memcmp,
0,
};
LOCAL void ICACHE_FLASH_ATTR
airkiss_wifilan_time_callback(void)
{
uint16 i;
airkiss_lan_ret_t ret;
if ((udp_sent_cnt++) >30) {
udp_sent_cnt = 0;
os_timer_disarm(&ssdp_time_serv);//s
//return;
}
ssdp_udp.remote_port = DEFAULT_LAN_PORT;
ssdp_udp.remote_ip[0] = 255;
ssdp_udp.remote_ip[1] = 255;
ssdp_udp.remote_ip[2] = 255;
ssdp_udp.remote_ip[3] = 255;
lan_buf_len = sizeof(lan_buf);
ret = airkiss_lan_pack(AIRKISS_LAN_SSDP_NOTIFY_CMD,
DEVICE_TYPE, DEVICE_ID, 0, 0, lan_buf, &lan_buf_len, &akconf);
if (ret != AIRKISS_LAN_PAKE_READY) {
os_printf("Pack lan packet error!");
return;
}
ret = espconn_sendto(&pssdpudpconn, lan_buf, lan_buf_len);
if (ret != 0) {
os_printf("UDP send error!");
}
os_printf("Finish send notify!\n");
}
LOCAL void ICACHE_FLASH_ATTR
airkiss_wifilan_recv_callbk(void *arg, char *pdata, unsigned short len)
{
uint16 i;
remot_info* pcon_info = NULL;
airkiss_lan_ret_t ret = airkiss_lan_recv(pdata, len, &akconf);
airkiss_lan_ret_t packret;
switch (ret){
case AIRKISS_LAN_SSDP_REQ:
espconn_get_connection_info(&pssdpudpconn, &pcon_info, 0);
os_printf("remote ip: %d.%d.%d.%d \r\n",pcon_info->remote_ip[0],pcon_info->remote_ip[1],
pcon_info->remote_ip[2],pcon_info->remote_ip[3]);
os_printf("remote port: %d \r\n",pcon_info->remote_port);
pssdpudpconn.proto.udp->remote_port = pcon_info->remote_port;
os_memcpy(pssdpudpconn.proto.udp->remote_ip,pcon_info->remote_ip,4);
ssdp_udp.remote_port = DEFAULT_LAN_PORT;
lan_buf_len = sizeof(lan_buf);
packret = airkiss_lan_pack(AIRKISS_LAN_SSDP_RESP_CMD,
DEVICE_TYPE, DEVICE_ID, 0, 0, lan_buf, &lan_buf_len, &akconf);
if (packret != AIRKISS_LAN_PAKE_READY) {
os_printf("Pack lan packet error!");
return;
}
os_printf("\r\n\r\n");
for (i=0; i<lan_buf_len; i++)
os_printf("%c",lan_buf[i]);
os_printf("\r\n\r\n");
packret = espconn_sendto(&pssdpudpconn, lan_buf, lan_buf_len);
if (packret != 0) {
os_printf("LAN UDP Send err!");
}
break;
default:
os_printf("Pack is not ssdq req!%d\r\n",ret);
break;
}
}
void ICACHE_FLASH_ATTR
airkiss_start_discover(void)
{
ssdp_udp.local_port = DEFAULT_LAN_PORT;
pssdpudpconn.type = ESPCONN_UDP;
pssdpudpconn.proto.udp = &(ssdp_udp);
espconn_regist_recvcb(&pssdpudpconn, airkiss_wifilan_recv_callbk);
espconn_create(&pssdpudpconn);
os_timer_disarm(&ssdp_time_serv);
os_timer_setfn(&ssdp_time_serv, (os_timer_func_t *)airkiss_wifilan_time_callback, NULL);
os_timer_arm(&ssdp_time_serv, 1000, 1);//1s
}
void ICACHE_FLASH_ATTR
smartconfig_done(sc_status status, void *pdata)
{
switch(status) {
case SC_STATUS_WAIT:
os_printf("SC_STATUS_WAIT\n");
break;
case SC_STATUS_FIND_CHANNEL:
os_printf("SC_STATUS_FIND_CHANNEL\n");
break;
case SC_STATUS_GETTING_SSID_PSWD:
os_printf("SC_STATUS_GETTING_SSID_PSWD\n");
sc_type *type = pdata;
if (*type == SC_TYPE_ESPTOUCH) {
os_printf("SC_TYPE:SC_TYPE_ESPTOUCH\n");
} else {
os_printf("SC_TYPE:SC_TYPE_AIRKISS\n");
}
break;
case SC_STATUS_LINK:
os_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:
os_printf("SC_STATUS_LINK_OVER\n");
if (pdata != NULL) {
//SC_TYPE_ESPTOUCH
uint8 phone_ip[4] = {0};
os_memcpy(phone_ip, (uint8*)pdata, 4);
os_printf("Phone ip: %d.%d.%d.%d\n",phone_ip[0],phone_ip[1],phone_ip[2],phone_ip[3]);
} else {
//SC_TYPE_AIRKISS - support airkiss v2.0
airkiss_start_discover();
}
smartconfig_stop();
break;
}
}
void ICACHE_FLASH_ATTR user_pre_init(void)
{
if(!system_partition_table_regist(at_partition_table, sizeof(at_partition_table)/sizeof(at_partition_table[0]),SPI_FLASH_SIZE_MAP)) {
os_printf("system_partition_table_regist fail\r\n");
while(1);
}
}
void delay_ms(int a)
{
while(a--)
os_delay_us(1000);
}
#define USE_US_TIMER
os_timer_t stimer;
char led_status=0;
static struct station_info *info=NULL;
void stimer_cb(void)
{
static int cnt=0;
led_status = !led_status;
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),led_status);
// if(++cnt==10) os_timer_disarm(&stimer);
os_printf("--%s--%d--\r\n",__FUNCTION__,__LINE__);
info = wifi_softap_get_station_info();
if(info)
{
os_printf("[%x.%x.%x.%x.%x.%x] is connected!\r\n",\
info->bssid[0],\
info->bssid[1],\
info->bssid[2],\
info->bssid[3],\
info->bssid[4],\
info->bssid[5]);
}
}
struct espconn user_udp_espconn;
uint8 uart_buff[1024]={0};
void uart_rx(void)//#define UART_BUFF_EN 1 //use uart buffer , FOR UART0 35hang
{
int len=0;
//len = rx_buff_deq(uart_buff,1024);
if(len)
{
espconn_sendto(&user_udp_espconn,uart_buff,len);
os_memset(uart_buff,0,1024);
led_status = !led_status;
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),led_status);
}
}
void stimer_init(void)
{
os_timer_disarm(&stimer);
//os_timer_setfn(&stimer,(os_timer_func_t *)stimer_cb,NULL);
os_timer_setfn(&stimer,(os_timer_func_t *)uart_rx,NULL);
//os_timer_arm_us(&stimer,500000,1);
os_timer_arm_us(&stimer,100,1);
}
void led_init(void)
{
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),1);
led_status=1;
}
void udp_recv_cb(void *arg,char *pdata,unsigned short len)
{
os_printf("[%s]\r\n",pdata);
//uart0_tx_buff((uint8 *)pdata,len);//来自NET的数据 在这里串口转发出去
led_status = !led_status;
GPIO_OUTPUT_SET(GPIO_ID_PIN(4),led_status);
struct espconn *T_arg = arg;
remot_info *portinfo=NULL;
if(espconn_get_connection_info(arg,&portinfo,0)==ESPCONN_OK)
{
T_arg->proto.udp->remote_port = portinfo->remote_port;
os_memcpy(T_arg->proto.udp->remote_ip,portinfo->remote_ip,4);
os_printf("\r\n%d-%d-%d-%d\r\n",portinfo->remote_ip[0],portinfo->remote_ip[1],portinfo->remote_ip[2],portinfo->remote_ip[3]);
espconn_send(T_arg,"koson",os_strlen("koson"));
}
}
void udpserver_init(void)
{
user_udp_espconn.type=ESPCONN_UDP;
user_udp_espconn.proto.udp=(esp_udp *)os_zalloc(sizeof(esp_udp));
user_udp_espconn.proto.udp->local_port=8266;
espconn_regist_recvcb(&user_udp_espconn,udp_recv_cb) ;
espconn_create(&user_udp_espconn);
#if 0
ssdp_udp.local_port = DEFAULT_LAN_PORT;
pssdpudpconn.type = ESPCONN_UDP;
pssdpudpconn.proto.udp = &(ssdp_udp);
espconn_regist_recvcb(&pssdpudpconn, airkiss_wifilan_recv_callbk);
espconn_create(&pssdpudpconn);
#endif
}
void user_init2(){
struct softap_config config;//首先定义一个soft_config的结构体
uint8 opmode;
//uart_init(115200,115200);
wifi_set_opmode(0x03);//设置为AP模式
opmode = wifi_get_opmode_default();
os_printf("\r\n当前的工作模式:%d\r\n",opmode);
wifi_softap_get_config(&config);//这个函数的参数是soft_config的结构体,记得取地址
os_memcpy(config.ssid,"ESP8266",strlen("ESP8266"));//往结构体里面初始化配置,调用os_memcpy函数
os_memcpy(config.password,"123456789",strlen("123456789"));
config.ssid_len = strlen("ESP8266");
wifi_softap_set_config(&config);//完成AP模式的参数配置,记得取地址
}
void softap_init(void)
{
#if 1
struct softap_config config;
os_strcpy(config.ssid,"GKoson");
os_strcpy(config.password,"123456");
config.ssid_len = os_strlen(config.ssid);
config.channel=1;
config.authmode=AUTH_OPEN;//AUTH_WPA_PSK;
config.ssid_hidden = 0;
config.max_connection=4;
config.beacon_interval=100;
wifi_softap_set_config(&config);
#else
user_init2();
#endif
}
void ICACHE_FLASH_ATTR
user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
os_printf("HELLO KOSON 2021\n");
system_timer_reinit();
//uart_init(115200,115200);
//uart_init(BIT_RATE_921600,BIT_RATE_921600);
os_delay_us(1000);
led_init();
softap_init();
udpserver_init();
stimer_init();
#if 0
while(1)
{
delay_ms(500);
system_soft_wdt_feed();
}
#endif
}