From 7a1da479ac8745c38e91f3a246ae7a4908ef76e2 Mon Sep 17 00:00:00 2001 From: Firmware Batman Date: Thu, 27 Apr 2017 12:17:41 -0700 Subject: [PATCH] disconn callback works --- boardesp/proxy.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/boardesp/proxy.c b/boardesp/proxy.c index 099b9f6..36a9cf8 100644 --- a/boardesp/proxy.c +++ b/boardesp/proxy.c @@ -33,6 +33,15 @@ uint32_t sendData[0x14] = {0}; uint32_t recvData[0x40] = {0}; static int ICACHE_FLASH_ATTR spi_comm(char *dat, int len, uint32_t *recvData, int recvDataLen) { + // blink the led during SPI comm + if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & (1 << pin)) { + // set gpio low + gpio_output_set(0, (1 << pin), 0, 0); + } else { + // set gpio high + gpio_output_set((1 << pin), 0, 0, 0); + } + SpiData spiData; spiData.cmd = 2; @@ -75,14 +84,6 @@ static int ICACHE_FLASH_ATTR spi_comm(char *dat, int len, uint32_t *recvData, in static void ICACHE_FLASH_ATTR tcp_rx_cb(void *arg, char *data, uint16_t len) { - if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & (1 << pin)) { - // set gpio low - gpio_output_set(0, (1 << pin), 0, 0); - } else { - // set gpio high - gpio_output_set((1 << pin), 0, 0, 0); - } - // nothing too big if (len > 0x14) return; @@ -123,9 +124,17 @@ void ICACHE_FLASH_ATTR some_timerfunc(void *arg) { volatile int timer_started = 0; +void ICACHE_FLASH_ATTR inter_disc_cb(void *arg) { + if (timer_started) { + os_timer_disarm(&some_timer); + timer_started = 0; + } +} + void ICACHE_FLASH_ATTR inter_connect_cb(void *arg) { struct espconn *conn = (struct espconn *)arg; - espconn_set_opt(&tcp_conn, ESPCONN_NODELAY); + espconn_set_opt(&inter_conn, ESPCONN_NODELAY); + espconn_regist_disconcb(conn, inter_disc_cb); // setup timer at 200hz // TODO: disable when it runs out