Lora Module DRF1278 Arduino with Raspberry Pi

Hello guys, i need a little help here. Im new to LoRa technology. im using LoRa DRF1278DM.

I want to make a IoT device with LoRa as its communication system, but I found an error on my device node, the Arduino Pro Mini 3.3V.
My gateway device is raspberry pi 3 model B+.
Header messages received by the device node have an incorrect return value. this is some part of my code on the device node

void radio_listening() {
  DEBUG_PRINTLN("radio listening...");
  char Message[14];
  char *pM = Message;
  memset(pM, 0, sizeof(pM));
     
  // Waiting instruction from gateway
  
  digitalWrite(pin_enable, LOW);
  serial_radio.listen();
  while (serial_radio.available() < 10);
  for (int i = 0; i < 14; i++) {
    *(pM+i) = (serial_radio.read() & 0xFF) ;
    Serial.print(*(pM+i)&0xFF,HEX); Serial.print("-");
    serial_radio.flush();
    Serial.flush();
  }
  serial_radio.end();
  Serial.println("");
  parsing_header(pM);
  for( int j = 0; j < 14;  ++j )
   *(pM+j) = (char)0; 
}

when parsing_header the message received has a return value of “unknown header”

#define MSG_HEADER          "GMLEWS"
#define MSG_HEADER_LEN      (sizeof(MSG_HEADER)-1)
void parsing_header(char *pMessage) {
  char *pS=pMessage;
  Serial.print("pS:");
  Serial.println(pS);
  if(strncmp(pS, "GMLEWS",MSG_HEADER_LEN) == 0){
    DEBUG_PRINTLN("GMLEWS header OK");
    if (get_checksum(pS,MSG_CMD_LEN-1)==*(pS+MSG_CMD_LEN-1)) {
      DEBUG_PRINTLN("Checksum OK");
      parsing_data(pS+MSG_HEADER_LEN+2);
    } else {
      DEBUG_PRINTLN("Checksum NG");
    }
  } else {
    DEBUG_PRINTLN("unknown header");
  }
}

char get_checksum(char *pS, int len) {
  char checksum = 0;
  for (int i=0;i< len; i++) {
    checksum += *(pS+i);
  }
  checksum = -(checksum % 256) & 0xFF;
  //Serial.println(checksum,HEX);
  return checksum;
}

Here’s the output

radio listening...
0-2-47-4D-4C-45-57-53-0-3-0-2-35-53-
pS:
unknown header

I have tried several ways by converting these bytes but i dont have any idea. the data received is still wrong. please help, thank you so much. i’ll appriciated it

Very difficult to see whats going on, you just posted a small fragment of code where you think the problem might be.

So this is a pure guess as my crystal ball is away for repair, maybe your mixing software serial and hardware serial (prints to serial monitor) at the same time ?

That can most certainly lead to problems, missed characters on the software serial input, corrupted prints to serial monitor etc.

The NeoSWserial library is far more stable in this type of application.