天天看點

基于esp8266網絡氣象時鐘(二)

和風天氣( HeFeng)

程式(HeFeng.cpp)

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>  
#include <WiFiClientSecureBearSSL.h>  
#include "HeFeng.h"


HeFeng::HeFeng() {

}




void HeFeng::doUpdateCurr(HeFengCurrentData *data, String key,String location) {

    std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);    
    client->setInsecure();    
    HTTPClient https;  
    String url="https://free-api.heweather.net/s6/weather/now?+location+"&key="+key;
  Serial.print("[HTTPS] begin...\n");  
    if (https.begin(*client, url)) {  // HTTPS    
      // start connection and send HTTP header  
      int httpCode = https.GET();    
      // httpCode will be negative on error  
      if (httpCode > 0) {  
        // HTTP header has been send and Server res
           

繼續閱讀