void ICACHE_FLASH_ATTR serledInit(void) { int8_t pin = flashConfig.ser_led_pin; if (pin >= 0) { makeGpio(pin); gpio_output_set(0, 0, (1<<pin), 0); serledFlash(1000); // turn it on for 1 second } #ifdef SERLED_DBG os_printf("SER led=%d\n", pin); #endif }
// Recv callback static void ICACHE_FLASH_ATTR tcpRecvCb(void *arg, char *data, uint16_t len) { struct espconn *conn = arg; TcpConn *tci = conn->reverse; os_printf("TCP recv CB (%p %p)\n", arg, tci); if (tci->state == TCP_data) { uint8_t chan; for (chan=0; chan<MAX_CHAN && tcpConn+chan!=tci; chan++) if (chan >= MAX_CHAN) return; // oops!? char buf[6]; short l = os_sprintf(buf, "\n~%d", chan); uart0_tx_buffer(buf, l); uart0_tx_buffer(data, len); uart0_tx_buffer("\0\n", 2); } serledFlash(50); // short blink on serial LED }
int ICACHE_FLASH_ATTR ajaxConsoleSend(HttpdConnData *connData) { if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. char buff[2048]; int len, status = 400; // figure out where to start in buffer based on URI param len = httpdFindArg(connData->getArgs, "text", buff, sizeof(buff)); if (len > 0) { serledFlash(50); // short blink on serial LED uart0_tx_buffer(buff, len); status = 200; } jsonHeader(connData, status); return HTTPD_CGI_DONE; }