rfm12b ack question

Added by spikie almost 4 years ago

Greetings all,

i’m started with code again and trying to get my ack scripts done.
when i was searching the web about more information i can’t find anything i really want.
and myabe some of you guys could help me.
at the moment i understand that when i send an ack to a node it is:

rf12_sendStart(RF12_HDR_ACK, "hello!", 6);

and at the receive side

 if (RF12_WANTS_ACK) {

      rf12_sendStart(RF12_ACK_REPLY, &payload, sizeof payload);


this far it goes well..

but at the transceiver its getting the ack back and then?!

what i want for my project is that when i receive the ack back, i can proces it further.
like: node is online: sends ack back with a simple ok.
and when the node is offline : cant send back and the sender of the ack needs to be alarm the rest of the system cause there is a node down..

Maybe its a easy question with a easy answer but at the moment i cant find it.



Replies (2)

RE: rfm12b ack question - Added by spikie almost 4 years ago

someone maybe could help me a bit futher?

RE: rfm12b ack question - Added by JohnO almost 4 years ago

Hi spikie,

I clipped this from the roomNode.ino example in the jeelib/examples directory:

    for (byte i = 0; i < RETRY_LIMIT; ++i) {
        rf12_sendNow(RF12_HDR_ACK, &payload, sizeof payload);
        byte acked = waitForAck();

        if (acked) {
            #if DEBUG
                Serial.print(" ack ");
                Serial.println((int) i);
            // reset scheduling to start a fresh measurement cycle
            scheduler.timer(MEASURE, MEASURE_PERIOD);

        delay(RETRY_PERIOD * 100);
    scheduler.timer(MEASURE, MEASURE_PERIOD);
    #if DEBUG
        Serial.println(" no ack!");

static byte waitForAck() {
    MilliTimer ackTimer;
    while (!ackTimer.poll(ACK_TIME)) {
        if (rf12_recvDone() && rf12_crc == 0 &&
                // see
                rf12_hdr == (RF12_HDR_DST | RF12_HDR_CTL | myNodeID))
            return 1;
    return 0;

It is a little complex in the above example but ideally you would use most of it as is since the logic and nesting is involved.