@nliviu can you please support me here a little as I’m getting an error with my code.
static void cron_socket1_off(struct mg_str action, struct mg_str payload, void *userdata)
{
int pin_S1 = mgos_sys_config_get_iotsocket_pin1();
mgos_gpio_write(pin_S1, 0); /* Turn on/off the light */
mgos_shadow_updatef(0, "{socket1_on: %B}", 0); /* Report status */
LOG(LL_INFO, ("Crontab foo job fired! Payload: %.*s", payload.len,
payload.p));
(void)userdata;
(void)action;
}
static void cron_socket1_on(struct mg_str action, struct mg_str payload, void *userdata)
{
int pin_S1 = mgos_sys_config_get_iotsocket_pin1();
mgos_gpio_write(pin_S1, 1); /* Turn on/off the light */
mgos_shadow_updatef(0, "{socket1_on: %B}", 1); /* Report status */
LOG(LL_INFO, ("Crontab foo job fired! Payload: %.*s", payload.len,
payload.p));
(void)userdata;
(void)action;
}
enum mgos_app_init_result mgos_app_init(void)
{
mgos_event_add_handler(MGOS_SHADOW_UPDATE_DELTA, delta_cb, NULL);
mgos_event_add_handler(MGOS_SHADOW_CONNECTED, connected_cb, NULL);
/* Register crontab handler - socke1-off/on */
mgos_crontab_register_handler("cron_socket1_on", cron_socket1_on, NULL);
mgos_crontab_register_handler("cron_socket1_off", cron_socket1_off, NULL);
return MGOS_APP_INIT_SUCCESS;
}
But when I compile I’m getting this error:
/data/fwbuild-volumes/2.17.0/apps/IoT_Socket_box/esp8266/build_contexts/build_ctx_350281813/src/main.c: In function 'mgos_app_init':
/data/fwbuild-volumes/2.17.0/apps/IoT_Socket_box/esp8266/build_contexts/build_ctx_350281813/src/main.c:187:3: error: implicit declaration of function 'mgos_crontab_register_handler' [-Werror=implicit-function-declaration]
mgos_crontab_register_handler("cron_socket1_on", cron_socket1_on, NULL);
^
And this is what I have in libs:
libs:
- origin: https://github.com/mongoose-os-libs/ca-bundle
- origin: https://github.com/mongoose-os-libs/core
- origin: https://github.com/mongoose-os-libs/dash
- origin: https://github.com/mongoose-os-libs/dns-sd
- origin: https://github.com/mongoose-os-libs/http-server
- origin: https://github.com/mongoose-os-libs/provision
- origin: https://github.com/mongoose-os-libs/rpc-service-config
- origin: https://github.com/mongoose-os-libs/rpc-service-fs
- origin: https://github.com/mongoose-os-libs/rpc-service-ota
- origin: https://github.com/mongoose-os-libs/rpc-service-wifi
- origin: https://github.com/mongoose-os-libs/rpc-uart
- origin: https://github.com/mongoose-os-libs/ota-http-server
- origin: https://github.com/mongoose-os-libs/ota-shadow
- origin: https://github.com/mongoose-os-libs/wifi
- origin: https://github.com/mongoose-os-libs/sntp
- origin: https://github.com/mongoose-os-libs/crontab
- origin: https://github.com/mongoose-os-libs/rpc-service-cron