ESP32 2 boards (AP and Station) WiFi COMM Toggle LED in ESP-IDF.

Posts: 23
Joined: Tue Oct 23, 2018 6:20 am

ESP32 2 boards (AP and Station) WiFi COMM Toggle LED in ESP-IDF.

Postby kmmaran » Tue Feb 11, 2020 5:57 am

Hi All,

I need to toggle LED of one ESP32 board (STATION) from another ESP32 board (AP) using WiFi and vice versa, in esp-idf and no arduino. I am able to do it via a web page with ON and OFF button but I don't want to use a web page.

For example if one EP32(AP) board switch toggled the other ESP32 board (Station) LED need to be ON. and Vice-Versa.

I am no where near a programmer, but the below code work for me, (this is using a web page for turn on and off LED) how can I modify this code to do what I want.

I am trying to modify below code but, no success. Please don't point to arduino coding.

Thank you.

Code: Select all

static void
http_server_netconn_serve(struct netconn *conn)
  struct netbuf *inbuf;
  char *buf;
  u16_t buflen;
  err_t err;

  /* Read the data from the port, blocking if nothing yet there.
   We assume the request (the part we care about) is in one netbuf */
  err = netconn_recv(conn, &inbuf);

  if (err == ERR_OK) {
    netbuf_data(inbuf, (void**)&buf, &buflen);

    /* Is this an HTTP GET command? (only check the first 5 chars, since
    there are other formats for GET, and we're keeping it very simple )*/
    if (buflen>=5 &&
        buf[0]=='G' &&
        buf[1]=='E' &&
        buf[2]=='T' &&
        buf[3]==' ' &&
        buf[4]=='/' ) {
          printf("%c\n", buf[5]);
      /* Send the HTML header
             * subtract 1 from the size, since we dont send the \0 in the string
             * NETCONN_NOCOPY: our data is const static, so no need to copy it
       /* Set the GPIO as a push/pull output */
       gpio_set_direction(DIODE_PIN, GPIO_MODE_OUTPUT);
      netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);

      /* Send our HTML page */
      netconn_write(conn, http_index_hml, sizeof(http_index_hml)-1, NETCONN_NOCOPY);

  /* Close the connection (server closes in HTTP) */

  /* Delete the buffer (netconn_recv gives us ownership,
   so we have to make sure to deallocate the buffer) */

static void http_server(void *pvParameters)
  struct netconn *conn, *newconn;
  err_t err;
  conn = netconn_new(NETCONN_TCP);
  netconn_bind(conn, NULL, 80);
  do {
     err = netconn_accept(conn, &newconn);
     if (err == ERR_OK) {
   } while(err == ERR_OK);

Who is online

Users browsing this forum: Google [Bot] and 27 guests