Hi --- I'm just beginning to read the code examples for the Gateway and Node. I have two of the
RFM69HW 915MHz Moteinos. In adjusting these sketches for my project I'm removing code not specifically required for my testing and have questions for what can be removed.
On looking at this code for Transmitting from the Gateway and Node sketches: sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Q.1.: Can I have just one occurrence of FREQUENCY such as: FREQUENCY==RF69_915MHZ ? 915
A.1.:
The example code for the Transmitting has FREQUENCY==868MHZ ? 868 : 915. I see in the RFM69.h library that #define RF69_915MHZ is present.
Q.2.: Is the "FREQUENCY.==868MHZ ..." a hard coded reference somewhere or can that be changed to "FREQUENCY==915MHZ ? 915;" (I am using 915MHZ.)
A.2.:
Thanks,
Brian.
That is a way to be able to change the setting in one place. It's C++ convenience.
But yeah you can strip all that out and just have the one setting you need.
In fact the answer would be - you can do whatever you need to, that's the beauty of C++.
The provided example is there to get you started.
Thanks and getting started.
The answer is: It is OK to delete the other frequency references from the line and to edit it to read:
"sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_915MHZ ? 915;"
???
I just realized the above is a message to terminal and not code required to run the application. Right? So, the entire line is not required. Right?
Exactly.
Uh, it gives an error.
My line reads:
sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_915MHZ ? 915);
Error is:
Node_RFM69HW.ino: In function 'void setup()':
Node_RFM69HW:27: error: expected `:' before ')' token
Node_RFM69HW:27: error: expected primary-expression before ')' token
Hello bstott,
The line should read:
sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_915MHZ);
Sorry about late reply. I see, thank you. I did not know that was a form if 'If Then Else'.
That helped!