[SOLVED] Sscanf() not saving sting sections to variables

You are correct @westfw, I ended up going with a different method to achieve the desired results and it's working now. And @johnwasser I corrected that issue. Thank you guys! @johnwasser @Koepel @westfw

new format:


#include "heltec.h"

#define BAND    915E6  //you can set band here directly,e.g. 868E6,915E6

char str[] = "";
int id = 0;
int hourRead = 0;
int minRead = 0;
int secRead = 0;
float latRead = 0.0;
float lonRead = 0.0;
float altRead = 0.0;
int sensorRead = 0;
float voltRead = 0.0;
float percRead = 0.0;
String rc = "";
void setup() {
  //WIFI Kit series V1 not support Vext control
  Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
  Serial.begin(115200);

}

void loop() {
  // try to parse packet

  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    // received a packet
    Serial.println("Received packet '");
    // read packet
    while (LoRa.available()) {
      rc = LoRa.readString();
      int str_len = rc.length() + 1;
      rc.toCharArray(str, str_len);
      char * strtokIndx; // this is used by strtok() as an index
      strtokIndx = strtok(str, ","); // this continues where the previous call left off
      id = atoi(strtokIndx);     // convert this part to an integer

      strtokIndx = strtok(NULL, ",");
      hourRead = atoi(strtokIndx);     // convert this part to a float

      strtokIndx = strtok(NULL, ",");
      minRead = atoi(strtokIndx);     // convert this part to a float

      strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
      secRead = atoi(strtokIndx);     // convert this part to an integer

      strtokIndx = strtok(NULL, ",");
      latRead = atof(strtokIndx);     // convert this part to a float

      strtokIndx = strtok(NULL, ",");
      lonRead = atof(strtokIndx);     // convert this part to a float

      strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
      altRead = atof(strtokIndx);     // convert this part to an integer

      strtokIndx = strtok(NULL, ",");
      sensorRead = atoi(strtokIndx);     // convert this part to a float

      strtokIndx = strtok(NULL, ",");
      voltRead = atof(strtokIndx);     // convert this part to a float

      strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
      percRead = atof(strtokIndx);     // convert this part to an integer

      Serial.println(rc);
      showData();
    }
  }
}

void showData() {
  Serial.print("ID: "); Serial.println(id);
  Serial.print("Time: "); Serial.print(hourRead); Serial.print(":"); Serial.print(minRead); Serial.print(":"); Serial.println(secRead);
  Serial.print("Location: "); Serial.print(latRead,6); Serial.print(","); Serial.println(lonRead,6);
  Serial.print("Altitude: "); Serial.println(altRead);
  Serial.print("Sensor Reading: "); Serial.println(sensorRead);
  Serial.print("Voltage: "); Serial.println(voltRead);
  Serial.print("Battery: "); Serial.print(percRead); Serial.println("%");
}