A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By zarya
#1107 Here you will find a diff to apply to the last SDK (at example)

the example will auto start the tcp/udp socket server and accept LED1 for GPIO2 HIGH and LED0 for setting GPIO2 LOW

the command LED will return the status of the GPIO, all this is done via a TCP connection to the module no need for extra mcu/arduino's

https://gist.github.com/zarya/f6c94d37d861a9079710
Last edited by zarya on Thu Oct 02, 2014 12:16 pm, edited 1 time in total.
User avatar
By zarya
#1125
M0ebius wrote:thx for sharing your example!

I've seen the nop loop - do you know the delay function? (os_delay_us())
How did you find out, how long each command needs to execute?

There is also already a gpio_init() in gpio.h.


i did not know of the os delay function so i just tryed something with nop after all the delay is prob. not needed.

and gpio.h is not included in the at example ;)
User avatar
By reaper7
#1456 @zarya

I use Your wonderful modification from gist "Simple autostarting example to toggle GPIO2 via tcp/udp",
it contains everything I need with one small exception :)

I moved Your code from user_main.c to additional wifi_connect.c file
Code: Select all#include "user_interface.h"
#include "ip_addr.h"
#include "osapi.h"
#include "c_types.h"
#include "mem.h"

#define sleepms(x) os_delay_us(x*1000);

void ICACHE_FLASH_ATTR
wifi_init(void)
{
  sleepms(500);
 
  uart0_sendStr("Setting MUX to 1:");
  at_setupCmdCipmux(15, "=1");

  sleepms(500);

  at_queryCmdCipmux(15);

  sleepms(500);

  uart0_sendStr("Starting TCP server:");
  at_setupCmdCipserver(16, "=1,9999"); 
}

and everything works ok

but...
my esp8266 will operate in three networks, with of course different SSIDs/PASSWORDs: in my home, sister home, brother home
so...how to add functionality to check and select appropriate/available network on ESP8266 startup?
...and finally, when any of declared networks is not available then start ESP in AP mode with its own declared SSID