我正在尝试连接 NodeMCU ESP8266 并上传影子。我正在学习 IoT Design Pro 的教程。当我第一次运行它时,我确实看到 AWS 上更新了影子。在随后的循环中,它停止更新。现在我收到一条消息“无法设置 SSL 连接”。这是我的代码和串行输出窗口:
#include <ESP8266WiFi.h>
#include <AmazonIOTClient.h>
#include "ESP8266AWSImplementations.h"
Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;
AmazonIOTClient iotClient;
ActionError actionError;
char *ssid="xxxxxxxxxxxxxxxxxxx";
char *password="xxxxxxxxxxx";
void setup() {
Serial.begin(115200);
delay(10);
// Connect to WAP
Serial.print("Connecting to ");
Serial.println(ssid);
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());
iotClient.setAWSRegion("us-west-2");//axxxxxxxxxxxb-ats.iot.us-west-2.amazonaws.com
iotClient.setAWSEndpoint("amazonaws.com");
iotClient.setAWSDomain("axxxxxxxxxxxb-ats.iot.us-west-2.amazonaws.com");
iotClient.setAWSPath("/things/MyThing/shadow");
iotClient.setAWSKeyID("AxxxxxxxxxxxxxxxxxxW");
iotClient.setAWSSecretKey("BxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxWmN1");
iotClient.setHttpClient(&httpClient);
iotClient.setDateTimeProvider(&dateTimeProvider);
}
void loop(){
char* shadow = "{\"state\":{\"reported\": {\"Foobar\": \"bar\"}}}";
char* result = iotClient.update_shadow(shadow, actionError);
Serial.print(result);
delay(500000);
}
带串行输出:
WiFi connected
IP address:
10.1.10.128
a2rl12mynda91b-ats.iot.us-west-2.amazonaws.com
443
POST /things/MyThing/shadow HTTP/1.1
Content-Type: application/json
Connection: close
Content-Length: 41
Host: axxxxxxxxxxxb-ats.iot.us-west-2.amazonaws.com
x-amz-content-sha256: d8af3f7d20512e6c2f9feddf0e729a9f9201023da39cde8ffa6826175c069174
x-amz-date: 20200122T221521Z
Authorization: AWS4-HMAC-SHA256 Credential=AxxxxxxxxxxxxxxxxxxW/20200122/us-west-2/iotdata/aws4_request,SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date,Signature=1d5e8b7d70a67d91704403796fd7bdae28b7f9396523314af98e3e1857b4368a
{"state":{"reported": {"Foobar": "bar"}}}
can't setup SSL connection
和 AWS IoT 影子输出: 串行输出是否表明它已连接?我认为使用授权行意味着它正在连接,不是吗?我看不出哪里出错了。
谢谢。