RFM69 library node/gateway examples - stuck on radio.sendWithRetry() [solved]

Started by labusr, April 16, 2014, 01:17:54 AM

labusr

Big edit.  I narrowed down what the issues is to one line.  I added a bunch of printlin's and this is the output. 


Quote
Transmitting at 433 Mhz...
SPI Flash Init FAIL! (is chip present?)
in loop
in loop2
in loop3
in loop3b
in loop3c
in loop3d

It's stopping after "loop3d", and never gets to printing "loop3e".  I'm not sure why this line is making the Arduino stop:

Quoteradio.sendWithRetry(GATEWAYID, buff, buffLen);




Quote

  Serial.println("in loop2");
  //check for any received packets
  if (radio.receiveDone())
  {
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA);
    Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");

    if (radio.ACK_REQUESTED)
    {
      radio.sendACK();
      Serial.print(" - ACK sent");
      delay(10);
    }
    Blink(LED,5);
    Serial.println();
  }
  Serial.println("in loop3");
  //send FLASH id
  if(sendSize==0)
  {
    Serial.println("in loop3b");
    sprintf(buff, "FLASH_MEM_ID:0x%X", flash.readDeviceId());
    Serial.println("in loop3c");
    byte buffLen=strlen(buff);
    Serial.println("in loop3d");
    radio.sendWithRetry(GATEWAYID, buff, buffLen);
    Serial.print("in loop3e");
    Serial.println(TRANSMITPERIOD);
    delay(TRANSMITPERIOD);
    Serial.print("in loop3F");
  }
  Serial.println("in loop4");
  int currPeriod = millis()/TRANSMITPERIOD;
  Serial.println("in loop5");


From the header file, the definition of the sendWithRetry is this:

Quotebool sendWithRetry(byte toAddress, const void* buffer, byte bufferSize, byte retries=2, byte retryWaitTime=30);

I'm not sure why the example can get away without the retry parameters.  I'm sure it works, just can't figure out what my particular issue is.

Spexx

No, you don't need a flash chip, the sketch should work anyway.

The Arduino itself works without problems, for example if you run a simple blink sketch?
Do you also get the println message from the setup in the serial monitor? I'm not sure what happens, if the RFM-module can not initialized in the setup routine, maybe this could be possible.

I would try to comment out the radio.initialize in the setup routine and test it again. You could also remove the complete code in the loop() to check, if you stuck in one of the if statement.

labusr

Good idea, I should've thought to try the blink sketch.  Thanks for the suggestion.


BR549

If "blinky" checks out, verify that the interrupt pin is connected correctly and defined correctly. The library depends on the radio interrupt to complete the transmit and receive functions.  Felix describes the 2 different entries in this thread: http://lowpowerlab.com/forum/index.php/topic,460.0/topicseen.html

The library is written in C++ which allows default values to substitute when they aren't provided; in this case "retries=2" and "retryWaitTime=30" is defined in RFM69.h

B

labusr

Yes, I've verified that both Arduinos run blinky fine, as well as one of my other sketch that use a temperature sensor.

I've verified that the interrupt is on the right pin:  from DIO0 on the RFM69 to Pin 2 of the digital I/O group on the Arduino Uno.  And the SPI interface seems working as I can get the RFM69 chip's temperature by typing "t" into the serial monitor on the Gateway Arduino.

I've also try swapping the sketches around - take the gateway sketch and download to what was the node, and vice versa, and the problem is still the same.  The Node Arduino hangs at the "radio.sendWithRetry(GATEWAYID, buff, buffLen)"

Maybe someone can help me understand the "loop3" if block of code? 

if(sendSize==0), it tries to compose a string that is the flash memory ID?  But I don't have any flash memory?  Maybe I'll just try initializing sendSize to some number other than 0?

But I'm getting out of my depth with this type of thing.  I'm sure the default examples work, I'm just doing something wrong.

Edit:  I tried initializing sendSize = 3 instead of 0 at the beginning.  My output:

Quote
Transmitting at 433 Mhz...
SPI Flash Init FAIL! (is chip present?)
in loop
in loop2
in loop3
in loop4
in loop5
Sending[3]: 123


Quote
  Serial.println("in loop4");
  int currPeriod = millis()/TRANSMITPERIOD;
  Serial.println("in loop5");
  if (currPeriod != lastPeriod)
  {
    lastPeriod=currPeriod;
    Serial.print("Sending[");
    Serial.print(sendSize);
    Serial.print("]: ");
    for(byte i = 0; i < sendSize; i++)
      Serial.print((char)payload);

    if (radio.sendWithRetry(GATEWAYID, payload, sendSize))
     Serial.print(" ok!");
    else Serial.print(" nothing...");

    sendSize = (sendSize + 1) % 31;
    Serial.println();
    Blink(LED,3);

So it never got a boolean return from sendWithRetry() function.