PULL_DOWN issue <SOLVED>

#1

If you are asking a question, please follow this template:

  1. My goal is: LOG some text when state is high
  2. My actions are: when I pull gpio hi and then connect to gnd works perfect, other way is not working
    enum mgos_app_init_result mgos_app_init(void)
    {
    mgos_gpio_set_mode(gpio, MGOS_GPIO_MODE_INPUT);
    mgos_gpio_set_mode(ms, MGOS_GPIO_MODE_INPUT);
    mgos_gpio_set_button_handler(gpio, MGOS_GPIO_PULL_UP, MGOS_GPIO_INT_EDGE_NEG, 50, onDemandAP, NULL);
    mgos_gpio_set_button_handler(ms, MGOS_GPIO_PULL_DOWN, MGOS_GPIO_INT_EDGE_POS, 50, sm_cb, NULL);
    mgos_set_timer(60000, MGOS_TIMER_REPEAT, gcpEvent, NULL);
    return MGOS_APP_INIT_SUCCESS;
    }
  3. The result I see is: onDemandAP is working, sm_cb not
  4. My expectation & question is: what is wrong?
    My full code is:

#include “mgos.h”
#include “mgos_gcp.h”

int gpio = 0;
int ms = 5;

static void onDemandAP(int pin, void *arg)
{
mgos_config_apply("{“wifi”: {“ap”: {“enable”: true}}}", false);
mgos_config_apply("{“wifi”: {“sta”: {“enable”: false}}}", true);
mgos_system_restart_after(1);
(void)pin;
(void)arg;
}

static void sm_cb(int pin, void *arg)
{
LOG(LL_INFO, (“motion detected”));
//mgos_gcp_send_eventf("{i:4, s:AL}");
(void)pin;
(void)arg;
}

static void gcpEvent(void *arg)
{
mgos_gcp_send_eventf("{i:4, s:OK}");
(void)arg;
}

enum mgos_app_init_result mgos_app_init(void)
{
mgos_gpio_set_mode(gpio, MGOS_GPIO_MODE_INPUT);
mgos_gpio_set_mode(ms, MGOS_GPIO_MODE_INPUT);
mgos_gpio_set_button_handler(gpio, MGOS_GPIO_PULL_UP, MGOS_GPIO_INT_EDGE_NEG, 50, onDemandAP, NULL);
mgos_gpio_set_button_handler(ms, MGOS_GPIO_PULL_DOWN, MGOS_GPIO_INT_EDGE_POS, 50, sm_cb, NULL);
mgos_set_timer(60000, MGOS_TIMER_REPEAT, gcpEvent, NULL);
return MGOS_APP_INIT_SUCCESS;
}

#2

The ESP8266 has no internal pulldown resistors, even GPIO16 which shoud have one is not working. So the only way is to use external pulldown resistor.
Regards