Skip to content

Commit

Permalink
Merge pull request #388 from gojimmypi/PR-Espressif-Examples
Browse files Browse the repository at this point in the history
Initial wolfMQTT Espressif ESP32 template and AWS IoT examples
  • Loading branch information
embhorn committed Jan 8, 2024
2 parents c6c93ce + 0e1f709 commit e49f7b3
Show file tree
Hide file tree
Showing 45 changed files with 5,912 additions and 88 deletions.
212 changes: 124 additions & 88 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,88 +1,124 @@
# Object files
*.o
*.ko
*.lo

# Libraries
*.lib
*.a
*.la

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app

# autoconf misc
aclocal.m4
lt*.m4
*.cache
config.*
configure
libtool
libtool.m4
*.log
*.gz
Makefile
Makefile.in
*.deps
.dirstamp
*.libs
stamp-h
src/stamp-h1
build-aux/
wolfmqtt-config
aminclude.am

# vim
*.swp
tags
diff
.vimrc

# test output

# scan-build
client.plist

# other
Debug
.vs
*.aps
*.sdf
*.user
*.opensdf
*.trs
firmware.bin
wolfmqtt/options.h
IDE/ARDUINO/wolfMQTT
IDE/Microchip-Harmony/wolfmqtt_client/firmware/mqtt_client.X/dist/default/
build/

# examples
examples/aws/awsiot
examples/azure/azureiothub
examples/firmware/fwclient
examples/firmware/fwpush
examples/mqttclient/mqttclient
examples/mqttsimple/mqttsimple
examples/nbclient/nbclient
examples/sn-client/sn-client
examples/sn-client/sn-client_qos-1
examples/sn-client/sn-multithread
examples/multithread/multithread
examples/wiot/wiot
examples/pub-sub/mqtt-pub
examples/pub-sub/mqtt-sub

# eclipse
.cproject
.project
.settings

# Object files
*.o
*.ko
*.lo

# Libraries
*.lib
*.a
*.la

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app

# autoconf misc
aclocal.m4
lt*.m4
*.cache
config.*
configure
libtool
libtool.m4
*.log
*.gz
Makefile
Makefile.in
*.deps
.dirstamp
*.libs
stamp-h
src/stamp-h1
build-aux/
wolfmqtt-config
aminclude.am

# vim
*.swp
tags
diff
.vimrc

# test output

# scan-build
client.plist

# other
Debug
.vs
*.aps
*.sdf
*.user
*.opensdf
*.trs
firmware.bin
wolfmqtt/options.h
IDE/ARDUINO/wolfMQTT
IDE/Microchip-Harmony/wolfmqtt_client/firmware/mqtt_client.X/dist/default/
build/

# examples
examples/aws/awsiot
examples/azure/azureiothub
examples/firmware/fwclient
examples/firmware/fwpush
examples/mqttclient/mqttclient
examples/mqttsimple/mqttsimple
examples/nbclient/nbclient
examples/sn-client/sn-client
examples/sn-client/sn-client_qos-1
examples/sn-client/sn-multithread
examples/multithread/multithread
examples/wiot/wiot
examples/pub-sub/mqtt-pub
examples/pub-sub/mqtt-sub

# eclipse
.cproject
.project
.settings

# All backup files
*.bak

# auto-created CMake backups
**/CMakeLists.txt.old
**/CMakeLists.txt.bak

# VisualGDB
**/.visualgdb
**/*.vgdbproj.*.user

# Espressif sdk config default should be saved in sdkconfig.defaults
# we won't track the actual working sdkconfig files
/IDE/Espressif/**/out/
/IDE/Espressif/**/sdkconfig
/IDE/Espressif/**/sdkconfig.old

# Espressif managed components to exclude:
/IDE/Espressif/**/managed_components/**

# Espressif managed component lock files to exclude.
# "In general, it's ok to have it under version control, however, it ties
# the solution to the exact version of ESP-IDF and will be ignored if an
# example is built against another IDF version or for a different target.
# So it's better to git ignore it for the examples."
/IDE/Espressif/**/dependencies.lock

# exclude any local oqs components
/IDE/Espressif/ESP-IDF/examples/**/components/oqs

# The only ESP Registry Files specific to this location
/IDE/Espressif/ESP-IDF/examples/wolfssl_test/**/components/cryptoauthlib

# Never exclude Espressif config.h files
!/IDE/Espressif/**/config.h

51 changes: 51 additions & 0 deletions IDE/Espressif/ESP-IDF/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Espressif ESP-IDF Examples

These are the core [examples](./examples/README.md) for wolfMQTT:

- [template](./examples/wolfmqtt_template/README.md)

- [AWS IoT MQTT](./examples/AWS_IoT_MQTT/README.md)

For details on wolfMQTT [see the wolfMQTT Manual](https://www.wolfssl.com/documentation/manuals/wolfmqtt/wolfMQTT-Manual.pdf).

## Installing wolfSSL for Espressif projects

[Core examples](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples)
have a local `components/wolfssl` directory with a special CMakeFile.txt that does not require
wolfSSL to be installed.

If you want to install wolfSSL, see the setup for [wolfSSL](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF#setup-for-linux)
and [wolfSSH](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif#setup-for-linux).

## VisualGDB

Users of VisualGDB can find project files in each respective example `.\VisualGDB` directory.
For convenience, there are separate project for various target chip sets and ESP-IDF version.

For devices without a built-in JTAG, the projects are configured with the open source [Tigard](https://www.crowdsupply.com/securinghw/tigard)
and using port `COM20`.

For devices _with_ a built-in JTAG, the projects are using `COM9`

Edit the COM port for your project:

- ESP-IDF Project; Bootloader COM Port.
- Raw Terminal; COM Port


## Troubleshooting

If unusual errors occur, exit Visual Studio and manually delete these directories to start over:

- `.\build`
- `.\VisualGDB\.visualgdb`
- `.\VisualGDB\.vs`


[RSA peripheral 50% slower on ESP32-S3/C3 than S2](https://www.esp32.com/viewtopic.php?t=23830)

[GPIO6,GPIO7,GPIO8,and GPIO9 changed for ESP32-WROOM-32E](https://esp32.com/viewtopic.php?t=29058)




117 changes: 117 additions & 0 deletions IDE/Espressif/ESP-IDF/examples/AWS_IoT_MQTT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# wolfSSL Espressif Example Project CMakeLists.txt
# v1.0
#
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

# enable wolfssl user_settings.h project-wide
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS")
set(WOLFSSL_USER_SETTINGS ON)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFMQTT_USER_SETTINGS")
set(WOLFMQTT_USER_SETTINGS ON)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_AWSIOT_EXAMPLE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_MQTT_TLS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFMQTT_EXTERN_CERT")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_MAIN_DRIVER")



# The wolfSSL CMake file should be able to find the source code.
# Otherwise, assign an environment variable or set it here:
#
# set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source")
# set(WOLFMQTT_ROOT "~/workspace/wolfmqtt-other-source")

# Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find
# USE_MY_PRIVATE_CONFIG path for my_private_config.h
#
# Expected path varies:
#
# WSL: /mnt/c/workspace
# Linux: ~/workspace
# Windows: C:\workspace
#
if(WIN32)
# Windows-specific configuration here
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS")
message("Detected Windows")
endif()
if(CMAKE_HOST_UNIX)
message("Detected UNIX")
endif()
if(APPLE)
message("Detected APPLE")
endif()
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop")
# Windows-specific configuration here
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL")
message("Detected WSL")
endif()
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32))
# Windows-specific configuration here
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX")
message("Detected Linux")
endif()
if(APPLE)
# Windows-specific configuration here
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE")
message("Detected Apple")
endif()
# End optional WOLFSSL_CMAKE_SYSTEM_NAME

# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)

if (EXISTS "${PROTOCOL_EXAMPLES_DIR}")
message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR")
else()
message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
endif()

# Check that there are not conflicting wolfSSL components
# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl
# The local component wolfSSL directory will be in ./components/wolfssl
if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" )
# These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake'
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL)
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL)
# So we'll error out and let the user decide how to proceed:
message(WARNING "\nFound wolfSSL components in\n"
"./managed_components/wolfssl__wolfssl\n"
"and\n"
"./components/wolfssl\n"
"in project directory: \n"
"${CMAKE_HOME_DIRECTORY}")
message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n"
"If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove "
"or rename the idf_component.yml file typically found in ./main/")
else()
message(STATUS "No conflicting wolfSSL components found.")
endif()


# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)

if (EXISTS "${PROTOCOL_EXAMPLES_DIR}")
message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR")
else()
message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}")
endif()

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

#set(COMPONENTS
#main
#wolfssl
#wolfmqtt
#) # set components

project(wolfssl_mqtt_aws_iot)
Loading

0 comments on commit e49f7b3

Please sign in to comment.