我正在尝试将测试值发送到AWS IOT Shadows,但是当我将其上传到设备时,它始终显示“无法设置SSL连接尝试发送数据”。请帮助我将此值发送给AWS IOT Shaodws!我试图将ARN更改为HTTPS端点ARN ..,并不断收到此错误消息。
#include <ESP8266WiFi.h>
#include <AmazonIOTClient.h>
#include <ESP8266AWSImplementations.h>
Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;
AmazonIOTClient iotClient;
ActionError actionError;
const char* ssid = "xxx";
const char* password = "xxx";
void initWLAN()
{
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
}
void initAWS()
{
iotClient.setAWSRegion("ap-southeast-2");
iotClient.setAWSEndpoint("amazonaws.com");
iotClient.setAWSDomain("arn:aws:iot:ap-southeast-2:489747887701:thing/IoTTestDevice");
iotClient.setAWSPath("/things/IoTTestDevice/shadow");
iotClient.setAWSKeyID("the-id");
iotClient.setAWSSecretKey("the-secret-key");
iotClient.setHttpClient(&httpClient);
iotClient.setDateTimeProvider(&dateTimeProvider);
}
void setup() {
Serial.begin(115200);
delay(10);
Serial.println("begin");
initWLAN();
Serial.println("wlan initialized");
initAWS();
Serial.println("iot initialized");
}
void loop()
{
char shadow[100];
strcpy(shadow, "{\"state\":{\"reported\":{\"test_value1\":123, \"test_value2\":234}}}");
Serial.println("Trying to send data");
Serial.print(shadow);
char* result = iotClient.update_shadow(shadow, actionError);
Serial.print(result);
delay(10000);
}
继续收到此错误消息。
12:31:04.295 -> can't setup SSL connectionTrying to send data
12:31:14.262 -> {"state":{"reported":{"test_value1":123, "test_value2":234}}}did not connect to timeserver
12:31:14.564 ->
12:31:14.564 ->
12:31:14.564 -> Exception (3):
12:31:14.564 -> epc1=0x4010011d epc2=0x00000000 epc3=0x00000000 excvaddr=0x40008550 depc=0x00000000
12:31:14.564 ->
12:31:14.564 -> ctx: cont
12:31:14.564 -> sp: 3ffefd60 end: 3fff0630 offset: 01a0
请帮助我! 谢谢
答案 0 :(得分:0)
setAWSDomain()
需要API端点,而不是ARN。
要找到API终结点,请通过转到IoT > Manage > Things > ThingName > Interact
在控制台中选择设备,然后找到HTTPS终结点。
或者,您可以从AWS CLI使用describe-endpoint
命令。
答案 1 :(得分:0)
如上所述,以下行需要使用您的端点进行更新:
From:
iotClient.setAWSDomain("arn:aws:iot:ap-southeast-2:489747887701:thing/IoTTestDevice");
To:
iotClient.setAWSDomain("axxxxxxxxxxxxz-ats.iot.ap-southeast-2.amazonaws.com");
即使解决了这个问题并假设您的esp8266开发板版本> 2.3.0和<2.6.0,您仍然可能会遇到相同的问题:-(
FWIW,esp8266 2.3.0开发板版本将连接到AWS iot,但是应用崩溃会导致另一个问题(参考:https://github.com/esp8266/Arduino/issues/4811)。我还没有找到解决方案……其他人有没有成功?