This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

what's "CHANNEL_IN_WRONG_STATE" ?

hello,

Have any example about how to use "CHANNEL_IN_WRONG_STATE" ?

I don't know how to use it. and also don't know when softdevice return this even.

///< Command response on attempt to perform an action from the wrong channel state

#define CHANNEL_IN_WRONG_STATE ((uint8_t)0x15)


condition: nrf51422/s310

  • What about sending broadcast, when CHANNEL_0 is (for instance) uninitialized, i.e. sd_ant_channel_status_get returns STATUS_UNASSIGNED_CHANNEL in statusCh0?

    #define CHANNEL_0 0x00
    uint8_t statusCh0;
    
    err_code = sd_ant_broadcast_message_tx(CHANNEL_0, BROADCAST_DATA_BUFFER_SIZE, m_broadcast_data);
    APP_ERROR_CHECK(err_code);
    
    err_code = sd_ant_channel_status_get(CHANNEL_0, &statusCh0);
    APP_ERROR_CHECK(err_code);
    
  • You need to use the debugger to figure out what SoftDevice function that returns the error. Turn off optimization and put a breakpoint in the app_error_handler, this will give you the error code, the line number and the file name.

    You can also put breakpoints in different places in main() and see how far you get before you get the error.

  • thanks. I only use "sd_ant_channel_status_get" and I get data from &statusCh0.

    because my project is ANT receiver, I get 0x00 when 51422 is uninitialized, I get 0x43 when 51422 is in EVENT_RX_FAIL , I get 0x41 when 51422 is in EVENT_RX_SEARCH_TIMEOUT,

  • Could I put "CHANNEL_IN_WRONG_STATE" in " on_ant_evt()" ?

    static void on_ant_evt(ant_evt_t * p_ant_evt) {

    if (p_ant_evt->channel == ANT_HRMRX_ANT_CHANNEL)
    {
        switch (p_ant_evt->event)
        {
            case EVENT_RX:
                on_ant_evt_rx(p_ant_evt);				
                break;
    
            case EVENT_CHANNEL_CLOSED:
                on_ant_evt_channel_closed();
                break;
    
        case EVENT_RX_FAIL: 
    	break;
    
        case CHANNEL_IN_WRONG_STATE:
    	break;
    
        case EVENT_RX_SEARCH_TIMEOUT:
     		break;
    
        default:
                // No implementation needed.
                break;
        }
    }
    
  • Could I put "CHANNEL_IN_WRONG_STATE" in " on_ant_evt()" ?

Related