Driver internal error: Cannot read property 'substring' of undefined

Hello,

I’ve developed a code based on the following library

It works for about 8h of the day, the remaining it gives me this error:

Encoded Payload: 30

Payload Decoding Error:
{
“code”: “com-4006”,
“message”: “driver internal error: TypeError: Cannot read property ‘substring’ of undefined”
}

Has anyone got this error previously?

The code is this

void getMeasure(){

myCommand = String(SENSOR_ADDRESS) + TAKE_MEASURE;
Serial.println(“Sending command to take measures”); // echo command to terminal
mySDI12.sendCommand(myCommand);
delay(30); // wait a while for a response

while (mySDI12.available()) { // build response string
char c = mySDI12.read();
if ((c != ‘\n’) && (c != ‘\r’)) {
sdiResponse += c;
delay(10); // 1 character ~ 7.5ms
}
}
if (sdiResponse.length() > 1)
//Serial.println(sdiResponse); // write the response to the screen
mySDI12.clearBuffer();
Serial.println(“Waiting the sensor…”);
delay(2000); // delay between taking reading and requesting data
sdiResponse = “”; // clear the response string

Serial.println(“Sending command to read the measures”);
// next command to request data from last measurement
myCommand = String(SENSOR_ADDRESS) + READ_MEASURE;
// Serial.println(myCommand); // echo command to terminal

mySDI12.sendCommand(myCommand);
delay(30); // wait a while for a response
int i = 0;
while (mySDI12.available()) { // build string from response
char c = mySDI12.read();
if ((c != ‘\n’) && (c != ‘\r’)) {
sdiResponse += c;
appData[i] = sdiResponse[i];
i++;
delay(10); // 1 character ~ 7.5ms
}
}
if (sdiResponse.length() > 1)
Serial.println(sdiResponse); // write the response to the screen
mySDI12.clearBuffer();
vextOff();
//sdiResponse = “”;

}

/*
Prepare lorawan packet with sensor values
*/
static void prepareTxFrame( uint8_t port )
{

appDataSize = sdiResponse.length();//AppDataSize max value is 64 ( src/Commissioning.h -> 128 )
for (int i =0;i<appDataSize;i++){
appData[i] = sdiResponse[i];
}
sdiResponse = “”;
}

void setup()
{
Serial.begin(115200);
pinMode(LEDPin,OUTPUT);
digitalWrite(LEDPin, HIGH);
Serial.println(“Opening SDI-12 bus…”);
setupSensor(); // Start SDI sensor
SPI.begin(SCK,MISO,MOSI,SS); // Start communication with lorawan chip
Mcu.init(SS,RST_LoRa,DIO0,DIO1,license);
deviceState = DEVICE_STATE_INIT;
if (customTxDutyCyle != 0){
appTxDutyCycle = customTxDutyCyle;
Serial.println(“Custom appTxDutyCycle: " + String(appTxDutyCycle));
}else{
Serial.println(” appTxDutyCycle: " + String(appTxDutyCycle));
}
}

// The loop function is called in an endless loop
void loop()
{

switch( deviceState )
{
case DEVICE_STATE_INIT:
{
#if(LORAWAN_DEVEUI_AUTO)
LoRaWAN.generateDeveuiByChipID();
#endif
LoRaWAN.init(loraWanClass,loraWanRegion);
break;
}
case DEVICE_STATE_JOIN:
{
LoRaWAN.join();
break;
}
case DEVICE_STATE_SEND:
{
getMeasure();
prepareTxFrame( appPort );
LoRaWAN.send(loraWanClass);
pinMode(LEDPin,OUTPUT);
digitalWrite(LEDPin, LOW);
deviceState = DEVICE_STATE_CYCLE;
break;
}
case DEVICE_STATE_CYCLE:
{
// Schedule next packet transmission
txDutyCycleTime = appTxDutyCycle + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
LoRaWAN.cycle(txDutyCycleTime);
deviceState = DEVICE_STATE_SLEEP;
break;
}
case DEVICE_STATE_SLEEP:
{
LoRaWAN.sleep(loraWanClass,debugLevel);
break;
}
default:
{
deviceState = DEVICE_STATE_INIT;
break;
}
}

}