Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

get_cfg() is no longer working

As of the last build, my code is no longer working with all calls to get_cfg() breaking:
error: implicit declaration of function 'get_cfg' [-Werror=implicit-function-declaration]
device_id = (get_cfg()->device.id ? get_cfg()->device.id : "-");

Is there something I am missing?

My mos version is:
The Mongoose OS command line tool
Version: latest
Build ID: 20171020-193121/master@5e8fb805+
Update channel: latest

Comments

  • nliviunliviu Romania
    edited October 2017

    If you want to use get_cfg() do

    mos update release
    

    The latest branch changed the way to get the configuration settings:

    mgos_sys_config_get_device_id()
    

    instead of

    get_cfg()->device.id
    

    Check https://mongoose-os.com/docs/book/configuration.html

    It looks like get_cfg() will not be available in the next release of mos. The new method will be merged in release,

  • @nliviu Thank you for the very quick response!

    I update my code and am now getting a bunch more broken references from mongoose source code that are also referencing get_cfg():
    .mos/libs-1.18/mqtt-1.18/src/mgos_mqtt.c:122:38: error: implicit declaration of function 'get_cfg' [-Werror=implicit-function-declaration]
    const struct sys_config *cfg = get_cfg();

    Is there a workaround for this?

  • Try to add --clean to your build command.

  • I have a similar issue with Quick-start C/C++ app:

    I have run:

    mos update release
    git clone https://github.com/mongoose-os-apps/empty mongoose-my-app && cd mongoose-my-app
    mos build --arch esp32 --clean --local --repo ~/Code/github/mongoose-os/
    

    I am getting errors:

    ...
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c: In function 'mg_rpc_get_channel_info_by_dst':
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:187:40: error: implicit declaration of function 'get_cfg' [-Werror=implicit-function-declaration]
             chcfg.reconnect_interval_min = get_cfg()->rpc.ws.reconnect_interval_min;
                                            ^
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:187:49: error: invalid type argument of '->' (have 'int')
             chcfg.reconnect_interval_min = get_cfg()->rpc.ws.reconnect_interval_min;
                                                     ^
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:193:49: error: invalid type argument of '->' (have 'int')
             chcfg.reconnect_interval_max = get_cfg()->rpc.ws.reconnect_interval_max;
                                                     ^
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c: In function 'mg_rpc_check_digest_auth':
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:793:36: error: invalid type argument of '->' (have 'int')
           if (mg_vcmp(&realm, get_cfg()->rpc.auth_domain) != 0) {
                                        ^
    In file included from /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:13:0:
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:796:32: error: invalid type argument of '->' (have 'int')
                           get_cfg()->rpc.auth_domain, realm.len, realm.p));
                                    ^
    /mongoose-os/common/cs_dbg.h:61:67: note: in definition of macro 'LOG'
         if (cs_log_print_prefix(l, __func__, __FILE__)) cs_log_printf x; \
                                                                       ^
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:798:44: error: invalid type argument of '->' (have 'int')
             FILE *htdigest_fp = fopen(get_cfg()->rpc.auth_file, "r");
                                                ^
    /home/user/.mos/libs-1.18/rpc-common-1.18/src/mg_rpc/mg_rpc.c:833:41: error: invalid type argument of '->' (have 'int')
           (uint64_t) mg_time(), 1, get_cfg()->rpc.auth_domain);
                                             ^
    cc1: all warnings being treated as errors
    make[1]: *** [mg_rpc.o] Error 1
    /mongoose-os/fw/platforms/esp32/src/esp32_src.mk:128: recipe for target 'mg_rpc.o' failed
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Entering directory '/home/user/Code/mongoose-my-app/build/objs/spiffs'
    CC /home/user/Code/mongoose-my-app/build/objs/spiffs/spiffs_cache.o
    make[1]: Leaving directory '/home/user/Code/mongoose-my-app/build/objs/mosapp'
    /opt/Espressif/esp-idf/make/project.mk:421: recipe for target 'component-mosapp-build' failed
    make: *** [component-mosapp-build] Error 2
    ...
    

    My mos version:
    20171001-163638/1.18@4bbec4b4+
    Update channel: release

  • Update:
    release channel does not seem to be a way to go. I was finally able to build by using latest (mos update latest) and then --clean in mos build command.

  • You are using a local repo which is the latest branch and the libraries are version 1.18.
    The libs and Mongoose OS must be in sync.

    If you use the release branch, don't git clone the repo, use simply mos build --arch esp32 --local and the mos tool will download the right version of the modules.

    ls  ~/.mos
    bin  config.yml  libs-1.18  modules-1.18  state.json  tmp
    
  • I was able to get past the get_cfg() issues (which is excellent), but it looks like bt-common is unable to compile:

    In file included from /deps/bt-common/src/esp32/esp32_bt_internal.h:11:0,
                     from /deps/bt-common/src/esp32/esp32_bt_gattc.c:7:
    /deps/bt-common/src/esp32/esp32_bt_gattc.c: In function 'esp32_bt_gattc_ev':
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:178:57: error: 'const struct gattc_read_char_evt_param' has no member named 'srvc_id'
                p->status, p->conn_id, mgos_bt_uuid_to_str(&p->srvc_id.id.uuid, buf),
                                                             ^
    /mongoose-os/common/cs_dbg.h:61:67: note: in definition of macro 'LOG'
         if (cs_log_print_prefix(l, __func__, __FILE__)) cs_log_printf x; \
                                                                       ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:179:34: error: 'const struct gattc_read_char_evt_param' has no member named 'char_id'
                mgos_bt_uuid_to_str(&p->char_id.uuid, buf2), p->value_type,
                                      ^
    /mongoose-os/common/cs_dbg.h:61:67: note: in definition of macro 'LOG'
         if (cs_log_print_prefix(l, __func__, __FILE__)) cs_log_printf x; \
                                                                       ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:179:58: error: 'const struct gattc_read_char_evt_param' has no member named 'value_type'
                mgos_bt_uuid_to_str(&p->char_id.uuid, buf2), p->value_type,
                                                              ^
    /mongoose-os/common/cs_dbg.h:61:67: note: in definition of macro 'LOG'
         if (cs_log_print_prefix(l, __func__, __FILE__)) cs_log_printf x; \
                                                                       ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:186:32: error: 'const struct gattc_read_char_evt_param' has no member named 'srvc_id'
             if (mgos_bt_uuid_cmp(&p->srvc_id.id.uuid, &rc->svc_id.id.uuid) == 0 &&
                                    ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:187:32: error: 'const struct gattc_read_char_evt_param' has no member named 'char_id'
                 mgos_bt_uuid_cmp(&p->char_id.uuid, &rc->char_id.uuid) == 0) {
                                    ^
    In file included from /deps/bt-common/src/esp32/esp32_bt_internal.h:11:0,
                     from /deps/bt-common/src/esp32/esp32_bt_gattc.c:7:
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:211:38: error: 'const struct gattc_write_evt_param' has no member named 'srvc_id'
                    mgos_bt_uuid_to_str(&p->srvc_id.id.uuid, buf),
                                          ^
    /mongoose-os/common/cs_dbg.h:61:67: note: in definition of macro 'LOG'
         if (cs_log_print_prefix(l, __func__, __FILE__)) cs_log_printf x; \
                                                                       ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:212:38: error: 'const struct gattc_write_evt_param' has no member named 'char_id'
                    mgos_bt_uuid_to_str(&p->char_id.uuid, buf2)));
                                          ^
    /mongoose-os/common/cs_dbg.h:61:67: note: in definition of macro 'LOG'
         if (cs_log_print_prefix(l, __func__, __FILE__)) cs_log_printf x; \
                                                                       ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:218:32: error: 'const struct gattc_write_evt_param' has no member named 'srvc_id'
             if (mgos_bt_uuid_cmp(&p->srvc_id.id.uuid, &wc->svc_id.id.uuid) == 0 &&
                                    ^
    /deps/bt-common/src/esp32/esp32_bt_gattc.c:219:32: error: 'const struct gattc_write_evt_param' has no member named 'char_id'
                 mgos_bt_uuid_cmp(&p->char_id.uuid, &wc->char_id.uuid) == 0) {
    
    
  • SergeySergey Dublin, Ireland

    mos build --clean to do a clean build.

  • It works on the remote build, but when I run it locally it breaks.

    mos build --arch esp32 --local --verbose --clean
    
  • shapeshape curaçao

    if get_cfg behavior has changed, maybe it's a good idea to update the quickstart manuals

    they use the previous behavior, see here:

    https://mongoose-os.com/docs/quickstart/using-c-cpp.html

Sign In or Register to comment.