openthread secure api

Hi,

I am trying to integrate the Google IoT Cloud example into my CoAP Server. The example is using Secure API to esablish COAPS.

I have enabled 

CONFIG_OPENTHREAD_COAP=y
CONFIG_OPENTHREAD_COAPS=y
CONFIG_OPENTHREAD_JOINER=y
#CONFIG_NORDIC_SECURITY_BACKEND=y
CONFIG_BASE64=y
CONFIG_MBEDTLS_BUILTIN=y
CONFIG_OPENTHREAD_SLAAC=y

in my prj.conf

There seems to be a confusion about where to find the mbedtls_base64_encode() function

openthread/src/core/meshcop/dtls.cpp
In file included from C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/common/code_utils.hpp:41,
from C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/common/message.hpp:45,
from C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/meshcop/dtls.hpp:55,
from C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/meshcop/dtls.cpp:34:
C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/meshcop/dtls.cpp: In member function 'ot::Error ot::MeshCoP::Dtls::GetPeerCertificateBase64(unsigned char*, size_t*, size_t)':
C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/meshcop/dtls.cpp:528:9: error: 'mbedtls_base64_encode' was not declared in this scope
528 | mbedtls_base64_encode(
| ^~~~~~~~~~~~~~~~~~~~~
C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/common/arg_macros.hpp:77:40: note: in definition of macro '_OT_GET_FIRST_ARG'
77 | #define _OT_GET_FIRST_ARG(aFirst, ...) aFirst
| ^~~~~~
C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/common/code_utils.hpp:124:15: note: in expansion of macro 'OT_FIRST_ARG'
124 | if (!(OT_FIRST_ARG(__VA_ARGS__))) \
| ^~~~~~~~~~~~
C:/nordic_sdk/v1.9.1/modules/lib/openthread/src/core/meshcop/dtls.cpp:527:5: note: in expansion of macro 'VerifyOrExit'
527 | VerifyOrExit(
| ^~~~~~~~~~~~
[165/833] Building CXX object modules/openthread/build/src/core/CMakeFiles/openthread-ftd.dir/meshcop/meshcop_leader.cpp.obj
ninja: build stopped: subcommand failed.

Even though the CONFIG_BASE64=y should enable the MBEDTLS_BASE64_C the package does not get linked to.

Parents Reply
  • Hello,

    I tried to build the coap client sample from NCS\nrf\samples\openthread\coap_client with the configs that you listed, but I didn't get any errors. Perhaps there is one of the configs in that sample that triggers the OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE. I didn't look too deep into it. 

    What sample are you trying to build?

    Best regards,

    Edvin

Children
  • Hi Edvin,


    Thanks for your time, I am building CoAP Server project.

    Here is the coap initialization function I have updated.

    int ot_coap_start_server(void)
    {
    #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
        otError error = otCoapSecureStart(srv_context.ot, OT_DEFAULT_COAP_SECURE_PORT);
        if (error != OT_ERROR_NONE)
        {
            LOG_ERR("Failed to start OT CoAPS. Error: %d", error);
            goto end;
        }
    
        otCoapSecureSetDefaultHandler(srv_context.ot, coap_default_handler, NULL);
    #else
        otError error = otCoapStart(srv_context.ot, COAP_PORT);
        if (error != OT_ERROR_NONE)
        {
            LOG_ERR("Failed to start OT CoAP. Error: %d", error);
            goto end;
        }
    
        otCoapSetDefaultHandler(srv_context.ot, coap_default_handler, NULL);
    #endif
    end:
        return error == OT_ERROR_NONE ? 0 : 1;
    }

Related