arduino代码中的http语法错误错误

Error in http syntax error in arduino code

下面的函数描述了使用 gps 模块的 adruino shield 和 uno board 的一组值。

我收到一些错误,可能是语法错误。请忽略指出错误的行。我不希望人们看到大量编码时感到害怕。

void send_HTTP(){

uint8_t answer=0;
// Initializes HTTP service
answer = sendATcommand("AT+HTTPINIT", "OK", 10000);
if (answer == 1)
{
    // Sets CID parameter
    answer = sendATcommand("AT+HTTPPARA=\"CID\",1", "OK", 5000);
    if (answer == 1)
    {
        // Sets url 
        sprintf(aux_str, "AT+HTTPPARA=\"URL\",\"http://%s/demo_sim908.php?", url);// line number :459
        Serial.print(aux_str);
        sprintf(frame, "visor=false&latitude=%s&longitude=%s&altitude=%s&time=%s&satellites=%s&speedOTG=%s&course=%s",       
        latitude, longitude, altitude, date, satellites, speedOTG, course);   // line number : 460
        Serial.print(frame);
        answer = sendATcommand("\"", "OK", 5000);
        if (answer == 1)
        {
            // Starts GET action
            answer = sendATcommand("AT+HTTPACTION=0", "+HTTPACTION:0,200", 30000);
            if (answer == 1)
            {

                Serial.println(F("Done!"));
            }
            else
            {
                Serial.println(F("Error getting url"));
            }

        }
        else
        {
            Serial.println(F("Error setting the url"));
        }
    }
    else
    {
        Serial.println(F("Error setting the CID"));
    }    
}
else
{
    Serial.println(F("Error initializating"));
}

sendATcommand("AT+HTTPTERM", "OK", 5000);

}

我收到以下错误。

Arduino: 1.7.5 (Windows 8.1), Board: "Arduino Uno"

sketch_aug22e.ino:459:13: error: missing terminating " character

sketch_aug22e.ino: In function 'void send_HTTP()':

sketch_aug22e.ino:460:34: error: expected ')' before ';' token

Error compiling.

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.

你在第459行的引号数量不均匀:

sprintf(aux_str, "AT+HTTPPARA=\"URL\",\"http://%s/demo_sim908.php?", url);

这让编译器感到困惑。

很难说不知道你到底想做什么,但如果你打印 3 个单独的字符串,那么你可能不想 'ESC' 第三个字符串 - 例如:

sprintf(aux_str, "AT+HTTPPARA=\"URL\"", "http://%s/demo_sim908.php?", url);

或者,如果您只是想打印两个字符串,而 http 之前的 'comma' 只是字符串的一部分,那么您可能只需要关闭 'ESCed' URL :

sprintf(aux_str, "AT+HTTPPARA=\"URL\",http://%s/demo_sim908.php?\", url);