This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Advertising termination

Part Number: CC2640R2F

Our application is based on the sample application simple_peripheral for SDk verison 2_20. We wish to permanently terminate advertising after a user specified period of time (to restore advertising would require a reset of the controller via a power cycle). I have probed the use of GAPROLE_ADVERT_ENABLE, which eventually can call the function GAP_EndDiscoverable(selfEntity). When I have tried to make use of this, the BLE stack crashes. I assume perhaps I am violating some context requirement for making the call. My search of the forums and documentation for the proper way to accomplish this have been unsuccessful. Any pointers to example code, or documentation would be greatly appreciated. Thank you.

  • I suppose you only need to use the following codes to stop advertsing

    advertEnabled = FALSE;

    // Enabled connectable advertising.
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
    &advertEnabled);

    Once you need to send advertising again, you can call

    advertEnabled = TRUE;

    // Enabled connectable advertising.
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
    &advertEnabled);

    There is no need to do a reset of the controller via a power cycle.
  • Thanks for the quick response. Here's the function that I created, which I call from my application context:

    void GAP_turnOffAdvertising()
    {
        uint8_t advertEnable= FALSE;
        // Disable advertising
        GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertEnable);
    }

    However, this results in icall_abort() executing an infinite loop. After some more digging, the error code appears to be:

    /**
     * @brief ICall function return value in case the calling
     * thread context is not a registered thread,
     * or the entity id passed is not a registered entity.
     */
    #define ICALL_ERRNO_UNKNOWN_THREAD         -5

    So do I need to call this from the simple_peripheral thread context? If so, how would that be implemented?

    Thank you.

  • I couldn't understand your question. Can you elaborate?

  • After digging through other forum posts and BLE source code, I believe that the various GAP functions can't be called until the calling context (thread) has registered with ICall, e.g. from simple_peripheral.c:

    // Register the current thread as an ICall dispatcher application
    // so that the application can send and receive messages.
    ICall_registerApp(&selfEntity, &syncEvent);

    I attempted to register my application thread (required increasing ICALL_MAX_NUM_TASKS to 4). The subsequent call to the GAP function to set the paramter to cease advertising failed. So, perhaps the question is as follows:

    What is the best way for a control application to signal to the BLE stack to quit advertising? In our control application, we want the BLE advertising to stop after a period of time, but the control application will continue to run. Perhaps configure an advertising timeout value for the simple peripheral task to use to stop advertising?

    Thank you,
    Dave
  • You can create and start timer event line SBP_PERIODIC_EVT in simple_peripheral.c