This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reverse direction: send message from slave

Hello Nordic,

I have a question: how do I send a message from a slave to a master? I want to do the same as sd_ant_acknowledge_message_tx, starting the communication from the slave. Right now I am trying with that same function but I get an error (0x4015).

Thanks for the help!

  • Acknowledged data messages can be sent from a slave to a master. In this case the message is sent immediately after a message is received from the master. If the acknowledged data message is sent successfully, this will be indicated by the channel event TRANSFER_TX_COMPLETED. If no acknowledgement is received from the master, this will be indicated by TX_TRANSFER_FAILED, which either means that the message failed to reach the master, or that the response from the master failed to reach the slave. In this case the slave’s application layer may retry the message. A third possible scenario is that the channel is dropped and the slave begins to search; in this case the event GO_TO_SEARCH will be received, instead of either of the other two commands. If GO_TO_SEARCH is received then the acknowledged message will not be sent, and the channel should be unassigned

  • So I think you should receive TRANSFER_TX_COMPLETED, TX_TRANSFER_FAILED or GO_TO_SEARCH. What do you mean by that you are not receiving anything right after? Do you receive anything later?

  • Hi again!

    Ok, I finally got the system to send ACK messages from the slave to the master. Have some questions now:

    1. When a channel is open from the slave, it starts searching for a master until it finds it or until it times out. While the slave is searching, which event is triggered? EVENT_RX? The thing is that I don't get any ANT events in slave when I start a channel and I don't have any master connected. Any events at all.

    2. When a channel is open from the master, what does it do? Does it trigger EVENT_TX at every channel period? Even if we don't fill the payload with information (using sd_ant_xxx_message_tx...)?

    3. I don't know why this is happening, but if I open a channel from the slave, start sending ACK messages to the master, and after a while, try to close the channel (with a button press, for example), the microprocessor resets itself, and the event EVENT_CHANNEL_CLOSED never triggers (this situation drives to HardFault). Why is that? To close the channel sucessfully without this happening, I have to first allow the slave to finish sending the data that is pending in the stack(i.e. wait for EVENT_TRANSFER_TX_COMPLETED), and then, close the channel. What is happening? (Myabe this question is related? devzone.nordicsemi.com/.../)

    The reason I want to close the channel is to change the channel ID and reopen.

    Thanks again for the help!

  • Great!

    1. If there aren't any masters matching the channel ID criteria you will not get any event until you get EVENT_RX_SEARCH_TIMEOUT.

    2. Yes. Yes.

    3. Are you calling APP_ERROR_CHECK() with the returned error code of sd_ant_channel_close()? What is the returned error code of sd_ant_channel_close()? Why would you not wait for the ack of an ACK message you have sent?

  • Hi Petter!

    Is there a way of getting an event sooner than EVENT_RX_SEARCH_TIMEOUT? Not even EVENT_CHANNEL_CLOSED? Maybe the one called GO_TO_SEARCH? My main problem is that even if I sucessfully send sd_ant_channel_close() (the error code is 0x0000), I don't get the event to trigger, and my whole program is waiting for this to happen...

    The reason why I would close the channel before the message is ACK'd is because it is a user input from the button. The user presses a button to: close the channel, wildcard the channel ID and start to search for a new master. As I do these things one after the other, respecting each interrupt happening, if one of those interrupts doesn't trigger (now, EVENT_CHANNEL_CLOSED is not triggering), the program gets stuck.

    Thanks!

Related