0

我已经按照几个说明从 ESP8266 连接到 Pushbullet 这是一个代码片段

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

const char* ssid = ".......";
const char* password = ".......";
const char* host = "api.pushbullet.com";
const int httpsPort = 443;
const char* PushBulletAPIKEY = "..............."; //get it from your pushbullet account

// Use web browser to view and copy
// SHA1 fingerprint of the certificate
const char* fingerprint = "2C BC 06 10 0A E0 6E B0 9E 60 E5 96 BA 72 C5 63 93 23 54 B3"; //got it using https://www.grc.com/fingerprints.htm

void setup() {
  Serial.begin(115200);
  Serial.println();

  Serial.print("connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Use WiFiClientSecure class to create TLS connection
  WiFiClientSecure client;
  Serial.print("connecting to ");
  Serial.println(host);
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }

它失败了!client.connect(host, httpsPort)

使用浏览器 api.pushbullet.com:443 失败

https://api.pushbullet.com返回一个不错的 JSON 代码

是否可以使用https://api.pushbullet.com进行连接?

有端口问题吗?

帮助表示赞赏。

PS 来自 RPI

curl --header 'Access-Token: o.abcdefghijklmnopqrstuvwxyz' \ https://api.pushbullet.com/v2/users/me

奇迹般有效。

4

1 回答 1

0

找到解决方案。

   // Use WiFiClientSecure class to create TLS connection
   WiFiClientSecure client;
   Serial.print("connecting to ");
   Serial.println(host);
   if (!client.connect(host, httpsPort)) {
     Serial.println("connection failed");
     return;
   }

添加:<client.setInsecure();> 就在下面:WiFiClientSecure 客户端;

在 GitHub 某处找到它,只是分享以帮助其他人找到解决方案。

于 2020-12-13T21:54:57.830 回答