Jam Detection Thread

Hey,

I am trying to use the Jam Detection Feature of Openthread on my nrf52840 DK. The device is running as coap server with the example code 

"simple coap server". I want to use the jamDetection in this code. I tried  to put the code you see down in the main file but it doesn't compile. I enabled the jamDetection in the config file and in the openthread file. 
How am I starting the Jamdetection? How can I put a Callback object in the otStartJamDetection function?

my function otJamDetectionIsEnabled(thread_ot_instance_get()) is alwys returning 0. Is this because there is no jamming at the moment or is it not really enanbled in the setting?

Or is there an example?

Best regards 

Verena

#include <openthread/thread.h>
#include <openthread/jam_detection.h>
#include <openthread/cli.h>     
     
     otCliOutputFormat("is enabled %d",otJamDetectionIsEnabled(thread_ot_instance_get()));

     otError otError = otJamDetectionSetRssiThreshold(thread_ot_instance_get(), aRssiThreshold);
     APP_ERROR_CHECK(otError);

     otCliOutputFormat("rssi treshold %d", otJamDetectionGetRssiThreshold(thread_ot_instance_get()));
     otCliOutputFormat("history bitmap %d", otJamDetectionGetHistoryBitmap(thread_ot_instance_get()));

     otStartJamDetection(thread_ot_instance_get(), otJamDetectionCallback aCallback,p_context);
     otCliOutputFormat("get state %d",otJamDetectionGetState(thread_ot_instance_get()));

Parents
  • I enabled the Jam detection in openthread/src/core/config/openthread-core-config-check.h and also in the sdk_config.h .
    But if I am calling the method otJamDetectionIsEnabled(thread_ot_instance_get())) i am always getting 0 back. The thread_ot_instance_get is a method which is getting the actuall instance. The instance is required as an argument  for  the function     *** bool otJamDetectionIsEnabled(  otInstance *aInstance ) ***.

    In the instruction it is written to enable the jam detection in the openthread/src/core/config/openthread-core-default-config.h , but there is no such file in my openthread repository.

    Where should I enable this to solve this problem?

    My second problem is that I don't know how to call the starting function.

    otError otJamDetectionStart(
      otInstance *aInstance,
      otJamDetectionCallback aCallback,
      void *aContext
    )

    This is out of the instruction, but I don't know how to give aCallback in this function. ainstance and aContext are already defined in some example code snippets, so I know these. Should I define my own function ? Or what should I place there.

    I would be glad about some help.

    Best regards

    Verena

  • Edvin said:

    What SDK version do you use? Do you use NCS or nRF5 SDK? The reason I ask is that I can't find any references to otStartJamDetection(), but I can find otJamDetectionStart() in our SDK.

    Can you please specify this?

    Verena said:
    In the instruction it is written to enable the jam detection in the openthread/src/core/config/openthread-core-default-config.h

    This link, nor the first link in your previous reply is leading anywhere. Can you please check both your links?

    Verena said:
    This is out of the instruction, but I don't know how to give aCallback in this function

    You need to look up the definition of this parameter. otJamDetectionCallback is defined in openthread\include\openthread\jam_detection (at least in the openthread instance that is used in the nRF5 SDk for Thread and Zigbee. If this is not what you are using, please specify what SDK you are using.

    typedef void (*otJamDetectionCallback)(bool aJamState, void *aContext);

    This means that you need to define a callback looking something like this:

    void my_jam_detection_callback(bool aJamState, void *aContext)
    {
        NRF_LOG_INFO("Jam state %d", aJamState);
    }

    and then pass my_jam_detection_callback instead of aCallback when you call otJamDetectionStart():

    otError err_code;
    
    otInstance my_instance = ...;
    
    err_code = otJamDetectionStart(&my_instance, my_jam_detection_callback, NULL);
    NRF_LOG_INFO("otJamDetectionStart returned %d", err_code);

Reply
  • Edvin said:

    What SDK version do you use? Do you use NCS or nRF5 SDK? The reason I ask is that I can't find any references to otStartJamDetection(), but I can find otJamDetectionStart() in our SDK.

    Can you please specify this?

    Verena said:
    In the instruction it is written to enable the jam detection in the openthread/src/core/config/openthread-core-default-config.h

    This link, nor the first link in your previous reply is leading anywhere. Can you please check both your links?

    Verena said:
    This is out of the instruction, but I don't know how to give aCallback in this function

    You need to look up the definition of this parameter. otJamDetectionCallback is defined in openthread\include\openthread\jam_detection (at least in the openthread instance that is used in the nRF5 SDk for Thread and Zigbee. If this is not what you are using, please specify what SDK you are using.

    typedef void (*otJamDetectionCallback)(bool aJamState, void *aContext);

    This means that you need to define a callback looking something like this:

    void my_jam_detection_callback(bool aJamState, void *aContext)
    {
        NRF_LOG_INFO("Jam state %d", aJamState);
    }

    and then pass my_jam_detection_callback instead of aCallback when you call otJamDetectionStart():

    otError err_code;
    
    otInstance my_instance = ...;
    
    err_code = otJamDetectionStart(&my_instance, my_jam_detection_callback, NULL);
    NRF_LOG_INFO("otJamDetectionStart returned %d", err_code);

Children
No Data
Related