MQTT Connection Parameters – SDK v3.1.0 Support for Username/Password in mqtt_helper_conn_params

Hi Nordic Team,

I'm currently working on integrating TagoIO using MQTT in our application. While attempting to add the MQTT connection details—specifically the username and password—into the struct mqtt_helper_conn_params conn_params within the connect_work_fn, I noticed that the hostname and port number are accepted without issues, but the username and password do not seem to be supported.

We're using nRF Connect SDK v3.1.0, and I couldn't find any documentation or examples indicating support for authentication via username and password in this version. Could you please confirm whether SDK v3.1.0 supports MQTT authentication using username and password? If not, is there a recommended workaround or plan to support this in future releases?

Thanks in advance for your support.

Best regards,
Rajeshwar Tokala
Embedded Engineer II

Parents Reply Children
    • I'm facing two issues while working with SDK v3.1.0:

      Issue 1: same as above topic
      When I try to add MQTT username and password macros in prj.conf, I get build-time errors. It seems SDK v3.1.0 may not support authentication via mqtt_helper_conn_params. Please confirm if this is supported and suggest the correct approach if available.

      Issue 2: different topic
      sometimes After Build successful .hex file is not being generated. The build completes without showing errors, but the output file is missing.

      Could you please help clarify both issues?

      Best regards,
      Rajeshwar Tokala
      Embedded Engineer II



  • Hi,

     

    Rajeshwar tokala said:
    When I try to add MQTT username and password macros in prj.conf, I get build-time errors. It seems SDK v3.1.0 may not support authentication via mqtt_helper_conn_params. Please confirm if this is supported and suggest the correct approach if available.

    Kconfig entries must be added by you to support this, which needs to be manually added by you in this file:

    https://github.com/nrfconnect/sdk-nrf/blob/v3.1.0/samples/net/mqtt/src/modules/transport/Kconfig.transport

     

    In addition to the actual .c implementation as previously mentioned:

    Håkon Alseth said:

    The mqtt-helper can be expanded, more specifically in this struct:

    https://github.com/nrfconnect/sdk-nrf/blob/v3.1.0/include/net/mqtt_helper.h#L94-L95

    https://github.com/nrfconnect/sdk-nrf/blob/v3.1.0/samples/net/mqtt/src/modules/transport/transport.c#L187-L192

    To hold the .user_name and .password as well. 

    Let me know if anything is unclear.

    Rajeshwar tokala said:
    Issue 2: different topic
    sometimes After Build successful .hex file is not being generated. The build completes without showing errors, but the output file is missing.

    Can you please share full logs of this scenario?

     

    Kind regards,

    Håkon

  • LOG for issue 2

    Building mqtt
    west build --build-dir c:/ncs/mqtt/build --domain mqtt

    -- west build: building domain(s): mqtt
    [0/1] Re-running CMake...
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/ncs/mqtt
    -- CMake version: 3.21.0
    -- Cache files will be written to: C:/ncs/v3.1.0/zephyr/.cache
    -- Zephyr version: 4.1.99 (C:/ncs/v3.1.0/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: nrf9160dk, Revision: 0.14.0, qualifiers: nrf9160/ns
    -- Found host-tools: zephyr 0.17.0 (C:/ncs/toolchains/b8b84efebd/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.17.0 (C:/ncs/toolchains/b8b84efebd/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v3.1.0/zephyr/boards/nordic/nrf9160dk/nrf9160dk_nrf9160_ns.dts
    -- Found devicetree overlay: C:/ncs/v3.1.0/zephyr/boards/nordic/nrf9160dk/nrf9160dk_nrf9160_ns_0_14_0.overlay
    -- Found devicetree overlay: C:/ncs/mqtt/boards/nrf9160dk_nrf9160_ns.overlay
    -- Generated zephyr.dts: C:/ncs/mqtt/build/mqtt/zephyr/zephyr.dts
    -- Generated pickled edt: C:/ncs/mqtt/build/mqtt/zephyr/edt.pickle
    -- Generated devicetree_generated.h: C:/ncs/mqtt/build/mqtt/zephyr/include/generated/zephyr/devicetree_generated.h
    Parsing C:/ncs/mqtt/Kconfig
    Loaded configuration 'C:/ncs/v3.1.0/zephyr/boards/nordic/nrf9160dk/nrf9160dk_nrf9160_ns_defconfig'
    Merged configuration 'C:/ncs/mqtt/prj.conf'
    Merged configuration 'C:/ncs/mqtt/boards/nrf9160dk_nrf9160_ns.conf'
    Merged configuration 'C:/ncs/mqtt/build/mqtt/zephyr/misc/generated/extra_kconfig_options.conf'
    Merged configuration 'C:/ncs/mqtt/build/mqtt/zephyr/.config.sysbuild'
    No change to configuration in 'C:/ncs/mqtt/build/mqtt/zephyr/.config'
    No change to Kconfig header in 'C:/ncs/mqtt/build/mqtt/zephyr/include/generated/zephyr/autoconf.h'
    =========== Generating psa_crypto_config ===============
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: False
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Backup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
    Backup: CONFIG_MBEDTLS_THREADING_C: True
    Backup: CONFIG_MBEDTLS_THREADING_ALT: False
    =========== Checkpoint: backup ===============
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: False
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Restore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
    Restore: CONFIG_MBEDTLS_THREADING_C: True
    Restore: CONFIG_MBEDTLS_THREADING_ALT: False
    =========== End psa_crypto_config ===============
    =========== Generating psa_crypto_library_config ===============
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: False
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Backup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: True
    Backup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
    Backup: CONFIG_MBEDTLS_THREADING_C: True
    Backup: CONFIG_MBEDTLS_THREADING_ALT: False
    =========== Checkpoint: backup ===============
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: False
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
    Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
    Restore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: True
    Restore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
    Restore: CONFIG_MBEDTLS_THREADING_C: True
    Restore: CONFIG_MBEDTLS_THREADING_ALT: False
    =========== End psa_crypto_library_config ===============
    -- Found gen_kobject_list: C:/ncs/v3.1.0/zephyr/scripts/build/gen_kobject_list.py
    CMake Warning at C:/ncs/v3.1.0/zephyr/kernel/CMakeLists.txt:178 (message):

    CONFIG_HEAP_MEM_POOL_SIZE is less than requested minimum:
    512 < 808
    Setting the system heap size to 808


    CMake Warning at C:/ncs/v3.1.0/zephyr/CMakeLists.txt:2232 (message):
    __ASSERT() statements are globally ENABLED


    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/ncs/mqtt/build/mqtt
    [0/362] Performing build step for 'tfm'
    * Terminal will be reused by tasks, press any key to close it. fm_psa_rot_partition_crypto.dir/crypto_cipher.o

    * Executing task: nRF Connect: Build: mqtt/mqtt (active)

    Building mqtt
    west build --build-dir c:/ncs/mqtt/build --domain mqtt

    -- west build: building domain(s): mqtt
    [0/282] Performing build step for 'tfm'
    [22/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...eron_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_help[24/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/core/nrf_oberon/...s/psa_core.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/library/psa_crypto_slot_managem[25/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/core/nrf_oberon/CMakeFiles/psa_core.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/library/psa_crypto_storag[27/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/core/nrf_oberon/CMakeFiles/psa_core.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/library/psa_crypto_client[30/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...s/oberon_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_[31/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober.../oberon_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_e[32/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...eron_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_spak[33/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...oberon_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_jp[34/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...oberon_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_ec[35/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...eron_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_ec_k[36/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...s/oberon_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_[37/49] Building C object secure_fw/partitions/crypto/mbedcrypto/nrf_security_src/drivers/nrf_ober...ron_psa_driver.dir/C_/ncs/v3.1.0/modules/crypto/oberon-psa-crypto/oberon/drivers/oberon_wpa3_[45/49] Linking C executable bin\tfm_s.axf
    Memory region Used Size Region Size %age Used
    FLASH: 64884 B 64 KB 99.01%
    RAM: 14532 B 32 KB 44.35%
    [49/49] Generating ../bin/tfm_s.elf
    [280/280] Linking C executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 216892 B 960 KB 22.06%
    RAM: 61836 B 195224 B 31.67%
    IDT_LIST: 0 GB 32 KB 0.00%
    Generating files from C:/ncs/mqtt/build/mqtt/zephyr/zephyr.elf for board: nrf9160dk
    * Terminal will be reused by tasks, press any key to close it.

  • Hi,

     

    Thank you for the logs.

    Rajeshwar tokala said:
    west build --build-dir c:/ncs/mqtt/build --domain mqtt

    This indicates that you have selected the subimage mqtt, similar to what I have done here:

    You can see that mqtt -> build -> mqtt is expanded and the last one is selected.

    What you want is to select the top-most project, so that "build" is blue:

    Could you try this and see if merged.hex is updated now?

     

    Kind regards,

    Håkon



  • After adding in Kconfig.transport file also i am getting same errors. Undefined variable's 

Related