ESP8266 Developer Zone The Official ESP8266 Forum 2015-10-30T15:47:40+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1286 2015-10-30T15:47:40+08:00 2015-10-30T15:47:40+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4382#p4382 <![CDATA[Re: wifi_softap_set_dhcps_lease函数错误]]>
我试了您的代码,因为没有 gpio.h ,测试时将 GPIO 和 UART 部分去掉了。
测试未能复现到您的问题。

附件为我编译生成的 bin 文件,麻烦使用测试,看是否有问题?
test_bin.zip

Statistics: Posted by ESP_Faye — Fri Oct 30, 2015 3:47 pm


]]>
2015-10-28T20:05:33+08:00 2015-10-28T20:05:33+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4344#p4344 <![CDATA[Re: wifi_softap_set_dhcps_lease函数错误]]> #include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_interface.h"
#include "mem.h"
#include "uart.h"

#define user_procTaskPrio 0
#define user_procTaskQueueLen 1
os_event_t user_procTaskQueue[user_procTaskQueueLen];
static void user_procTask(os_event_t *events);

static volatile os_timer_t some_timer;

int get_stations(void);

void some_timerfunc(void *arg)
{
//Do blinky stuff
if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT13)
{
//Set GPIO2 to LOW
// gpio_output_set(0, BIT2, BIT2, 0);
GPIO_OUTPUT_SET(12, 0);
}
else
{
//Set GPIO2 to HIGH
// gpio_output_set(BIT2, 0, BIT2, 0);
GPIO_OUTPUT_SET(12, 1);
}
get_stations();

os_printf("LED flush,in task\n");
}

//Do nothing function
static void ICACHE_FLASH_ATTR
user_procTask(os_event_t *events)
{
os_delay_us(10);
}


//return : 0-success,other-fail
int ap_setup(void)
{
struct ip_info info;
struct softap_config config;
struct dhcps_lease dhcp_lease;

if (!wifi_set_opmode_current(SOFTAP_MODE)) return -1; //Set softAP mode

os_memcpy(config.ssid, "configmode", 10);
os_memcpy(config.password, "12345678", 8);
config.ssid_len=os_strlen(config.ssid);
config.channel=11;
config.authmode=AUTH_WPA2_PSK;
config.ssid_hidden=0;
config.max_connection=4; //max 4
config.beacon_interval=100;
if (!wifi_softap_set_config_current(&config)) return -2;

wifi_softap_dhcps_stop();

IP4_ADDR(&info.ip, 192, 168, 1, 1);
IP4_ADDR(&info.gw, 192, 168, 1, 1);
IP4_ADDR(&info.netmask, 255, 255, 255, 0);
if (!wifi_set_ip_info(SOFTAP_IF, &info)) return -4;

const char* start_ip = "192.168.1.2";
const char* end_ip = "192.168.1.102";
dhcp_lease.start_ip.addr = ipaddr_addr(start_ip);
dhcp_lease.end_ip.addr = ipaddr_addr(end_ip);
if (!wifi_softap_set_dhcps_lease(&dhcp_lease)) os_printf("wifi_softap_set_dhcps_lease fail\n"); //return -3;

if (!wifi_softap_dhcps_start()) return -5;

wifi_status_led_install(13, PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); //GPIO13 is status of WIFI

return 0; //success
}

//get station info in AP mode
//return stations
int get_stations(void)
{
int i=0;
struct station_info * station = wifi_softap_get_station_info();
struct station_info * next_station;

while(station)
{
os_printf("bssid : %02x:%02x:%02x:%02x:%02x:%02x, ip : %d.%d.%d.%d\n", MAC2STR(station->bssid), IP2STR(&station->ip));
next_station = STAILQ_NEXT(station, next);
os_free(station); // Free it directly
station = next_station;
i++;
}
return i;
}

//Init function
void ICACHE_FLASH_ATTR
user_init()
{
int i;

wifi_set_opmode(SOFTAP_MODE); //Set softAP mode

// Initialize the GPIO subsystem.
gpio_init();

uart_init(115200, 115200);
uart0_sendStr("system start,in uart0\r\n");
uart1_sendStr_no_wait("system start,in uart1\r\n");

if ((i=ap_setup())) os_printf("start AP mode fail,error code %d\n", i);

os_printf("chip id 0x%x\n", system_get_chip_id() );
os_printf("CPU frequency %dMHz\n", system_get_cpu_freq() );
os_printf("flash id 0x%x, flash map %d\n", spi_flash_get_id(), system_get_flash_size_map());
os_delay_us(50000); //30ms,wait print finish
//os_printf("power valtage is %d/1024V, system meminfo:\n", system_get_vdd33() );
system_print_meminfo();

//Set GPIO2 to output mode
// PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
//Set GPIO12 to output mode
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO12);

//Set GPIO2 low
// gpio_output_set(0, BIT2, BIT2, 0);

//Disarm timer
os_timer_disarm(&some_timer);

//Setup timer
os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);

//Arm the timer
//&some_timer is the pointer
//1000 is the fire time in ms
//0 for once and 1 for repeating
os_timer_arm(&some_timer, 1000, 1);

//Start os task
system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}

Statistics: Posted by zhongjru — Wed Oct 28, 2015 8:05 pm


]]>
2015-10-28T10:45:46+08:00 2015-10-28T10:45:46+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4330#p4330 <![CDATA[Re: wifi_softap_set_dhcps_lease函数错误]]>
非常抱歉,我们未能复现到您的问题。

能否提供您的完整测试工程,以供查证?

感谢您对 ESP8266 的关注!

Statistics: Posted by ESP_Faye — Wed Oct 28, 2015 10:45 am


]]>
2015-10-27T20:30:33+08:00 2015-10-27T20:30:33+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4314#p4314 <![CDATA[Re: wifi_softap_set_dhcps_lease函数错误]]> wifi_softap_set_dhcps_lease fail
system meminfo:
data : 0x3ffe8000 ~ 0x3ffe8378, len: 888
rodata: 0x3ffe8378 ~ 0x3ffe85a8, len: 560
bss : 0x3ffe85a8 ~ 0x3ffef010, len: 27240
heap : 0x3ffef010 ~ 0x3fffc000, len: 53232
mode : softAP(1a:fe:34:a2:8b:95)
add if1
dhcp server start:(ip:192.168.1.1,mask:255.255.255.0,gw:192.168.1.1)
bcn 100
LED flush,in uart0
LED flush,in uart0
LED flush,in uart0

主函数:
//Init function
void ICACHE_FLASH_ATTR
user_init()
{
int i;

wifi_set_opmode(SOFTAP_MODE); //Set softAP mode

// Initialize the GPIO subsystem.
gpio_init();

uart_init(115200, 115200);
uart0_sendStr("system start,in uart0\r\n");
uart1_sendStr_no_wait("system start,in uart1\r\n");

if ((i=ap_setup())) os_printf("start AP mode fail,error code %d\n", i);

os_printf("system meminfo:\n");
system_print_meminfo();

//Set GPIO2 to output mode
// PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
//Set GPIO12 to output mode
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO12);

//Set GPIO2 low
// gpio_output_set(0, BIT2, BIT2, 0);

//Disarm timer
os_timer_disarm(&some_timer);

//Setup timer
os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);

//Arm the timer
//&some_timer is the pointer
//1000 is the fire time in ms
//0 for once and 1 for repeating
os_timer_arm(&some_timer, 1000, 1);

//Start os task
system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}

Statistics: Posted by zhongjru — Tue Oct 27, 2015 8:30 pm


]]>
2015-10-27T17:27:06+08:00 2015-10-27T17:27:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4311#p4311 <![CDATA[Re: wifi_softap_set_dhcps_lease函数错误]]> Statistics: Posted by zhongjru — Tue Oct 27, 2015 5:27 pm


]]>
2015-10-27T15:52:12+08:00 2015-10-27T15:52:12+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4305#p4305 <![CDATA[Re: wifi_softap_set_dhcps_lease函数错误]]>
我试了您的代码,运行正常。

请问您使用的 SDK 版本号是多少?能否提供完整的运行 log 以供分析。

Statistics: Posted by ESP_Faye — Tue Oct 27, 2015 3:52 pm


]]>
2015-10-27T00:47:38+08:00 2015-10-27T00:47:38+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1286&p=4285#p4285 <![CDATA[wifi_softap_set_dhcps_lease函数错误]]> int ap_setup(void)
{
struct ip_info info;
struct softap_config config;
struct dhcps_lease dhcp_lease;

if (!wifi_set_opmode_current(SOFTAP_MODE)) return -1; //Set softAP mode

strcpy(config.ssid, "configmode");
strcpy(config.password, "12345678");
config.ssid_len=strlen(config.ssid);
config.channel=11;
config.authmode=AUTH_WPA2_PSK;
config.ssid_hidden=0;
config.max_connection=4; //max 4
config.beacon_interval=100;
if (!wifi_softap_set_config_current(&config)) return -2;

wifi_softap_dhcps_stop();

IP4_ADDR(&info.ip, 192, 168, 1, 1);
IP4_ADDR(&info.gw, 192, 168, 1, 1);
IP4_ADDR(&info.netmask, 255, 255, 255, 0);
if (!wifi_set_ip_info(SOFTAP_IF, &info)) return -4;

const char* start_ip = "192.168.1.2";
const char* end_ip = "192.168.1.102";
dhcp_lease.start_ip.addr = ipaddr_addr(start_ip);
dhcp_lease.end_ip.addr = ipaddr_addr(end_ip);
if (!wifi_softap_set_dhcps_lease(&dhcp_lease)) os_printf("wifi_softap_set_dhcps_lease fail\n"); //return -3;

if (!wifi_softap_dhcps_start()) return -5;

wifi_status_led_install(13, PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); //GPIO13 is status of WIFI

return 0; //success
}
忽略错误继续运行,功能无误,原因?

Statistics: Posted by zhongjru — Tue Oct 27, 2015 12:47 am


]]>