CircuitDesign.Cloud and GeoLinker - command errors in sketch

uint8_t status = geo.loop()

switch (status) {

case STATUS_SENT:

Serial.println("Data sent successfully!");

break;

case STATUS_GPS_ERROR:

Serial.println("GPS connection error!");

break;

case STATUS_NETWORK_ERROR:

Serial.println("Network error (buffered).");

break;

case STATUS_BAD_REQUEST_ERROR:

Serial.println("Bad request error!");

break;

case STATUS_PARSE_ERROR:

Serial.println("GPS data format error!");

break;

case STATUS_CELLULAR_NOT_REGISTERED:

Serial.println("GSM: Not registered to network!");

break;

}

if ((status != STATUS_GPS_ERROR) && (status != STATUS_PARSE_ERROR)) {

digitalWrite(GPSFix_LED, HIGH);

} else {

digitalWrite(GPSFix_LED, LOW);

}

if (status == STATUS_SENT) {

digitalWrite(DataSent_LED, HIGH);

delay(1000);

digitalWrite(DataSent_LED, LOW);

}

}'

Errors
error: expected unqualified-id before 'else'
error: expected unqualified-id before 'if'
error: expected declaration before '}' token
expected unqualified-id before 'switch'

Please read the pinned post re 'How to get the most from the forum'.

I don't believe that's the the full error message.

However, the obvious mistake in your code is this:

Missing ; at the end.

Thank you for your reply. The semi-colon was missed-off when I copied the relevant section of software.
Yes, you are right the above copy of the error messages is not the whole picture. Here is the complete text:

C:\Users\panda\Documents\Arduino sketches\sketch_ESP32_GPS\sketch_ESP32_GPS.ino:64:1: error: expected unqualified-id before 'switch'
   64 | switch (status) {
      | ^~~~~~
C:\Users\panda\Documents\Arduino sketches\sketch_ESP32_GPS\sketch_ESP32_GPS.ino:84:1: error: expected unqualified-id before 'if'
   84 | if ((status != STATUS_GPS_ERROR) && (status != STATUS_PARSE_ERROR)) {
      | ^~
C:\Users\panda\Documents\Arduino sketches\sketch_ESP32_GPS\sketch_ESP32_GPS.ino:86:3: error: expected unqualified-id before 'else'
   86 | } else {
      |   ^~~~
C:\Users\panda\Documents\Arduino sketches\sketch_ESP32_GPS\sketch_ESP32_GPS.ino:89:1: error: expected unqualified-id before 'if'
   89 | if (status == STATUS_SENT) {
      | ^~
C:\Users\panda\Documents\Arduino sketches\sketch_ESP32_GPS\sketch_ESP32_GPS.ino:94:1: error: expected declaration before '}' token
   94 | }
      | ^
exit status 1

Compilation error: expected unqualified-id before 'switch'

I hope the above is more useful.

Thanks but you have yet to post the relevant section of the software: all of it.

type or paste code her
uint8_t status = geo.loop();

switch (status) {
case STATUS_SENT:
Serial.println("Data sent successfully!");
break;
case STATUS_GPS_ERROR:
Serial.println("GPS connection error!");
break;
case STATUS_NETWORK_ERROR:
Serial.println("Network error (buffered).");
break;
case STATUS_BAD_REQUEST_ERROR:
Serial.println("Bad request error!");
break;
case STATUS_PARSE_ERROR:
Serial.println("GPS data format error!");
break;
case STATUS_CELLULAR_NOT_REGISTERED:
Serial.println("GSM: Not registered to network!");
break;
}
if ((status != STATUS_GPS_ERROR) && (status != STATUS_PARSE_ERROR)) {
digitalWrite(GPSFix_LED, HIGH);
} else {
digitalWrite(GPSFix_LED, LOW);
}
if (status == STATUS_SENT) {
digitalWrite(DataSent_LED, HIGH);
delay(1000);
digitalWrite(DataSent_LED, LOW);
}
}

e

I also enclose again a list of the errors. After verifying the programme once more, these are still the same. When the sketch was first written these errors did not show-up; this is what has confused me!

@panda-henderson ,

Please read the forum guide as suggested in reply #2 by @sonofcy then post all your code, not just a bit of it.

Thank you.

When you post ALL the code then we can try to verify it and by auto-formatting it sometimes we can even quickly see something wrong. Until you do that our hands are tied.

Thank you for your reply. Here is the complete code:

#include <ArduinoJson.h>

#include <GeoLinker.h>
// GPS Configuration
HardwareSerial gpsSerial(1);
#define GPS_RX 16 
#define GPS_TX 17 
#define GPS_BAUD 9600

// GSM Configuration
HardwareSerial gsmSerial(2);
#define GSM_RX 18 
#define GSM_TX 19 
#define GSM_BAUD 9600
#define GSM_PWR_PIN -1
#define GSM_RST_PIN -1

// Network credentials
const char* apn = "prepay.tesco-mobile.com"; // Replace with your carrier's APN
const char* gsmUser = nullptr;
const char* gsmPass = nullptr;

// GeoLinker settings
const char* apiKey = "cd_ale_280126_xQ_qS-"; // Replace with your API key
const char* deviceID = "ESP32_Sim800l";

const uint16_t updateInterval = 30;
const bool enableOfflineStorage = true;
const uint8_t offlineBufferLimit = 20;

const bool enableAutoReconnect = true;
const int8_t timeOffsetHours = 5;
const int8_t timeOffsetMinutes = 30;

// LED pins
const int DataSent_LED = 32;
const int GPSFix_LED = 23;

GeoLinker geo;

void setup() {
Serial.begin(115200);
gpsSerial.begin(GPS_BAUD, SERIAL_8N1, GPS_RX, GPS_TX);
gsmSerial.begin(GSM_BAUD, SERIAL_8N1, GSM_RX, GSM_TX);
pinMode(DataSent_LED, OUTPUT);
pinMode(GPSFix_LED, OUTPUT);
geo.begin(gpsSerial);
geo.setApiKey(apiKey);
geo.setDeviceID(deviceID);
geo.setUpdateInterval_seconds(updateInterval);
geo.setDebugLevel(DEBUG_BASIC);
geo.enableOfflineStorage(enableOfflineStorage);
geo.enableAutoReconnect(enableAutoReconnect);
geo.setOfflineBufferLimit(offlineBufferLimit);
geo.setTimeOffset(timeOffsetHours, timeOffsetMinutes);
geo.setNetworkMode(GEOLINKER_CELLULAR);
geo.setModemCredentials(apn, gsmUser, gsmPass);
geo.beginModem(gsmSerial, GSM_PWR_PIN, GSM_RST_PIN, true);
geo.setModemTimeouts(5000, 15000);
}

uint8_t status = geo.loop();

switch (status) {
case STATUS_SENT:
Serial.println("Data sent successfully!");
break;
case STATUS_GPS_ERROR:
Serial.println("GPS connection error!");
break;
case STATUS_NETWORK_ERROR:
Serial.println("Network error (buffered).");
break;
case STATUS_BAD_REQUEST_ERROR:
Serial.println("Bad request error!");
break;
case STATUS_PARSE_ERROR:
Serial.println("GPS data format error!");
break;
case STATUS_CELLULAR_NOT_REGISTERED:
Serial.println("GSM: Not registered to network!");
break;
}
if ((status != STATUS_GPS_ERROR) && (status != STATUS_PARSE_ERROR)) {
digitalWrite(GPSFix_LED, HIGH);
} else {
digitalWrite(GPSFix_LED, LOW);
}
if (status == STATUS_SENT) {
digitalWrite(DataSent_LED, HIGH);
delay(1000);
digitalWrite(DataSent_LED, LOW);
}
}

All the above code is outside any function.

The loop function is missing, I'm guessing the above code should be inside the loop function.

Please look at the example in the IDE to see how code should contain at least a setup and a loop function.

@PerryBebbington I agree with Perry, the missing loop and a small (optional) rearrangement results in a successful compile although some libraries are not clean.

Whoever wrote this for you goes on my list.

Thank you for your help and useful next step; I will see what I can do

Thank you for your help; I will look at examples in Arduino IDE to see if there is a solution there.