Author Topic: Invalid Payload Error  (Read 1655 times)

DonpK

  • Jr. Member
  • **
  • Posts: 76
  • Country: us
Invalid Payload Error
« on: April 23, 2018, 08:57:11 PM »
I am using somewhat modified Struct_send and Struct_receive examples. I am getting the error "Invalid payload received, not matching Payload struct!". The tyepdef struct elements in both the sending and receiving code are the same. When I Serial.print the payload in receiving Moteino, all of the data matches what is being transmitted by the send Moteino. Can something else be causing the "Invalid payload..." error beside the struct elements?

Here is the radio.receiveDone() section for the Struct_receive sketch.

Code: [Select]
 if (radio.receiveDone())
    {
      theData = *(Payload*)radio.DATA; //Save incoming payload     
      Serial.print("Received from Node "); Serial.print(radio.SENDERID, DEC);
      Serial.print("  Size of Payload = "); Serial.print(radio.DATALEN);//added test line for invalid error
      Serial.print(" [RX_RSSI:"); Serial.print(radio.readRSSI()); Serial.println("]");
       
      if (radio.DATALEN != sizeof(Payload)) //Check for valid incoming payload
        Serial.print("Invalid payload received, not matching Payload struct!");   
           
      if (radio.ACKRequested())// check whether an ACK was requested in the last received packet (non-broadcasted packet)
      {                   
          byte theNodeID = radio.SENDERID;
          radio.sendACK();
          Serial.print ("ACK sent to Node "); Serial.println(radio.SENDERID, DEC);
           //When a node requests an ACK, respond to the ACK



Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Invalid Payload Error
« Reply #1 on: April 24, 2018, 09:29:35 AM »
As long as structs match, it should work.
Did you start from the library struct examples? Did those work?

DonpK

  • Jr. Member
  • **
  • Posts: 76
  • Country: us
Re: Invalid Payload Error
« Reply #2 on: April 24, 2018, 01:14:05 PM »
Yes, the Struct_Send/Receive examples worked fine, so it must be something I'm doing. I realize I only included a section of my version of the Receive sketches, so I can include more of both Send and Receive or check out any suggestions you might have.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Invalid Payload Error
« Reply #3 on: April 24, 2018, 01:33:24 PM »
I suggest taking 1 step at 1 time in making changes. That way you can easily see when it stops working and what chance causes it.
The examples are given as a working set of code so that it's easy to get that working, then work your way to what you need from that working code.