Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions arduino-esp32/AWS_IOT/src/AWS_IOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ void disconnectCallbackHandler(AWS_IoT_Client *pClient, void *data)
}


int AWS_IOT::connect(char *hostAddress, char *clientID, char *aws_root_ca, char *aws_cert, char *aws_key )
{
return _connect(hostAddress, clientID, aws_root_ca, aws_cert, aws_key );
}

int AWS_IOT::connect(char *hostAddress, char *clientID)
{
return _connect(hostAddress, clientID, aws_root_ca_pem, certificate_pem_crt, private_pem_key );
}

int AWS_IOT::_connect(char *hostAddress, char *clientID, const char *aws_root_ca, const char *aws_cert, const char *aws_key )
{
const size_t stack_size = 36*1024;

Expand All @@ -132,18 +142,16 @@ int AWS_IOT::connect(char *hostAddress, char *clientID)
mqttInitParams.port = CONFIG_AWS_IOT_MQTT_PORT;


mqttInitParams.pRootCALocation = (const char *)aws_root_ca_pem;
mqttInitParams.pDeviceCertLocation = (const char *)certificate_pem_crt;
mqttInitParams.pDevicePrivateKeyLocation = (const char *)private_pem_key;

mqttInitParams.pRootCALocation = (const char *)aws_root_ca;
mqttInitParams.pDeviceCertLocation = (const char *)aws_cert;
mqttInitParams.pDevicePrivateKeyLocation = (const char *)aws_key;

mqttInitParams.mqttCommandTimeout_ms = 20000;
mqttInitParams.tlsHandshakeTimeout_ms = 5000;
mqttInitParams.isSSLHostnameVerify = true;
mqttInitParams.disconnectHandler = disconnectCallbackHandler;
mqttInitParams.disconnectHandlerData = NULL;


rc = aws_iot_mqtt_init(&client, &mqttInitParams);

if(SUCCESS != rc) {
Expand Down Expand Up @@ -189,7 +197,6 @@ int AWS_IOT::connect(char *hostAddress, char *clientID)
return rc;
}


int AWS_IOT::publish(char *pubtopic,char *pubPayLoad)
{
IoT_Error_t rc;
Expand Down
4 changes: 3 additions & 1 deletion arduino-esp32/AWS_IOT/src/AWS_IOT.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ typedef void (*pSubCallBackHandler_t)(char *topicName, int payloadLen, char *pay
class AWS_IOT{

private:

int _connect(char *hostAddress, char *clientID, const char *aws_root_ca, const char *aws_cert, const char *aws_key );

public:
int connect(char *hostAddress, char *clientID);
int connect(char *hostAddress, char *clientID, char *aws_root_ca, char *aws_cert, char *aws_key );
int publish(char *pubtopic,char *pubPayLoad);
int subscribe(char *subTopic, pSubCallBackHandler_t pSubCallBackHandler);
};
Expand Down