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

ant+ connection/disconnection event?

Hi,

Is there any connection/disconnection API in ant+ (sd210) similar to BLE? I want to use this to control the device activity cycle, if I get disconnection event, would like to make the ANT+ device into sleep unless get a motion trigger.

For example: I need a connection/disconnection event on the master device (like a power meter sensor sending out messages), a slave device (like a power meter display) will initiate the connection to the master device. If the slave device initiates the disconnection from master device, any way to get this disconnection event from master device, so I can control the master device to keep sending data out or go to sleep.

Thanks.

  • Edit: master device

    In ANT, the master just sends out packets at regular intervals, and it does so independently of the slave.

    If the master is asleep it can't get any packets from the slave, so how would the slave initiate a connection?

    The master must be active at some point. To me it seems you have two options, have it active all the time, sending packets with a larger interval, or duty cycling between active and sleep. This depends on your real time requirements.

    If you want the slave to initiate and terminate the connection, I think you would have to implement this on top of the ANT stack, maybe by sending an "initiation" or "termination" message to the master. The "initiation" message could tell the master to increase its interval or skip duty cycling. The "termination" message could tell the master to decrease its interval or start duty cycling. Another option is that the master disconnects if it doesn't get any messages from the slave in a certain time interval.

    Old answer, slave device:

    I'm assuming you are talking about a slave device.

    Maybe you can go to sleep if you get x number of EVENT_RX_FAILevents, or when you get the EVENT_RX_FAIL_GO_TO_SEARCH event?

    You will get EVENT_RX_FAIL_GO_TO_SEARCHwhen a synchronous rx channel has missed 5 receiving an ANT packets. 5 is hardcoded.

    //////////////////////////////////////////////
    /** @name Channel Events and Command Response Codes
    @{ */
    //////////////////////////////////////////////
    #define RESPONSE_NO_ERROR                          ((uint8_t)0x00) ///< Command response with no error
    #define NO_EVENT                                   ((uint8_t)0x00) ///< No Event
    #define EVENT_RX_SEARCH_TIMEOUT                    ((uint8_t)0x01) ///< ANT stack generated event when rx searching state for the channel has timed out
    #define EVENT_RX_FAIL                              ((uint8_t)0x02) ///< ANT stack generated event when synchronous rx channel has missed receiving an ANT packet
    #define EVENT_TX                                   ((uint8_t)0x03) ///< ANT stack generated event when synchronous tx channel has occurred
    #define EVENT_TRANSFER_RX_FAILED                   ((uint8_t)0x04) ///< ANT stack generated event when the completion of rx transfer has failed
    #define EVENT_TRANSFER_TX_COMPLETED                ((uint8_t)0x05) ///< ANT stack generated event when the completion of tx transfer has succeeded
    #define EVENT_TRANSFER_TX_FAILED                   ((uint8_t)0x06) ///< ANT stack generated event when the completion of tx transfer has failed
    #define EVENT_CHANNEL_CLOSED                       ((uint8_t)0x07) ///< ANT stack generated event when channel has closed
    #define EVENT_RX_FAIL_GO_TO_SEARCH                 ((uint8_t)0x08) ///< ANT stack generated event when synchronous rx channel has lost tracking and is entering rx searching state
    #define EVENT_CHANNEL_COLLISION                    ((uint8_t)0x09) ///< ANT stack generated event during a multi-channel setup where an instance of the current synchronous channel is blocked by another synchronous channel
    #define EVENT_TRANSFER_TX_START                    ((uint8_t)0x0A) ///< ANT stack generated event when the start of tx transfer is occuring
    //...
    #define EVENT_TRANSFER_NEXT_DATA_BLOCK             ((uint8_t)0x11) ///< ANT stack generated event when the stack requires the next transfer data block for tx transfer continuation or completion
    //...
    #define CHANNEL_IN_WRONG_STATE                     ((uint8_t)0x15) ///< Command response on attempt to perform an action from the wrong channel state
    #define CHANNEL_NOT_OPENED                         ((uint8_t)0x16) ///< Command response on attempt to communicate on a channel that is not open
    //...
    #define CHANNEL_ID_NOT_SET                         ((uint8_t)0x18) ///< Command response on attempt to open a channel without setting the channel ID
    #define CLOSE_ALL_CHANNELS                         ((uint8_t)0x19) ///< Command response when attempting to start scanning mode, when channels are still open
    //...
    #define TRANSFER_IN_PROGRESS                       ((uint8_t)0x1F) ///< Command response on attempt to communicate on a channel with a TX transfer in progress
    #define TRANSFER_SEQUENCE_NUMBER_ERROR             ((uint8_t)0x20) ///< Command response when sequence number of burst message or burst data segment is out of order
    #define TRANSFER_IN_ERROR                          ((uint8_t)0x21) ///< Command response when transfer error has occured on supplied burst message or burst data segment
    #define TRANSFER_BUSY                              ((uint8_t)0x22) ///< Command response when transfer is busy and cannot process supplied burst message or burst data segment
    //...
    #define MESSAGE_SIZE_EXCEEDS_LIMIT                 ((uint8_t)0x27) ///< Command response if a data message is provided that is too large
    #define INVALID_MESSAGE                            ((uint8_t)0x28) ///< Command response when the message has an invalid parameter
    #define INVALID_NETWORK_NUMBER                     ((uint8_t)0x29) ///< Command response when an invalid network number is provided
    #define INVALID_LIST_ID                            ((uint8_t)0x30) ///< Command response when the provided list ID or size exceeds the limit
    #define INVALID_SCAN_TX_CHANNEL                    ((uint8_t)0x31) ///< Command response when attempting to transmit on channel 0 when in scan mode
    #define INVALID_PARAMETER_PROVIDED                 ((uint8_t)0x33) ///< Command response when an invalid parameter is specified in a configuration message
    #define EVENT_QUE_OVERFLOW                         ((uint8_t)0x35) ///< ANT stack generated event when the event queue in the stack has overflowed and drop 1 or 2 events
    #define EVENT_ENCRYPT_NEGOTIATION_SUCCESS          ((uint8_t)0x38) ///< ANT stack generated event when connecting to an encrypted channel has succeeded
    #define EVENT_ENCRYPT_NEGOTIATION_FAIL             ((uint8_t)0x39) ///< ANT stack generated event when connecting to an encrypted channel has failed
    #define EVENT_RFACTIVE_NOTIFICATION                ((uint8_t)0x3A) ///< ANT stack generated event when the time to next synchronous channel RF activity exceeds configured time threshold
    #define EVENT_CONNECTION_START                     ((uint8_t)0x3B) ///< Application generated event used to indicate when starting a connection to a channel
    #define EVENT_CONNECTION_SUCCESS                   ((uint8_t)0x3C) ///< Application generated event used to indicate when successfuly connected to a channel
    #define EVENT_CONNECTION_FAIL                      ((uint8_t)0x3D) ///< Application generated event used to indicate when failed to connect to a channel
    #define EVENT_CONNECTION_TIMEOUT                   ((uint8_t)0x3E) ///< Application generated event used to indicate when connecting to a channel has timed out
    #define EVENT_CONNECTION_UPDATE                    ((uint8_t)0x3F) ///< Application generated event used to indicate when connection parameters have been updated
    //...
    #define NO_RESPONSE_MESSAGE                        ((uint8_t)0x50) ///< Command response type intended to indicate that no serial reply message should be generated
    #define EVENT_RX                                   ((uint8_t)0x80) ///< ANT stack generated event indicating received data (eg. broadcast, acknowledge, burst) from the channel
    #define EVENT_BLOCKED                              ((uint8_t)0xFF) ///< ANT stack generated event that should be ignored (eg. filtered events will generate this)
    /** @} */
    
  • This information shouldn't be in a comment to my answer. Please edit your question and make it clear what you are asking, so this can be useful to others. Then I can modify my answer.

Related