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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,23 @@ jobs:
- name: Install dependencies
run: |
brew install openssl
# Install CMake 3.31.6 from Kitware
curl -L https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-macos-universal.dmg -o cmake.dmg
# Install CMake 3.26.4 from Kitware
curl -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-macos-universal.dmg -o cmake.dmg
hdiutil attach cmake.dmg
sudo cp -R /Volumes/cmake-3.31.6-macos-universal/CMake.app /Applications/
sudo cp -R /Volumes/cmake-3.26.4-macos-universal/CMake.app /Applications/
sudo /Applications/CMake.app/Contents/bin/cmake-gui --install
hdiutil detach /Volumes/cmake-3.31.6-macos-universal
hdiutil detach /Volumes/cmake-3.26.4-macos-universal
rm cmake.dmg
echo "CMAKE_PATH=/Applications/CMake.app/Contents/bin" >> $GITHUB_ENV

- name: Configure and build
env:
OPENSSL_ROOT_DIR: /opt/homebrew/opt/openssl@3
OPENSSL_LIBRARIES: /opt/homebrew/opt/openssl@3/lib
OPENSSL_INCLUDE_DIR: /opt/homebrew/opt/openssl@3/include
CMAKE_PATH: /Applications/CMake.app/Contents/bin
run: |
export PATH="/Applications/CMake.app/Contents/bin:$PATH"
./build.sh -DCMAKE_BUILD_TYPE=debug -DONESDK_WITH_TEST=ON

- name: Run tests
Expand Down
22 changes: 18 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ set -e # Exit on any error

# Function to check CMake version
check_cmake_version() {
if ! command -v cmake &> /dev/null; then
echo "Error: CMake is not installed!"
# Use CMAKE_PATH if provided, otherwise use default cmake command
if [ -n "$CMAKE_PATH" ]; then
CMAKE_CMD="$CMAKE_PATH/cmake"
else
CMAKE_CMD="cmake"
fi

if ! command -v $CMAKE_CMD &> /dev/null; then
echo "Error: CMake is not installed at $CMAKE_CMD!"
exit 1
fi

cmake_version=$(cmake --version | head -n1 | cut -d' ' -f3)
cmake_version=$($CMAKE_CMD --version | head -n1 | cut -d' ' -f3)
cmake_major=$(echo $cmake_version | cut -d'.' -f1)
cmake_minor=$(echo $cmake_version | cut -d'.' -f2)

Expand Down Expand Up @@ -48,8 +55,15 @@ fi
mkdir -p build
cd build

# Use CMAKE_PATH if provided, otherwise use default cmake command
if [ -n "$CMAKE_PATH" ]; then
CMAKE_CMD="$CMAKE_PATH/cmake"
else
CMAKE_CMD="cmake"
fi

echo "Running cmake with arguments: $@"
cmake $@ ..
$CMAKE_CMD $@ ..
if [ $? -ne 0 ]; then
echo "CMake configuration failed!"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion examples/onesdk_esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message(STATUS "onesdk_esp32 srcs: ${ONESDK_ESP32_SRCS}")
set(ONESDK_ESP32_DEPS onesdk)
message(STATUS "onesdk_esp32 deps: ${ONESDK_ESP32_DEPS}")
idf_component_register(SRCS "${ONESDK_ESP32_SRCS}"
PRIV_REQUIRES ${ONESDK_ESP32_DEPS}
PRIV_REQUIRES ${ONESDK_ESP32_DEPS} wpa_supplicant
# INCLUDE_DIRS "../libwebsockets/include;${IDF_PATH}/components/spi_flash/include;${IDF_PATH}/components/nvs_flash/include")
INCLUDE_DIRS ".;${IDF_PATH}/components/spi_flash/include;${IDF_PATH}/components/nvs_flash/include")

Expand Down
11 changes: 8 additions & 3 deletions src/iot/iot_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static int callback_mqtt(struct lws *wsi, enum lws_callback_reasons reason,
*/
struct lws_context *context = lws_get_context(wsi);
iot_mqtt_ctx_t *ctx = (iot_mqtt_ctx_t *)lws_context_user(context);
ctx->wsi = wsi;

switch (reason) {
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
Expand All @@ -62,7 +61,8 @@ static int callback_mqtt(struct lws *wsi, enum lws_callback_reasons reason,
ctx->waiting_for_suback = 0;
lws_callback_on_writable(wsi);
lws_set_timer_usecs(wsi, ctx->config->ping_interval*1000000);

ctx->wsi = wsi;

return 0;

case LWS_CALLBACK_MQTT_SUBSCRIBED:
Expand Down Expand Up @@ -452,7 +452,12 @@ int iot_mqtt_init(iot_mqtt_ctx_t *ctx, iot_mqtt_config_t *config) {
// info.register_notifier_list = na;
info.retry_and_idle_policy = &retry;
info.user = (void*)ctx;
// info.client_ssl_ca_filepath = NULL;
if (config->enable_mqtts && config->basic_config->ssl_ca_cert) {
info.server_ssl_ca_mem = config->basic_config->ssl_ca_cert;
info.server_ssl_ca_mem_len = strlen(config->basic_config->ssl_ca_cert);

info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
}
struct lws_context *context = lws_create_context(&info);
if (context == NULL) {
lwsl_err("lws init failed\n");
Expand Down
Loading