LowPowerLab Forum

Hardware support => Moteino => Topic started by: bstott on September 04, 2013, 09:46:07 AM

Title: Moteino Example Code Not Required
Post by: bstott on September 04, 2013, 09:46:07 AM
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.
Title: Re: Moteino Example Code Not Required
Post by: Felix on September 04, 2013, 09:54:07 AM
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.
Title: Re: Moteino Example Code Not Required
Post by: bstott on September 04, 2013, 11:18:22 AM
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? 
Title: Re: Moteino Example Code Not Required
Post by: Felix on September 04, 2013, 11:49:14 AM
Exactly.
Title: Re: Moteino Example Code Not Required
Post by: bstott on September 04, 2013, 02:22:54 PM
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
Title: Re: Moteino Example Code Not Required
Post by: CodyPChristian on September 04, 2013, 04:47:04 PM
Hello bstott,

The line should read:

sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_915MHZ);
Title: Re: Moteino Example Code Not Required
Post by: bstott on September 09, 2013, 09:13:02 AM
Sorry about late reply. I see, thank you. I did not know that was a form if 'If Then Else'.

That helped!