Heltec Cubecell hang when in Device State Send

Hi, Everyone. I have a problem by using the GY-NEO6MV2 Ublox GPS module with the Heltec Cubecell AB02A on Platformio. When the cubecell in case of DEVICE_STATE_SEND it hanged and didn’t send data to my gateway. However, I try to solve this problem by

  1. Write the code from scratch.
  2. Using the TinyGPS library.
  3. Reset the cubecell every sending 60 times.
  4. Config the GPS to send only GPRMC data.
    Thank you
    This is my latest version.
    include “LoRaWan_APP.h”

#include “Arduino.h”

#include “TinyGPS++.h”

#include “SoftSerial.h”

#include <define.h>

softSerial ss(GPIO5, GPIO7);

TinyGPSPlus gps;

uint8_t devEui[] = { 0xDA, 0x98, 0x35, 0x50, 0x39, 0x5E, 0x92, 0xA6 };

uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

uint8_t appKey[] = { 0x06, 0xD3, 0x9A, 0x81, 0xFE, 0x19, 0x38, 0xC1, 0xE7, 0x12, 0x97, 0xBF, 0x83, 0x8F, 0xF5, 0x26 };

uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 };

uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 };

uint32_t devAddr = ( uint32_t )0x007e6ae1;

uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 };

LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;

DeviceClass_t loraWanClass = LORAWAN_CLASS;

uint32_t appTxDutyCycle = 10000 ;

bool overTheAirActivation = LORAWAN_NETMODE;

bool loraWanAdr = LORAWAN_ADR;

bool keepNet = LORAWAN_NET_RESERVE;

bool isTxConfirmed = LORAWAN_UPLINKMODE;

uint8_t appPort = 2;

uint8_t confirmedNbTrials = 4;

void speeddivided() {

fulldata = speed ; // 12550

decimal_prt = fulldata % 100 ; // 50

number_prt = (fulldata - decimal_prt) / 100 ; // 125

realData[3] = number_prt ;

realData[4] = decimal_prt ;

}

void longtitudedivided() {

fulldata = longitude_encoded ; // 100444256

decimal_prt = fulldata % 1000000 ; // 444256

number_prt = (fulldata - decimal_prt) / 1000000 ; // 100

realData[5] = number_prt ;

// decimal first&second digit

realData[6] = int(decimal_prt / 10000) ; // 44

// decimal third&fourth digit

realData[7] = ((decimal_prt - (realData[6] * 10000)) / 100) ; // 42

// decimal fifth&sixth digit

realData[8] = decimal_prt % 100 ; // 56

}

void latitudedivided() {

fulldata = latitude_encoded ;

decimal_prt = fulldata % 1000000 ; // 11|11|11

number_prt = (fulldata - decimal_prt) / 1000000 ; // 16

realData[9] = number_prt ;

// decimal first&second digit

realData[10] = int(decimal_prt / 10000) ; // 11

// decimal third&fourth digit

realData[11] = ((decimal_prt - (realData[10] * 10000)) / 100) ; // 11

// decimal fifth&sixth digit

realData[12] = decimal_prt % 100 ; // 11

}

void PrepareDataForSending() { //must be transform index 3, 4, 5

realData[0] = new_hour ;

realData[1] = new_min ;

realData[2] = new_sec ;

speeddivided() ;

longtitudedivided() ;

latitudedivided() ;

}

void time(int hour, int min, int sec) {

time_hour_THAI = hour + UTC_TH ;

if (time_hour_THAI > 24) {

new_hour = (time_hour_THAI - 24) + 1 ;

}

else {

new_hour = time_hour_THAI ;

}

new_min = min ;

new_sec = sec ;

}

static void prepareTxFrame( uint8_t port )

{

appDataSize = 13 ;

for (int k = 0 ; k < appDataSize ; k ++) {

    appData[k] = realData[k] ;

}      

}

void setup() {

Serial.begin(9600);

ss.begin(9600) ;

#if(AT_SUPPORT)

enableAt();

#endif

deviceState = DEVICE_STATE_INIT;

LoRaWAN.ifskipjoin();

}

int count = 0 ;

void loop() {

/* Code insert */

switch( deviceState )

{

    case DEVICE_STATE_INIT:

    {

#if(LORAWAN_DEVEUI_AUTO)

        LoRaWAN.generateDeveuiByChipID();

#endif

#if(AT_SUPPORT)

        getDevParam();

#endif

        printDevParam();

        LoRaWAN.init(loraWanClass,loraWanRegion);

        LoRaWAN.setDataRateForNoADR(1);

        deviceState = DEVICE_STATE_JOIN;

        break;

    }

    case DEVICE_STATE_JOIN:

    {

        LoRaWAN.join();

        break;

    }

    case DEVICE_STATE_SEND:

    {

        while (ss.available() > 0) {

            gps.encode(ss.read()) ;

        }

        if (gps.location.isUpdated()) {

            count ++ ;

            longtitude = gps.location.lng() ;

            latitude = gps.location.lat();

            speed = gps.speed.kmph() ;

            time_hour = gps.time.hour() ;

            time_minute = gps.time.minute() ;

            time_second = gps.time.second() ;

            longitude_encoded = (int32_t)(longtitude * 1000000 ); // Scale and round

            latitude_encoded = (int32_t)(latitude * 1000000 );

            speed_encoded = (int32_t)(speed * 100 ); // Scale and round to 2 decimal places

            time(time_hour, time_minute, time_second) ;

            PrepareDataForSending() ;

        }

        if (count > 60) {

            CySoftwareReset() ;

        }

        prepareTxFrame( appPort );

        LoRaWAN.send() ;

        deviceState = DEVICE_STATE_CYCLE;

        break;

    }

    case DEVICE_STATE_CYCLE:

    {

        // Schedule next packet transmission

        txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND );

        LoRaWAN.cycle(txDutyCycleTime);

        deviceState = DEVICE_STATE_SLEEP;

        break;

    }

    case DEVICE_STATE_SLEEP:

    {

        lowPowerHandler();

        break;

    }

    default:

    {

        deviceState = DEVICE_STATE_INIT;

        break;

    }

}

}

Please pay attention to whether the frequency band and other parameters are correct

I do it correctly. I use AS923_AS1