Hello,
I am following through with the quick start guide of Mongoose and using ESP32. In the second stage of the tutorial, a DHT22 sensor is interfaced with ESP32 and the firmware is updated using OTA. I have followed all the steps but finally, when I tried to build it in the web-based or regular Mongoose OS, it showed me few errors in the console log (I did not add the whole console log due to the number of character restrictions on a post). I would really appreciate it if someone can help solve these errors.
Regards,
Ifthekhar
Console Log:
CC /data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/build/objs/wpa_supplicant/src/crypto/sha256-prf.o
CC /data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/build/objs/wpa_supplicant/src/crypto/rc4.o
/data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/src/main.c: In function 'mgos_app_init':
/data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/src/main.c:26:42: error: implicit declaration of function 'mgos_sys_config_get_app_pin'; did you mean 'mgos_sys_config_get_wifi'? [-Werror=implicit-function-declaration]
struct mgos_dht *dht = mgos_dht_create(mgos_sys_config_get_app_pin(), DHT22);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
mgos_sys_config_get_wifi
/data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/src/main.c: At top level:
/data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/src/main.c:31:13: error: redefinition of 'timer_cb'
static void timer_cb(void *arg) {
^~~~~~~~
/data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/src/main.c:21:13: note: previous definition of 'timer_cb' was here
static void timer_cb(void *dht) {
^~~~~~~~
/data/fwbuild-volumes/2.19.0/apps/app2/esp32/build_contexts/build_ctx_027669643/src/main.c:31:13: warning: 'timer_cb' defined but not used [-Wunused-function]
static void timer_cb(void *arg) {
^~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [main.c.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/mongoose-os/platforms/esp32/src/esp32_src.mk:102: recipe for target 'main.c.o' failed
Here is my main.c code:
/*
* Copyright (c) 2014-2018 Cesanta Software Limited
* All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the ""License"");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an ""AS IS"" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mgos_dht.h"
#include "mgos.h"
static void timer_cb(void *dht) {
LOG(LL_INFO, ("Temperature: %lf", mgos_dht_get_temp(dht)));
}
enum mgos_app_init_result mgos_app_init(void) {
struct mgos_dht *dht = mgos_dht_create(mgos_sys_config_get_app_pin(), DHT22);
mgos_set_timer(1000, true, timer_cb, dht);
return MGOS_APP_INIT_SUCCESS;
}
static void timer_cb(void *arg) {
static bool s_tick_tock = false;
LOG(LL_INFO,
("%s uptime: %.2lf, RAM: %lu, %lu free", (s_tick_tock ? "Tick" : "Tock"),
mgos_uptime(), (unsigned long) mgos_get_heap_size(),
(unsigned long) mgos_get_free_heap_size()));
s_tick_tock = !s_tick_tock;
#ifdef LED_PIN
mgos_gpio_toggle(LED_PIN);
#endif
(void) arg;
}
And here is the mos.yml code:
author: mongoose-os
description: A Mongoose OS app skeleton
version: 1.0
libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}
# Optional. List of tags for online search.
tags:
- c
# List of files / directories with C sources. No slashes at the end of dir names.
sources:
- src
# List of dirs. Files from these dirs will be copied to the device filesystem
filesystem:
- fs
# Custom configuration entries, settable via "device configuration"
# Below is a custom firmware configuration example.
# Uncomment and modify according to your needs:
config_schema:
- ["app.pin", "i", 5, {title: "GPIO pin a sensor is attached to"}]
# - ["my_app", "o", {title: "My app custom settings"}]
# - ["my_app.bool_value", "b", false, {title: "Some boolean value"}]
# - ["my_app.string_value", "s", "", {title: "Some string value"}]
# - ["my_app.int_value", "i", 123, {title: "Some integer value"}]
# These settings get compiled into the C structure, and can be accessed
# from the C code this way:
#
# printf("Hello from %s!\n", mgos_sys_config_get_device_id());
#
# Settings are cool: can be modified remotely without full firmware upgrade!
#
# To see all available compiled settings, buid the firmware and open
# build/gen/mgos_config.h file.
#
# Also, in this config_schema section, you can override existing
# settings that has been created by other libraries. For example, debug log
# level is 2 by default. For this firmware we can override it to 3:
#
# config_schema:
# - ["debug.level", 3]
libs:
- origin: https://github.com/mongoose-os-libs/boards
- origin: https://github.com/mongoose-os-libs/ca-bundle
- 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-uart
- origin: https://github.com/mongoose-os-libs/wifi
- origin: https://github.com/mongoose-os-libs/dht # <-- Add this line!
# Used by the mos tool to catch mos binaries incompatible with this file format
manifest_version: 2017-09-29