Thread CoAP Observe not configuring properly.

I'm working with the OpenThread CoAP protocol in the nRF Connect SDK 2.0.0.  I started with the samples:

\ncs\v2.0.0\nrf\samples\openthread\coap_client

\ncs\v2.0.0\nrf\samples\openthread\coap_server

I've added an Observable resource on the server, to which the client subscribes (registers) to be notified on updates.  I have the following Kconfig options set:

CONFIG_OPENTHREAD_COAP=y
CONFIG_OPENTHREAD_COAP_OBSERVE=y
I've verified that these are set to 'y' in the following project build file:
\build\zephyr\.config
However, the server notifications that the Observed resource has changed do not result in the response callback on the client.  In my call stack I see the OpenThread API functions are implemented in:
   \ncs\v2.0.0\modules\lib\openthread\src\core\api\coap_api.cpp
Which calls into
   \ncs\v2.0.0\modules\lib\openthread\src\core\coap\coap.cpp
In the latter "coap.cpp" file, the sections of code dealing with "Observe" support are conditionally compiled using
#if OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE
However, this is set to 0, and so these Observe code is not part of the build.  If not already defined, it defaults to 0 in 
  \ncs\v2.0.0\modules\lib\openthread\src\core\config\coap.h
/**
 * @def OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE
 *
 * Define to 1 to enable the CoAP Observe (RFC7641) API.
 *
 */
#ifndef OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE
#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 0
#endif
I determined it was not defaulting to 0, but was already defined as 0.  However, I forced it to be set by changing the header file as follows:
/**
 * @def OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE
 *
 * Define to 1 to enable the CoAP Observe (RFC7641) API.
 *
 */
//#ifndef OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE
#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 1
//#endif
After rebuilding with this change, the Observe notifications are properly calling the response callback on the client!!
So...  how should the project configuration be set up so OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE is set??
It appears that either CONFIG_OPENTHREAD_COAP_OBSERVE=y is insufficient, or something else overrides it...
Parents
  • Hi,

    I recommend using the Insert->Code functionality. It will make it a lot easier to read your questions.

    It appears that either CONFIG_OPENTHREAD_COAP_OBSERVE=y is insufficient, or something else overrides it...

    Lets start to check if something overrides this.
    If a Kconfig option is overridden, it is usually a warning about it in the build log. Can you see any such warning?

    Do you use VS Code?
    If so, you can use the Kconfig action and search for OPENTHREAD_COAP_OBSERVE to see what this configuration is set to in the finished build.
    Here you can also see which options the Kconfigs are dependent on, which is useful.

    Regards,
    Sigurd Hellesvik

  • We are using VS Code.  I checked the Kconfig for the configuration.  It appears that both the OBSERVE configuration and its dependencies are set:

    I also checked the \build\zephyr\.config file and verified that all 3 were set to 'y'.  (Attaching as 'dotconfig.txt')

    I checked the build log, \build\.ninja_log, and didn't find anything related to "observe" (Attaching as 'dotninja_log.txt')

    This is still a mystery why the OpenThread CoAP library #define for Observe isn't getting set during the build...

    Are you able to configure a build of one of the OT CoAP samples so OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE is set?

    dotconfig.txt

    dotninja_log.txt

Reply
  • We are using VS Code.  I checked the Kconfig for the configuration.  It appears that both the OBSERVE configuration and its dependencies are set:

    I also checked the \build\zephyr\.config file and verified that all 3 were set to 'y'.  (Attaching as 'dotconfig.txt')

    I checked the build log, \build\.ninja_log, and didn't find anything related to "observe" (Attaching as 'dotninja_log.txt')

    This is still a mystery why the OpenThread CoAP library #define for Observe isn't getting set during the build...

    Are you able to configure a build of one of the OT CoAP samples so OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE is set?

    dotconfig.txt

    dotninja_log.txt

Children
Related