kolesnikov.anton
New member
Протестировал следующий код на C
1 час 38 минут
Тоже самое, перестал принимать но продолжает отправлять "hello"
Код:
#include <ets_sys.h>
#include "user_interface.h"
#include <osapi.h>
#include <os_type.h>
#include <gpio.h>
#include <espconn.h>
#include <ets_sys.h>
#include <c_types.h>
#include <mem.h>
// see eagle_soc.h for these definitions
#define LED_GPIO 2
#define LED_GPIO_MUX PERIPHS_IO_MUX_GPIO2_U
#define LED_GPIO_FUNC FUNC_GPIO2
#define DELAY 1000 /* milliseconds */
LOCAL os_timer_t blink_timer;
LOCAL uint8_t led_state=0;
struct espconn myUdp;
LOCAL void ICACHE_FLASH_ATTR blink_cb(void *arg)
{
espconn_sendto(&myUdp, "hello", 6);
}
uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void)
{
enum 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 - 8;
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;
}
void ICACHE_FLASH_ATTR
myUdp_recv(void *arg, char *pusrdata, unsigned short len){
// Если приняли пакет меняем состояние светодиода
GPIO_OUTPUT_SET(LED_GPIO, led_state);
led_state ^=1;
espconn_sendto(&myUdp, "echo", 5);
os_printf(pusrdata);
os_printf("\n");
}
void ICACHE_FLASH_ATTR
create_socket(void){
myUdp.type=ESPCONN_UDP;
myUdp.proto.udp = (esp_udp *)os_zalloc(sizeof(esp_udp));
myUdp.proto.udp->local_port = 8888;
myUdp.proto.udp->remote_port = 8888;
myUdp.proto.udp->local_ip[0] = 172;
myUdp.proto.udp->local_ip[1] = 23;
myUdp.proto.udp->local_ip[2] = 4;
myUdp.proto.udp->local_ip[3] = 44;
myUdp.proto.udp->remote_ip[0] = 255;
myUdp.proto.udp->remote_ip[1] = 255;
myUdp.proto.udp->remote_ip[2] = 255;
myUdp.proto.udp->remote_ip[3] = 255;
espconn_regist_recvcb(&myUdp, myUdp_recv);
espconn_create(&myUdp);
}
void ICACHE_FLASH_ATTR
conect_WiFi(void){
const char ssid[32] = "XXXXX";
const char password[32] = "XXXXXXXXXX";
struct station_config stationConf;
wifi_set_opmode( STATION_MODE );
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 32);
wifi_station_set_config(&stationConf);
wifi_station_connect();
}
void ICACHE_FLASH_ATTR
setTimer(void){
PIN_FUNC_SELECT(LED_GPIO_MUX, LED_GPIO_FUNC);
os_timer_disarm(&blink_timer);
os_timer_setfn(&blink_timer, (os_timer_func_t *)blink_cb, (void *)0);
os_timer_arm(&blink_timer, DELAY, 1);
}
void ICACHE_FLASH_ATTR user_init(void)
{
conect_WiFi();
create_socket();
setTimer();
}
Тоже самое, перестал принимать но продолжает отправлять "hello"