mcsa wrote:To mharizanov:
What module do you have?
the classical DIP version with PCB trace antenna:
![Image](http://s2.electrodragon.com/wp-content/uploads/2014/08/ESP8266-WI07c-Wifi-Module-02.jpg)
Explore... Chat... Share...
mcsa wrote:To mharizanov:
What module do you have?
void ICACHE_FLASH_ATTR
at_user_input(void *arg, char *pdata, unsigned short len)
{
struct espconn *pespconn = (struct espconn *)arg;
at_linkConType *linkTemp = (at_linkConType *)pespconn->reverse;
char temp[1024]; // need a larger buffer to hold the html
if (pdata[0] == 'L' && pdata[1] == 'E' && pdata[2] == 'D') {
if (pdata[3] == '1') {
uart0_sendStr("\r\nSet led ON\r\n");
gpio_output_set(BIT2, 0, BIT2, 0);
LED = 1;
} else if (pdata[3] == '0') {
uart0_sendStr("\r\nSet led OFF\r\n");
gpio_output_set(0, BIT2, BIT2, 0);
LED = 0;
}
else
{
os_sprintf(temp, "LED: %d\r\n",LED);
espconn_sent(pLink[linkTemp->linkId].pCon, temp, strlen(temp));
}
}
if (pdata[0] == 'G' && pdata[1] == 'E' && pdata[2] == 'T') {
if (pdata[5] == ' ') { // initial get, send form
uart0_sendStr("\r\nIndex Request\r\n");
os_sprintf(temp,
"<!DOCTYPE html>"
"<html>"
"<head>"
"<title>LED Control</title>"
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1,user-scalable=no\">"
"<style>"
"body{font-size:18px}"
"input{width:100%;height:4em}"
"</style>"
"<script src=\"//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>"
"</head>"
"<body>"
"<h1>LED: <span id=\"s\">%s</span></h1>"
"<input type=\"button\" id=\"n\" value=\"On\" />"
"<input type=\"button\" id=\"f\" value=\"Off\" />"
"<script>"
"var nbtn=$('#n'),fbtn=$('#f');"
"function update(){"
"if($('#s').html()=='Off') {"
"fbtn.hide();nbtn.show();"
"}else{"
"fbtn.show();nbtn.hide();"
"}"
"}"
"update();"
"setInterval(function(){"
"$.get('q',{},function(d){"
"$('#s').html(d);"
"update();"
"});"
"}, 1000);"
"nbtn.off('click').on('click',function(){"
"$.get('n',{},function(d){"
"$('#s').html(d);"
"update();"
"});"
"});"
"fbtn.off('click').on('click',function(){"
"$.get('f',{},function(d){"
"$('#s').html(d);"
"update();"
"});"
"});"
"</script>"
"</body>"
"</html>",(LED == 0 ? "Off" : "On"));
} else if (pdata[5] == 'n') { // turn on request
uart0_sendStr("\r\nSet led ON\r\n");
gpio_output_set(BIT2, 0, BIT2, 0);
LED = 1;
os_sprintf(temp,"On");
} else if (pdata[5] == 'f') { // turn off request
uart0_sendStr("\r\nSet led OFF\r\n");
gpio_output_set(0, BIT2, BIT2, 0);
LED = 0;
os_sprintf(temp,"Off");
} else if (pdata[5] == 'q') { // state request
uart0_sendStr("\r\nSend current state\r\n");
if (LED == 0) {
os_sprintf(temp,"Off");
} else {
os_sprintf(temp,"On");
}
}
espconn_sent(pLink[linkTemp->linkId].pCon, temp, strlen(temp));
espconn_disconnect(pLink[linkTemp->linkId].pCon);
}
}
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]