Moteino Send Failed [solved ... was not using latest libs]

Started by donaldhwong, September 29, 2015, 01:48:20 PM

donaldhwong

Need your help with the following code trying to send a "key_pressed" to the Gateway.  Copied all setup code from your Node Sample.  Always getting "failed" message.
RFM69 radio;

void setup()
{
  Serial.begin(115200);
  delay(10);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  //radio.setFrequency(919000000);
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
  Serial.println("12 Keypad");
}

void loop()
{
  char keypressed = myKeypad.getKey();
  char data[1];
  if (keypressed != NO_KEY)
  {
    Serial.println(keypressed);
    data[1] = keypressed;

    switch (keypressed)
    {
      case '1':
        if (radio.sendWithRetry(GATEWAYID, data, 1))
          Serial.println(" 1 Sent!");
        else Serial.println(" 1 failed...");
        break;


I then tried to go to the basics.  Uploaded the original Node and Gateway code to one Moteino and a MEGA.  The Moteino is sending, but failed.  The MEGA is listening but nothing coming through.

I recall many moons ago, these codes worked perfectly.

Sigh....  I am lost.  Such basic and simple stuff...

Please advise.  Thank you.

TomWS

Quote from: donaldhwong on September 29, 2015, 01:48:20 PM
Need your help with the following code trying to send a "key_pressed" to the Gateway.  Copied all setup code from your Node Sample.  Always getting "failed" message.
RFM69 radio;

void setup()
{
  Serial.begin(115200);
  delay(10);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  //radio.setFrequency(919000000);
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
  Serial.println("12 Keypad");
}

void loop()
{
  char keypressed = myKeypad.getKey();
  char data[1];
  if (keypressed != NO_KEY)
  {
    Serial.println(keypressed);
    data[1] = keypressed;

    switch (keypressed)
    {
      case '1':
        if (radio.sendWithRetry(GATEWAYID, data, 1))
          Serial.println(" 1 Sent!");
        else Serial.println(" 1 failed...");
        break;


I then tried to go to the basics.  Uploaded the original Node and Gateway code to one Moteino and a MEGA.  The Moteino is sending, but failed.  The MEGA is listening but nothing coming through.

I recall many moons ago, these codes worked perfectly.

Sigh....  I am lost.  Such basic and simple stuff...

Please advise.  Thank you.

Hint:  the problem is somewhere in the vicinity of this code:
    data[1] = keypressed;

donaldhwong

Hi Tom,

Thank you for the rescue. My concern is why the original code from Felix failed, while I did not edit it at all???

Donald

donaldhwong

I downloaded the newest 9/23/2015 version of RFM69 library and example code.  They are now working.

But the old 12/20/2015 version did not.

I thought Felix should know.

donaldhwong

Now I discover your old Node works, therefore using them for the code I posted also works. 

It is your Gateway code does not.


donaldhwong

Interesting..  I compared the two versions of the Gateway.  They are identical.

I now believe that this incident was caused by the different version of the library.

I also just noticed.  Someone changed my subject line to [solved.... not using the latest lib.]

:-)

Felix

I like to mark things "SOLVED" otherwise a newcomer to the forum that sees a million threads with "FAIL" in the subject will think Moteino is a bad piece of hardware, freak out, and leave.