If you are asking a question, please follow this template:
- My goal is: LOG some text when state is high
- 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;
} - The result I see is: onDemandAP is working, sm_cb not
- 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;
}