Bidirectional wireless telegraph

telegraph_headerMaybe some of you read post Morse code for IQRF. Now, we are going to show, how to do simple bidirectional wireless telegraph within a few seconds. You need only some motherboard for IQRF TR module with assembled button, for example DK-EVAL-04 or CK-USB-04.

Source code is very simple. If incoming packet i received, then LED is set according to data. On the other side, if button is pressed, packet with “1” is sent, otherwise “0” is sent. Full source code is available at the end of post.

#include "includes/template-basic.h"

void APPLICATION()
{
    _LEDR = 0;     // Initialization
    toutRF = 10;   // Response max. 100 ms (10 ticks)
   
    while (1)
    {
        if (RFRXpacket()) // If RF packet received
        {
            if (bufferRF[0]) //then: 0 received?
                _LEDR = 1;   //No, LED on
            else
                _LEDR = 0;   //Yes, LED off
        }
        else
            _LEDR = 0; // No receipt for a long time, LED off
       
        if (buttonPressed)    // Copy the state 
            bufferRF[0] = 1;  //to data to transmit
        else
            bufferRF[0] = 0;
            
        DLEN = 1;      // 1 B packet length
        RFTXpacket();  // RF transmit
        clrwdt();
    }
}

.

Download Attachments

  • c telegraph.c
    Wireless telegraph source code
    File size: 775 B Downloads: 223

Leave a Reply

Your email address will not be published. Required fields are marked *