diff --git a/src/main.cpp b/src/main.cpp index 6ff8c03..40e67e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); // Initialize d CRGB leds[NUM_LEDS]; // Array to hold LED colors SoftwareSerial gpsSerial(GPS_RX_PIN, GPS_TX_PIN); // Software serial for GPS TinyGPSPlus gps; // TinyGPS++ object to process GPS data -RH_RF95 rf95(RFM95_CS, RMF95_INT); // Radio instance. +RH_RF95 rf95(RFM9X_CS, RMF9X_INT); // Radio instance. typedef struct Msg{ @@ -39,36 +39,36 @@ NodeId node = { id = 0; name = "name"; }; -uint8_t reciver_buffer[RF95_BUF_SZ]; +uint8_t reciver_buffer[RF9X_BUF_SZ]; void Radio_setup(void) { - pinMode(RFM95_RST, OUTPUT); - digitalWrite(RFM95_RST, HIGH); + pinMode(RFM9X_RST, OUTPUT); + digitalWrite(RFM9X_RST, HIGH); while(!rf95.init()){} Serial.println("radio: Initialized"); - if(rf95.setFrequency(RF95_FREQ)) { + if(rf95.setFrequency(RF9X_FREQ)) { Serial.println("radio: Error could not set frequency"); while(true){} //Loop forever } Serial.print("radio: Frequency = "); - Serial.println(RF95_FREQ); + Serial.println(RF9X_FREQ); - rf95.setTxPower(RF95_MIN_DB, false); + rf95.setTxPower(RF9X_MIN_DB, false); } void Radio_reset(void) { - digitalWrite(RFM95_RST, LOW); + digitalWrite(RFM9X_RST, LOW); delay(10); - digitalWrite(RFM95_RST, HIGH); + digitalWrite(RFM9X_RST, HIGH); delay(10); } int Radio_SendData() { - int8_t tx_power = RF95_MIN_DB; + int8_t tx_power = RF9X_MIN_DB; uint8_t received_id = 0; //Set the radio output to lowest power. @@ -78,21 +78,24 @@ int Radio_SendData() { rf95.setModeTx(); //Try transmitting data + Serial.println("Radio: Sending data..."); rf95.send(node.id, 1); rf95.waitPacketSent(); //Wait for ACK or Radio Msg. (Timeout Should be included). //On timeout increase the transmit power and re-attempt. - if(!rf95.waitAvailbleTimeout(RF95_TIMEOUT)) { - if(rf95.recv(reciver_buffer, RF95_BUF_SZ)) { + if(!rf95.waitAvailbleTimeout(RF9X_TIMEOUT)) { + if(rf95.recv(reciver_buffer, RF9X_BUF_SZ)) { } else { //Failed to receive the message. + Serial.println("Radio: Error failed to receive msg."); } } else { //No reply of any kind. + Serial.println("Radio: Error no reply."); } //Set the radio mode to idle.