本文整理汇总了C++中HTTPClient::errorToString方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPClient::errorToString方法的具体用法?C++ HTTPClient::errorToString怎么用?C++ HTTPClient::errorToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPClient
的用法示例。
在下文中一共展示了HTTPClient::errorToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendThingSpeakValues
void ICACHE_FLASH_ATTR ThingSpeakClass::SendThingSpeakValues()
{
// if (ThingEnabled) DebugPrintln("thingspeak enabled"); else DebugPrintln("thingspeak disabled");
if (ThingEnabled == false) return;
if (thingSpeakURL == "") return;
DebugPrintln(thingSpeakURL);
if (WiFi.status() != WL_CONNECTED) return; //check to make sure we are connected...
String postStr = "api_key=" + thingWriteKey;
if (HMGlobal.hmPitTemp != "U") postStr += "&field1=" + HMGlobal.hmPitTemp;
if (HMGlobal.hmFood1 != "U") postStr += "&field2=" + HMGlobal.hmFood1;
if (HMGlobal.hmFood2 != "U") postStr += "&field3=" + HMGlobal.hmFood2;
if (HMGlobal.hmAmbient != "U") postStr += "&field4=" + HMGlobal.hmAmbient;
if (HMGlobal.hmFanMovAvg != "U") postStr += "&field5=" + HMGlobal.hmFanMovAvg;
if (HMGlobal.hmFan != "U") postStr += "&field6=" + HMGlobal.hmFan;
if (HMGlobal.hmSetPoint != "U") postStr += "&field7=" + HMGlobal.hmSetPoint;
if (HMGlobal.hmLidOpenCountdown != "U") postStr += "&field8=" + HMGlobal.hmLidOpenCountdown;
if (inAlarm) //if alarm was triggered we send on next msg
{
postStr += "&status=" + MyWebServer.urlencode(MyWebServer.CurTimeString() + " " + AlarmInfo);
AlarmInfo = "";
inAlarm = false;
}
HTTPClient http;
DebugPrintln("http://" + thingSpeakURL + "/update");
http.begin("http://" + thingSpeakURL + "/update");
int httpCode = http.POST(postStr);
// httpCode will be negative on error
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK) {
}
}
else {
DebugPrintln("[HTTP] POST... failed, error: " + http.errorToString(httpCode));
}
http.end();
DebugPrintln("sending thingspeak stuffs");
}
示例2: getHTTPFile
String getHTTPFile(String url) {
HTTPClient http;
String payload;
// Serial << "Retriving HTTP: " << url << endl;
http.begin(url); //HTTP
int httpCode = http.GET();
if(httpCode > 0) {
if (DEBUG) Serial << F("[HTTP] GET... code:") << httpCode << endl;
if(httpCode == HTTP_CODE_OK) payload = http.getString();
} else {
if (DEBUG) Serial << F("[HTTP] GET... failed, error:") << http.errorToString(httpCode).c_str() << endl;
}
http.end();
return payload;
}
示例3: getThingSpeak
String ICACHE_FLASH_ATTR ThingSpeakClass::getThingSpeak(String talkBackID, String talkApiKey) //talkback message processing
{ //TalkBack Function from thingspeak
String pageLength;
String CommandString = "";
String HTMLResult;
bool GoodResult = false;
DebugPrintln("talkback checking...");
if (TalkBackEnabled == false) return "";
if (thingSpeakURL == "") return "";
if (WiFi.status() != WL_CONNECTED) return ""; //check to make sure we are connected...
String url = "/talkbacks/" + talkBackID + "/commands/execute?api_key=" + talkApiKey;
HTTPClient http;
http.begin("http://"+ thingSpeakURL + url);
int httpCode = http.GET();
// httpCode will be negative on error
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
//DebugPrintln("[HTTP] GET... code: " + String(httpCode));
// file found at server
if (httpCode == HTTP_CODE_OK) {
CommandString = http.getString();
}
}
else {
DebugPrintln("[HTTP] GET... failed, error: " + http.errorToString(httpCode));
}
http.end();
CommandString.replace("\n", "");
if (CommandString!="") DebugPrintln("Got talkback result : " + CommandString);
return CommandString;
}
示例4: loop
void loop() {
String url = "http://things.ubidots.com/api/v1.6/variables/" ID_VARIABLE "/values";
http.begin(url);
http.addHeader("Content-Type", "application/json");
http.addHeader("X-Auth-Token", AUTH_TOKEN);
int content_length =0;
String payload = String("{ \"value\": " + String(millis()/1000) + "}");
//content_length = payload.length();
//http.addHeader("Content-Length", String(content_length));
int httpCode = http.POST(payload);
if(httpCode > 0) {
String payload = http.getString();
Serial.println(payload);
}
else {
Serial.print("[HTTP] failed, error: ");Serial.println(http.errorToString(httpCode).c_str());
}
http.end();
delay(20000);
}