Facing issues with getting location

I am using gnss module of ec200ucn.. for which i am using the following sequence for getting location:

  1. Configure gnss after boot one time..
  2. Get location using qgpsloc

I am sharing my code snippet which is based on esp32 s3..

esp_err_t gsm_gnss_configure_once(void) {
    char resp[GSM_MAX_RESPONSE_LEN];

    if (!gnss_cfg_done) {
        // AGPS server (once)
        (void)gsm_send_command_wait_response(
            "AT+QAGPSCFG=1,\"http://quectel-api1.rx-networks.cn/rxn-api/locationApi/rtcm\","
            "\"wLgWwv6JQt\",\"Quectel\",\"aFltUERDZzZxeTY5cEp2eA==\",1,\"iot.com\"",
            "OK", resp, GSM_UART_TIMEOUT_MS);

        // Enable AGPS 
        if (!agps_enabled) {
            if (gsm_send_command_wait_response("AT+QAGPS=1", "OK", resp, GSM_UART_TIMEOUT_MS) == ESP_OK) {
                agps_enabled = true;
            }
        }

        // GNSS config
        (void)gsm_send_command_wait_response("AT+QGPSCFG=\"gnssconfig\",5", "OK", resp, GSM_UART_TIMEOUT_MS);
        (void)gsm_send_command_wait_response("AT+QGPSCFG=\"gpsnmeatype\",31", "OK", resp, GSM_UART_TIMEOUT_MS);
        (void)gsm_send_command_wait_response("AT+QGPSCFG=\"beidounmeatype\",31", "OK", resp, GSM_UART_TIMEOUT_MS);

        gnss_cfg_done = true;
        ESP_LOGI(TAG, "GNSS one-time configuration finished");
    }
    return ESP_OK;
}

esp_err_t gsm_get_location(gps_data_t *gps_data) {
    esp_err_t ret;
    char response[GSM_MAX_RESPONSE_LEN];
    int retry_count = 2;

    // init struct...
    memset(gps_data, 0, sizeof(*gps_data));
    gps_data->is_valid = false;

    // Ensure engine on
    ret = gsm_send_command_wait_response("AT+QGPS?", "OK", response, GSM_UART_TIMEOUT_MS);
    if (ret != ESP_OK || strstr(response, "+QGPS: 1") == NULL) {
        ESP_LOGI(TAG, "Starting GNSS engine…");
        ret = gsm_send_command_wait_response("AT+QGPS=1,30,500,0,1", "OK", response, GSM_UART_TIMEOUT_MS);
        if (ret != ESP_OK) {
            ESP_LOGW(TAG, "Failed to start GNSS engine: %s", response);
            return ESP_FAIL;
        }
        vTaskDelay(pdMS_TO_TICKS(1000));
    }

    while (retry_count-- > 0) {
        ret = gsm_send_command_wait_response("AT+QGPSLOC=2", "OK", response, 5000);
        if (ret == ESP_OK && strstr(response, "+QGPSLOC:")) {
            char *q = strstr(response, "+QGPSLOC:");
            if (q && parse_gps_response(q, gps_data) && gps_data->is_valid) {
                gps_valid = true;
                return ESP_OK;
            }
        } else if (ret != ESP_OK || strstr(response, "+CME ERROR: 516")) {
            // fallback
            (void)gsm_send_command_wait_response("AT+QGPSGNMEA=\"GGA\"", "OK", response, GSM_UART_TIMEOUT_MS);
        }
        vTaskDelay(pdMS_TO_TICKS(3000));
    }

    gps_valid = false;
    return ESP_FAIL;
}

We have tested on 7 devices.. Only 1 device gave the full location and worked properly.. but in case of other 6 we didn’t get the location.. sometimes we get only 1 or 2 location point but we should get around 500 points for a location tetsing trip..

can someone check the location at command sequence and suggest if some change is needed?

@Raphael-Q Please help to look into this issue.