Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 29c5299

Browse files
author
Alberto Iannaccone
committedAug 22, 2018
use AWS server
1 parent 520748e commit 29c5299

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed
 

‎src/ArduinoCloud.cpp

+13-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <utility/ECCX08Cert.h>
55
#include "CloudSerial.h"
66

7-
const static char server[] = "broker.shiftr.io"; //"a19g5nbe27wn47.iot.us-east-1.amazonaws.com"; //"xxxxxxxxxxxxxx.iot.xx-xxxx-x.amazonaws.com";
7+
const static char server[] = "a19g5nbe27wn47.iot.us-east-1.amazonaws.com"; //"xxxxxxxxxxxxxx.iot.xx-xxxx-x.amazonaws.com";
88

99
const static int keySlot = 0;
1010
const static int compressedCertSlot = 10;
@@ -28,7 +28,7 @@ ArduinoCloudClass::~ArduinoCloudClass()
2828
int ArduinoCloudClass::begin(Client& net)
2929
{
3030
byte thingIdBytes[72];
31-
/*
31+
3232
if (!ECCX08.begin()) {
3333
return 0;
3434
}
@@ -57,11 +57,9 @@ int ArduinoCloudClass::begin(Client& net)
5757
}
5858
_bearSslClient = new BearSSLClient(net);
5959
_bearSslClient->setEccSlot(keySlot, ECCX08Cert.bytes(), ECCX08Cert.length());
60-
*/
61-
//END of TLS communication part. The result of that part is *_bearSslClient [Network Client]
6260

6361
// Begin function for the MQTTClient
64-
mqttClientBegin(net);
62+
mqttClientBegin(*_bearSslClient);
6563
// Thing initialization
6664
Thing.begin();
6765

@@ -72,30 +70,27 @@ int ArduinoCloudClass::begin(Client& net)
7270
void ArduinoCloudClass::mqttClientBegin(Client& net)
7371
{
7472
// MQTT topics definition
75-
_id = "XXX";
76-
77-
_stdoutTopic = "/a/d/" + _id + "/s/o";
78-
_stdinTopic = "/a/d/" + _id + "/s/i";
79-
_dataTopicIn = "/a/d/" + _id + "/e/i";
80-
_dataTopicOut = "/a/d/" + _id + "/e/o";
73+
_stdoutTopic = "$aws/things/" + _id + "/stdout";
74+
_stdinTopic = "$aws/things/" + _id + "/stdin";
75+
_dataTopicIn = "$aws/things/" + _id + "/datain";
76+
_dataTopicOut = "$aws/things/" + _id + "/dataout";
8177

8278
// use onMessage as callback for received mqtt messages
8379
_mqttClient.onMessageAdvanced(ArduinoCloudClass::onMessage);
84-
//_mqttClient.begin(server, 8883, *_bearSslClient);
85-
_mqttClient.begin(server, 1883, net);
80+
_mqttClient.begin(server, 8883, net);
8681
// Set will for MQTT client: {topic, qos, retain message}
87-
const char lastMessage[] = "abcb";
88-
_mqttClient.setWill(_dataTopicOut.c_str(), lastMessage, false, 1);
89-
// Set MQTT connection options
90-
_mqttClient.setOptions(mqttOpt.keepAlive, mqttOpt.cleanSession, mqttOpt.timeout);
82+
// const char lastMessage[] = "abcb";
83+
// _mqttClient.setWill(_dataTopicOut.c_str(), lastMessage, false, 1);
84+
// // Set MQTT connection options
85+
// _mqttClient.setOptions(mqttOpt.keepAlive, mqttOpt.cleanSession, mqttOpt.timeout);
9186
}
9287

9388
int ArduinoCloudClass::connect()
9489
{
9590
//TODO MQTT brocker connection
9691
// Username: device id
9792
// Password: empty
98-
if (!_mqttClient.connect(_id.c_str(), "try", "try")) {
93+
if (!_mqttClient.connect(_id.c_str())) {
9994
return 0;
10095
}
10196
_mqttClient.subscribe(_stdinTopic);

0 commit comments

Comments
 (0)
Please sign in to comment.