Updating the espidf-aws-iot example to use AWS Embedded C Embedded SDK v3.1.5 (#601)
Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>
This commit is contained in:
+2
-2
@@ -76,8 +76,8 @@ For additional details about API parameters refer to the [API documentation](htt
|
||||
Define the `TLSDataParams` Struct as in `network_platform.h`
|
||||
This is used for data specific to the TLS library being used.
|
||||
|
||||
`IoT_Error_t iot_tls_init(Network *pNetwork, char *pRootCALocation, const char *pDeviceCertLocation,
|
||||
const char *pDevicePrivateKeyLocation, const char *pDestinationURL,
|
||||
`IoT_Error_t iot_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
|
||||
char *pDevicePrivateKeyLocation, char *pDestinationURL,
|
||||
uint16_t DestinationPort, uint32_t timeout_ms, bool ServerVerificationFlag);`
|
||||
Initialize the network client / structure.
|
||||
|
||||
|
||||
+3
-19
@@ -1,27 +1,11 @@
|
||||
**We have released version 4.0.0 beta 1 of this SDK on the [v4_beta](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/v4_beta) branch and encourage everyone to give it a try.**
|
||||
# AWS IoT Device SDK for Embedded C
|
||||
|
||||
Version 4 is a new design, and therefore **NOT** backwards compatible with version 3.0.1. We will continue to fix bugs in v3.0.1 even after v4.0.0 is released, but we may not add new features to v3.0.1.
|
||||
This tag [3.1.5](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/v3.1.5) contains the v3 version of AWS IoT Device SDK for Embedded C. No new features will be added to this tag; instead, only bug fixes will be made and minimally tested.
|
||||
|
||||
Please be aware that v4 beta may have bugs and performance issues. Additionally, there are currently missing features compared to v3.0.1. See the [README](https://github.com/aws/aws-iot-device-sdk-embedded-C/blob/v4_beta/README.md/) on the v4_beta branch for more information.
|
||||
|
||||
## Branches
|
||||
|
||||
### Master branch
|
||||
The [master](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/master) branch will now contain bug fixes/features that have been minimally tested to ensure nothing major is broken. The current version on the master branch is v3.0.1. Eventually, we will move v4.0.0 to the master branch and move v3.0.1 to a legacy branch.
|
||||
|
||||
### Release branch
|
||||
The [release](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/release) branch will contain new releases for the SDK that have been tested thoroughly on all supported platforms. Please ensure that you are tracking the release branch for all production work. The current version on the release branch is v3.0.1. Eventually, we will move v4.0.0 to the release branch and move v3.0.1 to a legacy branch.
|
||||
|
||||
### v4_beta branch
|
||||
The [v4_beta](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/v4_beta) branch will contain new features and a new design that inherits from both the AWS IoT Device SDK Embedded C and the libraries provided with Amazon FreeRTOS. This is version 4.0.0 of the SDK. Please be aware that v4 beta may have bugs and performance issues. Eventually, we will move v4.0.0 to the master/release branches and delete v4 beta branch.
|
||||
|
||||
### Development branch
|
||||
|
||||
The [development](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/development) currently hosts development of the next iteration of the AWS IoT Embedded C SDK version 4. It is currently a work in progress and should not be used to create any products. We will update this README when that status changes.
|
||||
|
||||
## Overview
|
||||
|
||||
The AWS IoT device SDK for embedded C is a collection of C source files which can be used in embedded applications to securely connect to the [AWS IoT platform](http://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html). It includes transport clients **MQTT**, **TLS** implementations and examples for their use. It also supports AWS IoT specific features such as **Thing Shadow**. It is distributed in source form and intended to be built into customer firmware along with application code, other libraries and RTOS. For additional information about porting the Device SDK for embedded C onto additional platforms please refer to the [PortingGuide](https://github.com/aws/aws-iot-device-sdk-embedded-c/blob/master/PortingGuide.md/).
|
||||
The AWS IoT device SDK for embedded C is a collection of C source files which can be used in embedded applications to securely connect to the [AWS IoT platform](http://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html). It includes transport clients **MQTT**, **TLS** implementations and examples for their use. It also supports AWS IoT specific features such as **Thing Shadow**. It is distributed in source form and intended to be built into customer firmware along with application code, other libraries and RTOS. For additional information about porting the Device SDK for embedded C onto additional platforms please refer to the [PortingGuide](./PortingGuide.md).
|
||||
|
||||
## Features
|
||||
The Device SDK simplifies access to the Pub/Sub functionality of the AWS IoT broker via MQTT and provide APIs to interact with Thing Shadows. The SDK has been tested to work with the AWS IoT platform to ensure best interoperability of a device with the AWS IoT platform.
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
@page architecture SDK Architecture and Design
|
||||
@brief This page documents the architecture and design goals of this SDK.
|
||||
|
||||
The Embedded C SDK has a layered architecture. It is currently based on the MQTT protocol, but may support protocols like HTTP in the future.
|
||||
|
||||
This SDK is primarily targeted for resource-constrained devices.
|
||||
|
||||
@section architecture_considerations Considerations during design
|
||||
- Low memory footprint (around 6k of code size without TLS library for the MQTT layer)
|
||||
- Flexibility in picking and choosing functionality
|
||||
- Static memory only (no malloc)
|
||||
- Configurable resource usage (JSON tokens, MQTT subscription handlers, etc.)
|
||||
- Portability across RTOSes
|
||||
|
||||
@section architecture_diagram Layered architecture
|
||||
@brief There are primarily 3 layers in the SDK as shown in the diagram below.
|
||||
|
||||
@image html architecture.png
|
||||
|
||||
@subsection architecture_tls TLS layer
|
||||
|
||||
This SDK uses TLS sockets to talk to the server. We provide wrappers around mbed TLS (ARM) that allow the libraries to connect with AWS IoT Platform.
|
||||
|
||||
@subsection architecture_mqtt AWS IoT MQTT client
|
||||
|
||||
The MQTT library included in this SDK is a modification of the [Paho C MQTT client](https://www.eclipse.org/paho/clients/c/). MQTT is a standardized publish subscribe protocol popular on embedded devices. AWS IoT supports the MQTT protocol for communication with devices. This MQTT library can be used standalone or with other AWS IoT services such as Thing Shadows or Jobs.
|
||||
|
||||
@subsection architecture_shadow Thing Shadow
|
||||
|
||||
This SDK provides a client implementation for [AWS IoT Thing Shadows](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html). A device's Shadow is a JSON document that is used to store and retrieve its current state information in the cloud regardless of whether it is connected to the Internet.
|
||||
*/
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
# SDK version.
|
||||
PROJECT_NUMBER = "3"
|
||||
|
||||
# Doxygen layout file for libraries.
|
||||
LAYOUT_FILE = doc/config/layout_library.xml
|
||||
|
||||
# Documentation output directory.
|
||||
OUTPUT_DIRECTORY = doc/output/
|
||||
|
||||
# Don't generate LaTeX documentation
|
||||
GENERATE_LATEX = NO
|
||||
|
||||
# Don't rearrange members in the input files.
|
||||
SORT_MEMBER_DOCS = NO
|
||||
|
||||
# Silence output (warnings only).
|
||||
QUIET = YES
|
||||
|
||||
# Configure Doxygen for C.
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
TYPEDEF_HIDES_STRUCT = YES
|
||||
|
||||
# Disable the tab bar and use treeview instead.
|
||||
DISABLE_INDEX = YES
|
||||
GENERATE_TREEVIEW = YES
|
||||
|
||||
# All files should have unique names, so showing the full path is unnecessary.
|
||||
FULL_PATH_NAMES = NO
|
||||
|
||||
# Disable the default Doxygen diagrams.
|
||||
HAVE_DOT = NO
|
||||
|
||||
# Disable the default Doxygen search engine (for now).
|
||||
SEARCHENGINE = NO
|
||||
|
||||
# Use custom header file, footer file, and stylesheet.
|
||||
HTML_HEADER = doc/config/html/header.html
|
||||
HTML_FOOTER = doc/config/html/footer.html
|
||||
HTML_EXTRA_STYLESHEET = doc/config/html/style.css
|
||||
|
||||
# Don't show external pages or groups.
|
||||
EXTERNAL_GROUPS = NO
|
||||
EXTERNAL_PAGES = NO
|
||||
|
||||
# Preprocessor defines.
|
||||
PREDEFINED = _ENABLE_THREAD_SUPPORT_
|
||||
|
||||
# Alias for starting a dependencies section.
|
||||
ALIASES += dependencies{2}="@section \1_dependencies Dependencies^^@brief Dependencies of the \2.^^^^"
|
||||
|
||||
# Alias for starting a configuration settings page.
|
||||
ALIASES += describeconfig="Configuration settings are C pre-processor constants. They can be set with a @c #`define` in the config file (`iot_config.h`) or by using a compiler option such as `-D` in gcc. If a configuration setting is not defined, the library will use a \"sensible\" default value (unless otherwise noted). Because they are compile-time constants, a library must be rebuilt if a configuration setting is changed."
|
||||
ALIASES += configpage{2}="@page \1_config Configuration^^@brief Configuration settings of the \2.^^^^@describeconfig^^@par configpagemarker"
|
||||
ALIASES += configpage{4}="@page \1_config \3 Configuration^^@brief Configuration settings of the \2.^^^^@describeconfig^^^^The settings on this page only affect the [\2](@ref \1). In addition to the settings on this page, them \2 will also be affected by [settings that affect all \4](@ref global_\4_config).^^@par configpagemarker"
|
||||
ALIASES += globalconfigpage{3}="@page global_\1_config Global \2 Configuration^^^^@describeconfig^^@brief Configuration settings that affect all \3.^^@par configpagemarker"
|
||||
|
||||
# Aliases for "Possible values", "Recommended values", and "Default values"
|
||||
# used in configuration setting pages.
|
||||
ALIASES += configpossible="<b>Possible values:</b> "
|
||||
ALIASES += configrecommended="<b>Recommended values:</b> "
|
||||
ALIASES += configdefault="<b>Default value (if undefined):</b> "
|
||||
|
||||
# Alias for starting a constants page.
|
||||
ALIASES += constantspage{2}="@page \1_constants Constants^^@brief Defined constants of the \2.^^^^Libraries may @c #`define` constants in their headers with special meanings. This page describes the meanings and uses of any constants defined by the \2. Related constants are shown in a single section on this page.^^"
|
||||
|
||||
# Alias for starting a functions page.
|
||||
ALIASES += functionspage{2}="@page \1_functions Functions^^@brief Functions of the \2.^^^^The \2 consists of the following functions."
|
||||
ALIASES += functionspage{3}="@page \1_functions \3^^@brief Functions of the \2.^^^^The \2 consists of the following functions."
|
||||
|
||||
# Alias for listing a single function on a functions page.
|
||||
ALIASES += functionname{1}="@subpage \1 <br>^^ @copybrief \1^^"
|
||||
|
||||
# Alias for creating a page for a single function.
|
||||
ALIASES += functionpage{3}="@page \2_function_\3 \1^^^^@snippet this declare_\2_\3^^@copydoc \1"
|
||||
|
||||
# Alias for starting a handles group.
|
||||
ALIASES += handles{2}="@defgroup \1_datatypes_handles Handles^^@brief Opaque handles of the \2."
|
||||
|
||||
# Alias for starting an enum group.
|
||||
ALIASES += enums{2}="@defgroup \1_datatypes_enums Enumerated types^^@brief Enumerated types of the \2."
|
||||
|
||||
# Alias for starting a function pointers group.
|
||||
ALIASES += functionpointers{2}="@defgroup \1_datatypes_functionpointers Function pointers types^^@brief Function pointers types of the \2."
|
||||
|
||||
# Alias for starting a structs group.
|
||||
ALIASES += structs{2}="@defgroup \1_datatypes_structs Structured types^^@brief Structured types of the \2."
|
||||
|
||||
# Alias for starting a parameter structures group.
|
||||
ALIASES += paramstructs{2}="@defgroup \1_datatypes_paramstructs Parameter structures^^@brief Structures passed as parameters to [\2 functions](@ref \1_functions)^^^^These structures are passed as parameters to library functions. Documentation for these structures will state the functions associated with each parameter structure and the purpose of each member."
|
||||
|
||||
# Alias for "Parameter for".
|
||||
ALIASES += paramfor="<b>Parameter for:</b> "
|
||||
|
||||
# Alias for parameter structure initializers.
|
||||
ALIASES += initializer{2}="All instances of #\1 should be initialized with #\2.^^"
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<!-- This file provides the custom footer for Doxygen-generated HTML. Per the
|
||||
Doxygen documentation, this file may need to be regenerated when Doxygen is
|
||||
updated. -->
|
||||
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="footer">
|
||||
$generatedby
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> $doxygenversion
|
||||
</li>
|
||||
<li class="footer">
|
||||
Last updated $date
|
||||
</li>
|
||||
<li class="footer" style="float:left">
|
||||
SDK version $projectnumber
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<hr class="footer"/>
|
||||
<address class="footer">
|
||||
<small>
|
||||
$generatedby  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/>
|
||||
</a> $doxygenversion
|
||||
</small>
|
||||
</address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
<!-- This file provides the custom header for Doxygen-generated HTML. Per the
|
||||
Doxygen documentation, this file may need to be regenerated when Doxygen is
|
||||
updated. -->
|
||||
|
||||
<!-- HTML header for doxygen 1.8.14-->
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<title>
|
||||
$projectname: $title
|
||||
</title>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<title>
|
||||
$title
|
||||
</title>
|
||||
<!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo">
|
||||
<img alt="Logo" src="$relpath^$projectlogo"/>
|
||||
</td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">
|
||||
<span id="csdkprefix">AWS IoT Device SDK C:</span>
|
||||
$projectname
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<div id="projectbrief">
|
||||
$projectbrief
|
||||
</div>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">
|
||||
$projectbrief
|
||||
</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>
|
||||
$searchbox
|
||||
</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="returntomain">
|
||||
<a href="../main/index.html">Return to main page ↑</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
$treeview
|
||||
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Stylesheet for Doxygen HTML output.
|
||||
*
|
||||
* This file defines styles for custom elements in the header/footer and
|
||||
* overrides some of the default Doxygen styles.
|
||||
*
|
||||
* Styles in this file do not affect the treeview sidebar.
|
||||
*/
|
||||
|
||||
/* Set the margins to place a small amount of whitespace on the left and right
|
||||
* side of the page. */
|
||||
div.contents {
|
||||
margin-left:4em;
|
||||
margin-right:4em;
|
||||
}
|
||||
|
||||
/* Justify text in paragraphs. */
|
||||
p {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
/* Style of section headings. */
|
||||
h1 {
|
||||
border-bottom: 1px solid #879ECB;
|
||||
color: #354C7B;
|
||||
font-size: 160%;
|
||||
font-weight: normal;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
/* Style of subsection headings. */
|
||||
h2:not(.memtitle):not(.groupheader) {
|
||||
font-size: 125%;
|
||||
margin-bottom: 0px;
|
||||
margin-top: 16px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
/* Style of paragraphs immediately after subsection headings. */
|
||||
h2 + p {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
/* Style of subsubsection headings. */
|
||||
h3 {
|
||||
font-size: 100%;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
/* Style of paragraphs immediately after subsubsection headings. */
|
||||
h3 + p {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* Style of the prefix "AWS IoT Device SDK C" that appears in the header. */
|
||||
#csdkprefix {
|
||||
color: #757575;
|
||||
}
|
||||
|
||||
/* Style of the "Return to main page" link that appears in the header. */
|
||||
#returntomain {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
/* Style of the dividers on Configuration Settings pages. */
|
||||
div.configpagedivider {
|
||||
margin-left: 0px !important;
|
||||
margin-right: 0px !important;
|
||||
margin-top: 20px !important;
|
||||
}
|
||||
|
||||
/* Style of configuration setting names. */
|
||||
dl.section.user ~ h1 {
|
||||
border-bottom: none;
|
||||
color: #000000;
|
||||
font-family: monospace, fixed;
|
||||
font-size: 16px;
|
||||
margin-bottom: 0px;
|
||||
margin-left: 2em;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
/* Style of paragraphs on a configuration settings page. */
|
||||
dl.section.user ~ * {
|
||||
margin-bottom: 10px;
|
||||
margin-left: 4em;
|
||||
margin-right: 4em;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* Hide the configuration setting marker. */
|
||||
dl.section.user {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Overrides for code fragments and lines. */
|
||||
div.fragment {
|
||||
background: #ffffff;
|
||||
border: none;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
div.line {
|
||||
color: #3a3a3a;
|
||||
}
|
||||
|
||||
/* Overrides for code syntax highlighting colors. */
|
||||
span.comment {
|
||||
color: #008000;
|
||||
}
|
||||
|
||||
span.keyword, span.keywordtype, span.keywordflow {
|
||||
color: #0000ff;
|
||||
}
|
||||
|
||||
span.preprocessor {
|
||||
color: #50015a;
|
||||
}
|
||||
|
||||
span.stringliteral, span.charliteral {
|
||||
color: #800c0c;
|
||||
}
|
||||
|
||||
a.code, a.code:visited, a.line, a.line:visited {
|
||||
color: #496194;
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
<!-- Layout file for the libraries. All library documentation uses this layout file. -->
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Generated by doxygen 1.8.14 -->
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title=""/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
<!-- Hide the default "Data Structures" tab and use the "Modules" tab for data
|
||||
structures. This allows internal data structures to be hidden. -->
|
||||
<tab type="modules" visible="yes" title="Data types" intro="This library defines the following data types."/>
|
||||
<tab type="namespaces" visible="yes" title="">
|
||||
<tab type="namespacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="classlist" visible="no" title="" intro=""/>
|
||||
<tab type="classes" visible="no" title="">
|
||||
<tab type="classindex" visible="no" title=""/>
|
||||
<tab type="hierarchy" visible="no" title="" intro=""/>
|
||||
<tab type="classmembers" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="filelist" visible="yes" title="Files" intro="The following files are associated with this library."/>
|
||||
<tab type="files" visible="no" title="">
|
||||
<tab type="globals" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="yes" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<includegraph visible="no"/>
|
||||
<includedbygraph visible="no"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<classes visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title=""/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
<!-- Layout for the Main page. -->
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Generated by doxygen 1.8.14 -->
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title=""/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
|
||||
<!-- Links to the library documentation. -->
|
||||
<tab type="user" title="MQTT" url="../mqtt/index.html"/>
|
||||
|
||||
<!-- The main page does not use the standard Doxygen tabs. -->
|
||||
<tab type="modules" visible="no" title="" intro=""/>
|
||||
<tab type="namespaces" visible="no" title="">
|
||||
<tab type="namespacelist" visible="no" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="classlist" visible="no" title="" intro=""/>
|
||||
<tab type="classes" visible="no" title="">
|
||||
<tab type="classindex" visible="no" title=""/>
|
||||
<tab type="hierarchy" visible="no" title="" intro=""/>
|
||||
<tab type="classmembers" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="filelist" visible="no" title="" intro=""/>
|
||||
<tab type="files" visible="no" title="">
|
||||
<tab type="globals" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="no" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<includegraph visible="$INCLUDE_GRAPH"/>
|
||||
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<classes visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title=""/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# Include common configuration options.
|
||||
@INCLUDE_PATH = doc/config
|
||||
@INCLUDE = common
|
||||
|
||||
# Basic project information.
|
||||
PROJECT_NAME = "Main"
|
||||
|
||||
# Library documentation output directory.
|
||||
HTML_OUTPUT = main
|
||||
|
||||
# Generate Doxygen tag file for this library.
|
||||
GENERATE_TAGFILE = doc/tag/main.tag
|
||||
|
||||
# Files to show on the main page.
|
||||
INPUT = README.md \
|
||||
CHANGELOG.md \
|
||||
PortingGuide.md \
|
||||
doc/architecture.txt
|
||||
|
||||
# Path to architecture image.
|
||||
IMAGE_PATH += doc/
|
||||
|
||||
# Use repository README as main page.
|
||||
USE_MDFILE_AS_MAINPAGE = README.md
|
||||
|
||||
# Don't automatically link to library symbols.
|
||||
AUTOLINK_SUPPORT = NO
|
||||
|
||||
# Use the Main page layout file
|
||||
LAYOUT_FILE = doc/config/layout_main.xml
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# Include common configuration options.
|
||||
@INCLUDE_PATH = doc/config
|
||||
@INCLUDE = common
|
||||
|
||||
# Basic project information.
|
||||
PROJECT_NAME = "MQTT"
|
||||
PROJECT_BRIEF = "MQTT v3.1.1 client library"
|
||||
|
||||
# Library documentation output directory.
|
||||
HTML_OUTPUT = mqtt
|
||||
|
||||
# Generate Doxygen tag file for this library.
|
||||
GENERATE_TAGFILE = doc/tag/mqtt.tag
|
||||
|
||||
# Directories containing library source code.
|
||||
INPUT = doc/lib \
|
||||
include/ \
|
||||
src/
|
||||
|
||||
# Library file names.
|
||||
FILE_PATTERNS = *mqtt*.c *mqtt*.h *mqtt*.txt
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
@mainpage
|
||||
@anchor mqtt
|
||||
@brief MQTT v3.1.1 client library.
|
||||
|
||||
MQTT is a standardized publish subscribe protocol popular on embedded devices. The MQTT library provided with this SDK implements a subset of the MQTT v3.1.1 protocol. The sample application for Linux `subscribe_publish_sample.c` is provided as a starting point for using this library.
|
||||
|
||||
The interface for communication over MQTT is provided in the file `aws_iot_mqtt_interface.h`.
|
||||
- MQTT client context management: @ref mqtt_function_init and @ref mqtt_function_free
|
||||
- Connection management: @ref mqtt_function_connect and @ref mqtt_function_disconnect
|
||||
- Publishing messages to the server: @ref mqtt_function_publish
|
||||
- Managing subscriptions: @ref mqtt_function_subscribe and @ref mqtt_function_unsubscribe
|
||||
- Process incoming messages, reconnections, and keep-alive: @ref mqtt_function_yield
|
||||
|
||||
@note In a multithreaded environment, always ensure that calls to this library's functions are serialized, such as with a lock or a queue. This library is not thread safe.
|
||||
|
||||
@note This library does not support QoS 2 or retained messages.
|
||||
|
||||
@section mqtt_configuration Configuration
|
||||
@brief The following configuration settings are associated with this MQTT library.
|
||||
- `AWS_IOT_MQTT_TX_BUF_LEN` <br>
|
||||
Size of buffer for outgoing messages.
|
||||
- `AWS_IOT_MQTT_RX_BUF_LEN` <br>
|
||||
Size of buffer for incoming messages. Messages longer than this will be dropped.
|
||||
- `AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS` <br>
|
||||
Number of subscriptions that may be registered simultaneously.
|
||||
- `AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL` <br>
|
||||
The initial wait time before the first reconnect attempt. See @ref mqtt_autoreconnect.
|
||||
- `AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL` <br>
|
||||
The maximum wait time between reconnect attempts. See @ref mqtt_autoreconnect.
|
||||
*/
|
||||
|
||||
/**
|
||||
@page mqtt_autoreconnect Auto-reconnect
|
||||
@brief This page describes the auto-reconnect mechanism of the MQTT library.
|
||||
|
||||
The auto-reconnect mechanism can be enabled through the following methods:
|
||||
- Set #IoT_Client_Init_Params.enableAutoReconnect to `true` when calling @ref mqtt_function_init.
|
||||
- Call @ref mqtt_function_autoreconnect_set_status with `newStatus` set to `true`. @ref mqtt_function_autoreconnect_set_status must only be called after @ref mqtt_function_connect.
|
||||
|
||||
Once enabled, this feature will attempt to reconnect to the server if the library detects a disconnection. The reconnections are handled through @ref mqtt_function_yield. In addition to re-establishing the network connection and MQTT session, all the previous subscriptions will be re-established. This restores the client-side subscriptions for both clean and persistent MQTT sessions.
|
||||
|
||||
The following events are considered disconnects:
|
||||
- Fatal errors returned from the TLS layer.
|
||||
- Failure to send a ping request.
|
||||
- Failure to receive a timely ping response.
|
||||
|
||||
On all disconnect events, the #iot_disconnect_handler for an MQTT client will be called.
|
||||
|
||||
Reconnect attempts are made with an exponential backoff strategy.
|
||||
- `AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL` <br>
|
||||
The initial wait time before the first reconnect attempt.
|
||||
- `AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL` <br>
|
||||
The maximum wait time between reconnect attempts.
|
||||
|
||||
If a reconnect attempt after `AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL` fails, @ref mqtt_function_yield will return `NETWORK_RECONNECT_TIMED_OUT`. There will be no more reconnect attempts. If an application still wants to re-connect, it should call @ref mqtt_function_attempt_reconnect.
|
||||
|
||||
Calling @ref mqtt_function_attempt_reconnect performs a single reconnect and resubscribe attempt. It is equivalent to a manual reconnect attempt.
|
||||
|
||||
@note Since reconnects are handled by @ref mqtt_function_yield and a new TLS handshake for reconnection may take a significant amount of time, calls to @ref mqtt_function_yield that handle reconnections may block for longer than usual.
|
||||
*/
|
||||
+5
@@ -3,3 +3,8 @@
|
||||
# You'll need to download mbedTLS from the official ARMmbed repository and
|
||||
# place the files here. We recommend that you pick the latest version of 2.16
|
||||
# LTS release in order to have up-to-date security fixes.
|
||||
|
||||
# Note that this SDK will not negotiate the TLS Maximum Fragment Length even if
|
||||
# it is enabled in mbedTLS' configuration. Therefore, you should ensure content
|
||||
# buffers used by mbedTLS are at least 16384 bytes in length to use the largest
|
||||
# maximum record length supported by TLS.
|
||||
|
||||
Regular → Executable
+1
-1
@@ -54,7 +54,7 @@ typedef enum {
|
||||
extern const char *JOB_EXECUTION_QUEUED_STR;
|
||||
extern const char *JOB_EXECUTION_IN_PROGRESS_STR;
|
||||
extern const char *JOB_EXECUTION_FAILED_STR;
|
||||
extern const char *JOB_EXECUTION_SUCCESS_STR;
|
||||
extern const char *JOB_EXECUTION_SUCCEEDED_STR;
|
||||
extern const char *JOB_EXECUTION_CANCELED_STR;
|
||||
extern const char *JOB_EXECUTION_REJECTED_STR;
|
||||
|
||||
|
||||
+7
@@ -48,6 +48,7 @@ extern "C" {
|
||||
printf("\n"); \
|
||||
}
|
||||
#else
|
||||
#undef IOT_DEBUG
|
||||
#define IOT_DEBUG(...)
|
||||
#endif
|
||||
|
||||
@@ -71,9 +72,12 @@ extern "C" {
|
||||
return x; \
|
||||
}
|
||||
#else
|
||||
#undef FUNC_ENTRY
|
||||
#define FUNC_ENTRY
|
||||
|
||||
#undef FUNC_EXIT
|
||||
#define FUNC_EXIT
|
||||
#undef FUNC_EXIT_RC
|
||||
#define FUNC_EXIT_RC(x) { return x; }
|
||||
#endif
|
||||
|
||||
@@ -89,6 +93,7 @@ extern "C" {
|
||||
printf("\n"); \
|
||||
}
|
||||
#else
|
||||
#undef IOT_INFO
|
||||
#define IOT_INFO(...)
|
||||
#endif
|
||||
|
||||
@@ -105,6 +110,7 @@ extern "C" {
|
||||
printf("\n"); \
|
||||
}
|
||||
#else
|
||||
#undef IOT_WARN
|
||||
#define IOT_WARN(...)
|
||||
#endif
|
||||
|
||||
@@ -121,6 +127,7 @@ extern "C" {
|
||||
printf("\n"); \
|
||||
}
|
||||
#else
|
||||
#undef IOT_ERROR
|
||||
#define IOT_ERROR(...)
|
||||
#endif
|
||||
|
||||
|
||||
+6
-5
@@ -134,7 +134,7 @@ extern const IoT_MQTT_Will_Options iotMqttWillOptionsDefault;
|
||||
typedef struct {
|
||||
char struct_id[4]; ///< The eyecatcher for this structure. must be MQTC
|
||||
MQTT_Ver_t MQTTVersion; ///< Desired MQTT version used during connection
|
||||
const char *pClientID; ///< Pointer to a string defining the MQTT client ID (this needs to be unique \b per \b device across your AWS account)
|
||||
char *pClientID; ///< Pointer to a string defining the MQTT client ID (this needs to be unique \b per \b device across your AWS account)
|
||||
uint16_t clientIDLen; ///< Client Id Length. 16 bit unsigned integer
|
||||
uint16_t keepAliveIntervalInSec; ///< MQTT keep alive interval in seconds. Defines inactivity time allowed before determining the connection has been lost.
|
||||
bool isCleanSession; ///< MQTT clean session. True = this session is to be treated as clean. Previous server state is cleared and no stated is retained from this connection.
|
||||
@@ -171,9 +171,9 @@ typedef struct {
|
||||
bool enableAutoReconnect; ///< Set to true to enable auto reconnect
|
||||
char *pHostURL; ///< Pointer to a string defining the endpoint for the MQTT service
|
||||
uint16_t port; ///< MQTT service listening port
|
||||
const char *pRootCALocation; ///< Pointer to a string defining the Root CA file (full file, not path)
|
||||
const char *pDeviceCertLocation; ///< Pointer to a string defining the device identity certificate file (full file, not path)
|
||||
const char *pDevicePrivateKeyLocation; ///< Pointer to a string defining the device private key file (full file, not path)
|
||||
char *pRootCALocation; ///< Pointer to a string defining the Root CA file (full file, not path)
|
||||
char *pDeviceCertLocation; ///< Pointer to a string defining the device identity certificate file (full file, not path)
|
||||
char *pDevicePrivateKeyLocation; ///< Pointer to a string defining the device private key file (full file, not path)
|
||||
uint32_t mqttPacketTimeout_ms; ///< Timeout for reading a complete MQTT packet. In milliseconds
|
||||
uint32_t mqttCommandTimeout_ms; ///< Timeout for MQTT blocking calls. In milliseconds
|
||||
uint32_t tlsHandshakeTimeout_ms; ///< TLS handshake timeout. In milliseconds
|
||||
@@ -266,6 +266,7 @@ typedef struct _ClientStatus {
|
||||
typedef struct _ClientData {
|
||||
uint16_t nextPacketId; ///< Packet ID to use for the next generated packet
|
||||
|
||||
/* Packet timeout is unused. See https://github.com/aws/aws-iot-device-sdk-embedded-C/pull/1475 */
|
||||
uint32_t packetTimeoutMs; ///< Timeout for reading incoming packets from the network
|
||||
uint32_t commandTimeoutMs; ///< Timeout for processing outgoing MQTT packets
|
||||
uint16_t keepAliveInterval; ///< Maximum interval between control packets
|
||||
@@ -367,7 +368,7 @@ uint16_t aws_iot_mqtt_get_next_packet_id(AWS_IoT_Client *pClient);
|
||||
* or @ref mqtt_function_yield.
|
||||
*/
|
||||
/* @[declare_mqtt_set_connect_params] */
|
||||
IoT_Error_t aws_iot_mqtt_set_connect_params(AWS_IoT_Client *pClient, const IoT_Client_Connect_Params *pNewConnectParams);
|
||||
IoT_Error_t aws_iot_mqtt_set_connect_params(AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pNewConnectParams);
|
||||
/* @[declare_mqtt_set_connect_params] */
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ extern "C" {
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "aws_iot_log.h"
|
||||
#include "aws_iot_mqtt_client_interface.h"
|
||||
|
||||
/** Types of MQTT messages */
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@ extern "C" {
|
||||
* @return `IoT_Error_t`: See `aws_iot_error.h`
|
||||
*/
|
||||
/* @[declare_mqtt_init] */
|
||||
IoT_Error_t aws_iot_mqtt_init(AWS_IoT_Client *pClient, const IoT_Client_Init_Params *pInitParams);
|
||||
IoT_Error_t aws_iot_mqtt_init(AWS_IoT_Client *pClient, IoT_Client_Init_Params *pInitParams);
|
||||
/* @[declare_mqtt_init] */
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ IoT_Error_t aws_iot_mqtt_free( AWS_IoT_Client *pClient );
|
||||
* @return `IoT_Error_t`: See `aws_iot_error.h`
|
||||
*/
|
||||
/* @[declare_mqtt_connect] */
|
||||
IoT_Error_t aws_iot_mqtt_connect(AWS_IoT_Client *pClient, const IoT_Client_Connect_Params *pConnectParams);
|
||||
IoT_Error_t aws_iot_mqtt_connect(AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pConnectParams);
|
||||
/* @[declare_mqtt_connect] */
|
||||
|
||||
/**
|
||||
|
||||
+7
-7
@@ -52,9 +52,9 @@ extern "C" {
|
||||
typedef struct {
|
||||
char *pHost; ///< This will be unique to a customer and can be retrieved from the console
|
||||
uint16_t port; ///< Network port for TCP/IP socket
|
||||
const char *pRootCA; ///< Location with the Filename of the Root CA
|
||||
const char *pClientCRT; ///< Location of Device certs signed by AWS IoT service
|
||||
const char *pClientKey; ///< Location of Device private key
|
||||
char *pRootCA; ///< Location with the Filename of the Root CA
|
||||
char *pClientCRT; ///< Location of Device certs signed by AWS IoT service
|
||||
char *pClientKey; ///< Location of Device private key
|
||||
bool enableAutoReconnect; ///< Set to true to enable auto reconnect
|
||||
iot_disconnect_handler disconnectHandler; ///< Callback to be invoked upon connection loss.
|
||||
} ShadowInitParameters_t;
|
||||
@@ -69,8 +69,8 @@ typedef struct {
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
const char *pMyThingName; ///< Every device has a Thing Shadow and this is the placeholder for name
|
||||
const char *pMqttClientId; ///< Currently the Shadow uses MQTT to connect and it is important to ensure we have unique client id
|
||||
char *pMyThingName; ///< Every device has a Thing Shadow and this is the placeholder for name
|
||||
char *pMqttClientId; ///< Currently the Shadow uses MQTT to connect and it is important to ensure we have unique client id
|
||||
uint16_t mqttClientIdLen; ///< Currently the Shadow uses MQTT to connect and it is important to ensure we have unique client id
|
||||
pApplicationHandler_t deleteActionHandler; ///< Callback to be invoked when Thing shadow for this device is deleted
|
||||
} ShadowConnectParameters_t;
|
||||
@@ -111,7 +111,7 @@ IoT_Error_t aws_iot_shadow_free(AWS_IoT_Client *pClient);
|
||||
* @param pClient A new MQTT Client to be used as the protocol layer. Will be initialized with pParams.
|
||||
* @return An IoT Error Type defining successful/failed Initialization
|
||||
*/
|
||||
IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, const ShadowInitParameters_t *pParams);
|
||||
IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, ShadowInitParameters_t *pParams);
|
||||
|
||||
/**
|
||||
* @brief Connect to the AWS IoT Thing Shadow service over MQTT
|
||||
@@ -122,7 +122,7 @@ IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, const ShadowInitParamet
|
||||
* @param pParams Shadow Conenction parameters like TLS cert location
|
||||
* @return An IoT Error Type defining successful/failed Connection
|
||||
*/
|
||||
IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient, const ShadowConnectParameters_t *pParams);
|
||||
IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient, ShadowConnectParameters_t *pParams);
|
||||
|
||||
/**
|
||||
* @brief Yield function to let the background tasks of MQTT and Shadow
|
||||
|
||||
+6
-6
@@ -48,10 +48,10 @@ typedef struct Network Network;
|
||||
* TLS networking layer to create a TLS secured socket.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *pRootCALocation; ///< Pointer to string containing the filename (including path) of the root CA file.
|
||||
const char *pDeviceCertLocation; ///< Pointer to string containing the filename (including path) of the device certificate.
|
||||
const char *pDevicePrivateKeyLocation; ///< Pointer to string containing the filename (including path) of the device private key file.
|
||||
const char *pDestinationURL; ///< Pointer to string containing the endpoint of the MQTT service.
|
||||
char *pRootCALocation; ///< Pointer to string containing the filename (including path) of the root CA file.
|
||||
char *pDeviceCertLocation; ///< Pointer to string containing the filename (including path) of the device certificate.
|
||||
char *pDevicePrivateKeyLocation; ///< Pointer to string containing the filename (including path) of the device private key file.
|
||||
char *pDestinationURL; ///< Pointer to string containing the endpoint of the MQTT service.
|
||||
uint16_t DestinationPort; ///< Integer defining the connection port of the MQTT service.
|
||||
uint32_t timeout_ms; ///< Unsigned integer defining the TLS handshake timeout value in milliseconds.
|
||||
bool ServerVerificationFlag; ///< Boolean. True = perform server certificate hostname validation. False = skip validation \b NOT recommended.
|
||||
@@ -93,8 +93,8 @@ struct Network {
|
||||
*
|
||||
* @return IoT_Error_t - successful initialization or TLS error
|
||||
*/
|
||||
IoT_Error_t iot_tls_init(Network *pNetwork, const char *pRootCALocation, const char *pDeviceCertLocation,
|
||||
const char *pDevicePrivateKeyLocation, const char *pDestinationURL,
|
||||
IoT_Error_t iot_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
|
||||
char *pDevicePrivateKeyLocation, char *pDestinationURL,
|
||||
uint16_t DestinationPort, uint32_t timeout_ms, bool ServerVerificationFlag);
|
||||
|
||||
/**
|
||||
|
||||
+101
-50
@@ -31,7 +31,23 @@ extern "C" {
|
||||
|
||||
|
||||
/* This is the value used for ssl read timeout */
|
||||
#define IOT_SSL_READ_TIMEOUT 10
|
||||
#ifndef IOT_SSL_READ_TIMEOUT_MS
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3
|
||||
#endif
|
||||
|
||||
/* When this much time has elapsed after receiving MBEDTLS_ERR_SSL_WANT_READ
|
||||
* or MBEDTLS_ERR_SSL_WANT_WRITE, then iot_tls_write will return
|
||||
* NETWORK_SSL_WRITE_TIMEOUT_ERROR. */
|
||||
#ifndef IOT_SSL_WRITE_RETRY_TIMEOUT_MS
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10
|
||||
#endif
|
||||
|
||||
/* When this much time has elapsed after receiving MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* MBEDTLS_ERR_SSL_WANT_WRITE, or MBEDTLS_ERR_SSL_TIMEOUT, then iot_tls_read
|
||||
* will return NETWORK_SSL_READ_TIMEOUT_ERROR. */
|
||||
#ifndef IOT_SSL_READ_RETRY_TIMEOUT_MS
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10
|
||||
#endif
|
||||
|
||||
/* This defines the value of the debug buffer that gets allocated.
|
||||
* The value can be altered based on memory constraints
|
||||
@@ -270,14 +286,14 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) {
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IOT_DEBUG
|
||||
if (mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)) != NULL) {
|
||||
if(mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)) != NULL) {
|
||||
IOT_DEBUG(" . Peer certificate information ...\n");
|
||||
mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)));
|
||||
IOT_DEBUG("%s\n", buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), IOT_SSL_READ_TIMEOUT);
|
||||
mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), IOT_SSL_READ_TIMEOUT_MS);
|
||||
|
||||
#ifdef IOT_SSL_SOCKET_NON_BLOCKING
|
||||
mbedtls_net_set_nonblock(&(tlsDataParams->server_fd));
|
||||
@@ -287,72 +303,107 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) {
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_write(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *written_len) {
|
||||
size_t written_so_far;
|
||||
bool isErrorFlag = false;
|
||||
int frags;
|
||||
mbedtls_ssl_context *pSsl = &(pNetwork->tlsDataParams.ssl);
|
||||
size_t txLen = 0U;
|
||||
int ret = 0;
|
||||
TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
|
||||
/* This timer checks for a timeout whenever MBEDTLS_ERR_SSL_WANT_READ
|
||||
* or MBEDTLS_ERR_SSL_WANT_WRITE are returned by mbedtls_ssl_write.
|
||||
* Timeout is specified by IOT_SSL_WRITE_RETRY_TIMEOUT_MS. */
|
||||
Timer writeTimer;
|
||||
|
||||
for(written_so_far = 0, frags = 0;
|
||||
written_so_far < len && !has_timer_expired(timer); written_so_far += ret, frags++) {
|
||||
while(!has_timer_expired(timer) &&
|
||||
(ret = mbedtls_ssl_write(&(tlsDataParams->ssl), pMsg + written_so_far, len - written_so_far)) <= 0) {
|
||||
if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
IOT_ERROR(" failed\n ! mbedtls_ssl_write returned -0x%x\n\n", -ret);
|
||||
/* All other negative return values indicate connection needs to be reset.
|
||||
* Will be caught in ping request so ignored here */
|
||||
isErrorFlag = true;
|
||||
break;
|
||||
/* This variable is unused */
|
||||
(void) timer;
|
||||
|
||||
/* The timer must be started in case no bytes are written on the first try */
|
||||
init_timer(&writeTimer);
|
||||
countdown_ms(&writeTimer, IOT_SSL_WRITE_RETRY_TIMEOUT_MS);
|
||||
|
||||
while(len > 0U) {
|
||||
ret = mbedtls_ssl_write(pSsl, pMsg, len);
|
||||
|
||||
if(ret > 0) {
|
||||
if((size_t) ret > len) {
|
||||
IOT_ERROR("More bytes written than requested\n\n");
|
||||
return NETWORK_SSL_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
if(isErrorFlag) {
|
||||
break;
|
||||
|
||||
/* Successfully sent data, so reset the timeout */
|
||||
init_timer(&writeTimer);
|
||||
countdown_ms(&writeTimer, IOT_SSL_WRITE_RETRY_TIMEOUT_MS);
|
||||
|
||||
txLen += ret;
|
||||
pMsg += ret;
|
||||
len -= ret;
|
||||
} else if(ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
if(has_timer_expired(&writeTimer)) {
|
||||
*written_len = txLen;
|
||||
return NETWORK_SSL_WRITE_TIMEOUT_ERROR;
|
||||
}
|
||||
} else {
|
||||
IOT_ERROR(" failed\n ! mbedtls_ssl_write returned -0x%x\n\n", (unsigned int) -ret);
|
||||
/* All other negative return values indicate connection needs to be reset.
|
||||
* Will be caught in ping request so ignored here */
|
||||
return NETWORK_SSL_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
*written_len = written_so_far;
|
||||
|
||||
if(isErrorFlag) {
|
||||
return NETWORK_SSL_WRITE_ERROR;
|
||||
} else if(has_timer_expired(timer) && written_so_far != len) {
|
||||
return NETWORK_SSL_WRITE_TIMEOUT_ERROR;
|
||||
}
|
||||
|
||||
*written_len = txLen;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_read(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *read_len) {
|
||||
mbedtls_ssl_context *ssl = &(pNetwork->tlsDataParams.ssl);
|
||||
size_t rxLen = 0;
|
||||
mbedtls_ssl_context *pSsl = &(pNetwork->tlsDataParams.ssl);
|
||||
size_t rxLen = 0U;
|
||||
int ret;
|
||||
/* This timer checks for a timeout whenever MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* MBEDTLS_ERR_SSL_WANT_WRITE, or MBEDTLS_ERR_SSL_TIMEOUT are returned by
|
||||
* mbedtls_ssl_read. Timeout is specified by IOT_SSL_READ_RETRY_TIMEOUT_MS. */
|
||||
Timer readTimer;
|
||||
|
||||
/* This variable is unused */
|
||||
(void) timer;
|
||||
|
||||
/* The timer must be started in case no bytes are read on the first try */
|
||||
init_timer(&readTimer);
|
||||
countdown_ms(&readTimer, IOT_SSL_READ_RETRY_TIMEOUT_MS);
|
||||
|
||||
while(len > 0U) {
|
||||
/* This read will timeout after IOT_SSL_READ_TIMEOUT_MS if there's no data to be read */
|
||||
ret = mbedtls_ssl_read(pSsl, pMsg, len);
|
||||
|
||||
if(ret > 0) {
|
||||
if((size_t) ret > len) {
|
||||
IOT_ERROR("More bytes read than requested\n\n");
|
||||
return NETWORK_SSL_WRITE_ERROR;
|
||||
}
|
||||
|
||||
/* Successfully received data, so reset the timeout */
|
||||
init_timer(&readTimer);
|
||||
countdown_ms(&readTimer, IOT_SSL_READ_RETRY_TIMEOUT_MS);
|
||||
|
||||
while (len > 0) {
|
||||
// This read will timeout after IOT_SSL_READ_TIMEOUT if there's no data to be read
|
||||
ret = mbedtls_ssl_read(ssl, pMsg, len);
|
||||
if (ret > 0) {
|
||||
rxLen += ret;
|
||||
pMsg += ret;
|
||||
len -= ret;
|
||||
} else if (ret == 0 || (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_TIMEOUT)) {
|
||||
} else if(ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE ||
|
||||
ret == MBEDTLS_ERR_SSL_TIMEOUT) {
|
||||
if(has_timer_expired(&readTimer)) {
|
||||
*read_len = rxLen;
|
||||
if(rxLen == 0U) {
|
||||
return NETWORK_SSL_NOTHING_TO_READ;
|
||||
} else {
|
||||
return NETWORK_SSL_READ_TIMEOUT_ERROR;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IOT_ERROR("Failed\n ! mbedtls_ssl_read returned -0x%x\n\n", (unsigned int) -ret);
|
||||
return NETWORK_SSL_READ_ERROR;
|
||||
}
|
||||
|
||||
// Evaluate timeout after the read to make sure read is done at least once
|
||||
if (has_timer_expired(timer)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
*read_len = rxLen;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
if (rxLen == 0) {
|
||||
return NETWORK_SSL_NOTHING_TO_READ;
|
||||
} else {
|
||||
return NETWORK_SSL_READ_TIMEOUT_ERROR;
|
||||
}
|
||||
*read_len = rxLen;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_disconnect(Network *pNetwork) {
|
||||
|
||||
+12
-10
@@ -1,3 +1,14 @@
|
||||
# Sample apps for the AWS IoT Device SDK for Embedded C
|
||||
|
||||
All samples are written in C unless otherwise mentioned. The these sample apps are included in the SDK and described below.
|
||||
* [`subscribe_publish_sample`](#subscribe-publish-sample) - demonstrates how to publish and subscribe to MQTT messages.
|
||||
* [`subscribe_publish_library_sample`](#subscribe-publish-library-sample) - demonstrates how to create a library that provides support to publish and subscribe to MQTT messages.
|
||||
|
||||
These sample apps are also provided in this SDK.
|
||||
* [`shadow_sample`](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/master/samples/linux/shadow_sample) - demonstrates how to use a simple device shadow in a connected window example.
|
||||
* [`shadow_sample_console_echo`](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/master/samples/linux/shadow_sample_console_echo) - demonstrates how to work with the AWS IoT Console interactive guide.
|
||||
* [`jobs_sample`](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/master/samples/linux/jobs_sample) - demonstrates how to connect to the AWS IoT MQTT platform and perform several operations that use the basic capabilities of the AWS IoT Jobs platform.
|
||||
|
||||
## Overview
|
||||
This folder contains several samples that demonstrate various SDK functions. The Readme file also includes a walk-through of the subscribe publish sample to explain how the SDK is used. The samples are currently provided with Makefiles for building them on linux. For each sample:
|
||||
|
||||
@@ -10,12 +21,6 @@ This folder contains several samples that demonstrate various SDK functions. The
|
||||
* Ensure the certificate has an attached policy which allows the proper permissions for AWS IoT
|
||||
* Build the example using make (`make`)
|
||||
* Run sample application (./subscribe_publish_sample or ./shadow_sample). The sample will print status messages to stdout
|
||||
* All samples are written in C unless otherwise mentioned. The following sample applications are included:
|
||||
* `subscribe_publish_sample` - a simple pub/sub MQTT example
|
||||
* `subscribe_publish_cpp_sample` - a simple pub/sub MQTT example written in C++
|
||||
* `subscribe_publish_library_sample` - a simple pub/sub MQTT example which builds the SDK as a separate library
|
||||
* `shadow_sample` - a simple device shadow example using a connected window example
|
||||
* `shadow_sample_console_echo` - a sample to work with the AWS IoT Console interactive guide
|
||||
|
||||
## Subscribe Publish Sample
|
||||
This is a simple pub/sub MQTT example. It connects a single MQTT client to the server and subscribes to a test topic. Then it proceeds to publish messages on this topic and yields after each publish to ensure that the message was received.
|
||||
@@ -35,8 +40,5 @@ This is a simple pub/sub MQTT example. It connects a single MQTT client to the s
|
||||
|
||||
For further information on each API please read the API documentation.
|
||||
|
||||
## Subscribe Publish Cpp Sample
|
||||
This is the same sample as above but it is built using a C++ compiler. It demonstrates how the SDK can be used in a C++ program.
|
||||
|
||||
## Subscribe Publish Library Sample
|
||||
This is also the same code as the Subscribe Publish sample. In this case, the SDK is built as a separate library and then used in the sample program.
|
||||
This is also the same code as the Subscribe Publish sample. In this case, the SDK is built as a separate library and then used in the sample program.
|
||||
|
||||
+5
@@ -70,4 +70,9 @@
|
||||
|
||||
#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
|
||||
|
||||
// TLS configs
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3 ///< Timeout associated with underlying socket of TLS connection (set by mbedtls_ssl_conf_read_timeout)
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_read when pending data has not yet been received
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_write when pending data has not yet been written
|
||||
|
||||
#endif /* SRC_JOBS_IOT_JOB_CONFIG_H_ */
|
||||
|
||||
+5
@@ -55,4 +55,9 @@
|
||||
|
||||
#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
|
||||
|
||||
// TLS configs
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3 ///< Timeout associated with underlying socket of TLS connection (set by mbedtls_ssl_conf_read_timeout)
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_read when pending data has not yet been received
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_write when pending data has not yet been written
|
||||
|
||||
#endif /* SRC_SHADOW_IOT_SHADOW_CONFIG_H_ */
|
||||
|
||||
+5
@@ -55,4 +55,9 @@
|
||||
|
||||
#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
|
||||
|
||||
// TLS configs
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3 ///< Timeout associated with underlying socket of TLS connection (set by mbedtls_ssl_conf_read_timeout)
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_read when pending data has not yet been received
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_write when pending data has not yet been written
|
||||
|
||||
#endif /* SRC_SHADOW_IOT_SHADOW_CONFIG_H_ */
|
||||
|
||||
+5
@@ -55,4 +55,9 @@
|
||||
|
||||
#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
|
||||
|
||||
// TLS configs
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3 ///< Timeout associated with underlying socket of TLS connection (set by mbedtls_ssl_conf_read_timeout)
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_read when pending data has not yet been received
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_write when pending data has not yet been written
|
||||
|
||||
#endif /* SRC_SHADOW_IOT_SHADOW_CONFIG_H_ */
|
||||
|
||||
+5
@@ -55,4 +55,9 @@
|
||||
|
||||
#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
|
||||
|
||||
// TLS configs
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3 ///< Timeout associated with underlying socket of TLS connection (set by mbedtls_ssl_conf_read_timeout)
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_read when pending data has not yet been received
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_write when pending data has not yet been written
|
||||
|
||||
#endif /* SRC_SHADOW_IOT_SHADOW_CONFIG_H_ */
|
||||
|
||||
+3
-22
@@ -31,7 +31,6 @@ extern "C" {
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "aws_iot_log.h"
|
||||
|
||||
@@ -80,16 +79,10 @@ IoT_Error_t parseUnsignedInteger8Value(uint8_t *i, const char *jsonString, jsmnt
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
|
||||
uint32_t i_word;
|
||||
if(('-' == (char) (jsonString[token->start])) || (1 != sscanf(jsonString + token->start, "%" SCNu32, &i_word))) {
|
||||
if(('-' == (char) (jsonString[token->start])) || (1 != sscanf(jsonString + token->start, "%hhu", i))) {
|
||||
IOT_WARN("Token was not an unsigned integer.");
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
if (i_word > UINT8_MAX) {
|
||||
IOT_WARN("Token value %u exceeds 8 bits", i_word);
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
*i = i_word;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -114,16 +107,10 @@ IoT_Error_t parseInteger16Value(int16_t *i, const char *jsonString, jsmntok_t *t
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
|
||||
int32_t i_word;
|
||||
if(1 != sscanf(jsonString + token->start, "%" SCNi32, &i_word)) {
|
||||
if(1 != sscanf(jsonString + token->start, "%hi", i)) {
|
||||
IOT_WARN("Token was not an integer.");
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
if(i_word < INT16_MIN || i_word > INT16_MAX) {
|
||||
IOT_WARN("Token value %d out of range for 16-bit int", i_word);
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
*i = i_word;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -134,16 +121,10 @@ IoT_Error_t parseInteger8Value(int8_t *i, const char *jsonString, jsmntok_t *tok
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
|
||||
int32_t i_word;
|
||||
if(1 != sscanf(jsonString + token->start, "%" SCNi32, &i_word)) {
|
||||
if(1 != sscanf(jsonString + token->start, "%hhi", i)) {
|
||||
IOT_WARN("Token was not an integer.");
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
if(i_word < INT8_MIN || i_word > INT8_MAX) {
|
||||
IOT_WARN("Token value %d out of range for 8-bit int", i_word);
|
||||
return JSON_PARSE_ERROR;
|
||||
}
|
||||
*i = i_word;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
+5
-5
@@ -142,9 +142,9 @@ IoT_Error_t aws_iot_mqtt_set_client_state(AWS_IoT_Client *pClient, ClientState e
|
||||
}
|
||||
|
||||
#ifdef _ENABLE_THREAD_SUPPORT_
|
||||
rc = aws_iot_mqtt_client_lock_mutex(pClient, &(pClient->clientData.state_change_mutex));
|
||||
if(SUCCESS != rc) {
|
||||
return rc;
|
||||
threadRc = aws_iot_mqtt_client_lock_mutex(pClient, &(pClient->clientData.state_change_mutex));
|
||||
if(SUCCESS != threadRc) {
|
||||
return threadRc;
|
||||
}
|
||||
#endif
|
||||
if(expectedCurrentState == aws_iot_mqtt_get_client_state(pClient)) {
|
||||
@@ -164,7 +164,7 @@ IoT_Error_t aws_iot_mqtt_set_client_state(AWS_IoT_Client *pClient, ClientState e
|
||||
FUNC_EXIT_RC(rc);
|
||||
}
|
||||
|
||||
IoT_Error_t aws_iot_mqtt_set_connect_params(AWS_IoT_Client *pClient, const IoT_Client_Connect_Params *pNewConnectParams) {
|
||||
IoT_Error_t aws_iot_mqtt_set_connect_params(AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pNewConnectParams) {
|
||||
FUNC_ENTRY;
|
||||
if(NULL == pClient || NULL == pNewConnectParams) {
|
||||
FUNC_EXIT_RC(NULL_VALUE_ERROR);
|
||||
@@ -231,7 +231,7 @@ IoT_Error_t aws_iot_mqtt_free(AWS_IoT_Client *pClient)
|
||||
FUNC_EXIT_RC(rc);
|
||||
}
|
||||
|
||||
IoT_Error_t aws_iot_mqtt_init(AWS_IoT_Client *pClient, const IoT_Client_Init_Params *pInitParams) {
|
||||
IoT_Error_t aws_iot_mqtt_init(AWS_IoT_Client *pClient, IoT_Client_Init_Params *pInitParams) {
|
||||
uint32_t i;
|
||||
IoT_Error_t rc;
|
||||
IoT_Client_Connect_Params default_options = IoT_Client_Connect_Params_initializer;
|
||||
|
||||
+11
-10
@@ -310,6 +310,10 @@ IoT_Error_t aws_iot_mqtt_internal_send_packet(AWS_IoT_Client *pClient, size_t le
|
||||
size_t sentLen, sent;
|
||||
IoT_Error_t rc = FAILURE;
|
||||
|
||||
#ifdef _ENABLE_THREAD_SUPPORT_
|
||||
IoT_Error_t threadRc;
|
||||
#endif
|
||||
|
||||
FUNC_ENTRY;
|
||||
|
||||
if(NULL == pClient || NULL == pTimer) {
|
||||
@@ -321,9 +325,9 @@ IoT_Error_t aws_iot_mqtt_internal_send_packet(AWS_IoT_Client *pClient, size_t le
|
||||
}
|
||||
|
||||
#ifdef _ENABLE_THREAD_SUPPORT_
|
||||
rc = aws_iot_mqtt_client_lock_mutex(pClient, &(pClient->clientData.tls_write_mutex));
|
||||
if(SUCCESS != rc) {
|
||||
FUNC_EXIT_RC(rc);
|
||||
threadRc = aws_iot_mqtt_client_lock_mutex(pClient, &(pClient->clientData.tls_write_mutex));
|
||||
if(SUCCESS != threadRc) {
|
||||
FUNC_EXIT_RC(threadRc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -344,9 +348,9 @@ IoT_Error_t aws_iot_mqtt_internal_send_packet(AWS_IoT_Client *pClient, size_t le
|
||||
}
|
||||
|
||||
#ifdef _ENABLE_THREAD_SUPPORT_
|
||||
rc = aws_iot_mqtt_client_unlock_mutex(pClient, &(pClient->clientData.tls_write_mutex));
|
||||
if(SUCCESS != rc) {
|
||||
FUNC_EXIT_RC(rc);
|
||||
threadRc = aws_iot_mqtt_client_unlock_mutex(pClient, &(pClient->clientData.tls_write_mutex));
|
||||
if((SUCCESS != threadRc) && ( SUCCESS == rc )) {
|
||||
FUNC_EXIT_RC(threadRc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -356,7 +360,7 @@ IoT_Error_t aws_iot_mqtt_internal_send_packet(AWS_IoT_Client *pClient, size_t le
|
||||
FUNC_EXIT_RC(SUCCESS);
|
||||
}
|
||||
|
||||
FUNC_EXIT_RC(rc);
|
||||
FUNC_EXIT_RC(rc)
|
||||
}
|
||||
|
||||
static IoT_Error_t _aws_iot_mqtt_internal_readWrapper( AWS_IoT_Client *pClient, size_t offset, size_t size, Timer *pTimer, size_t * read_len ) {
|
||||
@@ -424,9 +428,6 @@ static IoT_Error_t _aws_iot_mqtt_internal_read_packet(AWS_IoT_Client *pClient, T
|
||||
IoT_Error_t rc;
|
||||
size_t offset = 0;
|
||||
MQTTHeader header = {0};
|
||||
Timer packetTimer;
|
||||
init_timer(&packetTimer);
|
||||
countdown_ms(&packetTimer, pClient->clientData.packetTimeoutMs);
|
||||
|
||||
rem_len = 0;
|
||||
total_bytes_read = 0;
|
||||
|
||||
+15
-58
@@ -45,50 +45,6 @@ extern "C" {
|
||||
#include "aws_iot_mqtt_client_interface.h"
|
||||
#include "aws_iot_mqtt_client_common_internal.h"
|
||||
|
||||
/** connect flags byte */
|
||||
typedef union {
|
||||
uint8_t all; /**< all connect flags */
|
||||
#if defined(REVERSED)
|
||||
struct
|
||||
{
|
||||
unsigned int username : 1; /**< 3.1 user name */
|
||||
unsigned int password : 1; /**< 3.1 password */
|
||||
unsigned int willRetain : 1; /**< will retain setting */
|
||||
unsigned int willQoS : 2; /**< will QoS value */
|
||||
unsigned int will : 1; /**< will flag */
|
||||
unsigned int cleansession : 1; /**< clean session flag */
|
||||
unsigned int : 1; /**< unused */
|
||||
} bits; /**< connect flags byte (reversed order) */
|
||||
#else
|
||||
struct {
|
||||
unsigned int : 1; /**< unused */
|
||||
unsigned int cleansession : 1; /**< cleansession flag */
|
||||
unsigned int will : 1; /**< will flag */
|
||||
unsigned int willQoS : 2; /**< will QoS value */
|
||||
unsigned int willRetain : 1; /**< will retain setting */
|
||||
unsigned int password : 1; /**< 3.1 password */
|
||||
unsigned int username : 1; /**< 3.1 user name */
|
||||
} bits; /**< connect flags byte (normal order) */
|
||||
#endif
|
||||
} MQTT_Connect_Header_Flags;
|
||||
|
||||
/** connack flags byte */
|
||||
typedef union {
|
||||
uint8_t all; /**< all connack flags */
|
||||
#if defined(REVERSED)
|
||||
struct
|
||||
{
|
||||
unsigned int sessionpresent : 1; /**< session present flag */
|
||||
unsigned int : 7; /**< unused */
|
||||
} bits; /**< connect flags byte (reverse order) */
|
||||
#else
|
||||
struct {
|
||||
unsigned int : 7; /**< unused */
|
||||
unsigned int sessionpresent : 1; /**< session present flag */
|
||||
} bits; /**< connect flags byte (normal order) */
|
||||
#endif
|
||||
} MQTT_Connack_Header_Flags;
|
||||
|
||||
/** @brief Connect request response codes from server */
|
||||
typedef enum {
|
||||
CONNACK_CONNECTION_ACCEPTED = 0, /**< Connection accepted */
|
||||
@@ -149,7 +105,7 @@ static IoT_Error_t _aws_iot_mqtt_serialize_connect(unsigned char *pTxBuf, size_t
|
||||
uint32_t len;
|
||||
IoT_Error_t rc;
|
||||
MQTTHeader header = {0};
|
||||
MQTT_Connect_Header_Flags flags = {0};
|
||||
uint8_t flags = 0u;
|
||||
|
||||
FUNC_ENTRY;
|
||||
|
||||
@@ -188,28 +144,28 @@ static IoT_Error_t _aws_iot_mqtt_serialize_connect(unsigned char *pTxBuf, size_t
|
||||
aws_iot_mqtt_internal_write_char(&ptr, (unsigned char) pConnectParams->MQTTVersion);
|
||||
//}
|
||||
|
||||
flags.all = 0;
|
||||
flags = 0;
|
||||
if (pConnectParams->isCleanSession)
|
||||
{
|
||||
flags.all |= 1 << 1;
|
||||
flags |= 1 << 1;
|
||||
}
|
||||
|
||||
if (pConnectParams->isWillMsgPresent)
|
||||
{
|
||||
flags.all |= 1 << 2;
|
||||
flags.all |= (uint8_t) (pConnectParams->will.qos << 3);
|
||||
flags.all |= (uint8_t) (pConnectParams->will.isRetained << 5);
|
||||
flags |= 1 << 2;
|
||||
flags |= (uint8_t) (pConnectParams->will.qos << 3);
|
||||
flags |= (uint8_t) (pConnectParams->will.isRetained << 5);
|
||||
}
|
||||
|
||||
if(pConnectParams->pPassword) {
|
||||
flags.all |= 1 << 6;
|
||||
flags |= 1 << 6;
|
||||
}
|
||||
|
||||
if(pConnectParams->pUsername) {
|
||||
flags.all |= 1 << 7;
|
||||
flags |= 1 << 7;
|
||||
}
|
||||
|
||||
aws_iot_mqtt_internal_write_char(&ptr, flags.all);
|
||||
aws_iot_mqtt_internal_write_char(&ptr, flags);
|
||||
aws_iot_mqtt_internal_write_uint_16(&ptr, pConnectParams->keepAliveIntervalInSec);
|
||||
|
||||
/* If the code have passed the check for incorrect values above, no client id was passed as argument */
|
||||
@@ -252,7 +208,7 @@ static IoT_Error_t _aws_iot_mqtt_deserialize_connack(unsigned char *pSessionPres
|
||||
unsigned char connack_rc_char;
|
||||
uint32_t decodedLen, readBytesLen;
|
||||
IoT_Error_t rc;
|
||||
MQTT_Connack_Header_Flags flags = {0};
|
||||
uint8_t flags = 0u;
|
||||
MQTTHeader header = {0};
|
||||
|
||||
FUNC_ENTRY;
|
||||
@@ -291,8 +247,9 @@ static IoT_Error_t _aws_iot_mqtt_deserialize_connack(unsigned char *pSessionPres
|
||||
FUNC_EXIT_RC(MQTT_DECODE_REMAINING_LENGTH_ERROR);
|
||||
}
|
||||
|
||||
flags.all = aws_iot_mqtt_internal_read_char(&curdata);
|
||||
*pSessionPresent = flags.bits.sessionpresent;
|
||||
flags = aws_iot_mqtt_internal_read_char(&curdata);
|
||||
/* Session present is in the LSb. */
|
||||
*pSessionPresent = (flags & 0x01);
|
||||
connack_rc_char = aws_iot_mqtt_internal_read_char(&curdata);
|
||||
switch(connack_rc_char) {
|
||||
case CONNACK_CONNECTION_ACCEPTED:
|
||||
@@ -374,7 +331,7 @@ static bool _aws_iot_mqtt_is_client_state_valid_for_connect(ClientState clientSt
|
||||
*
|
||||
* @return An IoT Error Type defining successful/failed connection
|
||||
*/
|
||||
static IoT_Error_t _aws_iot_mqtt_internal_connect(AWS_IoT_Client *pClient, const IoT_Client_Connect_Params *pConnectParams) {
|
||||
static IoT_Error_t _aws_iot_mqtt_internal_connect(AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pConnectParams) {
|
||||
Timer connect_timer;
|
||||
IoT_Error_t connack_rc = FAILURE;
|
||||
char sessionPresent = 0;
|
||||
@@ -449,7 +406,7 @@ static IoT_Error_t _aws_iot_mqtt_internal_connect(AWS_IoT_Client *pClient, const
|
||||
*
|
||||
* @return An IoT Error Type defining successful/failed connection
|
||||
*/
|
||||
IoT_Error_t aws_iot_mqtt_connect(AWS_IoT_Client *pClient, const IoT_Client_Connect_Params *pConnectParams) {
|
||||
IoT_Error_t aws_iot_mqtt_connect(AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pConnectParams) {
|
||||
IoT_Error_t rc, disconRc;
|
||||
ClientState clientState;
|
||||
FUNC_ENTRY;
|
||||
|
||||
+5
-4
@@ -241,6 +241,11 @@ static IoT_Error_t _aws_iot_mqtt_internal_yield(AWS_IoT_Client *pClient, uint32_
|
||||
|
||||
if(NETWORK_DISCONNECTED_ERROR == yieldRc) {
|
||||
pClient->clientData.counterNetworkDisconnected++;
|
||||
/* Always clear resubscribe flags. */
|
||||
for(itr = 0; itr < AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS; itr++) {
|
||||
pClient->clientData.messageHandlers[itr].resubscribed = 0;
|
||||
}
|
||||
|
||||
if(1 == pClient->clientStatus.isAutoReconnectEnabled) {
|
||||
yieldRc = aws_iot_mqtt_set_client_state(pClient, CLIENT_STATE_DISCONNECTED_ERROR,
|
||||
CLIENT_STATE_PENDING_RECONNECT);
|
||||
@@ -251,10 +256,6 @@ static IoT_Error_t _aws_iot_mqtt_internal_yield(AWS_IoT_Client *pClient, uint32_
|
||||
pClient->clientData.currentReconnectWaitInterval = AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL;
|
||||
countdown_ms(&(pClient->reconnectDelayTimer), pClient->clientData.currentReconnectWaitInterval);
|
||||
|
||||
for(itr = 0; itr < AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS; itr++) {
|
||||
pClient->clientData.messageHandlers[itr].resubscribed = 0;
|
||||
}
|
||||
|
||||
/* Depending on timer values, it is possible that yield timer has expired
|
||||
* Set to rc to attempting reconnect to inform client that autoreconnect
|
||||
* attempt has started */
|
||||
|
||||
+2
-3
@@ -69,9 +69,8 @@ IoT_Error_t aws_iot_shadow_free(AWS_IoT_Client *pClient)
|
||||
FUNC_EXIT_RC(rc);
|
||||
}
|
||||
|
||||
IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, const ShadowInitParameters_t *pParams) {
|
||||
IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, ShadowInitParameters_t *pParams) {
|
||||
IoT_Client_Init_Params mqttInitParams = IoT_Client_Init_Params_initializer;
|
||||
|
||||
IoT_Error_t rc;
|
||||
|
||||
FUNC_ENTRY;
|
||||
@@ -104,7 +103,7 @@ IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, const ShadowInitParamet
|
||||
FUNC_EXIT_RC(SUCCESS);
|
||||
}
|
||||
|
||||
IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient, const ShadowConnectParameters_t *pParams) {
|
||||
IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient, ShadowConnectParameters_t *pParams) {
|
||||
IoT_Error_t rc = SUCCESS;
|
||||
uint16_t deleteAcceptedTopicLen;
|
||||
IoT_Client_Connect_Params ConnectParams = iotClientConnectParamsDefault;
|
||||
|
||||
+5
@@ -65,4 +65,9 @@
|
||||
|
||||
#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
|
||||
|
||||
// TLS configs
|
||||
#define IOT_SSL_READ_TIMEOUT_MS 3 ///< Timeout associated with underlying socket of TLS connection (set by mbedtls_ssl_conf_read_timeout)
|
||||
#define IOT_SSL_READ_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_read when pending data has not yet been received
|
||||
#define IOT_SSL_WRITE_RETRY_TIMEOUT_MS 10 ///< Minimum elapsed time before returning from iot_tls_write when pending data has not yet been written
|
||||
|
||||
#endif /* SRC_SHADOW_IOT_SHADOW_CONFIG_H_ */
|
||||
|
||||
@@ -28,15 +28,21 @@
|
||||
*/
|
||||
|
||||
// redefine the AWS IoT log functions to call into the IDF log layer
|
||||
#undef IOT_DEBUG
|
||||
#define IOT_DEBUG(format, ...) ESP_LOGD("aws_iot", format, ##__VA_ARGS__)
|
||||
#undef IOT_INFO
|
||||
#define IOT_INFO(format, ...) ESP_LOGI("aws_iot", format, ##__VA_ARGS__)
|
||||
#undef IOT_WARN
|
||||
#define IOT_WARN(format, ...) ESP_LOGW("aws_iot", format, ##__VA_ARGS__)
|
||||
#undef IOT_ERROR
|
||||
#define IOT_ERROR(format, ...) ESP_LOGE("aws_iot", format, ##__VA_ARGS__)
|
||||
|
||||
/* Function tracing macros used in AWS IoT SDK,
|
||||
mapped to "verbose" level output
|
||||
*/
|
||||
#undef FUNC_ENTRY
|
||||
#define FUNC_ENTRY ESP_LOGV("aws_iot", "FUNC_ENTRY: %s L#%d \n", __func__, __LINE__)
|
||||
#undef FUNC_EXIT_RC
|
||||
#define FUNC_EXIT_RC(x) \
|
||||
do { \
|
||||
ESP_LOGV("aws_iot", "FUNC_EXIT: %s L#%d Return Code : %d \n", __func__, __LINE__, x); \
|
||||
|
||||
@@ -58,8 +58,8 @@ static int _iot_tls_verify_cert(void *data, mbedtls_x509_crt *crt, int depth, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _iot_tls_set_connect_params(Network *pNetwork, const char *pRootCALocation, const char *pDeviceCertLocation,
|
||||
const char *pDevicePrivateKeyLocation, const char *pDestinationURL,
|
||||
static void _iot_tls_set_connect_params(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
|
||||
char *pDevicePrivateKeyLocation, char *pDestinationURL,
|
||||
uint16_t destinationPort, uint32_t timeout_ms, bool ServerVerificationFlag) {
|
||||
pNetwork->tlsConnectParams.DestinationPort = destinationPort;
|
||||
pNetwork->tlsConnectParams.pDestinationURL = pDestinationURL;
|
||||
@@ -70,8 +70,8 @@ static void _iot_tls_set_connect_params(Network *pNetwork, const char *pRootCALo
|
||||
pNetwork->tlsConnectParams.ServerVerificationFlag = ServerVerificationFlag;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_init(Network *pNetwork, const char *pRootCALocation, const char *pDeviceCertLocation,
|
||||
const char *pDevicePrivateKeyLocation, const char *pDestinationURL,
|
||||
IoT_Error_t iot_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
|
||||
char *pDevicePrivateKeyLocation, char *pDestinationURL,
|
||||
uint16_t destinationPort, uint32_t timeout_ms, bool ServerVerificationFlag) {
|
||||
_iot_tls_set_connect_params(pNetwork, pRootCALocation, pDeviceCertLocation, pDevicePrivateKeyLocation,
|
||||
pDestinationURL, destinationPort, timeout_ms, ServerVerificationFlag);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event_loop.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "driver/sdmmc_host.h"
|
||||
@@ -109,25 +109,37 @@ char HostAddress[255] = AWS_IOT_MQTT_HOST;
|
||||
uint32_t port = AWS_IOT_MQTT_PORT;
|
||||
|
||||
|
||||
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
||||
static void event_handler(void* handler_args, esp_event_base_t base, int32_t id, void* event_data)
|
||||
{
|
||||
switch(event->event_id) {
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
/* This is a workaround as ESP32 WiFi libs don't currently
|
||||
auto-reassociate. */
|
||||
esp_wifi_connect();
|
||||
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
ESP_LOGI(TAG, "event_handler: %s:%d", base, id);
|
||||
|
||||
if(base == WIFI_EVENT) {
|
||||
switch(id) {
|
||||
case WIFI_EVENT_STA_START:
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
case WIFI_EVENT_STA_CONNECTED:
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISCONNECTED:
|
||||
/* This is a workaround as ESP32 WiFi libs don't currently
|
||||
auto-reassociate. */
|
||||
esp_wifi_connect();
|
||||
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(base == IP_EVENT) {
|
||||
switch(id) {
|
||||
case IP_EVENT_STA_GOT_IP:
|
||||
{
|
||||
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
|
||||
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void iot_subscribe_callback_handler(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen,
|
||||
@@ -178,9 +190,9 @@ void aws_iot_task(void *param) {
|
||||
mqttInitParams.port = port;
|
||||
|
||||
#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)
|
||||
mqttInitParams.pRootCALocation = (const char *)aws_root_ca_pem_start;
|
||||
mqttInitParams.pDeviceCertLocation = (const char *)certificate_pem_crt_start;
|
||||
mqttInitParams.pDevicePrivateKeyLocation = (const char *)private_pem_key_start;
|
||||
mqttInitParams.pRootCALocation = (char *)aws_root_ca_pem_start;
|
||||
mqttInitParams.pDeviceCertLocation = (char *)certificate_pem_crt_start;
|
||||
mqttInitParams.pDevicePrivateKeyLocation = (char *)private_pem_key_start;
|
||||
|
||||
#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)
|
||||
mqttInitParams.pRootCALocation = ROOT_CA_PATH;
|
||||
@@ -228,7 +240,7 @@ void aws_iot_task(void *param) {
|
||||
connectParams.clientIDLen = (uint16_t) strlen(CONFIG_AWS_EXAMPLE_CLIENT_ID);
|
||||
connectParams.isWillMsgPresent = false;
|
||||
|
||||
ESP_LOGI(TAG, "Connecting to AWS...");
|
||||
ESP_LOGI(TAG, "Connecting to AWS with client ID '%s'", connectParams.pClientID);
|
||||
do {
|
||||
rc = aws_iot_mqtt_connect(&client, &connectParams);
|
||||
if(SUCCESS != rc) {
|
||||
@@ -298,9 +310,23 @@ void aws_iot_task(void *param) {
|
||||
|
||||
static void initialise_wifi(void)
|
||||
{
|
||||
tcpip_adapter_init();
|
||||
wifi_event_group = xEventGroupCreate();
|
||||
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||
ESP_EVENT_ANY_ID,
|
||||
&event_handler,
|
||||
NULL,
|
||||
NULL));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||
IP_EVENT_STA_GOT_IP,
|
||||
&event_handler,
|
||||
NULL,
|
||||
NULL));
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
|
||||
|
||||
Reference in New Issue
Block a user