esp32: make button debounce also available in factory
[platform/upstream/libwebsockets.git] / lib / lws-plat-esp32.c
index 3356963..2765416 100644 (file)
@@ -433,6 +433,12 @@ lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
        return inet_ntop(af, src, dst, cnt);
 }
 
+LWS_VISIBLE int
+lws_plat_inet_pton(int af, const char *src, void *dst)
+{
+       return 1; //  inet_pton(af, src, dst);
+}
+
 LWS_VISIBLE lws_fop_fd_t IRAM_ATTR
 _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
                    const char *vpath, lws_fop_flags_t *flags)
@@ -788,29 +794,6 @@ again:
        return 0;
 }
 
-void __attribute__(( weak ))
-lws_esp32_button(int down)
-{
-}
-
-void IRAM_ATTR
-gpio_irq(void *arg)
-{
-       bdown ^= 1;
-       gpio_set_intr_type(GPIO_SW, GPIO_INTR_DISABLE);
-       xTimerStart(debounce_timer, 0);
-
-       lws_esp32_button(bdown);
-}
-
-static void lws_esp32_debounce_timer_cb(TimerHandle_t th)
-{
-       if (bdown)
-               gpio_set_intr_type(GPIO_SW, GPIO_INTR_POSEDGE);
-       else
-               gpio_set_intr_type(GPIO_SW, GPIO_INTR_NEGEDGE);
-}
-
 static void lws_esp32_mdns_timer_cb(TimerHandle_t th)
 {
        uint64_t now = time_in_microseconds(); 
@@ -908,6 +891,30 @@ next:
 }
 #endif
 
+void __attribute__(( weak ))
+lws_esp32_button(int down)
+{
+}
+
+void IRAM_ATTR
+gpio_irq(void *arg)
+{
+       bdown ^= 1;
+       gpio_set_intr_type(GPIO_SW, GPIO_INTR_DISABLE);
+       xTimerStart(debounce_timer, 0);
+
+       lws_esp32_button(bdown);
+}
+
+static void lws_esp32_debounce_timer_cb(TimerHandle_t th)
+{
+       if (bdown)
+               gpio_set_intr_type(GPIO_SW, GPIO_INTR_POSEDGE);
+       else
+               gpio_set_intr_type(GPIO_SW, GPIO_INTR_NEGEDGE);
+}
+
+
 static int
 start_scan()
 {