Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Radio.cpp

Committer:
elmbed
Date:
2015-11-29
Revision:
18:affef3a7db2a
Child:
23:26f27c462976

File content as of revision 18:affef3a7db2a:

#include <RFM69.h>
#include <SPI.h>

#define GATEWAY_ID    1     // this is ME, TGateway
#define NETWORKID     101   //the same on all nodes that talk to each other

#define FREQUENCY     RF69_915MHZ

//#define IS_RFM69HW   //NOTE: uncomment this ONLY for RFM69HW or RFM69HCW
#define ENCRYPT_KEY    "EncryptKey123456"  // use same 16byte encryption key for all devices on net
#define ACK_TIME       50                  // max msec for ACK wait
#define LED            9                   // Anardino miniWireless has LEDs on D9
#define SERIAL_BAUD    115200
#define VERSION  "1.0"

#define MSGBUFSIZE 64   // message buffersize, but for this demo we only use: 
                        // 1-byte NODEID + 4-bytes for time + 1-byte for temp in C + 2-bytes for vcc(mV)

//RFM69::RFM69(PinName  PinName mosi, PinName miso, PinName sclk,slaveSelectPin, PinName int)
//RFM69 radio(P0_24,P0_23,P0_25,P0_28,P0_7);

static bool promiscuousMode = false; // set 'true' to sniff all packets on the same network
static bool requestACK = false;

static char phone_buffer[150] = {0};
static char radio_buffer[150] = {0};

extern void writeToPhone(char *data);

void radio_init()
{
  //tmr.start();
  
  //delay_ms(1000);
  
  //radio.initialize(FREQUENCY, GATEWAY_ID, NETWORKID);
  //radio.encrypt(0);
  //radio.promiscuous(promiscuousMode);
}

#if 0
void radio_loop()
{
  static int counter = 0;
  
  if (radio.receiveDone()) 
  {
     snprintf(phone_buffer, sizeof(phone_buffer), "Got data from: %d.\r\n[%s]\r\n", radio.SENDERID, radio.DATA);
     writeToPhone(phone_buffer);

     if (radio.ACKRequested())
     {
        radio.sendACK();
     } 
  }    
  
  if (++counter > 30)
  {
      snprintf(radio_buffer, sizeof(radio_buffer), "timer val: %d", 8);
      radio.sendWithRetry((uint8_t)GATEWAY_ID, radio_buffer,strlen(radio_buffer),true);
     
      counter = 0;
  }    
}
#endif