diff --git a/.appveyor.yml b/.appveyor.yml index a22ecb83..c13b4db3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,6 +2,7 @@ image: - Visual Studio 2015 - Visual Studio 2017 - Visual Studio 2019 + - Visual Studio 2022 init: - git config --global core.autocrlf input @@ -18,6 +19,10 @@ configuration: - Release environment: + COMMS_BRANCH: master + CC_MQTTSN_BRANCH: master + CC_MQTT311_BRANCH: master + matrix: - CPP_STD: 11 - CPP_STD: 14 @@ -37,13 +42,25 @@ matrix: install: - call script\appveyor_install.bat - set PATH=%PATH%;%QTDIR%\bin + - set BUILD_DIR=%APPVEYOR_BUILD_FOLDER%\build.%PLATFORM%.%CONFIGURATION%.%TOOLCHAIN% + - if exist %BUILD_DIR% rmdir /S /Q %BUILD_DIR% + - set COMMS_TAG=%COMMS_BRANCH% + - set CC_MQTTSN_TAG=%CC_MQTTSN_BRANCH% + - set CC_MQTT311_TAG=%CC_MQTT311_BRANCH% + - set COMMON_INSTALL_DIR=%BUILD_DIR%\install + - set COMMON_BUILD_TYPE=%CONFIGURATION% + - set COMMON_CXX_STANDARD=%CPP_STD% + - call script\prepare_externals.bat build_script: - - mkdir build.%PLATFORM%.%CONFIGURATION%.%TOOLCHAIN% - - cd build.%PLATFORM%.%CONFIGURATION%.%TOOLCHAIN% - - cmake .. -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "NMake Makefiles" -DCC_MQTTSN_QT_DIR=%QTDIR% -DCMAKE_INSTALL_PREFIX=install -DCMAKE_CXX_STANDARD=%CPP_STD% - - nmake install + - echo ------------------------- Building Project ------------------------- + - cd %BUILD_DIR% + - cmake .. -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install ^ + -DCMAKE_CXX_STANDARD=%CPP_STD% -DCMAKE_PREFIX_PATH="%COMMON_INSTALL_DIR%" ^ + -DCC_MQTTSN_BUILD_UNIT_TESTS=ON + - cmake --build . --config %CONFIGURATION% --target install test_script: + - echo ------------------------- Testing ------------------------- - ctest diff --git a/.github/workflows/actions_build.yml b/.github/workflows/actions_build.yml index 8d82f3cf..6c1b270d 100644 --- a/.github/workflows/actions_build.yml +++ b/.github/workflows/actions_build.yml @@ -2,32 +2,60 @@ name: Github Actions Build on: [push] +env: + COMMS_BRANCH: master + CC_MQTTSN_BRANCH: master + CC_MQTT311_BRANCH: master + jobs: - build_gcc_ubuntu_18_04: - runs-on: ubuntu-18.04 + build_gcc_old_ubuntu_20_04: + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: type: [Debug, Release, MinSizeRel] - cc_ver: [5, 6] + cc_ver: [5, 6, 7] cpp: [11, 14] steps: - uses: actions/checkout@v2 + - name: Add repositories + run: | + sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ bionic main'; \ + sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ bionic universe' + - name: Prepare Install run: sudo apt-get update --fix-missing - name: Install Packages - run: sudo apt install gcc-${{matrix.cc_ver}} g++-${{matrix.cc_ver}} + run: sudo apt install qtbase5-dev valgrind gcc-${{matrix.cc_ver}} g++-${{matrix.cc_ver}} - name: Create Build Environment run: cmake -E make_directory ${{runner.workspace}}/build + - name: Prepare externals + shell: bash + run: $GITHUB_WORKSPACE/script/prepare_externals.sh + env: + BUILD_DIR: ${{runner.workspace}}/build + CC: gcc-${{matrix.cc_ver}} + CXX: g++-${{matrix.cc_ver}} + EXTERNALS_DIR: ${{runner.workspace}}/externals + COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install + COMMON_BUILD_TYPE: ${{matrix.type}} + COMMON_CXX_STANDARD: ${{matrix.cpp}} + COMMS_TAG: ${{env.COMMS_BRANCH}} + CC_MQTTSN_TAG: ${{env.CC_MQTTSN_BRANCH}} + CC_MQTT311_TAG: ${{env.CC_MQTT311_BRANCH}} + - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DCMAKE_INSTALL_PREFIX=install -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold + run: | + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold -DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install \ + -DCC_MQTTSN_BUILD_UNIT_TESTS=ON -DCC_MQTTSN_UNIT_TEST_WITH_VALGRIND=ON env: CC: gcc-${{matrix.cc_ver}} CXX: g++-${{matrix.cc_ver}} @@ -35,14 +63,14 @@ jobs: - name: Build working-directory: ${{runner.workspace}}/build shell: bash - run: cmake --build . --target install + run: cmake --build . --config ${{matrix.type}} --target install env: VERBOSE: 1 - name: Test working-directory: ${{runner.workspace}}/build shell: bash - run: ctest + run: ctest -V build_gcc_ubuntu_20_04: runs-on: ubuntu-20.04 @@ -50,13 +78,67 @@ jobs: fail-fast: false matrix: type: [Debug, Release, MinSizeRel] - cc_ver: [7, 8, 9, 10] + cc_ver: [8] + cpp: [11, 14, 17] + + steps: + - uses: actions/checkout@v2 + + - name: Prepare Install + run: sudo apt-get update --fix-missing + + - name: Install Packages + run: sudo apt install qtbase5-dev gcc-${{matrix.cc_ver}} g++-${{matrix.cc_ver}} + + - name: Create Build Environment + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Prepare externals + shell: bash + run: $GITHUB_WORKSPACE/script/prepare_externals.sh + env: + BUILD_DIR: ${{runner.workspace}}/build + CC: gcc-${{matrix.cc_ver}} + CXX: g++-${{matrix.cc_ver}} + EXTERNALS_DIR: ${{runner.workspace}}/externals + COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install + COMMON_BUILD_TYPE: ${{matrix.type}} + COMMON_CXX_STANDARD: ${{matrix.cpp}} + COMMS_TAG: ${{env.COMMS_BRANCH}} + CC_MQTTSN_TAG: ${{env.CC_MQTTSN_BRANCH}} + CC_MQTT311_TAG: ${{env.CC_MQTT311_BRANCH}} + + - name: Configure CMake + shell: bash + working-directory: ${{runner.workspace}}/build + run: | + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install \ + -DCC_MQTTSN_BUILD_UNIT_TESTS=ON -DCC_MQTTSN_WITH_SANITIZERS=ON + env: + CC: gcc-${{matrix.cc_ver}} + CXX: g++-${{matrix.cc_ver}} + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + run: cmake --build . --config ${{matrix.type}} --target install + env: + VERBOSE: 1 + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + run: ctest -V + + build_gcc_ubuntu_22_04: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + type: [Debug, Release, MinSizeRel] + cc_ver: [9, 10, 11, 12] cpp: [11, 14, 17, 20] - exclude: - - cc_ver: 7 - cpp: 20 - - cc_ver: 8 - cpp: 20 steps: - uses: actions/checkout@v2 @@ -65,15 +147,33 @@ jobs: run: sudo apt-get update --fix-missing - name: Install Packages - run: sudo apt install gcc-${{matrix.cc_ver}} g++-${{matrix.cc_ver}} + run: sudo apt install qtbase5-dev gcc-${{matrix.cc_ver}} g++-${{matrix.cc_ver}} - name: Create Build Environment run: cmake -E make_directory ${{runner.workspace}}/build + - name: Prepare externals + shell: bash + run: $GITHUB_WORKSPACE/script/prepare_externals.sh + env: + BUILD_DIR: ${{runner.workspace}}/build + CC: gcc-${{matrix.cc_ver}} + CXX: g++-${{matrix.cc_ver}} + EXTERNALS_DIR: ${{runner.workspace}}/externals + COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install + COMMON_BUILD_TYPE: ${{matrix.type}} + COMMON_CXX_STANDARD: ${{matrix.cpp}} + COMMS_TAG: ${{env.COMMS_BRANCH}} + CC_MQTTSN_TAG: ${{env.CC_MQTTSN_BRANCH}} + CC_MQTT311_TAG: ${{env.CC_MQTT311_BRANCH}} + - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DCMAKE_INSTALL_PREFIX=install + run: | + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install \ + -DCC_MQTTSN_BUILD_UNIT_TESTS=ON -DCC_MQTTSN_WITH_SANITIZERS=ON env: CC: gcc-${{matrix.cc_ver}} CXX: g++-${{matrix.cc_ver}} @@ -81,37 +181,24 @@ jobs: - name: Build working-directory: ${{runner.workspace}}/build shell: bash - run: cmake --build . --target install + run: cmake --build . --config ${{matrix.type}} --target install env: VERBOSE: 1 - name: Test working-directory: ${{runner.workspace}}/build shell: bash - run: ctest + run: ctest -V - build_clang_ubuntu_18_04: - runs-on: ubuntu-18.04 +# - clang crashes up to version 9 + build_clang_ubuntu_20_04: + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: type: [Debug, Release, MinSizeRel] -# cc_ver: ["4.0", "5.0", "6.0", 7, 8, 9] - clang crashes up to version 9 - cc_ver: [9] + cc_ver: [9, 10, 11] cpp: [11, 14, 17, 20] - exclude: - - cc_ver: "4.0" - cpp: 17 - - cc_ver: "4.0" - cpp: 20 - - cc_ver: "5.0" - cpp: 20 - - cc_ver: "6.0" - cpp: 20 - - cc_ver: 7 - cpp: 20 - - cc_ver: 8 - cpp: 20 steps: - uses: actions/checkout@v2 @@ -120,15 +207,33 @@ jobs: run: sudo apt-get update --fix-missing - name: Install Packages - run: sudo apt install clang-${{matrix.cc_ver}} + run: sudo apt install qtbase5-dev clang-${{matrix.cc_ver}} - name: Create Build Environment run: cmake -E make_directory ${{runner.workspace}}/build + - name: Prepare externals + shell: bash + run: $GITHUB_WORKSPACE/script/prepare_externals.sh + env: + BUILD_DIR: ${{runner.workspace}}/build + CC: clang-${{matrix.cc_ver}} + CXX: clang++-${{matrix.cc_ver}} + EXTERNALS_DIR: ${{runner.workspace}}/externals + COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install + COMMON_BUILD_TYPE: ${{matrix.type}} + COMMON_CXX_STANDARD: ${{matrix.cpp}} + COMMS_TAG: ${{env.COMMS_BRANCH}} + CC_MQTTSN_TAG: ${{env.CC_MQTTSN_BRANCH}} + CC_MQTT311_TAG: ${{env.CC_MQTT311_BRANCH}} + - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DCMAKE_INSTALL_PREFIX=install + run: | + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install \ + -DCC_MQTTSN_BUILD_UNIT_TESTS=ON -DCC_MQTTSN_WITH_SANITIZERS=ON env: CC: clang-${{matrix.cc_ver}} CXX: clang++-${{matrix.cc_ver}} @@ -136,22 +241,22 @@ jobs: - name: Build working-directory: ${{runner.workspace}}/build shell: bash - run: cmake --build . --target install + run: cmake --build . --config ${{matrix.type}} --target install env: VERBOSE: 1 - name: Test working-directory: ${{runner.workspace}}/build shell: bash - run: ctest - - build_clang_ubuntu_20_04: - runs-on: ubuntu-20.04 + run: ctest -V + + build_clang_ubuntu_22_04: + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: type: [Debug, Release, MinSizeRel] - cc_ver: [10] + cc_ver: [12, 13, 14] cpp: [11, 14, 17, 20] steps: @@ -161,15 +266,33 @@ jobs: run: sudo apt-get update --fix-missing - name: Install Packages - run: sudo apt install clang-${{matrix.cc_ver}} + run: sudo apt install qtbase5-dev clang-${{matrix.cc_ver}} - name: Create Build Environment run: cmake -E make_directory ${{runner.workspace}}/build + - name: Prepare externals + shell: bash + run: $GITHUB_WORKSPACE/script/prepare_externals.sh + env: + BUILD_DIR: ${{runner.workspace}}/build + CC: clang-${{matrix.cc_ver}} + CXX: clang++-${{matrix.cc_ver}} + EXTERNALS_DIR: ${{runner.workspace}}/externals + COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install + COMMON_BUILD_TYPE: ${{matrix.type}} + COMMON_CXX_STANDARD: ${{matrix.cpp}} + COMMS_TAG: ${{env.COMMS_BRANCH}} + CC_MQTTSN_TAG: ${{env.CC_MQTTSN_BRANCH}} + CC_MQTT311_TAG: ${{env.CC_MQTT311_BRANCH}} + - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DCMAKE_INSTALL_PREFIX=install + run: | + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install \ + -DCC_MQTTSN_BUILD_UNIT_TESTS=ON -DCC_MQTTSN_WITH_SANITIZERS=ON env: CC: clang-${{matrix.cc_ver}} CXX: clang++-${{matrix.cc_ver}} @@ -177,12 +300,12 @@ jobs: - name: Build working-directory: ${{runner.workspace}}/build shell: bash - run: cmake --build . --target install + run: cmake --build . --config ${{matrix.type}} --target install env: VERBOSE: 1 - name: Test working-directory: ${{runner.workspace}}/build shell: bash - run: ctest - + run: ctest -V + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a742ece2..6387b8e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,63 +1,23 @@ cmake_minimum_required (VERSION 3.1) -project ("mqttsn") +project ("cc_mqttsn") -option (CC_MQTTSN_NO_WARN_AS_ERR "Do NOT treat warning as error" OFF) +option (CC_MQTTSN_WARN_AS_ERR "Do NOT treat warning as error" ON) option (CC_MQTTSN_CLIENT_DEFAULT_LIB "Build and install default variant of MQTT-SN Client library" ON) option (CC_MQTTSN_BUILD_GATEWAY "Build and install MQTT-SN client library(ies) and applications" ON) -option (CC_MQTTSN_NO_UNIT_TESTS "Disable unittests." OFF) -option (CC_MQTTSN_NO_VALGRIND "Disable valgrind in unittests." OFF) -option (CC_MQTTSN_EXTERNALS_UPDATE_DISCONNECTED "Allow skip of external projects update." OFF) +option (CC_MQTTSN_BUILD_CLIENT_APPS "Build and install client applications" ${CC_MQTTSN_CLIENT_DEFAULT_LIB}) +option (CC_MQTTSN_BUILD_GATEWAY_APPS "Build and install gateway applications" ${CC_MQTTSN_BUILD_GATEWAY}) +option (CC_MQTTSN_BUILD_UNIT_TESTS "Build unittests." OFF) +option (CC_MQTTSN_UNIT_TEST_WITH_VALGRIND "Disable valgrind in unittests." OFF) option (CC_MQTTSN_USE_CCACHE "Use ccache on unix system" ON) +option (CC_MQTTSN_WITH_SANITIZERS "Build with sanitizers" OFF) # Extra variables -# CC_MAIN_INSTALL_DIR - Path to external installation directory of COMMS library. -# CC_MQTTSN_GENERATED_INSTALL_DIR - Path to external installation directory of cc.mqttsn.generated project. -# CC_MQTT311_GENERATED_INSTALL_DIR - Path to external installation directory of cc.mqtt311.generated project. # CC_MQTTSN_CUSTOM_CLIENT_CONFIG_FILES - List of custom client configuration files # CC_MQTTSN_DEFAULT_CLIENT_CONFIG_FILE - Custom congiruation of the default client. -# CC_MQTTSN_QT_DIR - Path to external Qt5 installation directory - -# CC_COMMS_REPO - Repository of COMMS library project. Defaults to https://github.com/commschamp/comms.git -# CC_COMMS_TAG - Tag to use for external COMMS library project. Can be empty. -# CC_COMMS_CMAKE_ARGS - Extra CMake arguments pass to external COMMS library project - -# CC_MQTTSN_PROTOCOL_REPO - Repository of cc.mqttsn.generated project. Defaults to https://github.com/commschamp/cc.mqttsn.generated.git -# CC_MQTTSN_PROTOCOL_TAG - Tag to use for external cc.mqttsn.generated project. Can be empty. -# CC_MQTTSN_PROTOCOL_CMAKE_ARGS - Extra CMake arguments pass to external cc.mqttsn.generated project - -# CC_MQTT311_PROTOCOL_REPO - Repository of cc.mqtt311.generated project. Defaults to https://github.com/commschamp/cc.mqtt311.generated.git -# CC_MQTT311_PROTOCOL_TAG - Tag to use for external cc.mqttsn.generated project. Can be empty. -# CC_MQTT311_PROTOCOL_CMAKE_ARGS - Extra CMake arguments pass to external cc.mqtt311.generated project - +# CC_MQTTSN_SANITIZERS - List of sanitizing options # Updating default settings -if (NOT CMAKE_CXX_STANDARD) - set (CMAKE_CXX_STANDARD 11) -endif() - -if ("${CC_COMMS_REPO}" STREQUAL "") - set (CC_COMMS_REPO "https://github.com/commschamp/comms.git") -endif () - -if ("${CC_COMMS_TAG}" STREQUAL "") - set (CC_COMMS_TAG "v4.0") -endif () - -if ("${CC_MQTTSN_PROTOCOL_REPO}" STREQUAL "") - set (CC_MQTTSN_PROTOCOL_REPO "https://github.com/commschamp/cc.mqttsn.generated.git") -endif () - -if ("${CC_MQTTSN_PROTOCOL_TAG}" STREQUAL "") - set (CC_MQTTSN_PROTOCOL_TAG "v1.0") -endif () - -if ("${CC_MQTT311_PROTOCOL_REPO}" STREQUAL "") - set (CC_MQTT311_PROTOCOL_REPO "https://github.com/commschamp/cc.mqtt311.generated.git") -endif () - -if ("${CC_MQTT311_PROTOCOL_TAG}" STREQUAL "") - set (CC_MQTT311_PROTOCOL_TAG "v1.0") -endif () +set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use") ########################################################################## @@ -65,141 +25,56 @@ if (CMAKE_TOOLCHAIN_FILE AND EXISTS ${CMAKE_TOOLCHAIN_FILE}) message(STATUS "Loading toolchain from ${CMAKE_TOOLCHAIN_FILE}") endif() -set (EXTERNALS_DIR "${PROJECT_SOURCE_DIR}/externals") -set (CXXTEST_EXTERNAL_DIR "${EXTERNALS_DIR}/cxxtest") - -if (NOT CC_MAIN_INSTALL_DIR) - execute_process ( - COMMAND ${CMAKE_COMMAND} -E make_directory "${EXTERNALS_DIR}" - ) - - set (cc_src_dir "${EXTERNALS_DIR}/comms") - set (cc_bin_dir "${PROJECT_BINARY_DIR}/comms") - set (CC_MAIN_INSTALL_DIR "${cc_bin_dir}/install") - - include (${PROJECT_SOURCE_DIR}/cmake/CC_Prefetch.cmake) - cc_prefetch(SRC_DIR ${cc_src_dir} TAG ${CC_COMMS_TAG}) - - include (${cc_src_dir}/cmake/CC_CommsExternal.cmake) - cc_comms_build_during_config( - SRC_DIR ${cc_src_dir} - BUILD_DIR ${cc_bin_dir} - TAG ${CC_COMMS_TAG} - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CC_MAIN_INSTALL_DIR} - ) +find_package(LibComms REQUIRED) +set (compile_opts) +if (CC_MQTTSN_USE_CCACHE) + list (APPEND compile_opts USE_CCACHE) endif () -list (APPEND CMAKE_PREFIX_PATH "${CC_MAIN_INSTALL_DIR}") -find_package(LibComms NO_MODULE) -set (cc_compile_file ${CC_MAIN_INSTALL_DIR}/lib/LibComms/cmake/CC_Compile.cmake) -if (EXISTS ${cc_compile_file}) - set (warn_as_err_opt) - if (NOT CC_MQTTSN_NO_WARN_AS_ERR) - set (warn_as_err_opt WARN_AS_ERR) - endif () +if (CC_MQTTSN_WARN_AS_ERR) + list (APPEND compile_opts WARN_AS_ERR) +endif () + +if (CC_MQTTSN_WITH_SANITIZERS) + list (APPEND compile_opts DEFAULT_SANITIZERS) - set (ccache_opt) - if (CC_MQTTSN_USE_CCACHE) - set (ccache_opt USE_CCACHE) + if (CMAKE_COMPILER_IS_GNUCC) + # gcc gives false pasitive on vptr sanitizer + list (APPEND compile_opts EXTRA -fno-sanitize=vptr) endif () - include (${cc_compile_file}) - cc_compile(${warn_as_err_opt} ${ccache_opt}) endif () -if (MSVC) - add_definitions(-D_SCL_SECURE_NO_WARNINGS) -endif () +include (${LibComms_DIR}/CC_Compile.cmake) +cc_compile(${compile_opts}) + +set (EXTERNALS_DIR "${PROJECT_SOURCE_DIR}/externals") while (TRUE) - if (CC_MQTTSN_NO_UNIT_TESTS) - message (STATUS "Unittests are disabled") + if (NOT CC_MQTTSN_BUILD_UNIT_TESTS) break() endif () + + message (STATUS "Unittests are enabled") if (CMAKE_CROSSCOMPILING) message (STATUS "Not building unittests when cross-compiling") break() endif () - include (${CC_MAIN_INSTALL_DIR}/lib/LibComms/cmake/CC_CxxtestFuncs.cmake) + include (${LibComms_DIR}/CC_CxxtestFuncs.cmake) cc_get_cxxtest(INSTALL_PREFIX ${EXTERNALS_DIR}) - if (NOT CC_MQTTSN_NO_VALGRIND) + if ((NOT CC_MQTTSN_WITH_SANITIZERS) AND (CC_MQTTSN_UNIT_TEST_WITH_VALGRIND)) find_program(VALGRIND_EXECUTABLE NAMES "valgrind") endif () break() endwhile () -set (INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) - include(GNUInstallDirs) -set (INSTALL_NAME "CC_Mqttsn") -set (LIB_INSTALL_DIR ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}) -set (BIN_INSTALL_DIR ${INSTALL_DIR}/${CMAKE_INSTALL_BINDIR}) -set (ETC_INSTALL_DIR ${INSTALL_DIR}/${CMAKE_INSTALL_SYSCONFDIR}) -set (INC_INSTALL_DIR ${INSTALL_DIR}/${CMAKE_INSTALL_INCLUDEDIR}) -set (CONFIG_INSTALL_DIR ${INSTALL_DIR}/config) -set (PLUGIN_INSTALL_DIR ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/CommsChampion/plugin) -set (DOC_INSTALL_DIR ${INSTALL_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/doc) - set (DEFAULT_CLIENT_LIB_TGT "cc_mqttsn_client") -if (NOT "${CC_MQTTSN_QT_DIR}" STREQUAL "") - list (APPEND CMAKE_PREFIX_PATH ${CC_MQTTSN_QT_DIR}) -endif () - -###################################################################### - -set (CC_MQTTSN_EXTERNAL_DIR "${EXTERNALS_DIR}/cc.mqttsn.generated") -set (CC_MQTTSN_EXTERNAL_TGT "mqttsn_external") -set (CC_MQTTSN_EXTERNAL_TGT_INCLUDE) - -if ("${CC_MQTTSN_GENERATED_INSTALL_DIR}" STREQUAL "") - execute_process ( - COMMAND ${CMAKE_COMMAND} -E make_directory "${EXTERNALS_DIR}") - - include(ExternalProject) - - set (cc_mqttsn_generated_tag "${CC_MQTTSN_PROTOCOL_TAG}") - set (cc_mqttsn_main_dir "${CMAKE_CURRENT_BINARY_DIR}/cc.mqttsn.generated") - set (cc_mqttsn_src_dir "${CC_MQTTSN_EXTERNAL_DIR}") - set (cc_mqttsn_bin_dir "${cc_mqttsn_main_dir}/build") - set (cc_mqttsn_install_dir "${cc_mqttsn_main_dir}/install") - set (cc_mqttsn_update_disconnected) - - if (CC_MQTTSN_EXTERNALS_UPDATE_DISCONNECTED) - set (cc_mqttsn_update_disconnected UPDATE_DISCONNECTED 1) - endif () - - ExternalProject_Add( - "${CC_MQTTSN_EXTERNAL_TGT}" - PREFIX "${cc_mqttsn_bin_dir}" - STAMP_DIR "${cc_mqttsn_bin_dir}" - GIT_REPOSITORY "${CC_MQTTSN_PROTOCOL_REPO}" - GIT_TAG "${cc_mqttsn_generated_tag}" - SOURCE_DIR "${cc_mqttsn_src_dir}" - CMAKE_ARGS - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${cc_mqttsn_install_dir} - -DOPT_REQUIRE_COMMS_LIB=OFF - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - ${CC_MQTTSN_PROTOCOL_CMAKE_ARGS} - BINARY_DIR "${cc_mqttsn_bin_dir}" - ${cc_mqttsn_update_disconnected} - ) - set (CC_MQTTSN_EXTERNAL_TGT_INCLUDE "${cc_mqttsn_install_dir}/include") -else () - list (APPEND CMAKE_PREFIX_PATH "${CC_MQTT311_GENERATED_INSTALL_DIR}") - find_package(mqtt311 NO_MODULE) - if (NOT TARGET cc::mqtt311) - message (FATAL_ERROR "Failed to find external mqtt311 library") - endif () -endif () - ###################################################################### add_subdirectory(client) diff --git a/README.md b/README.md index 41dbb891..e6fb9069 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ details below. This repository provides the MQTT-SN **client** library. It is implemented using C++(11) programming language, but provides **C** interface. The library's code doesn't use [RTTI](https://en.wikipedia.org/wiki/Run-time_type_information) -or exceptions, but by default, +or exceptions, but by default the library's implementation uses C++ STL data types, such as [std::string](http://en.cppreference.com/w/cpp/string/basic_string) and [std::vector](http://en.cppreference.com/w/cpp/container/vector). However, @@ -32,8 +32,7 @@ refer to [doc/custom_client_build.md](doc/custom_client_build.md) for instructio how to do it. The doxygen generated documentation of the library with its full tutorial can -be downloaded from -[release artefacts](https://github.com/arobenko/mqtt-sn/releases). +be downloaded from the [release artefacts](releases). # Client Applications The [Client Library](#client-library) described above is I/O link agnostic, @@ -42,7 +41,7 @@ correct delivery of the messages. This repository also provides a couple of MQTT-SN **client** "publish"(**cc_mqttsn_pub_udp**) and "subscribe" (**cc_mqttsn_sub_udp**) example applications, which use UDP/IP as its datagram transport layer. These applications are also using -[QT5](https://doc.qt.io/qt-5/) framework for their operation. It means that if +[Qt5](https://doc.qt.io/qt-5/) framework for their operation. It means that if proper QT5 libraries are not installed or can not be found, these applications won't be compiled. @@ -60,8 +59,7 @@ The gateway uses [v3.1.1](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3 of the MQTT protocol to connect to and communicate with the broker. The doxygen generated documentation of the library with its full tutorial can -be downloaded from -[release artefacts](https://github.com/arobenko/mqtt-sn/releases). +be downloaded from the [release artefacts](releases). # Gateway Applications The [Gateway Library](#gateway-library) described above is I/O link agnostic, @@ -69,7 +67,7 @@ it allows to do any additional packatisation of the sent data to allow correct delivery of the messages. This repository also provides the MQTT-SN gateway(**cc_mqttsn_gateway_udp**) example application, which uses UDP/IP as its datagram transport layer. The application also using -[QT5](https://doc.qt.io/qt-5/) framework for its operation. It means that if +[Qt5](https://doc.qt.io/qt-5/) framework for its operation. It means that if proper QT5 libraries are not installed or can not be found, the gateway example application won't be compiled. diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index adacc55a..d5808a6c 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -14,6 +14,7 @@ set (TEMPL_PROCESS_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/script/ProcessTemplate.cma set (DEFAULT_CLIENT_NAME "") set (MQTTSN_CLIENT_LIB_NAME "cc_mqttsn_client") set (MQTTSN_CLIENT_HEADER_TGT "client.h.tgt") +set (COMMON_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) ###################################################################### @@ -73,12 +74,19 @@ function (gen_lib_mqttsn_client name client_opts inst extra_flags) message (STATUS "Defining library ${lib_name}") add_library (${lib_name} STATIC ${src_output}) - target_include_directories(${lib_name} BEFORE PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") - target_link_libraries(${lib_name} PRIVATE cc::comms) + add_library (cc::${lib_name} ALIAS ${lib_name}) + target_link_libraries(${lib_name} PRIVATE cc::cc_mqttsn cc::comms) + target_include_directories( + ${lib_name} BEFORE + PUBLIC + $ + $ + PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}") set_target_properties( ${lib_name} PROPERTIES - POSITION_INDEPENDENT_CODE TRUE + INTERFACE_LINK_LIBRARIES "" ) add_dependencies(${lib_name} ${header_tgt_name} ${src_tgt_name}) @@ -102,41 +110,32 @@ function (gen_lib_mqttsn_client name client_opts inst extra_flags) ) endif () - if (TARGET cc::mqttsn) - target_link_libraries(${lib_name} PRIVATE cc::mqttsn) - endif () - - if (NOT "${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${lib_name} PRIVATE ${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}) - endif () - - if (TARGET ${CC_MQTTSN_EXTERNAL_TGT}) - add_dependencies(${lib_name} ${CC_MQTTSN_EXTERNAL_TGT}) - endif () - if (inst) install ( FILES ${header_output} - DESTINATION ${INC_INSTALL_DIR}/mqttsn/client + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cc_mqttsn_client ) install ( TARGETS ${lib_name} - DESTINATION ${LIB_INSTALL_DIR} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + EXPORT ${lib_name}Config ) + + install(EXPORT ${lib_name}Config NAMESPACE cc:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${lib_name}/cmake + ) endif () endfunction() ###################################################################### -include_directories( - BEFORE - ${CMAKE_CURRENT_SOURCE_DIR}/include -) +find_package(LibComms REQUIRED) +find_package(cc_mqttsn REQUIRED) install ( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/mqttsn - DESTINATION ${INC_INSTALL_DIR} + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/cc_mqttsn_client + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) add_subdirectory (src) @@ -146,7 +145,7 @@ add_subdirectory (test) find_package (Doxygen) if (DOXYGEN_FOUND AND CC_MQTTSN_CLIENT_DEFAULT_LIB) - set (doc_output_dir "${DOC_INSTALL_DIR}/mqttsn/client") + set (doc_output_dir "${CMAKE_INSTALL_FULL_DATAROOTDIR}/doc/cc_mqttsn_client") make_directory (${doc_output_dir}) set (match_str "OUTPUT_DIRECTORY[^\n]*") @@ -164,7 +163,7 @@ if (DOXYGEN_FOUND AND CC_MQTTSN_CLIENT_DEFAULT_LIB) execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/doc/main.dox - ${CMAKE_CURRENT_SOURCE_DIR}/include/mqttsn/client/common.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/cc_mqttsn_client/common.h ${interface_doc_dir}/) add_custom_target ("doc_mqttsn_client" diff --git a/client/doc/doxygen.conf b/client/doc/doxygen.conf index 16446288..3172862c 100644 --- a/client/doc/doxygen.conf +++ b/client/doc/doxygen.conf @@ -1,4 +1,4 @@ -# Doxyfile 1.8.11 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -17,11 +17,11 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = /mqttsn/client +OUTPUT_DIRECTORY = /cc_mqttsn_client # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -93,6 +93,14 @@ ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. @@ -179,6 +187,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -199,6 +217,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -226,16 +252,15 @@ TAB_SIZE = 4 # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all @@ -264,28 +289,40 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -293,6 +330,15 @@ EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -318,7 +364,7 @@ BUILTIN_STL_SUPPORT = YES CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -404,6 +450,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -424,6 +483,12 @@ EXTRACT_ALL = YES EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -461,6 +526,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -478,8 +550,8 @@ HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -498,11 +570,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = YES @@ -684,12 +763,12 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -734,13 +813,17 @@ WARN_IF_DOC_ERROR = NO # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = YES @@ -776,8 +859,8 @@ INPUT = # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -790,13 +873,61 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, -# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. - -FILE_PATTERNS = +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -827,7 +958,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -838,7 +969,7 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include @@ -949,7 +1080,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -981,12 +1112,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1009,16 +1140,22 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. # Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse-libclang=ON option for CMake. +# generated with the -Duse_libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories @@ -1027,6 +1164,19 @@ CLANG_ASSISTED_PARSING = NO CLANG_OPTIONS = +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1038,13 +1188,6 @@ CLANG_OPTIONS = ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1145,7 +1288,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1181,6 +1324,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1204,13 +1358,14 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1249,8 +1404,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1280,7 +1435,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1325,7 +1480,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1333,8 +1489,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1342,30 +1498,30 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1442,6 +1598,17 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1451,7 +1618,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1462,8 +1629,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1475,7 +1648,7 @@ USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1490,11 +1663,11 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example @@ -1505,7 +1678,8 @@ MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1533,7 +1707,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1552,7 +1726,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1565,8 +1740,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1617,21 +1793,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_CMD_NAME = latex +LATEX_CMD_NAME = # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1716,9 +1906,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1752,7 +1944,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1766,6 +1958,14 @@ LATEX_BIB_STYLE = plain LATEX_TIMESTAMP = NO +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1805,9 +2005,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1816,8 +2016,8 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = @@ -1903,6 +2103,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1935,9 +2142,9 @@ DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2214,10 +2421,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2336,7 +2565,7 @@ MSCFILE_DIRS = # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the # path where java can find the plantuml.jar file. If left blank, it is assumed @@ -2346,6 +2575,11 @@ DIAFILE_DIRS = PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. @@ -2394,7 +2628,7 @@ DOT_TRANSPARENT = NO # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_MULTI_TARGETS = YES +DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated @@ -2404,9 +2638,11 @@ DOT_MULTI_TARGETS = YES GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/client/doc/main.dox b/client/doc/main.dox index 1e43706e..db26efbd 100644 --- a/client/doc/main.dox +++ b/client/doc/main.dox @@ -1,6 +1,6 @@ /// @mainpage MQTT-SN Client Library /// @tableofcontents -/// @section mqttsn_client_overview Overview +/// @section cc_mqttsn_client_overview Overview /// The MQTT-SN Client Library provides simple, asynchronous, non-blocking, /// and easy to use interface to operate MQTT-SN client. The library doesn't /// make any assumption on the system it is running on, as well as on the type @@ -10,18 +10,18 @@ /// /// @li Sends and receives over the I/O link are managed outside this /// library. The data received from the gateway is provided to the library for processing -/// (see mqttsn_client_process_data()) and the data to be sent to the gateway is +/// (see cc_mqttsn_client_process_data()) and the data to be sent to the gateway is /// provided by the library using callback (see -/// mqttsn_client_set_send_output_data_callback()). +/// cc_mqttsn_client_set_send_output_data_callback()). /// @li The library requires measurement of timeouts, it will request to /// do so using callback (see -/// mqttsn_client_set_next_tick_program_callback()). +/// cc_mqttsn_client_set_next_tick_program_callback()). /// The driving code will have to use available system timer -/// and notify the library about the requested time expiry (see mqttsn_client_tick()). +/// and notify the library about the requested time expiry (see cc_mqttsn_client_tick()). /// @li Sometimes the library will terminate the previously requested time /// measurement request and inquire the amount of elapsed milliseconds /// since last request. Such inquiry is performed using callback (see -/// mqttsn_client_set_cancel_next_tick_wait_callback()). +/// cc_mqttsn_client_set_cancel_next_tick_wait_callback()). /// @li The library supports only @b one asynchronous operation at a time. The /// next one can @b NOT be started until previous one complete or cancelled. /// @li All the asynchronous operations receive pointer to callback function, @@ -30,7 +30,7 @@ /// (string or raw data), this buffer must be preserved intact by the caller /// until the asynchronous operation is complete (provided callback is called). /// -/// @section mqttsn_client_io_links Various I/O Links +/// @section cc_mqttsn_client_io_links Various I/O Links /// MQTT-SN is designed to be a @b datagram protocol, i.e. if sent message is /// received by the other side, it is received in full and /// without errors. If sent over UDP link, it can be used as is. The @@ -42,37 +42,37 @@ /// sent or received data to be wrapped with or unwrapped from additional /// independent transport data, that insures safe and correct delivery. /// -/// @section mqttsn_client_header Header +/// @section cc_mqttsn_client_header Header /// To use this MQTT-SN Client Library use the following include statement: /// @code -/// #include "mqttsn/client/client.h" +/// #include "cc_mqttsn_client/client.h" /// @endcode /// -/// @section mqttsn_client_allocation Client Allocation +/// @section cc_mqttsn_client_allocation Client Allocation /// The library supports may support multiple independent MQTT-SN clients. The /// allocation of data structures relevant to a single client is performed -/// using mqttsn_client_new() function. +/// using cc_mqttsn_client_new() function. /// @code -/// MqttsnClientHandle client = mqttsn_client_new(); +/// CC_MqttsnClientHandle client = cc_mqttsn_client_new(); /// @endcode /// All other functions are client specific, the receive the returned handle /// as their first parameter. /// /// When work with allocated client is complete, it must be freed using -/// mqttsn_client_free() function. +/// cc_mqttsn_client_free() function. /// @code -/// mqttsn_client_free(client); +/// cc_mqttsn_client_free(client); /// @endcode /// /// All the allocated clients are completely independent. It is safe to use /// multiple threads working with multiple clients as long as there are no /// concurrent accesses to the same one. /// -/// @section mqttsn_client_setup Client Setup +/// @section cc_mqttsn_client_setup Client Setup /// As was mentioned earlier, there is a need for multiple callbacks to be /// set. Four of them are mandatory. /// -# Callback to be invoked when new message needs to be sent to the gateway -/// (see mqttsn_client_set_send_output_data_callback()). +/// (see cc_mqttsn_client_set_send_output_data_callback()). /// @code /// void my_send(void* userData, const unsigned char* buf, unsigned bufLen, bool broadcast) /// { @@ -85,21 +85,21 @@ /// } /// /// void* someUserData = ...; -/// mqttsn_client_set_send_output_data_callback(client, &my_send, someUserData); +/// cc_mqttsn_client_set_send_output_data_callback(client, &my_send, someUserData); /// @endcode /// -# Callback to be invoked when timer needs to be programmed -/// (see mqttsn_client_set_next_tick_program_callback()). +/// (see cc_mqttsn_client_set_next_tick_program_callback()). /// @code /// void my_timer(void* userData, unsigned ms) /// { -/// ... /* Program asynchronous timer to tick after requested number of milliseconds. When expires invoke mqttsn_client_tick() */ +/// ... /* Program asynchronous timer to tick after requested number of milliseconds. When expires invoke cc_mqttsn_client_tick() */ /// } /// -/// mqttsn_client_set_next_tick_program_callback(client, &my_timer, someUserData); +/// cc_mqttsn_client_set_next_tick_program_callback(client, &my_timer, someUserData); /// @endcode /// -# Callback to be invoked when previous timer program needs to be cancelled /// and number of elapsed seconds since last timer programming request known -/// (see mqttsn_client_set_cancel_next_tick_wait_callback()). +/// (see cc_mqttsn_client_set_cancel_next_tick_wait_callback()). /// @code /// unsigned my_cancel_timer(void* userData) /// { @@ -107,17 +107,17 @@ /// return ...; /* return number of elapsed milliseconds */ /// } /// -/// mqttsn_client_set_cancel_next_tick_wait_callback(client, &my_cancel_timer, someUserData); +/// cc_mqttsn_client_set_cancel_next_tick_wait_callback(client, &my_cancel_timer, someUserData); /// @endcode /// -# Callback to be invoked when new application message arrives -/// (see mqttsn_client_set_message_report_callback()). +/// (see cc_mqttsn_client_set_message_report_callback()). /// @code -/// void my_message_handler(void* userData, const MqttsnMessageInfo* msgInfo) +/// void my_message_handler(void* userData, const CC_MqttsnMessageInfo* msgInfo) /// { /// ... /* handle application message */ /// } /// -/// mqttsn_client_set_message_report_callback(client, &my_message_handler, someUserData); +/// cc_mqttsn_client_set_message_report_callback(client, &my_message_handler, someUserData); /// @endcode /// /// All other callbacks are optional and described in later sections. @@ -127,60 +127,60 @@ /// message needs to be resent. After number of such retry attempts if there is /// still no response, the requested operation needs to terminate with relevant /// error code. The retry period in seconds can be configured using -/// mqttsn_client_set_retry_period() function and number of retry attempts -/// can be configured using mqttsn_client_set_retry_count() function. The +/// cc_mqttsn_client_set_retry_period() function and number of retry attempts +/// can be configured using cc_mqttsn_client_set_retry_count() function. The /// default values are @b 15 seconds and @b 3 attempts respectively. /// @code -/// mqttsn_client_set_retry_period(client, 5); // retry after 5 seconds -/// mqttsn_client_set_retry_count(client, 4); // perform 4 retry attempts +/// cc_mqttsn_client_set_retry_period(client, 5); // retry after 5 seconds +/// cc_mqttsn_client_set_retry_count(client, 4); // perform 4 retry attempts /// @endcode /// /// After client has been successfully configured, it needs to be started. /// @code -/// MqttsnErrorCode result = mqttsn_client_start(client); -/// if (result != MqttsnErrorCode_Success) { +/// CC_MqttsnErrorCode result = cc_mqttsn_client_start(client); +/// if (result != CC_MqttsnErrorCode_Success) { /// ... /* start has failed, probably some mandatory callback hasn't been set */ /// } /// @endcode -/// If a gateway needs to be discovered (see @ref mqttsn_client_gateways), the +/// If a gateway needs to be discovered (see @ref cc_mqttsn_client_gateways), the /// client will immediately request to send generated @b SEARCHGW message. /// /// If client's work needs to be paused for a while, it can be stopped using -/// mqttsn_client_stop() and restarted again using mqttsn_client_start(). +/// cc_mqttsn_client_stop() and restarted again using cc_mqttsn_client_start(). /// -/// @section mqttsn_client_data_recv Receiving Data +/// @section cc_mqttsn_client_data_recv Receiving Data /// When new data datagram is successfully received over I/O link, it needs -/// to be passed to the library for processing using mqttsn_client_process_data(). +/// to be passed to the library for processing using cc_mqttsn_client_process_data(). /// @code /// unsigned char buf[1024] = {0}; /// ... /* Read data into buffer */ /// -/// unsigned consumed = mqttsn_client_process_data(client, &buf[0], bytesCount); +/// unsigned consumed = cc_mqttsn_client_process_data(client, &buf[0], bytesCount); /// if (consumed < bytesCount) { /// ... /* Unexpected protocol error, too few bytes consumed. */ /// } /// @endcode -/// The mqttsn_client_process_data() function returns number of bytes that +/// The cc_mqttsn_client_process_data() function returns number of bytes that /// were actually processed. If number of processed bytes is less that number /// of bytes residing in the buffer, then probably some unexpected protocol error has /// occurred. /// -/// The invocation of mqttsn_client_process_data() function may cause invocation +/// The invocation of cc_mqttsn_client_process_data() function may cause invocation /// of multiple callbacks, such as cancellation of the current time measurement, /// report of incoming new application message, report information about new /// gateway, asynchronous operation completion, request to send data back to /// the gateway, and reprogram timer with new delay value. /// -/// @section mqttsn_client_data_send Sending Data +/// @section cc_mqttsn_client_data_send Sending Data /// As was mentioned earlier, the request to send data is performed using callback -/// function. It is set using mqttsn_client_set_send_output_data_callback(). +/// function. It is set using cc_mqttsn_client_set_send_output_data_callback(). /// @code /// void my_send(void* userData, const unsigned char* buf, unsigned bufLen, bool broadcast) /// { /// ... /// } /// -/// mqttsn_client_set_send_output_data_callback(client, &my_send, someUserData); +/// cc_mqttsn_client_set_send_output_data_callback(client, &my_send, someUserData); /// @endcode /// @b NOTE, that the callback function receives pointer to the buffer of data. /// This buffer will be destroyed or updated right after the function returns. @@ -192,7 +192,7 @@ /// data needs to be broadcasted on the network or sent directly to the /// gateway that the client is connected to. /// -/// @section mqttsn_client_time_measurement Time Measurement +/// @section cc_mqttsn_client_time_measurement Time Measurement /// The MQTT-SN client must be aware of time to be able to measure delays /// between messages. The driving code has to provide a callback using /// which the library may request for such time measurement. The second @@ -201,17 +201,17 @@ /// @code /// void my_timer(void* userData, unsigned ms) /// { -/// ... /* Program asynchronous timer to tick after requested number of milliseconds. When expires invoke mqttsn_client_tick() */ +/// ... /* Program asynchronous timer to tick after requested number of milliseconds. When expires invoke cc_mqttsn_client_tick() */ /// } /// -/// mqttsn_client_set_next_tick_program_callback(client, &my_timer, someUserData); +/// cc_mqttsn_client_set_next_tick_program_callback(client, &my_timer, someUserData); /// @endcode /// /// The driving code will have to use its system timer(s) to measure the /// required time, and notify the library when it expires using -/// mqttsn_client_tick() function. +/// cc_mqttsn_client_tick() function. /// @code -/// mqttsn_client_tick(client); +/// cc_mqttsn_client_tick(client); /// @endcode /// /// Based on some events, the library may require knowledge of elapsed time @@ -225,13 +225,13 @@ /// return ...; /* return number of elapsed milliseconds */ /// } /// -/// mqttsn_client_set_cancel_next_tick_wait_callback(client, &my_cancel_timer, someUserData); +/// cc_mqttsn_client_set_cancel_next_tick_wait_callback(client, &my_cancel_timer, someUserData); /// @endcode /// When the library issues the existing time measurement cancellation request, /// the driving code must cancel its programmed system timer and -/// must @b NOT call mqttsn_client_tick() function later on. +/// must @b NOT call cc_mqttsn_client_tick() function later on. /// -/// @section mqttsn_client_gateways Gateway Discovery +/// @section cc_mqttsn_client_gateways Gateway Discovery /// The MQTT-SN protocol built to be suitable for wireless sensor networks, where /// the exact address of the gateway may be unknown upfront or there may be /// multiple gateways available. As the result it includes messages for @@ -240,28 +240,28 @@ /// provides an ability to enable or disable broadcast of @b SEARCHGW message, /// which causes available gateways to respond and be identified. /// @code -/// mqttsn_client_set_searchgw_enabled(client, false); /* Disable sending of SEARCHGW messages to discover the gateway */ +/// cc_mqttsn_client_set_searchgw_enabled(client, false); /* Disable sending of SEARCHGW messages to discover the gateway */ /// @endcode /// By default, the broadcast of @b SEARCHGW message is /// @b enabled, and the library will immediately request to do so when -/// call to mqttsn_client_start() is performed. +/// call to cc_mqttsn_client_start() is performed. /// /// The library monitors the @b GWINFO responses of the gateways as well as /// their own independent advertising of their presence (using @b ADVERTISE /// message) and reports the discovered gateways via callback. /// @code -/// void my_gw_status_report(void* userData, unsigned char gwId, MqttsnGwStatus status) +/// void my_gw_status_report(void* userData, unsigned char gwId, CC_MqttsnGwStatus status) /// { -/// if (status == MqttsnGwStatus_Available) { +/// if (status == CC_MqttsnGwStatus_Available) { /// ... /* New gateway has been discovered */ /// } -/// else if (status == MqttsnGwStatus_TimedOut) { +/// else if (status == CC_MqttsnGwStatus_TimedOut) { /// ... /* The gateway hasn't advertise its presence for a while, probably is not available any more */ /// } /// ... /// } /// -/// mqttsn_client_set_gw_status_report_callback(client, &my_gw_status_report, someUserData); +/// cc_mqttsn_client_set_gw_status_report_callback(client, &my_gw_status_report, someUserData); /// @endcode /// The gateways report their numeric ID (only one byte long), /// which is expected be unique on the available network. @@ -269,7 +269,7 @@ /// in order to connect to the chosen available gateway, there may be a need to know /// address of the latter. In this case, the driving code should store the origin address /// of every message in its private data structures prior to forwarding the -/// incoming data to the library for processing (see @ref mqttsn_client_data_recv). +/// incoming data to the library for processing (see @ref cc_mqttsn_client_data_recv). /// If the gateway status report callback is called immediately, indicating /// available gateway, the reported ID as well as recorded address may be /// stored as gateway identification information and to be used for connection @@ -289,7 +289,7 @@ /// when some gateway failed to advertise its presence in time, and hence was /// reported as "timed out", but may still be online and respond to messages. /// The only way to identify the real availability of the gateway is to try -/// to connect to it (see @ref mqttsn_client_connect_disconnect section below). +/// to connect to it (see @ref cc_mqttsn_client_connect_disconnect section below). /// /// The library provides an ability to discard information about currently being /// tracked gateway. It may be useful when attempt to connect or send any messages @@ -297,25 +297,25 @@ /// the gateway appears online again and advertises its presence, the gateway /// status report callback will be invoked again reporting new availability. /// @code -/// mqttsn_client_discard_gw(client, gwId); +/// cc_mqttsn_client_discard_gw(client, gwId); /// @endcode /// /// The library also provides an ability to discard information about all /// gateways at once. /// @code -/// mqttsn_client_discard_all_gw(client); +/// cc_mqttsn_client_discard_all_gw(client); /// @endcode /// -/// @section mqttsn_client_connect_disconnect Connect / Disconnect +/// @section cc_mqttsn_client_connect_disconnect Connect / Disconnect /// In order to establish connection to MQTT-SN gateway, the client must send /// to it special @b CONNECT message. It must be done prior to issuing any /// publish or subscribe request. The connection can be performed using -/// mqttsn_client_connect() call. +/// cc_mqttsn_client_connect() call. /// @code /// const char* clientId = "my_client_id"; -/// void my_connect_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_connect_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { -/// if (status == MqttsnAsyncOpStatus_Successful) { +/// if (status == CC_MqttsnAsyncOpStatus_Successful) { /// ... /* Connection is successful, do something */ /// } /// else { @@ -326,7 +326,7 @@ /// /// void someFunc() /// { -/// MqttsnErrorCode result = mqttsn_client_connect(client, clientId, 60, true, NULL, &my_client_connect, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_connect(client, clientId, 60, true, NULL, &my_client_connect, someUserData); /// ... /// } /// @endcode @@ -338,7 +338,7 @@ /// /// Also @b NOTE, that @b will information (fifth parameter) may also be NULL to /// indicate that will doesn't exist. NULL or empty string as topic in the -/// passed @ref MqttsnWillInfo structure will have the same effect. +/// passed @ref CC_MqttsnWillInfo structure will have the same effect. /// @code /// const char* willTopic = "this/is/will/topic" /// const unsigned char willMsg[] = {...} @@ -346,14 +346,14 @@ /// /// void someFunc() /// { -/// MqttsnWillInfo willInfo; +/// CC_MqttsnWillInfo willInfo; /// willInfo.topic = willTopic; /// willInfo.msg = willMsg; /// willInfo.msgLen = willMsgSize; -/// willInfo.qos = MqttsnQoS_AtMostOnceDelivery; +/// willInfo.qos = CC_MqttsnQoS_AtMostOnceDelivery; /// willInfo.retain = false; /// -/// MqttsnErrorCode result = mqttsn_client_connect(client, clientId, 60, true, &willInfo, &my_client_connect, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_connect(client, clientId, 60, true, &willInfo, &my_client_connect, someUserData); /// ... /// } /// @endcode @@ -361,18 +361,18 @@ /// client ID, will topic as will as will message body must be preserved intact /// until the completion callback is called. However, the @b willInfo structure /// may reside on the stack and be destroyed right after invocation of -/// mqttsn_client_connect() function. +/// cc_mqttsn_client_connect() function. /// /// When client needs to gracefully terminate its connection to the gateway it /// needs to send @b DISCONNECT message. It can be achieved by calling to -/// mqttsn_client_disconnect() function. +/// cc_mqttsn_client_disconnect() function. /// @code -/// void my_disconnect_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_disconnect_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /* do something */ /// } /// -/// MqttsnErrorCode result = mqttsn_client_disconnect(client, &my_disconnect_complete, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_disconnect(client, &my_disconnect_complete, someUserData); /// ... /// @endcode /// If client just abandons its connection to the gateway without proper @@ -392,25 +392,25 @@ /// ... /* try to connect to the gateway again */ /// } /// -/// mqttsn_client_set_gw_disconnect_report_callback(client, &my_gw_disconnect_report, someUserData); +/// cc_mqttsn_client_set_gw_disconnect_report_callback(client, &my_gw_disconnect_report, someUserData); /// @endcode /// If this callback is invoked, the client may try to connect to the gateway again. /// -/// When establishing first connection to the broker (using mqttsn_client_connect()), +/// When establishing first connection to the broker (using cc_mqttsn_client_connect()), /// the client ID and "keep alive" /// period information is provided. This information is stored in internal /// data structures of the library. When there is a need to refresh the same -/// connection to the client, mqttsn_client_reconnect() function may be used. +/// connection to the client, cc_mqttsn_client_reconnect() function may be used. /// Such need may arise when any asynchronous operation reports -/// @ref MqttsnAsyncOpStatus_NoResponse. It may happen for multiple reasons, +/// @ref CC_MqttsnAsyncOpStatus_NoResponse. It may happen for multiple reasons, /// for example, when gateway issued unsolicited disconnect request, but its /// @b DISCONNECT message wasn't received by the client. The gateway will /// drop or reject any incoming messages until the new connection request is /// sent. /// @code -/// void my_reconnect_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_reconnect_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { -/// if (status == MqttsnAsyncOpStatus_Successful) { +/// if (status == CC_MqttsnAsyncOpStatus_Successful) { /// ... /* Connection is successful, do something */ /// } /// else { @@ -419,14 +419,14 @@ /// ... /// } /// -/// MqttsnErrorCode result = mqttsn_client_reconnect(client, &my_reconnect_complete, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_reconnect(client, &my_reconnect_complete, someUserData); /// ... /// @endcode /// -/// @section mqttsn_client_publish Publishing -/// The publish operation is performed using mqttsn_client_publish() function call. +/// @section cc_mqttsn_client_publish Publishing +/// The publish operation is performed using cc_mqttsn_client_publish() function call. /// @code -/// void my_publish_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_publish_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /// } @@ -436,13 +436,13 @@ /// const unsigned pubDataSize = sizeof(pubData)/sizeof(pubData[0]); /// /// void someFunc() { -/// MqttsnErrorCode result = -/// mqttsn_client_publish( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_publish( /// client, /// pubTopic, /// pubData, /// pubDataSize, -/// MqttsnQoS_AtLeastOnceDelivery, +/// CC_MqttsnQoS_AtLeastOnceDelivery, /// false, /// &my_publish_complete, /// someUserData); @@ -453,26 +453,27 @@ /// preserved intact by the caller until the completion callback is invoked. /// /// The MQTT-SN protocol also supports predefined numeric topic IDs instead of -/// topic strings. To publish such message use mqttsn_client_publish_id(). +/// topic strings. To publish such message use cc_mqttsn_client_publish_id(). /// @code /// void someFunc() { -/// MqttsnErrorCode result = -/// mqttsn_client_publish_id( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_publish_id( /// client, /// pubTopicId, /* numeric topic ID instead of string */ /// pubData, /// pubDataSize, -/// MqttsnQoS_AtLeastOnceDelivery, +/// CC_MqttsnQoS_AtLeastOnceDelivery, /// false, /// &my_publish_complete, /// someUserData); +/// } /// @endcode /// -/// @section mqttsn_client_subscribe Subscribing -/// The subscribe operation is performed using mqttsn_client_subscribe() function +/// @section cc_mqttsn_client_subscribe Subscribing +/// The subscribe operation is performed using cc_mqttsn_client_subscribe() function /// call. /// @code -/// void my_subscribe_complete(void* userData, MqttsnAsyncOpStatus status, MqttsnQoS qos) +/// void my_subscribe_complete(void* userData, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos) /// { /// ... /// } @@ -480,11 +481,11 @@ /// const char* subTopic = "subtopic1/+/subtopic2/#" /// /// void someFunc() { -/// MqttsnErrorCode result = -/// mqttsn_client_subscribe( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_subscribe( /// client, /// subTopic, -/// MqttsnQoS_ExactlyOnceDelivery, /* max QoS */ +/// CC_MqttsnQoS_ExactlyOnceDelivery, /* max QoS */ /// &my_subscribe_complete, /// someUserData); /// ... @@ -503,22 +504,24 @@ /// @b + and @b # wildcards. /// /// The MQTT-SN protocol also supports subscription to predefined topic IDs -/// instead of topic strings. To do so use mqttsn_client_subscribe_id(). +/// instead of topic strings. To do so use cc_mqttsn_client_subscribe_id(). /// @code /// void someFunc() { -/// MqttsnErrorCode result = -/// mqttsn_client_subscribe_id( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_subscribe_id( /// client, /// subTopicId, /* numeric topic ID instead of string */ -/// MqttsnQoS_ExactlyOnceDelivery, +/// CC_MqttsnQoS_ExactlyOnceDelivery, /// &my_subscribe_complete, /// someUserData); +/// ... +/// } /// @endcode /// -/// @section mqttsn_client_unsubscribe Unsubscribing -/// To unsubscribe use either mqttsn_client_unsubscribe() for string topics: +/// @section cc_mqttsn_client_unsubscribe Unsubscribing +/// To unsubscribe use either cc_mqttsn_client_unsubscribe() for string topics: /// @code -/// void my_unsubscribe_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_unsubscribe_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /// } @@ -526,8 +529,8 @@ /// const char* unsubTopic = "some/topic" /// /// void someFunc() { -/// MqttsnErrorCode result = -/// mqttsn_client_unsubscribe( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_unsubscribe( /// client, /// unsubTopic, /// &my_unsubscribe_complete, @@ -535,11 +538,11 @@ /// ... /// } /// @endcode -/// and mqttsn_client_unsubscribe_id() for predefined numeric topic IDs: +/// and cc_mqttsn_client_unsubscribe_id() for predefined numeric topic IDs: /// @code /// void someFunc() { -/// MqttsnErrorCode result = -/// mqttsn_client_unsubscribe_id( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_unsubscribe_id( /// client, /// unsubTopicId, // numeric ID /// &my_unsubscribe_complete, @@ -548,13 +551,13 @@ /// } /// @endcode /// -/// @section mqttsn_client_will Updating the Will +/// @section cc_mqttsn_client_will Updating the Will /// There are several ways to update the will information that was initially -/// setup during connection process (see @ref mqttsn_client_connect_disconnect). +/// setup during connection process (see @ref cc_mqttsn_client_connect_disconnect). /// /// One way is to update both topic and message body in one go: /// @code -/// void my_will_update_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_will_update_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /// } @@ -564,27 +567,27 @@ /// /// void someFunc() /// { -/// MqttsnWillInfo willInfo; +/// CC_MqttsnWillInfo willInfo; /// willInfo.topic = willTopic; /// willInfo.msg = willMsg; /// willInfo.msgLen = willMsgSize; -/// willInfo.qos = MqttsnQoS_AtMostOnceDelivery; +/// willInfo.qos = CC_MqttsnQoS_AtMostOnceDelivery; /// willInfo.retain = false; /// -/// MqttsnErrorCode result = mqttsn_client_will_update(client, &willInfo, &my_will_update_complete, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_will_update(client, &willInfo, &my_will_update_complete, someUserData); /// ... /// } /// @endcode /// Just like with connection request, all the buffers must be preserved by the /// caller until callback is called. Passing NULL as second parameter -/// (pointer to MqttsnWillInfo structure) as well as assigning NULL or empty +/// (pointer to CC_MqttsnWillInfo structure) as well as assigning NULL or empty /// string to @b topic data member of the struct means clearing the will /// information recorded with the broker. /// /// Another possible way is to update both will topic and will message body /// separately. /// @code -/// void my_will_topic_update_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_will_topic_update_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /// } @@ -592,11 +595,11 @@ /// /// void someFunc() /// { -/// MqttsnErrorCode result = -/// mqttsn_client_will_topic_update( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_will_topic_update( /// client, /// willTopic, -/// MqttsnQoS_AtMostOnceDelivery, +/// CC_MqttsnQoS_AtMostOnceDelivery, /// false, /// &my_will_topic_update_complete, /// someUserData); @@ -608,7 +611,7 @@ /// /// Updating will message body: /// @code -/// void my_will_msg_update_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_will_msg_update_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /// } @@ -617,8 +620,8 @@ /// /// void someFunc() /// { -/// MqttsnErrorCode result = -/// mqttsn_client_will_msg_update( +/// CC_MqttsnErrorCode result = +/// cc_mqttsn_client_will_msg_update( /// client, /// willMsg, /// willMsgSize, @@ -628,23 +631,23 @@ /// } /// @endcode /// -/// @section mqttsn_client_sleep Sleeping +/// @section cc_mqttsn_client_sleep Sleeping /// The MQTT-SN protocol supports sleeping clients. It requires to let gateway /// know about entering the low power mode to cause accumulating the /// incoming messages with the gateway until clients wakes up. /// -/// To notify the gateway use mqttsn_client_sleep() function. +/// To notify the gateway use cc_mqttsn_client_sleep() function. /// @code -/// void my_sleep_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_sleep_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { -/// if (status == MqttsnAsyncOpStatus_Successful) { +/// if (status == CC_MqttsnAsyncOpStatus_Successful) { /// ... /* Enter low power mode */ /// } /// ... /// } /// /// // Next communication attempt in 10 minutes (600 seconds) -/// MqttsnErrorCode result = mqttsn_client_sleep(client, 600, &my_sleep_complete, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_sleep(client, 600, &my_sleep_complete, someUserData); /// ... /// @endcode /// The second parameter specifies time duration in seconds within which the @@ -652,35 +655,35 @@ /// request. /// /// In order to notify the gateway about return to normal running mode, use -/// mqttsn_client_reconnect() message, described in -/// @ref mqttsn_client_connect_disconnect section. +/// cc_mqttsn_client_reconnect() message, described in +/// @ref cc_mqttsn_client_connect_disconnect section. /// /// Check for pending messages to be delivered can be performed using -/// mqttsn_client_check_messages() function. +/// cc_mqttsn_client_check_messages() function. /// @code -/// void my_check_messages_complete(void* userData, MqttsnAsyncOpStatus status) +/// void my_check_messages_complete(void* userData, CC_MqttsnAsyncOpStatus status) /// { /// ... /// } /// -/// MqttsnErrorCode result = mqttsn_client_check_messages(client, &my_check_messages_complete, someUserData); +/// CC_MqttsnErrorCode result = cc_mqttsn_client_check_messages(client, &my_check_messages_complete, someUserData); /// @endcode /// Between issuing the check request and completion callback invocation, there /// can be multiple exchange of messages between the client and gateway with /// multiple reports about incoming application messages. After callback is /// called, the client may return to low power mode again for up to number of -/// seconds provided to initial mqttsn_client_sleep() call. When this period +/// seconds provided to initial cc_mqttsn_client_sleep() call. When this period /// is over again, the client needs to either check for accumulated messages -/// again or reconnect to the gateway (using mqttsn_client_reconnect() function). +/// again or reconnect to the gateway (using cc_mqttsn_client_reconnect() function). /// -/// @section mqttsn_client_cancel Cancel Existing Operation +/// @section cc_mqttsn_client_cancel Cancel Existing Operation /// This MQTT-SN client library supports only one asynchronous operation at a /// time. If current operation takes too much time or there is other more /// important one to perform, the current operation can be cancelled. /// @code -/// bool cancelled = mqttsn_client_cancel(client); +/// bool cancelled = cc_mqttsn_client_cancel(client); /// @endcode /// The return value shows whether the operation was really cancelled. If no /// operation was in progress, false is returned. If the operation is cancelled, -/// the relevant callback will be invoked with @ref MqttsnAsyncOpStatus_Aborted +/// the relevant callback will be invoked with @ref CC_MqttsnAsyncOpStatus_Aborted /// status. diff --git a/client/include/cc_mqttsn_client/common.h b/client/include/cc_mqttsn_client/common.h new file mode 100644 index 00000000..747a1b8f --- /dev/null +++ b/client/include/cc_mqttsn_client/common.h @@ -0,0 +1,199 @@ +// +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +/// @file +/// @brief Common definition for MQTT-SN clients. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#else + +#ifdef WIN32 +#ifndef bool +#define bool char +#endif + +#ifndef true +#define true 1 +#endif + +#ifndef false +#define false 0 +#endif + +#else // #ifdef WIN32 +#include +#endif // #ifdef WIN32 + +#endif // #ifdef __cplusplus + +/// @brief Major verion of the library +#define CC_MQTTSN_CLIENT_MAJOR_VERSION 1U + +/// @brief Minor verion of the library +#define CC_MQTTSN_CLIENT_MINOR_VERSION 0U + +/// @brief Patch level of the library +#define CC_MQTTSN_CLIENT_PATCH_VERSION 0U + +/// @brief Macro to create numeric version as single unsigned number +#define CC_MQTTSN_CLIENT_MAKE_VERSION(major_, minor_, patch_) \ + ((static_cast(major_) << 24) | \ + (static_cast(minor_) << 8) | \ + (static_cast(patch_))) + +/// @brief Version of the library as single numeric value +#define CC_MQTTSN_CLIENT_VERSION CC_MQTTSN_CLIENT_MAKE_VERSION(CC_MQTTSN_CLIENT_MAJOR_VERSION, CC_MQTTSN_CLIENT_MINOR_VERSION, CC_MQTTSN_CLIENT_PATCH_VERSION) + +/// @brief Quality of Service +typedef enum +{ + CC_MqttsnQoS_NoGwPublish = -1, ///< QoS=-1. No gateway publish, used by publish only clients. + CC_MqttsnQoS_AtMostOnceDelivery, ///< QoS=0. At most once delivery. + CC_MqttsnQoS_AtLeastOnceDelivery, ///< QoS=1. At least once delivery. + CC_MqttsnQoS_ExactlyOnceDelivery ///< QoS=2. Exactly once delivery. +} CC_MqttsnQoS; + +/// @brief Error code returned by various API functions. +typedef enum +{ + CC_MqttsnErrorCode_Success, ///< The requested operation was successfully started. + CC_MqttsnErrorCode_AlreadyStarted, ///< Returned by cc_mqttsn_client_start() function if invoked twice. + CC_MqttsnErrorCode_NotStarted, ///< Returned by various operations if issued prior to successful start using cc_mqttsn_client_start(). + CC_MqttsnErrorCode_Busy, ///< The client library is in the middle of previous operation, cannot start a new one. + CC_MqttsnErrorCode_AlreadyConnected, ///< The client library is already connected to the gateway. Returned when cc_mqttsn_client_connect() invoked second time. + CC_MqttsnErrorCode_NotConnected, ///< The client library is not connected to the gateway. Returned by operations that require connection to the gateway. + CC_MqttsnErrorCode_NotSleeping, ///< The client is not in ASLEEP mode. + CC_MqttsnErrorCode_BadParam, ///< Bad parameter is passed to the function. +} CC_MqttsnErrorCode; + +/// @brief Status of the gateway +typedef enum +{ + CC_MqttsnGwStatus_Invalid, ///< Invalid value, should never be used + CC_MqttsnGwStatus_Available, ///< The gateway is available. + CC_MqttsnGwStatus_TimedOut, ///< The gateway hasn't advertised its presence in time, assumed disconnected. + CC_MqttsnGwStatus_Discarded ///< The gateway info was discarded using cc_mqttsn_client_discard_gw() or cc_mqttsn_client_discard_all_gw(). +} CC_MqttsnGwStatus; + +/// @brief Status of the asynchronous operation +typedef enum +{ + CC_MqttsnAsyncOpStatus_Invalid, ///< Invalid value, should never be used + CC_MqttsnAsyncOpStatus_Successful, ///< The operation was successful + CC_MqttsnAsyncOpStatus_Congestion, ///< The gateway/broker was busy and could not handle the request, try again + CC_MqttsnAsyncOpStatus_InvalidId, ///< Publish message used invalid topic ID. + CC_MqttsnAsyncOpStatus_NotSupported, ///< The issued request is not supported by the gateway. + CC_MqttsnAsyncOpStatus_NoResponse, ///< The gateway/broker didn't respond the the request + CC_MqttsnAsyncOpStatus_Aborted, ///< The operation was cancelled using cc_mqttsn_client_cancel() call. +} CC_MqttsnAsyncOpStatus; + +/// @brief Handler used to access client specific data structures. +/// @details Returned by cc_mqttsn_client_new() function. +typedef struct +{ + void* m_ptr; +} CC_MqttsnClientHandle; + +/// @brief Type used to hold Topic ID value. +typedef unsigned short CC_MqttsnTopicId; + +/// @brief Will Information +typedef struct +{ + const char* topic; ///< Topic of the will, can be NULL (means empty topic) + const unsigned char* msg; ///< Pointer to the buffer containing will binary message. + unsigned msgLen; ///< Length of the buffer containing will binary message. + CC_MqttsnQoS qos; ///< QoS level of the will message. + bool retain; ///< Retain flag +} CC_MqttsnWillInfo; + +/// @brief Incoming message information +typedef struct +{ + const char* topic; ///< Topic the message was published with. May be NULL if message is reported with predefined topic ID. + CC_MqttsnTopicId topicId; ///< Predefined topic ID. This data member is used only if topic field has value NULL. + const unsigned char* msg; ///< Pointer to reported message binary data. + unsigned msgLen; ///< Number of bytes in reported message binary data. + CC_MqttsnQoS qos; ///< QoS level the message was received with. + bool retain; ///< Retain flag of the message. +} CC_MqttsnMessageInfo; + +/// @brief Callback used to request time measurement. +/// @details The callback is set using +/// cc_mqttsn_client_set_next_tick_program_callback() function. +/// @param[in] data Pointer to user data object, passed as last parameter to +/// cc_mqttsn_client_set_next_tick_program_callback() function. +/// @param[in] duration Time duration in @b milliseconds. After the requested +/// time expires, the cc_mqttsn_client_tick() function is expected to be invoked. +typedef void (*CC_MqttsnNextTickProgramFn)(void* data, unsigned duration); + +/// @brief Callback used to request termination of existing time measurement. +/// @details The callback is set using +/// cc_mqttsn_client_set_cancel_next_tick_wait_callback() function. +/// @param[in] data Pointer to user data object, passed as last parameter to +/// cc_mqttsn_client_set_cancel_next_tick_wait_callback() function. +/// @return Number of elapsed milliseconds since last time measurement request. +typedef unsigned (*CC_MqttsnCancelNextTickWaitFn)(void* data); + +/// @brief Callback used to request to send data to the gateway. +/// @details The callback is set using +/// cc_mqttsn_client_set_send_output_data_callback() function. The reported +/// data resides in internal data structures of the client library, and +/// it can be updated right after the callback function returns. It means +/// the data may need to be copied into some other buffer which will be +/// held intact until the send over I/O link operation is complete. +/// @param[in] data Pointer to user data object, passed as last parameter to +/// cc_mqttsn_client_set_send_output_data_callback() function. +/// @param[in] buf Pointer to the buffer containing data to send +/// @param[in] bufLen Number of bytes to send +/// @param[in] broadcast Indication whether data needs to be broadcasted or +/// sent directly to the gateway. +typedef void (*CC_MqttsnSendOutputDataFn)(void* data, const unsigned char* buf, unsigned bufLen, bool broadcast); + +/// @brief Callback used to report gateway status. +/// @details The callback is set using +/// cc_mqttsn_client_set_gw_status_report_callback() function. +/// @param[in] data Pointer to user data object, passed as last parameter to +/// cc_mqttsn_client_set_gw_status_report_callback() function. +/// @param[in] gwId ID of the gateway. +/// @param[in] status Status of the gateway. +typedef void (*CC_MqttsnGwStatusReportFn)(void* data, unsigned char gwId, CC_MqttsnGwStatus status); + +/// @brief Callback used to report unsolicited disconnection of the gateway. +/// @param[in] data Pointer to user data object, passed as the last parameter to +/// the request call. +typedef void (*CC_MqttsnGwDisconnectReportFn)(void* data); + +/// @brief Callback used to report completion of the asynchronous operation. +/// @param[in] data Pointer to user data object, passed as the last parameter to +/// the request call. +/// @param[in] status Status of the asynchronous operation. +typedef void (*CC_MqttsnAsyncOpCompleteReportFn)(void* data, CC_MqttsnAsyncOpStatus status); + +/// @brief Callback used to report completion of the subscribe operation. +/// @param[in] data Pointer to user data object, passed as the last parameter to +/// the subscribe request. +/// @param[in] status Status of the subscribe operation. +/// @param[in] qos Maximal level of quality of service, the gateway/broker is going to use to publish incoming messages. +typedef void (*CC_MqttsnSubscribeCompleteReportFn)(void* data, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos); + +/// @brief Callback used to report incoming messages. +/// @details The callback is set using +/// cc_mqttsn_client_set_message_report_callback() function. The reported +/// data resides in internal data structures of the client library, and +/// it can be updated right after the callback function returns. +/// @param[in] data Pointer to user data object, passed as last parameter to +/// cc_mqttsn_client_set_message_report_callback() function. +/// @param[in] msgInfo Information about incoming message. +typedef void (*CC_MqttsnMessageReportFn)(void* data, const CC_MqttsnMessageInfo* msgInfo); + +#ifdef __cplusplus +} +#endif diff --git a/client/include/mqttsn/client/common.h b/client/include/mqttsn/client/common.h deleted file mode 100644 index 5e219186..00000000 --- a/client/include/mqttsn/client/common.h +++ /dev/null @@ -1,196 +0,0 @@ -// -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/// @file -/// @brief Common definition for MQTT-SN clients. - -#pragma once - -#ifdef __cplusplus -extern "C" { -#else - -#ifdef WIN32 -#ifndef bool -#define bool char -#endif - -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif - -#else // #ifdef WIN32 -#include -#endif // #ifdef WIN32 - -#endif // #ifdef __cplusplus - -/// @brief Major verion of the library -#define MQTTSN_CLIENT_MAJOR_VERSION 0U - -/// @brief Minor verion of the library -#define MQTTSN_CLIENT_MINOR_VERSION 13U - -/// @brief Patch level of the library -#define MQTTSN_CLIENT_PATCH_VERSION 4U - -/// @brief Macro to create numeric version as single unsigned number -#define MQTTSN_CLIENT_MAKE_VERSION(major_, minor_, patch_) \ - ((static_cast(major_) << 24) | \ - (static_cast(minor_) << 8) | \ - (static_cast(patch_))) - -/// @brief Version of the library as single numeric value -#define MQTTSN_CLIENT_VERSION MQTTSN_CLIENT_MAKE_VERSION(MQTTSN_CLIENT_MAJOR_VERSION, MQTTSN_CLIENT_MINOR_VERSION, MQTTSN_CLIENT_PATCH_VERSION) - -/// @brief Quality of Service -typedef enum -{ - MqttsnQoS_NoGwPublish = -1, ///< QoS=-1. No gateway publish, used by publish only clients. - MqttsnQoS_AtMostOnceDelivery, ///< QoS=0. At most once delivery. - MqttsnQoS_AtLeastOnceDelivery, ///< QoS=1. At least once delivery. - MqttsnQoS_ExactlyOnceDelivery ///< QoS=2. Exactly once delivery. -} MqttsnQoS; - -/// @brief Error code returned by various API functions. -typedef enum -{ - MqttsnErrorCode_Success, ///< The requested operation was successfully started. - MqttsnErrorCode_AlreadyStarted, ///< Returned by mqttsn_client_start() function if invoked twice. - MqttsnErrorCode_NotStarted, ///< Returned by various operations if issued prior to successful start using mqttsn_client_start(). - MqttsnErrorCode_Busy, ///< The client library is in the middle of previous operation, cannot start a new one. - MqttsnErrorCode_AlreadyConnected, ///< The client library is already connected to the gateway. Returned when mqttsn_client_connect() invoked second time. - MqttsnErrorCode_NotConnected, ///< The client library is not connected to the gateway. Returned by operations that require connection to the gateway. - MqttsnErrorCode_NotSleeping, ///< The client is not in ASLEEP mode. - MqttsnErrorCode_BadParam, ///< Bad parameter is passed to the function. -} MqttsnErrorCode; - -/// @brief Status of the gateway -typedef enum -{ - MqttsnGwStatus_Invalid, ///< Invalid value, should never be used - MqttsnGwStatus_Available, ///< The gateway is available. - MqttsnGwStatus_TimedOut, ///< The gateway hasn't advertised its presence in time, assumed disconnected. - MqttsnGwStatus_Discarded ///< The gateway info was discarded using mqttsn_client_discard_gw() or mqttsn_client_discard_all_gw(). -} MqttsnGwStatus; - -/// @brief Status of the asynchronous operation -typedef enum -{ - MqttsnAsyncOpStatus_Invalid, ///< Invalid value, should never be used - MqttsnAsyncOpStatus_Successful, ///< The operation was successful - MqttsnAsyncOpStatus_Congestion, ///< The gateway/broker was busy and could not handle the request, try again - MqttsnAsyncOpStatus_InvalidId, ///< Publish message used invalid topic ID. - MqttsnAsyncOpStatus_NotSupported, ///< The issued request is not supported by the gateway. - MqttsnAsyncOpStatus_NoResponse, ///< The gateway/broker didn't respond the the request - MqttsnAsyncOpStatus_Aborted, ///< The operation was cancelled using mqttsn_client_cancel() call. -} MqttsnAsyncOpStatus; - -/// @brief Handler used to access client specific data structures. -/// @details Returned by mqttsn_client_new() function. -typedef void* MqttsnClientHandle; - -/// @brief Type used to hold Topic ID value. -typedef unsigned short MqttsnTopicId; - -/// @brief Will Information -typedef struct -{ - const char* topic; ///< Topic of the will, can be NULL (means empty topic) - const unsigned char* msg; ///< Pointer to the buffer containing will binary message. - unsigned msgLen; ///< Length of the buffer containing will binary message. - MqttsnQoS qos; ///< QoS level of the will message. - bool retain; ///< Retain flag -} MqttsnWillInfo; - -/// @brief Incoming message information -typedef struct -{ - const char* topic; ///< Topic the message was published with. May be NULL if message is reported with predefined topic ID. - MqttsnTopicId topicId; ///< Predefined topic ID. This data member is used only if topic field has value NULL. - const unsigned char* msg; ///< Pointer to reported message binary data. - unsigned msgLen; ///< Number of bytes in reported message binary data. - MqttsnQoS qos; ///< QoS level the message was received with. - bool retain; ///< Retain flag of the message. -} MqttsnMessageInfo; - -/// @brief Callback used to request time measurement. -/// @details The callback is set using -/// mqttsn_client_set_next_tick_program_callback() function. -/// @param[in] data Pointer to user data object, passed as last parameter to -/// mqttsn_client_set_next_tick_program_callback() function. -/// @param[in] duration Time duration in @b milliseconds. After the requested -/// time expires, the mqttsn_client_tick() function is expected to be invoked. -typedef void (*MqttsnNextTickProgramFn)(void* data, unsigned duration); - -/// @brief Callback used to request termination of existing time measurement. -/// @details The callback is set using -/// mqttsn_client_set_cancel_next_tick_wait_callback() function. -/// @param[in] data Pointer to user data object, passed as last parameter to -/// mqttsn_client_set_cancel_next_tick_wait_callback() function. -/// @return Number of elapsed milliseconds since last time measurement request. -typedef unsigned (*MqttsnCancelNextTickWaitFn)(void* data); - -/// @brief Callback used to request to send data to the gateway. -/// @details The callback is set using -/// mqttsn_client_set_send_output_data_callback() function. The reported -/// data resides in internal data structures of the client library, and -/// it can be updated right after the callback function returns. It means -/// the data may need to be copied into some other buffer which will be -/// held intact until the send over I/O link operation is complete. -/// @param[in] data Pointer to user data object, passed as last parameter to -/// mqttsn_client_set_send_output_data_callback() function. -/// @param[in] buf Pointer to the buffer containing data to send -/// @param[in] bufLen Number of bytes to send -/// @param[in] broadcast Indication whether data needs to be broadcasted or -/// sent directly to the gateway. -typedef void (*MqttsnSendOutputDataFn)(void* data, const unsigned char* buf, unsigned bufLen, bool broadcast); - -/// @brief Callback used to report gateway status. -/// @details The callback is set using -/// mqttsn_client_set_gw_status_report_callback() function. -/// @param[in] data Pointer to user data object, passed as last parameter to -/// mqttsn_client_set_gw_status_report_callback() function. -/// @param[in] gwId ID of the gateway. -/// @param[in] status Status of the gateway. -typedef void (*MqttsnGwStatusReportFn)(void* data, unsigned char gwId, MqttsnGwStatus status); - -/// @brief Callback used to report unsolicited disconnection of the gateway. -/// @param[in] data Pointer to user data object, passed as the last parameter to -/// the request call. -typedef void (*MqttsnGwDisconnectReportFn)(void* data); - -/// @brief Callback used to report completion of the asynchronous operation. -/// @param[in] data Pointer to user data object, passed as the last parameter to -/// the request call. -/// @param[in] status Status of the asynchronous operation. -typedef void (*MqttsnAsyncOpCompleteReportFn)(void* data, MqttsnAsyncOpStatus status); - -/// @brief Callback used to report completion of the subscribe operation. -/// @param[in] data Pointer to user data object, passed as the last parameter to -/// the subscribe request. -/// @param[in] status Status of the subscribe operation. -/// @param[in] qos Maximal level of quality of service, the gateway/broker is going to use to publish incoming messages. -typedef void (*MqttsnSubscribeCompleteReportFn)(void* data, MqttsnAsyncOpStatus status, MqttsnQoS qos); - -/// @brief Callback used to report incoming messages. -/// @details The callback is set using -/// mqttsn_client_set_message_report_callback() function. The reported -/// data resides in internal data structures of the client library, and -/// it can be updated right after the callback function returns. -/// @param[in] data Pointer to user data object, passed as last parameter to -/// mqttsn_client_set_message_report_callback() function. -/// @param[in] msgInfo Information about incoming message. -typedef void (*MqttsnMessageReportFn)(void* data, const MqttsnMessageInfo* msgInfo); - -#ifdef __cplusplus -} -#endif diff --git a/client/src/app/CMakeLists.txt b/client/src/app/CMakeLists.txt index 4fdac939..c991e36c 100644 --- a/client/src/app/CMakeLists.txt +++ b/client/src/app/CMakeLists.txt @@ -1,4 +1,4 @@ -if (NOT CC_MQTTSN_CLIENT_DEFAULT_LIB) +if ((NOT CC_MQTTSN_CLIENT_DEFAULT_LIB) OR (NOT CC_MQTTSN_BUILD_CLIENT_APPS)) return () endif () diff --git a/client/src/app/pub/udp/CMakeLists.txt b/client/src/app/pub/udp/CMakeLists.txt index 36cc78b6..bd69bf1c 100644 --- a/client/src/app/pub/udp/CMakeLists.txt +++ b/client/src/app/pub/udp/CMakeLists.txt @@ -22,15 +22,12 @@ function (bin_pub_udp) Pub.h ) - #qt5_add_resources(resources ${CMAKE_CURRENT_SOURCE_DIR}/ui.qrc) - add_executable(${name} ${src} ${moc}) - target_link_libraries(${name} ${MQTTSN_CLIENT_LIB_NAME}) - qt5_use_modules(${name} Network Core) + target_link_libraries(${name} PRIVATE cc::${MQTTSN_CLIENT_LIB_NAME} Qt5::Network Qt5::Core) install ( TARGETS ${name} - DESTINATION ${BIN_INSTALL_DIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endfunction () diff --git a/client/src/app/pub/udp/Pub.cpp b/client/src/app/pub/udp/Pub.cpp index 0f00ea25..af6a10a5 100644 --- a/client/src/app/pub/udp/Pub.cpp +++ b/client/src/app/pub/udp/Pub.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,10 +16,7 @@ #include -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace app @@ -39,25 +36,25 @@ typedef std::vector DataBuf; } // namespace Pub::Pub() - : m_client(mqttsn_client_new()) + : m_client(cc_mqttsn_client_new()) { - mqttsn_client_set_next_tick_program_callback( - m_client.get(), &Pub::nextTickProgramCb, this); + cc_mqttsn_client_set_next_tick_program_callback( + m_client, &Pub::nextTickProgramCb, this); - mqttsn_client_set_cancel_next_tick_wait_callback( - m_client.get(), &Pub::caneclTickCb, this); + cc_mqttsn_client_set_cancel_next_tick_wait_callback( + m_client, &Pub::caneclTickCb, this); - mqttsn_client_set_send_output_data_callback( - m_client.get(), &Pub::sendDataCb, this); + cc_mqttsn_client_set_send_output_data_callback( + m_client, &Pub::sendDataCb, this); - mqttsn_client_set_gw_status_report_callback( - m_client.get(), &Pub::gwStatusReportCb, this); + cc_mqttsn_client_set_gw_status_report_callback( + m_client, &Pub::gwStatusReportCb, this); - mqttsn_client_set_gw_disconnect_report_callback( - m_client.get(), &Pub::gwDisconnectReportCb, this); + cc_mqttsn_client_set_gw_disconnect_report_callback( + m_client, &Pub::gwDisconnectReportCb, this); - mqttsn_client_set_message_report_callback( - m_client.get(), &Pub::messageReportCb, this); + cc_mqttsn_client_set_message_report_callback( + m_client, &Pub::messageReportCb, this); connect( @@ -74,19 +71,24 @@ Pub::Pub() } +Pub::~Pub() +{ + cc_mqttsn_client_free(m_client); +} + bool Pub::start() { bool result = bindLocalPort() && openSocket() && connectToGw() && - mqttsn_client_start(m_client.get()) == MqttsnErrorCode_Success; + cc_mqttsn_client_start(m_client) == CC_MqttsnErrorCode_Success; if (!result) { return false; } - if (m_qos == MqttsnQoS_NoGwPublish) { + if (m_qos == CC_MqttsnQoS_NoGwPublish) { doPublish(); return true; } @@ -101,7 +103,7 @@ bool Pub::start() void Pub::tick() { m_reqTimeout = 0; - mqttsn_client_tick(m_client.get()); + cc_mqttsn_client_tick(m_client); } void Pub::readFromSocket() @@ -126,7 +128,7 @@ void Pub::readFromSocket() std::cout << std::dec << std::endl; } - mqttsn_client_process_data(m_client.get(), &data[0], static_cast(data.size())); + cc_mqttsn_client_process_data(m_client, &data[0], static_cast(data.size())); } } @@ -197,9 +199,9 @@ void Pub::sendDataCb(void* obj, const unsigned char* buf, unsigned bufLen, bool reinterpret_cast(obj)->sendData(buf, bufLen, broadcast); } -void Pub::gwStatusReport(unsigned short gwId, MqttsnGwStatus status) +void Pub::gwStatusReport(unsigned short gwId, CC_MqttsnGwStatus status) { - if (status != MqttsnGwStatus_Available) { + if (status != CC_MqttsnGwStatus_Available) { return; } @@ -221,7 +223,7 @@ void Pub::gwStatusReport(unsigned short gwId, MqttsnGwStatus status) doConnect(); } -void Pub::gwStatusReportCb(void* obj, unsigned char gwId, MqttsnGwStatus status) +void Pub::gwStatusReportCb(void* obj, unsigned char gwId, CC_MqttsnGwStatus status) { assert(obj != nullptr); reinterpret_cast(obj)->gwStatusReport(gwId, status); @@ -244,7 +246,7 @@ void Pub::gwDisconnectReportCb(void* obj) reinterpret_cast(obj)->gwDisconnectReport(); } -void Pub::messageReportCb(void* obj, const MqttsnMessageInfo* msgInfo) +void Pub::messageReportCb(void* obj, const CC_MqttsnMessageInfo* msgInfo) { static_cast(obj); static_cast(msgInfo); @@ -258,15 +260,15 @@ void Pub::doConnect(bool reconnecting) } auto result = - mqttsn_client_connect( - m_client.get(), + cc_mqttsn_client_connect( + m_client, m_clientId.c_str(), m_keepAlive, cleanSession, nullptr, &Pub::connectCompleteCb, this); - if (result != MqttsnErrorCode_Success) { + if (result != CC_MqttsnErrorCode_Success) { std::cerr << "ERROR: Failed to connect to the gateway" << std::endl; } } @@ -275,8 +277,8 @@ void Pub::doPublish() { if (!m_topic.empty()) { auto result = - mqttsn_client_publish( - m_client.get(), + cc_mqttsn_client_publish( + m_client, m_topic.c_str(), m_msg.empty() ? nullptr : &m_msg[0], static_cast(m_msg.size()), @@ -284,7 +286,7 @@ void Pub::doPublish() m_retain, &Pub::publishCompleteCb, this); - if (result != MqttsnErrorCode_Success) { + if (result != CC_MqttsnErrorCode_Success) { std::cerr << "ERROR: Failed to initiate publish of topic " << m_topic << std::endl; quitApp(); } @@ -293,8 +295,8 @@ void Pub::doPublish() if (m_topicId != 0) { auto result = - mqttsn_client_publish_id( - m_client.get(), + cc_mqttsn_client_publish_id( + m_client, m_topicId, m_msg.empty() ? nullptr : &m_msg[0], static_cast(m_msg.size()), @@ -303,34 +305,34 @@ void Pub::doPublish() &Pub::publishCompleteCb, this); - if (result != MqttsnErrorCode_Success) { + if (result != CC_MqttsnErrorCode_Success) { std::cerr << "ERROR: Failed to initiate subscribe for topic ID " << m_topicId << std::endl; quitApp(); } return; } - if (m_qos == MqttsnQoS_NoGwPublish) { + if (m_qos == CC_MqttsnQoS_NoGwPublish) { quitApp(); return; } m_disconnecting = true; - mqttsn_client_disconnect(m_client.get(), &Pub::disconnectCompleteCb, this); + cc_mqttsn_client_disconnect(m_client, &Pub::disconnectCompleteCb, this); } -void Pub::connectComplete(MqttsnAsyncOpStatus status) +void Pub::connectComplete(CC_MqttsnAsyncOpStatus status) { - if (m_qos == MqttsnQoS_NoGwPublish) { + if (m_qos == CC_MqttsnQoS_NoGwPublish) { return; } - if (status == MqttsnAsyncOpStatus_Successful) { + if (status == CC_MqttsnAsyncOpStatus_Successful) { doPublish(); return; } - if (status == MqttsnAsyncOpStatus_Congestion) { + if (status == CC_MqttsnAsyncOpStatus_Congestion) { std::cerr << "WARNING: Congestion reported, reconnecting..." << std::endl; doConnect(); return; @@ -340,33 +342,33 @@ void Pub::connectComplete(MqttsnAsyncOpStatus status) quitApp(); } -void Pub::connectCompleteCb(void* obj, MqttsnAsyncOpStatus status) +void Pub::connectCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status) { assert(obj != nullptr); reinterpret_cast(obj)->connectComplete(status); } -void Pub::disconnectComplete(MqttsnAsyncOpStatus status) +void Pub::disconnectComplete(CC_MqttsnAsyncOpStatus status) { static_cast(status); quitApp(); } -void Pub::disconnectCompleteCb(void* obj, MqttsnAsyncOpStatus status) +void Pub::disconnectCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status) { assert(obj != nullptr); reinterpret_cast(obj)->disconnectComplete(status); } -void Pub::publishComplete(MqttsnAsyncOpStatus status) +void Pub::publishComplete(CC_MqttsnAsyncOpStatus status) { - if (status == MqttsnAsyncOpStatus_Congestion) { + if (status == CC_MqttsnAsyncOpStatus_Congestion) { std::cerr << "WARNING: Failed to publish due to congestion, retrying..." << std::endl; doPublish(); return; } - if (status != MqttsnAsyncOpStatus_Successful) { + if (status != CC_MqttsnAsyncOpStatus_Successful) { std::cerr << "WARNING: Failed to publish topic "; if (!m_topic.empty()) { std::cerr << m_topic; @@ -377,17 +379,17 @@ void Pub::publishComplete(MqttsnAsyncOpStatus status) std::cerr << std::endl; } - if (m_qos == MqttsnQoS_NoGwPublish) { + if (m_qos == CC_MqttsnQoS_NoGwPublish) { m_socket.flush(); quitApp(); return; } m_disconnecting = true; - mqttsn_client_disconnect(m_client.get(), &Pub::disconnectCompleteCb, this); + cc_mqttsn_client_disconnect(m_client, &Pub::disconnectCompleteCb, this); } -void Pub::publishCompleteCb(void* obj, MqttsnAsyncOpStatus status) +void Pub::publishCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status) { assert(obj != nullptr); reinterpret_cast(obj)->publishComplete(status); @@ -435,7 +437,7 @@ bool Pub::connectToGw() assert(m_socket.isOpen()); assert(m_socket.state() == QUdpSocket::ConnectedState); - mqttsn_client_set_searchgw_enabled(m_client.get(), false); + cc_mqttsn_client_set_searchgw_enabled(m_client, false); return true; } @@ -494,8 +496,6 @@ void Pub::quitApp() } // namespace app -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/app/pub/udp/Pub.h b/client/src/app/pub/udp/Pub.h index c6d0e5be..c472679a 100644 --- a/client/src/app/pub/udp/Pub.h +++ b/client/src/app/pub/udp/Pub.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,10 +19,7 @@ #include "client.h" -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace app @@ -39,6 +36,7 @@ class Pub : public QObject Q_OBJECT public: Pub(); + ~Pub(); void setGwAddr(const QString& value) { @@ -85,7 +83,7 @@ class Pub : public QObject m_topicId = topicId; } - void setQos(MqttsnQoS value) + void setQos(CC_MqttsnQoS value) { m_qos = value; } @@ -114,19 +112,6 @@ private slots: void socketErrorOccurred(QAbstractSocket::SocketError err); private: - struct ClientDeleter - { - void operator()(MqttsnClientHandle client) - { - mqttsn_client_free(client); - } - }; - - typedef std::unique_ptr< - typename std::remove_pointer::type, - ClientDeleter - > ClientPtr; - void nextTickProgram(unsigned ms); static void nextTickProgramCb(void* obj, unsigned ms); @@ -136,22 +121,22 @@ private slots: void sendData(const unsigned char* buf, unsigned bufLen, bool broadcast); static void sendDataCb(void* obj, const unsigned char* buf, unsigned bufLen, bool broadcast); - void gwStatusReport(unsigned short gwId, MqttsnGwStatus status); - static void gwStatusReportCb(void* obj, unsigned char gwId, MqttsnGwStatus status); + void gwStatusReport(unsigned short gwId, CC_MqttsnGwStatus status); + static void gwStatusReportCb(void* obj, unsigned char gwId, CC_MqttsnGwStatus status); void gwDisconnectReport(); static void gwDisconnectReportCb(void* obj); - static void messageReportCb(void* obj, const MqttsnMessageInfo* msgInfo); + static void messageReportCb(void* obj, const CC_MqttsnMessageInfo* msgInfo); void doConnect(bool reconnecting = false); void doPublish(); - void connectComplete(MqttsnAsyncOpStatus status); - static void connectCompleteCb(void* obj, MqttsnAsyncOpStatus status); - void disconnectComplete(MqttsnAsyncOpStatus status); - static void disconnectCompleteCb(void* obj, MqttsnAsyncOpStatus status); - void publishComplete(MqttsnAsyncOpStatus status); - static void publishCompleteCb(void* obj, MqttsnAsyncOpStatus status); + void connectComplete(CC_MqttsnAsyncOpStatus status); + static void connectCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status); + void disconnectComplete(CC_MqttsnAsyncOpStatus status); + static void disconnectCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status); + void publishComplete(CC_MqttsnAsyncOpStatus status); + static void publishCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status); bool bindLocalPort(); bool openSocket(); bool connectToGw(); @@ -159,7 +144,7 @@ private slots: void sendDataConnected(const unsigned char* buf, unsigned bufLen); static void quitApp(); - ClientPtr m_client; + CC_MqttsnClientHandle m_client; QTimer m_timer; unsigned m_reqTimeout = 0; QString m_gwAddr; @@ -175,7 +160,7 @@ private slots: bool m_retain = false; std::string m_topic; std::uint16_t m_topicId; - MqttsnQoS m_qos = MqttsnQoS_AtMostOnceDelivery; + CC_MqttsnQoS m_qos = CC_MqttsnQoS_AtMostOnceDelivery; DataBuf m_msg; bool m_debug = false; bool m_disconnecting = false; @@ -187,8 +172,6 @@ private slots: } // namespace app -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/app/pub/udp/main.cpp b/client/src/app/pub/udp/main.cpp index f06d67db..f3dcb91d 100644 --- a/client/src/app/pub/udp/main.cpp +++ b/client/src/app/pub/udp/main.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -291,7 +291,7 @@ std::uint16_t getTopicId(const QCommandLineParser& parser) return topicId; } -MqttsnQoS getQos(const QCommandLineParser& parser) +CC_MqttsnQoS getQos(const QCommandLineParser& parser) { auto value = DefaultQos; do { @@ -308,7 +308,7 @@ MqttsnQoS getQos(const QCommandLineParser& parser) value = std::max(-1, std::min(2, valueTmp)); } while (false); - return static_cast(value); + return static_cast(value); } std::vector getMessage(const QCommandLineParser& parser) @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) unsigned short port = getLocalPort(parser, gwAddr); auto keepAlive = getKeepAlive(parser); - mqttsn::client::app::sub::udp::Pub pub; + cc_mqttsn_client::app::sub::udp::Pub pub; pub.setGwAddr(gwAddr); pub.setGwPort(gwPort); diff --git a/client/src/app/sub/udp/CMakeLists.txt b/client/src/app/sub/udp/CMakeLists.txt index 896eff37..d9ee6fd9 100644 --- a/client/src/app/sub/udp/CMakeLists.txt +++ b/client/src/app/sub/udp/CMakeLists.txt @@ -22,15 +22,12 @@ function (bin_sub_udp) Sub.h ) - #qt5_add_resources(resources ${CMAKE_CURRENT_SOURCE_DIR}/ui.qrc) - add_executable(${name} ${src} ${moc}) - target_link_libraries(${name} ${MQTTSN_CLIENT_LIB_NAME}) - qt5_use_modules(${name} Network Core) + target_link_libraries(${name} PRIVATE cc::${MQTTSN_CLIENT_LIB_NAME} Qt5::Network Qt5::Core) install ( TARGETS ${name} - DESTINATION ${BIN_INSTALL_DIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endfunction () diff --git a/client/src/app/sub/udp/Sub.cpp b/client/src/app/sub/udp/Sub.cpp index 3929721a..b7007a6f 100644 --- a/client/src/app/sub/udp/Sub.cpp +++ b/client/src/app/sub/udp/Sub.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -17,10 +17,7 @@ #include #include -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace app @@ -40,25 +37,25 @@ typedef std::vector DataBuf; } // namespace Sub::Sub() - : m_client(mqttsn_client_new()) + : m_client(cc_mqttsn_client_new()) { - mqttsn_client_set_next_tick_program_callback( - m_client.get(), &Sub::nextTickProgramCb, this); + cc_mqttsn_client_set_next_tick_program_callback( + m_client, &Sub::nextTickProgramCb, this); - mqttsn_client_set_cancel_next_tick_wait_callback( - m_client.get(), &Sub::caneclTickCb, this); + cc_mqttsn_client_set_cancel_next_tick_wait_callback( + m_client, &Sub::caneclTickCb, this); - mqttsn_client_set_send_output_data_callback( - m_client.get(), &Sub::sendDataCb, this); + cc_mqttsn_client_set_send_output_data_callback( + m_client, &Sub::sendDataCb, this); - mqttsn_client_set_gw_status_report_callback( - m_client.get(), &Sub::gwStatusReportCb, this); + cc_mqttsn_client_set_gw_status_report_callback( + m_client, &Sub::gwStatusReportCb, this); - mqttsn_client_set_gw_disconnect_report_callback( - m_client.get(), &Sub::gwDisconnectReportCb, this); + cc_mqttsn_client_set_gw_disconnect_report_callback( + m_client, &Sub::gwDisconnectReportCb, this); - mqttsn_client_set_message_report_callback( - m_client.get(), &Sub::messageReportCb, this); + cc_mqttsn_client_set_message_report_callback( + m_client, &Sub::messageReportCb, this); connect( @@ -75,13 +72,18 @@ Sub::Sub() } +Sub::~Sub() +{ + cc_mqttsn_client_free(m_client); +} + bool Sub::start() { bool result = bindLocalPort() && openSocket() && connectToGw() && - mqttsn_client_start(m_client.get()) == MqttsnErrorCode_Success; + cc_mqttsn_client_start(m_client) == CC_MqttsnErrorCode_Success; if (result && (m_socket.state() == QUdpSocket::ConnectedState)) { @@ -93,7 +95,7 @@ bool Sub::start() void Sub::tick() { m_reqTimeout = 0; - mqttsn_client_tick(m_client.get()); + cc_mqttsn_client_tick(m_client); } void Sub::readFromSocket() @@ -114,7 +116,7 @@ void Sub::readFromSocket() // std::copy_n(&data[0], data.size(), std::ostream_iterator(std::cout, " ")); // std::cout << std::dec << std::endl; - mqttsn_client_process_data(m_client.get(), &data[0], static_cast(data.size())); + cc_mqttsn_client_process_data(m_client, &data[0], static_cast(data.size())); } } @@ -181,9 +183,9 @@ void Sub::sendDataCb(void* obj, const unsigned char* buf, unsigned bufLen, bool reinterpret_cast(obj)->sendData(buf, bufLen, broadcast); } -void Sub::gwStatusReport(unsigned short gwId, MqttsnGwStatus status) +void Sub::gwStatusReport(unsigned short gwId, CC_MqttsnGwStatus status) { - if (status != MqttsnGwStatus_Available) { + if (status != CC_MqttsnGwStatus_Available) { return; } @@ -205,7 +207,7 @@ void Sub::gwStatusReport(unsigned short gwId, MqttsnGwStatus status) doConnect(); } -void Sub::gwStatusReportCb(void* obj, unsigned char gwId, MqttsnGwStatus status) +void Sub::gwStatusReportCb(void* obj, unsigned char gwId, CC_MqttsnGwStatus status) { assert(obj != nullptr); reinterpret_cast(obj)->gwStatusReport(gwId, status); @@ -223,7 +225,7 @@ void Sub::gwDisconnectReportCb(void* obj) reinterpret_cast(obj)->gwDisconnectReport(); } -void Sub::messageReport(const MqttsnMessageInfo* msgInfo) +void Sub::messageReport(const CC_MqttsnMessageInfo* msgInfo) { assert(msgInfo != nullptr); if (msgInfo->retain && m_noRetain) { @@ -260,7 +262,7 @@ void Sub::messageReport(const MqttsnMessageInfo* msgInfo) std::cout << std::dec << std::endl; } -void Sub::messageReportCb(void* obj, const MqttsnMessageInfo* msgInfo) +void Sub::messageReportCb(void* obj, const CC_MqttsnMessageInfo* msgInfo) { assert(obj != nullptr); reinterpret_cast(obj)->messageReport(msgInfo); @@ -274,15 +276,15 @@ void Sub::doConnect(bool reconnecting) } auto result = - mqttsn_client_connect( - m_client.get(), + cc_mqttsn_client_connect( + m_client, m_clientId.c_str(), m_keepAlive, cleanSession, nullptr, &Sub::connectCompleteCb, this); - if (result != MqttsnErrorCode_Success) { + if (result != CC_MqttsnErrorCode_Success) { std::cerr << "ERROR: Failed to connect to the gateway" << std::endl; } } @@ -291,13 +293,13 @@ void Sub::doSubscribe() { if (!m_topics.empty()) { auto result = - mqttsn_client_subscribe( - m_client.get(), + cc_mqttsn_client_subscribe( + m_client, m_topics.front().c_str(), m_qos, &Sub::subscribeCompleteCb, this); - if (result != MqttsnErrorCode_Success) { + if (result != CC_MqttsnErrorCode_Success) { std::cerr << "ERROR: Failed to initiate subscribe for topic " << m_topics.front() << std::endl; m_topics.pop_front(); doSubscribe(); @@ -307,14 +309,14 @@ void Sub::doSubscribe() if (!m_topicIds.empty()) { auto result = - mqttsn_client_subscribe_id( - m_client.get(), + cc_mqttsn_client_subscribe_id( + m_client, m_topicIds.front(), m_qos, &Sub::subscribeCompleteCb, this); - if (result != MqttsnErrorCode_Success) { + if (result != CC_MqttsnErrorCode_Success) { std::cerr << "ERROR: Failed to initiate subscribe for topic ID " << m_topicIds.front() << std::endl; m_topicIds.pop_front(); doSubscribe(); @@ -323,14 +325,14 @@ void Sub::doSubscribe() } } -void Sub::connectComplete(MqttsnAsyncOpStatus status) +void Sub::connectComplete(CC_MqttsnAsyncOpStatus status) { - if (status == MqttsnAsyncOpStatus_Successful) { + if (status == CC_MqttsnAsyncOpStatus_Successful) { doSubscribe(); return; } - if (status == MqttsnAsyncOpStatus_Congestion) { + if (status == CC_MqttsnAsyncOpStatus_Congestion) { std::cerr << "WARNING: Congestion reported, reconnecting..." << std::endl; doConnect(); return; @@ -340,22 +342,22 @@ void Sub::connectComplete(MqttsnAsyncOpStatus status) QTimer::singleShot(10, qApp, SLOT(quit())); } -void Sub::connectCompleteCb(void* obj, MqttsnAsyncOpStatus status) +void Sub::connectCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status) { assert(obj != nullptr); reinterpret_cast(obj)->connectComplete(status); } -void Sub::subscribeComplete(MqttsnAsyncOpStatus status) +void Sub::subscribeComplete(CC_MqttsnAsyncOpStatus status) { - if (status == MqttsnAsyncOpStatus_Congestion) { + if (status == CC_MqttsnAsyncOpStatus_Congestion) { std::cerr << "WARNING: Failed to subscribe due to congestion, retrying..." << std::endl; doSubscribe(); return; } - if (status != MqttsnAsyncOpStatus_Successful) { + if (status != CC_MqttsnAsyncOpStatus_Successful) { std::cerr << "WARNING: Failed to subscribe to topic "; if (!m_topics.empty()) { std::cerr << m_topics.front(); @@ -376,7 +378,7 @@ void Sub::subscribeComplete(MqttsnAsyncOpStatus status) doSubscribe(); } -void Sub::subscribeCompleteCb(void* obj, MqttsnAsyncOpStatus status, MqttsnQoS qos) +void Sub::subscribeCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos) { static_cast(qos); assert(obj != nullptr); @@ -425,7 +427,7 @@ bool Sub::connectToGw() assert(m_socket.isOpen()); assert(m_socket.state() == QUdpSocket::ConnectedState); - mqttsn_client_set_searchgw_enabled(m_client.get(), false); + cc_mqttsn_client_set_searchgw_enabled(m_client, false); return true; } @@ -480,8 +482,6 @@ void Sub::sendDataConnected(const unsigned char* buf, unsigned bufLen) } // namespace app -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/app/sub/udp/Sub.h b/client/src/app/sub/udp/Sub.h index f82e9019..50ddad05 100644 --- a/client/src/app/sub/udp/Sub.h +++ b/client/src/app/sub/udp/Sub.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,10 +20,7 @@ #include "client.h" -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace app @@ -40,6 +37,7 @@ class Sub : public QObject Q_OBJECT public: Sub(); + ~Sub(); void setGwAddr(const QString& value) { @@ -88,7 +86,7 @@ class Sub : public QObject m_topicIds = topicIds; } - void setQos(MqttsnQoS value) + void setQos(CC_MqttsnQoS value) { m_qos = value; } @@ -116,19 +114,6 @@ private slots: void socketErrorOccurred(QAbstractSocket::SocketError err); private: - struct ClientDeleter - { - void operator()(MqttsnClientHandle client) - { - mqttsn_client_free(client); - } - }; - - typedef std::unique_ptr< - typename std::remove_pointer::type, - ClientDeleter - > ClientPtr; - void nextTickProgram(unsigned ms); static void nextTickProgramCb(void* obj, unsigned ms); @@ -138,28 +123,28 @@ private slots: void sendData(const unsigned char* buf, unsigned bufLen, bool broadcast); static void sendDataCb(void* obj, const unsigned char* buf, unsigned bufLen, bool broadcast); - void gwStatusReport(unsigned short gwId, MqttsnGwStatus status); - static void gwStatusReportCb(void* obj, unsigned char gwId, MqttsnGwStatus status); + void gwStatusReport(unsigned short gwId, CC_MqttsnGwStatus status); + static void gwStatusReportCb(void* obj, unsigned char gwId, CC_MqttsnGwStatus status); void gwDisconnectReport(); static void gwDisconnectReportCb(void* obj); - void messageReport(const MqttsnMessageInfo* msgInfo); - static void messageReportCb(void* obj, const MqttsnMessageInfo* msgInfo); + void messageReport(const CC_MqttsnMessageInfo* msgInfo); + static void messageReportCb(void* obj, const CC_MqttsnMessageInfo* msgInfo); void doConnect(bool reconnecting = false); void doSubscribe(); - void connectComplete(MqttsnAsyncOpStatus status); - static void connectCompleteCb(void* obj, MqttsnAsyncOpStatus status); - void subscribeComplete(MqttsnAsyncOpStatus status); - static void subscribeCompleteCb(void* obj, MqttsnAsyncOpStatus status, MqttsnQoS qos); + void connectComplete(CC_MqttsnAsyncOpStatus status); + static void connectCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status); + void subscribeComplete(CC_MqttsnAsyncOpStatus status); + static void subscribeCompleteCb(void* obj, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos); bool bindLocalPort(); bool openSocket(); bool connectToGw(); void broadcastData(const unsigned char* buf, unsigned bufLen); void sendDataConnected(const unsigned char* buf, unsigned bufLen); - ClientPtr m_client; + CC_MqttsnClientHandle m_client; QTimer m_timer; unsigned m_reqTimeout = 0; QString m_gwAddr; @@ -177,7 +162,7 @@ private slots: bool m_hexOutput = false; TopicsList m_topics; TopicIdsList m_topicIds; - MqttsnQoS m_qos = MqttsnQoS_ExactlyOnceDelivery; + CC_MqttsnQoS m_qos = CC_MqttsnQoS_ExactlyOnceDelivery; }; } // namespace udp @@ -186,8 +171,6 @@ private slots: } // namespace app -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/app/sub/udp/main.cpp b/client/src/app/sub/udp/main.cpp index 41f3f180..3e4549e3 100644 --- a/client/src/app/sub/udp/main.cpp +++ b/client/src/app/sub/udp/main.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -271,7 +271,7 @@ unsigned short getKeepAlive(const QCommandLineParser& parser) return keepAlive; } -mqttsn::client::app::sub::udp::Sub::TopicsList getTopics(const QCommandLineParser& parser) +cc_mqttsn_client::app::sub::udp::Sub::TopicsList getTopics(const QCommandLineParser& parser) { auto topicStrings = parser.values(TopicOpt); std::vector topics; @@ -287,10 +287,10 @@ mqttsn::client::app::sub::udp::Sub::TopicsList getTopics(const QCommandLineParse topics.erase( std::unique(topics.begin(), topics.end()), topics.end()); - return mqttsn::client::app::sub::udp::Sub::TopicsList(topics.begin(), topics.end()); + return cc_mqttsn_client::app::sub::udp::Sub::TopicsList(topics.begin(), topics.end()); } -mqttsn::client::app::sub::udp::Sub::TopicIdsList getTopicIds(const QCommandLineParser& parser) +cc_mqttsn_client::app::sub::udp::Sub::TopicIdsList getTopicIds(const QCommandLineParser& parser) { auto topicStrings = parser.values(TopicIdOpt); std::vector topics; @@ -316,10 +316,10 @@ mqttsn::client::app::sub::udp::Sub::TopicIdsList getTopicIds(const QCommandLineP std::unique(topics.begin(), topics.end()), topics.end()); - return mqttsn::client::app::sub::udp::Sub::TopicIdsList(topics.begin(), topics.end()); + return cc_mqttsn_client::app::sub::udp::Sub::TopicIdsList(topics.begin(), topics.end()); } -MqttsnQoS getQos(const QCommandLineParser& parser) +CC_MqttsnQoS getQos(const QCommandLineParser& parser) { auto value = DefaultQos; do { @@ -336,7 +336,7 @@ MqttsnQoS getQos(const QCommandLineParser& parser) value = std::min(value, valueTmp); } while (false); - return static_cast(value); + return static_cast(value); } @@ -356,7 +356,7 @@ int main(int argc, char *argv[]) unsigned short port = getLocalPort(parser, gwAddr); auto keepAlive = getKeepAlive(parser); - mqttsn::client::app::sub::udp::Sub sub; + cc_mqttsn_client::app::sub::udp::Sub sub; sub.setGwAddr(gwAddr); sub.setGwPort(gwPort); diff --git a/client/src/basic/BasicClient.h b/client/src/basic/BasicClient.h index 82045ea3..193f1999 100644 --- a/client/src/basic/BasicClient.h +++ b/client/src/basic/BasicClient.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,19 +16,16 @@ #include "comms/comms.h" #include "comms/util/ScopeGuard.h" -#include "mqttsn/client/common.h" -#include "mqttsn/Message.h" -#include "mqttsn/frame/Frame.h" -#include "mqttsn/input/ClientInputMessages.h" -#include "mqttsn/options/ClientDefaultOptions.h" +#include "cc_mqttsn/Message.h" +#include "cc_mqttsn/frame/Frame.h" +#include "cc_mqttsn/input/ClientInputMessages.h" +#include "cc_mqttsn/options/ClientDefaultOptions.h" +#include "cc_mqttsn_client/common.h" #include "details/WriteBufStorageType.h" //#include -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace details @@ -139,35 +136,35 @@ using ClientIdStorageOptT = //----------------------------------------------------------- -mqttsn::field::QosVal translateQosValue(MqttsnQoS val) +cc_mqttsn::field::QosVal translateQosValue(CC_MqttsnQoS val) { static_assert( - static_cast(mqttsn::field::QosVal::AtMostOnceDelivery) == MqttsnQoS_AtMostOnceDelivery, + static_cast(cc_mqttsn::field::QosVal::AtMostOnceDelivery) == CC_MqttsnQoS_AtMostOnceDelivery, "Invalid mapping"); static_assert( - static_cast(mqttsn::field::QosVal::AtLeastOnceDelivery) == MqttsnQoS_AtLeastOnceDelivery, + static_cast(cc_mqttsn::field::QosVal::AtLeastOnceDelivery) == CC_MqttsnQoS_AtLeastOnceDelivery, "Invalid mapping"); static_assert( - static_cast(mqttsn::field::QosVal::ExactlyOnceDelivery) == MqttsnQoS_ExactlyOnceDelivery, + static_cast(cc_mqttsn::field::QosVal::ExactlyOnceDelivery) == CC_MqttsnQoS_ExactlyOnceDelivery, "Invalid mapping"); - if (val == MqttsnQoS_NoGwPublish) { - return mqttsn::field::QosVal::NoGwPublish; + if (val == CC_MqttsnQoS_NoGwPublish) { + return cc_mqttsn::field::QosVal::NoGwPublish; } - return static_cast(val); + return static_cast(val); } -MqttsnQoS translateQosValue(mqttsn::field::QosVal val) +CC_MqttsnQoS translateQosValue(cc_mqttsn::field::QosVal val) { - if (val == mqttsn::field::QosVal::NoGwPublish) { - return MqttsnQoS_NoGwPublish; + if (val == cc_mqttsn::field::QosVal::NoGwPublish) { + return CC_MqttsnQoS_NoGwPublish; } - return static_cast(val); + return static_cast(val); } } // namespace details @@ -177,7 +174,7 @@ class BasicClient { typedef details::WriteBufStorageTypeT WriteBufStorage; - typedef mqttsn::Message< + typedef cc_mqttsn::Message< comms::option::IdInfoInterface, comms::option::ReadIterator, comms::option::WriteIterator, @@ -213,14 +210,14 @@ class BasicClient struct AsyncOpBase : public OpBase { - MqttsnAsyncOpCompleteReportFn m_cb = nullptr; + CC_MqttsnAsyncOpCompleteReportFn m_cb = nullptr; void* m_cbData = nullptr; }; struct ConnectOp : public AsyncOpBase { - MqttsnWillInfo m_willInfo = MqttsnWillInfo(); + CC_MqttsnWillInfo m_willInfo = CC_MqttsnWillInfo(); const char* m_clientId = nullptr; std::uint16_t m_keepAlivePeriod = 0; bool m_hasWill = false; @@ -233,11 +230,11 @@ class BasicClient struct PublishOpBase : public AsyncOpBase { - MqttsnTopicId m_topicId = 0U; + CC_MqttsnTopicId m_topicId = 0U; std::uint16_t m_msgId = 0U; const std::uint8_t* m_msg = nullptr; std::size_t m_msgLen = 0; - MqttsnQoS m_qos = MqttsnQoS_AtMostOnceDelivery; + CC_MqttsnQoS m_qos = CC_MqttsnQoS_AtMostOnceDelivery; bool m_retain = false; bool m_ackReceived = false; }; @@ -256,11 +253,11 @@ class BasicClient struct SubscribeOpBase : public OpBase { - MqttsnQoS m_qos = MqttsnQoS_AtMostOnceDelivery; - MqttsnSubscribeCompleteReportFn m_cb = nullptr; + CC_MqttsnQoS m_qos = CC_MqttsnQoS_AtMostOnceDelivery; + CC_MqttsnSubscribeCompleteReportFn m_cb = nullptr; void* m_cbData = nullptr; std::uint16_t m_msgId = 0U; - MqttsnTopicId m_topicId = 0U; + CC_MqttsnTopicId m_topicId = 0U; }; struct SubscribeIdOp : public SubscribeOpBase @@ -276,7 +273,7 @@ class BasicClient struct UnsubscribeOpBase : public AsyncOpBase { std::uint16_t m_msgId = 0U; - MqttsnTopicId m_topicId = 0U; + CC_MqttsnTopicId m_topicId = 0U; }; struct UnsubscribeIdOp : public UnsubscribeOpBase @@ -292,7 +289,7 @@ class BasicClient struct WillTopicUpdateOp : public AsyncOpBase { const char* m_topic = nullptr; - MqttsnQoS m_qos; + CC_MqttsnQoS m_qos; bool m_retain; }; @@ -316,19 +313,19 @@ class BasicClient Asleep }; - typedef void (BasicClient::*FinaliseFunc)(MqttsnAsyncOpStatus); + typedef void (BasicClient::*FinaliseFunc)(CC_MqttsnAsyncOpStatus); - using TopicIdTypeVal = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; - using ReturnCodeVal = mqttsn::field::ReturnCodeVal; + using TopicIdTypeVal = cc_mqttsn::field::TopicIdTypeVal; + using ReturnCodeVal = cc_mqttsn::field::ReturnCodeVal; // struct NoOrigDataViewProtOpts : TProtOpts // { // static const bool HasOrigDataView = false; // }; - class ProtOpts : public mqttsn::options::ClientDefaultOptions + class ProtOpts : public cc_mqttsn::options::ClientDefaultOptions { - using Base = mqttsn::options::ClientDefaultOptions; + using Base = cc_mqttsn::options::ClientDefaultOptions; public: @@ -352,9 +349,9 @@ class BasicClient }; // struct frame }; - class StorageOptions : public mqttsn::options::ClientDefaultOptions + class StorageOptions : public cc_mqttsn::options::ClientDefaultOptions { - using Base = mqttsn::options::ClientDefaultOptions; + using Base = cc_mqttsn::options::ClientDefaultOptions; public: struct field : public Base::field { @@ -368,11 +365,11 @@ class BasicClient public: typedef typename Message::Field FieldBase; - typedef typename mqttsn::field::GwId::ValueType GwIdValueType; - typedef typename mqttsn::field::TopicName::ValueType TopicNameType; - typedef typename mqttsn::field::Data::ValueType DataType; - typedef typename mqttsn::field::TopicId::ValueType TopicIdType; - typedef typename mqttsn::field::ClientId::ValueType ClientIdType; + typedef typename cc_mqttsn::field::GwId::ValueType GwIdValueType; + typedef typename cc_mqttsn::field::TopicName::ValueType TopicNameType; + typedef typename cc_mqttsn::field::Data::ValueType DataType; + typedef typename cc_mqttsn::field::TopicId::ValueType TopicIdType; + typedef typename cc_mqttsn::field::ClientId::ValueType ClientIdType; struct GwInfo { @@ -386,33 +383,33 @@ class BasicClient typedef details::GwInfoStorageTypeT GwInfoStorage; - typedef mqttsn::message::Advertise AdvertiseMsg; - typedef mqttsn::message::Searchgw SearchgwMsg; - typedef mqttsn::message::Gwinfo GwinfoMsg; - typedef mqttsn::message::Connect ConnectMsg; - typedef mqttsn::message::Connack ConnackMsg; - typedef mqttsn::message::Willtopicreq WilltopicreqMsg; - typedef mqttsn::message::Willtopic WilltopicMsg; - typedef mqttsn::message::Willmsgreq WillmsgreqMsg; - typedef mqttsn::message::Willmsg WillmsgMsg; - typedef mqttsn::message::Register RegisterMsg; - typedef mqttsn::message::Regack RegackMsg; - typedef mqttsn::message::Publish PublishMsg; - typedef mqttsn::message::Puback PubackMsg; - typedef mqttsn::message::Pubrec PubrecMsg; - typedef mqttsn::message::Pubrel PubrelMsg; - typedef mqttsn::message::Pubcomp PubcompMsg; - typedef mqttsn::message::Subscribe SubscribeMsg; - typedef mqttsn::message::Suback SubackMsg; - typedef mqttsn::message::Unsubscribe UnsubscribeMsg; - typedef mqttsn::message::Unsuback UnsubackMsg; - typedef mqttsn::message::Pingreq PingreqMsg; - typedef mqttsn::message::Pingresp PingrespMsg; - typedef mqttsn::message::Disconnect DisconnectMsg; - typedef mqttsn::message::Willtopicupd WilltopicupdMsg; - typedef mqttsn::message::Willtopicresp WilltopicrespMsg; - typedef mqttsn::message::Willmsgupd WillmsgupdMsg; - typedef mqttsn::message::Willmsgresp WillmsgrespMsg; + typedef cc_mqttsn::message::Advertise AdvertiseMsg; + typedef cc_mqttsn::message::Searchgw SearchgwMsg; + typedef cc_mqttsn::message::Gwinfo GwinfoMsg; + typedef cc_mqttsn::message::Connect ConnectMsg; + typedef cc_mqttsn::message::Connack ConnackMsg; + typedef cc_mqttsn::message::Willtopicreq WilltopicreqMsg; + typedef cc_mqttsn::message::Willtopic WilltopicMsg; + typedef cc_mqttsn::message::Willmsgreq WillmsgreqMsg; + typedef cc_mqttsn::message::Willmsg WillmsgMsg; + typedef cc_mqttsn::message::Register RegisterMsg; + typedef cc_mqttsn::message::Regack RegackMsg; + typedef cc_mqttsn::message::Publish PublishMsg; + typedef cc_mqttsn::message::Puback PubackMsg; + typedef cc_mqttsn::message::Pubrec PubrecMsg; + typedef cc_mqttsn::message::Pubrel PubrelMsg; + typedef cc_mqttsn::message::Pubcomp PubcompMsg; + typedef cc_mqttsn::message::Subscribe SubscribeMsg; + typedef cc_mqttsn::message::Suback SubackMsg; + typedef cc_mqttsn::message::Unsubscribe UnsubscribeMsg; + typedef cc_mqttsn::message::Unsuback UnsubackMsg; + typedef cc_mqttsn::message::Pingreq PingreqMsg; + typedef cc_mqttsn::message::Pingresp PingrespMsg; + typedef cc_mqttsn::message::Disconnect DisconnectMsg; + typedef cc_mqttsn::message::Willtopicupd WilltopicupdMsg; + typedef cc_mqttsn::message::Willtopicresp WilltopicrespMsg; + typedef cc_mqttsn::message::Willmsgupd WillmsgupdMsg; + typedef cc_mqttsn::message::Willmsgresp WillmsgrespMsg; BasicClient() = default; ~BasicClient() noexcept = default; @@ -441,7 +438,7 @@ class BasicClient m_broadcastRadius = val; } - void setNextTickProgramCallback(MqttsnNextTickProgramFn cb, void* data) + void setNextTickProgramCallback(CC_MqttsnNextTickProgramFn cb, void* data) { if (cb != nullptr) { m_nextTickProgramFn = cb; @@ -449,7 +446,7 @@ class BasicClient } } - void setCancelNextTickWaitCallback(MqttsnCancelNextTickWaitFn cb, void* data) + void setCancelNextTickWaitCallback(CC_MqttsnCancelNextTickWaitFn cb, void* data) { if (cb != nullptr) { m_cancelNextTickWaitFn = cb; @@ -457,7 +454,7 @@ class BasicClient } } - void setSendOutputDataCallback(MqttsnSendOutputDataFn cb, void* data) + void setSendOutputDataCallback(CC_MqttsnSendOutputDataFn cb, void* data) { if (cb != nullptr) { m_sendOutputDataFn = cb; @@ -465,19 +462,19 @@ class BasicClient } } - void setGwStatusReportCallback(MqttsnGwStatusReportFn cb, void* data) + void setGwStatusReportCallback(CC_MqttsnGwStatusReportFn cb, void* data) { m_gwStatusReportFn = cb; m_gwStatusReportData = data; } - void setGwDisconnectReportCallback(MqttsnGwDisconnectReportFn cb, void* data) + void setGwDisconnectReportCallback(CC_MqttsnGwDisconnectReportFn cb, void* data) { m_gwDisconnectReportFn = cb; m_gwDisconnectReportData = data; } - void setMessageReportCallback(MqttsnMessageReportFn cb, void* data) + void setMessageReportCallback(CC_MqttsnMessageReportFn cb, void* data) { m_msgReportFn = cb; m_msgReportData = data; @@ -509,7 +506,7 @@ class BasicClient } m_gwInfos.erase(iter); - reportGwStatus(gwId, MqttsnGwStatus_Discarded); + reportGwStatus(gwId, CC_MqttsnGwStatus_Discarded); } void discardAllGw() @@ -533,21 +530,21 @@ class BasicClient m_gwInfos.clear(); for (auto gwId : ids) { - reportGwStatus(gwId, MqttsnGwStatus_Discarded); + reportGwStatus(gwId, CC_MqttsnGwStatus_Discarded); } } - MqttsnErrorCode start() + CC_MqttsnErrorCode start() { if (m_running) { - return MqttsnErrorCode_AlreadyStarted; + return CC_MqttsnErrorCode_AlreadyStarted; } if ((m_nextTickProgramFn == nullptr) || (m_cancelNextTickWaitFn == nullptr) || (m_sendOutputDataFn == nullptr) || (m_msgReportFn == nullptr)) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } m_running = true; @@ -568,18 +565,18 @@ class BasicClient checkGwSearchReq(); programNextTimeout(); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode stop() + CC_MqttsnErrorCode stop() { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } auto guard = apiCall(); m_running = false; - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } void tick() @@ -641,28 +638,28 @@ class BasicClient auto fn = getFinaliseFunc(); COMMS_ASSERT(fn != nullptr); - (this->*(fn))(MqttsnAsyncOpStatus_Aborted); + (this->*(fn))(CC_MqttsnAsyncOpStatus_Aborted); return true; } - MqttsnErrorCode connect( + CC_MqttsnErrorCode connect( const char* clientId, unsigned short keepAlivePeriod, bool cleanSession, - const MqttsnWillInfo* willInfo, - MqttsnAsyncOpCompleteReportFn callback, + const CC_MqttsnWillInfo* willInfo, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Disconnected) { - return MqttsnErrorCode_AlreadyConnected; + return CC_MqttsnErrorCode_AlreadyConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } auto guard = apiCall(); @@ -682,27 +679,27 @@ class BasicClient bool result = doConnect(); static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode reconnect( - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnErrorCode reconnect( + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus == ConnectionStatus::Disconnected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -718,23 +715,23 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode disconnect( - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnErrorCode disconnect( + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus == ConnectionStatus::Disconnected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } auto guard = apiCall(); @@ -746,42 +743,42 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode publish( - MqttsnTopicId topicId, + CC_MqttsnErrorCode publish( + CC_MqttsnTopicId topicId, const std::uint8_t* msg, std::size_t msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } - if ((m_connectionStatus != ConnectionStatus::Connected) && (qos != MqttsnQoS_NoGwPublish)) { - return MqttsnErrorCode_NotConnected; + if ((m_connectionStatus != ConnectionStatus::Connected) && (qos != CC_MqttsnQoS_NoGwPublish)) { + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } - if ((qos < MqttsnQoS_NoGwPublish) || - (MqttsnQoS_ExactlyOnceDelivery < qos)) { - return MqttsnErrorCode_BadParam; + if ((qos < CC_MqttsnQoS_NoGwPublish) || + (CC_MqttsnQoS_ExactlyOnceDelivery < qos)) { + return CC_MqttsnErrorCode_BadParam; } - if ((callback == nullptr) && (MqttsnQoS_AtLeastOnceDelivery <= qos)) { - return MqttsnErrorCode_BadParam; + if ((callback == nullptr) && (CC_MqttsnQoS_AtLeastOnceDelivery <= qos)) { + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); - if (MqttsnQoS_AtLeastOnceDelivery <= qos) { + if (CC_MqttsnQoS_AtLeastOnceDelivery <= qos) { m_currOp = Op::PublishId; auto* pubOp = newAsyncOp(callback, data); pubOp->m_topicId = topicId; @@ -805,39 +802,39 @@ class BasicClient retain, false); if (callback != nullptr) { - callback(data, MqttsnAsyncOpStatus_Successful); + callback(data, CC_MqttsnAsyncOpStatus_Successful); } } - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode publish( + CC_MqttsnErrorCode publish( const char* topic, const std::uint8_t* msg, std::size_t msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } - if ((m_connectionStatus != ConnectionStatus::Connected) && (qos != MqttsnQoS_NoGwPublish)) { - return MqttsnErrorCode_NotConnected; + if ((m_connectionStatus != ConnectionStatus::Connected) && (qos != CC_MqttsnQoS_NoGwPublish)) { + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } - if ((qos < MqttsnQoS_AtMostOnceDelivery) || - (MqttsnQoS_ExactlyOnceDelivery < qos) || + if ((qos < CC_MqttsnQoS_AtMostOnceDelivery) || + (CC_MqttsnQoS_ExactlyOnceDelivery < qos) || (callback == nullptr)) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -859,32 +856,32 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode subscribe( - MqttsnTopicId topicId, - MqttsnQoS qos, - MqttsnSubscribeCompleteReportFn callback, + CC_MqttsnErrorCode subscribe( + CC_MqttsnTopicId topicId, + CC_MqttsnQoS qos, + CC_MqttsnSubscribeCompleteReportFn callback, void* data ) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } - if ((qos < MqttsnQoS_AtMostOnceDelivery) || - (MqttsnQoS_ExactlyOnceDelivery < qos) || + if ((qos < CC_MqttsnQoS_AtMostOnceDelivery) || + (CC_MqttsnQoS_ExactlyOnceDelivery < qos) || (callback == nullptr)) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -901,33 +898,33 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode subscribe( + CC_MqttsnErrorCode subscribe( const char* topic, - MqttsnQoS qos, - MqttsnSubscribeCompleteReportFn callback, + CC_MqttsnQoS qos, + CC_MqttsnSubscribeCompleteReportFn callback, void* data ) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } - if ((qos < MqttsnQoS_AtMostOnceDelivery) || - (MqttsnQoS_ExactlyOnceDelivery < qos) || + if ((qos < CC_MqttsnQoS_AtMostOnceDelivery) || + (CC_MqttsnQoS_ExactlyOnceDelivery < qos) || (topic == nullptr) || (callback == nullptr)) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -948,29 +945,29 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode unsubscribe( - MqttsnTopicId topicId, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnErrorCode unsubscribe( + CC_MqttsnTopicId topicId, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -984,28 +981,28 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode unsubscribe( + CC_MqttsnErrorCode unsubscribe( const char* topic, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -1023,28 +1020,28 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode willUpdate( - const MqttsnWillInfo* willInfo, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnErrorCode willUpdate( + const CC_MqttsnWillInfo* willInfo, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -1063,30 +1060,30 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode willTopicUpdate( + CC_MqttsnErrorCode willTopicUpdate( const char* topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -1101,29 +1098,29 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode willMsgUpdate( + CC_MqttsnErrorCode willMsgUpdate( const unsigned char* msg, unsigned msgLen, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Connected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -1137,28 +1134,28 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode sleep( + CC_MqttsnErrorCode sleep( std::uint16_t duration, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus == ConnectionStatus::Disconnected) { - return MqttsnErrorCode_NotConnected; + return CC_MqttsnErrorCode_NotConnected; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -1171,27 +1168,27 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } - MqttsnErrorCode checkMessages( - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnErrorCode checkMessages( + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { if (!m_running) { - return MqttsnErrorCode_NotStarted; + return CC_MqttsnErrorCode_NotStarted; } if (m_connectionStatus != ConnectionStatus::Asleep) { - return MqttsnErrorCode_NotSleeping; + return CC_MqttsnErrorCode_NotSleeping; } if (m_currOp != Op::None) { - return MqttsnErrorCode_Busy; + return CC_MqttsnErrorCode_Busy; } if (callback == nullptr) { - return MqttsnErrorCode_BadParam; + return CC_MqttsnErrorCode_BadParam; } auto guard = apiCall(); @@ -1204,7 +1201,7 @@ class BasicClient static_cast(result); COMMS_ASSERT(result); - return MqttsnErrorCode_Success; + return CC_MqttsnErrorCode_Success; } void handle(AdvertiseMsg& msg) @@ -1222,7 +1219,7 @@ class BasicClient return; } - reportGwStatus(msg.field_gwId().value(), MqttsnGwStatus_Available); + reportGwStatus(msg.field_gwId().value(), CC_MqttsnGwStatus_Available); } void handle(GwinfoMsg& msg) @@ -1246,7 +1243,7 @@ class BasicClient // iter->m_addr = addrField.value(); // } - reportGwStatus(msg.field_gwId().value(), MqttsnGwStatus_Available); + reportGwStatus(msg.field_gwId().value(), CC_MqttsnGwStatus_Available); } void handle(ConnackMsg& msg) @@ -1379,7 +1376,7 @@ class BasicClient auto reportMsgFunc = [this, &msg](const char* topicName) { - auto msgInfo = MqttsnMessageInfo(); + auto msgInfo = CC_MqttsnMessageInfo(); msgInfo.topic = topicName; if (topicName == nullptr) { @@ -1423,8 +1420,8 @@ class BasicClient topicName = &shortTopicName[0]; } - if ((msg.field_flags().field_qos().value() < mqttsn::field::QosVal::AtLeastOnceDelivery) || - (mqttsn::field::QosVal::ExactlyOnceDelivery < msg.field_flags().field_qos().value())) { + if ((msg.field_flags().field_qos().value() < cc_mqttsn::field::QosVal::AtLeastOnceDelivery) || + (cc_mqttsn::field::QosVal::ExactlyOnceDelivery < msg.field_flags().field_qos().value())) { if ((topicName == nullptr) && (msg.field_flags().field_topicIdType().value() != TopicIdTypeVal::PredefinedTopicId)) { @@ -1441,13 +1438,13 @@ class BasicClient return; } - if (msg.field_flags().field_qos().value() == mqttsn::field::QosVal::AtLeastOnceDelivery) { + if (msg.field_flags().field_qos().value() == cc_mqttsn::field::QosVal::AtLeastOnceDelivery) { sendPuback(msg.field_topicId().value(), msg.field_msgId().value(), ReturnCodeVal::Accepted); reportMsgFunc(topicName); return; } - COMMS_ASSERT(msg.field_flags().field_qos().value() == mqttsn::field::QosVal::ExactlyOnceDelivery); + COMMS_ASSERT(msg.field_flags().field_qos().value() == cc_mqttsn::field::QosVal::ExactlyOnceDelivery); bool newMessage = ((!msg.field_flags().field_high().getBitValue_Dup()) || @@ -1506,14 +1503,14 @@ class BasicClient return; } - if ((op->m_qos == MqttsnQoS_ExactlyOnceDelivery) && + if ((op->m_qos == CC_MqttsnQoS_ExactlyOnceDelivery) && (retCodeValue == ReturnCodeVal::Accepted)) { // PUBREC is expected instead return; } do { - if ((op->m_qos < MqttsnQoS_AtLeastOnceDelivery) || + if ((op->m_qos < CC_MqttsnQoS_AtLeastOnceDelivery) || (retCodeValue != ReturnCodeVal::InvalidTopicId) || (m_currOp != Op::Publish) || (opPtr()->m_didRegistration)) { @@ -1560,7 +1557,7 @@ class BasicClient sendMessage(compMsg); if (!m_lastInMsg.m_reported) { - auto msgInfo = MqttsnMessageInfo(); + auto msgInfo = CC_MqttsnMessageInfo(); if (m_lastInMsg.m_usingShortTopicName) { msgInfo.topic = &m_lastInMsg.m_shortTopic[0]; @@ -1582,7 +1579,7 @@ class BasicClient msgInfo.msg = &(*m_lastInMsg.m_msgData.begin()); msgInfo.msgLen = static_cast(m_lastInMsg.m_msgData.size()); - msgInfo.qos = MqttsnQoS_ExactlyOnceDelivery; + msgInfo.qos = CC_MqttsnQoS_ExactlyOnceDelivery; msgInfo.retain = m_lastInMsg.m_retain; m_lastInMsg.m_reported = true; @@ -1605,7 +1602,7 @@ class BasicClient return; } - finalisePublishOp(MqttsnAsyncOpStatus_Successful); + finalisePublishOp(CC_MqttsnAsyncOpStatus_Successful); } void handle(SubackMsg& msg) @@ -1657,7 +1654,7 @@ class BasicClient if ((m_currOp == Op::SubscribeId) && (opPtr()->m_topicId != msg.field_topicId().value())) { if (!doSubscribeId()) { - finaliseSubscribeOp(MqttsnAsyncOpStatus_InvalidId); + finaliseSubscribeOp(CC_MqttsnAsyncOpStatus_InvalidId); } return; } @@ -1668,7 +1665,7 @@ class BasicClient } op->m_qos = qosValue; - finaliseSubscribeOp(MqttsnAsyncOpStatus_Successful); + finaliseSubscribeOp(CC_MqttsnAsyncOpStatus_Successful); } void handle(UnsubackMsg& msg) @@ -1708,7 +1705,7 @@ class BasicClient iter->m_locked = false; } while (false); - finaliseUnsubscribeOp(MqttsnAsyncOpStatus_Successful); + finaliseUnsubscribeOp(CC_MqttsnAsyncOpStatus_Successful); } void handle(PingreqMsg& msg) @@ -1730,7 +1727,7 @@ class BasicClient // checking messages in asleep mode COMMS_ASSERT(m_connectionStatus == ConnectionStatus::Asleep); - finaliseCheckMessagesOp(MqttsnAsyncOpStatus_Successful); + finaliseCheckMessagesOp(CC_MqttsnAsyncOpStatus_Successful); } void handle(DisconnectMsg& msg) @@ -1738,13 +1735,13 @@ class BasicClient static_cast(msg); if (m_currOp == Op::Disconnect) { - finaliseDisconnectOp(MqttsnAsyncOpStatus_Successful); + finaliseDisconnectOp(CC_MqttsnAsyncOpStatus_Successful); return; } if (m_currOp == Op::Sleep) { m_connectionStatus = ConnectionStatus::Asleep; - finaliseSleepOp(MqttsnAsyncOpStatus_Successful); + finaliseSleepOp(CC_MqttsnAsyncOpStatus_Successful); return; } @@ -1799,8 +1796,8 @@ class BasicClient > >::Type OpStorageType; - using InputMessages = mqttsn::input::ClientInputMessages; - typedef mqttsn::frame::Frame ProtStack; + using InputMessages = cc_mqttsn::input::ClientInputMessages; + typedef cc_mqttsn::frame::Frame ProtStack; typedef typename ProtStack::MsgPtr MsgPtr; struct RegInfo @@ -1817,7 +1814,7 @@ class BasicClient struct LastInMsgInfo { DataType m_msgData; - MqttsnTopicId m_topicId = 0; + CC_MqttsnTopicId m_topicId = 0; std::uint16_t m_msgId = 0; char m_shortTopic[3] = {0}; bool m_retain = false; @@ -1913,7 +1910,7 @@ class BasicClient } template - TOp* newAsyncOp(MqttsnAsyncOpCompleteReportFn cb, void* cbData) + TOp* newAsyncOp(CC_MqttsnAsyncOpCompleteReportFn cb, void* cbData) { static_assert(std::is_base_of::value, "Invalid base"); @@ -2079,7 +2076,7 @@ class BasicClient m_gwInfos.end()); for (auto id : idsToRemove) { - reportGwStatus(id, MqttsnGwStatus_TimedOut); + reportGwStatus(id, CC_MqttsnGwStatus_TimedOut); } } @@ -2169,7 +2166,7 @@ class BasicClient auto finaliseFn = getFinaliseFunc(); COMMS_ASSERT(finaliseFn != nullptr); - (this->*finaliseFn)(MqttsnAsyncOpStatus_NoResponse); + (this->*finaliseFn)(CC_MqttsnAsyncOpStatus_NoResponse); } void checkTimeouts() @@ -2198,7 +2195,7 @@ class BasicClient return true; } - void reportGwStatus(GwIdValueType id, MqttsnGwStatus status) + void reportGwStatus(GwIdValueType id, CC_MqttsnGwStatus status) { if (m_gwStatusReportFn != nullptr) { m_gwStatusReportFn(m_gwStatusReportData, id, status); @@ -2290,13 +2287,13 @@ class BasicClient bool firstAttempt = (op->m_attempt == 0U); ++op->m_attempt; - if (firstAttempt && (MqttsnQoS_AtLeastOnceDelivery <= op->m_qos)) { + if (firstAttempt && (CC_MqttsnQoS_AtLeastOnceDelivery <= op->m_qos)) { op->m_msgId = allocMsgId(); } if ((!firstAttempt) && (op->m_ackReceived) && - (MqttsnQoS_ExactlyOnceDelivery <= op->m_qos)) { + (CC_MqttsnQoS_ExactlyOnceDelivery <= op->m_qos)) { sendPubrel(op->m_msgId); return true; } @@ -2311,8 +2308,8 @@ class BasicClient op->m_retain, !firstAttempt); - if (op->m_qos <= MqttsnQoS_AtMostOnceDelivery) { - finalisePublishOp(MqttsnAsyncOpStatus_Successful); + if (op->m_qos <= CC_MqttsnQoS_AtMostOnceDelivery) { + finalisePublishOp(CC_MqttsnAsyncOpStatus_Successful); } return true; @@ -2357,7 +2354,7 @@ class BasicClient } while (false); op->m_msgId = 0U; - if (firstAttempt && (MqttsnQoS_AtLeastOnceDelivery <= op->m_qos)) { + if (firstAttempt && (CC_MqttsnQoS_AtLeastOnceDelivery <= op->m_qos)) { op->m_msgId = allocMsgId(); } @@ -2365,7 +2362,7 @@ class BasicClient if ((!firstAttempt) && (op->m_ackReceived) && - (MqttsnQoS_ExactlyOnceDelivery <= op->m_qos)) { + (CC_MqttsnQoS_ExactlyOnceDelivery <= op->m_qos)) { sendPubrel(op->m_msgId); return true; } @@ -2385,8 +2382,8 @@ class BasicClient op->m_retain, !firstAttempt); - if (op->m_qos <= MqttsnQoS_AtMostOnceDelivery) { - finalisePublishOp(MqttsnAsyncOpStatus_Successful); + if (op->m_qos <= CC_MqttsnQoS_AtMostOnceDelivery) { + finalisePublishOp(CC_MqttsnAsyncOpStatus_Successful); } return true; @@ -2610,7 +2607,7 @@ class BasicClient void sendWilltopic( const char* topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain) { WilltopicMsg msg; @@ -2636,12 +2633,12 @@ class BasicClient } void sendPublish( - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId, const std::uint8_t* msg, std::size_t msgLen, TopicIdTypeVal topicIdType, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain, bool duplicate) { @@ -2659,7 +2656,7 @@ class BasicClient } void sendPuback( - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId, ReturnCodeVal retCode) { @@ -2703,7 +2700,7 @@ class BasicClient } template - void finaliseAsyncOp(MqttsnAsyncOpStatus status) + void finaliseAsyncOp(CC_MqttsnAsyncOpStatus status) { COMMS_ASSERT(m_currOp == TCurr); @@ -2719,7 +2716,7 @@ class BasicClient } template - void finaliseAsyncDoubleOp(MqttsnAsyncOpStatus status) + void finaliseAsyncDoubleOp(CC_MqttsnAsyncOpStatus status) { COMMS_ASSERT((m_currOp == TCurr1) || (m_currOp == TCurr2)); @@ -2741,22 +2738,22 @@ class BasicClient cb(cbData, status); } - void finaliseConnectOp(MqttsnAsyncOpStatus status) + void finaliseConnectOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncOp(status); } - void finaliseDisconnectOp(MqttsnAsyncOpStatus status) + void finaliseDisconnectOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncOp(status); } - void finalisePublishOp(MqttsnAsyncOpStatus status) + void finalisePublishOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncDoubleOp(status); } - void finaliseSubscribeOp(MqttsnAsyncOpStatus status) + void finaliseSubscribeOp(CC_MqttsnAsyncOpStatus status) { COMMS_ASSERT((m_currOp == Op::Subscribe) || (m_currOp == Op::SubscribeId)); auto* op = opPtr(); @@ -2774,27 +2771,27 @@ class BasicClient cb(cbData, status, op->m_qos); } - void finaliseUnsubscribeOp(MqttsnAsyncOpStatus status) + void finaliseUnsubscribeOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncDoubleOp(status); } - void finaliseWillTopicUpdateOp(MqttsnAsyncOpStatus status) + void finaliseWillTopicUpdateOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncOp(status); } - void finaliseWillMsgUpdateOp(MqttsnAsyncOpStatus status) + void finaliseWillMsgUpdateOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncOp(status); } - void finaliseSleepOp(MqttsnAsyncOpStatus status) + void finaliseSleepOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncOp(status); } - void finaliseCheckMessagesOp(MqttsnAsyncOpStatus status) + void finaliseCheckMessagesOp(CC_MqttsnAsyncOpStatus status) { finaliseAsyncOp(status); } @@ -2827,13 +2824,13 @@ class BasicClient return Map[opIdx]; } - MqttsnAsyncOpStatus retCodeToStatus(ReturnCodeVal val) + CC_MqttsnAsyncOpStatus retCodeToStatus(ReturnCodeVal val) { - static const MqttsnAsyncOpStatus Map[] = { - /* ReturnCodeVal_Accepted */ MqttsnAsyncOpStatus_Successful, - /* ReturnCodeVal_Congestion */ MqttsnAsyncOpStatus_Congestion, - /* ReturnCodeVal_InvalidTopicId */ MqttsnAsyncOpStatus_InvalidId, - /* ReturnCodeVal_NotSupported */ MqttsnAsyncOpStatus_NotSupported + static const CC_MqttsnAsyncOpStatus Map[] = { + /* ReturnCodeVal_Accepted */ CC_MqttsnAsyncOpStatus_Successful, + /* ReturnCodeVal_Congestion */ CC_MqttsnAsyncOpStatus_Congestion, + /* ReturnCodeVal_InvalidTopicId */ CC_MqttsnAsyncOpStatus_InvalidId, + /* ReturnCodeVal_NotSupported */ CC_MqttsnAsyncOpStatus_NotSupported }; static const std::size_t MapSize = std::extent::value; @@ -2841,7 +2838,7 @@ class BasicClient static_assert(MapSize == static_cast(ReturnCodeVal::ValuesLimit), "Map is incorrect"); - MqttsnAsyncOpStatus status = MqttsnAsyncOpStatus_NotSupported; + CC_MqttsnAsyncOpStatus status = CC_MqttsnAsyncOpStatus_NotSupported; if (static_cast(val) < MapSize) { status = Map[static_cast(val)]; } @@ -2902,17 +2899,17 @@ class BasicClient return topic[2] == '\0'; } - static MqttsnTopicId shortTopicToTopicId(const char* topic) + static CC_MqttsnTopicId shortTopicToTopicId(const char* topic) { COMMS_ASSERT(topic[0] != '\0'); COMMS_ASSERT(topic[1] != '\0'); return - static_cast( - (static_cast(topic[0]) << 8) | static_cast(topic[1])); + static_cast( + (static_cast(topic[0]) << 8) | static_cast(topic[1])); } - static void topicIdToShortTopic(MqttsnTopicId topicId, char* topicOut) + static void topicIdToShortTopic(CC_MqttsnTopicId topicId, char* topicOut) { topicOut[0] = static_cast((topicId >> 8) & 0xff); topicOut[1] = static_cast(topicId & 0xff); @@ -2950,22 +2947,22 @@ class BasicClient LastInMsgInfo m_lastInMsg; - MqttsnNextTickProgramFn m_nextTickProgramFn = nullptr; + CC_MqttsnNextTickProgramFn m_nextTickProgramFn = nullptr; void* m_nextTickProgramData = nullptr; - MqttsnCancelNextTickWaitFn m_cancelNextTickWaitFn = nullptr; + CC_MqttsnCancelNextTickWaitFn m_cancelNextTickWaitFn = nullptr; void* m_cancelNextTickWaitData = nullptr; - MqttsnSendOutputDataFn m_sendOutputDataFn = nullptr; + CC_MqttsnSendOutputDataFn m_sendOutputDataFn = nullptr; void* m_sendOutputDataData = nullptr; - MqttsnGwStatusReportFn m_gwStatusReportFn = nullptr; + CC_MqttsnGwStatusReportFn m_gwStatusReportFn = nullptr; void* m_gwStatusReportData = nullptr; - MqttsnGwDisconnectReportFn m_gwDisconnectReportFn = nullptr; + CC_MqttsnGwDisconnectReportFn m_gwDisconnectReportFn = nullptr; void* m_gwDisconnectReportData = nullptr; - MqttsnMessageReportFn m_msgReportFn = nullptr; + CC_MqttsnMessageReportFn m_msgReportFn = nullptr; void* m_msgReportData = nullptr; WriteBufStorage m_writeBuf; @@ -2979,8 +2976,6 @@ class BasicClient static const Timestamp DefaultStartTimestamp = 100; }; -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/basic/CMakeLists.txt b/client/src/basic/CMakeLists.txt index 86300d4b..08330de4 100644 --- a/client/src/basic/CMakeLists.txt +++ b/client/src/basic/CMakeLists.txt @@ -34,8 +34,8 @@ foreach (f ${CC_MQTTSN_CUSTOM_CLIENT_CONFIG_FILES}) include (${f}) if ("${f}" STREQUAL "${CC_MQTTSN_DEFAULT_CLIENT_CONFIG_FILE}") - set (MQTTSN_CUSTOM_CLIENT_NAME "${DEFAULT_CLIENT_NAME}") - elseif ("${MQTTSN_CUSTOM_CLIENT_NAME}" STREQUAL "") + set (CC_MQTTSN_CUSTOM_CLIENT_NAME "${DEFAULT_CLIENT_NAME}") + elseif ("${CC_MQTTSN_CUSTOM_CLIENT_NAME}" STREQUAL "") message (WARNING "File ${f} does not specify client name!") continue () endif () @@ -44,55 +44,55 @@ foreach (f ${CC_MQTTSN_CUSTOM_CLIENT_CONFIG_FILES}) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::ClientIdStaticStorageSize" - "${MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE}" + "cc_mqttsn_client::option::ClientIdStaticStorageSize" + "${CC_MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE}" ) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::GwAddStaticStorageSize" - "${MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE}" + "cc_mqttsn_client::option::GwAddStaticStorageSize" + "${CC_MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE}" ) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::TopicNameStaticStorageSize" - "${MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE}" + "cc_mqttsn_client::option::TopicNameStaticStorageSize" + "${CC_MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE}" ) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::MessageDataStaticStorageSize" - "${MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE}" + "cc_mqttsn_client::option::MessageDataStaticStorageSize" + "${CC_MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE}" ) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::ClientsAllocLimit" - "${MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT}" + "cc_mqttsn_client::option::ClientsAllocLimit" + "${CC_MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT}" ) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::TrackedGatewaysLimit" - "${MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT}" + "cc_mqttsn_client::option::TrackedGatewaysLimit" + "${CC_MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT}" ) mqttsn_append_option ( mqttsn_library_opts - "mqttsn::client::option::RegisteredTopicsLimit" - "${MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT}" + "cc_mqttsn_client::option::RegisteredTopicsLimit" + "${CC_MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT}" ) set (extra_flags) - if (CMAKE_COMPILER_IS_GNUCC AND MQTTSN_CUSTOM_CLIENT_NO_STDLIB) + if (CMAKE_COMPILER_IS_GNUCC AND CC_MQTTSN_CUSTOM_CLIENT_NO_STDLIB) set (extra_flags "-nostdlib") endif () - gen_lib_mqttsn_client("${MQTTSN_CUSTOM_CLIENT_NAME}" "${mqttsn_library_opts}" TRUE "${extra_flags}") + gen_lib_mqttsn_client("${CC_MQTTSN_CUSTOM_CLIENT_NAME}" "${mqttsn_library_opts}" TRUE "${extra_flags}") - if (MQTTSN_CUSTOM_CLIENT_NO_STDLIB) - target_compile_definitions("cc_mqttsn_${MQTTSN_CUSTOM_CLIENT_NAME}_client" PRIVATE "-DNOSTDLIB") + if (CC_MQTTSN_CUSTOM_CLIENT_NO_STDLIB) + target_compile_definitions("cc_mqttsn_${CC_MQTTSN_CUSTOM_CLIENT_NAME}_client" PRIVATE "-DNOSTDLIB") endif () endforeach() diff --git a/client/src/basic/ClientMgr.h b/client/src/basic/ClientMgr.h index 8dfd275c..1fdffe5f 100644 --- a/client/src/basic/ClientMgr.h +++ b/client/src/basic/ClientMgr.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,10 +9,7 @@ #include "comms/comms.h" -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace details @@ -63,8 +60,6 @@ class ClientMgr Alloc m_alloc; }; -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/basic/ParsedOptions.h b/client/src/basic/ParsedOptions.h index 605c1015..2caefcb8 100644 --- a/client/src/basic/ParsedOptions.h +++ b/client/src/basic/ParsedOptions.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,17 +9,12 @@ #pragma once -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { template using ParsedOptions = details::OptionsParser; -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/basic/details/OptionsParser.h b/client/src/basic/details/OptionsParser.h index 5c4e1a18..e385c357 100644 --- a/client/src/basic/details/OptionsParser.h +++ b/client/src/basic/details/OptionsParser.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,10 +9,7 @@ #include "option.h" -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace details @@ -36,10 +33,10 @@ class OptionsParser<> template class OptionsParser< - mqttsn::client::option::ClientsAllocLimit, + cc_mqttsn_client::option::ClientsAllocLimit, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::ClientsAllocLimit Option; + typedef cc_mqttsn_client::option::ClientsAllocLimit Option; public: static const bool HasClientsAllocLimit = true; static const std::size_t ClientsAllocLimit = Option::Value; @@ -47,10 +44,10 @@ class OptionsParser< template class OptionsParser< - mqttsn::client::option::TrackedGatewaysLimit, + cc_mqttsn_client::option::TrackedGatewaysLimit, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::TrackedGatewaysLimit Option; + typedef cc_mqttsn_client::option::TrackedGatewaysLimit Option; public: static const bool HasTrackedGatewaysLimit = true; static const std::size_t TrackedGatewaysLimit = Option::Value; @@ -58,10 +55,10 @@ class OptionsParser< template class OptionsParser< - mqttsn::client::option::RegisteredTopicsLimit, + cc_mqttsn_client::option::RegisteredTopicsLimit, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::RegisteredTopicsLimit Option; + typedef cc_mqttsn_client::option::RegisteredTopicsLimit Option; public: static const bool HasRegisteredTopicsLimit = true; static const std::size_t RegisteredTopicsLimit = Option::Value; @@ -69,10 +66,10 @@ class OptionsParser< template class OptionsParser< - mqttsn::client::option::GwAddStaticStorageSize, + cc_mqttsn_client::option::GwAddStaticStorageSize, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::GwAddStaticStorageSize Option; + typedef cc_mqttsn_client::option::GwAddStaticStorageSize Option; public: static const bool HasGwAddStaticStorageSize = true; static const std::size_t GwAddStaticStorageSize = Option::Value; @@ -80,10 +77,10 @@ class OptionsParser< template class OptionsParser< - mqttsn::client::option::ClientIdStaticStorageSize, + cc_mqttsn_client::option::ClientIdStaticStorageSize, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::ClientIdStaticStorageSize Option; + typedef cc_mqttsn_client::option::ClientIdStaticStorageSize Option; public: static const bool HasClientIdStaticStorageSize = true; static const std::size_t ClientIdStaticStorageSize = Option::Value; @@ -91,10 +88,10 @@ class OptionsParser< template class OptionsParser< - mqttsn::client::option::TopicNameStaticStorageSize, + cc_mqttsn_client::option::TopicNameStaticStorageSize, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::TopicNameStaticStorageSize Option; + typedef cc_mqttsn_client::option::TopicNameStaticStorageSize Option; public: static const bool HasTopicNameStaticStorageSize = true; static const std::size_t TopicNameStaticStorageSize = Option::Value; @@ -102,10 +99,10 @@ class OptionsParser< template class OptionsParser< - mqttsn::client::option::MessageDataStaticStorageSize, + cc_mqttsn_client::option::MessageDataStaticStorageSize, TOptions...> : public OptionsParser { - typedef mqttsn::client::option::MessageDataStaticStorageSize Option; + typedef cc_mqttsn_client::option::MessageDataStaticStorageSize Option; public: static const bool HasMessageDataStaticStorageSize = true; static const std::size_t MessageDataStaticStorageSize = Option::Value; @@ -122,7 +119,5 @@ class OptionsParser< } // namespace details -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/basic/details/WriteBufStorageType.h b/client/src/basic/details/WriteBufStorageType.h index 57f1cb4d..d0d75347 100644 --- a/client/src/basic/details/WriteBufStorageType.h +++ b/client/src/basic/details/WriteBufStorageType.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,10 +9,7 @@ #include "comms/comms.h" -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace details @@ -70,8 +67,6 @@ using WriteBufStorageTypeT = } // namespace details -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/src/basic/option.h b/client/src/basic/option.h index 5f862e5e..3a23956e 100644 --- a/client/src/basic/option.h +++ b/client/src/basic/option.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,10 +9,7 @@ #include -namespace mqttsn -{ - -namespace client +namespace cc_mqttsn_client { namespace option @@ -63,8 +60,6 @@ struct MessageDataStaticStorageSize } // namespace option -} // namespace client - -} // namespace mqttsn +} // namespace cc_mqttsn_client diff --git a/client/templ/client.cpp.templ b/client/templ/client.cpp.templ index ef19cd8d..fec8b764 100644 --- a/client/templ/client.cpp.templ +++ b/client/templ/client.cpp.templ @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -18,10 +18,10 @@ typedef std::tuple< ##CLIENT_OPTS## > ClientOptions; -typedef mqttsn::client::ParsedOptions ParsedClientOptions; +typedef cc_mqttsn_client::ParsedOptions ParsedClientOptions; -typedef mqttsn::client::BasicClient MqttsnClient; -typedef mqttsn::client::ClientMgr MqttsnClientMgr; +typedef cc_mqttsn_client::BasicClient MqttsnClient; +typedef cc_mqttsn_client::ClientMgr MqttsnClientMgr; MqttsnClientMgr& getClientMgr() { @@ -31,160 +31,162 @@ MqttsnClientMgr& getClientMgr() } // namespace -MqttsnClientHandle mqttsn_##NAME##client_new() +CC_MqttsnClientHandle cc_mqttsn_##NAME##client_new() { auto client = getClientMgr().alloc(); - return client.release(); + auto handle = CC_MqttsnClientHandle(); + handle.m_ptr = client.release(); + return handle; } -void mqttsn_##NAME##client_free(MqttsnClientHandle client) +void cc_mqttsn_##NAME##client_free(CC_MqttsnClientHandle client) { - getClientMgr().free(reinterpret_cast(client)); + getClientMgr().free(reinterpret_cast(client.m_ptr)); } -void mqttsn_##NAME##client_set_next_tick_program_callback( - MqttsnClientHandle client, - MqttsnNextTickProgramFn fn, +void cc_mqttsn_##NAME##client_set_next_tick_program_callback( + CC_MqttsnClientHandle client, + CC_MqttsnNextTickProgramFn fn, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setNextTickProgramCallback(fn, data); } -void mqttsn_##NAME##client_set_cancel_next_tick_wait_callback( - MqttsnClientHandle client, - MqttsnCancelNextTickWaitFn fn, +void cc_mqttsn_##NAME##client_set_cancel_next_tick_wait_callback( + CC_MqttsnClientHandle client, + CC_MqttsnCancelNextTickWaitFn fn, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setCancelNextTickWaitCallback(fn, data); } -void mqttsn_##NAME##client_set_send_output_data_callback( - MqttsnClientHandle client, - MqttsnSendOutputDataFn fn, +void cc_mqttsn_##NAME##client_set_send_output_data_callback( + CC_MqttsnClientHandle client, + CC_MqttsnSendOutputDataFn fn, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setSendOutputDataCallback(fn, data); } -void mqttsn_##NAME##client_set_gw_status_report_callback( - MqttsnClientHandle client, - MqttsnGwStatusReportFn fn, +void cc_mqttsn_##NAME##client_set_gw_status_report_callback( + CC_MqttsnClientHandle client, + CC_MqttsnGwStatusReportFn fn, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setGwStatusReportCallback(fn, data); } -void mqttsn_##NAME##client_set_gw_disconnect_report_callback( - MqttsnClientHandle client, - MqttsnGwDisconnectReportFn fn, +void cc_mqttsn_##NAME##client_set_gw_disconnect_report_callback( + CC_MqttsnClientHandle client, + CC_MqttsnGwDisconnectReportFn fn, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setGwDisconnectReportCallback(fn, data); } -void mqttsn_##NAME##client_set_message_report_callback( - MqttsnClientHandle client, - MqttsnMessageReportFn fn, +void cc_mqttsn_##NAME##client_set_message_report_callback( + CC_MqttsnClientHandle client, + CC_MqttsnMessageReportFn fn, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setMessageReportCallback(fn, data); } -MqttsnErrorCode mqttsn_##NAME##client_start(MqttsnClientHandle client) +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_start(CC_MqttsnClientHandle client) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->start(); } -MqttsnErrorCode mqttsn_##NAME##client_stop(MqttsnClientHandle client) +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_stop(CC_MqttsnClientHandle client) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->stop(); } -unsigned mqttsn_##NAME##client_process_data( - void* client, +unsigned cc_mqttsn_##NAME##client_process_data( + CC_MqttsnClientHandle client, const unsigned char* from, unsigned len) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return static_cast(clientObj->processData(from, len)); } -void mqttsn_##NAME##client_tick(void* client) +void cc_mqttsn_##NAME##client_tick(CC_MqttsnClientHandle client) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->tick(); } -void mqttsn_##NAME##client_set_retry_period(MqttsnClientHandle client, unsigned value) +void cc_mqttsn_##NAME##client_set_retry_period(CC_MqttsnClientHandle client, unsigned value) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setRetryPeriod(value); } -void mqttsn_##NAME##client_set_retry_count(MqttsnClientHandle client, unsigned value) +void cc_mqttsn_##NAME##client_set_retry_count(CC_MqttsnClientHandle client, unsigned value) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setRetryCount(value); } -void mqttsn_##NAME##client_set_broadcast_radius(MqttsnClientHandle client, unsigned char value) +void cc_mqttsn_##NAME##client_set_broadcast_radius(CC_MqttsnClientHandle client, unsigned char value) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setBroadcastRadius(value); } -void mqttsn_##NAME##client_set_searchgw_enabled( - MqttsnClientHandle client, +void cc_mqttsn_##NAME##client_set_searchgw_enabled( + CC_MqttsnClientHandle client, bool value) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->setSearchgwEnabled(value); } -void mqttsn_##NAME##client_search_gw(MqttsnClientHandle client) +void cc_mqttsn_##NAME##client_search_gw(CC_MqttsnClientHandle client) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->sendSearchGw(); } -void mqttsn_##NAME##client_discard_gw( - MqttsnClientHandle client, +void cc_mqttsn_##NAME##client_discard_gw( + CC_MqttsnClientHandle client, unsigned char gwId) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->discardGw(gwId); } -void mqttsn_##NAME##client_discard_all_gw(MqttsnClientHandle client) +void cc_mqttsn_##NAME##client_discard_all_gw(CC_MqttsnClientHandle client) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); clientObj->discardAllGw(); } -bool mqttsn_##NAME##client_cancel(MqttsnClientHandle client) +bool cc_mqttsn_##NAME##client_cancel(CC_MqttsnClientHandle client) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->cancel(); } -MqttsnErrorCode mqttsn_##NAME##client_connect( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_connect( + CC_MqttsnClientHandle client, const char* clientId, unsigned short keepAliveSeconds, bool cleanSession, - const MqttsnWillInfo* willInfo, - MqttsnAsyncOpCompleteReportFn callback, + const CC_MqttsnWillInfo* willInfo, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->connect( clientId, keepAliveSeconds, @@ -194,153 +196,153 @@ MqttsnErrorCode mqttsn_##NAME##client_connect( data); } -MqttsnErrorCode mqttsn_##NAME##client_reconnect( - MqttsnClientHandle client, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_reconnect( + CC_MqttsnClientHandle client, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->reconnect(callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_disconnect( - MqttsnClientHandle client, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_disconnect( + CC_MqttsnClientHandle client, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->disconnect(callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_publish_id( - MqttsnClientHandle client, - MqttsnTopicId topicId, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_publish_id( + CC_MqttsnClientHandle client, + CC_MqttsnTopicId topicId, const unsigned char* msg, unsigned msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->publish(topicId, msg, msgLen, qos, retain, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_publish( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_publish( + CC_MqttsnClientHandle client, const char* topic, const unsigned char* msg, unsigned msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->publish(topic, msg, msgLen, qos, retain, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_subscribe_id( - MqttsnClientHandle client, - MqttsnTopicId topicId, - MqttsnQoS qos, - MqttsnSubscribeCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_subscribe_id( + CC_MqttsnClientHandle client, + CC_MqttsnTopicId topicId, + CC_MqttsnQoS qos, + CC_MqttsnSubscribeCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->subscribe(topicId, qos, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_subscribe( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_subscribe( + CC_MqttsnClientHandle client, const char* topic, - MqttsnQoS qos, - MqttsnSubscribeCompleteReportFn callback, + CC_MqttsnQoS qos, + CC_MqttsnSubscribeCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->subscribe(topic, qos, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_unsubscribe_id( - MqttsnClientHandle client, - MqttsnTopicId topicId, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_unsubscribe_id( + CC_MqttsnClientHandle client, + CC_MqttsnTopicId topicId, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->unsubscribe(topicId, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_unsubscribe( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_unsubscribe( + CC_MqttsnClientHandle client, const char* topic, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->unsubscribe(topic, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_will_update( - MqttsnClientHandle client, - const MqttsnWillInfo* willInfo, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_will_update( + CC_MqttsnClientHandle client, + const CC_MqttsnWillInfo* willInfo, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->willUpdate(willInfo, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_will_topic_update( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_will_topic_update( + CC_MqttsnClientHandle client, const char* topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->willTopicUpdate(topic, qos, retain, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_will_msg_update( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_will_msg_update( + CC_MqttsnClientHandle client, const unsigned char* msg, unsigned msgLen, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->willMsgUpdate(msg, msgLen, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_sleep( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_sleep( + CC_MqttsnClientHandle client, unsigned short duration, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->sleep(duration, callback, data); } -MqttsnErrorCode mqttsn_##NAME##client_check_messages( - MqttsnClientHandle client, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_check_messages( + CC_MqttsnClientHandle client, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ) { - auto* clientObj = reinterpret_cast(client); + auto* clientObj = reinterpret_cast(client.m_ptr); return clientObj->checkMessages(callback, data); } diff --git a/client/templ/client.h.templ b/client/templ/client.h.templ index 1c0ef9e3..84f3f075 100644 --- a/client/templ/client.h.templ +++ b/client/templ/client.h.templ @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,170 +10,170 @@ #pragma once -#include "mqttsn/client/common.h" +#include "cc_mqttsn_client/common.h" #ifdef __cplusplus extern "C" { #endif // #ifdef __cplusplus /// @brief Allocate new client. -/// @details When work with the client is complete, mqttsn_client_free() -/// function, must be invoked. +/// @details When work with the client is complete, @ref cc_mqttsn_##NAME##client_free() +/// function must be invoked. /// @return Handle to allocated client object. This handle needs to be passed /// as first parameter to all other API functions. -MqttsnClientHandle mqttsn_##NAME##client_new(); +CC_MqttsnClientHandle cc_mqttsn_##NAME##client_new(); /// @brief Free previously allocated client. /// @details When used communication channel to the gateway is no longer /// needed, the client data structes allocated with -/// mqttsn_##NAME##client_new() must be released using this function. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. -void mqttsn_##NAME##client_free(MqttsnClientHandle client); +/// cc_mqttsn_##NAME##client_new() must be released using this function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. +void cc_mqttsn_##NAME##client_free(CC_MqttsnClientHandle client); /// @brief Set callback to call when time measurement is required. /// @details The MQTT-SN client may require to measure time. When such /// measurement is required, the provided callback will be invoked with /// the timeout duration in milliseconds. After requested time expires, -/// the mqttsn_##NAME##client_tick() function must be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// the @ref cc_mqttsn_##NAME##client_tick() function must be invoked. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] fn Callback function. /// @param[in] data Pointer to any user data structure. It will passed as one /// of the parameters in callback invocation. May be NULL. -void mqttsn_##NAME##client_set_next_tick_program_callback( - MqttsnClientHandle client, - MqttsnNextTickProgramFn fn, +void cc_mqttsn_##NAME##client_set_next_tick_program_callback( + CC_MqttsnClientHandle client, + CC_MqttsnNextTickProgramFn fn, void* data); /// @brief Set callback to terminate current time measurement. /// @details The client may request termination of currently running time /// measurement, previously requested via callback, which was set using -/// mqttsn_##NAME##client_set_next_tick_program_callback() function. This function +/// @ref cc_mqttsn_##NAME##client_set_next_tick_program_callback() function. This function /// sets appropriate callback. When invoked, it must returne number of /// elapsed milliseconds since previoius time measurement request. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] fn Callback function. /// @param[in] data Pointer to any user data structure. It will passed as one /// of the parameters in callback invocation. May be NULL. -void mqttsn_##NAME##client_set_cancel_next_tick_wait_callback( - MqttsnClientHandle client, - MqttsnCancelNextTickWaitFn fn, +void cc_mqttsn_##NAME##client_set_cancel_next_tick_wait_callback( + CC_MqttsnClientHandle client, + CC_MqttsnCancelNextTickWaitFn fn, void* data); /// @brief Set callback to send raw data over I/O link. /// @details The callback is invoked when there is a need to send data /// to the gateway. The callback is invoked for every single message /// that need to be sent as a single datagram. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] fn Callback function. /// @param[in] data Pointer to any user data structure. It will passed as one /// of the parameters in callback invocation. May be NULL. -void mqttsn_##NAME##client_set_send_output_data_callback( - MqttsnClientHandle client, - MqttsnSendOutputDataFn fn, +void cc_mqttsn_##NAME##client_set_send_output_data_callback( + CC_MqttsnClientHandle client, + CC_MqttsnSendOutputDataFn fn, void* data); /// @brief Set callback to report status of the gateway. /// @details The callback is invoked when gateway status has changed. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] fn Callback function. /// @param[in] data Pointer to any user data structure. It will passed as one /// of the parameters in callback invocation. May be NULL. -void mqttsn_##NAME##client_set_gw_status_report_callback( - MqttsnClientHandle client, - MqttsnGwStatusReportFn fn, +void cc_mqttsn_##NAME##client_set_gw_status_report_callback( + CC_MqttsnClientHandle client, + CC_MqttsnGwStatusReportFn fn, void* data); /// @brief Set callback to report unsolicited disconnection of the gateway. /// @details The callback will be invoked when gateway sends unsolicited /// @b DISCONNECT message or does not reply to @b PINGREQ message. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] fn Callback function. /// @param[in] data Pointer to any user data structure. It will passed as one /// of the parameters in callback invocation. May be NULL. -void mqttsn_##NAME##client_set_gw_disconnect_report_callback( - MqttsnClientHandle client, - MqttsnGwDisconnectReportFn fn, +void cc_mqttsn_##NAME##client_set_gw_disconnect_report_callback( + CC_MqttsnClientHandle client, + CC_MqttsnGwDisconnectReportFn fn, void* data); /// @brief Set callback to report incoming messages. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] fn Callback function. /// @param[in] data Pointer to any user data structure. It will passed as one /// of the parameters in callback invocation. May be NULL. -void mqttsn_##NAME##client_set_message_report_callback( - MqttsnClientHandle client, - MqttsnMessageReportFn fn, +void cc_mqttsn_##NAME##client_set_message_report_callback( + CC_MqttsnClientHandle client, + CC_MqttsnMessageReportFn fn, void* data); /// @brief Start the library's operation. /// @details The function will check whether all necessary callback functions -/// were set. In not @ref MqttsnErrorCode_BadParam will be returned. +/// were set. In not @ref CC_MqttsnErrorCode_BadParam will be returned. /// If search for gateways is enabled (see description of -/// mqttsn_##NAME##client_set_searchgw_enabled()), the library may +/// cc_mqttsn_##NAME##client_set_searchgw_enabled()), the library may /// send @b SEARCHGW message by invoking the callback, set by -/// mqttsn_##NAME##client_set_send_output_data_callback(). -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// cc_mqttsn_##NAME##client_set_send_output_data_callback(). +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_start(MqttsnClientHandle client); +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_start(CC_MqttsnClientHandle client); /// @brief Stop the library's operation. -/// @details The operation may be resumed using mqttsn_##NAME##client_start(). -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @details The operation may be resumed using cc_mqttsn_##NAME##client_start(). +/// @param[in] client Handle returned by cc_mqttsn_##NAME##client_new() function. /// @return Error code indicating success/failure status of the operation -MqttsnErrorCode mqttsn_##NAME##client_stop(MqttsnClientHandle client); +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_stop(CC_MqttsnClientHandle client); /// @brief Provide data, received over I/O link, to the library for processing. /// @details This call may cause invocation of some callbacks, such as /// request to cancel the currently running time measurement, send some messages to /// the gateway, report incoming application message, and (re)start time /// measurement. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] buf Pointer to the buffer of data to process. /// @param[in] bufLen Number of bytes in the data buffer. /// @return Number of processed bytes. /// @note The function returns number of bytes that were actually consumed, and /// can be removed from the holding buffer. -unsigned mqttsn_##NAME##client_process_data(MqttsnClientHandle client, const unsigned char* buf, unsigned bufLen); +unsigned cc_mqttsn_##NAME##client_process_data(CC_MqttsnClientHandle client, const unsigned char* buf, unsigned bufLen); /// @brief Notify client about requested time expiry. /// @details The reported amount of milliseconds needs to be from the /// last request to program timer via callback (set by -/// mqttsn_##NAME##client_set_next_tick_program_callback()). +/// cc_mqttsn_##NAME##client_set_next_tick_program_callback()). /// It can be less than actually requested via the callback. If this /// function is called, the library assumes that previously requested /// timeout measurement is not in progress any more, and will request /// new measurement if needed. /// This call may cause invocation of some other callbacks, such as a request /// to send new data to the gateway. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] ms Number of elapsed @b milliseconds. -void mqttsn_##NAME##client_tick(MqttsnClientHandle client); +void cc_mqttsn_##NAME##client_tick(CC_MqttsnClientHandle client); /// @brief Set retry period to wait between resending unacknowledged message to the gateway. /// @details Some messages, sent to the gateway, may require acknowledgement by /// the latter. The delay (in seconds) between such attempts to resend the /// message may be specified using this function. The default value is /// @b 15 seconds. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] value Number of @b seconds to wait before making an attempt to resend. -void mqttsn_##NAME##client_set_retry_period(MqttsnClientHandle client, unsigned value); +void cc_mqttsn_##NAME##client_set_retry_period(CC_MqttsnClientHandle client, unsigned value); /// @brief Set number of retry attempts to perform before reporting unsuccessful result of the operation. /// @details Some messages, sent to the gateway, may require acknowledgement by /// the latter. The amount of retry attempts before reporting unsuccessful result /// of the operation may be specified using this function. The default value /// is @b 3. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] value Number of retry attempts. -void mqttsn_##NAME##client_set_retry_count(MqttsnClientHandle client, unsigned value); +void cc_mqttsn_##NAME##client_set_retry_count(CC_MqttsnClientHandle client, unsigned value); /// @brief Set broadcast radius. /// @details When searching for gateways, the client library broadcasts @b SEARCHGW /// messages. It contains the broadcast radius value. This value can be /// set using this function. Default radius value is 0. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] value Broadcast radius. -void mqttsn_##NAME##client_set_broadcast_radius(MqttsnClientHandle client, unsigned char value); +void cc_mqttsn_##NAME##client_set_broadcast_radius(CC_MqttsnClientHandle client, unsigned char value); /// @brief Enable/Disable search for gateways. /// @details According to @b MQTT-SN protocol specification the client may @@ -182,36 +182,36 @@ void mqttsn_##NAME##client_set_broadcast_radius(MqttsnClientHandle client, unsig /// be no need to send these messages. To enable/disable search for available /// gateways can be done using this function. By default the search for /// the gateway is @b enabled. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] value @b true to enable, and @false to disable. -void mqttsn_##NAME##client_set_searchgw_enabled(MqttsnClientHandle client, bool value); +void cc_mqttsn_##NAME##client_set_searchgw_enabled(CC_MqttsnClientHandle client, bool value); /// @brief Send @b SEARCHGW message. /// @details This function performs one send of @b SEARCHGW message regardless /// of whether the search for gateways is enabled or disabled. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. -void mqttsn_##NAME##client_search_gw(MqttsnClientHandle client); +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. +void cc_mqttsn_##NAME##client_search_gw(CC_MqttsnClientHandle client); /// @brief Discard information about the gateway. /// @details The client library maintains the list of gateways that either /// advertised their presence or replied to previously sent @b SEARCHGW /// messages. This function causes information about specified gateway /// to be dropped. If such information exists, the callback, set -/// using mqttsn_##NAME##client_set_gw_status_report_callback() function, -/// will be invoked reporting @ref MqttsnGwStatus_Discarded as status value. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// using @ref cc_mqttsn_##NAME##client_set_gw_status_report_callback() function, +/// will be invoked reporting @ref CC_MqttsnGwStatus_Discarded as status value. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] gwId ID of the gateway. -void mqttsn_##NAME##client_discard_gw(MqttsnClientHandle client, unsigned char gwId); +void cc_mqttsn_##NAME##client_discard_gw(CC_MqttsnClientHandle client, unsigned char gwId); /// @brief Discard information about all gateways. /// @details The client library maintains the list of gateways that either /// advertised their presence or replied to previously sent @b SEARCHGW /// messages. This function causes the callback, set -/// using mqttsn_##NAME##client_set_gw_status_report_callback() function, -/// to be invoked reporting @ref MqttsnGwStatus_Discarded as status value for +/// using @ref cc_mqttsn_##NAME##client_set_gw_status_report_callback() function, +/// to be invoked reporting @ref CC_MqttsnGwStatus_Discarded as status value for /// all the recorded gateways. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. -void mqttsn_##NAME##client_discard_all_gw(MqttsnClientHandle client); +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. +void cc_mqttsn_##NAME##client_discard_all_gw(CC_MqttsnClientHandle client); /// @brief Cancel current asynchronous operation. /// @details The library provides support for multiple asynchronous operations, @@ -219,33 +219,33 @@ void mqttsn_##NAME##client_discard_all_gw(MqttsnClientHandle client); /// doesn't support start of the new operation before previous one completed. /// This function provides an ability to cancel existing operation to allow /// issue of the new request. When successfully cancelled the callback of -/// the asyncrhonous operation will report @ref MqttsnAsyncOpStatus_Aborted +/// the asyncrhonous operation will report @ref CC_MqttsnAsyncOpStatus_Aborted /// as operation result status. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @return true in case an asynchronous operation was cancelled, /// false otherwise. -bool mqttsn_##NAME##client_cancel(MqttsnClientHandle client); +bool cc_mqttsn_##NAME##client_cancel(CC_MqttsnClientHandle client); /// @brief Issue the connect request to the gateway. /// @details This function needs to be called to connect to the gateway. /// When the operation is complete, the provided callback /// will be invoked. Note, that the function cannot be successfully called when /// client is already connected to the gateway. In order to change the -/// will information use mqttsn_##NAME##client_will_update() function. -/// If some other operation timed out, use mqttsn_##NAME##client_reconnect() +/// will information use @ref cc_mqttsn_##NAME##client_will_update() function. +/// If some other operation timed out, use @ref cc_mqttsn_##NAME##client_reconnect() /// to refresh the connection. /// In order to change client ID and/or "keep alive" value disconnect -/// first (using mqttsn_##NAME##client_disconnect()) and then try to +/// first (using @ref cc_mqttsn_##NAME##client_disconnect()) and then try to /// connect again. /// /// @b IMPORTANT : The buffers containing client ID string, as well as /// will topic and message (if such exist) must be preserved intact /// until the connect operation is complete (provided -/// callback is invoked). The @b MqttsnWillInfo structure passed as +/// callback is invoked). The @b CC_MqttsnWillInfo structure passed as /// @b willInfo parameter may reside on the stack and be destructed /// immediately after this function returns, but the buffers its data /// members point to must be preserved. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] clientId Client ID string. /// @param[in] keepAliveSeconds Maximum number of seconds allowed between the /// messages sent to the gateway. If no publish is performed during this @@ -258,31 +258,31 @@ bool mqttsn_##NAME##client_cancel(MqttsnClientHandle client); /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_connect( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_connect( + CC_MqttsnClientHandle client, const char* clientId, unsigned short keepAliveSeconds, bool cleanSession, - const MqttsnWillInfo* willInfo, - MqttsnAsyncOpCompleteReportFn callback, + const CC_MqttsnWillInfo* willInfo, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data); /// @brief Reconnect to the gateway using previously used client ID and keep alive /// period. /// @details The invocation will work only when in "connected" or "asleep" state, -/// It will not work after invocation of mqttsn_##NAME##client_disconnect(). +/// It will not work after invocation of @ref cc_mqttsn_##NAME##client_disconnect(). /// When the operation is complete, the provided callback /// will be invoked. If successful completion is reported, the client /// is properly connected to the gateway again. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] callback Callback to be invoked when operation is complete, /// must @b NOT be NULL. /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_reconnect( - MqttsnClientHandle client, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_reconnect( + CC_MqttsnClientHandle client, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); @@ -291,11 +291,11 @@ MqttsnErrorCode mqttsn_##NAME##client_reconnect( /// will be invoked. Regardless of the reported disconnect result, /// the library assumes "disconnected" internal state and some functions, /// such as requests to publish and/or subscribe may not work. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_disconnect( - MqttsnClientHandle client, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_disconnect( + CC_MqttsnClientHandle client, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data); /// @brief Publish message with predefined topic ID. @@ -306,7 +306,7 @@ MqttsnErrorCode mqttsn_##NAME##client_disconnect( /// /// @b IMPORTANT : The buffer containing message data must be preserved /// intact until the end of the operation (provided callback is invoked). -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topicId Predefined topic ID. /// @param[in] msg Pointer to buffer containing data to be published. /// @param[in] msgLen Size of the buffer containing data to be published. @@ -319,14 +319,14 @@ MqttsnErrorCode mqttsn_##NAME##client_disconnect( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_publish_id( - MqttsnClientHandle client, - MqttsnTopicId topicId, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_publish_id( + CC_MqttsnClientHandle client, + CC_MqttsnTopicId topicId, const unsigned char* msg, unsigned msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); @@ -338,7 +338,7 @@ MqttsnErrorCode mqttsn_##NAME##client_publish_id( /// /// @b IMPORTANT : The buffer containing message data must be preserved /// intact until the end of the operation (provided callback is invoked). -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topic Topic string. /// @param[in] msg Pointer to buffer containing data to be published. /// @param[in] msgLen Size of the buffer containing data to be published. @@ -349,21 +349,21 @@ MqttsnErrorCode mqttsn_##NAME##client_publish_id( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_publish( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_publish( + CC_MqttsnClientHandle client, const char* topic, const unsigned char* msg, unsigned msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); /// @brief Subscribe to topic having predefined topic ID. /// @details When subscribe operation is complete, the provided callback /// will be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topicId Predefined topic ID. /// @param[in] qos Maximum level of quality of service the messages are sent to this client. /// @param[in] callback Callback to be invoked when operation is complete, @@ -371,11 +371,11 @@ MqttsnErrorCode mqttsn_##NAME##client_publish( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_subscribe_id( - MqttsnClientHandle client, - MqttsnTopicId topicId, - MqttsnQoS qos, - MqttsnSubscribeCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_subscribe_id( + CC_MqttsnClientHandle client, + CC_MqttsnTopicId topicId, + CC_MqttsnQoS qos, + CC_MqttsnSubscribeCompleteReportFn callback, void* data ); @@ -385,7 +385,7 @@ MqttsnErrorCode mqttsn_##NAME##client_subscribe_id( /// /// @b IMPORTANT : The buffer containing topic string must be preserved /// intact until the end of the operation (provided callback is invoked). -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topic Topic string. /// @param[in] qos Maximum level of quality of service the messages are sent to this client. /// @param[in] callback Callback to be invoked when operation is complete, @@ -393,54 +393,54 @@ MqttsnErrorCode mqttsn_##NAME##client_subscribe_id( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_subscribe( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_subscribe( + CC_MqttsnClientHandle client, const char* topic, - MqttsnQoS qos, - MqttsnSubscribeCompleteReportFn callback, + CC_MqttsnQoS qos, + CC_MqttsnSubscribeCompleteReportFn callback, void* data ); /// @brief Unsubscribe from messages having predefined topic ID. /// @details When unsubscribe operation is complete, the provided callback /// will be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topicId Predefined topic ID. /// @param[in] callback Callback to be invoked when operation is complete, /// must @b NOT be NULL. /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_unsubscribe_id( - MqttsnClientHandle client, - MqttsnTopicId topicId, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_unsubscribe_id( + CC_MqttsnClientHandle client, + CC_MqttsnTopicId topicId, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); /// @brief Unsubscribe from messages having specified topic. /// @details When unsubscribe operation is complete, the provided callback /// will be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topic Topic string. /// @param[in] callback Callback to be invoked when operation is complete, /// must @b NOT be NULL. /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_unsubscribe( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_unsubscribe( + CC_MqttsnClientHandle client, const char* topic, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); /// @brief Update will recorded with the gateway/broker. /// @details When the operation is complete, the provided callback /// will be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] willInfo New will full information. The parameter can be NULL -/// or the @b topic data member of the @ref MqttsnWillInfo struct may be +/// or the @b topic data member of the @ref CC_MqttsnWillInfo struct may be /// null. In this case the request means erase current will information /// recorded with the gateway/broker. /// @param[in] callback Callback to be invoked when operation is complete, @@ -448,17 +448,17 @@ MqttsnErrorCode mqttsn_##NAME##client_unsubscribe( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_will_update( - MqttsnClientHandle client, - const MqttsnWillInfo* willInfo, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_will_update( + CC_MqttsnClientHandle client, + const CC_MqttsnWillInfo* willInfo, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); /// @brief Update topic of the will recorded with the gateway/broker. /// @details When the operation is complete, the provided callback /// will be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topic New will topic string. The parameter can be NULL. /// In this case the request means erase current will information /// recorded with the gateway/broker. @@ -469,19 +469,19 @@ MqttsnErrorCode mqttsn_##NAME##client_will_update( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_will_topic_update( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_will_topic_update( + CC_MqttsnClientHandle client, const char* topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); /// @brief Update will message body recorded with the gateway/broker. /// @details When the operation is complete, the provided callback /// will be invoked. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] topic New will topic string. The parameter can be NULL. /// In this case the request means erase current will information /// recorded with the gateway/broker. @@ -490,11 +490,11 @@ MqttsnErrorCode mqttsn_##NAME##client_will_topic_update( /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_will_msg_update( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_will_msg_update( + CC_MqttsnClientHandle client, const unsigned char* msg, unsigned msgLen, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); @@ -502,50 +502,50 @@ MqttsnErrorCode mqttsn_##NAME##client_will_msg_update( /// @details When the operation is complete, the provided callback /// will be invoked. If successful completion is reported, the client may /// enter the low power mode and do not send any messages within the -/// "keep alive" period specified in mqttsn_##NAME##client_connect() +/// "keep alive" period specified in @ref cc_mqttsn_##NAME##client_connect() /// invocation. However, there is a need to either wake up (using -/// mqttsn_##NAME##client_reconnect()) or check for the accumulated messages -/// (using mqttsn_##NAME##client_check_messages()) within the period +/// @ref cc_mqttsn_##NAME##client_reconnect()) or check for the accumulated messages +/// (using @ref cc_mqttsn_##NAME##client_check_messages()) within the period /// specified in this function invocation. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] duration Muximal number of seconds the client will remain in /// the sleep state until next check of accumulated pending messages -/// (use mqttsn_##NAME##client_check_messages() for this purpose) or -/// full wake up (use mqttsn_##NAME##client_reconnect() for this purpose). +/// (use @ref cc_mqttsn_##NAME##client_check_messages() for this purpose) or +/// full wake up (use @ref cc_mqttsn_##NAME##client_reconnect() for this purpose). /// @param[in] callback Callback to be invoked when operation is complete, /// must @b NOT be NULL. /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_sleep( - MqttsnClientHandle client, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_sleep( + CC_MqttsnClientHandle client, unsigned short duration, - MqttsnAsyncOpCompleteReportFn callback, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); /// @brief Check for accumulated pending messages the gateway has to report. /// @details Can be invoked after successful entering the sleep state using -/// mqttsn_##NAME##client_sleep(). +/// @ref cc_mqttsn_##NAME##client_sleep(). /// According to MQTT-SN protocol specification, this function will /// force sending @b PINGREQ message to the gateway. The gateway then will /// deliver all the pending messages, which may cause multiple invocation /// of message report callback (set with -/// mqttsn_##NAME##client_set_message_report_callback()). After gateway +/// @ref cc_mqttsn_##NAME##client_set_message_report_callback()). After gateway /// reports all accumulated messages, it will send @b PINGRESP message, /// which will case invocation of the provided callback. After the /// callback is invoked, the client may return to "asleep" state and will /// be required to check messages again or wake up after number of seconds -/// provided in mqttsn_##NAME##client_sleep() call. -/// @param[in] client Handle returned by mqttsn_##NAME##client_new() function. +/// provided in @ref cc_mqttsn_##NAME##client_sleep() call. +/// @param[in] client Handle returned by @ref cc_mqttsn_##NAME##client_new() function. /// @param[in] callback Callback to be invoked when operation is complete, /// must @b NOT be NULL. /// @param[in] data Pointer to any user data, it will be passed as the first /// parameter to the invoked completion report callback, can be NULL. /// @return Error code indicating success/failure status of the operation. -MqttsnErrorCode mqttsn_##NAME##client_check_messages( - MqttsnClientHandle client, - MqttsnAsyncOpCompleteReportFn callback, +CC_MqttsnErrorCode cc_mqttsn_##NAME##client_check_messages( + CC_MqttsnClientHandle client, + CC_MqttsnAsyncOpCompleteReportFn callback, void* data ); diff --git a/client/test/CMakeLists.txt b/client/test/CMakeLists.txt index 80f6071b..1f942521 100644 --- a/client/test/CMakeLists.txt +++ b/client/test/CMakeLists.txt @@ -15,20 +15,7 @@ function (lib_common_test_client) "DataProcessor.cpp" ) add_library (${COMMON_TEST_CLIENT_LIB} STATIC ${src}) - add_dependencies(${COMMON_TEST_CLIENT_LIB} ${DEFAULT_CLIENT_LIB_TGT}) - target_link_libraries(${COMMON_TEST_CLIENT_LIB} PUBLIC cc::comms) - - if (TARGET cc::mqttsn) - target_link_libraries(${COMMON_TEST_CLIENT_LIB} PUBLIC cc::mqttsn) - endif () - - if (NOT "${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${COMMON_TEST_CLIENT_LIB} PUBLIC ${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}) - endif () - - if (TARGET ${CC_MQTTSN_EXTERNAL_TGT}) - add_dependencies(${COMMON_TEST_CLIENT_LIB} ${CC_MQTTSN_EXTERNAL_TGT}) - endif () + target_link_libraries(${COMMON_TEST_CLIENT_LIB} PUBLIC cc::${DEFAULT_CLIENT_LIB_TGT} cc::cc_mqttsn cc::comms) endfunction () ################################################################# @@ -48,11 +35,7 @@ function (test_func test_suite_name) SRC ${tests} ${valgrand_args}) - target_link_libraries(${name} PRIVATE ${COMMON_TEST_CLIENT_LIB} ${DEFAULT_CLIENT_LIB_TGT}) - target_compile_options(${name} PRIVATE - $<$:-Wno-old-style-cast -Wno-ignored-qualifiers -Wno-conversion> - $<$:-Wno-old-style-cast -Wno-ignored-qualifiers> - ) + target_link_libraries(${name} PRIVATE ${COMMON_TEST_CLIENT_LIB} cc::${DEFAULT_CLIENT_LIB_TGT} cxxtest::cxxtest) endfunction () ################################################################# @@ -64,7 +47,6 @@ endfunction () ################################################################# include_directories ( - "${CXXTEST_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}/client/src/basic" ) diff --git a/client/test/ClientBasic.th b/client/test/ClientBasic.th index d57d985a..2f3edc1e 100644 --- a/client/test/ClientBasic.th +++ b/client/test/ClientBasic.th @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,7 +9,7 @@ #include #include "comms/comms.h" -#include "mqttsn/client/common.h" +#include "cc_mqttsn_client/common.h" #include "client.h" CC_DISABLE_WARNINGS() @@ -96,7 +96,7 @@ private: typedef DataProcessor::WilltopicupdMsg WilltopicupdMsg; typedef DataProcessor::WillmsgupdMsg WillmsgupdMsg; - using TopicIdTypeVal = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; + using TopicIdTypeVal = cc_mqttsn::field::TopicIdTypeVal; static const std::string DefaultClientId; static const unsigned DefaultAdvertisePeriod = 5 * 60 * 1000; @@ -110,7 +110,7 @@ private: struct ReportedMsgInfo { - ReportedMsgInfo(const MqttsnMessageInfo& info) + ReportedMsgInfo(const CC_MqttsnMessageInfo& info) : m_topic((info.topic != nullptr) ? info.topic : std::string()), m_topicId(info.topicId), m_data(info.msg, info.msg + info.msgLen), @@ -120,22 +120,22 @@ private: } std::string m_topic; - MqttsnTopicId m_topicId = 0; + CC_MqttsnTopicId m_topicId = 0; std::vector m_data; - MqttsnQoS m_qos = MqttsnQoS_NoGwPublish; + CC_MqttsnQoS m_qos = CC_MqttsnQoS_NoGwPublish; bool m_retain = false; }; struct ReportedGwInfo { - ReportedGwInfo(std::uint16_t id, MqttsnGwStatus status) + ReportedGwInfo(std::uint16_t id, CC_MqttsnGwStatus status) : m_id(id), m_status(status) { } unsigned short m_id = 0U; - MqttsnGwStatus m_status = MqttsnGwStatus_Invalid; + CC_MqttsnGwStatus m_status = CC_MqttsnGwStatus_Invalid; }; struct TestBasicState @@ -147,17 +147,17 @@ private: std::list m_reportedMsgs; std::list m_reportedGws; std::list m_reportedGwDisconnects; - std::list m_reportedConnects; - std::list m_reportedDisconnects; - std::list m_reportedPublishes; - std::list > m_reportedSubscribes; - std::list m_reportedUnsubscribes; - std::list m_reportedWillUpdates; - std::list m_reportedWillTopicUpdates; - std::list m_reportedWillMsgUpdates; - std::list m_reportedSleeps; - std::list m_reportedReconnects; - std::list m_reportedMessageChecks; + std::list m_reportedConnects; + std::list m_reportedDisconnects; + std::list m_reportedPublishes; + std::list > m_reportedSubscribes; + std::list m_reportedUnsubscribes; + std::list m_reportedWillUpdates; + std::list m_reportedWillTopicUpdates; + std::list m_reportedWillMsgUpdates; + std::list m_reportedSleeps; + std::list m_reportedReconnects; + std::list m_reportedMessageChecks; }; template @@ -211,7 +211,7 @@ private: }); ptr->setConnectCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Connect complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -220,7 +220,7 @@ private: }); ptr->setDisconnectCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Disconnect complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -229,7 +229,7 @@ private: }); ptr->setPublishCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Publish complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -238,7 +238,7 @@ private: }); ptr->setSubsribeCompleteCallback( - [state](MqttsnAsyncOpStatus val, MqttsnQoS qos) + [state](CC_MqttsnAsyncOpStatus val, CC_MqttsnQoS qos) { TS_TRACE("Subscribe complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -247,7 +247,7 @@ private: }); ptr->setUnsubsribeCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Unsubscribe complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -256,7 +256,7 @@ private: }); ptr->setWillUpdateCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Will update complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -265,7 +265,7 @@ private: }); ptr->setWillTopicUpdateCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Will topic update complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -274,7 +274,7 @@ private: }); ptr->setWillMsgUpdateCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Will msg update complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -283,7 +283,7 @@ private: }); ptr->setSleepCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Sleep complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -292,7 +292,7 @@ private: }); ptr->setReconnectCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Reconnect complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -301,7 +301,7 @@ private: }); ptr->setCheckMessagesCompleteCallback( - [state](MqttsnAsyncOpStatus val) + [state](CC_MqttsnAsyncOpStatus val) { TS_TRACE("Check messages complete with status: " + std::to_string((int)val)); if (state != nullptr) { @@ -310,7 +310,7 @@ private: }); ptr->setMessageReportCallback( - [state](const MqttsnMessageInfo& msgInfo) + [state](const CC_MqttsnMessageInfo& msgInfo) { if (msgInfo.topic != nullptr) { TS_TRACE(std::string("Received message with topic ") + msgInfo.topic); @@ -324,7 +324,7 @@ private: } }); ptr->setGwStatusReportCallback( - [state](unsigned short gwId, MqttsnGwStatus status) + [state](unsigned short gwId, CC_MqttsnGwStatus status) { TS_TRACE(std::string("GW info reported: id=") + std::to_string(gwId) + "; status=" + std::to_string(status)); if (state != nullptr) { @@ -505,7 +505,7 @@ private: state.m_nextElapsedTicks = 1 * 1000; dataFromGw(client, gwInfoData, "GWINFO"); - verifyCb_ReportedGw(state, GwId, MqttsnGwStatus_Available); + verifyCb_ReportedGw(state, GwId, CC_MqttsnGwStatus_Available); verifyNoOtherEvent(state); } @@ -521,13 +521,13 @@ private: static const std::vector WillData{ 0x1, 0x2, 0x3, 0x4 }; - static const MqttsnQoS WillQos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS WillQos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool WillRetain = false; static const auto WillInfoCreateFunc = - []() -> MqttsnWillInfo + []() -> CC_MqttsnWillInfo { - auto willInfo = MqttsnWillInfo(); + auto willInfo = CC_MqttsnWillInfo(); willInfo.topic = WillTopic.c_str(); willInfo.msg = &WillData[0]; willInfo.msgLen = static_cast(WillData.size()); @@ -536,17 +536,17 @@ private: return willInfo; }; - static const MqttsnWillInfo WillInfo = WillInfoCreateFunc(); + static const CC_MqttsnWillInfo WillInfo = WillInfoCreateFunc(); TS_TRACE("Connecting..."); state.m_nextElapsedTicks = 0; - const MqttsnWillInfo* willInfo = nullptr; + const CC_MqttsnWillInfo* willInfo = nullptr; if (hasWill) { willInfo = &WillInfo; } auto result = client.connect(DefaultClientId.c_str(), DefaultKeepAlive, true, willInfo); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, ClientId, DefaultKeepAlive, true, willInfo != nullptr); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -570,9 +570,9 @@ private: clearState(state); } - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(client, connackMsg, "CONNACK"); - verifyCb_ReportedConnect(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedConnect(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); verifyNoOtherEvent(state); return ClientId; @@ -581,7 +581,7 @@ private: static void startClient(CommonTestClient& client) { auto result = client.start(); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); } static void doTopicRegister( @@ -589,7 +589,7 @@ private: DataProcessor& dataProc, TestBasicState& state, const std::string& topic, - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId) { clearState(state); @@ -661,7 +661,7 @@ private: const TestBasicState& state, DataProcessor& dataProc, const std::string& topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain) { bool sent = false; @@ -741,9 +741,9 @@ private: static void verifySent_RegackMsg( const TestBasicState& state, DataProcessor& dataProc, - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode = mqttsn::field::ReturnCodeVal::Accepted) + cc_mqttsn::field::ReturnCodeVal retCode = cc_mqttsn::field::ReturnCodeVal::Accepted) { bool sent = false; auto oldCb = dataProc.setRegackMsgReportCallback( @@ -765,10 +765,10 @@ private: static std::uint16_t verifySent_PublishMsg( const TestBasicState& state, DataProcessor& dataProc, - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, const DataSeq& data, TopicIdTypeVal topicIdType, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain, bool duplicate) { @@ -800,9 +800,9 @@ private: static void verifySent_PubackMsg( const TestBasicState& state, DataProcessor& dataProc, - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode = mqttsn::field::ReturnCodeVal::Accepted) + cc_mqttsn::field::ReturnCodeVal retCode = cc_mqttsn::field::ReturnCodeVal::Accepted) { bool sent = false; auto oldCb = dataProc.setPubackMsgReportCallback( @@ -884,7 +884,7 @@ private: const TestBasicState& state, DataProcessor& dataProc, const std::string& topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool duplicate) { bool sent = false; @@ -931,8 +931,8 @@ private: static std::uint16_t verifySent_SubsribeMsg( const TestBasicState& state, DataProcessor& dataProc, - MqttsnTopicId topicId, - MqttsnQoS qos, + CC_MqttsnTopicId topicId, + CC_MqttsnQoS qos, bool duplicate) { bool sent = false; @@ -1003,7 +1003,7 @@ private: static std::uint16_t verifySent_UnsubsribeMsg( const TestBasicState& state, DataProcessor& dataProc, - MqttsnTopicId topicId) + CC_MqttsnTopicId topicId) { bool sent = false; std::uint16_t msgId = 0U; @@ -1092,7 +1092,7 @@ private: const TestBasicState& state, DataProcessor& dataProc, const std::string& topic, - MqttsnQoS qos = MqttsnQoS(), + CC_MqttsnQoS qos = CC_MqttsnQoS(), bool retain = false) { bool sent = false; @@ -1143,7 +1143,7 @@ private: static void verifyCb_ReportedGw( TestBasicState& state, std::uint16_t gwId, - MqttsnGwStatus status) + CC_MqttsnGwStatus status) { TS_ASSERT(!state.m_reportedGws.empty()); if (state.m_reportedGws.empty()) { @@ -1159,9 +1159,9 @@ private: static void verifyCb_ReportedMessage( TestBasicState& state, const std::string& topic, - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, const std::vector& data, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain) { TS_ASSERT(!state.m_reportedMsgs.empty()); @@ -1191,7 +1191,7 @@ private: static void verifyCb_ReportedConnect( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedConnects.empty()); if (state.m_reportedConnects.empty()) { @@ -1204,7 +1204,7 @@ private: static void verifyCb_ReportedDisconnect( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedDisconnects.empty()); if (state.m_reportedDisconnects.empty()) { @@ -1217,7 +1217,7 @@ private: static void verifyCb_ReportedPublish( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedPublishes.empty()); if (state.m_reportedPublishes.empty()) { @@ -1230,8 +1230,8 @@ private: static void verifyCb_ReportedSubsribe( TestBasicState& state, - MqttsnAsyncOpStatus status, - MqttsnQoS qos) + CC_MqttsnAsyncOpStatus status, + CC_MqttsnQoS qos) { TS_ASSERT(!state.m_reportedSubscribes.empty()); if (state.m_reportedSubscribes.empty()) { @@ -1247,7 +1247,7 @@ private: static void verifyCb_ReportedUnsubsribe( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedUnsubscribes.empty()); if (state.m_reportedUnsubscribes.empty()) { @@ -1262,7 +1262,7 @@ private: static void verifyCb_ReportedWillUpdate( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedWillUpdates.empty()); if (state.m_reportedWillUpdates.empty()) { @@ -1277,7 +1277,7 @@ private: static void verifyCb_ReportedWillTopicUpdate( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedWillTopicUpdates.empty()); if (state.m_reportedWillTopicUpdates.empty()) { @@ -1292,7 +1292,7 @@ private: static void verifyCb_ReportedWillMsgUpdate( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedWillMsgUpdates.empty()); if (state.m_reportedWillMsgUpdates.empty()) { @@ -1307,7 +1307,7 @@ private: static void verifyCb_ReportedSleep( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedSleeps.empty()); if (state.m_reportedSleeps.empty()) { @@ -1322,7 +1322,7 @@ private: static void verifyCb_ReportedReconnect( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedReconnects.empty()); if (state.m_reportedReconnects.empty()) { @@ -1337,7 +1337,7 @@ private: static void verifyCb_ReportedMessageChecks( TestBasicState& state, - MqttsnAsyncOpStatus status) + CC_MqttsnAsyncOpStatus status) { TS_ASSERT(!state.m_reportedMessageChecks.empty()); if (state.m_reportedMessageChecks.empty()) { @@ -1350,12 +1350,12 @@ private: state.m_reportedMessageChecks.pop_front(); } - static MqttsnQoS transformQos(mqttsn::field::QosVal val) + static CC_MqttsnQoS transformQos(cc_mqttsn::field::QosVal val) { return CommonTestClient::transformQos(val); } - static mqttsn::field::QosVal transformQos(MqttsnQoS val) + static cc_mqttsn::field::QosVal transformQos(CC_MqttsnQoS val) { return CommonTestClient::transformQos(val); } @@ -1398,13 +1398,13 @@ void ClientBasic::test2() state.m_nextElapsedTicks = 1 * 1000; dataFromGw(*client, gwInfoData, "GWINFO"); - verifyCb_ReportedGw(state, GwId, MqttsnGwStatus_Available); + verifyCb_ReportedGw(state, GwId, CC_MqttsnGwStatus_Available); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, MaxPeriod); verifyNoOtherEvent(state); clearState(state); client->tick(); - verifyCb_ReportedGw(state, GwId, MqttsnGwStatus_TimedOut); + verifyCb_ReportedGw(state, GwId, CC_MqttsnGwStatus_TimedOut); verifySent_SearchgwMsg(state, dataProc, DefaultBroadcastRadius); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -1415,13 +1415,13 @@ void ClientBasic::test2() state.m_nextElapsedTicks = 1 * 1000; dataFromGw(*client, advertiseData, "ADVERTISE"); - verifyCb_ReportedGw(state, GwId, MqttsnGwStatus_Available); + verifyCb_ReportedGw(state, GwId, CC_MqttsnGwStatus_Available); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultAdvertisePeriod + 1000) * 3); verifyNoOtherEvent(state); clearState(state); client->tick(); - verifyCb_ReportedGw(state, GwId, MqttsnGwStatus_TimedOut); + verifyCb_ReportedGw(state, GwId, CC_MqttsnGwStatus_TimedOut); verifySent_SearchgwMsg(state, dataProc, DefaultBroadcastRadius); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -1433,7 +1433,7 @@ void ClientBasic::test3() DataProcessor dataProc; struct Test3State : public TestBasicState { - MqttsnAsyncOpStatus m_connectionStatus = MqttsnAsyncOpStatus_Invalid; + CC_MqttsnAsyncOpStatus m_connectionStatus = CC_MqttsnAsyncOpStatus_Invalid; }; Test3State state; @@ -1448,17 +1448,17 @@ void ClientBasic::test3() static const unsigned short KeepAlive = 60; client->setConnectCompleteCallback( - [&](MqttsnAsyncOpStatus val) + [&](CC_MqttsnAsyncOpStatus val) { // First connect is expected to be timed out TS_TRACE("Connect complete with status: " + std::to_string((int)val)); - TS_ASSERT_EQUALS(val, MqttsnAsyncOpStatus_NoResponse); + TS_ASSERT_EQUALS(val, CC_MqttsnAsyncOpStatus_NoResponse); client->setConnectCompleteCallback( - [&](MqttsnAsyncOpStatus val2) + [&](CC_MqttsnAsyncOpStatus val2) { TS_TRACE("Connect complete with status: " + std::to_string((int)val2)); - TS_ASSERT_EQUALS(val2, MqttsnAsyncOpStatus_Successful); + TS_ASSERT_EQUALS(val2, CC_MqttsnAsyncOpStatus_Successful); state.m_connectionStatus = val2; }); @@ -1466,7 +1466,7 @@ void ClientBasic::test3() auto result2 = client->connect(ClientId.c_str(), KeepAlive, true, nullptr); - TS_ASSERT_EQUALS(result2, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result2, CC_MqttsnErrorCode_Success); }); TS_TRACE("Connecting..."); @@ -1474,7 +1474,7 @@ void ClientBasic::test3() auto result = client->connect(ClientId.c_str(), KeepAlive, true, nullptr); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, ClientId, KeepAlive, true, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -1498,10 +1498,10 @@ void ClientBasic::test3() verifySent_ConnectMsg(state, dataProc, ClientId, KeepAlive, true, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); clearState(state); - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); - TS_ASSERT_EQUALS(state.m_connectionStatus, MqttsnAsyncOpStatus_Successful); + TS_ASSERT_EQUALS(state.m_connectionStatus, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, KeepAlive * 1000); verifyNoOtherEvent(state); } @@ -1524,11 +1524,11 @@ void ClientBasic::test4() static const std::vector WillData{ 0x1, 0x2, 0x3, 0x4 }; - static const MqttsnQoS WillQos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS WillQos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool WillRetain = false; TS_TRACE("Connecting..."); - auto willInfo = MqttsnWillInfo(); + auto willInfo = CC_MqttsnWillInfo(); willInfo.topic = WillTopic.c_str(); willInfo.msg = &WillData[0]; willInfo.msgLen = static_cast(WillData.size()); @@ -1539,7 +1539,7 @@ void ClientBasic::test4() auto result = client->connect(ClientId.c_str(), KeepAlive, true, &willInfo); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, ClientId, KeepAlive, true, true); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -1548,7 +1548,7 @@ void ClientBasic::test4() // Send ack message, check ignored state.m_nextElapsedTicks = 1000; - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); // Ack must be ignored TS_ASSERT(state.m_nextOutput.empty()) @@ -1587,7 +1587,7 @@ void ClientBasic::test4() dataFromGw(*client, connackMsg, "CONNACK"); // check connected - verifyCb_ReportedConnect(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedConnect(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (KeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); } @@ -1693,7 +1693,7 @@ void ClientBasic::test7() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->disconnect(); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc); verifyNoOtherEvent(state); @@ -1702,7 +1702,7 @@ void ClientBasic::test7() state.m_nextElapsedTicks = 1000; auto disconnectMsg = dataProc.prepareDisconnectMsg(); dataFromGw(*client, disconnectMsg, "DISCONNECT"); - verifyCb_ReportedDisconnect(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedDisconnect(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -1723,7 +1723,7 @@ void ClientBasic::test8() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->disconnect(); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -1744,7 +1744,7 @@ void ClientBasic::test8() client->tick(); TS_ASSERT(state.m_nextOutput.empty()); - verifyCb_ReportedDisconnect(state, MqttsnAsyncOpStatus_NoResponse); + verifyCb_ReportedDisconnect(state, CC_MqttsnAsyncOpStatus_NoResponse); verifyNoOtherEvent(state); } @@ -1767,7 +1767,7 @@ void ClientBasic::test9() state.m_nextElapsedTicks = 0; auto result = client->connect(ClientId.c_str(), KeepAlive, true, nullptr); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, ClientId, KeepAlive, true, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -1780,7 +1780,7 @@ void ClientBasic::test9() bool cancelResult = client->cancel(); TS_ASSERT(cancelResult); - verifyCb_ReportedConnect(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedConnect(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); } @@ -1802,7 +1802,7 @@ void ClientBasic::test10() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->disconnect(); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -1810,7 +1810,7 @@ void ClientBasic::test10() state.m_nextElapsedTicks = 1000; bool cancelResult = client->cancel(); TS_ASSERT(cancelResult); - verifyCb_ReportedDisconnect(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedDisconnect(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); } @@ -1828,9 +1828,9 @@ void ClientBasic::test11() doConnect(*client, dataProc, state); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - static const MqttsnTopicId TopicId = 0x0123; + static const CC_MqttsnTopicId TopicId = 0x0123; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const MqttsnQoS Qos = MqttsnQoS_AtMostOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtMostOnceDelivery; static const bool Retain = true; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -1839,9 +1839,9 @@ void ClientBasic::test11() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publishId(TopicId, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -1856,9 +1856,9 @@ void ClientBasic::test12() doGwInfo(*client, dataProc, state); - static const MqttsnTopicId TopicId = 0x0123; + static const CC_MqttsnTopicId TopicId = 0x0123; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const MqttsnQoS Qos = MqttsnQoS_NoGwPublish; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_NoGwPublish; static const bool Retain = true; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -1866,16 +1866,16 @@ void ClientBasic::test12() clearState(state); state.m_nextElapsedTicks = 1000; - auto result = client->publishId(TopicId, &Data[0], Data.size(), MqttsnQoS_AtMostOnceDelivery, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + auto result = client->publishId(TopicId, &Data[0], Data.size(), CC_MqttsnQoS_AtMostOnceDelivery, Retain); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); TS_ASSERT(state.m_reportedPublishes.empty()); TS_ASSERT(state.m_nextOutput.empty()); verifyNoOtherEvent(state); result = client->publishId(TopicId, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -1894,9 +1894,9 @@ void ClientBasic::test13() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - static const MqttsnTopicId TopicId = 0x0123; + static const CC_MqttsnTopicId TopicId = 0x0123; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -1905,7 +1905,7 @@ void ClientBasic::test13() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publishId(TopicId, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdTypeVal::PredefinedTopicId, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); TS_ASSERT(state.m_reportedPublishes.empty()); @@ -1920,16 +1920,16 @@ void ClientBasic::test13() clearState(state); state.m_nextElapsedTicks = 1000; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId + 1, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, static_cast(msgId + 1), cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); TS_ASSERT(state.m_reportedPublishes.empty()); TS_ASSERT(state.m_nextOutput.empty()); // must be ignored verifyNoOtherEvent(state); clearState(state); - pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -1948,9 +1948,9 @@ void ClientBasic::test14() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - static const MqttsnTopicId TopicId = 0xabcd; + static const CC_MqttsnTopicId TopicId = 0xabcd; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const MqttsnQoS Qos = MqttsnQoS_ExactlyOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_ExactlyOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -1960,7 +1960,7 @@ void ClientBasic::test14() static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; auto result = client->publishId(TopicId, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); TS_ASSERT(state.m_reportedPublishes.empty()); @@ -1968,9 +1968,9 @@ void ClientBasic::test14() clearState(state); state.m_nextElapsedTicks = NextTicks; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_InvalidId); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_InvalidId); verifyNoOtherEvent(state); } @@ -1989,9 +1989,9 @@ void ClientBasic::test15() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - static const MqttsnTopicId TopicId = 0xabcd; + static const CC_MqttsnTopicId TopicId = 0xabcd; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const MqttsnQoS Qos = MqttsnQoS_ExactlyOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_ExactlyOnceDelivery; static const bool Retain = true; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2000,7 +2000,7 @@ void ClientBasic::test15() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publishId(TopicId, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -2027,7 +2027,7 @@ void ClientBasic::test15() state.m_nextElapsedTicks = 1000; auto pubcompMsg = dataProc.preparePubcompMsg(msgId); dataFromGw(*client, pubcompMsg, "PUBCOMP"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - 1000); verifyNoOtherEvent(state); } @@ -2049,18 +2049,18 @@ void ClientBasic::test16() static const std::string Topic("this/is/topic"); static const auto TopicIdType = TopicIdTypeVal::Normal; - static const MqttsnQoS Qos = MqttsnQoS_AtMostOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtMostOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef }; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); TS_ASSERT(state.m_reportedPublishes.empty()); @@ -2068,26 +2068,26 @@ void ClientBasic::test16() clearState(state); state.m_nextElapsedTicks = 1000; - auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId + 1, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = dataProc.prepareRegackMsg(TopicId, static_cast(msgId + 1), cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); TS_ASSERT(state.m_reportedPublishes.empty()); TS_ASSERT(state.m_nextOutput.empty()); verifyNoOtherEvent(state); - regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000 - state.m_nextElapsedTicks); verifyNoOtherEvent(state); } @@ -2107,7 +2107,7 @@ void ClientBasic::test17() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); static const std::string Topic("this/is/topic"); - static const MqttsnQoS Qos = MqttsnQoS_AtMostOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtMostOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2116,7 +2116,7 @@ void ClientBasic::test17() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); TS_ASSERT(state.m_reportedPublishes.empty()); @@ -2138,7 +2138,7 @@ void ClientBasic::test17() clearState(state); client->tick(); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_NoResponse); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_NoResponse); TS_ASSERT(state.m_nextOutput.empty()); verifyNoOtherEvent(state); @@ -2148,9 +2148,9 @@ void ClientBasic::test17() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); - verifyCb_ReportedReconnect(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedReconnect(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -2171,17 +2171,17 @@ void ClientBasic::test18() static const std::string Topic("this/is/topic"); static const auto TopicIdType = TopicIdTypeVal::Normal; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef }; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); TS_ASSERT(state.m_reportedPublishes.empty()); @@ -2203,7 +2203,7 @@ void ClientBasic::test18() clearState(state); state.m_nextElapsedTicks = 1000; - auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); TS_ASSERT(state.m_reportedPublishes.empty()); verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); @@ -2221,9 +2221,9 @@ void ClientBasic::test18() clearState(state); static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); } @@ -2245,18 +2245,18 @@ void ClientBasic::test19() static const std::string Topic("this/is/topic"); static const auto TopicIdType = TopicIdTypeVal::Normal; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef }; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); TS_ASSERT(state.m_reportedPublishes.empty()); auto msgId = verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -2264,7 +2264,7 @@ void ClientBasic::test19() clearState(state); state.m_nextElapsedTicks = NextTicks; - auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); TS_ASSERT(state.m_reportedPublishes.empty()); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); @@ -2273,15 +2273,15 @@ void ClientBasic::test19() clearState(state); state.m_nextElapsedTicks = NextTicks; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); clearState(state); result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); TS_ASSERT(state.m_reportedPublishes.empty()); @@ -2289,7 +2289,7 @@ void ClientBasic::test19() clearState(state); state.m_nextElapsedTicks = NextTicks; - pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromGw(*client, pubackMsg, "PUBACK"); TS_ASSERT(state.m_reportedPublishes.empty()); msgId = verifySent_RegisterMsg(state, dataProc, Topic); @@ -2298,7 +2298,7 @@ void ClientBasic::test19() clearState(state); state.m_nextElapsedTicks = NextTicks; - regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); TS_ASSERT(state.m_reportedPublishes.empty()); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); @@ -2307,9 +2307,9 @@ void ClientBasic::test19() clearState(state); state.m_nextElapsedTicks = NextTicks; - pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); } @@ -2331,18 +2331,18 @@ void ClientBasic::test20() static const std::string Topic("this/is/topic"); static const auto TopicIdType = TopicIdTypeVal::Normal; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef }; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); TS_ASSERT(state.m_reportedPublishes.empty()); auto msgId = verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -2350,7 +2350,7 @@ void ClientBasic::test20() clearState(state); state.m_nextElapsedTicks = NextTicks; - auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); TS_ASSERT(state.m_reportedPublishes.empty()); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); @@ -2359,9 +2359,9 @@ void ClientBasic::test20() clearState(state); state.m_nextElapsedTicks = NextTicks; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_InvalidId); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_InvalidId); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); } @@ -2383,18 +2383,18 @@ void ClientBasic::test21() static const std::string Topic("this/is/topic"); static const auto TopicIdType = TopicIdTypeVal::Normal; - static const MqttsnQoS Qos = MqttsnQoS_ExactlyOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_ExactlyOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef }; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -2402,18 +2402,18 @@ void ClientBasic::test21() clearState(state); state.m_nextElapsedTicks = NextTicks; client->cancel(); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_RegisterMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = NextTicks; - auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = dataProc.prepareRegackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -2429,12 +2429,12 @@ void ClientBasic::test21() clearState(state); state.m_nextElapsedTicks = NextTicks; client->cancel(); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); clearState(state); result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -2450,7 +2450,7 @@ void ClientBasic::test21() state.m_nextElapsedTicks = NextTicks; auto pubcompMsg = dataProc.preparePubcompMsg(msgId); dataFromGw(*client, pubcompMsg, "PUBCOMP"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); } @@ -2472,9 +2472,9 @@ void ClientBasic::test22() static const std::string Topic("this/is/topic"); static const std::uint16_t RegMsgId = 0x1234; - static const MqttsnTopicId TopicId = 0x2222; + static const CC_MqttsnTopicId TopicId = 0x2222; static const auto TopicIdType = TopicIdTypeVal::Normal; - static const MqttsnQoS Qos = MqttsnQoS_AtMostOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtMostOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2490,9 +2490,9 @@ void ClientBasic::test22() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publish(Topic, &Data[0], Data.size(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdType, Qos, Retain, false); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -2513,11 +2513,11 @@ void ClientBasic::test23() static const std::string Topic1("this/is/topic1"); static const std::string Topic2("this/is/topic2"); - static const MqttsnTopicId Topic1Id = 0x1234; - static const MqttsnTopicId Topic2Id = 0x4321; + static const CC_MqttsnTopicId Topic1Id = 0x1234; + static const CC_MqttsnTopicId Topic2Id = 0x4321; static const std::uint16_t RegMsgId = 0x2222; - static const MqttsnQoS Qos1 = MqttsnQoS_ExactlyOnceDelivery; - static const MqttsnQoS Qos2 = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos1 = CC_MqttsnQoS_ExactlyOnceDelivery; + static const CC_MqttsnQoS Qos2 = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2526,14 +2526,14 @@ void ClientBasic::test23() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->publish(Topic1, &Data[0], Data.size(), Qos1, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_RegisterMsg(state, dataProc, Topic1); verifyNoOtherEvent(state); clearState(state); static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; - auto regackMsg = dataProc.prepareRegackMsg(Topic1Id, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = dataProc.prepareRegackMsg(Topic1Id, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, regackMsg, "REGACK"); msgId = verifySent_PublishMsg(state, dataProc, Topic1Id, Data, TopicIdTypeVal::Normal, Qos1, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -2554,14 +2554,14 @@ void ClientBasic::test23() state.m_nextElapsedTicks = NextTicks; auto pubcompMsg = dataProc.preparePubcompMsg(msgId); dataFromGw(*client, pubcompMsg, "PUBCOMP"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (DefaultKeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->publish(Topic2, &Data[0], Data.size(), Qos2, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, Topic2Id, Data, TopicIdTypeVal::Normal, Qos2, Retain, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -2569,9 +2569,9 @@ void ClientBasic::test23() clearState(state); state.m_nextElapsedTicks = 1000; - auto pubackMsg = dataProc.preparePubackMsg(Topic2Id, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(Topic2Id, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -2590,10 +2590,10 @@ void ClientBasic::test24() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; static const std::uint16_t MsgId = 0x5555; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const auto Qos = mqttsn::field::QosVal::AtMostOnceDelivery; + static const auto Qos = cc_mqttsn::field::QosVal::AtMostOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2613,7 +2613,7 @@ void ClientBasic::test24() clearState(state); state.m_nextElapsedTicks = 1000; - publishMsg = dataProc.preparePublishMsg(TopicId, MsgId + 1, Data, TopicIdTypeVal::Normal, Qos, Retain, false); + publishMsg = dataProc.preparePublishMsg(TopicId, static_cast(MsgId + 1), Data, TopicIdTypeVal::Normal, Qos, Retain, false); dataFromGw(*client, publishMsg, "PUBLISH"); verifyCb_ReportedMessage(state, Topic, 0, Data, transformQos(Qos), Retain); TS_ASSERT(state.m_nextOutput.empty()); @@ -2622,9 +2622,9 @@ void ClientBasic::test24() clearState(state); state.m_nextElapsedTicks = 1000; - publishMsg = dataProc.preparePublishMsg(TopicId + 1, MsgId + 2, Data, TopicIdTypeVal::Normal, Qos, Retain, false); + publishMsg = dataProc.preparePublishMsg(static_cast(TopicId + 1), static_cast(MsgId + 2), Data, TopicIdTypeVal::Normal, Qos, Retain, false); dataFromGw(*client, publishMsg, "PUBLISH"); - verifySent_PubackMsg(state, dataProc, TopicId + 1, MsgId + 2, mqttsn::field::ReturnCodeVal::InvalidTopicId); + verifySent_PubackMsg(state, dataProc, static_cast(TopicId + 1), static_cast(MsgId + 2), cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); TS_ASSERT(state.m_reportedMsgs.empty()); verifyNoOtherEvent(state); } @@ -2647,14 +2647,14 @@ void ClientBasic::test25() static const std::string Topic = "/this/is/topic"; static const std::uint16_t RegMsgId = 0x1222; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); doTopicRegister(*client, dataProc, state, Topic, TopicId, RegMsgId); static const std::uint16_t MsgId = 0x5555; static const auto TopicIdType = TopicIdTypeVal::Normal; - static const auto Qos = mqttsn::field::QosVal::AtLeastOnceDelivery; + static const auto Qos = cc_mqttsn::field::QosVal::AtLeastOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2679,7 +2679,7 @@ void ClientBasic::test25() clearState(state); state.m_nextElapsedTicks = 1000; - expectedMsgId = MsgId + 1; + expectedMsgId = static_cast(MsgId + 1); publishMsg = dataProc.preparePublishMsg(TopicId, expectedMsgId, Data, TopicIdType, Qos, Retain, true); dataFromGw(*client, publishMsg, "PUBLISH"); verifySent_PubackMsg(state, dataProc, TopicId, expectedMsgId); @@ -2705,14 +2705,14 @@ void ClientBasic::test26() static const std::string Topic = "/this/is/topic"; static const std::uint16_t RegMsgId = 0x1222; - static const MqttsnTopicId TopicId = 0x1234; + static const CC_MqttsnTopicId TopicId = 0x1234; clearState(state); doTopicRegister(*client, dataProc, state, Topic, TopicId, RegMsgId); static const std::uint16_t MsgId = 0x5555; static const auto TopicIdType = TopicIdTypeVal::PredefinedTopicId; - static const auto Qos = mqttsn::field::QosVal::ExactlyOnceDelivery; + static const auto Qos = cc_mqttsn::field::QosVal::ExactlyOnceDelivery; static const bool Retain = false; static const std::vector Data = { 0x01, 0x02, 0x03, 0x04, 0xab, 0xcd, 0xef @@ -2786,18 +2786,18 @@ void ClientBasic::test27() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - static const MqttsnTopicId TopicId = 0x1234; - static const auto Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnTopicId TopicId = 0x1234; + static const auto Qos = CC_MqttsnQoS_AtLeastOnceDelivery; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->subscribe(TopicId, Qos); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_SubsribeMsg(state, dataProc, TopicId, Qos, false); clearState(state); state.m_nextElapsedTicks = 1000; - auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId + 1, mqttsn::field::ReturnCodeVal::Accepted); + auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, static_cast(msgId + 1), cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); TS_ASSERT(state.m_reportedSubscribes.empty()); verifyNoOtherEvent(state); @@ -2810,9 +2810,9 @@ void ClientBasic::test27() clearState(state); state.m_nextElapsedTicks = 1000; - subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Successful, Qos); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Successful, Qos); verifyNoOtherEvent(state); } @@ -2829,11 +2829,11 @@ void ClientBasic::test28() clearState(state); static const std::string Topic("/this/is/topic"); - static const auto Qos1 = MqttsnQoS_ExactlyOnceDelivery; - static const auto Qos2 = MqttsnQoS_AtLeastOnceDelivery; + static const auto Qos1 = CC_MqttsnQoS_ExactlyOnceDelivery; + static const auto Qos2 = CC_MqttsnQoS_AtLeastOnceDelivery; auto result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); clearState(state); doConnect(*client, dataProc, state); @@ -2843,36 +2843,36 @@ void ClientBasic::test28() clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos1, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos2); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Busy); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Busy); verifyNoOtherEvent(state); - static const MqttsnTopicId TopicId = 0x1111; + static const CC_MqttsnTopicId TopicId = 0x1111; clearState(state); state.m_nextElapsedTicks = 1000; - auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, mqttsn::field::ReturnCodeVal::Congestion); + auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Congestion); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Congestion, Qos2); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Congestion, Qos2); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos1, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Successful, Qos2); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Successful, Qos2); verifyNoOtherEvent(state); static const DataSeq Data = { @@ -2883,15 +2883,15 @@ void ClientBasic::test28() clearState(state); state.m_nextElapsedTicks = 1000; result = client->publish(Topic, &Data[0], Data.size(), Qos2, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdTypeVal::Normal, Qos2, Retain, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -2911,12 +2911,12 @@ void ClientBasic::test29() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); static const std::string Topic("/this/is/topic"); - static const auto Qos = MqttsnQoS_ExactlyOnceDelivery; + static const auto Qos = CC_MqttsnQoS_ExactlyOnceDelivery; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->subscribe(Topic, Qos); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_SubsribeMsg(state, dataProc, Topic, Qos, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -2924,13 +2924,13 @@ void ClientBasic::test29() clearState(state); state.m_nextElapsedTicks = 5000; client->cancel(); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Aborted, Qos); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Aborted, Qos); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_SubsribeMsg(state, dataProc, Topic, Qos, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -2949,23 +2949,23 @@ void ClientBasic::test29() clearState(state); client->tick(); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_NoResponse, Qos); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_NoResponse, Qos); verifyNoOtherEvent(state); - static const MqttsnTopicId TopicId = 0x1233; + static const CC_MqttsnTopicId TopicId = 0x1233; clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(TopicId, Qos); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_SubsribeMsg(state, dataProc, TopicId, Qos, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), 0, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), 0, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_InvalidId, Qos); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_InvalidId, Qos); verifyNoOtherEvent(state); } @@ -2985,8 +2985,8 @@ void ClientBasic::test30() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); static const std::string Topic("/this/is/topic"); - static const MqttsnTopicId TopicId = 0x1111; - static const auto Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnTopicId TopicId = 0x1111; + static const auto Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const std::uint16_t RegMsgId = 1; clearState(state); @@ -2999,16 +2999,16 @@ void ClientBasic::test30() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->subscribe(Topic, Qos); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); // Even if topic is pre-registered, use subscribe by topic name auto msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Successful, Qos); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Successful, Qos); verifyNoOtherEvent(state); static const DataSeq Data = { 0x0, 0x1, 0x2 }; @@ -3021,7 +3021,7 @@ void ClientBasic::test30() clearState(state); state.m_nextElapsedTicks = 1000; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromGw(*client, pubackMsg, "PUBACK"); TS_ASSERT(state.m_reportedPublishes.empty()); verifySent_RegisterMsg(state, dataProc, Topic); @@ -3030,30 +3030,30 @@ void ClientBasic::test30() clearState(state); state.m_nextElapsedTicks = 1000; client->cancel(); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + subackMsg = dataProc.prepareSubackMsg(transformQos(Qos), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Successful, Qos); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Successful, Qos); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; client->publish(Topic, &Data[0], Data.size(), Qos, Retain); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdTypeVal::Normal, Qos, Retain, false); - pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3071,7 +3071,7 @@ void ClientBasic::test31() static const std::string Topic("/this/is/topic"); auto result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); clearState(state); doConnect(*client, dataProc, state); @@ -3081,21 +3081,21 @@ void ClientBasic::test31() clearState(state); state.m_nextElapsedTicks = 1000; result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_UnsubsribeMsg(state, dataProc, Topic); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Busy); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Busy); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; auto unsubackMsg = dataProc.prepareUnsubackMsg(msgId); dataFromGw(*client, unsubackMsg, "UNSUBACK"); - verifyCb_ReportedUnsubsribe(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedUnsubsribe(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3110,10 +3110,10 @@ void ClientBasic::test32() doGwInfo(*client, dataProc, state); clearState(state); - static const MqttsnTopicId TopicId = 1111; + static const CC_MqttsnTopicId TopicId = 1111; auto result = client->unsubscribe(TopicId); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); clearState(state); doConnect(*client, dataProc, state); @@ -3123,24 +3123,24 @@ void ClientBasic::test32() clearState(state); state.m_nextElapsedTicks = 1000; result = client->unsubscribe(TopicId); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_UnsubsribeMsg(state, dataProc, TopicId); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->unsubscribe(TopicId); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Busy); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Busy); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; client->cancel(); - verifyCb_ReportedUnsubsribe(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedUnsubsribe(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); result = client->unsubscribe(TopicId); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_UnsubsribeMsg(state, dataProc, TopicId); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3159,18 +3159,18 @@ void ClientBasic::test32() clearState(state); client->tick(); - verifyCb_ReportedUnsubsribe(state, MqttsnAsyncOpStatus_NoResponse); + verifyCb_ReportedUnsubsribe(state, CC_MqttsnAsyncOpStatus_NoResponse); verifyNoOtherEvent(state); result = client->unsubscribe(TopicId); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_UnsubsribeMsg(state, dataProc, TopicId); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); auto unsubackMsg = dataProc.prepareUnsubackMsg(msgId); dataFromGw(*client, unsubackMsg, "UNSUBACK"); - verifyCb_ReportedUnsubsribe(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedUnsubsribe(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3189,7 +3189,7 @@ void ClientBasic::test33() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); static const std::string Topic("/bla/bla/bla"); - static const MqttsnTopicId TopicId = 1111; + static const CC_MqttsnTopicId TopicId = 1111; static const std::uint16_t RegMsgId = 5555; clearState(state); state.m_nextElapsedTicks = 1000; @@ -3198,7 +3198,7 @@ void ClientBasic::test33() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); // Unsubscribe by full topic even if pre-registered auto msgId = verifySent_UnsubsribeMsg(state, dataProc, Topic); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); @@ -3206,7 +3206,7 @@ void ClientBasic::test33() auto unsubackMsg = dataProc.prepareUnsubackMsg(msgId); dataFromGw(*client, unsubackMsg, "UNSUBACK"); - verifyCb_ReportedUnsubsribe(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedUnsubsribe(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3225,34 +3225,34 @@ void ClientBasic::test34() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); static const std::string WillTopic("will/topic"); - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->willTopicUpdate(WillTopic, Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WilltopicupdMsg(state, dataProc, WillTopic, Qos, Retain); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto msgRespMsg = dataProc.prepareWillmsgrespMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto msgRespMsg = dataProc.prepareWillmsgrespMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, msgRespMsg, "WILLMSGRESP"); TS_ASSERT(state.m_nextOutput.empty()); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto topicRespMsg = dataProc.prepareWilltopicrespMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto topicRespMsg = dataProc.prepareWilltopicrespMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, topicRespMsg, "WILLTOPICRESP"); - verifyCb_ReportedWillTopicUpdate(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedWillTopicUpdate(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); static const DataSeq Data = {0x0, 0x2, 0x3}; result = client->willMsgUpdate(&Data[0], Data.size()); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WillmsgupdMsg(state, dataProc, Data); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3269,7 +3269,7 @@ void ClientBasic::test34() clearState(state); state.m_nextElapsedTicks = 1000; dataFromGw(*client, msgRespMsg, "WILLMSGRESP"); - verifyCb_ReportedWillMsgUpdate(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedWillMsgUpdate(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3288,13 +3288,13 @@ void ClientBasic::test35() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); static const std::string WillTopic("will/topic"); - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->willTopicUpdate(WillTopic, Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WilltopicupdMsg(state, dataProc, WillTopic, Qos, Retain); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3315,7 +3315,7 @@ void ClientBasic::test35() clearState(state); client->tick(); - verifyCb_ReportedWillTopicUpdate(state, MqttsnAsyncOpStatus_NoResponse); + verifyCb_ReportedWillTopicUpdate(state, CC_MqttsnAsyncOpStatus_NoResponse); verifyNoOtherEvent(state); } @@ -3335,26 +3335,26 @@ void ClientBasic::test36() static const std::string WillTopic("will/topic"); static const DataSeq Data; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->willTopicUpdate(WillTopic.c_str(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WilltopicupdMsg(state, dataProc, WillTopic, Qos, Retain); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto topicRespMsg = dataProc.prepareWilltopicrespMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto topicRespMsg = dataProc.prepareWilltopicrespMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, topicRespMsg, "WILLTOPICRESP"); - verifyCb_ReportedWillTopicUpdate(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedWillTopicUpdate(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); result = client->willMsgUpdate(nullptr, 0); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WillmsgupdMsg(state, dataProc, Data); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3375,7 +3375,7 @@ void ClientBasic::test36() clearState(state); client->tick(); - verifyCb_ReportedWillMsgUpdate(state, MqttsnAsyncOpStatus_NoResponse); + verifyCb_ReportedWillMsgUpdate(state, CC_MqttsnAsyncOpStatus_NoResponse); verifyNoOtherEvent(state); } @@ -3395,13 +3395,13 @@ void ClientBasic::test37() static const std::string WillTopic("will/topic"); static const DataSeq Data; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->willTopicUpdate(WillTopic.c_str(), Qos, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WilltopicupdMsg(state, dataProc, WillTopic, Qos, Retain); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3409,13 +3409,13 @@ void ClientBasic::test37() clearState(state); state.m_nextElapsedTicks = 1000; client->cancel(); - verifyCb_ReportedWillTopicUpdate(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedWillTopicUpdate(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->willMsgUpdate(nullptr, 0); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_WillmsgupdMsg(state, dataProc, Data); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3423,12 +3423,12 @@ void ClientBasic::test37() clearState(state); state.m_nextElapsedTicks = 1000; client->cancel(); - verifyCb_ReportedWillMsgUpdate(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedWillMsgUpdate(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto msgRespMsg = dataProc.prepareWillmsgrespMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto msgRespMsg = dataProc.prepareWillmsgrespMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, msgRespMsg, "WILLMSGRESP"); TS_ASSERT(state.m_nextOutput.empty()); verifyNoOtherEvent(state); @@ -3452,7 +3452,7 @@ void ClientBasic::test38() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->sleep(Duration); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc, Duration); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3460,13 +3460,13 @@ void ClientBasic::test38() clearState(state); state.m_nextElapsedTicks = 1000; client->cancel(); - verifyCb_ReportedSleep(state, MqttsnAsyncOpStatus_Aborted); + verifyCb_ReportedSleep(state, CC_MqttsnAsyncOpStatus_Aborted); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->sleep(Duration); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc, Duration); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3485,13 +3485,13 @@ void ClientBasic::test38() clearState(state); client->tick(); - verifyCb_ReportedSleep(state, MqttsnAsyncOpStatus_NoResponse); + verifyCb_ReportedSleep(state, CC_MqttsnAsyncOpStatus_NoResponse); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->sleep(Duration); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc, Duration); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3500,7 +3500,7 @@ void ClientBasic::test38() state.m_nextElapsedTicks = 1000; auto disconnectMsg = dataProc.prepareDisconnectMsg(Duration); dataFromGw(*client, disconnectMsg, "DISCONNECT"); - verifyCb_ReportedSleep(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedSleep(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, 0); verifyNoOtherEvent(state); @@ -3508,7 +3508,7 @@ void ClientBasic::test38() state.m_nextElapsedTicks = 1000; static const std::string ClientId = "test_client"; result = client->connect(ClientId.c_str(), DefaultKeepAlive, true, nullptr); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_AlreadyConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_AlreadyConnected); verifyNoOtherEvent(state); } @@ -3527,13 +3527,13 @@ void ClientBasic::test39() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); auto result = client->checkMessages(); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotSleeping); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotSleeping); static const std::uint16_t Duration = 10000; clearState(state); state.m_nextElapsedTicks = 1000; result = client->sleep(Duration); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_DisconnectMsg(state, dataProc, Duration); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3542,7 +3542,7 @@ void ClientBasic::test39() state.m_nextElapsedTicks = 1000; auto disconnectMsg = dataProc.prepareDisconnectMsg(Duration); dataFromGw(*client, disconnectMsg, "DISCONNECT"); - verifyCb_ReportedSleep(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedSleep(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, 0); verifyNoOtherEvent(state); @@ -3553,10 +3553,10 @@ void ClientBasic::test39() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); - static const MqttsnTopicId TopicId = 0x1111; + static const CC_MqttsnTopicId TopicId = 0x1111; static const std::uint16_t MsgId = 0x2222; static const DataSeq Data = {0x0, 0x1, 0x2}; - static const MqttsnQoS Qos = MqttsnQoS_AtMostOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtMostOnceDelivery; static const bool Retain = false; clearState(state); @@ -3584,12 +3584,12 @@ void ClientBasic::test39() state.m_nextElapsedTicks = 1000; auto pingrespMsg = dataProc.preparePingrespMsg(); dataFromGw(*client, pingrespMsg, "PINGRESP"); - verifyCb_ReportedMessageChecks(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedMessageChecks(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, 0); verifyNoOtherEvent(state); result = client->reconnect(); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, DefaultClientId, DefaultKeepAlive, false, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3602,9 +3602,9 @@ void ClientBasic::test39() clearState(state); state.m_nextElapsedTicks = 1000; - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); - verifyCb_ReportedReconnect(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedReconnect(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3624,10 +3624,10 @@ void ClientBasic::test40() static const std::string WillTopic("will/topic/upd"); static const DataBuf WillData = {1, 1, 1, 1}; - static const MqttsnQoS Qos = MqttsnQoS_AtLeastOnceDelivery; + static const CC_MqttsnQoS Qos = CC_MqttsnQoS_AtLeastOnceDelivery; static const bool Retain = true; - auto info = MqttsnWillInfo(); + auto info = CC_MqttsnWillInfo(); info.topic = WillTopic.c_str(); info.msg = &WillData[0]; info.msgLen = static_cast(WillData.size()); @@ -3637,7 +3637,7 @@ void ClientBasic::test40() clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->willUpdate(&info); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, DefaultClientId, DefaultKeepAlive, false, true); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3658,9 +3658,9 @@ void ClientBasic::test40() clearState(state); state.m_nextElapsedTicks = 1000; - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); - verifyCb_ReportedWillUpdate(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedWillUpdate(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3678,12 +3678,12 @@ void ClientBasic::test41() TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultKeepAlive * 1000); - auto info = MqttsnWillInfo(); + auto info = CC_MqttsnWillInfo(); clearState(state); state.m_nextElapsedTicks = 1000; auto result = client->willUpdate(&info); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, DefaultClientId, DefaultKeepAlive, false, true); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3692,15 +3692,15 @@ void ClientBasic::test41() state.m_nextElapsedTicks = 1000; auto topicReqMsg = dataProc.prepareWilltopicreqMsg(); dataFromGw(*client, topicReqMsg, "WILLTOPICREQ"); - verifySent_WilltopicMsg(state, dataProc, std::string(), MqttsnQoS_AtMostOnceDelivery, false); + verifySent_WilltopicMsg(state, dataProc, std::string(), CC_MqttsnQoS_AtMostOnceDelivery, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); - verifyCb_ReportedWillUpdate(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedWillUpdate(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3724,7 +3724,7 @@ void ClientBasic::test42() auto result = client->connect(nullptr, KeepAlive, true, nullptr); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); verifySent_ConnectMsg(state, dataProc, std::string(), KeepAlive, true, false); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, DefaultRetryTimeout); verifyNoOtherEvent(state); @@ -3732,11 +3732,11 @@ void ClientBasic::test42() clearState(state); static const unsigned NextTicks = 1000; state.m_nextElapsedTicks = NextTicks; - auto connackMsg = dataProc.prepareConnackMsg(mqttsn::field::ReturnCodeVal::Accepted); + auto connackMsg = dataProc.prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, connackMsg, "CONNACK"); // check connected - verifyCb_ReportedConnect(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedConnect(state, CC_MqttsnAsyncOpStatus_Successful); TS_ASSERT_EQUALS(state.m_nextRequestedTicks, (KeepAlive * 1000) - NextTicks); verifyNoOtherEvent(state); } @@ -3767,11 +3767,11 @@ void ClientBasic::test44() clearState(state); static const std::string Topic("tt"); // Short topic - static const auto Qos1 = MqttsnQoS_ExactlyOnceDelivery; - static const auto Qos2 = MqttsnQoS_AtLeastOnceDelivery; + static const auto Qos1 = CC_MqttsnQoS_ExactlyOnceDelivery; + static const auto Qos2 = CC_MqttsnQoS_AtLeastOnceDelivery; auto result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); clearState(state); doConnect(*client, dataProc, state); @@ -3781,38 +3781,38 @@ void ClientBasic::test44() clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos1, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos2); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Busy); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Busy); verifyNoOtherEvent(state); static const auto TopicId = - static_cast( - (static_cast(Topic[0]) << 8U) | static_cast(Topic[1])); + static_cast( + (static_cast(Topic[0]) << 8U) | static_cast(Topic[1])); clearState(state); state.m_nextElapsedTicks = 1000; - auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, mqttsn::field::ReturnCodeVal::Congestion); + auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Congestion); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Congestion, Qos2); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Congestion, Qos2); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos1, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Successful, Qos2); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Successful, Qos2); verifyNoOtherEvent(state); static const DataSeq Data = { @@ -3823,15 +3823,15 @@ void ClientBasic::test44() clearState(state); state.m_nextElapsedTicks = 1000; result = client->publish(Topic, &Data[0], Data.size(), Qos2, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdTypeVal::ShortTopicName, Qos2, Retain, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3848,11 +3848,11 @@ void ClientBasic::test45() clearState(state); static const std::string Topic("#"); // Wildcard topic - static const auto Qos1 = MqttsnQoS_ExactlyOnceDelivery; - static const auto Qos2 = MqttsnQoS_AtLeastOnceDelivery; + static const auto Qos1 = CC_MqttsnQoS_ExactlyOnceDelivery; + static const auto Qos2 = CC_MqttsnQoS_AtLeastOnceDelivery; auto result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); clearState(state); doConnect(*client, dataProc, state); @@ -3862,36 +3862,36 @@ void ClientBasic::test45() clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos1, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos2); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Busy); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Busy); verifyNoOtherEvent(state); - static const MqttsnTopicId TopicId = 0x1111; + static const CC_MqttsnTopicId TopicId = 0x1111; clearState(state); state.m_nextElapsedTicks = 1000; - auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, mqttsn::field::ReturnCodeVal::Congestion); + auto subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Congestion); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Congestion, Qos2); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Congestion, Qos2); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->subscribe(Topic, Qos1); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_SubsribeMsg(state, dataProc, Topic, Qos1, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + subackMsg = dataProc.prepareSubackMsg(transformQos(Qos2), TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, subackMsg, "SUBACK"); - verifyCb_ReportedSubsribe(state, MqttsnAsyncOpStatus_Successful, Qos2); + verifyCb_ReportedSubsribe(state, CC_MqttsnAsyncOpStatus_Successful, Qos2); verifyNoOtherEvent(state); static const DataSeq Data = { @@ -3902,15 +3902,15 @@ void ClientBasic::test45() clearState(state); state.m_nextElapsedTicks = 1000; result = client->publish(Topic, &Data[0], Data.size(), Qos2, Retain); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); msgId = verifySent_PublishMsg(state, dataProc, TopicId, Data, TopicIdTypeVal::Normal, Qos2, Retain, false); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; - auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = dataProc.preparePubackMsg(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromGw(*client, pubackMsg, "PUBACK"); - verifyCb_ReportedPublish(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedPublish(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } @@ -3928,7 +3928,7 @@ void ClientBasic::test46() static const std::string Topic("tt"); // Short topic auto result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_NotConnected); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_NotConnected); clearState(state); doConnect(*client, dataProc, state); @@ -3938,20 +3938,20 @@ void ClientBasic::test46() clearState(state); state.m_nextElapsedTicks = 1000; result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Success); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Success); auto msgId = verifySent_UnsubsribeMsg(state, dataProc, Topic); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; result = client->unsubscribe(Topic); - TS_ASSERT_EQUALS(result, MqttsnErrorCode_Busy); + TS_ASSERT_EQUALS(result, CC_MqttsnErrorCode_Busy); verifyNoOtherEvent(state); clearState(state); state.m_nextElapsedTicks = 1000; auto unsubackMsg = dataProc.prepareUnsubackMsg(msgId); dataFromGw(*client, unsubackMsg, "UNSUBACK"); - verifyCb_ReportedUnsubsribe(state, MqttsnAsyncOpStatus_Successful); + verifyCb_ReportedUnsubsribe(state, CC_MqttsnAsyncOpStatus_Successful); verifyNoOtherEvent(state); } diff --git a/client/test/CommonTestClient.cpp b/client/test/CommonTestClient.cpp index f95b9c0f..7977956b 100644 --- a/client/test/CommonTestClient.cpp +++ b/client/test/CommonTestClient.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,36 +16,36 @@ namespace ClientLibFuncs createDefaultLibFuncs() { ClientLibFuncs funcs; - funcs.m_newFunc = &mqttsn_client_new; - funcs.m_freeFunc = &mqttsn_client_free; - funcs.m_nextTickProgramCallbackSetFunc = &mqttsn_client_set_next_tick_program_callback; - funcs.m_cancelNextTickCallbackSetFunc = &mqttsn_client_set_cancel_next_tick_wait_callback; - funcs.m_sentOutDataCallbackSetFunc = &mqttsn_client_set_send_output_data_callback; - funcs.m_gwStatusReportCallbackSetFunc = &mqttsn_client_set_gw_status_report_callback; - funcs.m_gwDisconnectReportCallbackSetFunc = &mqttsn_client_set_gw_disconnect_report_callback; - funcs.m_msgReportCallbackSetFunc = &mqttsn_client_set_message_report_callback; - funcs.m_startFunc = &mqttsn_client_start; - funcs.m_processDataFunc = &mqttsn_client_process_data; - funcs.m_tickFunc = &mqttsn_client_tick; - funcs.m_setRetryPeriodFunc = &mqttsn_client_set_retry_period; - funcs.m_setRetryCountFunc = &mqttsn_client_set_retry_count; - funcs.m_setBroadcastRadius = &mqttsn_client_set_broadcast_radius; - funcs.m_setSearchgwEnabledFunc = &mqttsn_client_set_searchgw_enabled; - funcs.m_cancelFunc = &mqttsn_client_cancel; - funcs.m_connectFunc = &mqttsn_client_connect; - funcs.m_disconnectFunc = &mqttsn_client_disconnect; - funcs.m_publishIdFunc = &mqttsn_client_publish_id; - funcs.m_publishFunc = &mqttsn_client_publish; - funcs.m_subscribeIdFunc = &mqttsn_client_subscribe_id; - funcs.m_subscribeFunc = &mqttsn_client_subscribe; - funcs.m_unsubscribeIdFunc = &mqttsn_client_unsubscribe_id; - funcs.m_unsubscribeFunc = &mqttsn_client_unsubscribe; - funcs.m_willUpdateFunc = &mqttsn_client_will_update; - funcs.m_willTopicUpdateFunc = &mqttsn_client_will_topic_update; - funcs.m_willMsgUpdateFunc = &mqttsn_client_will_msg_update; - funcs.m_sleepFunc = &mqttsn_client_sleep; - funcs.m_reconnectFunc = &mqttsn_client_reconnect; - funcs.m_checkMessagesFunc = &mqttsn_client_check_messages; + funcs.m_newFunc = &cc_mqttsn_client_new; + funcs.m_freeFunc = &cc_mqttsn_client_free; + funcs.m_nextTickProgramCallbackSetFunc = &cc_mqttsn_client_set_next_tick_program_callback; + funcs.m_cancelNextTickCallbackSetFunc = &cc_mqttsn_client_set_cancel_next_tick_wait_callback; + funcs.m_sentOutDataCallbackSetFunc = &cc_mqttsn_client_set_send_output_data_callback; + funcs.m_gwStatusReportCallbackSetFunc = &cc_mqttsn_client_set_gw_status_report_callback; + funcs.m_gwDisconnectReportCallbackSetFunc = &cc_mqttsn_client_set_gw_disconnect_report_callback; + funcs.m_msgReportCallbackSetFunc = &cc_mqttsn_client_set_message_report_callback; + funcs.m_startFunc = &cc_mqttsn_client_start; + funcs.m_processDataFunc = &cc_mqttsn_client_process_data; + funcs.m_tickFunc = &cc_mqttsn_client_tick; + funcs.m_setRetryPeriodFunc = &cc_mqttsn_client_set_retry_period; + funcs.m_setRetryCountFunc = &cc_mqttsn_client_set_retry_count; + funcs.m_setBroadcastRadius = &cc_mqttsn_client_set_broadcast_radius; + funcs.m_setSearchgwEnabledFunc = &cc_mqttsn_client_set_searchgw_enabled; + funcs.m_cancelFunc = &cc_mqttsn_client_cancel; + funcs.m_connectFunc = &cc_mqttsn_client_connect; + funcs.m_disconnectFunc = &cc_mqttsn_client_disconnect; + funcs.m_publishIdFunc = &cc_mqttsn_client_publish_id; + funcs.m_publishFunc = &cc_mqttsn_client_publish; + funcs.m_subscribeIdFunc = &cc_mqttsn_client_subscribe_id; + funcs.m_subscribeFunc = &cc_mqttsn_client_subscribe; + funcs.m_unsubscribeIdFunc = &cc_mqttsn_client_unsubscribe_id; + funcs.m_unsubscribeFunc = &cc_mqttsn_client_unsubscribe; + funcs.m_willUpdateFunc = &cc_mqttsn_client_will_update; + funcs.m_willTopicUpdateFunc = &cc_mqttsn_client_will_topic_update; + funcs.m_willMsgUpdateFunc = &cc_mqttsn_client_will_msg_update; + funcs.m_sleepFunc = &cc_mqttsn_client_sleep; + funcs.m_reconnectFunc = &cc_mqttsn_client_reconnect; + funcs.m_checkMessagesFunc = &cc_mqttsn_client_check_messages; return funcs; } @@ -199,7 +199,7 @@ CommonTestClient::Ptr CommonTestClient::alloc(const ClientLibFuncs& libFuncs) return Ptr(new CommonTestClient(libFuncs)); } -MqttsnErrorCode CommonTestClient::start() +CC_MqttsnErrorCode CommonTestClient::start() { assert(m_libFuncs.m_startFunc != nullptr); return (m_libFuncs.m_startFunc)(m_client); @@ -249,11 +249,11 @@ void CommonTestClient::setSearchgwEnabled(bool value) (m_libFuncs.m_setSearchgwEnabledFunc)(m_client, value); } -MqttsnErrorCode CommonTestClient::connect( +CC_MqttsnErrorCode CommonTestClient::connect( const char* clientId, unsigned short keepAliveSeconds, bool cleanSession, - const MqttsnWillInfo* willInfo) + const CC_MqttsnWillInfo* willInfo) { assert(m_libFuncs.m_connectFunc != nullptr); @@ -274,7 +274,7 @@ bool CommonTestClient::cancel() return (m_libFuncs.m_cancelFunc)(m_client); } -MqttsnErrorCode CommonTestClient::disconnect() +CC_MqttsnErrorCode CommonTestClient::disconnect() { assert(m_libFuncs.m_disconnectFunc != nullptr); return (m_libFuncs.m_disconnectFunc)( @@ -283,11 +283,11 @@ MqttsnErrorCode CommonTestClient::disconnect() this); } -MqttsnErrorCode CommonTestClient::publishId( - MqttsnTopicId topicId, +CC_MqttsnErrorCode CommonTestClient::publishId( + CC_MqttsnTopicId topicId, const std::uint8_t* msg, std::size_t msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain) { assert(m_libFuncs.m_publishIdFunc != nullptr); @@ -302,11 +302,11 @@ MqttsnErrorCode CommonTestClient::publishId( this); } -MqttsnErrorCode CommonTestClient::publish( +CC_MqttsnErrorCode CommonTestClient::publish( const std::string& topic, const std::uint8_t* msg, std::size_t msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain) { assert(m_libFuncs.m_publishFunc != nullptr); @@ -321,9 +321,9 @@ MqttsnErrorCode CommonTestClient::publish( this); } -MqttsnErrorCode CommonTestClient::subscribe( +CC_MqttsnErrorCode CommonTestClient::subscribe( const std::string& topic, - MqttsnQoS qos) + CC_MqttsnQoS qos) { assert(m_libFuncs.m_subscribeFunc != nullptr); return (m_libFuncs.m_subscribeFunc)( @@ -334,9 +334,9 @@ MqttsnErrorCode CommonTestClient::subscribe( this); } -MqttsnErrorCode CommonTestClient::subscribe( - MqttsnTopicId topicId, - MqttsnQoS qos) +CC_MqttsnErrorCode CommonTestClient::subscribe( + CC_MqttsnTopicId topicId, + CC_MqttsnQoS qos) { assert(m_libFuncs.m_subscribeIdFunc != nullptr); return (m_libFuncs.m_subscribeIdFunc)( @@ -347,7 +347,7 @@ MqttsnErrorCode CommonTestClient::subscribe( this); } -MqttsnErrorCode CommonTestClient::unsubscribe(const std::string& topic) +CC_MqttsnErrorCode CommonTestClient::unsubscribe(const std::string& topic) { assert(m_libFuncs.m_unsubscribeFunc != nullptr); return (m_libFuncs.m_unsubscribeFunc)( @@ -357,7 +357,7 @@ MqttsnErrorCode CommonTestClient::unsubscribe(const std::string& topic) this); } -MqttsnErrorCode CommonTestClient::unsubscribe(MqttsnTopicId topicId) +CC_MqttsnErrorCode CommonTestClient::unsubscribe(CC_MqttsnTopicId topicId) { assert(m_libFuncs.m_unsubscribeIdFunc != nullptr); return (m_libFuncs.m_unsubscribeIdFunc)( @@ -367,8 +367,8 @@ MqttsnErrorCode CommonTestClient::unsubscribe(MqttsnTopicId topicId) this); } -MqttsnErrorCode CommonTestClient::willUpdate( - const MqttsnWillInfo* willInfo) +CC_MqttsnErrorCode CommonTestClient::willUpdate( + const CC_MqttsnWillInfo* willInfo) { assert(m_libFuncs.m_willUpdateFunc != nullptr); return (m_libFuncs.m_willUpdateFunc)( @@ -378,9 +378,9 @@ MqttsnErrorCode CommonTestClient::willUpdate( this); } -MqttsnErrorCode CommonTestClient::willTopicUpdate( +CC_MqttsnErrorCode CommonTestClient::willTopicUpdate( const std::string& topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain) { assert(m_libFuncs.m_willTopicUpdateFunc != nullptr); @@ -393,7 +393,7 @@ MqttsnErrorCode CommonTestClient::willTopicUpdate( this); } -MqttsnErrorCode CommonTestClient::willMsgUpdate( +CC_MqttsnErrorCode CommonTestClient::willMsgUpdate( const std::uint8_t* msg, std::size_t msgLen) { @@ -406,7 +406,7 @@ MqttsnErrorCode CommonTestClient::willMsgUpdate( this); } -MqttsnErrorCode CommonTestClient::sleep(std::uint16_t duration) +CC_MqttsnErrorCode CommonTestClient::sleep(std::uint16_t duration) { assert(m_libFuncs.m_sleepFunc != nullptr); return (m_libFuncs.m_sleepFunc)( @@ -416,7 +416,7 @@ MqttsnErrorCode CommonTestClient::sleep(std::uint16_t duration) this); } -MqttsnErrorCode CommonTestClient::reconnect() +CC_MqttsnErrorCode CommonTestClient::reconnect() { assert(m_libFuncs.m_reconnectFunc != nullptr); return (m_libFuncs.m_reconnectFunc)( @@ -425,7 +425,7 @@ MqttsnErrorCode CommonTestClient::reconnect() this); } -MqttsnErrorCode CommonTestClient::checkMessages() +CC_MqttsnErrorCode CommonTestClient::checkMessages() { assert(m_libFuncs.m_checkMessagesFunc != nullptr); return (m_libFuncs.m_checkMessagesFunc)( @@ -434,35 +434,35 @@ MqttsnErrorCode CommonTestClient::checkMessages() this); } -MqttsnQoS CommonTestClient::transformQos(mqttsn::field::QosVal val) +CC_MqttsnQoS CommonTestClient::transformQos(cc_mqttsn::field::QosVal val) { static_assert( - static_cast(mqttsn::field::QosVal::AtMostOnceDelivery) == MqttsnQoS_AtMostOnceDelivery, + static_cast(cc_mqttsn::field::QosVal::AtMostOnceDelivery) == CC_MqttsnQoS_AtMostOnceDelivery, "Invalid mapping"); static_assert( - static_cast(mqttsn::field::QosVal::AtLeastOnceDelivery) == MqttsnQoS_AtLeastOnceDelivery, + static_cast(cc_mqttsn::field::QosVal::AtLeastOnceDelivery) == CC_MqttsnQoS_AtLeastOnceDelivery, "Invalid mapping"); static_assert( - static_cast(mqttsn::field::QosVal::ExactlyOnceDelivery) == MqttsnQoS_ExactlyOnceDelivery, + static_cast(cc_mqttsn::field::QosVal::ExactlyOnceDelivery) == CC_MqttsnQoS_ExactlyOnceDelivery, "Invalid mapping"); - if (val == mqttsn::field::QosVal::NoGwPublish) { - return MqttsnQoS_NoGwPublish; + if (val == cc_mqttsn::field::QosVal::NoGwPublish) { + return CC_MqttsnQoS_NoGwPublish; } - return static_cast(val); + return static_cast(val); } -mqttsn::field::QosVal CommonTestClient::transformQos(MqttsnQoS val) +cc_mqttsn::field::QosVal CommonTestClient::transformQos(CC_MqttsnQoS val) { - if (val == MqttsnQoS_NoGwPublish) { - return mqttsn::field::QosVal::NoGwPublish; + if (val == CC_MqttsnQoS_NoGwPublish) { + return cc_mqttsn::field::QosVal::NoGwPublish; } - return static_cast(val); + return static_cast(val); } CommonTestClient::CommonTestClient(const ClientLibFuncs& libFuncs) @@ -514,7 +514,7 @@ void CommonTestClient::sendOutputData(const unsigned char* buf, unsigned bufLen, } } -void CommonTestClient::reportGwStatus(unsigned short gwId, MqttsnGwStatus status) +void CommonTestClient::reportGwStatus(unsigned short gwId, CC_MqttsnGwStatus status) { if (m_gwStatusReportCallback) { GwStatusReportCallback tmp(m_gwStatusReportCallback); @@ -530,7 +530,7 @@ void CommonTestClient::reportGwDisconnect() } } -void CommonTestClient::reportMessage(const MqttsnMessageInfo* msgInfo) +void CommonTestClient::reportMessage(const CC_MqttsnMessageInfo* msgInfo) { if (m_msgReportCallback) { assert(msgInfo != nullptr); @@ -539,7 +539,7 @@ void CommonTestClient::reportMessage(const MqttsnMessageInfo* msgInfo) } } -void CommonTestClient::reportConnectComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportConnectComplete(CC_MqttsnAsyncOpStatus status) { if (m_connectCompleteCallback) { AsyncOpCompleteCallback tmp(m_connectCompleteCallback); @@ -547,7 +547,7 @@ void CommonTestClient::reportConnectComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportDisconnectComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportDisconnectComplete(CC_MqttsnAsyncOpStatus status) { if (m_disconnectCompleteCallback) { AsyncOpCompleteCallback tmp(m_disconnectCompleteCallback); @@ -555,7 +555,7 @@ void CommonTestClient::reportDisconnectComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportPublishComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportPublishComplete(CC_MqttsnAsyncOpStatus status) { if (m_publishCompleteCallback) { AsyncOpCompleteCallback tmp(m_publishCompleteCallback); @@ -563,7 +563,7 @@ void CommonTestClient::reportPublishComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportSubsribeComplete(MqttsnAsyncOpStatus status, MqttsnQoS qos) +void CommonTestClient::reportSubsribeComplete(CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos) { if (m_subscribeCompleteCallback) { SubscribeCompleteCallback tmp(m_subscribeCompleteCallback); @@ -571,7 +571,7 @@ void CommonTestClient::reportSubsribeComplete(MqttsnAsyncOpStatus status, Mqttsn } } -void CommonTestClient::reportUnsubsribeComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportUnsubsribeComplete(CC_MqttsnAsyncOpStatus status) { if (m_unsubscribeCompleteCallback) { AsyncOpCompleteCallback tmp(m_unsubscribeCompleteCallback); @@ -579,7 +579,7 @@ void CommonTestClient::reportUnsubsribeComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportWillUpdateComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportWillUpdateComplete(CC_MqttsnAsyncOpStatus status) { if (m_willUpdateCompleteCallback) { AsyncOpCompleteCallback tmp(m_willUpdateCompleteCallback); @@ -587,7 +587,7 @@ void CommonTestClient::reportWillUpdateComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportWillTopicUpdateComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportWillTopicUpdateComplete(CC_MqttsnAsyncOpStatus status) { if (m_willTopicUpdateCompleteCallback) { AsyncOpCompleteCallback tmp(m_willTopicUpdateCompleteCallback); @@ -595,7 +595,7 @@ void CommonTestClient::reportWillTopicUpdateComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportWillMsgUpdateComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportWillMsgUpdateComplete(CC_MqttsnAsyncOpStatus status) { if (m_willMsgUpdateCompleteCallback) { AsyncOpCompleteCallback tmp(m_willMsgUpdateCompleteCallback); @@ -603,7 +603,7 @@ void CommonTestClient::reportWillMsgUpdateComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportSleepComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportSleepComplete(CC_MqttsnAsyncOpStatus status) { if (m_sleepCompleteCallback) { AsyncOpCompleteCallback tmp(m_sleepCompleteCallback); @@ -611,7 +611,7 @@ void CommonTestClient::reportSleepComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportReconnectComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportReconnectComplete(CC_MqttsnAsyncOpStatus status) { if (m_reconnectCompleteCallback) { AsyncOpCompleteCallback tmp(m_reconnectCompleteCallback); @@ -619,7 +619,7 @@ void CommonTestClient::reportReconnectComplete(MqttsnAsyncOpStatus status) } } -void CommonTestClient::reportCheckMessagesComplete(MqttsnAsyncOpStatus status) +void CommonTestClient::reportCheckMessagesComplete(CC_MqttsnAsyncOpStatus status) { if (m_checkMessagesCompleteCallback) { AsyncOpCompleteCallback tmp(m_checkMessagesCompleteCallback); @@ -652,7 +652,7 @@ void CommonTestClient::sendOutputDataCallback( void CommonTestClient::gwStatusReportCallback( void* data, unsigned char gwId, - MqttsnGwStatus status) + CC_MqttsnGwStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportGwStatus(gwId, status); @@ -664,73 +664,73 @@ void CommonTestClient::gwDisconnectReportCallback(void* data) reinterpret_cast(data)->reportGwDisconnect(); } -void CommonTestClient::msgReportCallback(void* data, const MqttsnMessageInfo* msgInfo) +void CommonTestClient::msgReportCallback(void* data, const CC_MqttsnMessageInfo* msgInfo) { assert(data != nullptr); reinterpret_cast(data)->reportMessage(msgInfo); } -void CommonTestClient::publishCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::publishCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportPublishComplete(status); } -void CommonTestClient::connectCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::connectCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportConnectComplete(status); } -void CommonTestClient::disconnectCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::disconnectCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportDisconnectComplete(status); } -void CommonTestClient::subsribeCompleteCallback(void* data, MqttsnAsyncOpStatus status, MqttsnQoS qos) +void CommonTestClient::subsribeCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos) { assert(data != nullptr); reinterpret_cast(data)->reportSubsribeComplete(status, qos); } -void CommonTestClient::unsubsribeCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::unsubsribeCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportUnsubsribeComplete(status); } -void CommonTestClient::willUpdateCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::willUpdateCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportWillUpdateComplete(status); } -void CommonTestClient::willTopicUpdateCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::willTopicUpdateCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportWillTopicUpdateComplete(status); } -void CommonTestClient::willMsgUpdateCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::willMsgUpdateCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportWillMsgUpdateComplete(status); } -void CommonTestClient::sleepCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::sleepCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportSleepComplete(status); } -void CommonTestClient::reconnectCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::reconnectCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportReconnectComplete(status); } -void CommonTestClient::checkMessagesCompleteCallback(void* data, MqttsnAsyncOpStatus status) +void CommonTestClient::checkMessagesCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status) { assert(data != nullptr); reinterpret_cast(data)->reportCheckMessagesComplete(status); diff --git a/client/test/CommonTestClient.h b/client/test/CommonTestClient.h index 7d39b88b..c458dab8 100644 --- a/client/test/CommonTestClient.h +++ b/client/test/CommonTestClient.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,40 +14,40 @@ #include #include -#include "mqttsn/client/common.h" -#include "mqttsn/field/QosCommon.h" +#include "cc_mqttsn_client/common.h" +#include "cc_mqttsn/field/QosCommon.h" #include "client.h" -typedef decltype(&mqttsn_client_new) ClientNewFunc; -typedef decltype(&mqttsn_client_free) ClientFreeFunc; -typedef decltype(&mqttsn_client_set_next_tick_program_callback) NextTickProgramCallbackSetFunc; -typedef decltype(&mqttsn_client_set_cancel_next_tick_wait_callback) CancelNextTickCallbackSetFunc; -typedef decltype(&mqttsn_client_set_send_output_data_callback) SendOutDataCallbackSetFunc; -typedef decltype(&mqttsn_client_set_gw_status_report_callback) GwStatusReportCallbackSetFunc; -typedef decltype(&mqttsn_client_set_gw_disconnect_report_callback) GwDisconnectsReportCallbackSetFunc; -typedef decltype(&mqttsn_client_set_message_report_callback) MessageReportCallbackSetFunc; -typedef decltype(&mqttsn_client_start) StartFunc; -typedef decltype(&mqttsn_client_process_data) ProcessDataFunc; -typedef decltype(&mqttsn_client_tick) TickFunc; -typedef decltype(&mqttsn_client_set_retry_period) SetRetryPeriodFunc; -typedef decltype(&mqttsn_client_set_retry_count) SetRetryCountFunc; -typedef decltype(&mqttsn_client_set_broadcast_radius) SetBroadcastRadiusFunc; -typedef decltype(&mqttsn_client_set_searchgw_enabled) SetSearchgwEnabledFunc; -typedef decltype(&mqttsn_client_cancel) CancelFunc; -typedef decltype(&mqttsn_client_connect) ConnectFunc; -typedef decltype(&mqttsn_client_disconnect) DisconnectFunc; -typedef decltype(&mqttsn_client_publish_id) PublishIdFunc; -typedef decltype(&mqttsn_client_publish) PublishFunc; -typedef decltype(&mqttsn_client_subscribe_id) SubscribeIdFunc; -typedef decltype(&mqttsn_client_subscribe) SubscribeFunc; -typedef decltype(&mqttsn_client_unsubscribe_id) UnsubscribeIdFunc; -typedef decltype(&mqttsn_client_unsubscribe) UnsubscribeFunc; -typedef decltype(&mqttsn_client_will_update) WillUpdateFunc; -typedef decltype(&mqttsn_client_will_topic_update) WillTopicUpdateFunc; -typedef decltype(&mqttsn_client_will_msg_update) WillMsgUpdateFunc; -typedef decltype(&mqttsn_client_sleep) SleepFunc; -typedef decltype(&mqttsn_client_reconnect) ReconnectFunc; -typedef decltype(&mqttsn_client_check_messages) CheckMessagesFunc; +typedef decltype(&cc_mqttsn_client_new) ClientNewFunc; +typedef decltype(&cc_mqttsn_client_free) ClientFreeFunc; +typedef decltype(&cc_mqttsn_client_set_next_tick_program_callback) NextTickProgramCallbackSetFunc; +typedef decltype(&cc_mqttsn_client_set_cancel_next_tick_wait_callback) CancelNextTickCallbackSetFunc; +typedef decltype(&cc_mqttsn_client_set_send_output_data_callback) SendOutDataCallbackSetFunc; +typedef decltype(&cc_mqttsn_client_set_gw_status_report_callback) GwStatusReportCallbackSetFunc; +typedef decltype(&cc_mqttsn_client_set_gw_disconnect_report_callback) GwDisconnectsReportCallbackSetFunc; +typedef decltype(&cc_mqttsn_client_set_message_report_callback) MessageReportCallbackSetFunc; +typedef decltype(&cc_mqttsn_client_start) StartFunc; +typedef decltype(&cc_mqttsn_client_process_data) ProcessDataFunc; +typedef decltype(&cc_mqttsn_client_tick) TickFunc; +typedef decltype(&cc_mqttsn_client_set_retry_period) SetRetryPeriodFunc; +typedef decltype(&cc_mqttsn_client_set_retry_count) SetRetryCountFunc; +typedef decltype(&cc_mqttsn_client_set_broadcast_radius) SetBroadcastRadiusFunc; +typedef decltype(&cc_mqttsn_client_set_searchgw_enabled) SetSearchgwEnabledFunc; +typedef decltype(&cc_mqttsn_client_cancel) CancelFunc; +typedef decltype(&cc_mqttsn_client_connect) ConnectFunc; +typedef decltype(&cc_mqttsn_client_disconnect) DisconnectFunc; +typedef decltype(&cc_mqttsn_client_publish_id) PublishIdFunc; +typedef decltype(&cc_mqttsn_client_publish) PublishFunc; +typedef decltype(&cc_mqttsn_client_subscribe_id) SubscribeIdFunc; +typedef decltype(&cc_mqttsn_client_subscribe) SubscribeFunc; +typedef decltype(&cc_mqttsn_client_unsubscribe_id) UnsubscribeIdFunc; +typedef decltype(&cc_mqttsn_client_unsubscribe) UnsubscribeFunc; +typedef decltype(&cc_mqttsn_client_will_update) WillUpdateFunc; +typedef decltype(&cc_mqttsn_client_will_topic_update) WillTopicUpdateFunc; +typedef decltype(&cc_mqttsn_client_will_msg_update) WillMsgUpdateFunc; +typedef decltype(&cc_mqttsn_client_sleep) SleepFunc; +typedef decltype(&cc_mqttsn_client_reconnect) ReconnectFunc; +typedef decltype(&cc_mqttsn_client_check_messages) CheckMessagesFunc; struct ClientLibFuncs @@ -91,11 +91,11 @@ class CommonTestClient typedef std::function ProgramNextTickCallback; typedef std::function CancelNextTickCallback; typedef std::function SendDataCallback; - typedef std::function GwStatusReportCallback; + typedef std::function GwStatusReportCallback; typedef std::function GwDisconnectReportCallback; - typedef std::function MessageReportCallback; - typedef std::function AsyncOpCompleteCallback; - typedef std::function SubscribeCompleteCallback; + typedef std::function MessageReportCallback; + typedef std::function AsyncOpCompleteCallback; + typedef std::function SubscribeCompleteCallback; ~CommonTestClient(); @@ -118,7 +118,7 @@ class CommonTestClient AsyncOpCompleteCallback setCheckMessagesCompleteCallback(AsyncOpCompleteCallback&& func); static Ptr alloc(const ClientLibFuncs& libFuncs = DefaultFuncs); - MqttsnErrorCode start(); + CC_MqttsnErrorCode start(); void inputData(const std::uint8_t* buf, std::size_t bufLen); void tick(); void setRetryPeriod(unsigned ms); @@ -127,60 +127,60 @@ class CommonTestClient void setSearchgwEnabled(bool value); bool cancel(); - MqttsnErrorCode connect( + CC_MqttsnErrorCode connect( const char* clientId, unsigned short keepAliveSeconds, bool cleanSession, - const MqttsnWillInfo* willInfo); + const CC_MqttsnWillInfo* willInfo); - MqttsnErrorCode disconnect(); + CC_MqttsnErrorCode disconnect(); - MqttsnErrorCode publishId( - MqttsnTopicId topicId, + CC_MqttsnErrorCode publishId( + CC_MqttsnTopicId topicId, const std::uint8_t* msg, std::size_t msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain); - MqttsnErrorCode publish( + CC_MqttsnErrorCode publish( const std::string& topic, const std::uint8_t* msg, std::size_t msgLen, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain); - MqttsnErrorCode subscribe( + CC_MqttsnErrorCode subscribe( const std::string& topic, - MqttsnQoS qos); + CC_MqttsnQoS qos); - MqttsnErrorCode subscribe( - MqttsnTopicId topicId, - MqttsnQoS qos); + CC_MqttsnErrorCode subscribe( + CC_MqttsnTopicId topicId, + CC_MqttsnQoS qos); - MqttsnErrorCode unsubscribe(const std::string& topic); + CC_MqttsnErrorCode unsubscribe(const std::string& topic); - MqttsnErrorCode unsubscribe(MqttsnTopicId topicId); + CC_MqttsnErrorCode unsubscribe(CC_MqttsnTopicId topicId); - MqttsnErrorCode willUpdate( - const MqttsnWillInfo* willInfo); + CC_MqttsnErrorCode willUpdate( + const CC_MqttsnWillInfo* willInfo); - MqttsnErrorCode willTopicUpdate( + CC_MqttsnErrorCode willTopicUpdate( const std::string& topic, - MqttsnQoS qos, + CC_MqttsnQoS qos, bool retain); - MqttsnErrorCode willMsgUpdate( + CC_MqttsnErrorCode willMsgUpdate( const std::uint8_t* msg, std::size_t msgLen); - MqttsnErrorCode sleep(std::uint16_t duration); + CC_MqttsnErrorCode sleep(std::uint16_t duration); - MqttsnErrorCode reconnect(); + CC_MqttsnErrorCode reconnect(); - MqttsnErrorCode checkMessages(); + CC_MqttsnErrorCode checkMessages(); - static MqttsnQoS transformQos(mqttsn::field::QosVal val); - static mqttsn::field::QosVal transformQos(MqttsnQoS val); + static CC_MqttsnQoS transformQos(cc_mqttsn::field::QosVal val); + static cc_mqttsn::field::QosVal transformQos(CC_MqttsnQoS val); private: typedef std::vector InputData; @@ -190,41 +190,41 @@ class CommonTestClient void programNextTick(unsigned duration); unsigned cancelNextTick(); void sendOutputData(const unsigned char* buf, unsigned bufLen, bool broadcast); - void reportGwStatus(unsigned short gwId, MqttsnGwStatus status); + void reportGwStatus(unsigned short gwId, CC_MqttsnGwStatus status); void reportGwDisconnect(); - void reportMessage(const MqttsnMessageInfo* msgInfo); - void reportConnectComplete(MqttsnAsyncOpStatus status); - void reportDisconnectComplete(MqttsnAsyncOpStatus status); - void reportPublishComplete(MqttsnAsyncOpStatus status); - void reportSubsribeComplete(MqttsnAsyncOpStatus status, MqttsnQoS qos); - void reportUnsubsribeComplete(MqttsnAsyncOpStatus status); - void reportWillUpdateComplete(MqttsnAsyncOpStatus status); - void reportWillTopicUpdateComplete(MqttsnAsyncOpStatus status); - void reportWillMsgUpdateComplete(MqttsnAsyncOpStatus status); - void reportSleepComplete(MqttsnAsyncOpStatus status); - void reportReconnectComplete(MqttsnAsyncOpStatus status); - void reportCheckMessagesComplete(MqttsnAsyncOpStatus status); + void reportMessage(const CC_MqttsnMessageInfo* msgInfo); + void reportConnectComplete(CC_MqttsnAsyncOpStatus status); + void reportDisconnectComplete(CC_MqttsnAsyncOpStatus status); + void reportPublishComplete(CC_MqttsnAsyncOpStatus status); + void reportSubsribeComplete(CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos); + void reportUnsubsribeComplete(CC_MqttsnAsyncOpStatus status); + void reportWillUpdateComplete(CC_MqttsnAsyncOpStatus status); + void reportWillTopicUpdateComplete(CC_MqttsnAsyncOpStatus status); + void reportWillMsgUpdateComplete(CC_MqttsnAsyncOpStatus status); + void reportSleepComplete(CC_MqttsnAsyncOpStatus status); + void reportReconnectComplete(CC_MqttsnAsyncOpStatus status); + void reportCheckMessagesComplete(CC_MqttsnAsyncOpStatus status); static void nextTickProgramCallback(void* data, unsigned duration); static unsigned cancelNextTickCallback(void* data); static void sendOutputDataCallback(void* data, const unsigned char* buf, unsigned bufLen, bool broadcast); - static void gwStatusReportCallback(void* data, unsigned char gwId, MqttsnGwStatus status); + static void gwStatusReportCallback(void* data, unsigned char gwId, CC_MqttsnGwStatus status); static void gwDisconnectReportCallback(void* data); - static void msgReportCallback(void* data, const MqttsnMessageInfo* msgInfo); - static void connectCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void disconnectCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void publishCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void subsribeCompleteCallback(void* data, MqttsnAsyncOpStatus status, MqttsnQoS qos); - static void unsubsribeCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void willUpdateCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void willTopicUpdateCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void willMsgUpdateCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void sleepCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void reconnectCompleteCallback(void* data, MqttsnAsyncOpStatus status); - static void checkMessagesCompleteCallback(void* data, MqttsnAsyncOpStatus status); + static void msgReportCallback(void* data, const CC_MqttsnMessageInfo* msgInfo); + static void connectCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void disconnectCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void publishCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void subsribeCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos); + static void unsubsribeCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void willUpdateCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void willTopicUpdateCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void willMsgUpdateCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void sleepCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void reconnectCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); + static void checkMessagesCompleteCallback(void* data, CC_MqttsnAsyncOpStatus status); ClientLibFuncs m_libFuncs; - MqttsnClientHandle m_client = nullptr; + CC_MqttsnClientHandle m_client; InputData m_inData; ProgramNextTickCallback m_programNextTickCallback; diff --git a/client/test/DataProcessor.cpp b/client/test/DataProcessor.cpp index 144cba8c..e388ded8 100644 --- a/client/test/DataProcessor.cpp +++ b/client/test/DataProcessor.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -342,7 +342,7 @@ DataProcessor::DataBuf DataProcessor::prepareAdvertiseMsg(std::uint8_t id, unsig return buf; } -DataProcessor::DataBuf DataProcessor::prepareConnackMsg(mqttsn::field::ReturnCodeVal val) +DataProcessor::DataBuf DataProcessor::prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal val) { ConnackMsg msg; msg.field_returnCode().value() = val; @@ -376,7 +376,7 @@ DataProcessor::DataBuf DataProcessor::prepareRegisterMsg( DataProcessor::DataBuf DataProcessor::prepareRegackMsg( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode) + cc_mqttsn::field::ReturnCodeVal retCode) { RegackMsg msg; msg.field_topicId().value() = topicId; @@ -390,7 +390,7 @@ DataProcessor::DataBuf DataProcessor::preparePublishMsg( std::uint16_t msgId, const std::vector& data, TopicIdTypeVal topicIdType, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain, bool duplicate) { @@ -406,9 +406,9 @@ DataProcessor::DataBuf DataProcessor::preparePublishMsg( } DataProcessor::DataBuf DataProcessor::preparePubackMsg( - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode) + cc_mqttsn::field::ReturnCodeVal retCode) { PubackMsg msg; msg.field_topicId().value() = topicId; @@ -439,10 +439,10 @@ DataProcessor::DataBuf DataProcessor::preparePubcompMsg(std::uint16_t msgId) } DataProcessor::DataBuf DataProcessor::prepareSubackMsg( - mqttsn::field::QosVal qos, - MqttsnTopicId topicId, + cc_mqttsn::field::QosVal qos, + CC_MqttsnTopicId topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode) + cc_mqttsn::field::ReturnCodeVal retCode) { SubackMsg msg; msg.field_flags().field_qos().value() = qos; @@ -485,7 +485,7 @@ DataProcessor::DataBuf DataProcessor::prepareDisconnectMsg(std::uint16_t duratio } DataProcessor::DataBuf DataProcessor::prepareWilltopicrespMsg( - mqttsn::field::ReturnCodeVal retCode) + cc_mqttsn::field::ReturnCodeVal retCode) { WilltopicrespMsg msg; msg.field_returnCode().value() = retCode; @@ -493,7 +493,7 @@ DataProcessor::DataBuf DataProcessor::prepareWilltopicrespMsg( } DataProcessor::DataBuf DataProcessor::prepareWillmsgrespMsg( - mqttsn::field::ReturnCodeVal retCode) + cc_mqttsn::field::ReturnCodeVal retCode) { WillmsgrespMsg msg; msg.field_returnCode().value() = retCode; diff --git a/client/test/DataProcessor.h b/client/test/DataProcessor.h index 7301194f..448fe645 100644 --- a/client/test/DataProcessor.h +++ b/client/test/DataProcessor.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,13 +13,13 @@ #include #include "comms/comms.h" -#include "mqttsn/frame/Frame.h" -#include "mqttsn/Message.h" -#include "mqttsn/client/common.h" +#include "cc_mqttsn/frame/Frame.h" +#include "cc_mqttsn/Message.h" +#include "cc_mqttsn_client/common.h" class DataProcessor; -typedef mqttsn::Message< +typedef cc_mqttsn::Message< comms::option::IdInfoInterface, comms::option::ReadIterator, comms::option::WriteIterator, @@ -27,42 +27,42 @@ typedef mqttsn::Message< comms::option::LengthInfoInterface > TestMessage; -typedef mqttsn::input::AllMessages AllTestMessages; +typedef cc_mqttsn::input::AllMessages AllTestMessages; class DataProcessor : public comms::GenericHandler { typedef comms::GenericHandler Base; public: typedef std::vector DataBuf; - using TopicIdTypeVal = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; - - typedef mqttsn::message::Advertise AdvertiseMsg; - typedef mqttsn::message::Searchgw SearchgwMsg; - typedef mqttsn::message::Gwinfo GwinfoMsg; - typedef mqttsn::message::Connect ConnectMsg; - typedef mqttsn::message::Connack ConnackMsg; - typedef mqttsn::message::Willtopicreq WilltopicreqMsg; - typedef mqttsn::message::Willtopic WilltopicMsg; - typedef mqttsn::message::Willmsgreq WillmsgreqMsg; - typedef mqttsn::message::Willmsg WillmsgMsg; - typedef mqttsn::message::Register RegisterMsg; - typedef mqttsn::message::Regack RegackMsg; - typedef mqttsn::message::Publish PublishMsg; - typedef mqttsn::message::Puback PubackMsg; - typedef mqttsn::message::Pubrec PubrecMsg; - typedef mqttsn::message::Pubrel PubrelMsg; - typedef mqttsn::message::Pubcomp PubcompMsg; - typedef mqttsn::message::Subscribe SubscribeMsg; - typedef mqttsn::message::Suback SubackMsg; - typedef mqttsn::message::Unsubscribe UnsubscribeMsg; - typedef mqttsn::message::Unsuback UnsubackMsg; - typedef mqttsn::message::Pingreq PingreqMsg; - typedef mqttsn::message::Pingresp PingrespMsg; - typedef mqttsn::message::Disconnect DisconnectMsg; - typedef mqttsn::message::Willtopicupd WilltopicupdMsg; - typedef mqttsn::message::Willmsgupd WillmsgupdMsg; - typedef mqttsn::message::Willtopicresp WilltopicrespMsg; - typedef mqttsn::message::Willmsgresp WillmsgrespMsg; + using TopicIdTypeVal = cc_mqttsn::field::TopicIdTypeVal; + + typedef cc_mqttsn::message::Advertise AdvertiseMsg; + typedef cc_mqttsn::message::Searchgw SearchgwMsg; + typedef cc_mqttsn::message::Gwinfo GwinfoMsg; + typedef cc_mqttsn::message::Connect ConnectMsg; + typedef cc_mqttsn::message::Connack ConnackMsg; + typedef cc_mqttsn::message::Willtopicreq WilltopicreqMsg; + typedef cc_mqttsn::message::Willtopic WilltopicMsg; + typedef cc_mqttsn::message::Willmsgreq WillmsgreqMsg; + typedef cc_mqttsn::message::Willmsg WillmsgMsg; + typedef cc_mqttsn::message::Register RegisterMsg; + typedef cc_mqttsn::message::Regack RegackMsg; + typedef cc_mqttsn::message::Publish PublishMsg; + typedef cc_mqttsn::message::Puback PubackMsg; + typedef cc_mqttsn::message::Pubrec PubrecMsg; + typedef cc_mqttsn::message::Pubrel PubrelMsg; + typedef cc_mqttsn::message::Pubcomp PubcompMsg; + typedef cc_mqttsn::message::Subscribe SubscribeMsg; + typedef cc_mqttsn::message::Suback SubackMsg; + typedef cc_mqttsn::message::Unsubscribe UnsubscribeMsg; + typedef cc_mqttsn::message::Unsuback UnsubackMsg; + typedef cc_mqttsn::message::Pingreq PingreqMsg; + typedef cc_mqttsn::message::Pingresp PingrespMsg; + typedef cc_mqttsn::message::Disconnect DisconnectMsg; + typedef cc_mqttsn::message::Willtopicupd WilltopicupdMsg; + typedef cc_mqttsn::message::Willmsgupd WillmsgupdMsg; + typedef cc_mqttsn::message::Willtopicresp WilltopicrespMsg; + typedef cc_mqttsn::message::Willmsgresp WillmsgrespMsg; virtual ~DataProcessor(); @@ -149,7 +149,7 @@ class DataProcessor : public comms::GenericHandler DataBuf prepareGwinfoMsg(std::uint8_t id); DataBuf prepareAdvertiseMsg(std::uint8_t id, unsigned short duration); - DataBuf prepareConnackMsg(mqttsn::field::ReturnCodeVal val); + DataBuf prepareConnackMsg(cc_mqttsn::field::ReturnCodeVal val); DataBuf prepareWilltopicreqMsg(); DataBuf prepareWillmsgreqMsg(); DataBuf prepareRegisterMsg( @@ -159,36 +159,36 @@ class DataProcessor : public comms::GenericHandler DataBuf prepareRegackMsg( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode); + cc_mqttsn::field::ReturnCodeVal retCode); DataBuf preparePublishMsg( std::uint16_t topicId, std::uint16_t msgId, const std::vector& data, TopicIdTypeVal topicIdType, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain, bool duplicate); DataBuf preparePubackMsg( - MqttsnTopicId topicId, + CC_MqttsnTopicId topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode); + cc_mqttsn::field::ReturnCodeVal retCode); DataBuf preparePubrecMsg(std::uint16_t msgId); DataBuf preparePubrelMsg(std::uint16_t msgId); DataBuf preparePubcompMsg(std::uint16_t msgId); DataBuf prepareSubackMsg( - mqttsn::field::QosVal qos, - MqttsnTopicId topicId, + cc_mqttsn::field::QosVal qos, + CC_MqttsnTopicId topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal retCode); + cc_mqttsn::field::ReturnCodeVal retCode); DataBuf prepareUnsubackMsg(std::uint16_t msgId); DataBuf preparePingreqMsg(); DataBuf preparePingrespMsg(); DataBuf prepareDisconnectMsg(std::uint16_t duration = 0); - DataBuf prepareWilltopicrespMsg(mqttsn::field::ReturnCodeVal retCode); - DataBuf prepareWillmsgrespMsg(mqttsn::field::ReturnCodeVal retCode); + DataBuf prepareWilltopicrespMsg(cc_mqttsn::field::ReturnCodeVal retCode); + DataBuf prepareWillmsgrespMsg(cc_mqttsn::field::ReturnCodeVal retCode); private: - typedef mqttsn::frame::Frame ProtStack; + typedef cc_mqttsn::frame::Frame ProtStack; ProtStack m_stack; SearchgwMsgReportCallback m_searchgwMsgReportCallback; diff --git a/client/test/bare_metal_app/startup/startup.s b/client/test/bare_metal_app/startup/startup.s index e848b926..d4677b82 100644 --- a/client/test/bare_metal_app/startup/startup.s +++ b/client/test/bare_metal_app/startup/startup.s @@ -1,5 +1,5 @@ ;@ -;@ Copyright 2013 - 2020 (C). Alex Robenko. All rights reserved. +;@ Copyright 2013 - 2023 (C). Alex Robenko. All rights reserved. ;@ ;@ This Source Code Form is subject to the terms of the Mozilla Public ;@ License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/client/test/bare_metal_app/test_client_build/CMakeLists.txt b/client/test/bare_metal_app/test_client_build/CMakeLists.txt index 0937bb70..90d224b5 100644 --- a/client/test/bare_metal_app/test_client_build/CMakeLists.txt +++ b/client/test/bare_metal_app/test_client_build/CMakeLists.txt @@ -1,4 +1,4 @@ -set (BARE_METAL_CLIENT_OPTS "mqttsn::client::option::ClientIdStaticStorageSize<21>,mqttsn::client::option::GwAddStaticStorageSize<4>,mqttsn::client::option::TopicNameStaticStorageSize<128>,mqttsn::client::option::MessageDataStaticStorageSize<256>,mqttsn::client::option::ClientsAllocLimit<1>,mqttsn::client::option::TrackedGatewaysLimit<1>,mqttsn::client::option::RegisteredTopicsLimit<5>") +set (BARE_METAL_CLIENT_OPTS "cc_mqttsn_client::option::ClientIdStaticStorageSize<21>,cc_mqttsn_client::option::GwAddStaticStorageSize<4>,cc_mqttsn_client::option::TopicNameStaticStorageSize<128>,cc_mqttsn_client::option::MessageDataStaticStorageSize<256>,cc_mqttsn_client::option::ClientsAllocLimit<1>,cc_mqttsn_client::option::TrackedGatewaysLimit<1>,cc_mqttsn_client::option::RegisteredTopicsLimit<5>") set (TEST_BARE_METAL_CLIENT_NAME "test_bare_metal") set (MQTTSN_BARE_METAL_CLIENT_LIB_NAME "cc_mqttsn_${TEST_BARE_METAL_CLIENT_NAME}_client") diff --git a/client/test/bare_metal_app/test_client_build/main.c b/client/test/bare_metal_app/test_client_build/main.c index d69e9178..d5fbeeaa 100644 --- a/client/test/bare_metal_app/test_client_build/main.c +++ b/client/test/bare_metal_app/test_client_build/main.c @@ -1,5 +1,5 @@ // -// Copyright 2014 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2014 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -24,11 +24,11 @@ unsigned cancelTick(void* data) return 0U; } -void connectComplete(void* data, MqttsnAsyncOpStatus status) +void connectComplete(void* data, CC_MqttsnAsyncOpStatus status) { } -void disconnectComplete(void* data, MqttsnAsyncOpStatus status) +void disconnectComplete(void* data, CC_MqttsnAsyncOpStatus status) { } @@ -40,27 +40,27 @@ void sendOutputData(void* data, const unsigned char* buf, unsigned bufSize, bool { } -void publishCallback(void* data, MqttsnAsyncOpStatus status) +void publishCallback(void* data, CC_MqttsnAsyncOpStatus status) { } -void subscribeCallback(void* data, MqttsnAsyncOpStatus status, MqttsnQoS qos) +void subscribeCallback(void* data, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos) { } -void unsubscribeCallback(void* data, MqttsnAsyncOpStatus status) +void unsubscribeCallback(void* data, CC_MqttsnAsyncOpStatus status) { } -void gwStatusReport(void* data, unsigned char gwId, MqttsnGwStatus status) +void gwStatusReport(void* data, unsigned char gwId, CC_MqttsnGwStatus status) { } -void msgReport(void* data, const MqttsnMessageInfo* msgInfo) +void msgReport(void* data, const CC_MqttsnMessageInfo* msgInfo) { } -void willUpdated(void* data, MqttsnAsyncOpStatus status) +void willUpdated(void* data, CC_MqttsnAsyncOpStatus status) { } @@ -74,98 +74,98 @@ int main(int argc, const char** argv) }; static const unsigned DataSize = sizeof(Data)/sizeof(Data[0]); const unsigned char* from = &Seq[0]; - MqttsnClientHandle client = mqttsn_test_bare_metal_client_new(); - MqttsnWillInfo willInfo; + CC_MqttsnClientHandle client = cc_mqttsn_test_bare_metal_client_new(); + CC_MqttsnWillInfo willInfo; - mqttsn_test_bare_metal_client_set_next_tick_program_callback(client, &programNextTick, NULL); - mqttsn_test_bare_metal_client_set_cancel_next_tick_wait_callback(client, &cancelTick, NULL); - mqttsn_test_bare_metal_client_set_send_output_data_callback(client, &sendOutputData, NULL); - mqttsn_test_bare_metal_client_set_gw_disconnect_report_callback(client, &gwDisconnected, NULL); - mqttsn_test_bare_metal_client_set_gw_status_report_callback(client, &gwStatusReport, NULL); - mqttsn_test_bare_metal_client_set_message_report_callback(client, &msgReport, NULL); - if (mqttsn_test_bare_metal_client_start(client) == 0) { + cc_mqttsn_test_bare_metal_client_set_next_tick_program_callback(client, &programNextTick, NULL); + cc_mqttsn_test_bare_metal_client_set_cancel_next_tick_wait_callback(client, &cancelTick, NULL); + cc_mqttsn_test_bare_metal_client_set_send_output_data_callback(client, &sendOutputData, NULL); + cc_mqttsn_test_bare_metal_client_set_gw_disconnect_report_callback(client, &gwDisconnected, NULL); + cc_mqttsn_test_bare_metal_client_set_gw_status_report_callback(client, &gwStatusReport, NULL); + cc_mqttsn_test_bare_metal_client_set_message_report_callback(client, &msgReport, NULL); + if (cc_mqttsn_test_bare_metal_client_start(client) == 0) { return -1; } - mqttsn_test_bare_metal_client_process_data(client, from, SeqSize); - mqttsn_test_bare_metal_client_tick(client); - mqttsn_test_bare_metal_client_connect(client, "my_id", 60, true, NULL, &connectComplete, NULL); - mqttsn_test_bare_metal_client_publish( + cc_mqttsn_test_bare_metal_client_process_data(client, from, SeqSize); + cc_mqttsn_test_bare_metal_client_tick(client); + cc_mqttsn_test_bare_metal_client_connect(client, "my_id", 60, true, NULL, &connectComplete, NULL); + cc_mqttsn_test_bare_metal_client_publish( client, Topic, &Data[0], DataSize, - MqttsnQoS_ExactlyOnceDelivery, + CC_MqttsnQoS_ExactlyOnceDelivery, false, &publishCallback, NULL); - mqttsn_test_bare_metal_client_publish_id( + cc_mqttsn_test_bare_metal_client_publish_id( client, 0x1234, &Data[0], DataSize, - MqttsnQoS_ExactlyOnceDelivery, + CC_MqttsnQoS_ExactlyOnceDelivery, false, &publishCallback, NULL); - mqttsn_test_bare_metal_client_subscribe( + cc_mqttsn_test_bare_metal_client_subscribe( client, Topic, - MqttsnQoS_ExactlyOnceDelivery, + CC_MqttsnQoS_ExactlyOnceDelivery, &subscribeCallback, NULL); - mqttsn_test_bare_metal_client_subscribe_id( + cc_mqttsn_test_bare_metal_client_subscribe_id( client, 0x1111, - MqttsnQoS_ExactlyOnceDelivery, + CC_MqttsnQoS_ExactlyOnceDelivery, &subscribeCallback, NULL); - mqttsn_test_bare_metal_client_cancel(client); + cc_mqttsn_test_bare_metal_client_cancel(client); - mqttsn_test_bare_metal_client_unsubscribe( + cc_mqttsn_test_bare_metal_client_unsubscribe( client, Topic, &unsubscribeCallback, NULL); - mqttsn_test_bare_metal_client_unsubscribe_id( + cc_mqttsn_test_bare_metal_client_unsubscribe_id( client, 0x1111, &unsubscribeCallback, NULL); - mqttsn_test_bare_metal_client_sleep( + cc_mqttsn_test_bare_metal_client_sleep( client, 10000, &unsubscribeCallback, NULL); - mqttsn_test_bare_metal_client_check_messages( + cc_mqttsn_test_bare_metal_client_check_messages( client, &unsubscribeCallback, NULL); - mqttsn_test_bare_metal_client_set_retry_period(client, 10); - mqttsn_test_bare_metal_client_set_retry_count(client, 3); - mqttsn_test_bare_metal_client_set_broadcast_radius(client, 0); - mqttsn_test_bare_metal_client_set_searchgw_enabled(client, true); - mqttsn_test_bare_metal_client_search_gw(client); - mqttsn_test_bare_metal_client_discard_gw(client, 0); - mqttsn_test_bare_metal_client_discard_all_gw(client); - mqttsn_test_bare_metal_client_reconnect(client, &connectComplete, NULL); - - mqttsn_test_bare_metal_client_will_update(client, &willInfo, &willUpdated, NULL); - mqttsn_test_bare_metal_client_will_topic_update(client, Topic, MqttsnQoS_ExactlyOnceDelivery, false, &willUpdated, NULL); - mqttsn_test_bare_metal_client_will_msg_update(client, Data, DataSize, &willUpdated, NULL); - - mqttsn_test_bare_metal_client_disconnect(client, &disconnectComplete, NULL); - mqttsn_test_bare_metal_client_stop(client); - mqttsn_test_bare_metal_client_free(client); + cc_mqttsn_test_bare_metal_client_set_retry_period(client, 10); + cc_mqttsn_test_bare_metal_client_set_retry_count(client, 3); + cc_mqttsn_test_bare_metal_client_set_broadcast_radius(client, 0); + cc_mqttsn_test_bare_metal_client_set_searchgw_enabled(client, true); + cc_mqttsn_test_bare_metal_client_search_gw(client); + cc_mqttsn_test_bare_metal_client_discard_gw(client, 0); + cc_mqttsn_test_bare_metal_client_discard_all_gw(client); + cc_mqttsn_test_bare_metal_client_reconnect(client, &connectComplete, NULL); + + cc_mqttsn_test_bare_metal_client_will_update(client, &willInfo, &willUpdated, NULL); + cc_mqttsn_test_bare_metal_client_will_topic_update(client, Topic, CC_MqttsnQoS_ExactlyOnceDelivery, false, &willUpdated, NULL); + cc_mqttsn_test_bare_metal_client_will_msg_update(client, Data, DataSize, &willUpdated, NULL); + + cc_mqttsn_test_bare_metal_client_disconnect(client, &disconnectComplete, NULL); + cc_mqttsn_test_bare_metal_client_stop(client); + cc_mqttsn_test_bare_metal_client_free(client); while (true) {}; return 0; } diff --git a/client/test/bare_metal_app/test_client_build/stub.cpp b/client/test/bare_metal_app/test_client_build/stub.cpp index e8fb8e91..aef75a3a 100644 --- a/client/test/bare_metal_app/test_client_build/stub.cpp +++ b/client/test/bare_metal_app/test_client_build/stub.cpp @@ -1,5 +1,5 @@ // -// Copyright 2014 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2014 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/doc/BUILD.md b/doc/BUILD.md index 8d3aaff6..de8bb670 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -15,21 +15,24 @@ The provided libraries depend on several external projects: provides [COMMS library](https://github.com/commschamp/comms) which is used to define the protocols. -In case these external dependencies are also built externally paths to them -can be provided using **CC_MQTTSN_GENERATED_INSTALL_DIR**, **CC_MQTT311_GENERATED_INSTALL_DIR**, -and **CC_MAIN_INSTALL_DIR** respectively. If these paths are not provided, the -build process will check out and build the necessary dependencies. +These dependencies are expected to be built independenty and access to them provided +via standard **CMAKE_PREFIX_PATH** cmake variable. There are also scripts ( +[script/prepare_externals.sh](script/prepare_externals.sh) for Linux and +[script/prepare_externals.bat](script/prepare_externals.bat) for Windows) +which can help in preparation of these dependencies. They are also used +in configuration of the [github actions](.github/workflows/actions_build.yml) and +[appveyor](.appveyor.yml). ## Choosing C++ Standard - Since CMake v3.1 it became possible to set version of C++ standard by setting **CMAKE_CXX_STANDARD** variable. If no value of this variable is set in command line arguments, default value **11** will be assigned to it. In order to use c++14 standard in compilation, set the variable value to **14**. -Please **NOTE**, that _clang_ compiler has problems compiling valid c++11 constructs -used in this project. Hence, the compilation will fail unless the compilation is +Please **NOTE**, that some older versions of the _clang_ compiler habe problems +compiling valid c++11 constructs used in this project. +Hence, the compilation will fail unless the compilation is configured to use c++14 standard. ## Build and Install Examples @@ -49,21 +52,24 @@ builds. ### Build MQTT-SN Client/Gateway Libraries and Applications ``` -$> cmake -DCMAKE_BUILD_TYPE=Release .. +$> cmake .. -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH=/path/to/comms/install\;/path/to/cc.mqttsn.generated/install\;/path/to/cc.mqtt311.generated/install ``` ### Build Two Custom Client Libraries See [custom_client_build.md](custom_client_build.md) for details on custom build configuration ``` -$> cmake -DCMAKE_BUILD_TYPE=Release -DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF \ +$> cmake .. -DCMAKE_BUILD_TYPE=Release -DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF \ -DCC_MQTTSN_BUILD_GATEWAY=OFF \ - -DCC_MQTTSN_CUSTOM_CLIENT_CONFIG_FILES=config1.cmake\;config2.cmake .. + -DCC_MQTTSN_CUSTOM_CLIENT_CONFIG_FILES=config1.cmake\;config2.cmake \ + -DCMAKE_PREFIX_PATH=/path/to/comms/install\;/path/to/cc.mqttsn.generated/install ``` ### Build Gateway Library and Application(s) ``` -$> cmake -DCMAKE_BUILD_TYPE=Release -DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF .. +$> cmake .. -DCMAKE_BUILD_TYPE=Release -DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF \ + -DCMAKE_PREFIX_PATH=/path/to/comms/install\;/path/to/cc.mqttsn.generated/install\;/path/to/cc.mqtt311.generated/install ``` diff --git a/doc/custom_client_build.md b/doc/custom_client_build.md index 1cde36d0..e92c73b7 100644 --- a/doc/custom_client_build.md +++ b/doc/custom_client_build.md @@ -17,103 +17,103 @@ various lists, because there is no known and predefined limit on string length and/or number of elements in the list. However if such limit is specified, the library will use [StaticString](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticString.h) and [StaticVector](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticVector.h) -from [COMMS library](https://github.com/commschamp/comms) +from the [COMMS library](https://github.com/commschamp/comms) instead. These classes don't use exceptions and/or dynamic memory allocation and can be suitable for bare-metal systems. -### MQTTSN_CUSTOM_CLIENT_NAME +### CC_MQTTSN_CUSTOM_CLIENT_NAME This variable specifies the name of the custom client library. It will influence the names of the API functions. The **default** client build (controlled by **CC_MQTTSN_CLIENT_DEFAULT_LIB** option) prefixes all the -functions with `mqttsn_client_`, while client with custom name will produce +functions with `cc_mqttsn_client_`, while client with custom name will produce functions having `mqttsn__client_` prefix. For example having the -`set (MQTTSN_CUSTOM_CLIENT_NAME "my_name")` statement in configuration file +`set (CC_MQTTSN_CUSTOM_CLIENT_NAME "my_name")` statement in configuration file will produce a library which prefixes all API functions with `mqttsn_my_name_client_`. -The **MQTTSN_CUSTOM_CLIENT_NAME** variable is a **must have** one, without it +The **CC_MQTTSN_CUSTOM_CLIENT_NAME** variable is a **must have** one, without it the custom build of the client library won't be possible. -### MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE +### CC_MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE The MQTT-SN needs to store the client ID string. By default it is stored using [std::string](http://en.cppreference.com/w/cpp/string/basic_string) type. The -**MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE** variable can be used to set +**CC_MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE** variable can be used to set the limit to the client ID string known at compile time, as the result the [StaticString](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticString.h) type will be used instead. ``` # Allow up to 20 characters in client ID string -set(MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE 20) +set(CC_MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE 20) ``` -### MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE +### CC_MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE The MQTT-SN protocol defines **SEARCHGW** message, which can contain the address of the gateway. The client library doesn't make any assumptions on maximum length of the address information. As the result it uses [std::vector](http://en.cppreference.com/w/cpp/container/vector) type to store such information. If the limit of the address's length is known at compile -time, use **MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE** variable to +time, use **CC_MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE** variable to specify the limit. It will cause [StaticVector](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticVector.h) to be used instead. ``` # The address of GW can be stored within 4 bytes (IP4 for example) -set(MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE 4) +set(CC_MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE 4) ``` -### MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE +### CC_MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE Similar to the client id, the maximum length of the topic string is not known, and [std::string](http://en.cppreference.com/w/cpp/string/basic_string) type is -used as the result. Use **MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE** +used as the result. Use **CC_MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE** option to limit the maximum length and force usage of [StaticString](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticString.h) instead. ``` # The topics contain no more than 64 characters -set(MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE 64) +set(CC_MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE 64) ``` -### MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE +### CC_MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE The MQTT-SN protocol defines **PUBLISH** message, which contains binary data being published. If there is no known limit for the length of such data, the [std::vector](http://en.cppreference.com/w/cpp/container/vector) type will be used. However, if there is a limit known at compile time, the -**MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE** can be used to specify the +**CC_MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE** can be used to specify the limit and force usage of [StaticVector](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticVector.h) type instead. ``` # The message data is no more than 128 bytes long -set(MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE 128) +set(CC_MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE 128) ``` -### MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT +### CC_MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT The client library allows allocation of multiple client managing objects -(**mqttsn_client_alloc()** function). By default, there is no limit on such +(**cc_mqttsn_client_alloc()** function). By default, there is no limit on such allocations, and as a result every such object is dynamically allocated. However, if there is a known limit for number of client managing objects, the -library will be requested to allocate, use ***MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT** +library will be requested to allocate, use ***CC_MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT** variable to specify such limit. If the limit is specified the library will use static pool for allocation and won't use heap for this purpose. ``` # Only 1 MQTT-SN client will be allocated -set(MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT 1) +set(CC_MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT 1) ``` -### MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT +### CC_MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT The client library monitors and keep information about available gateways. When the number of possible gateways is not known such information is stored using [std::vector](http://en.cppreference.com/w/cpp/container/vector) type. However, if there is a known limit on number of the available gateways on the nenwork, the client library may be compiled to use [StaticVector](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticVector.h) -instead. Use **MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT** variable for this purpose. +instead. Use **CC_MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT** variable for this purpose. ``` # The library doesn't need to support more than 1 gateway -set(MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT 1) +set(CC_MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT 1) ``` -### MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT +### CC_MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT The MQTT-SN protocol uses topic IDs in its **PUBLISH** message, and requires topic strings to be registered with the gateway, which in turn is responsible to allocate numeric IDs for them. The client object must store the registration @@ -121,23 +121,23 @@ information. By default, there is no known limit on how many topics need to be registered. As the result the library uses [std::vector](http://en.cppreference.com/w/cpp/container/vector) to store all the required information. However, if there is predefined limit for number of topics -the client object must be able to keep inside, the **MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT** +the client object must be able to keep inside, the **CC_MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT** variable can be used to force usage of [StaticVector](https://github.com/commschamp/comms/blob/master/include/comms/util/StaticVector.h) type instead. ``` # No need to support registration of more than 32 topic strings -set(MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT 32) +set(CC_MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT 32) ``` -### MQTTSN_CUSTOM_CLIENT_NO_STDLIB +### CC_MQTTSN_CUSTOM_CLIENT_NO_STDLIB Sometimes the bare metal applications are compiled without standard library (using `-nostdlib` option with gcc compiler). To prevent the client library from explicitly calling functions provided by the standard library, -set **MQTTSN_CUSTOM_CLIENT_NO_STDLIB** value to `TRUE`. +set **CC_MQTTSN_CUSTOM_CLIENT_NO_STDLIB** value to `TRUE`. ``` # Don't use standard library functions. -set(MQTTSN_CUSTOM_CLIENT_NO_STDLIB TRUE) +set(CC_MQTTSN_CUSTOM_CLIENT_NO_STDLIB TRUE) ``` **NOTE**, that it doesn't prevent the library from using **STL**, and the compiler may still generate code invoking functions like `memcpy` or `memset`. It will @@ -148,9 +148,9 @@ Also **NOTE**, that the library is implemented in **C++** (although it provides constructors prior to invocation of the `main()` function. It is recommended to read -[Practical Guide to Bare Metal C++](https://www.gitbook.com/book/arobenko/bare_metal_cpp/details) +[Practical Guide to Bare Metal C++](https://arobenko.github.io/bare_metal_cpp) free e-book, especially -[Know Your Compiler Output](https://arobenko.gitbooks.io/bare_metal_cpp/content/compiler_output/) +[Know Your Compiler Output](https://arobenko.github.io/bare_metal_cpp/#_know_your_compiler_output) chapter. It will guide the reader through necessary functions that may need to be implemented to make the bare-metal application, written in C++, work. @@ -162,52 +162,52 @@ and [std::vector](http://en.cppreference.com/w/cpp/container/vector), may look like this: ``` # Name of the client API -set (MQTTSN_CUSTOM_CLIENT_NAME "bare_metal") +set (CC_MQTTSN_CUSTOM_CLIENT_NAME "bare_metal") # Use up to 20 characters for client ID -set(MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE 20) +set(CC_MQTTSN_CUSTOM_CLIENT_ID_STATIC_STORAGE_SIZE 20) # The address of GW can be stored within 2 bytes -set(MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE 2) +set(CC_MQTTSN_CUSTOM_CLIENT_GW_ADDR_STATIC_STORAGE_SIZE 2) # Support only topics containing no more than 64 characters -set(MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE 64) +set(CC_MQTTSN_CUSTOM_CLIENT_TOPIC_NAME_STATIC_STORAGE_SIZE 64) # The message data is no more than 128 bytes long -set(MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE 128) +set(CC_MQTTSN_CUSTOM_CLIENT_MSG_DATA_STATIC_STORAGE_SIZE 128) # The library won't support more than 1 allocated client object -set(MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT 1) +set(CC_MQTTSN_CUSTOM_CLIENT_ALLOC_LIMIT 1) # The library doesn't need to support more than 1 gateway -set(MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT 1) +set(CC_MQTTSN_CUSTOM_CLIENT_TRACKED_GW_LIMIT 1) # No need to support registration of more than 8 topic strings -set(MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT 8) +set(CC_MQTTSN_CUSTOM_CLIENT_REGISTERED_TOPICS_LIMIT 8) # Don't use standard library functions. -set(MQTTSN_CUSTOM_CLIENT_NO_STDLIB TRUE) +set(CC_MQTTSN_CUSTOM_CLIENT_NO_STDLIB TRUE) ``` As the result of such configuration, the static library `cc_mqttsn_bare_metal_client` will be generated, which will contain functions defined in -`include/mqttsn/client/bare_metal_client.h" header file: +`include/cc_mqttsn_client/bare_metal_client.h" header file: ```c -MqttsnClientHandle mqttsn_bare_metal_client_new(); +CC_MqttsnClientHandle mqttsn_bare_metal_client_new(); -void mqttsn_bare_metal_client_free(MqttsnClientHandle client); +void mqttsn_bare_metal_client_free(CC_MqttsnClientHandle client); void mqttsn_bare_metal_client_set_next_tick_program_callback( - MqttsnClientHandle client, - MqttsnNextTickProgramFn fn, + CC_MqttsnClientHandle client, + CC_MqttsnNextTickProgramFn fn, void* data); void mqttsn_bare_metal_client_set_cancel_next_tick_wait_callback( - MqttsnClientHandle client, - MqttsnCancelNextTickWaitFn fn, + CC_MqttsnClientHandle client, + CC_MqttsnCancelNextTickWaitFn fn, void* data); ... ``` **NOTE**, that all the functions have **mqttsn_bare_metal_** prefix due to the -fact of setting value of **MQTTSN_CUSTOM_CLIENT_NAME** variable to "bare_metal" string. +fact of setting value of **CC_MQTTSN_CUSTOM_CLIENT_NAME** variable to "bare_metal" string. diff --git a/gateway/CMakeLists.txt b/gateway/CMakeLists.txt index 3671f8fa..b71b599f 100644 --- a/gateway/CMakeLists.txt +++ b/gateway/CMakeLists.txt @@ -4,60 +4,14 @@ endif () ###################################################################### -set (CC_MQTT_EXTERNAL_DIR "${EXTERNALS_DIR}/cc.mqtt311.generated") -set (CC_MQTT_EXTERNAL_TGT "mqtt_external") -set (CC_MQTT_EXTERNAL_TGT_INCLUDE) - -if ("${CC_MQTT311_GENERATED_INSTALL_DIR}" STREQUAL "") - execute_process ( - COMMAND ${CMAKE_COMMAND} -E make_directory "${EXTERNALS_DIR}") - - include(ExternalProject) - - set (cc_mqtt_generated_tag "${CC_MQTT311_PROTOCOL_TAG}") - set (cc_mqtt_main_dir "${CMAKE_CURRENT_BINARY_DIR}/cc.mqtt311.generated") - set (cc_mqtt_src_dir "${CC_MQTT_EXTERNAL_DIR}") - set (cc_mqtt_bin_dir "${cc_mqtt_main_dir}/build") - set (cc_mqtt_install_dir "${cc_mqtt_main_dir}/install") - set (cc_mqtt_update_disconnected) - if (CC_MQTTSN_EXTERNALS_UPDATE_DISCONNECTED) - set (cc_mqtt_update_disconnected UPDATE_DISCONNECTED 1) - endif () - - - ExternalProject_Add( - "${CC_MQTT_EXTERNAL_TGT}" - PREFIX "${cc_mqtt_bin_dir}" - STAMP_DIR "${cc_mqtt_bin_dir}" - GIT_REPOSITORY "${CC_MQTT311_PROTOCOL_REPO}" - GIT_TAG "${cc_mqtt_generated_tag}" - SOURCE_DIR "${cc_mqtt_src_dir}" - CMAKE_ARGS - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${cc_mqtt_install_dir} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DOPT_REQUIRE_COMMS_LIB=OFF - ${CC_MQTT311_PROTOCOL_CMAKE_ARGS} - BINARY_DIR "${cc_mqtt_bin_dir}" - ${cc_mqtt_update_disconnected} - ) - set (CC_MQTT_EXTERNAL_TGT_INCLUDE "${cc_mqtt_install_dir}/include") -else () - list (APPEND CMAKE_PREFIX_PATH "${CC_MQTT311_GENERATED_INSTALL_DIR}") - find_package(mqtt311 NO_MODULE) - if (NOT TARGET cc::mqtt311) - message (FATAL_ERROR "Failed to find external mqtt311 library") - endif () -endif () +find_package(LibComms REQUIRED) +find_package(cc_mqttsn REQUIRED) +find_package(cc_mqtt311 REQUIRED) ###################################################################### - -include_directories( - BEFORE - ${CMAKE_CURRENT_SOURCE_DIR}/include -) +set (GATEWAY_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) + if (CMAKE_COMPILER_IS_GNUCC) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-backtrace-limit=0") endif () @@ -68,20 +22,20 @@ add_subdirectory (src) add_subdirectory (test) install ( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/mqttsn - DESTINATION ${INC_INSTALL_DIR} + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/cc_mqttsn_gateway + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/etc/ - DESTINATION ${ETC_INSTALL_DIR}/mqttsn/ + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cc_mqttsn_gateway ) ###################################################################### find_package (Doxygen) if (DOXYGEN_FOUND) - set (doc_output_dir "${DOC_INSTALL_DIR}/mqttsn/gateway") + set (doc_output_dir "${CMAKE_INSTALL_FULL_DATAROOTDIR}/doc/cc_mqttsn_gateway") make_directory (${doc_output_dir}) set (match_str "OUTPUT_DIRECTORY[^\n]*") diff --git a/gateway/doc/config.dox b/gateway/doc/config.dox index 63abedc7..a287d054 100644 --- a/gateway/doc/config.dox +++ b/gateway/doc/config.dox @@ -1,4 +1,4 @@ -/// @page mqttsn_gw_config_page Config +/// @page cc_mqttsn_gw_config_page Config /// @tableofcontents /// The @b Config object is responsible to provide a common way to parse the /// configuration file and provide a convenient interface to retrieve any @@ -6,23 +6,23 @@ /// @b Session objects. The format of the configuration file is described in the /// example config file provided with the project. /// -/// @section mqttsn_gw_config_page_alloc Allocation -/// When using @b C++ interface, just instantiate object of mqttsn::gateway::Config +/// @section cc_mqttsn_gw_config_page_alloc Allocation +/// When using @b C++ interface, just instantiate object of cc_mqttsn_gateway::Config /// class. The destruction of the object will clean up all acquired resources. /// @code -/// mqttsn::gateway::Config config; +/// cc_mqttsn_gateway::Config config; /// @endcode /// -/// When using @b C interface, the allocation is performed using mqttsn_gw_config_alloc() +/// When using @b C interface, the allocation is performed using cc_mqttsn_gw_config_alloc() /// @code -/// MqttsnConfigHandle handle = mqttsn_gw_config_alloc(); +/// CC_MqttsnConfigHandle handle = cc_mqttsn_gw_config_alloc(); /// @endcode -/// and de-allocation is performed using mqttsn_gw_config_free() functions. +/// and de-allocation is performed using cc_mqttsn_gw_config_free() functions. /// @code -/// mqttsn_gw_config_free(handle); +/// cc_mqttsn_gw_config_free(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_parse Read and Parse Configuration +/// @section cc_mqttsn_gw_config_page_parse Read and Parse Configuration /// The gateway application may have multiple configuration options. These /// options and their parameters may be listed in a special configuration file. /// The expected format of the file is as following: @@ -49,19 +49,19 @@ /// /// @b C interface also allows either reading from file: /// @code -/// mqttsn_gw_config_read(handle, "/path/to/config/file"); +/// cc_mqttsn_gw_config_read(handle, "/path/to/config/file"); /// @endcode /// or parsing the string, if configuration file contents have been read from /// file into a buffer earlier: /// @code /// char buf[4096] = {0}; /// ... /* read data from buf into buf, put \0 at the end */ -/// mqttsn_gw_config_parse(handle, buf); +/// cc_mqttsn_gw_config_parse(handle, buf); /// @endcode /// -/// @section mqttsn_gw_config_page_id Gateway ID -/// Both @ref mqttsn_gw_gateway_page (see @ref mqttsn_gw_gateway_page_gw) -/// and @ref mqttsn_gw_session_page (see @ref mqttsn_gw_session_page_id) objects require +/// @section cc_mqttsn_gw_config_page_id Gateway ID +/// Both @ref cc_mqttsn_gw_gateway_page (see @ref cc_mqttsn_gw_gateway_page_gw) +/// and @ref cc_mqttsn_gw_session_page (see @ref cc_mqttsn_gw_session_page_id) objects require /// knowledge of gateway numeric ID to be able to properly report it to the /// client(s). /// @@ -72,13 +72,13 @@ /// /// @b C interface: /// @code -/// unsigned char id = mqttsn_gw_config_id(handle); +/// unsigned char id = cc_mqttsn_gw_config_id(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_advertise Advertise Period -/// The @ref mqttsn_gw_gateway_page object sends @b ADVERTISE message periodically. +/// @section cc_mqttsn_gw_config_page_advertise Advertise Period +/// The @ref cc_mqttsn_gw_gateway_page object sends @b ADVERTISE message periodically. /// It needs to be configured with propere period value -/// (see @ref mqttsn_gw_gateway_page_adv_period). Use the following interface +/// (see @ref cc_mqttsn_gw_gateway_page_adv_period). Use the following interface /// to retrieve this value from the @b Config object. /// /// @b C++ interface: @@ -88,13 +88,13 @@ /// /// @b C interface: /// @code -/// unsigned short period = mqttsn_gw_config_advertise_period(handle); +/// unsigned short period = cc_mqttsn_gw_config_advertise_period(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_retry Retry Configuration -/// The @ref mqttsn_gw_session_page object can be configured with period between +/// @section cc_mqttsn_gw_config_page_retry Retry Configuration +/// The @ref cc_mqttsn_gw_session_page object can be configured with period between /// its retry attempts as well as number of such attempts (see -/// @ref mqttsn_gw_session_page_retry). Use the following interface of the +/// @ref cc_mqttsn_gw_session_page_retry). Use the following interface of the /// @b Config object to retreive these values: /// /// @b C++ interface: @@ -105,13 +105,13 @@ /// /// @b C interface: /// @code -/// unsigned period = mqttsn_gw_config_retry_period(handle); -/// unsigned attempts = mqttsn_gw_config_retry_count(handle); +/// unsigned period = cc_mqttsn_gw_config_retry_period(handle); +/// unsigned attempts = cc_mqttsn_gw_config_retry_count(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_default_client Default Client ID -/// Can be used in @ref mqttsn_gw_session_page object configuration (see -/// @ref mqttsn_gw_session_page_default_client_id). +/// @section cc_mqttsn_gw_config_page_default_client Default Client ID +/// Can be used in @ref cc_mqttsn_gw_session_page object configuration (see +/// @ref cc_mqttsn_gw_session_page_default_client_id). /// /// @b C++ interface: /// @code @@ -120,12 +120,12 @@ /// /// @b C interface: /// @code -/// const char* clientId = mqttsn_gw_config_default_client_id(handle); +/// const char* clientId = cc_mqttsn_gw_config_default_client_id(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_pub_only_keep_alive Keep Alive Period for Publish Only Clients -/// Can be used in @ref mqttsn_gw_session_page object configuration (see -/// @ref mqttsn_gw_session_page_publish_only). +/// @section cc_mqttsn_gw_config_page_pub_only_keep_alive Keep Alive Period for Publish Only Clients +/// Can be used in @ref cc_mqttsn_gw_session_page object configuration (see +/// @ref cc_mqttsn_gw_session_page_publish_only). /// /// @b C++ interface: /// @code @@ -134,12 +134,12 @@ /// /// @b C interface: /// @code -/// unsigned short keepAlivePeriod = mqttsn_gw_config_pub_only_keep_alive(handle); +/// unsigned short keepAlivePeriod = cc_mqttsn_gw_config_pub_only_keep_alive(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_sleeping_client_msg_limit Limit Messages for Sleeping Clients -/// Can be used in @ref mqttsn_gw_session_page object configuration (see -/// @ref mqttsn_gw_session_page_sleep). +/// @section cc_mqttsn_gw_config_page_sleeping_client_msg_limit Limit Messages for Sleeping Clients +/// Can be used in @ref cc_mqttsn_gw_session_page object configuration (see +/// @ref cc_mqttsn_gw_session_page_sleep). /// /// @b C++ interface: /// @code @@ -148,28 +148,28 @@ /// /// @b C interface: /// @code -/// unsigned limit = mqttsn_gw_config_sleeping_client_msg_limit(handle); +/// unsigned limit = cc_mqttsn_gw_config_sleeping_client_msg_limit(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_predefined_topics Predefined Topics -/// The @ref mqttsn_gw_session_page object can be configured with -/// number of predefined topics (see @ref mqttsn_gw_session_page_predefined_topics). +/// @section cc_mqttsn_gw_config_page_predefined_topics Predefined Topics +/// The @ref cc_mqttsn_gw_session_page object can be configured with +/// number of predefined topics (see @ref cc_mqttsn_gw_session_page_predefined_topics). /// Retrieve this information from the @b Config object using the following /// API. /// /// @b C++ interface: /// @code -/// const mqttsn::gateway::Config::PredefinedTopicsList& list = config.predefinedTopics(); +/// const cc_mqttsn_gateway::Config::PredefinedTopicsList& list = config.predefinedTopics(); /// ... // iterate over the list and assign values to @b Session object(s). /// @endcode /// /// @b C interface: /// @code -/// MqttsnPredefinedTopicInfo infos[100]; -/// unsigned count = mqttsn_gw_config_get_predefined_topics(handle, infos, 100); +/// CC_MqttsnPredefinedTopicInfo infos[100]; +/// unsigned count = cc_mqttsn_gw_config_get_predefined_topics(handle, infos, 100); /// unsigned idx; /// for (idx = 0; idx < count; idx++) { -/// const MqttsnPredefinedTopicInfo* elem = infos[idx]; +/// const CC_MqttsnPredefinedTopicInfo* elem = infos[idx]; /// ... /* assign elem info to @b Session object(s). /// } /// @endcode @@ -178,24 +178,24 @@ /// there is no known limit for the buffer upfront and it needs to be dynamically /// allocated: /// @code -/// unsigned count = mqttsn_gw_config_available_predefined_topics(handle); +/// unsigned count = cc_mqttsn_gw_config_available_predefined_topics(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_client_auth Authentication Information -/// The @ref mqttsn_gw_session_page object can inquire authentication information -/// when some client attempts connection (see @ref mqttsn_gw_session_page_client_auth). +/// @section cc_mqttsn_gw_config_page_client_auth Authentication Information +/// The @ref cc_mqttsn_gw_session_page object can inquire authentication information +/// when some client attempts connection (see @ref cc_mqttsn_gw_session_page_client_auth). /// Retrieve this information from the @b Config object using the following /// API. /// /// @b C++ interface: /// @code -/// const mqttsn::gateway::Config::AuthInfosList& list = config.authInfos(); +/// const cc_mqttsn_gateway::Config::AuthInfosList& list = config.authInfos(); /// @endcode /// /// @b C interface: /// @code -/// MqttsnAuthInfo infos[100]; -/// unsigned count = mqttsn_gw_config_get_auth_infos(handle, infos, 100); +/// CC_MqttsnAuthInfo infos[100]; +/// unsigned count = cc_mqttsn_gw_config_get_auth_infos(handle, infos, 100); /// ... // use up to count infos. /// @endcode /// @@ -204,19 +204,19 @@ /// there is no known limit for the buffer upfront and it needs to be dynamically /// allocated: /// @code -/// unsigned count = mqttsn_gw_config_available_auth_infos(handle); +/// unsigned count = cc_mqttsn_gw_config_available_auth_infos(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_topic_id_range Topic ID Allocation Range -/// The @ref mqttsn_gw_session_page object can be configured to limit its +/// @section cc_mqttsn_gw_config_page_topic_id_range Topic ID Allocation Range +/// The @ref cc_mqttsn_gw_session_page object can be configured to limit its /// range of topic IDs, which are allocated for newly registered topic strings -/// (see @ref mqttsn_gw_session_page_topics_registration). +/// (see @ref cc_mqttsn_gw_session_page_topics_registration). /// Retrieve this information from the @b Config object using the following /// API. /// /// @b C++ interface: /// @code -/// const mqttsn::gateway::Config::TopicIdsRange range = config.topicIdAllocRange(); +/// const cc_mqttsn_gateway::Config::TopicIdsRange range = config.topicIdAllocRange(); /// std::uint16_t minTopicId = range.first; /// std::uint16_t maxTopicId = range.second; /// @endcode @@ -225,10 +225,10 @@ /// @code /// unsigned short minTopicId = 0; /// unsigned short maxTopicId = 0; -/// mqttsn_gw_config_topic_id_alloc_range(handle, &minTopicId, &maxTopicId); +/// cc_mqttsn_gw_config_topic_id_alloc_range(handle, &minTopicId, &maxTopicId); /// @endcode /// -/// @section mqttsn_gw_config_page_broker_addr Broker Address and Port +/// @section cc_mqttsn_gw_config_page_broker_addr Broker Address and Port /// The MQTT-SN gateway application must connect and forward traffic to /// MQTT broker. Below are API functions that can be used to retrieve the /// TCP/IP address and port of the broker. @@ -241,11 +241,11 @@ /// /// @b C interface /// @code -/// const char* addr = mqttsn_gw_config_broker_address(handle); -/// unsigned short port = mqttsn_gw_config_broker_port(handle); +/// const char* addr = cc_mqttsn_gw_config_broker_address(handle); +/// unsigned short port = cc_mqttsn_gw_config_broker_port(handle); /// @endcode /// -/// @section mqttsn_gw_config_page_custom Custom Configuration Values +/// @section cc_mqttsn_gw_config_page_custom Custom Configuration Values /// The @b Config object has a list of predefined options it recognises in the /// configuration file. It also accumulates all the options it doesn't recognise. /// As a reminder: the first word (until the first white character) in the @@ -256,27 +256,27 @@ /// /// @b C++ interface /// @code -/// const mqttsn::gateway::Config::ConfigMap map = config.configMap(); +/// const cc_mqttsn_gateway::Config::ConfigMap map = config.configMap(); /// auto iters = map.equal_range("my_custom_config"); /// for (auto iter = iters.first; iter != iters.second; ++iter) { /// const std::string& value = iter->second; /// ... // Parse and use the value /// } /// @endcode -/// @b NOTE, that mqttsn::gateway::Config::ConfigMap type is a @b multimap, +/// @b NOTE, that cc_mqttsn_gateway::Config::ConfigMap type is a @b multimap, /// it allows multiple entries for the same key. /// /// @b C interface: @n /// First, retrieve the number of available entries for the provided configuration /// key: /// @code -/// unsigned count = mqttsn_gw_config_values_count(handle, "my_custom_config"); +/// unsigned count = cc_mqttsn_gw_config_values_count(handle, "my_custom_config"); /// @endcode /// Then, access the available configuration values: /// @code /// unsigned idx; /// for (idx = 0; idx < count; idx++) { -/// const char* value = mqttsn_gw_config_get_value(handle, "my_custom_config", idx); +/// const char* value = cc_mqttsn_gw_config_get_value(handle, "my_custom_config", idx); /// ... /* Parse and use the value */ /// } /// @endcode diff --git a/gateway/doc/doxygen.conf b/gateway/doc/doxygen.conf index 5e807915..44565963 100644 --- a/gateway/doc/doxygen.conf +++ b/gateway/doc/doxygen.conf @@ -1,4 +1,4 @@ -# Doxyfile 1.8.11 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -17,11 +17,11 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -93,6 +93,14 @@ ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. @@ -179,6 +187,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -199,6 +217,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -226,16 +252,15 @@ TAB_SIZE = 4 # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all @@ -264,28 +289,40 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -293,6 +330,15 @@ EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -318,7 +364,7 @@ BUILTIN_STL_SUPPORT = YES CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -404,6 +450,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -424,6 +483,12 @@ EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -461,6 +526,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -478,8 +550,8 @@ HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -498,11 +570,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = YES @@ -689,7 +768,7 @@ LAYOUT_FILE = doc/layout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -734,13 +813,17 @@ WARN_IF_DOC_ERROR = NO # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = YES @@ -776,8 +859,8 @@ INPUT = # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -790,13 +873,61 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, -# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. - -FILE_PATTERNS = +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -949,7 +1080,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -981,12 +1112,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1009,16 +1140,22 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. # Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse-libclang=ON option for CMake. +# generated with the -Duse_libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories @@ -1027,6 +1164,19 @@ CLANG_ASSISTED_PARSING = NO CLANG_OPTIONS = +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1038,13 +1188,6 @@ CLANG_OPTIONS = ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1145,7 +1288,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1181,6 +1324,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1204,13 +1358,14 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1249,8 +1404,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1280,7 +1435,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1325,7 +1480,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1333,8 +1489,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1342,30 +1498,30 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1442,6 +1598,17 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1451,7 +1618,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1462,8 +1629,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1475,7 +1648,7 @@ USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1490,11 +1663,11 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example @@ -1505,7 +1678,8 @@ MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1533,7 +1707,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1552,7 +1726,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1565,8 +1740,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1617,21 +1793,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_CMD_NAME = latex +LATEX_CMD_NAME = # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1716,9 +1906,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1752,7 +1944,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1766,6 +1958,14 @@ LATEX_BIB_STYLE = plain LATEX_TIMESTAMP = NO +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1805,9 +2005,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1816,8 +2016,8 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = @@ -1903,6 +2103,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1935,9 +2142,9 @@ DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2214,10 +2421,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2336,7 +2565,7 @@ MSCFILE_DIRS = # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the # path where java can find the plantuml.jar file. If left blank, it is assumed @@ -2346,6 +2575,11 @@ DIAFILE_DIRS = PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. @@ -2394,7 +2628,7 @@ DOT_TRANSPARENT = NO # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_MULTI_TARGETS = YES +DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated @@ -2404,9 +2638,11 @@ DOT_MULTI_TARGETS = YES GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/gateway/doc/gateway.dox b/gateway/doc/gateway.dox index 7858d99e..db66f583 100644 --- a/gateway/doc/gateway.dox +++ b/gateway/doc/gateway.dox @@ -1,26 +1,26 @@ -/// @page mqttsn_gw_gateway_page Gateway +/// @page cc_mqttsn_gw_gateway_page Gateway /// @tableofcontents /// The @b Gateway object is responsible to advertise the gateway presence to /// all the possible clients on MQTT-SN network. If such advertisement is not /// needed, there is no need to create or use the @b Gateway object. /// -/// @section mqttsn_gw_gateway_page_alloc Allocation -/// When using @b C++ interface, just instantiate object of mqttsn::gateway::Gateway +/// @section cc_mqttsn_gw_gateway_page_alloc Allocation +/// When using @b C++ interface, just instantiate object of cc_mqttsn_gateway::Gateway /// class. The destruction of the object will clean up all acquired resources. /// @code -/// mqttsn::gateway::Gateway gw; +/// cc_mqttsn_gateway::Gateway gw; /// @endcode /// -/// When using @b C interface, the allocation is performed using mqttsn_gw_alloc() +/// When using @b C interface, the allocation is performed using cc_mqttsn_gw_alloc() /// @code -/// MqttsnGatewayHandle gw = mqttsn_gw_alloc(); +/// CC_MqttsnGatewayHandle gw = cc_mqttsn_gw_alloc(); /// @endcode -/// and de-allocation is performed using mqttsn_gw_free() functions. +/// and de-allocation is performed using cc_mqttsn_gw_free() functions. /// @code -/// mqttsn_gw_free(gw); +/// cc_mqttsn_gw_free(gw); /// @endcode /// -/// @section mqttsn_gw_gateway_page_send Sending Data +/// @section cc_mqttsn_gw_gateway_page_send Sending Data /// As was stated, the @b Gateway object is responsible to periodically /// broadcast @b ADVERTISE messages to all MQTT-SN clients on the network to /// advertise its presence. The library just generates the binary data, that @@ -44,10 +44,10 @@ /// ... /* Broadcast the provided buffer */ /// } /// -/// mqttsn_gw_set_advertise_broadcast_req_cb(gw, &my_advertise_broadcast, someUserData); +/// cc_mqttsn_gw_set_advertise_broadcast_req_cb(gw, &my_advertise_broadcast, someUserData); /// @endcode /// -/// @section mqttsn_gw_gateway_page_time Time Measurement +/// @section cc_mqttsn_gw_gateway_page_time Time Measurement /// As was mentioned earlier there is a need to send @b ADVERTISE messages /// @b periodically. As the result the @b Gateway object needs to perform /// some time measurement. It relies on the driving code to provide such @@ -68,10 +68,10 @@ /// void my_tick_req(void* userData, unsigned duration) /// { /// ... /* Set timer to expire after duration milliseconds */ -/// ... /* After expiry call mqttsn_gw_tick() */ +/// ... /* After expiry call cc_mqttsn_gw_tick() */ /// } /// -/// mqttsn_gw_set_tick_req_cb(gw, &my_tick_req, someUserData); +/// cc_mqttsn_gw_set_tick_req_cb(gw, &my_tick_req, someUserData); /// @endcode /// /// After the requested time expires, the driving code needs to notify the @@ -84,10 +84,10 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_tick(gw); +/// cc_mqttsn_gw_tick(gw); /// @endcode /// -/// @section mqttsn_gw_gateway_page_adv_period Advertise Period +/// @section cc_mqttsn_gw_gateway_page_adv_period Advertise Period /// The @b ADVERTISE message must be sent periodically. The message itself /// contains information when next @b ADVERTISE message will be sent. The /// @b Gateway object cannot operate without the advertise period being set. @@ -99,10 +99,10 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_set_advertise_period(gw, 900); /* The advertise period is in seconds */ +/// cc_mqttsn_gw_set_advertise_period(gw, 900); /* The advertise period is in seconds */ /// @endcode /// -/// @section mqttsn_gw_gateway_page_gw Gateway ID +/// @section cc_mqttsn_gw_gateway_page_gw Gateway ID /// The @b ADVERTISE message also contain 1 byte of numeric gateway ID. If the /// actual gateway ID differs from default value @b 0. It must be provided /// to the @b Gateway object. @@ -114,10 +114,10 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_set_id(gw, 5); +/// cc_mqttsn_gw_set_id(gw, 5); /// @endcode /// -/// @section mqttsn_gw_gateway_page_start Start Operation +/// @section cc_mqttsn_gw_gateway_page_start Start Operation /// After all the callbacks have been set and the advertise period was provided, /// the operation of the @b Gateway object needs to be properly started. /// @@ -130,7 +130,7 @@ /// /// @b C interface: /// @code -/// if (!mqttsn_gw_start(gw) { +/// if (!cc_mqttsn_gw_start(gw) { /// ... /* Something is not configured properly */ /// } /// @endcode @@ -140,9 +140,9 @@ /// for the next time. /// /// If the @b Gateway's operation needs to be paused for a while, use -/// mqttsn::gateway::Gateway::stop() or mqttsn_gw_stop() functions. The -/// operation can be resumed using mqttsn::gateway::Gateway::start() or -/// mqttsn_gw_start() respectively. +/// cc_mqttsn_gateway::Gateway::stop() or cc_mqttsn_gw_stop() functions. The +/// operation can be resumed using cc_mqttsn_gateway::Gateway::start() or +/// cc_mqttsn_gw_start() respectively. /// /// @b C++ interface: /// @code @@ -151,6 +151,6 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_stop(gw); +/// cc_mqttsn_gw_stop(gw); /// @endcode /// diff --git a/gateway/doc/main.dox b/gateway/doc/main.dox index 66184694..60f4c125 100644 --- a/gateway/doc/main.dox +++ b/gateway/doc/main.dox @@ -1,6 +1,6 @@ /// @mainpage MQTT-SN Gateway Library /// @tableofcontents -/// @section mqttsn_gw_overview Overview +/// @section cc_mqttsn_gw_overview Overview /// The MQTT-SN Gateway Library provides simple, asynchronous, non-blocking, /// and easy to use interface to implement and operate MQTT-SN gateway. /// The library doesn't make any assumption on the system it is running on, @@ -16,7 +16,7 @@ /// and @b C. The @b C interface is a wrapper around @b C++ one, but provides /// an interface to be used with any project developed using C. /// -/// @section mqttsn_client_io_links Various I/O Links +/// @section cc_mqttsn_client_io_links Various I/O Links /// MQTT-SN is designed to be a @b datagram protocol, i.e. if sent message is /// received by the other side, it is received in full and /// without errors. If sent over UDP link, it can be used as is. The @@ -28,24 +28,24 @@ /// sent or received data to be wrapped with or unwrapped from additional /// independent transport data, that insures safe and correct delivery. /// -/// @section mqttsn_gw_headers Headers +/// @section cc_mqttsn_gw_headers Headers /// To use the C++ interface, use the following include statement: /// @code -/// #include "mqttsn/gateway/gateway_allpp.h" +/// #include "cc_mqttsn_gateway/gateway_allpp.h" /// @endcode -/// Per-entity includes can also be used (see @ref mqttsn_gw_entities) +/// Per-entity includes can also be used (see @ref cc_mqttsn_gw_entities) /// @code -/// #include "mqttsn/gateway/Gateway.h" -/// #include "mqttsn/gateway/Session.h" -/// #include "mqttsn/gateway/Config.h" +/// #include "cc_mqttsn_gateway/Gateway.h" +/// #include "cc_mqttsn_gateway/Session.h" +/// #include "cc_mqttsn_gateway/Config.h" /// @endcode /// /// And for C interface, use the the following include statement: /// @code -/// #include "mqttsn/gateway/gateway_all.h" +/// #include "cc_mqttsn_gateway/gateway_all.h" /// @endcode /// -/// @section mqttsn_gw_entities Entities +/// @section cc_mqttsn_gw_entities Entities /// The gateway library works with and provides an interface for three /// intependent entities. /// - @b Gateway - Its main responsibility to advertise presence of the MQTT-SN @@ -54,20 +54,20 @@ /// case would be UDP/IP network where the clients know up front the /// address of the gateway, and do not require gateway advertising its /// presence. For API description and tutorial, please read the -/// @ref mqttsn_gw_gateway_page page. +/// @ref cc_mqttsn_gw_gateway_page page. /// - @b Session - It is responsible to inteligently forward traffic between /// single client and the broker. New "session" object must be created /// when message from new client has been received. Once the relevant client /// gets disconnected, the "session" object needs to be deleted. /// For API description and tutorial, please read the -/// @ref mqttsn_gw_session_page page. +/// @ref cc_mqttsn_gw_session_page page. /// - @b Config - It is responsible to provide a common way to parse the configuration /// file and provide a convenient interface to retrieve any configuration /// values, which can later be applied to the @b Gateway and/or @b Session /// entities. The format of the configuration file is described in the /// example config file provided with the project. For API description and -/// tutorial, please read the @ref mqttsn_gw_config_page page. +/// tutorial, please read the @ref cc_mqttsn_gw_config_page page. /// -/// @section mqttsn_gw_thread_safety Thread Safety +/// @section cc_mqttsn_gw_thread_safety Thread Safety /// Parallel access to the distinct objects @b is safe, but parallel access /// to the same one is @b NOT. diff --git a/gateway/doc/session.dox b/gateway/doc/session.dox index 48f1b10b..2bc88bbe 100644 --- a/gateway/doc/session.dox +++ b/gateway/doc/session.dox @@ -1,4 +1,4 @@ -/// @page mqttsn_gw_session_page Session +/// @page cc_mqttsn_gw_session_page Session /// @tableofcontents /// The @b Session object is responsible to manage and forward traffic of /// messages between @b single MQTT-SN client and the broker. When new message @@ -13,30 +13,30 @@ /// the driving code to maintain a valid map between the client's address and /// appropriate @b Session object. /// -/// @section mqttsn_gw_session_page_alloc Allocation -/// When using @b C++ interface, just instantiate object of mqttsn::gateway::Session +/// @section cc_mqttsn_gw_session_page_alloc Allocation +/// When using @b C++ interface, just instantiate object of cc_mqttsn_gateway::Session /// class. The destruction of the object will clean up all acquired resources. /// @code -/// mqttsn::gateway::Session* session = new mqttsn::gateway::Session(); // make sure to use smart pointer in production code +/// cc_mqttsn_gateway::Session* session = new cc_mqttsn_gateway::Session(); // make sure to use smart pointer in production code /// @endcode /// -/// When using @b C interface, the allocation is performed using mqttsn_gw_session_alloc() +/// When using @b C interface, the allocation is performed using cc_mqttsn_gw_session_alloc() /// @code -/// MqttsnSessionHandle handle = mqttsn_gw_session_alloc(); +/// CC_MqttsnSessionHandle handle = cc_mqttsn_gw_session_alloc(); /// @endcode -/// and de-allocation is performed using mqttsn_gw_session_free() functions. +/// and de-allocation is performed using cc_mqttsn_gw_session_free() functions. /// @code -/// mqttsn_gw_session_free(handle); +/// cc_mqttsn_gw_session_free(handle); /// @endcode /// -/// @section mqttsn_gw_session_page_recv Receiving Data +/// @section cc_mqttsn_gw_session_page_recv Receiving Data /// The MQTT-SN gateway @b Session serves as message translator and forwarder between /// MQTT-SN client and MQTT broker. The driver code is responsible to /// manage these two independent communication links. Once a message is /// received on any of them, it must be provided the the @b Session object /// for processing. /// -/// @subsection mqttsn_gw_session_page_recv_client Receiving Data from Client +/// @subsection cc_mqttsn_gw_session_page_recv_client Receiving Data from Client /// @b C++ interface: /// @code /// std::size_t consumed = session->dataFromClient(buf, bufLen); @@ -44,7 +44,7 @@ /// /// @b C interface: /// @code -/// unsigned consumed = mqttsn_gw_session_data_from_client(handle, buf, bufLen); +/// unsigned consumed = cc_mqttsn_gw_session_data_from_client(handle, buf, bufLen); /// @endcode /// /// @b NOTE, that functions return number of bytes that were actually processed. @@ -54,7 +54,7 @@ /// The call to this function may cause invocation of various callback functions /// that have been set. /// -/// @subsection mqttsn_gw_session_page_recv_broker Receiving Data from Broker +/// @subsection cc_mqttsn_gw_session_page_recv_broker Receiving Data from Broker /// @b C++ interface: /// @code /// std::size_t consumed = session->dataFromBroker(buf, bufLen); @@ -62,7 +62,7 @@ /// /// @b C interface: /// @code -/// unsigned consumed = mqttsn_gw_session_data_from_broker(handle, buf, bufLen); +/// unsigned consumed = cc_mqttsn_gw_session_data_from_broker(handle, buf, bufLen); /// @endcode /// /// @b NOTE, that functions return number of bytes that were actually processed. @@ -72,7 +72,7 @@ /// The call to this function may cause invocation of various callback functions /// that have been set. /// -/// @section mqttsn_gw_session_page_send Sending Data +/// @section cc_mqttsn_gw_session_page_send Sending Data /// The @b Session object may require to send a message to either client or /// broker. The driving code has to provide appropriate callbacks for this /// purpose. When the callback is invoked, it is provided with pointer to @@ -82,7 +82,7 @@ /// internal data structures to preserve the data intact until send over I/O /// link operation is complete. /// -/// @subsection mqttsn_gw_session_page_send_client Sending Data to Client +/// @subsection cc_mqttsn_gw_session_page_send_client Sending Data to Client /// @b C++ interface: /// @code /// session->setSendDataClientReqCb( @@ -99,10 +99,10 @@ /// ... /// } /// -/// mqttsn_gw_session_set_send_data_to_client_cb(handle, &my_send_to_client, someUserData); +/// cc_mqttsn_gw_session_set_send_data_to_client_cb(handle, &my_send_to_client, someUserData); /// @endcode /// -/// @subsection mqttsn_gw_session_page_send_broker Sending Data to Broker +/// @subsection cc_mqttsn_gw_session_page_send_broker Sending Data to Broker /// @b C++ interface: /// @code /// session->setSendDataBrokerReqCb( @@ -119,10 +119,10 @@ /// ... /// } /// -/// mqttsn_gw_session_set_send_data_to_broker_cb(handle, &my_send_to_broker, someUserData); +/// cc_mqttsn_gw_session_set_send_data_to_broker_cb(handle, &my_send_to_broker, someUserData); /// @endcode /// -/// @section mqttsn_gw_session_page_time Time Measurement +/// @section cc_mqttsn_gw_session_page_time Time Measurement /// The @b Session object may require to measure time to identify message delivery /// timeouts. It relies on the driving code to provide such /// service. There is a need to set appropriate callback: @@ -142,10 +142,10 @@ /// void my_tick_req(void* userData, unsigned duration) /// { /// ... /* Set timer to expire after duration milliseconds */ -/// ... /* After expiry call mqttsn_gw_session_tick() */ +/// ... /* After expiry call cc_mqttsn_gw_session_tick() */ /// } /// -/// mqttsn_gw_session_set_tick_req_cb(handle, &my_tick_req, someUserData); +/// cc_mqttsn_gw_session_set_tick_req_cb(handle, &my_tick_req, someUserData); /// @endcode /// /// After the requested time expires, the driving code needs to notify the @@ -158,7 +158,7 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_session_tick(handle); +/// cc_mqttsn_gw_session_tick(handle); /// @endcode /// /// Based on some events, the @b Session object may require knowledge of elapsed time @@ -184,10 +184,10 @@ /// return ...; /* return number of elapsed milliseconds */ /// } /// -/// mqttsn_gw_session_set_cancel_tick_cb(handle, &my_cancel_timer_req, someUserData); +/// cc_mqttsn_gw_session_set_cancel_tick_cb(handle, &my_cancel_timer_req, someUserData); /// @endcode /// -/// @section mqttsn_gw_session_page_term Session Termination +/// @section cc_mqttsn_gw_session_page_term Session Termination /// The @b Session object may recognise disconnection of MQTT-SN client and/or /// MQTT broker. As the result the session object must be destructed immediately and /// new one is created once the client renews its connection. The request to @@ -208,13 +208,13 @@ /// void my_session_term(void* userData) /// { /// ... /* Remove reference to session object from internal data structures */ -/// mqttsn_gw_session_free(handle); +/// cc_mqttsn_gw_session_free(handle); /// } /// -/// mqttsn_gw_session_set_term_req_cb(handle, &my_session_term, someUserData); +/// cc_mqttsn_gw_session_set_term_req_cb(handle, &my_session_term, someUserData); /// @endcode /// -/// @section mqttsn_gw_session_page_broker_reconnect Re-Connection to Broker +/// @section cc_mqttsn_gw_session_page_broker_reconnect Re-Connection to Broker /// The @b MQTT-SN protocol specification defines messages and operations, that /// are not properly supported by the @b MQTT protocol, such as will information /// update. The @b Session object supports these kind of operations by sending updated @@ -249,14 +249,14 @@ /// ... /* Close existing TCP/IP connection to broker and open a new one */ /// } /// -/// mqttsn_gw_session_set_broker_reconnect_req_cb(handle, &my_broker_reconnect, someUserData); +/// cc_mqttsn_gw_session_set_broker_reconnect_req_cb(handle, &my_broker_reconnect, someUserData); /// @endcode /// @b NOTE, that the updated connection statuses of the broker (first /// disconnected and then connected) must be reported to the @b Session object /// when they happen. Details are in -/// @ref mqttsn_gw_session_page_broker_conn section below. +/// @ref cc_mqttsn_gw_session_page_broker_conn section below. /// -/// @section mqttsn_gw_session_page_id Gateway ID +/// @section cc_mqttsn_gw_session_page_id Gateway ID /// The MQTT-SN client may broadcast @b SEARCHGW message in an attempt to discover /// existing gateways on the network. The @b Session object is responsible to /// send @b GWINFO message as a response. Such message contains numeric @@ -270,10 +270,10 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_session_set_id(handle, 5); +/// cc_mqttsn_gw_session_set_id(handle, 5); /// @endcode /// -/// @section mqttsn_gw_session_page_retry Retry Attempts +/// @section cc_mqttsn_gw_session_page_retry Retry Attempts /// There are cases when the communication to either client or broker is /// driven by the @b Session object itself. Such communication may involve /// messages that require acknowledgement by the other side. If acknowledgement @@ -289,12 +289,12 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_session_set_retry_period(handle, 5U); /* 5 seconds between resend attempts */ -/// mqttsn_gw_session_set_retry_count(handle, 4U); /* up to 4 attempts to resend the same message */ +/// cc_mqttsn_gw_session_set_retry_period(handle, 5U); /* 5 seconds between resend attempts */ +/// cc_mqttsn_gw_session_set_retry_count(handle, 4U); /* up to 4 attempts to resend the same message */ /// @endcode /// If not configured, the default values of @b 10 seconds and @b 3 attempts apply. /// -/// @section mqttsn_gw_session_page_predefined_topics Predefined Topics +/// @section cc_mqttsn_gw_session_page_predefined_topics Predefined Topics /// The messages in MQTT-SN protocol are published with numeric topic IDs /// instead of strings (like in original MQTT). The protocol also allows /// bypassing the topic strings registration and using predefined IDs directly. @@ -316,23 +316,23 @@ /// /// @b C interface: /// @code -/// if (!mqttsn_gw_session_add_predefined_topic(handle, "some/predefined/topic", 123)) { +/// if (!cc_mqttsn_gw_session_add_predefined_topic(handle, "some/predefined/topic", 123)) { /// ... /* report error */ /// } /// -/// if (!mqttsn_gw_session_add_predefined_topic(handle, "other/predefined/topic", 1111)) { +/// if (!cc_mqttsn_gw_session_add_predefined_topic(handle, "other/predefined/topic", 1111)) { /// ... /* report error */ /// } /// @endcode /// -/// @section mqttsn_gw_session_page_topics_registration Allocating Topic IDs +/// @section cc_mqttsn_gw_session_page_topics_registration Allocating Topic IDs /// When not using predefined topic IDs, there is a process of topic string /// registration and allocating relevant numeric topic ID. This allocation is /// performed by the @b Session object. By default the @b Session object will /// pick the first number available. However, it may be wise to reserve some /// range of topic IDs to be predefined ones, especially when there are /// some @b client @b specific predefined topic IDs, which added later when -/// connected client ID is known (see @ref mqttsn_gw_session_page_connected_client). +/// connected client ID is known (see @ref cc_mqttsn_gw_session_page_connected_client). /// The library provides a way to limit range of topic IDs allocated during /// the registration process. /// @@ -345,12 +345,12 @@ /// /// @b C interface: /// @code -/// if (!mqttsn_gw_session_set_topic_id_alloc_range(handle, 0x1000, 0xffff)) { +/// if (!cc_mqttsn_gw_session_set_topic_id_alloc_range(handle, 0x1000, 0xffff)) { /// ... // report error /// } /// @endcode /// -/// @section mqttsn_gw_session_page_start Start Operation +/// @section cc_mqttsn_gw_session_page_start Start Operation /// After been properly configured the @b Session object needs to be /// started. /// @@ -363,7 +363,7 @@ /// /// @b C interface: /// @code -/// if (!mqttsn_gw_session_start(handle)) { +/// if (!cc_mqttsn_gw_session_start(handle)) { /// ... /* The session hasn't been properly configured, report error */ /// } /// @endcode @@ -379,14 +379,14 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_session_stop(handle); +/// cc_mqttsn_gw_session_stop(handle); /// @endcode /// The operation of the stopped @b Session object may be restarted using the -/// same mqttsn::gateway::Session::start() and mqttsn_gw_session_start() functions. +/// same cc_mqttsn_gateway::Session::start() and cc_mqttsn_gw_session_start() functions. /// -/// @section mqttsn_gw_session_page_broker_conn Connection to Broker +/// @section cc_mqttsn_gw_session_page_broker_conn Connection to Broker /// @b AFTER (important emphasis here) successfully starting operation of the -/// @b Session object (see @ref mqttsn_gw_session_page_start) the driving +/// @b Session object (see @ref cc_mqttsn_gw_session_page_start) the driving /// code must initiate TCP/IP connection to the MQTT broker. The driving code /// must also constantly monitor the state of this connection and /// to the @b Session object any detected change. When started, the @b Session @@ -399,9 +399,9 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_session_broker_connected(handle, true); // Reports broker being connected +/// cc_mqttsn_gw_session_broker_connected(handle, true); // Reports broker being connected /// @endcode -/// When issuing broker re-connection request (see @ref mqttsn_gw_session_page_broker_reconnect), +/// When issuing broker re-connection request (see @ref cc_mqttsn_gw_session_page_broker_reconnect), /// the @b Session object expects this call to happen twice: the first one for disconnection /// report and second one for new connection report. /// @@ -409,7 +409,7 @@ /// TCP/IP link to the broker and report it to the @b Session object using the /// same function call. /// -/// @section mqttsn_gw_session_page_client_auth Client Authentication +/// @section cc_mqttsn_gw_session_page_client_auth Client Authentication /// The @b MQTT protocol supports client authentication, where the @b CONNECT /// message may contain username and password. The @b MQTT-SN protocol, /// on the other hand, lacks this feature. The @b Session object @@ -421,7 +421,7 @@ /// @b C++ interface: /// @code /// session->setAuthInfoReqCb( -/// [](const std::string& clientId) -> mqttsn::gateway::Session::AuthInfo +/// [](const std::string& clientId) -> cc_mqttsn_gateway::Session::AuthInfo /// { /// return std::make_pair(getUsernameFor(clientId), getPasswordFor(clientId)); /// @@ -442,10 +442,10 @@ /// *passwordLen = ...; /* specify length of the password */ /// } /// -/// mqttsn_gw_session_set_auth_info_req_cb(handle, &my_auth_callback, someUserData); +/// cc_mqttsn_gw_session_set_auth_info_req_cb(handle, &my_auth_callback, someUserData); /// @endcode /// -/// @section mqttsn_gw_session_page_connected_client Connected Client Report +/// @section cc_mqttsn_gw_session_page_connected_client Connected Client Report /// The @b Session object provides an ability to get notified when a MQTT-SN /// client is successfully connected. The notification is performed using /// a callback. Inside this callback, the driving code may provide some @@ -467,15 +467,15 @@ /// @code /// void my_client_connect_report(void* userData, const char* clientId) /// { -/// if (!mqttsn_gw_session_add_predefined_topic(handle, "client/specific/predefined/topic", 2222)) { +/// if (!cc_mqttsn_gw_session_add_predefined_topic(handle, "client/specific/predefined/topic", 2222)) { /// ... /* report error */ /// } /// } /// -/// mqttsn_gw_session_set_client_connect_report_cb(handle, &my_client_connect_report, someUserData); +/// cc_mqttsn_gw_session_set_client_connect_report_cb(handle, &my_client_connect_report, someUserData); /// @endcode /// -/// @section mqttsn_gw_session_page_default_client_id Default Client ID +/// @section cc_mqttsn_gw_session_page_default_client_id Default Client ID /// The @b Session object interface allows to specify the default ID /// of the client, which is going to be used to connect to broker, if the /// client doesn't provide non-empty ID string in its connection attempt. @@ -486,7 +486,7 @@ /// one, when forwarding the connection request to the broker. /// /// The default client ID configuration may also be used with "publish -/// only" clients (see @ref mqttsn_gw_session_page_publish_only below). +/// only" clients (see @ref cc_mqttsn_gw_session_page_publish_only below). /// The configured client ID will be used when connecting to the broker on /// behalf of the "publish only" client. /// @@ -497,20 +497,20 @@ /// /// @b C interface: /// @code -/// mqttsn_gw_session_set_default_client_id(handle, "some_default_id"); +/// cc_mqttsn_gw_session_set_default_client_id(handle, "some_default_id"); /// @endcode /// @b NOTE, that the @b Session object will make an attempt to substitute /// reported client ID if and only if the client ID @b is empty and /// configured default client ID is @b NOT. /// -/// @section mqttsn_gw_session_page_publish_only Publish Only Client +/// @section cc_mqttsn_gw_session_page_publish_only Publish Only Client /// The MQTT-SN protocol allows "publish only" clients, which don't make /// an attempt to connect to the gateway/broker, but allowed to /// publish messages with predefined topic IDs and QoS=-1. The gateway /// must connect to the broker on behalf of such client. The connection /// operation involves knowledge about client ID and "keep alive" period. /// The client ID, that is going to be used, is configured as -/// @ref mqttsn_gw_session_page_default_client_id. The "keep alive" period +/// @ref cc_mqttsn_gw_session_page_default_client_id. The "keep alive" period /// can be provided using separate function: /// /// @b C++ interface: @@ -520,12 +520,12 @@ /// /// @b C++ interface: /// @code -/// mqttsn_gw_session_set_pub_only_keep_alive(handle, 100); /* 100 seconds */ +/// cc_mqttsn_gw_session_set_pub_only_keep_alive(handle, 100); /* 100 seconds */ /// @endcode /// If such configuration is not provided, the default value of @b 60 seconds /// is assumed. /// -/// @section mqttsn_gw_session_page_sleep Sleeping Client +/// @section cc_mqttsn_gw_session_page_sleep Sleeping Client /// The @b Session object supports client entering the @b SLEEP mode without any /// extra configuration. It will send the @b PINGREQ messages on behalf of /// the client to keep the connection to the broker alive, and will accumulate @@ -542,7 +542,7 @@ /// /// @b C++ interface: /// @code -/// mqttsn_gw_session_set_sleeping_client_msg_limit(handle, 1000); /* no more that 1000 messages */ +/// cc_mqttsn_gw_session_set_sleeping_client_msg_limit(handle, 1000); /* no more that 1000 messages */ /// @endcode /// diff --git a/gateway/etc/cc_mqttsn_gateway.conf.example b/gateway/etc/cc_mqttsn_gateway.conf.example index 68f729f0..66f5f552 100644 --- a/gateway/etc/cc_mqttsn_gateway.conf.example +++ b/gateway/etc/cc_mqttsn_gateway.conf.example @@ -5,7 +5,7 @@ # ================================================================= # Gateway ID, reported in ADVERTISE and GWINFO messages. Default value is 0. -#mqttsn_gw_id 0 +#cc_mqttsn_gw_id 0 # Advertise period (in seconds), when gateway is expected to advertise its # presence by broadcasting ADVERTISE message. Default value is 900 (=15 min). diff --git a/gateway/include/mqttsn/gateway/Config.h b/gateway/include/cc_mqttsn_gateway/Config.h similarity index 95% rename from gateway/include/mqttsn/gateway/Config.h rename to gateway/include/cc_mqttsn_gateway/Config.h index 563e3c76..9d1375ea 100644 --- a/gateway/include/mqttsn/gateway/Config.h +++ b/gateway/include/cc_mqttsn_gateway/Config.h @@ -1,12 +1,12 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. /// @file -/// @brief Contains interface of mqttsn::gateway::Config class. +/// @brief Contains interface of cc_mqttsn_gateway::Config class. #pragma once @@ -20,10 +20,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class ConfigImpl; @@ -146,8 +143,6 @@ class Config std::unique_ptr m_pImpl; }; -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/include/mqttsn/gateway/Gateway.h b/gateway/include/cc_mqttsn_gateway/Gateway.h similarity index 95% rename from gateway/include/mqttsn/gateway/Gateway.h rename to gateway/include/cc_mqttsn_gateway/Gateway.h index 7f3530ad..a4fca601 100644 --- a/gateway/include/mqttsn/gateway/Gateway.h +++ b/gateway/include/cc_mqttsn_gateway/Gateway.h @@ -1,12 +1,12 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. /// @file -/// @brief Contains interface of mqttsn::gateway::Gateway class. +/// @brief Contains interface of cc_mqttsn_gateway::Gateway class. #pragma once @@ -14,10 +14,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class GatewayImpl; @@ -104,8 +101,6 @@ class Gateway std::unique_ptr m_pImpl; }; -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/include/mqttsn/gateway/Session.h b/gateway/include/cc_mqttsn_gateway/Session.h similarity index 98% rename from gateway/include/mqttsn/gateway/Session.h rename to gateway/include/cc_mqttsn_gateway/Session.h index 8b189321..930f738b 100644 --- a/gateway/include/mqttsn/gateway/Session.h +++ b/gateway/include/cc_mqttsn_gateway/Session.h @@ -1,12 +1,12 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. /// @file -/// @brief Contains interface of mqttsn::gateway::Session class. +/// @brief Contains interface of cc_mqttsn_gateway::Session class. #pragma once @@ -17,10 +17,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class SessionImpl; @@ -262,7 +259,5 @@ class Session std::unique_ptr m_pImpl; }; -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/include/mqttsn/gateway/gateway_all.h b/gateway/include/cc_mqttsn_gateway/gateway_all.h similarity index 63% rename from gateway/include/mqttsn/gateway/gateway_all.h rename to gateway/include/cc_mqttsn_gateway/gateway_all.h index 42d29e7a..6b0d7ba4 100644 --- a/gateway/include/mqttsn/gateway/gateway_all.h +++ b/gateway/include/cc_mqttsn_gateway/gateway_all.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -37,24 +37,24 @@ extern "C" { /*===================== Gateway Object ======================*/ -/// @brief Handle for gateway object used in all @b mqttsn_gw_* functions. +/// @brief Handle for gateway object used in all @b cc_mqttsn_gw_* functions. typedef struct { void* obj; -} MqttsnGatewayHandle; +} CC_MqttsnGatewayHandle; /// @brief Type of callback function, to be used to request time measurement for /// the @b Gateway object. -/// @details The callback is set using mqttsn_gw_set_tick_req_cb(). When +/// @details The callback is set using cc_mqttsn_gw_set_tick_req_cb(). When /// the required time expires, the driving code is responsible to invoke -/// mqttsn_gw_tick() function. +/// cc_mqttsn_gw_tick() function. /// @param[in] userData User data passed as the last parameter to the setting function. /// @param[in] duration Requested time measurement duration in @b milliseconds. -typedef void (*MqttsnGwTickReqCb)(void* userData, unsigned duration); +typedef void (*CC_MqttsnGwTickReqCb)(void* userData, unsigned duration); /// @brief Type of callback function, to be used to request broadcast of serialised /// @b ADVERTISE message. -/// @details The callback is set using mqttsn_gw_set_advertise_broadcast_req_cb(). +/// @details The callback is set using cc_mqttsn_gw_set_advertise_broadcast_req_cb(). /// @param[in] userData User data passed as the last parameter to the setting function. /// @param[in] buf Pointer to the buffer of data, that needs to be sent. /// @param[in] bufLen Number of bytes in the buffer. @@ -62,46 +62,46 @@ typedef void (*MqttsnGwTickReqCb)(void* userData, unsigned duration); /// object and can be updated right after the callback function returns. The /// driving code may require to copy the buffer to its own data structures /// and preserve it intact until send over I/O link is complete. -typedef void (*MqttsnGwBroadcastReqCb)(void* userData, const unsigned char* buf, unsigned bufLen); +typedef void (*CC_MqttsnGwBroadcastReqCb)(void* userData, const unsigned char* buf, unsigned bufLen); /// @brief Allocate @b Gateway object. /// @details The returned handle need to be passed as first parameter /// to all relevant functions. Note that the @b Gateway object is /// dynamically allocated and needs to be freed using -/// mqttsn_gw_free() function. +/// cc_mqttsn_gw_free() function. /// @return Handler to the allocated @b Gateway object. -MqttsnGatewayHandle mqttsn_gw_alloc(void); +CC_MqttsnGatewayHandle cc_mqttsn_gw_alloc(void); /// @brief Free allocated @b Gateway object. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. -void mqttsn_gw_free(MqttsnGatewayHandle gw); +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. +void cc_mqttsn_gw_free(CC_MqttsnGatewayHandle gw); /// @brief Set the advertise period. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. /// @param[in] value Advertise period in @b seconds. -void mqttsn_gw_set_advertise_period(MqttsnGatewayHandle gw, unsigned short value); +void cc_mqttsn_gw_set_advertise_period(CC_MqttsnGatewayHandle gw, unsigned short value); /// @brief Set the numeric gateway ID. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. /// @param[in] id Numeric gateway ID. -void mqttsn_gw_set_id(MqttsnGatewayHandle gw, unsigned char id); +void cc_mqttsn_gw_set_id(CC_MqttsnGatewayHandle gw, unsigned char id); /// @brief Set callback that requests to perform time measurement. /// @details The @b Gateway object will invoke the callback to request time /// measurement. When requested time expires, the driving code is responsible -/// to call mqttsn_gw_tick(). -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. +/// to call cc_mqttsn_gw_tick(). +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Any user data, to be passed as first parameter to the callback -void mqttsn_gw_set_tick_req_cb(MqttsnGatewayHandle gw, MqttsnGwTickReqCb cb, void* data); +void cc_mqttsn_gw_set_tick_req_cb(CC_MqttsnGatewayHandle gw, CC_MqttsnGwTickReqCb cb, void* data); /// @brief Set callback that requests to send serialised @b ADVERTISE message. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Any user data, to be passed as first parameter to the callback -void mqttsn_gw_set_advertise_broadcast_req_cb( - MqttsnGatewayHandle gw, - MqttsnGwBroadcastReqCb cb, +void cc_mqttsn_gw_set_advertise_broadcast_req_cb( + CC_MqttsnGatewayHandle gw, + CC_MqttsnGwBroadcastReqCb cb, void* data); /// @brief Start operation of the @b Gateway object. @@ -109,34 +109,34 @@ void mqttsn_gw_set_advertise_broadcast_req_cb( /// period were set properly and start the operation if everything is in /// place. If start is successful, the callbacks of requesting data send /// as well as data measurement request will be invoked. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. /// @return @b true if the operation was successfully started, @b false otherwise. -bool mqttsn_gw_start(MqttsnGatewayHandle gw); +bool cc_mqttsn_gw_start(CC_MqttsnGatewayHandle gw); /// @brief Stop operation of the @b Gateway object. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. -void mqttsn_gw_stop(MqttsnGatewayHandle gw); +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. +void cc_mqttsn_gw_stop(CC_MqttsnGatewayHandle gw); /// @brief Notify the @b Gateway object about requested time expiry. /// @details Invocation of this function will cause invocation of the send /// data request callback as well as new time measurement request. -/// @param[in] gw Handle returned by mqttsn_gw_alloc() function. -void mqttsn_gw_tick(MqttsnGatewayHandle gw); +/// @param[in] gw Handle returned by cc_mqttsn_gw_alloc() function. +void cc_mqttsn_gw_tick(CC_MqttsnGatewayHandle gw); /*===================== Session Object ======================*/ -/// @brief Handle for session object used in all @b mqttsn_gw_session_* functions. +/// @brief Handle for session object used in all @b cc_mqttsn_gw_session_* functions. typedef struct { void* obj; -} MqttsnSessionHandle; +} CC_MqttsnSessionHandle; /// @brief Type of callback, used to request new time measurement. /// @details When the requested time is due, the driving code is expected -/// to call mqttsn_gw_session_tick() member function. +/// to call cc_mqttsn_gw_session_tick() member function. /// @param[in] userData User data passed as the last parameter to the setting function. /// @param[in] value Number of @b milliseconds to measure. -typedef void (*MqttsnSessionTickReqCb)(void* userData, unsigned duration); +typedef void (*CC_MqttsnSessionTickReqCb)(void* userData, unsigned duration); /// @brief Type of callback, used to cancel existing time measurement. /// @details When invoked the existing time measurement needs to be cancelled. @@ -145,27 +145,27 @@ typedef void (*MqttsnSessionTickReqCb)(void* userData, unsigned duration); /// @param[in] userData User data passed as the last parameter to the setting function. /// @return Number of elapsed @b milliseconds since last timer programming /// request. -typedef unsigned (*MqttsnSessionCancelTickReqCb)(void* userData); +typedef unsigned (*CC_MqttsnSessionCancelTickReqCb)(void* userData); /// @brief Type of callback, used to request delivery of serialised message /// to the client or broker. /// @param[in] userData User data passed as the last parameter to the setting function. /// @param[in] buf Buffer containing serialised message. /// @param[in] bufLen Number of bytes in the buffer -typedef void (*MqttsnSessionSendDataReqCb)(void* userData, const unsigned char* buf, unsigned bufLen); +typedef void (*CC_MqttsnSessionSendDataReqCb)(void* userData, const unsigned char* buf, unsigned bufLen); /// @brief Type of callback, used to request session termination. /// @details When the callback is invoked, the driving code must flush /// all the previously sent messages to appropriate I/O links and /// delete this session object. /// @param[in] userData User data passed as the last parameter to the setting function. -typedef void (*MqttsnSessionTermReqCb)(void* userData); +typedef void (*CC_MqttsnSessionTermReqCb)(void* userData); /// @brief Type of callback used to request reconnection to the broker. /// @details When the callback is invoked, the driving code must close /// existing TCP/IP connection to the broker and create a new one. /// @param[in] userData User data passed as the last parameter to the setting function. -typedef void (*MqttsnSessionBrokerReconnectReqCb)(void* userData); +typedef void (*CC_MqttsnSessionBrokerReconnectReqCb)(void* userData); /// @brief Type of callback used to report client ID of the newly connected /// MQTT-SN client. @@ -173,7 +173,7 @@ typedef void (*MqttsnSessionBrokerReconnectReqCb)(void* userData); /// information, such as predefined topic IDs. /// @param[in] userData User data passed as the last parameter to the setting function. /// @param[in] clientId Client ID -typedef void (*MqttsnSessionClientConnectReportCb)(void* userData, const char* clientId); +typedef void (*CC_MqttsnSessionClientConnectReportCb)(void* userData, const char* clientId); /// @brief Type of callback used to request authentication information of /// the client that is trying to connect. @@ -182,7 +182,7 @@ typedef void (*MqttsnSessionClientConnectReportCb)(void* userData, const char* c /// @param[out] username Username string /// @param[out] password Binary password buffer /// @param[out] passwordLen Length of the binary password -typedef void (*MqttsnSessionAuthInfoReqCb)( +typedef void (*CC_MqttsnSessionAuthInfoReqCb)( void* userData, const char* clientId, const char** username, @@ -193,89 +193,89 @@ typedef void (*MqttsnSessionAuthInfoReqCb)( /// @details The returned handle need to be passed as first parameter /// to all relevant functions. Note that the @b Session object is /// dynamically allocated and needs to be freed using -/// mqttsn_gw_session_free() function. +/// cc_mqttsn_gw_session_free() function. /// @return Handler to the allocated @b Session object. -MqttsnSessionHandle mqttsn_gw_session_alloc(void); +CC_MqttsnSessionHandle cc_mqttsn_gw_session_alloc(void); /// @brief Free allocated @b Session object. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. -void mqttsn_gw_session_free(MqttsnSessionHandle session); +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. +void cc_mqttsn_gw_session_free(CC_MqttsnSessionHandle session); /// @brief Set the callback to be invoked when new time measurement is required. /// @details This is a must have callback, without it the object can not -/// be started (see mqttsn_gw_session_start()). -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// be started (see cc_mqttsn_gw_session_start()). +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_tick_req_cb( - MqttsnSessionHandle session, - MqttsnSessionTickReqCb cb, +void cc_mqttsn_gw_session_set_tick_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionTickReqCb cb, void* data); /// @brief Set the callback to be invoked when previously requested time /// measurement needs to be cancelled. /// @details This is a must have callback, without it the object can not -/// be started (see mqttsn_gw_session_start()). -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// be started (see cc_mqttsn_gw_session_start()). +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_cancel_tick_cb( - MqttsnSessionHandle session, - MqttsnSessionCancelTickReqCb cb, +void cc_mqttsn_gw_session_set_cancel_tick_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionCancelTickReqCb cb, void* data); /// @brief Set the callback to be invoked when new data needs to be sent /// to the @b client. /// @details This is a must have callback, without it the object can not -/// be started (see mqttsn_gw_session_start()). -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// be started (see cc_mqttsn_gw_session_start()). +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_send_data_to_client_cb( - MqttsnSessionHandle session, - MqttsnSessionSendDataReqCb cb, +void cc_mqttsn_gw_session_set_send_data_to_client_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionSendDataReqCb cb, void* data); /// @brief Set the callback to be invoked when new data needs to be sent /// to the @b broker. /// @details This is a must have callback, without it the object can not -/// be started (see mqttsn_gw_session_start()). -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// be started (see cc_mqttsn_gw_session_start()). +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_send_data_to_broker_cb( - MqttsnSessionHandle session, - MqttsnSessionSendDataReqCb cb, +void cc_mqttsn_gw_session_set_send_data_to_broker_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionSendDataReqCb cb, void* data); /// @brief Set the callback to be invoked when the @b Session needs to be /// terminated and the calling @b Session object deleted. /// @details This is a must have callback, without it the object can not -/// be started (see mqttsn_gw_session_start()). -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// be started (see cc_mqttsn_gw_session_start()). +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_term_req_cb( - MqttsnSessionHandle session, - MqttsnSessionTermReqCb cb, +void cc_mqttsn_gw_session_set_term_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionTermReqCb cb, void* data); /// @brief Set the callback to be invoked when the @b Session needs to close /// existing TCP/IP connection to the broker and open a new one. /// @details This is a must have callback, without it the object can not -/// be started (see mqttsn_gw_session_start()). -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// be started (see cc_mqttsn_gw_session_start()). +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_broker_reconnect_req_cb( - MqttsnSessionHandle session, - MqttsnSessionBrokerReconnectReqCb cb, +void cc_mqttsn_gw_session_set_broker_reconnect_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionBrokerReconnectReqCb cb, void* data); /// @brief Set the callback to be invoked when MQTT-SN client is successfully @@ -283,13 +283,13 @@ void mqttsn_gw_session_set_broker_reconnect_req_cb( /// @details This is an optional callback. It can be used when there is a /// need to provide client specific configuration, such as predefined /// topic IDs, valid only for specific client. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_client_connect_report_cb( - MqttsnSessionHandle session, - MqttsnSessionClientConnectReportCb cb, +void cc_mqttsn_gw_session_set_client_connect_report_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionClientConnectReportCb cb, void* data); /// @brief Set the callback to be used to request authentication information @@ -297,20 +297,20 @@ void mqttsn_gw_session_set_client_connect_report_cb( /// @details This is an optional callback. It can be used when there is a /// need to provide authentication details (username/password) for /// specific clients. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] cb Pointer to callback function /// @param[in] data Pointer to any user data, will be passed back as first /// parameter to the callback. -void mqttsn_gw_session_set_auth_info_req_cb( - MqttsnSessionHandle session, - MqttsnSessionAuthInfoReqCb cb, +void cc_mqttsn_gw_session_set_auth_info_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionAuthInfoReqCb cb, void* data); /// @brief Set gateway numeric ID to be reported when requested. /// @details If not set, default value @b 0 is assumed. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] id Gateway numeric ID. -void mqttsn_gw_session_set_id(MqttsnSessionHandle session, unsigned char id); +void cc_mqttsn_gw_session_set_id(CC_MqttsnSessionHandle session, unsigned char id); /// @brief Set retry period to wait between resending unacknowledged message /// to the client and/or broker. @@ -318,9 +318,9 @@ void mqttsn_gw_session_set_id(MqttsnSessionHandle session, unsigned char id); /// the client and/or broker. The delay (in seconds) between such /// attempts to resend the message may be specified using this function. /// The default value is @b 10 seconds. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] value Number of @b seconds to wait before making an attempt to resend. -void mqttsn_gw_session_set_retry_period(MqttsnSessionHandle session, unsigned value); +void cc_mqttsn_gw_session_set_retry_period(CC_MqttsnSessionHandle session, unsigned value); /// @brief Set number of retry attempts to perform before abandoning attempt /// to send unacknowledged message. @@ -328,9 +328,9 @@ void mqttsn_gw_session_set_retry_period(MqttsnSessionHandle session, unsigned va /// the client and/or broker. The amount of retry attempts before /// abandoning the attempt to deliver the message may be specified /// using this function. The default value is @b 3. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] value Number of retry attempts. -void mqttsn_gw_session_set_retry_count(MqttsnSessionHandle session, unsigned value); +void cc_mqttsn_gw_session_set_retry_count(CC_MqttsnSessionHandle session, unsigned value); /// @brief Provide limit to number pending messages being accumulated for /// the sleeping client. @@ -339,17 +339,17 @@ void mqttsn_gw_session_set_retry_count(MqttsnSessionHandle session, unsigned val /// or explicitly requests to send them. This function may be used /// to limit amount of such messages to prevent acquiring lots of /// RAM by the gateway application. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] value Max number of pending messages. -void mqttsn_gw_session_set_sleeping_client_msg_limit( - MqttsnSessionHandle session, +void cc_mqttsn_gw_session_set_sleeping_client_msg_limit( + CC_MqttsnSessionHandle session, unsigned value); /// @brief Provide default client ID for clients that report empty one /// in their attempt to connect. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] clientId Default client ID string. -void mqttsn_gw_session_set_default_client_id(MqttsnSessionHandle session, const char* clientId); +void cc_mqttsn_gw_session_set_default_client_id(CC_MqttsnSessionHandle session, const char* clientId); /// @brief Provide default "keep alive" period for "publish only" clients, /// that do not make an attempt to connect to the gateway. @@ -359,41 +359,41 @@ void mqttsn_gw_session_set_default_client_id(MqttsnSessionHandle session, const /// to the broker on behalf of the "publish only" client. Such connection /// attempt requires to specify "keep alive" period. Use this function /// to set the value. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] value Max number of seconds between messages the "publish only" /// client is going to send. -void mqttsn_gw_session_set_pub_only_keep_alive(MqttsnSessionHandle session, unsigned value); +void cc_mqttsn_gw_session_set_pub_only_keep_alive(CC_MqttsnSessionHandle session, unsigned value); /// @brief Start the @b Session's object's operation. /// @details The function will check whether all necessary callbacks have been /// set. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @return true if the operation has been successfully started, false in /// case some necessary callback hasn't been set. -bool mqttsn_gw_session_start(MqttsnSessionHandle session); +bool cc_mqttsn_gw_session_start(CC_MqttsnSessionHandle session); /// @brief Stop the operation of the @b Session object. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. -void mqttsn_gw_session_stop(MqttsnSessionHandle session); +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. +void cc_mqttsn_gw_session_stop(CC_MqttsnSessionHandle session); /// @brief Notify the @b Session object about requested time period expiry. /// @details This function needs to be called from the driving code after /// the requested time measurement has expired. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. -void mqttsn_gw_session_tick(MqttsnSessionHandle session); +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. +void cc_mqttsn_gw_session_tick(CC_MqttsnSessionHandle session); /// @brief Provide data received from the @b client for processing. /// @details This call may cause invocation of some callbacks, such as /// request to cancel the currently running time measurement, /// send new message(s) and/or (re)start time measurement. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] buf Pointer to the buffer of data to process. /// @param[in] len Number of bytes in the data buffer. /// @return Number of processed bytes. /// @note The function returns number of bytes that were actually consumed, and /// can be removed from the holding buffer. -unsigned mqttsn_gw_session_data_from_client( - MqttsnSessionHandle session, +unsigned cc_mqttsn_gw_session_data_from_client( + CC_MqttsnSessionHandle session, const unsigned char* buf, unsigned bufLen); @@ -401,43 +401,43 @@ unsigned mqttsn_gw_session_data_from_client( /// @details This call may cause invocation of some callbacks, such as /// request to cancel the currently running time measurement, /// send new message(s) and/or (re)start time measurement. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] buf Pointer to the buffer of data to process. /// @param[in] len Number of bytes in the data buffer. /// @return Number of processed bytes. /// @note The function returns number of bytes that were actually consumed, and /// can be removed from the holding buffer. -unsigned mqttsn_gw_session_data_from_broker( - MqttsnSessionHandle session, +unsigned cc_mqttsn_gw_session_data_from_broker( + CC_MqttsnSessionHandle session, const unsigned char* buf, unsigned bufLen); /// @brief Notify the @b Session object about broker being connected / disconnected /// @details The report of broker being connected or disconnected must /// be performed only when the session's operation has been successfully -/// started (see mqttsn_gw_session_start()). Otherwise the call to this function gets +/// started (see cc_mqttsn_gw_session_start()). Otherwise the call to this function gets /// ignored. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] conneted Connection status - @b true means connected, @b false disconnected. -void mqttsn_gw_session_broker_connected(MqttsnSessionHandle session, bool connected); +void cc_mqttsn_gw_session_broker_connected(CC_MqttsnSessionHandle session, bool connected); /// @brief Add predefined topic string and ID information. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] topic Topic string /// @param[in] topicId Numeric topic ID. /// @return success/failure status -bool mqttsn_gw_session_add_predefined_topic( - MqttsnSessionHandle session, +bool cc_mqttsn_gw_session_add_predefined_topic( + CC_MqttsnSessionHandle session, const char* topic, unsigned short topicId); /// @brief Limit range of topic IDs allocated for newly registered topics. -/// @param[in] session Handle returned by mqttsn_gw_session_alloc() function. +/// @param[in] session Handle returned by cc_mqttsn_gw_session_alloc() function. /// @param[in] minVal Min topic ID. /// @param[in] maxVal Max topic ID. /// @return success/failure status -bool mqttsn_gw_session_set_topic_id_alloc_range( - MqttsnSessionHandle session, +bool cc_mqttsn_gw_session_set_topic_id_alloc_range( + CC_MqttsnSessionHandle session, unsigned short minTopicId, unsigned short maxTopicId); @@ -449,7 +449,7 @@ typedef struct const char* clientId; ///< Client ID const char* topic; ///< Topic string unsigned short topicId; ///< Numeric topic ID -} MqttsnPredefinedTopicInfo; +} CC_MqttsnPredefinedTopicInfo; /// @brief Authentication infor for a single client. typedef struct @@ -457,141 +457,141 @@ typedef struct const char* clientId; ///< Client ID const char* username; ///< Username string const char* password; ///< Password string (from the configuration) -} MqttsnAuthInfo; +} CC_MqttsnAuthInfo; -/// @brief Handle for configuration object used in all @b mqttsn_gw_config_* functions. +/// @brief Handle for configuration object used in all @b cc_mqttsn_gw_config_* functions. typedef struct { void* obj; -} MqttsnConfigHandle; +} CC_MqttsnConfigHandle; /// @brief Allocate @b Config object. /// @details The returned handle need to be passed as first parameter /// to all relevant functions. Note that the @b Config object is /// dynamically allocated and needs to be freed using -/// mqttsn_gw_config_free() function. +/// cc_mqttsn_gw_config_free() function. /// @return Handler to the allocated @b Config object. -MqttsnConfigHandle mqttsn_gw_config_alloc(void); +CC_MqttsnConfigHandle cc_mqttsn_gw_config_alloc(void); /// @brief Free allocated @b Config object. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. -void mqttsn_gw_config_free(MqttsnConfigHandle config); +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. +void cc_mqttsn_gw_config_free(CC_MqttsnConfigHandle config); /// @brief Parse configuration contents from string /// @details Updates the default values with values read from string buffer. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @param[in] str Pointer to the string buffer, containing configuration. -void mqttsn_gw_config_parse(MqttsnConfigHandle config, const char* str); +void cc_mqttsn_gw_config_parse(CC_MqttsnConfigHandle config, const char* str); /// @brief Read configuration file /// @details Updates the default values with values read from the file. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @param[in] filename Path to the file. -bool mqttsn_gw_config_read(MqttsnConfigHandle config, const char* filename); +bool cc_mqttsn_gw_config_read(CC_MqttsnConfigHandle config, const char* filename); /// @brief Get gateway numeric ID. /// @details Default value is @b 0. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Numeric gateway ID. -unsigned char mqttsn_gw_config_id(MqttsnConfigHandle config); +unsigned char cc_mqttsn_gw_config_id(CC_MqttsnConfigHandle config); /// @brief Get advertise period. /// @details Default value is @b 900 seconds (15 minutes). -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Advertise period in @b seconds. -unsigned short mqttsn_gw_config_advertise_period(MqttsnConfigHandle config); +unsigned short cc_mqttsn_gw_config_advertise_period(CC_MqttsnConfigHandle config); /// @brief Get retry period /// @details Default value is @b 10 seconds. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Retry period in @b seconds -unsigned mqttsn_gw_config_retry_period(MqttsnConfigHandle config); +unsigned cc_mqttsn_gw_config_retry_period(CC_MqttsnConfigHandle config); /// @brief Get number of retry attempts. /// @details Default value is @b 3. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Number of retry attempts -unsigned mqttsn_gw_config_retry_count(MqttsnConfigHandle config); +unsigned cc_mqttsn_gw_config_retry_count(CC_MqttsnConfigHandle config); /// @brief Get default client ID. /// @details Default value is empty string. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Default client ID. -const char* mqttsn_gw_config_default_client_id(MqttsnConfigHandle config); +const char* cc_mqttsn_gw_config_default_client_id(CC_MqttsnConfigHandle config); /// @brief Get keep alive period for publish only clients /// @details Default value is @b 60 seconds. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Keep alive period for publish only clients. -unsigned mqttsn_gw_config_pub_only_keep_alive(MqttsnConfigHandle config); +unsigned cc_mqttsn_gw_config_pub_only_keep_alive(CC_MqttsnConfigHandle config); /// @brief Get limit for max number of messages to accumulate for sleeping /// clients. /// @details Default value is @b MAX_UINT seconds. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @return Max number of accumulated messages for sleeping clients. -unsigned mqttsn_gw_config_sleeping_client_msg_limit(MqttsnConfigHandle config); +unsigned cc_mqttsn_gw_config_sleeping_client_msg_limit(CC_MqttsnConfigHandle config); /// @brief Get number of available predefined topic IDs. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. -unsigned mqttsn_gw_config_available_predefined_topics(MqttsnConfigHandle config); +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. +unsigned cc_mqttsn_gw_config_available_predefined_topics(CC_MqttsnConfigHandle config); /// @brief Read information about available topic IDs into a buffer. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @param[out] buf Buffer to write information into /// @param[in] bufLen Max number of element to write into the buffer. /// @return Actual number of elements that have been written into a buffer. -unsigned mqttsn_gw_config_get_predefined_topics( - MqttsnConfigHandle config, - MqttsnPredefinedTopicInfo* buf, +unsigned cc_mqttsn_gw_config_get_predefined_topics( + CC_MqttsnConfigHandle config, + CC_MqttsnPredefinedTopicInfo* buf, unsigned bufLen); /// @brief Get number of available authenticatin infos for all the clients. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. -unsigned mqttsn_gw_config_available_auth_infos(MqttsnConfigHandle config); +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. +unsigned cc_mqttsn_gw_config_available_auth_infos(CC_MqttsnConfigHandle config); /// @brief Read clients' authentication information into a buffer -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @param[out] buf Buffer to write information into /// @param[in] bufLen Max number of element to write into the buffer. /// @return Actual number of elements that have been written into a buffer. -unsigned mqttsn_gw_config_get_auth_infos( - MqttsnConfigHandle config, - MqttsnAuthInfo* buf, +unsigned cc_mqttsn_gw_config_get_auth_infos( + CC_MqttsnConfigHandle config, + CC_MqttsnAuthInfo* buf, unsigned bufLen); /// @brief Get range of allowed topic IDs for allocation. /// @details Default range is [1, 0xfffe] -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @param[out] min Minimal allowed topic ID. /// @param[out] max Maximal allowed topic ID. -void mqttsn_gw_config_topic_id_alloc_range( - MqttsnConfigHandle config, +void cc_mqttsn_gw_config_topic_id_alloc_range( + CC_MqttsnConfigHandle config, unsigned short* min, unsigned short* max); /// @brief Get TCP/IP address of the broker. /// @details Default address is @b 127.0.0.1 -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. -const char* mqttsn_gw_config_broker_address(MqttsnConfigHandle config); +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. +const char* cc_mqttsn_gw_config_broker_address(CC_MqttsnConfigHandle config); /// @brief Get TCP/IP port of the broker. /// @details Default value is @b 1883 -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. -unsigned short mqttsn_gw_config_broker_port(MqttsnConfigHandle config); +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. +unsigned short cc_mqttsn_gw_config_broker_port(CC_MqttsnConfigHandle config); /// @brief Get number of available configuration values for the provided key /// @details The key is the first word in the configuration line, and the /// value is rest of the string until the end of the line. -/// @param[in] config Handle returned by mqttsn_gw_config_alloc() function. +/// @param[in] config Handle returned by cc_mqttsn_gw_config_alloc() function. /// @param[in] key Key string. -unsigned mqttsn_gw_config_values_count(MqttsnConfigHandle config, const char* key); +unsigned cc_mqttsn_gw_config_values_count(CC_MqttsnConfigHandle config, const char* key); /// @brief Get the available value for the configuration key. /// @details The key is the first word in the configuration line, and the /// value is rest of the string until the end of the line. /// If the configuration value doesn't exist, @b NULL is returned. -const char* mqttsn_gw_config_get_value(MqttsnConfigHandle config, const char* key, unsigned idx); +const char* cc_mqttsn_gw_config_get_value(CC_MqttsnConfigHandle config, const char* key, unsigned idx); #ifdef __cplusplus } diff --git a/gateway/include/mqttsn/gateway/gateway_allpp.h b/gateway/include/cc_mqttsn_gateway/gateway_allpp.h similarity index 85% rename from gateway/include/mqttsn/gateway/gateway_allpp.h rename to gateway/include/cc_mqttsn_gateway/gateway_allpp.h index 3ddd8465..9f302190 100644 --- a/gateway/include/mqttsn/gateway/gateway_allpp.h +++ b/gateway/include/cc_mqttsn_gateway/gateway_allpp.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/gateway/include/mqttsn/gateway/version.h b/gateway/include/cc_mqttsn_gateway/version.h similarity index 69% rename from gateway/include/mqttsn/gateway/version.h rename to gateway/include/cc_mqttsn_gateway/version.h index 1f85cefc..e563ad94 100644 --- a/gateway/include/mqttsn/gateway/version.h +++ b/gateway/include/cc_mqttsn_gateway/version.h @@ -11,19 +11,19 @@ #pragma once /// @brief Major verion of the library -#define MQTTSN_GW_MAJOR_VERSION 0U +#define CC_MQTTSN_GW_MAJOR_VERSION 1U /// @brief Minor verion of the library -#define MQTTSN_GW_MINOR_VERSION 13U +#define CC_MQTTSN_GW_MINOR_VERSION 0U /// @brief Patch level of the library -#define MQTTSN_GW_PATCH_VERSION 4U +#define CC_MQTTSN_GW_PATCH_VERSION 0U /// @brief Macro to create numeric version as single unsigned number -#define MQTTSN_GW_MAKE_VERSION(major_, minor_, patch_) \ +#define CC_MQTTSN_GW_MAKE_VERSION(major_, minor_, patch_) \ ((static_cast(major_) << 24) | \ (static_cast(minor_) << 8) | \ (static_cast(patch_))) /// @brief Version of the library as single numeric value -#define MQTTSN_GW_VERSION MQTTSN_GW_MAKE_VERSION(MQTTSN_GW_MAJOR_VERSION, MQTTSN_GW_MINOR_VERSION, MQTTSN_GW_PATCH_VERSION) +#define CC_MQTTSN_GW_VERSION CC_MQTTSN_GW_MAKE_VERSION(CC_MQTTSN_GW_MAJOR_VERSION, CC_MQTTSN_GW_MINOR_VERSION, CC_MQTTSN_GW_PATCH_VERSION) diff --git a/gateway/include/mqttsn/gateway/versionpp.h b/gateway/include/cc_mqttsn_gateway/versionpp.h similarity index 76% rename from gateway/include/mqttsn/gateway/versionpp.h rename to gateway/include/cc_mqttsn_gateway/versionpp.h index de3de0bd..f6a83700 100644 --- a/gateway/include/mqttsn/gateway/versionpp.h +++ b/gateway/include/cc_mqttsn_gateway/versionpp.h @@ -12,47 +12,42 @@ #include "version.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { /// @brief Major verion of the library inline constexpr unsigned versionMajor() { - return MQTTSN_GW_MAJOR_VERSION; + return CC_MQTTSN_GW_MAJOR_VERSION; } /// @brief Minor verion of the library inline constexpr unsigned versionMinor() { - return MQTTSN_GW_MINOR_VERSION; + return CC_MQTTSN_GW_MINOR_VERSION; } /// @brief Patch level of the library inline constexpr unsigned versionPatch() { - return MQTTSN_GW_PATCH_VERSION; + return CC_MQTTSN_GW_PATCH_VERSION; } /// @brief Create version of the library as single unsigned numeric value. inline constexpr unsigned versionCreate(unsigned major, unsigned minor, unsigned patch) { - return MQTTSN_GW_MAKE_VERSION(major, minor, patch); + return CC_MQTTSN_GW_MAKE_VERSION(major, minor, patch); } /// @brief Version of the library as single numeric value inline constexpr unsigned version() { - return MQTTSN_GW_VERSION; + return CC_MQTTSN_GW_VERSION; } -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/CMakeLists.txt b/gateway/src/app/CMakeLists.txt index 963576e4..cec60b51 100644 --- a/gateway/src/app/CMakeLists.txt +++ b/gateway/src/app/CMakeLists.txt @@ -1 +1,5 @@ +if (NOT CC_MQTTSN_BUILD_GATEWAY_APPS) + return () +endif () + add_subdirectory (udp) \ No newline at end of file diff --git a/gateway/src/app/udp/CMakeLists.txt b/gateway/src/app/udp/CMakeLists.txt index 7393d06c..b6a3ca56 100644 --- a/gateway/src/app/udp/CMakeLists.txt +++ b/gateway/src/app/udp/CMakeLists.txt @@ -29,12 +29,11 @@ function (bin_gateway_udp) #qt5_add_resources(resources ${CMAKE_CURRENT_SOURCE_DIR}/ui.qrc) add_executable(${name} ${src} ${moc}) - target_link_libraries(${name} ${MQTTSN_GATEWAY_LIB_NAME}) - qt5_use_modules(${name} Network Core) + target_link_libraries(${name} ${MQTTSN_GATEWAY_LIB_NAME} Qt5::Network Qt5::Core) install ( TARGETS ${name} - DESTINATION ${BIN_INSTALL_DIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endfunction () @@ -43,8 +42,4 @@ endfunction () find_package(Qt5Core) find_package(Qt5Network) -include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} -) - bin_gateway_udp() diff --git a/gateway/src/app/udp/GatewayWrapper.cpp b/gateway/src/app/udp/GatewayWrapper.cpp index e77a7af8..1eed89a8 100644 --- a/gateway/src/app/udp/GatewayWrapper.cpp +++ b/gateway/src/app/udp/GatewayWrapper.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace app @@ -54,8 +51,6 @@ void GatewayWrapper::tickTimeout() } // namespace app -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/udp/GatewayWrapper.h b/gateway/src/app/udp/GatewayWrapper.h index 1ef1408f..66b5e809 100644 --- a/gateway/src/app/udp/GatewayWrapper.h +++ b/gateway/src/app/udp/GatewayWrapper.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,13 +10,10 @@ #include #include -#include "mqttsn/gateway/Config.h" -#include "mqttsn/gateway/Gateway.h" +#include "cc_mqttsn_gateway/Config.h" +#include "cc_mqttsn_gateway/Gateway.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace app @@ -33,7 +30,7 @@ class GatewayWrapper : public QObject explicit GatewayWrapper(const Config& config); - typedef mqttsn::gateway::Gateway::SendDataReqCb SendDataReqCb; + typedef cc_mqttsn_gateway::Gateway::SendDataReqCb SendDataReqCb; bool start(SendDataReqCb&& sendCb); private slots: @@ -41,7 +38,7 @@ private slots: private: const Config& m_config; - mqttsn::gateway::Gateway m_gw; + cc_mqttsn_gateway::Gateway m_gw; QTimer m_timer; }; @@ -49,6 +46,4 @@ private slots: } // namespace app -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/udp/Mgr.cpp b/gateway/src/app/udp/Mgr.cpp index 974bc09a..6ca1d3ea 100644 --- a/gateway/src/app/udp/Mgr.cpp +++ b/gateway/src/app/udp/Mgr.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,10 +11,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace app @@ -251,6 +248,4 @@ void Mgr::broadcastAdvertise(const std::uint8_t* buf, std::size_t bufSize) } // namespace app -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/udp/Mgr.h b/gateway/src/app/udp/Mgr.h index 428b5f1e..fd4d0334 100644 --- a/gateway/src/app/udp/Mgr.h +++ b/gateway/src/app/udp/Mgr.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,14 +15,11 @@ #include #include -#include "mqttsn/gateway/Config.h" +#include "cc_mqttsn_gateway/Config.h" #include "GatewayWrapper.h" #include "SessionWrapper.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace app @@ -67,6 +64,4 @@ private slots: } // namespace app -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/udp/SessionWrapper.cpp b/gateway/src/app/udp/SessionWrapper.cpp index e6689a94..81b7a1fa 100644 --- a/gateway/src/app/udp/SessionWrapper.cpp +++ b/gateway/src/app/udp/SessionWrapper.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,10 +12,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace app @@ -350,8 +347,6 @@ SessionWrapper::AuthInfo SessionWrapper::getAuthInfoFor(const std::string& clien } // namespace app -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/udp/SessionWrapper.h b/gateway/src/app/udp/SessionWrapper.h index 8e930942..131f7b82 100644 --- a/gateway/src/app/udp/SessionWrapper.h +++ b/gateway/src/app/udp/SessionWrapper.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,13 +16,10 @@ #include #include -#include "mqttsn/gateway/Config.h" -#include "mqttsn/gateway/Session.h" +#include "cc_mqttsn_gateway/Config.h" +#include "cc_mqttsn_gateway/Session.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace app @@ -37,7 +34,7 @@ class SessionWrapper : public QObject typedef QObject Base; public: typedef unsigned short PortType; - typedef mqttsn::gateway::Session::AuthInfo AuthInfo; + typedef cc_mqttsn_gateway::Session::AuthInfo AuthInfo; SessionWrapper(const Config& config, QObject* parent); ~SessionWrapper(); @@ -104,7 +101,7 @@ private slots: const Config& m_config; QTcpSocket m_brokerSocket; - mqttsn::gateway::Session m_session; + cc_mqttsn_gateway::Session m_session; QTimer m_timer; unsigned m_reqTicks = 0; bool m_reconnectRequested = false; @@ -119,6 +116,4 @@ private slots: } // namespace app -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/app/udp/main.cpp b/gateway/src/app/udp/main.cpp index f6b4b97b..d633642e 100644 --- a/gateway/src/app/udp/main.cpp +++ b/gateway/src/app/udp/main.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,7 +15,7 @@ #include #include "Mgr.h" -#include "mqttsn/gateway/Config.h" +#include "cc_mqttsn_gateway/Config.h" namespace { @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) prepareCommandLineOptions(parser); parser.process(app); - mqttsn::gateway::Config config; + cc_mqttsn_gateway::Config config; do { if (!parser.isSet(ConfigOptStr)) { break; @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) config.read(stream); } while (false); - mqttsn::gateway::app::udp::Mgr gw(config); + cc_mqttsn_gateway::app::udp::Mgr gw(config); if (!gw.start()) { std::cerr << "Failed to start!" << std::endl; return -1; diff --git a/gateway/src/lib/CMakeLists.txt b/gateway/src/lib/CMakeLists.txt index e2358aa8..76b96262 100644 --- a/gateway/src/lib/CMakeLists.txt +++ b/gateway/src/lib/CMakeLists.txt @@ -24,45 +24,34 @@ function (lib_mqttsn_gateway) add_library (${name} STATIC ${src}) - if (TARGET cc::mqtt311) - target_link_libraries(${name} PRIVATE cc::mqtt311) - endif () - - if (TARGET cc::mqttsn) - target_link_libraries(${name} PRIVATE cc::mqttsn) - endif () - - target_link_libraries(${name} PRIVATE cc::comms) - - if (NOT "${CC_MQTT_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${name} PRIVATE ${CC_MQTT_EXTERNAL_TGT_INCLUDE}) - endif () - - if (NOT "${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${name} PRIVATE ${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}) - endif () - - if (TARGET ${CC_MQTT_EXTERNAL_TGT}) - add_dependencies(${name} ${CC_MQTT_EXTERNAL_TGT}) - endif () - - if (TARGET ${CC_MQTTSN_EXTERNAL_TGT}) - add_dependencies(${name} ${CC_MQTTSN_EXTERNAL_TGT}) - endif () + target_link_libraries(${name} PRIVATE cc::cc_mqtt311 cc::cc_mqttsn cc::comms) + set_target_properties( + ${name} PROPERTIES + INTERFACE_LINK_LIBRARIES "" + ) + + target_include_directories( + ${name} BEFORE + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}) + install ( TARGETS ${name} - DESTINATION ${LIB_INSTALL_DIR} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + EXPORT ${name}Config ) + + install(EXPORT ${name}Config NAMESPACE cc:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${name}/cmake + ) endfunction() ###################################################################### -include_directories( - BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} -) - lib_mqttsn_gateway () diff --git a/gateway/src/lib/Config.cpp b/gateway/src/lib/Config.cpp index 2346a668..ab5a014e 100644 --- a/gateway/src/lib/Config.cpp +++ b/gateway/src/lib/Config.cpp @@ -1,18 +1,15 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "mqttsn/gateway/Config.h" +#include "cc_mqttsn_gateway/Config.h" #include "ConfigImpl.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { Config::Config() @@ -92,9 +89,4 @@ std::uint16_t Config::brokerTcpHostPort() const return m_pImpl->brokerTcpHostPort(); } - -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/ConfigImpl.cpp b/gateway/src/lib/ConfigImpl.cpp index 59357c83..5e5f0d4d 100644 --- a/gateway/src/lib/ConfigImpl.cpp +++ b/gateway/src/lib/ConfigImpl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,10 +14,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace @@ -25,7 +22,7 @@ namespace const char CommentChar = '#'; const std::string SpaceChars(" \t"); -const std::string GatewayIdKey("mqttsn_gw_id"); +const std::string GatewayIdKey("cc_mqttsn_gw_id"); const std::string AdvertiseKey("mqttsn_advertise"); const std::string RetryPeriodKey("mqttsn_retry_period"); const std::string RetryCountKey("mqttsn_retry_count"); @@ -425,8 +422,4 @@ void ConfigImpl::readBrokerAddrInfo() const } } -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/ConfigImpl.h b/gateway/src/lib/ConfigImpl.h index 7fbe24b4..57103d63 100644 --- a/gateway/src/lib/ConfigImpl.h +++ b/gateway/src/lib/ConfigImpl.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,12 +9,9 @@ #include -#include "mqttsn/gateway/Config.h" +#include "cc_mqttsn_gateway/Config.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class ConfigImpl @@ -75,8 +72,4 @@ class ConfigImpl mutable std::uint16_t m_brokerPort = 0; }; -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/Gateway.cpp b/gateway/src/lib/Gateway.cpp index 1e9da6fd..a10d97fa 100644 --- a/gateway/src/lib/Gateway.cpp +++ b/gateway/src/lib/Gateway.cpp @@ -1,18 +1,15 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "mqttsn/gateway/Gateway.h" +#include "cc_mqttsn_gateway/Gateway.h" #include "GatewayImpl.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { Gateway::Gateway() @@ -57,8 +54,4 @@ void Gateway::tick() m_pImpl->tick(); } -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/GatewayImpl.cpp b/gateway/src/lib/GatewayImpl.cpp index 63d82cab..e35933a3 100644 --- a/gateway/src/lib/GatewayImpl.cpp +++ b/gateway/src/lib/GatewayImpl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { bool GatewayImpl::start() @@ -76,8 +73,4 @@ void GatewayImpl::sendAndReprogram() m_tickProgramCb(m_advertisePeriod * 1000U); } -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/GatewayImpl.h b/gateway/src/lib/GatewayImpl.h index 0d3073b4..7a6016ba 100644 --- a/gateway/src/lib/GatewayImpl.h +++ b/gateway/src/lib/GatewayImpl.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,15 +8,13 @@ #pragma once #include +#include -#include "mqttsn/gateway/Gateway.h" -#include "mqttsn/Message.h" -#include "mqttsn/frame/Frame.h" +#include "cc_mqttsn_gateway/Gateway.h" +#include "cc_mqttsn/Message.h" +#include "cc_mqttsn/frame/Frame.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class GatewayImpl @@ -26,15 +24,15 @@ class GatewayImpl using SendDataReqCb = Gateway::SendDataReqCb; using Message = - mqttsn::Message< + cc_mqttsn::Message< comms::option::IdInfoInterface, comms::option::WriteIterator, comms::option::LengthInfoInterface >; - using AdvertiseMsg = mqttsn::message::Advertise; + using AdvertiseMsg = cc_mqttsn::message::Advertise; using AllMsgs = std::tuple; - using ProtStack = mqttsn::frame::Frame; + using ProtStack = cc_mqttsn::frame::Frame; template void setNextTickProgramReqCb(TFunc&& func) @@ -83,6 +81,4 @@ class GatewayImpl ProtStack m_protStack; }; -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/MsgHandler.h b/gateway/src/lib/MsgHandler.h index 115a3928..0b1717a1 100644 --- a/gateway/src/lib/MsgHandler.h +++ b/gateway/src/lib/MsgHandler.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,22 +10,19 @@ #include "comms/comms.h" #include "messages.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { template using MqttsnMsgHandler = comms::GenericHandler< TMsgBase, - mqttsn::gateway::InputMqttsnMessages + cc_mqttsn_gateway::InputMqttsnMessages >; template using MqttMsgHandler = comms::GenericHandler< TMsgBase, - mqttsn::gateway::InputMqtt311Messages + cc_mqttsn_gateway::InputMqtt311Messages >; class MsgHandler : public MqttsnMsgHandler, public MqttMsgHandler @@ -40,9 +37,4 @@ class MsgHandler : public MqttsnMsgHandler, public MqttMsgHandler virtual ~MsgHandler() = default; }; - -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/RegMgr.cpp b/gateway/src/lib/RegMgr.cpp index fde5d00c..69c9fcac 100644 --- a/gateway/src/lib/RegMgr.cpp +++ b/gateway/src/lib/RegMgr.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,10 +11,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace @@ -252,8 +249,4 @@ void RegMgr::removeFromTopicMap(const std::string& topic, RegInfosList::iterator } } -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/RegMgr.h b/gateway/src/lib/RegMgr.h index 04ef5767..02cccbd8 100644 --- a/gateway/src/lib/RegMgr.h +++ b/gateway/src/lib/RegMgr.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,19 +13,16 @@ #include #include -#include "mqttsn/field/FlagsCommon.h" +#include "cc_mqttsn/field/FlagsCommon.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class RegMgr { public: - using TopicIdType = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; + using TopicIdType = cc_mqttsn::field::TopicIdTypeVal; struct TopicInfo { std::uint16_t m_topicId = 0; @@ -64,8 +61,4 @@ class RegMgr static const std::uint16_t DefaultMaxTopicId = 0xfffe; }; -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/Session.cpp b/gateway/src/lib/Session.cpp index 62fd2bf5..01d16096 100644 --- a/gateway/src/lib/Session.cpp +++ b/gateway/src/lib/Session.cpp @@ -1,17 +1,14 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "mqttsn/gateway/Session.h" +#include "cc_mqttsn_gateway/Session.h" #include "SessionImpl.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { Session::Session() @@ -136,7 +133,5 @@ bool Session::setTopicIdAllocationRange(std::uint16_t minVal, std::uint16_t maxV return m_pImpl->setTopicIdAllocationRange(minVal, maxVal); } -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/SessionImpl.cpp b/gateway/src/lib/SessionImpl.cpp index b58ffd66..f22fa4de 100644 --- a/gateway/src/lib/SessionImpl.cpp +++ b/gateway/src/lib/SessionImpl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -21,10 +21,7 @@ #include "session_op/Forward.h" #include "session_op/WillUpdate.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace @@ -386,9 +383,6 @@ auto SessionImpl::apiCall() -> decltype(comms::util::makeScopeGuard(std::bind(&S #endif // #ifdef _MSC_VER - -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/SessionImpl.h b/gateway/src/lib/SessionImpl.h index 8dbce8c9..9d5200a0 100644 --- a/gateway/src/lib/SessionImpl.h +++ b/gateway/src/lib/SessionImpl.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,16 +13,13 @@ #include #include -#include "mqttsn/gateway/Session.h" +#include "cc_mqttsn_gateway/Session.h" #include "MsgHandler.h" #include "SessionOp.h" #include "common.h" #include "comms/util/ScopeGuard.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class SessionImpl : public MsgHandler @@ -158,7 +155,7 @@ class SessionImpl : public MsgHandler private: - using ReturnCodeVal = mqttsn::field::ReturnCodeVal; + using ReturnCodeVal = cc_mqttsn::field::ReturnCodeVal; typedef std::vector OpsList; using Base::handle; @@ -214,8 +211,6 @@ class SessionImpl : public MsgHandler SessionState m_state; }; -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/SessionOp.cpp b/gateway/src/lib/SessionOp.cpp index bede75f8..fee8f7e3 100644 --- a/gateway/src/lib/SessionOp.cpp +++ b/gateway/src/lib/SessionOp.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,10 +7,7 @@ #include "SessionOp.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { void SessionOp::sendDisconnectToClient() @@ -23,8 +20,4 @@ void SessionOp::sendDisconnectToClient() } -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/SessionOp.h b/gateway/src/lib/SessionOp.h index e83b56f8..fdfd66fc 100644 --- a/gateway/src/lib/SessionOp.h +++ b/gateway/src/lib/SessionOp.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,14 +11,11 @@ #include #include -#include "mqttsn/gateway/Session.h" +#include "cc_mqttsn_gateway/Session.h" #include "MsgHandler.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { class SessionOp : public MsgHandler @@ -153,8 +150,4 @@ class SessionOp : public MsgHandler typedef std::unique_ptr SessionOpPtr; -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/common.h b/gateway/src/lib/common.h index de2d3e8c..8f0fd30d 100644 --- a/gateway/src/lib/common.h +++ b/gateway/src/lib/common.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,15 +13,12 @@ #include #include -#include "mqttsn/field/QosCommon.h" -#include "mqtt311/field/QosCommon.h" +#include "cc_mqttsn/field/QosCommon.h" +#include "cc_mqtt311/field/QosCommon.h" #include "RegMgr.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { typedef std::vector DataBuf; @@ -35,27 +32,27 @@ enum QoS }; inline -mqtt311::field::QosVal translateQosForBroker(QoS val) +cc_mqtt311::field::QosVal translateQosForBroker(QoS val) { - return static_cast(val); + return static_cast(val); } inline -mqttsn::field::QosVal translateQosForClient(QoS val) +cc_mqttsn::field::QosVal translateQosForClient(QoS val) { - return static_cast(val); + return static_cast(val); } inline -QoS translateQos(mqtt311::field::QosVal val) +QoS translateQos(cc_mqtt311::field::QosVal val) { return static_cast(val); } inline -QoS translateQos(mqttsn::field::QosVal val) +QoS translateQos(cc_mqttsn::field::QosVal val) { - if (val == mqttsn::field::QosVal::NoGwPublish) { + if (val == cc_mqttsn::field::QosVal::NoGwPublish) { return QoS_AtMostOnceDelivery; } @@ -141,7 +138,4 @@ struct SessionState RegMgr m_regMgr; }; -} // namespace gateway - -} // namespace mqttsn - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/gateway_all.c b/gateway/src/lib/gateway_all.c index 56faa712..92faa95a 100644 --- a/gateway/src/lib/gateway_all.c +++ b/gateway/src/lib/gateway_all.c @@ -1,10 +1,10 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "mqttsn/gateway/gateway_all.h" +#include "cc_mqttsn_gateway/gateway_all.h" diff --git a/gateway/src/lib/gateway_all.cpp b/gateway/src/lib/gateway_all.cpp index 3de12f71..3797fe94 100644 --- a/gateway/src/lib/gateway_all.cpp +++ b/gateway/src/lib/gateway_all.cpp @@ -1,44 +1,44 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "mqttsn/gateway/gateway_all.h" +#include "cc_mqttsn_gateway/gateway_all.h" #include #include #include #include -#include "mqttsn/gateway/gateway_allpp.h" +#include "cc_mqttsn_gateway/gateway_allpp.h" namespace { -typedef mqttsn::gateway::Config Config; -typedef mqttsn::gateway::Gateway Gateway; -typedef mqttsn::gateway::Session Session; +typedef cc_mqttsn_gateway::Config Config; +typedef cc_mqttsn_gateway::Gateway Gateway; +typedef cc_mqttsn_gateway::Session Session; } // namespace /*===================== Gateway Object ======================*/ -MqttsnGatewayHandle mqttsn_gw_alloc(void) +CC_MqttsnGatewayHandle cc_mqttsn_gw_alloc(void) { - MqttsnGatewayHandle gw; + CC_MqttsnGatewayHandle gw; gw.obj = new Gateway(); return gw; } -void mqttsn_gw_free(MqttsnGatewayHandle gw) +void cc_mqttsn_gw_free(CC_MqttsnGatewayHandle gw) { std::unique_ptr(reinterpret_cast(gw.obj)); } -void mqttsn_gw_set_advertise_period( - MqttsnGatewayHandle gw, +void cc_mqttsn_gw_set_advertise_period( + CC_MqttsnGatewayHandle gw, unsigned short value) { if (gw.obj == nullptr) { @@ -48,7 +48,7 @@ void mqttsn_gw_set_advertise_period( reinterpret_cast(gw.obj)->setAdvertisePeriod(value); } -void mqttsn_gw_set_id(MqttsnGatewayHandle gw, unsigned char id) +void cc_mqttsn_gw_set_id(CC_MqttsnGatewayHandle gw, unsigned char id) { if (gw.obj == nullptr) { return; @@ -57,7 +57,7 @@ void mqttsn_gw_set_id(MqttsnGatewayHandle gw, unsigned char id) reinterpret_cast(gw.obj)->setGatewayId(id); } -void mqttsn_gw_set_tick_req_cb(MqttsnGatewayHandle gw, MqttsnGwTickReqCb cb, void* data) +void cc_mqttsn_gw_set_tick_req_cb(CC_MqttsnGatewayHandle gw, CC_MqttsnGwTickReqCb cb, void* data) { if ((gw.obj == nullptr) || (cb == nullptr)) { return; @@ -70,9 +70,9 @@ void mqttsn_gw_set_tick_req_cb(MqttsnGatewayHandle gw, MqttsnGwTickReqCb cb, voi }); } -void mqttsn_gw_set_advertise_broadcast_req_cb( - MqttsnGatewayHandle gw, - MqttsnGwBroadcastReqCb cb, +void cc_mqttsn_gw_set_advertise_broadcast_req_cb( + CC_MqttsnGatewayHandle gw, + CC_MqttsnGwBroadcastReqCb cb, void* data) { if ((gw.obj == nullptr) || (cb == nullptr)) { @@ -86,7 +86,7 @@ void mqttsn_gw_set_advertise_broadcast_req_cb( }); } -bool mqttsn_gw_start(MqttsnGatewayHandle gw) +bool cc_mqttsn_gw_start(CC_MqttsnGatewayHandle gw) { if (gw.obj == nullptr) { return false; @@ -95,7 +95,7 @@ bool mqttsn_gw_start(MqttsnGatewayHandle gw) return reinterpret_cast(gw.obj)->start(); } -void mqttsn_gw_stop(MqttsnGatewayHandle gw) +void cc_mqttsn_gw_stop(CC_MqttsnGatewayHandle gw) { if (gw.obj == nullptr) { return; @@ -104,7 +104,7 @@ void mqttsn_gw_stop(MqttsnGatewayHandle gw) reinterpret_cast(gw.obj)->stop(); } -void mqttsn_gw_tick(MqttsnGatewayHandle gw) +void cc_mqttsn_gw_tick(CC_MqttsnGatewayHandle gw) { if (gw.obj == nullptr) { return; @@ -116,21 +116,21 @@ void mqttsn_gw_tick(MqttsnGatewayHandle gw) /*===================== Session Object ======================*/ -MqttsnSessionHandle mqttsn_gw_session_alloc(void) +CC_MqttsnSessionHandle cc_mqttsn_gw_session_alloc(void) { - MqttsnSessionHandle session; + CC_MqttsnSessionHandle session; session.obj = new Session; return session; } -void mqttsn_gw_session_free(MqttsnSessionHandle session) +void cc_mqttsn_gw_session_free(CC_MqttsnSessionHandle session) { std::unique_ptr(reinterpret_cast(session.obj)); } -void mqttsn_gw_session_set_tick_req_cb( - MqttsnSessionHandle session, - MqttsnSessionTickReqCb cb, +void cc_mqttsn_gw_session_set_tick_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionTickReqCb cb, void* data) { if ((session.obj == nullptr) || (cb == nullptr)) { @@ -144,9 +144,9 @@ void mqttsn_gw_session_set_tick_req_cb( }); } -void mqttsn_gw_session_set_cancel_tick_cb( - MqttsnSessionHandle session, - MqttsnSessionCancelTickReqCb cb, +void cc_mqttsn_gw_session_set_cancel_tick_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionCancelTickReqCb cb, void* data) { if ((session.obj == nullptr) || (cb == nullptr)) { @@ -160,9 +160,9 @@ void mqttsn_gw_session_set_cancel_tick_cb( }); } -void mqttsn_gw_session_set_send_data_to_client_cb( - MqttsnSessionHandle session, - MqttsnSessionSendDataReqCb cb, +void cc_mqttsn_gw_session_set_send_data_to_client_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionSendDataReqCb cb, void* data) { if ((session.obj == nullptr) || (cb == nullptr)) { @@ -177,9 +177,9 @@ void mqttsn_gw_session_set_send_data_to_client_cb( } -void mqttsn_gw_session_set_send_data_to_broker_cb( - MqttsnSessionHandle session, - MqttsnSessionSendDataReqCb cb, +void cc_mqttsn_gw_session_set_send_data_to_broker_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionSendDataReqCb cb, void* data) { if ((session.obj == nullptr) || (cb == nullptr)) { @@ -193,9 +193,9 @@ void mqttsn_gw_session_set_send_data_to_broker_cb( }); } -void mqttsn_gw_session_set_term_req_cb( - MqttsnSessionHandle session, - MqttsnSessionTermReqCb cb, +void cc_mqttsn_gw_session_set_term_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionTermReqCb cb, void* data) { if ((session.obj == nullptr) || (cb == nullptr)) { @@ -209,9 +209,9 @@ void mqttsn_gw_session_set_term_req_cb( }); } -void mqttsn_gw_session_set_broker_reconnect_req_cb( - MqttsnSessionHandle session, - MqttsnSessionBrokerReconnectReqCb cb, +void cc_mqttsn_gw_session_set_broker_reconnect_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionBrokerReconnectReqCb cb, void* data) { if ((session.obj == nullptr) || (cb == nullptr)) { @@ -225,9 +225,9 @@ void mqttsn_gw_session_set_broker_reconnect_req_cb( }); } -void mqttsn_gw_session_set_client_connect_report_cb( - MqttsnSessionHandle session, - MqttsnSessionClientConnectReportCb cb, +void cc_mqttsn_gw_session_set_client_connect_report_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionClientConnectReportCb cb, void* data) { if (session.obj == nullptr) { @@ -246,9 +246,9 @@ void mqttsn_gw_session_set_client_connect_report_cb( }); } -void mqttsn_gw_session_set_auth_info_req_cb( - MqttsnSessionHandle session, - MqttsnSessionAuthInfoReqCb cb, +void cc_mqttsn_gw_session_set_auth_info_req_cb( + CC_MqttsnSessionHandle session, + CC_MqttsnSessionAuthInfoReqCb cb, void* data) { if (session.obj == nullptr) { @@ -281,7 +281,7 @@ void mqttsn_gw_session_set_auth_info_req_cb( }); } -void mqttsn_gw_session_set_id(MqttsnSessionHandle session, unsigned char id) +void cc_mqttsn_gw_session_set_id(CC_MqttsnSessionHandle session, unsigned char id) { if (session.obj == nullptr) { return; @@ -290,7 +290,7 @@ void mqttsn_gw_session_set_id(MqttsnSessionHandle session, unsigned char id) reinterpret_cast(session.obj)->setGatewayId(id); } -void mqttsn_gw_session_set_retry_period(MqttsnSessionHandle session, unsigned value) +void cc_mqttsn_gw_session_set_retry_period(CC_MqttsnSessionHandle session, unsigned value) { if (session.obj == nullptr) { return; @@ -299,7 +299,7 @@ void mqttsn_gw_session_set_retry_period(MqttsnSessionHandle session, unsigned va reinterpret_cast(session.obj)->setRetryPeriod(value); } -void mqttsn_gw_session_set_retry_count(MqttsnSessionHandle session, unsigned value) +void cc_mqttsn_gw_session_set_retry_count(CC_MqttsnSessionHandle session, unsigned value) { if (session.obj == nullptr) { return; @@ -308,8 +308,8 @@ void mqttsn_gw_session_set_retry_count(MqttsnSessionHandle session, unsigned val reinterpret_cast(session.obj)->setRetryCount(value); } -void mqttsn_gw_session_set_sleeping_client_msg_limit( - MqttsnSessionHandle session, +void cc_mqttsn_gw_session_set_sleeping_client_msg_limit( + CC_MqttsnSessionHandle session, unsigned value) { if (session.obj == nullptr) { @@ -319,7 +319,7 @@ void mqttsn_gw_session_set_sleeping_client_msg_limit( reinterpret_cast(session.obj)->setSleepingClientMsgLimit(value); } -void mqttsn_gw_session_set_default_client_id(MqttsnSessionHandle session, const char* clientId) +void cc_mqttsn_gw_session_set_default_client_id(CC_MqttsnSessionHandle session, const char* clientId) { if (session.obj == nullptr) { return; @@ -328,8 +328,8 @@ void mqttsn_gw_session_set_default_client_id(MqttsnSessionHandle session, const reinterpret_cast(session.obj)->setDefaultClientId(clientId); } -void mqttsn_gw_session_set_pub_only_keep_alive( - MqttsnSessionHandle session, +void cc_mqttsn_gw_session_set_pub_only_keep_alive( + CC_MqttsnSessionHandle session, unsigned value) { if (session.obj == nullptr) { @@ -339,7 +339,7 @@ void mqttsn_gw_session_set_pub_only_keep_alive( reinterpret_cast(session.obj)->setPubOnlyKeepAlive(static_cast(value)); } -bool mqttsn_gw_session_start(MqttsnSessionHandle session) +bool cc_mqttsn_gw_session_start(CC_MqttsnSessionHandle session) { if (session.obj == nullptr) { return false; @@ -348,7 +348,7 @@ bool mqttsn_gw_session_start(MqttsnSessionHandle session) return reinterpret_cast(session.obj)->start(); } -void mqttsn_gw_session_stop(MqttsnSessionHandle session) +void cc_mqttsn_gw_session_stop(CC_MqttsnSessionHandle session) { if (session.obj == nullptr) { return; @@ -357,7 +357,7 @@ void mqttsn_gw_session_stop(MqttsnSessionHandle session) reinterpret_cast(session.obj)->stop(); } -void mqttsn_gw_session_tick(MqttsnSessionHandle session) +void cc_mqttsn_gw_session_tick(CC_MqttsnSessionHandle session) { if (session.obj == nullptr) { return; @@ -366,8 +366,8 @@ void mqttsn_gw_session_tick(MqttsnSessionHandle session) reinterpret_cast(session.obj)->tick(); } -unsigned mqttsn_gw_session_data_from_client( - MqttsnSessionHandle session, +unsigned cc_mqttsn_gw_session_data_from_client( + CC_MqttsnSessionHandle session, const unsigned char* buf, unsigned bufLen) { @@ -380,8 +380,8 @@ unsigned mqttsn_gw_session_data_from_client( } -unsigned mqttsn_gw_session_data_from_broker( - MqttsnSessionHandle session, +unsigned cc_mqttsn_gw_session_data_from_broker( + CC_MqttsnSessionHandle session, const unsigned char* buf, unsigned bufLen) { @@ -394,7 +394,7 @@ unsigned mqttsn_gw_session_data_from_broker( } -void mqttsn_gw_session_broker_connected(MqttsnSessionHandle session, bool connected) +void cc_mqttsn_gw_session_broker_connected(CC_MqttsnSessionHandle session, bool connected) { if (session.obj == nullptr) { return; @@ -403,8 +403,8 @@ void mqttsn_gw_session_broker_connected(MqttsnSessionHandle session, bool connec reinterpret_cast(session.obj)->setBrokerConnected(connected); } -bool mqttsn_gw_session_add_predefined_topic( - MqttsnSessionHandle session, +bool cc_mqttsn_gw_session_add_predefined_topic( + CC_MqttsnSessionHandle session, const char* topic, unsigned short topicId) { @@ -415,8 +415,8 @@ bool mqttsn_gw_session_add_predefined_topic( return reinterpret_cast(session.obj)->addPredefinedTopic(topic, topicId); } -bool mqttsn_gw_session_set_topic_id_alloc_range( - MqttsnSessionHandle session, +bool cc_mqttsn_gw_session_set_topic_id_alloc_range( + CC_MqttsnSessionHandle session, unsigned short minTopicId, unsigned short maxTopicId) { @@ -429,19 +429,19 @@ bool mqttsn_gw_session_set_topic_id_alloc_range( /*===================== Config Object ======================*/ -MqttsnConfigHandle mqttsn_gw_config_alloc(void) +CC_MqttsnConfigHandle cc_mqttsn_gw_config_alloc(void) { - MqttsnConfigHandle config; + CC_MqttsnConfigHandle config; config.obj = new Config; return config; } -void mqttsn_gw_config_free(MqttsnConfigHandle config) +void cc_mqttsn_gw_config_free(CC_MqttsnConfigHandle config) { std::unique_ptr(reinterpret_cast(config.obj)); } -void mqttsn_gw_config_parse(MqttsnConfigHandle config, const char* str) +void cc_mqttsn_gw_config_parse(CC_MqttsnConfigHandle config, const char* str) { if (config.obj == nullptr) { return; @@ -452,7 +452,7 @@ void mqttsn_gw_config_parse(MqttsnConfigHandle config, const char* str) reinterpret_cast(config.obj)->read(stream); } -bool mqttsn_gw_config_read(MqttsnConfigHandle config, const char* filename) +bool cc_mqttsn_gw_config_read(CC_MqttsnConfigHandle config, const char* filename) { if (config.obj == nullptr) { return false; @@ -467,7 +467,7 @@ bool mqttsn_gw_config_read(MqttsnConfigHandle config, const char* filename) return true; } -unsigned char mqttsn_gw_config_id(MqttsnConfigHandle config) +unsigned char cc_mqttsn_gw_config_id(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -476,7 +476,7 @@ unsigned char mqttsn_gw_config_id(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->gatewayId(); } -unsigned short mqttsn_gw_config_advertise_period(MqttsnConfigHandle config) +unsigned short cc_mqttsn_gw_config_advertise_period(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -485,7 +485,7 @@ unsigned short mqttsn_gw_config_advertise_period(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->advertisePeriod(); } -unsigned mqttsn_gw_config_retry_period(MqttsnConfigHandle config) +unsigned cc_mqttsn_gw_config_retry_period(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -494,7 +494,7 @@ unsigned mqttsn_gw_config_retry_period(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->retryPeriod(); } -unsigned mqttsn_gw_config_retry_count(MqttsnConfigHandle config) +unsigned cc_mqttsn_gw_config_retry_count(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -503,7 +503,7 @@ unsigned mqttsn_gw_config_retry_count(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->retryCount(); } -const char* mqttsn_gw_config_default_client_id(MqttsnConfigHandle config) +const char* cc_mqttsn_gw_config_default_client_id(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return nullptr; @@ -512,7 +512,7 @@ const char* mqttsn_gw_config_default_client_id(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->defaultClientId().c_str(); } -unsigned mqttsn_gw_config_pub_only_keep_alive(MqttsnConfigHandle config) +unsigned cc_mqttsn_gw_config_pub_only_keep_alive(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -521,7 +521,7 @@ unsigned mqttsn_gw_config_pub_only_keep_alive(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->pubOnlyKeepAlive(); } -unsigned mqttsn_gw_config_sleeping_client_msg_limit(MqttsnConfigHandle config) +unsigned cc_mqttsn_gw_config_sleeping_client_msg_limit(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return std::numeric_limits::max(); @@ -533,7 +533,7 @@ unsigned mqttsn_gw_config_sleeping_client_msg_limit(MqttsnConfigHandle config) static_cast(std::numeric_limits::max()))); } -unsigned mqttsn_gw_config_available_predefined_topics(MqttsnConfigHandle config) +unsigned cc_mqttsn_gw_config_available_predefined_topics(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -543,9 +543,9 @@ unsigned mqttsn_gw_config_available_predefined_topics(MqttsnConfigHandle config) reinterpret_cast(config.obj)->predefinedTopics().size()); } -unsigned mqttsn_gw_config_get_predefined_topics( - MqttsnConfigHandle config, - MqttsnPredefinedTopicInfo* buf, +unsigned cc_mqttsn_gw_config_get_predefined_topics( + CC_MqttsnConfigHandle config, + CC_MqttsnPredefinedTopicInfo* buf, unsigned bufLen) { if (config.obj == nullptr) { @@ -557,9 +557,9 @@ unsigned mqttsn_gw_config_get_predefined_topics( std::transform( predefinedTopics.begin(), predefinedTopics.begin() + total, buf, - [](const mqttsn::gateway::Config::PredefinedTopicInfo& info) -> MqttsnPredefinedTopicInfo + [](const cc_mqttsn_gateway::Config::PredefinedTopicInfo& info) -> CC_MqttsnPredefinedTopicInfo { - MqttsnPredefinedTopicInfo retInfo; + CC_MqttsnPredefinedTopicInfo retInfo; retInfo.clientId = info.clientId.c_str(); retInfo.topic = info.topic.c_str(); retInfo.topicId = info.topicId; @@ -568,7 +568,7 @@ unsigned mqttsn_gw_config_get_predefined_topics( return total; } -unsigned mqttsn_gw_config_available_auth_infos(MqttsnConfigHandle config) +unsigned cc_mqttsn_gw_config_available_auth_infos(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -578,9 +578,9 @@ unsigned mqttsn_gw_config_available_auth_infos(MqttsnConfigHandle config) reinterpret_cast(config.obj)->authInfos().size()); } -unsigned mqttsn_gw_config_get_auth_infos( - MqttsnConfigHandle config, - MqttsnAuthInfo* buf, +unsigned cc_mqttsn_gw_config_get_auth_infos( + CC_MqttsnConfigHandle config, + CC_MqttsnAuthInfo* buf, unsigned bufLen) { if (config.obj == nullptr) { @@ -592,9 +592,9 @@ unsigned mqttsn_gw_config_get_auth_infos( std::transform( authInfos.begin(), authInfos.begin() + total, buf, - [](const mqttsn::gateway::Config::AuthInfo& info) -> MqttsnAuthInfo + [](const cc_mqttsn_gateway::Config::AuthInfo& info) -> CC_MqttsnAuthInfo { - MqttsnAuthInfo retInfo; + CC_MqttsnAuthInfo retInfo; retInfo.clientId = info.clientId.c_str(); retInfo.username = info.username.c_str(); retInfo.password = info.password.c_str(); @@ -603,8 +603,8 @@ unsigned mqttsn_gw_config_get_auth_infos( return total; } -void mqttsn_gw_config_topic_id_alloc_range( - MqttsnConfigHandle config, +void cc_mqttsn_gw_config_topic_id_alloc_range( + CC_MqttsnConfigHandle config, unsigned short* min, unsigned short* max) { @@ -622,7 +622,7 @@ void mqttsn_gw_config_topic_id_alloc_range( } } -const char* mqttsn_gw_config_broker_address(MqttsnConfigHandle config) +const char* cc_mqttsn_gw_config_broker_address(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return nullptr; @@ -631,7 +631,7 @@ const char* mqttsn_gw_config_broker_address(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->brokerTcpHostAddress().c_str(); } -unsigned short mqttsn_gw_config_broker_port(MqttsnConfigHandle config) +unsigned short cc_mqttsn_gw_config_broker_port(CC_MqttsnConfigHandle config) { if (config.obj == nullptr) { return 0U; @@ -640,7 +640,7 @@ unsigned short mqttsn_gw_config_broker_port(MqttsnConfigHandle config) return reinterpret_cast(config.obj)->brokerTcpHostPort(); } -unsigned mqttsn_gw_config_values_count(MqttsnConfigHandle config, const char* key) +unsigned cc_mqttsn_gw_config_values_count(CC_MqttsnConfigHandle config, const char* key) { if (config.obj == nullptr) { return 0U; @@ -651,7 +651,7 @@ unsigned mqttsn_gw_config_values_count(MqttsnConfigHandle config, const char* ke return static_cast(std::distance(range.first, range.second)); } -const char* mqttsn_gw_config_get_value(MqttsnConfigHandle config, const char* key, unsigned idx) +const char* cc_mqttsn_gw_config_get_value(CC_MqttsnConfigHandle config, const char* key, unsigned idx) { if (config.obj == nullptr) { return 0U; diff --git a/gateway/src/lib/messages.h b/gateway/src/lib/messages.h index 0ede66b0..0d8cf317 100644 --- a/gateway/src/lib/messages.h +++ b/gateway/src/lib/messages.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,27 +7,24 @@ #pragma once -#include "mqttsn/Message.h" -#include "mqttsn/frame/Frame.h" -#include "mqttsn/input/ServerInputMessages.h" -#include "mqttsn/options/ServerDefaultOptions.h" -#include "mqttsn/options/DataViewDefaultOptions.h" -#include "mqtt311/Message.h" -#include "mqtt311/frame/Frame.h" -#include "mqtt311/input/ClientInputMessages.h" -#include "mqtt311/options/ClientDefaultOptions.h" -#include "mqtt311/options/DataViewDefaultOptions.h" - -namespace mqttsn -{ - -namespace gateway +#include "cc_mqttsn/Message.h" +#include "cc_mqttsn/frame/Frame.h" +#include "cc_mqttsn/input/ServerInputMessages.h" +#include "cc_mqttsn/options/ServerDefaultOptions.h" +#include "cc_mqttsn/options/DataViewDefaultOptions.h" +#include "cc_mqtt311/Message.h" +#include "cc_mqtt311/frame/Frame.h" +#include "cc_mqtt311/input/ClientInputMessages.h" +#include "cc_mqtt311/options/ClientDefaultOptions.h" +#include "cc_mqtt311/options/DataViewDefaultOptions.h" + +namespace cc_mqttsn_gateway { class MsgHandler; using MqttsnMessage = - mqttsn::Message< + cc_mqttsn::Message< comms::option::IdInfoInterface, comms::option::ReadIterator, comms::option::WriteIterator, @@ -36,7 +33,7 @@ using MqttsnMessage = >; using MqttMessage = - mqtt311::Message< + cc_mqtt311::Message< comms::option::IdInfoInterface, comms::option::ReadIterator, comms::option::WriteIterator, @@ -45,79 +42,75 @@ using MqttMessage = >; using MqttsnGwOptions = - mqttsn::options::DataViewDefaultOptionsT< - mqttsn::options::ServerDefaultOptions + cc_mqttsn::options::DataViewDefaultOptionsT< + cc_mqttsn::options::ServerDefaultOptions >; -typedef mqttsn::message::Advertise AdvertiseMsg_SN; -typedef mqttsn::message::Searchgw SearchgwMsg_SN; -typedef mqttsn::message::Gwinfo GwinfoMsg_SN; -typedef mqttsn::message::Connect ConnectMsg_SN; -typedef mqttsn::message::Connack ConnackMsg_SN; -typedef mqttsn::message::Willtopicreq WilltopicreqMsg_SN; -typedef mqttsn::message::Willtopic WilltopicMsg_SN; -typedef mqttsn::message::Willmsgreq WillmsgreqMsg_SN; -typedef mqttsn::message::Willmsg WillmsgMsg_SN; -typedef mqttsn::message::Register RegisterMsg_SN; -typedef mqttsn::message::Regack RegackMsg_SN; -typedef mqttsn::message::Publish PublishMsg_SN; -typedef mqttsn::message::Puback PubackMsg_SN; -typedef mqttsn::message::Pubrec PubrecMsg_SN; -typedef mqttsn::message::Pubrel PubrelMsg_SN; -typedef mqttsn::message::Pubcomp PubcompMsg_SN; -typedef mqttsn::message::Subscribe SubscribeMsg_SN; -typedef mqttsn::message::Suback SubackMsg_SN; -typedef mqttsn::message::Unsubscribe UnsubscribeMsg_SN; -typedef mqttsn::message::Unsuback UnsubackMsg_SN; -typedef mqttsn::message::Pingreq PingreqMsg_SN; -typedef mqttsn::message::Pingresp PingrespMsg_SN; -typedef mqttsn::message::Disconnect DisconnectMsg_SN; -typedef mqttsn::message::Willtopicupd WilltopicupdMsg_SN; -typedef mqttsn::message::Willtopicresp WilltopicrespMsg_SN; -typedef mqttsn::message::Willmsgupd WillmsgupdMsg_SN; -typedef mqttsn::message::Willmsgresp WillmsgrespMsg_SN; +typedef cc_mqttsn::message::Advertise AdvertiseMsg_SN; +typedef cc_mqttsn::message::Searchgw SearchgwMsg_SN; +typedef cc_mqttsn::message::Gwinfo GwinfoMsg_SN; +typedef cc_mqttsn::message::Connect ConnectMsg_SN; +typedef cc_mqttsn::message::Connack ConnackMsg_SN; +typedef cc_mqttsn::message::Willtopicreq WilltopicreqMsg_SN; +typedef cc_mqttsn::message::Willtopic WilltopicMsg_SN; +typedef cc_mqttsn::message::Willmsgreq WillmsgreqMsg_SN; +typedef cc_mqttsn::message::Willmsg WillmsgMsg_SN; +typedef cc_mqttsn::message::Register RegisterMsg_SN; +typedef cc_mqttsn::message::Regack RegackMsg_SN; +typedef cc_mqttsn::message::Publish PublishMsg_SN; +typedef cc_mqttsn::message::Puback PubackMsg_SN; +typedef cc_mqttsn::message::Pubrec PubrecMsg_SN; +typedef cc_mqttsn::message::Pubrel PubrelMsg_SN; +typedef cc_mqttsn::message::Pubcomp PubcompMsg_SN; +typedef cc_mqttsn::message::Subscribe SubscribeMsg_SN; +typedef cc_mqttsn::message::Suback SubackMsg_SN; +typedef cc_mqttsn::message::Unsubscribe UnsubscribeMsg_SN; +typedef cc_mqttsn::message::Unsuback UnsubackMsg_SN; +typedef cc_mqttsn::message::Pingreq PingreqMsg_SN; +typedef cc_mqttsn::message::Pingresp PingrespMsg_SN; +typedef cc_mqttsn::message::Disconnect DisconnectMsg_SN; +typedef cc_mqttsn::message::Willtopicupd WilltopicupdMsg_SN; +typedef cc_mqttsn::message::Willtopicresp WilltopicrespMsg_SN; +typedef cc_mqttsn::message::Willmsgupd WillmsgupdMsg_SN; +typedef cc_mqttsn::message::Willmsgresp WillmsgrespMsg_SN; template -using InputMqttsnMessages = mqttsn::input::ServerInputMessages; +using InputMqttsnMessages = cc_mqttsn::input::ServerInputMessages; using MqttsnProtStack = - mqttsn::frame::Frame >; + cc_mqttsn::frame::Frame >; -//using Mqtt311GwOptions = mqtt311::options::ClientDefaultOptions; +//using Mqtt311GwOptions = cc_mqtt311::options::ClientDefaultOptions; // TODO: Currently gateway is implemented to receive PING and DISCONNECT from server, // According to protocol spec these are client only messages. Consider using ClientDefaultOptions in the future -using Mqtt311GwOptions = mqtt311::options::DefaultOptions; - -typedef mqtt311::message::Connect ConnectMsg; -typedef mqtt311::message::Connack ConnackMsg; -typedef mqtt311::message::Publish PublishMsg; -typedef mqtt311::message::Puback PubackMsg; -typedef mqtt311::message::Pubrec PubrecMsg; -typedef mqtt311::message::Pubrel PubrelMsg; -typedef mqtt311::message::Pubcomp PubcompMsg; -typedef mqtt311::message::Subscribe SubscribeMsg; -typedef mqtt311::message::Suback SubackMsg; -typedef mqtt311::message::Unsubscribe UnsubscribeMsg; -typedef mqtt311::message::Unsuback UnsubackMsg; -typedef mqtt311::message::Pingreq PingreqMsg; -typedef mqtt311::message::Pingresp PingrespMsg; -typedef mqtt311::message::Disconnect DisconnectMsg; +using Mqtt311GwOptions = cc_mqtt311::options::DefaultOptions; + +typedef cc_mqtt311::message::Connect ConnectMsg; +typedef cc_mqtt311::message::Connack ConnackMsg; +typedef cc_mqtt311::message::Publish PublishMsg; +typedef cc_mqtt311::message::Puback PubackMsg; +typedef cc_mqtt311::message::Pubrec PubrecMsg; +typedef cc_mqtt311::message::Pubrel PubrelMsg; +typedef cc_mqtt311::message::Pubcomp PubcompMsg; +typedef cc_mqtt311::message::Subscribe SubscribeMsg; +typedef cc_mqtt311::message::Suback SubackMsg; +typedef cc_mqtt311::message::Unsubscribe UnsubscribeMsg; +typedef cc_mqtt311::message::Unsuback UnsubackMsg; +typedef cc_mqtt311::message::Pingreq PingreqMsg; +typedef cc_mqtt311::message::Pingresp PingrespMsg; +typedef cc_mqtt311::message::Disconnect DisconnectMsg; // template -// using InputMqtt311Messages = mqtt311::input::ClientInputMessages; +// using InputMqtt311Messages = cc_mqtt311::input::ClientInputMessages; // TODO: Currently gateway is implemented to receive PING and DISCONNECT from server, // According to protocol spec these are client only messages. Consider using ClientInputMessages in the future template -using InputMqtt311Messages = mqtt311::input::AllMessages; +using InputMqtt311Messages = cc_mqtt311::input::AllMessages; using MqttProtStack = - mqtt311::frame::Frame > ; - -} // namespace gateway - -} // namespace mqttsn - + cc_mqtt311::frame::Frame > ; +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Asleep.cpp b/gateway/src/lib/session_op/Asleep.cpp index 78c2c46b..d79feb24 100644 --- a/gateway/src/lib/session_op/Asleep.cpp +++ b/gateway/src/lib/session_op/Asleep.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -129,9 +126,4 @@ void Asleep::reqNextTick() } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Asleep.h b/gateway/src/lib/session_op/Asleep.h index 6ee9a7a3..1381acfd 100644 --- a/gateway/src/lib/session_op/Asleep.h +++ b/gateway/src/lib/session_op/Asleep.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -48,8 +45,6 @@ class Asleep : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/AsleepMonitor.cpp b/gateway/src/lib/session_op/AsleepMonitor.cpp index 6e295f47..1eeca5f2 100644 --- a/gateway/src/lib/session_op/AsleepMonitor.cpp +++ b/gateway/src/lib/session_op/AsleepMonitor.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,13 +10,10 @@ #include #include -namespace mqttsn +namespace cc_mqttsn_gateway { -namespace gateway -{ - -namespace session_op +namespace session_op { AsleepMonitor::AsleepMonitor(SessionState& sessionState) @@ -98,9 +95,4 @@ void AsleepMonitor::reqNextTick() } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/AsleepMonitor.h b/gateway/src/lib/session_op/AsleepMonitor.h index 026d0048..07e2cf81 100644 --- a/gateway/src/lib/session_op/AsleepMonitor.h +++ b/gateway/src/lib/session_op/AsleepMonitor.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -46,8 +43,6 @@ class AsleepMonitor : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Connect.cpp b/gateway/src/lib/session_op/Connect.cpp index 9fe47af6..a99d74d8 100644 --- a/gateway/src/lib/session_op/Connect.cpp +++ b/gateway/src/lib/session_op/Connect.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,10 +8,7 @@ #include "Connect.h" #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -152,7 +149,7 @@ void Connect::handle(PublishMsg_SN& msg) return; } - if (msg.field_flags().field_qos().value() != mqttsn::field::QosVal::NoGwPublish) { + if (msg.field_flags().field_qos().value() != cc_mqttsn::field::QosVal::NoGwPublish) { return; } @@ -405,9 +402,7 @@ void Connect::clearInternalState() } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Connect.h b/gateway/src/lib/session_op/Connect.h index d2fa32b6..d8fc19c8 100644 --- a/gateway/src/lib/session_op/Connect.h +++ b/gateway/src/lib/session_op/Connect.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,14 +7,11 @@ #pragma once -#include "mqttsn/gateway/Session.h" +#include "cc_mqttsn_gateway/Session.h" #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -60,7 +57,7 @@ class Connect : public SessionOp bool m_pubOnlyClient = false; }; - using ReturnCodeVal = mqttsn::field::ReturnCodeVal; + using ReturnCodeVal = cc_mqttsn::field::ReturnCodeVal; using Base::handle; virtual void handle(ConnectMsg_SN& msg) override; @@ -87,8 +84,6 @@ class Connect : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Disconnect.cpp b/gateway/src/lib/session_op/Disconnect.cpp index e4f08a7e..8b46b0d4 100644 --- a/gateway/src/lib/session_op/Disconnect.cpp +++ b/gateway/src/lib/session_op/Disconnect.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,10 +9,7 @@ #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -79,9 +76,7 @@ void Disconnect::sendDisconnectSn() } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Disconnect.h b/gateway/src/lib/session_op/Disconnect.h index c331849a..23957597 100644 --- a/gateway/src/lib/session_op/Disconnect.h +++ b/gateway/src/lib/session_op/Disconnect.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -40,8 +37,6 @@ class Disconnect : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Forward.cpp b/gateway/src/lib/session_op/Forward.cpp index d173e18e..cc3d3084 100644 --- a/gateway/src/lib/session_op/Forward.cpp +++ b/gateway/src/lib/session_op/Forward.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -32,7 +29,7 @@ void Forward::handle(PublishMsg_SN& msg) do { - if ((msg.field_flags().field_qos().value() != mqttsn::field::QosVal::NoGwPublish) || + if ((msg.field_flags().field_qos().value() != cc_mqttsn::field::QosVal::NoGwPublish) || (st.m_connStatus == ConnectionStatus::Connected)) { break; } @@ -371,7 +368,7 @@ void Forward::handle(SubackMsg& msg) return (elem.m_timestamp + state().m_retryPeriod) < state().m_timestamp; }); - auto qos = mqttsn::field::QosVal::AtMostOnceDelivery; + auto qos = cc_mqttsn::field::QosVal::AtMostOnceDelivery; auto rc = ReturnCodeVal::NotSupported; do { auto& retCodesList = msg.field_list().value(); @@ -386,7 +383,7 @@ void Forward::handle(SubackMsg& msg) } auto adjustedRetCode = std::min(ackRetCode.value(), SubackRetCode::Qos2); - auto reportedQos = static_cast(adjustedRetCode); + auto reportedQos = static_cast(adjustedRetCode); qos = translateQosForClient(translateQos(reportedQos)); rc = ReturnCodeVal::Accepted; } while (false); @@ -420,9 +417,4 @@ void Forward::sendPubackToClient( } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/Forward.h b/gateway/src/lib/session_op/Forward.h index 44217db8..77f0382d 100644 --- a/gateway/src/lib/session_op/Forward.h +++ b/gateway/src/lib/session_op/Forward.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,10 +14,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -68,8 +65,8 @@ class Forward : public SessionOp typedef std::list NoGwPubInfosList; - using ReturnCodeVal = mqttsn::field::ReturnCodeVal; - using TopicIdTypeVal = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; + using ReturnCodeVal = cc_mqttsn::field::ReturnCodeVal; + using TopicIdTypeVal = cc_mqttsn::field::TopicIdTypeVal; void sendPubackToClient( std::uint16_t topicId, std::uint16_t msgId, @@ -84,8 +81,4 @@ class Forward : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/PubRecv.cpp b/gateway/src/lib/session_op/PubRecv.cpp index afcc4d80..c40a6427 100644 --- a/gateway/src/lib/session_op/PubRecv.cpp +++ b/gateway/src/lib/session_op/PubRecv.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -163,9 +160,7 @@ void PubRecv::addPubInfo(PubInfoPtr info) } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/PubRecv.h b/gateway/src/lib/session_op/PubRecv.h index feff8741..e2155430 100644 --- a/gateway/src/lib/session_op/PubRecv.h +++ b/gateway/src/lib/session_op/PubRecv.h @@ -10,10 +10,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -53,8 +50,6 @@ class PubRecv : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/PubSend.cpp b/gateway/src/lib/session_op/PubSend.cpp index 57a23f68..89fefcaf 100644 --- a/gateway/src/lib/session_op/PubSend.cpp +++ b/gateway/src/lib/session_op/PubSend.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -301,9 +298,4 @@ void PubSend::checkSend() } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/PubSend.h b/gateway/src/lib/session_op/PubSend.h index 5dfc6f02..1dfcc64b 100644 --- a/gateway/src/lib/session_op/PubSend.h +++ b/gateway/src/lib/session_op/PubSend.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -31,7 +28,7 @@ class PubSend : public SessionOp virtual void tickImpl() override; private: typedef RegMgr::TopicInfo TopicInfo; - using ReturnCodeVal = mqttsn::field::ReturnCodeVal; + using ReturnCodeVal = cc_mqttsn::field::ReturnCodeVal; using Base::handle; virtual void handle(RegackMsg_SN& msg) override; @@ -64,8 +61,4 @@ class PubSend : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/WillUpdate.cpp b/gateway/src/lib/session_op/WillUpdate.cpp index d9e19881..a6d07a37 100644 --- a/gateway/src/lib/session_op/WillUpdate.cpp +++ b/gateway/src/lib/session_op/WillUpdate.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include #include -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -258,9 +255,7 @@ void WillUpdate::sendFailureAndTerm() } // namespace session_op -} // namespace gateway - -} // namespace mqttsn +} // namespace cc_mqttsn_gateway diff --git a/gateway/src/lib/session_op/WillUpdate.h b/gateway/src/lib/session_op/WillUpdate.h index 63052056..dce92564 100644 --- a/gateway/src/lib/session_op/WillUpdate.h +++ b/gateway/src/lib/session_op/WillUpdate.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,7 @@ #include "SessionOp.h" #include "common.h" -namespace mqttsn -{ - -namespace gateway +namespace cc_mqttsn_gateway { namespace session_op @@ -39,7 +36,7 @@ class WillUpdate : public SessionOp MsgUpd }; - using ReturnCodeVal = mqttsn::field::ReturnCodeVal; + using ReturnCodeVal = cc_mqttsn::field::ReturnCodeVal; using Base::handle; virtual void handle(ConnectMsg_SN& msg) override; @@ -65,8 +62,4 @@ class WillUpdate : public SessionOp } // namespace session_op -} // namespace gateway - -} // namespace mqttsn - - +} // namespace cc_mqttsn_gateway diff --git a/gateway/test/CMakeLists.txt b/gateway/test/CMakeLists.txt index d5086077..14e51b72 100644 --- a/gateway/test/CMakeLists.txt +++ b/gateway/test/CMakeLists.txt @@ -12,33 +12,9 @@ function (lib_common_test_session) "TestMsgHandler.cpp" ) add_library (${COMMON_TEST_SESSION_LIB} STATIC ${src}) - target_link_libraries(${COMMON_TEST_SESSION_LIB} PRIVATE cc::comms) + target_link_libraries(${COMMON_TEST_SESSION_LIB} PUBLIC cc::cc_mqtt311 cc::cc_mqttsn cc::comms) add_dependencies (${COMMON_TEST_SESSION_LIB} ${MQTTSN_GATEWAY_LIB_NAME}) - if (TARGET cc::mqtt311) - target_link_libraries(${COMMON_TEST_SESSION_LIB} PRIVATE cc::mqtt311) - endif () - - if (TARGET cc::mqttsn) - target_link_libraries(${COMMON_TEST_SESSION_LIB} PRIVATE cc::mqttsn) - endif () - - if (NOT "${CC_MQTT_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${COMMON_TEST_SESSION_LIB} PRIVATE ${CC_MQTT_EXTERNAL_TGT_INCLUDE}) - endif () - - if (NOT "${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${COMMON_TEST_SESSION_LIB} PRIVATE ${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}) - endif () - - if (TARGET ${CC_MQTT_EXTERNAL_TGT}) - add_dependencies(${COMMON_TEST_SESSION_LIB} ${CC_MQTT_EXTERNAL_TGT}) - endif () - - if (TARGET ${CC_MQTTSN_EXTERNAL_TGT}) - add_dependencies(${COMMON_TEST_SESSION_LIB} ${CC_MQTTSN_EXTERNAL_TGT}) - endif () - endfunction () ################################################################# @@ -58,37 +34,7 @@ function (test_func test_suite_name) SRC ${tests} ${valgrand_args}) - target_link_libraries(${name} PRIVATE ${COMMON_TEST_SESSION_LIB} ${MQTTSN_GATEWAY_LIB_NAME}) - - target_compile_options(${name} PRIVATE - $<$:-Wno-old-style-cast -Wno-ignored-qualifiers -Wno-conversion> - $<$:-Wno-old-style-cast -Wno-ignored-qualifiers> - ) - - if (TARGET cc::mqtt311) - target_link_libraries(${name} PRIVATE cc::mqtt311) - endif () - - if (TARGET cc::mqttsn) - target_link_libraries(${name} PRIVATE cc::mqtts ) - endif () - - if (NOT "${CC_MQTT_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${name} PRIVATE ${CC_MQTT_EXTERNAL_TGT_INCLUDE}) - endif () - - if (NOT "${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}" STREQUAL "") - target_include_directories(${name} PRIVATE ${CC_MQTTSN_EXTERNAL_TGT_INCLUDE}) - endif () - - if (TARGET ${CC_MQTT_EXTERNAL_TGT}) - add_dependencies(${name} ${CC_MQTT_EXTERNAL_TGT}) - endif () - - if (TARGET ${CC_MQTTSN_EXTERNAL_TGT}) - add_dependencies(${name} ${CC_MQTTSN_EXTERNAL_TGT}) - endif () - + target_link_libraries(${name} PRIVATE ${COMMON_TEST_SESSION_LIB} ${MQTTSN_GATEWAY_LIB_NAME} cxxtest::cxxtest) endfunction () ################################################################# @@ -105,10 +51,6 @@ endfunction () ################################################################# -include_directories ( - "${CXXTEST_INCLUDE_DIR}" -) - lib_common_test_session() test_gateway() test_session() diff --git a/gateway/test/Gateway.th b/gateway/test/Gateway.th index 3d5a2804..a516cadf 100644 --- a/gateway/test/Gateway.th +++ b/gateway/test/Gateway.th @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,7 +8,7 @@ #pragma once #include "comms/comms.h" -#include "mqttsn/gateway/Gateway.h" +#include "cc_mqttsn_gateway/Gateway.h" CC_DISABLE_WARNINGS() #include "cxxtest/TestSuite.h" @@ -22,7 +22,7 @@ public: void GatewayTests::test1() { - mqttsn::gateway::Gateway gw; + cc_mqttsn_gateway::Gateway gw; TS_ASSERT(!gw.start()); diff --git a/gateway/test/Session.th b/gateway/test/Session.th index 64041644..dbd7b079 100644 --- a/gateway/test/Session.th +++ b/gateway/test/Session.th @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,7 +10,7 @@ #include #include "comms/comms.h" -#include "mqttsn/gateway/Session.h" +#include "cc_mqttsn_gateway/Session.h" CC_DISABLE_WARNINGS() #include "cxxtest/TestSuite.h" @@ -51,9 +51,9 @@ public: void test28(); private: - typedef std::unique_ptr SessionPtr; + typedef std::unique_ptr SessionPtr; typedef std::vector DataBuf; - using TopicIdTypeVal = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; + using TopicIdTypeVal = cc_mqttsn::field::TopicIdTypeVal; static const std::uint8_t DefaultGwId = 5; static const std::uint16_t DefaultKeepAlivePeriod = 60; @@ -78,7 +78,7 @@ private: { std::string m_topic; DataBuf m_msg; - mqtt311::field::QosVal m_qos = mqtt311::field::QosVal::AtMostOnceDelivery; + cc_mqtt311::field::QosVal m_qos = cc_mqtt311::field::QosVal::AtMostOnceDelivery; bool m_retain = false; }; @@ -90,7 +90,7 @@ private: const DataBuf* password = nullptr, bool connectToBroker = true) { - SessionPtr session(new mqttsn::gateway::Session); + SessionPtr session(new cc_mqttsn_gateway::Session); session->setNextTickProgramReqCb( [&state](unsigned val) { @@ -143,9 +143,9 @@ private: }); session->setAuthInfoReqCb( - [username, password](const std::string&) -> mqttsn::gateway::Session::AuthInfo + [username, password](const std::string&) -> cc_mqttsn_gateway::Session::AuthInfo { - mqttsn::gateway::Session::AuthInfo info; + cc_mqttsn_gateway::Session::AuthInfo info; if (username == nullptr) { return info; } @@ -350,7 +350,7 @@ private: } static void dataFromClient( - mqttsn::gateway::Session& session, + cc_mqttsn_gateway::Session& session, const DataBuf& buf, const std::string& msgStr) { @@ -360,7 +360,7 @@ private: } static void dataFromBroker( - mqttsn::gateway::Session& session, + cc_mqttsn_gateway::Session& session, const DataBuf& buf, const std::string& msgStr) { @@ -413,7 +413,7 @@ private: static void verifySentToClient_ConnackMsg( State& state, TestMsgHandler& handler, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { if (state.m_sentToClient.empty()) { TS_FAIL("No data was sent to client"); @@ -514,7 +514,7 @@ private: State& state, TestMsgHandler& handler, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { if (state.m_sentToClient.empty()) { TS_FAIL("No data was sent to client"); @@ -584,7 +584,7 @@ private: std::uint16_t topicId, const DataBuf& msgData, TopicIdTypeVal topicType, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain, bool duplicate) { @@ -625,7 +625,7 @@ private: TestMsgHandler& handler, std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { if (state.m_sentToClient.empty()) { TS_FAIL("No data was sent to client"); @@ -788,8 +788,8 @@ private: State& state, TestMsgHandler& handler, std::uint16_t msgId, - mqttsn::field::QosVal qos, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::QosVal qos, + cc_mqttsn::field::ReturnCodeVal rc) { if (state.m_sentToClient.empty()) { TS_FAIL("No data was sent to client"); @@ -848,7 +848,7 @@ private: static void verifySentToClient_WilltopicrespMsg( State& state, TestMsgHandler& handler, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { if (state.m_sentToClient.empty()) { TS_FAIL("No data was sent to client"); @@ -875,7 +875,7 @@ private: static void verifySentToClient_WillmsgrespMsg( State& state, TestMsgHandler& handler, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { if (state.m_sentToClient.empty()) { TS_FAIL("No data was sent to client"); @@ -1055,7 +1055,7 @@ private: const std::string& topic, const DataBuf& data, std::uint16_t packetId, - mqtt311::field::QosVal qos, + cc_mqtt311::field::QosVal qos, bool retain, bool dup) { @@ -1079,7 +1079,7 @@ private: TS_ASSERT_EQUALS(msg.field_topic().value(), topic); TS_ASSERT_EQUALS(msg.field_payload().value(), data); - if (qos == mqtt311::field::QosVal::AtMostOnceDelivery) { + if (qos == cc_mqtt311::field::QosVal::AtMostOnceDelivery) { TS_ASSERT_EQUALS(msg.field_packetId().getMode(), comms::field::OptionalMode::Missing); } else { @@ -1208,7 +1208,7 @@ private: State& state, TestMsgHandler& handler, const std::string& topic, - mqtt311::field::QosVal qos, + cc_mqtt311::field::QosVal qos, std::uint16_t packetId) { if (state.m_sentToBroker.empty()) { @@ -1364,21 +1364,21 @@ private: (static_cast(topic[0]) << 8) | static_cast(topic[1])); } - static mqttsn::field::QosVal translateQos(mqtt311::field::QosVal val) + static cc_mqttsn::field::QosVal translateQos(cc_mqtt311::field::QosVal val) { - return static_cast(val); + return static_cast(val); } - static mqtt311::field::QosVal translateQos(mqttsn::field::QosVal val) + static cc_mqtt311::field::QosVal translateQos(cc_mqttsn::field::QosVal val) { - if (val == mqttsn::field::QosVal::NoGwPublish) { - return mqtt311::field::QosVal::AtMostOnceDelivery; + if (val == cc_mqttsn::field::QosVal::NoGwPublish) { + return cc_mqtt311::field::QosVal::AtMostOnceDelivery; } - return static_cast(val); + return static_cast(val); } - static void doTick(State& state, mqttsn::gateway::Session& session, unsigned ms = 0) + static void doTick(State& state, cc_mqttsn_gateway::Session& session, unsigned ms = 0) { if (ms != 0) { TS_TRACE("[TICK]: " + std::to_string(ms)); @@ -1400,7 +1400,7 @@ private: } static void doConnect( - mqttsn::gateway::Session& session, + cc_mqttsn_gateway::Session& session, State& state, TestMsgHandler& handler, WillInfo* willInfo = nullptr, @@ -1455,20 +1455,20 @@ private: using ConnackResponseCodeVal = ConnackMsg::Field_returnCode::ValueType; auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted); dataFromBroker(session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); if (expectClientReport) { verifyConnectedClient(state, DefaultClientId); } verifyNoOtherEvent(state, handler); } - static void doBrokerConnect(mqttsn::gateway::Session& session) + static void doBrokerConnect(cc_mqttsn_gateway::Session& session) { session.setBrokerConnected(true); TS_TRACE("[BROKER connected]"); } - static void doBrokerDisconnect(mqttsn::gateway::Session& session) + static void doBrokerDisconnect(cc_mqttsn_gateway::Session& session) { session.setBrokerConnected(false); TS_TRACE("[BROKER disconnected]"); @@ -1507,7 +1507,7 @@ void SessionTest::test2() using ConnackResponseCodeVal = ConnackMsg::Field_returnCode::ValueType; auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyConnectedClient(state, ClientId); verifyNoOtherEvent(state, handler); } @@ -1533,12 +1533,12 @@ void SessionTest::test3() using ConnackResponseCodeVal = ConnackMsg::Field_returnCode::ValueType; auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyConnectedClient(state, ClientId); verifyNoOtherEvent(state, handler); dataFromClient(*session, connectMsg, "CONNECT"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); @@ -1563,7 +1563,7 @@ void SessionTest::test3() verifyNoOtherEvent(state, handler); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); static const std::string ClientId2 = "blablabla"; @@ -1592,7 +1592,7 @@ void SessionTest::test4() static const std::string WillTopic("this/is/will"); static const DataBuf WillMsg = {0, 1, 2, 3, 4, 5}; - static const auto WillQos = mqttsn::field::QosVal::AtLeastOnceDelivery; + static const auto WillQos = cc_mqttsn::field::QosVal::AtLeastOnceDelivery; static const bool WillRetain = false; state.m_elapsed.push_back(1000); @@ -1604,7 +1604,7 @@ void SessionTest::test4() WillInfo willInfo; willInfo.m_topic = WillTopic; willInfo.m_msg = WillMsg; - willInfo.m_qos = mqtt311::field::QosVal::AtLeastOnceDelivery; + willInfo.m_qos = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; willInfo.m_retain = WillRetain; state.m_elapsed.push_back(1000); @@ -1615,7 +1615,7 @@ void SessionTest::test4() using ConnackResponseCodeVal = ConnackMsg::Field_returnCode::ValueType; auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::BadAuth); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::NotSupported); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::NotSupported); verifyNoOtherEvent(state, handler); } @@ -1718,7 +1718,7 @@ void SessionTest::test7() state.m_elapsed.push_back(2000); auto connectMsg = handler.prepareClientConnect(DefaultClientId, DefaultKeepAlivePeriod, false, false); dataFromClient(*session, connectMsg, "CONNECT"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); verifyNoOtherEvent(state, handler); } @@ -1731,7 +1731,7 @@ void SessionTest::test8() static const std::string WillTopic("will/topic"); static const DataBuf WillMsg = {0x1, 0x2, 0x3}; - static const auto WillQos = mqtt311::field::QosVal::AtMostOnceDelivery; + static const auto WillQos = cc_mqtt311::field::QosVal::AtMostOnceDelivery; static const bool WillRetain = false; WillInfo willInfo; willInfo.m_topic = WillTopic; @@ -1780,7 +1780,7 @@ void SessionTest::test8() state.m_elapsed.push_back(1000); auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); } @@ -1796,15 +1796,15 @@ void SessionTest::test9() static const std::uint16_t MsgId = 0x1122; auto registerMsg = handler.prepareClientRegister(Topic, MsgId); dataFromClient(*session, registerMsg, "REGISTER"); - auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, mqttsn::field::ReturnCodeVal::Accepted); + auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); TS_ASSERT_LESS_THAN_EQUALS(DefaultMinTopicId, topicId); TS_ASSERT_LESS_THAN_EQUALS(topicId, DefaultMaxTopicId); verifyNoOtherEvent(state, handler); - auto registerMsg2 = handler.prepareClientRegister(Topic, MsgId + 1); + auto registerMsg2 = handler.prepareClientRegister(Topic, static_cast(MsgId + 1)); dataFromClient(*session, registerMsg2, "REGISTER"); - auto topicId2 = verifySentToClient_RegackMsg(state, handler, MsgId + 1, mqttsn::field::ReturnCodeVal::Accepted); + auto topicId2 = verifySentToClient_RegackMsg(state, handler, static_cast(MsgId + 1), cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); TS_ASSERT_EQUALS(topicId, topicId2); verifyNoOtherEvent(state, handler); @@ -1826,16 +1826,16 @@ void SessionTest::test10() static const std::uint16_t MsgId = 0x1122; auto registerMsg = handler.prepareClientRegister(Topic2, MsgId); dataFromClient(*session, registerMsg, "REGISTER"); - auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, mqttsn::field::ReturnCodeVal::Accepted); + auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); TS_ASSERT_LESS_THAN_EQUALS(DefaultMinTopicId, topicId); TS_ASSERT_LESS_THAN_EQUALS(topicId, DefaultMaxTopicId); TS_ASSERT_DIFFERS(topicId, TopicId1); verifyNoOtherEvent(state, handler); - auto registerMsg2 = handler.prepareClientRegister(Topic1, MsgId + 1); + auto registerMsg2 = handler.prepareClientRegister(Topic1, static_cast(MsgId + 1)); dataFromClient(*session, registerMsg2, "REGISTER"); - auto topicId2 = verifySentToClient_RegackMsg(state, handler, MsgId + 1, mqttsn::field::ReturnCodeVal::Accepted); + auto topicId2 = verifySentToClient_RegackMsg(state, handler, static_cast(MsgId + 1), cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); TS_ASSERT_EQUALS(topicId2, TopicId1); verifyNoOtherEvent(state, handler); @@ -1855,7 +1855,7 @@ void SessionTest::test11() static const DataBuf Data = {0, 1, 2, 3, 4 }; static const std::uint16_t MsgId = 1234; - static const auto Qos = mqtt311::field::QosVal::AtMostOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::AtMostOnceDelivery; static const bool Retain = false; static const bool Dup = false; auto publishMsg = handler.prepareBrokerPublish(Topic, Data, MsgId, Qos, Retain, Dup); @@ -1878,7 +1878,7 @@ void SessionTest::test12() static const DataBuf Data = {0, 1, 2, 3, 4 }; static const std::uint16_t MsgId = 1234; - static const auto Qos = mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; static const bool Retain = false; auto publishMsg = handler.prepareBrokerPublish(Topic, Data, MsgId, Qos, Retain, false); dataFromBroker(*session, publishMsg, "PUBLISH"); @@ -1901,7 +1901,7 @@ void SessionTest::test12() TS_ASSERT_EQUALS(msgId, msgId2); state.m_elapsed.push_back(1000); - auto pubackMsg = handler.prepareClientPuback(TopicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto pubackMsg = handler.prepareClientPuback(TopicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, pubackMsg, "PUBACK"); auto msgId3 = verifySentToClient_PublishMsg(state, handler, TopicId, Data, TopicIdTypeVal::PredefinedTopicId, translateQos(Qos), Retain, true); verifyTickReq(state, DefaultRetryPeriod * 1000); @@ -1920,7 +1920,7 @@ void SessionTest::test13() static const std::string Topic("topic/bla/bla"); static const DataBuf Data = {0, 1, 2, 3, 4}; static const std::uint16_t MsgId = 0x1234; - static const auto Qos = mqtt311::field::QosVal::ExactlyOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::ExactlyOnceDelivery; static const bool Retain = true; auto publishMsg = handler.prepareBrokerPublish(Topic, Data, MsgId, Qos, Retain, false); @@ -1943,7 +1943,7 @@ void SessionTest::test13() verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto regackMsg = handler.prepareClientRegack(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = handler.prepareClientRegack(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, regackMsg, "REGACK"); verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos), Retain, false); verifyTickReq(state, DefaultRetryPeriod * 1000); @@ -1968,7 +1968,7 @@ void SessionTest::test13() verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto pubcompMsg = handler.prepareClientPubcomp(pubMsgId + 1); + auto pubcompMsg = handler.prepareClientPubcomp(static_cast(pubMsgId + 1)); dataFromClient(*session, pubcompMsg, "PUBCOMP"); verifyTickReq(state, DefaultRetryPeriod * 1000 - 1000); verifyNoOtherEvent(state, handler); @@ -1990,7 +1990,7 @@ void SessionTest::test14() static const std::string Topic("topic/bla/bla"); static const DataBuf Data = {0, 1, 2, 3, 4}; static const std::uint16_t MsgId = 0x1234; - static const auto Qos = mqtt311::field::QosVal::AtMostOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::AtMostOnceDelivery; static const bool Retain = true; auto publishMsg = handler.prepareBrokerPublish(Topic, Data, MsgId, Qos, Retain, false); @@ -2002,7 +2002,7 @@ void SessionTest::test14() verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto regackMsg = handler.prepareClientRegack(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = handler.prepareClientRegack(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, regackMsg, "REGACK"); verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos), Retain, false); verifyNoOtherEvent(state, handler); @@ -2011,7 +2011,7 @@ void SessionTest::test14() verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos), Retain, false); verifyNoOtherEvent(state, handler); - static const auto Qos2 = mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto Qos2 = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; publishMsg = handler.prepareBrokerPublish(Topic, Data, MsgId, Qos2, Retain, false); dataFromBroker(*session, publishMsg, "PUBLISH"); verifySentToBroker_PubackMsg(state, handler, MsgId); @@ -2020,21 +2020,21 @@ void SessionTest::test14() verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto pubackMsg = handler.prepareClientPuback(topicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + auto pubackMsg = handler.prepareClientPuback(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromClient(*session, pubackMsg, "PUBACK"); std::tie(topicId, msgId) = verifySentToClient_RegisterMsg(state, handler, Topic); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - regackMsg = handler.prepareClientRegack(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + regackMsg = handler.prepareClientRegack(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, regackMsg, "REGACK"); msgId = verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos2), Retain, false); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - pubackMsg = handler.prepareClientPuback(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + pubackMsg = handler.prepareClientPuback(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, pubackMsg, "PUBACK"); verifyNoOtherEvent(state, handler); } @@ -2050,7 +2050,7 @@ void SessionTest::test15() static const std::string Topic("topic/bla/bla"); static const DataBuf Data = {0, 1, 2, 3, 4}; static const std::uint16_t MsgId = 0x1234; - static const auto Qos = mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; static const bool Retain = false; auto publishMsg = handler.prepareBrokerPublish(Topic, Data, MsgId, Qos, Retain, false); @@ -2064,42 +2064,42 @@ void SessionTest::test15() verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto regackMsg = handler.prepareClientRegack(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + auto regackMsg = handler.prepareClientRegack(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, regackMsg, "REGACK"); msgId = verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos), Retain, false); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto pubackMsg = handler.prepareClientPuback(topicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + auto pubackMsg = handler.prepareClientPuback(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromClient(*session, pubackMsg, "PUBACK"); std::tie(topicId, msgId) = verifySentToClient_RegisterMsg(state, handler, Topic); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - regackMsg = handler.prepareClientRegack(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + regackMsg = handler.prepareClientRegack(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, regackMsg, "REGACK"); msgId = verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos), Retain, false); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - pubackMsg = handler.prepareClientPuback(topicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + pubackMsg = handler.prepareClientPuback(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromClient(*session, pubackMsg, "PUBACK"); std::tie(topicId, msgId) = verifySentToClient_RegisterMsg(state, handler, Topic); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - regackMsg = handler.prepareClientRegack(topicId, msgId, mqttsn::field::ReturnCodeVal::Accepted); + regackMsg = handler.prepareClientRegack(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, regackMsg, "REGACK"); msgId = verifySentToClient_PublishMsg(state, handler, topicId, Data, TopicIdTypeVal::Normal, translateQos(Qos), Retain, false); verifyTickReq(state, DefaultRetryPeriod * 1000); verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - pubackMsg = handler.prepareClientPuback(topicId, msgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + pubackMsg = handler.prepareClientPuback(topicId, msgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); dataFromClient(*session, pubackMsg, "PUBACK"); verifyNoOtherEvent(state, handler); // discarding the publish is expected } @@ -2133,7 +2133,7 @@ void SessionTest::test16() static const DataBuf Data = {0, 1, 2, 3, 4 }; static const std::uint16_t MsgId = 1234; - static const auto Qos = mqtt311::field::QosVal::AtMostOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::AtMostOnceDelivery; static const bool Retain = false; state.m_elapsed.push_back(1000); @@ -2185,7 +2185,7 @@ void SessionTest::test16() state.m_elapsed.push_back(1000); auto connectMsg = handler.prepareClientConnect(DefaultClientId, DefaultKeepAlivePeriod, false, false); dataFromClient(*session, connectMsg, "CONNECT"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToClient_PublishMsg(state, handler, TopicId, Data, TopicIdTypeVal::PredefinedTopicId, translateQos(Qos), Retain, false); verifySentToClient_PublishMsg(state, handler, TopicId, Data, TopicIdTypeVal::PredefinedTopicId, translateQos(Qos), Retain, false); verifySentToClient_PublishMsg(state, handler, TopicId, Data, TopicIdTypeVal::PredefinedTopicId, translateQos(Qos), Retain, false); @@ -2210,7 +2210,7 @@ void SessionTest::test17() static const std::uint16_t MsgId = 0x1122; auto registerMsg = handler.prepareClientRegister(Topic, MsgId); dataFromClient(*session, registerMsg, "REGISTER"); - auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, mqttsn::field::ReturnCodeVal::Accepted); + auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); TS_ASSERT_LESS_THAN_EQUALS(DefaultMinTopicId, topicId); TS_ASSERT_LESS_THAN_EQUALS(topicId, DefaultMaxTopicId); @@ -2218,12 +2218,12 @@ void SessionTest::test17() static const DataBuf Data = {0, 1, 2, 3, 4, 5, 6}; - static const auto Qos = mqttsn::field::QosVal::AtLeastOnceDelivery; + static const auto Qos = cc_mqttsn::field::QosVal::AtLeastOnceDelivery; static const bool Retain = false; - auto publishMsg = handler.prepareClientPublish(Data, topicId + 1, MsgId, TopicIdTypeVal::Normal, Qos, Retain, false); + auto publishMsg = handler.prepareClientPublish(Data, static_cast(topicId + 1), MsgId, TopicIdTypeVal::Normal, Qos, Retain, false); dataFromClient(*session, publishMsg, "PUBLISH"); - verifySentToClient_PubackMsg(state, handler, topicId + 1, MsgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + verifySentToClient_PubackMsg(state, handler, static_cast(topicId + 1), MsgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); verifySentToBroker_PingreqMsg(state, handler); verifyNoOtherEvent(state, handler); @@ -2234,7 +2234,7 @@ void SessionTest::test17() auto pubackMsg = handler.prepareBrokerPuback(MsgId); dataFromBroker(*session, pubackMsg, "PUBACK"); - verifySentToClient_PubackMsg(state, handler, topicId, MsgId, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_PubackMsg(state, handler, topicId, MsgId, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); static const std::uint16_t SleepDuration = 30 * 60; @@ -2255,12 +2255,12 @@ void SessionTest::test17() state.m_elapsed.push_back(1000); auto connectMsg = handler.prepareClientConnect(DefaultClientId, DefaultKeepAlivePeriod, false, true); dataFromClient(*session, connectMsg, "CONNECT"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); verifyNoOtherEvent(state, handler); dataFromClient(*session, publishMsg, "PUBLISH"); - verifySentToClient_PubackMsg(state, handler, topicId, MsgId, mqttsn::field::ReturnCodeVal::InvalidTopicId); + verifySentToClient_PubackMsg(state, handler, topicId, MsgId, cc_mqttsn::field::ReturnCodeVal::InvalidTopicId); verifySentToBroker_PingreqMsg(state, handler); verifyNoOtherEvent(state, handler); @@ -2286,15 +2286,15 @@ void SessionTest::test18() static const std::uint16_t MsgId = 0x1122; auto registerMsg = handler.prepareClientRegister(Topic, MsgId); dataFromClient(*session, registerMsg, "REGISTER"); - auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, mqttsn::field::ReturnCodeVal::Accepted); + auto topicId = verifySentToClient_RegackMsg(state, handler, MsgId, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); TS_ASSERT_LESS_THAN_EQUALS(DefaultMinTopicId, topicId); TS_ASSERT_LESS_THAN_EQUALS(topicId, DefaultMaxTopicId); verifyNoOtherEvent(state, handler); static const DataBuf Data = {0, 1, 2, 3, 4, 5, 6}; - static const auto Qos1 = mqttsn::field::QosVal::AtLeastOnceDelivery; - static const auto Qos2 = mqttsn::field::QosVal::ExactlyOnceDelivery; + static const auto Qos1 = cc_mqttsn::field::QosVal::AtLeastOnceDelivery; + static const auto Qos2 = cc_mqttsn::field::QosVal::ExactlyOnceDelivery; static const bool Retain = false; auto publishMsg = handler.prepareClientPublish(Data, topicId, MsgId, TopicIdTypeVal::Normal, Qos1, Retain, false); @@ -2304,7 +2304,7 @@ void SessionTest::test18() auto pubackMsg = handler.prepareBrokerPuback(MsgId); dataFromBroker(*session, pubackMsg, "PUBACK"); - verifySentToClient_PubackMsg(state, handler, topicId, MsgId, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_PubackMsg(state, handler, topicId, MsgId, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); publishMsg = handler.prepareClientPublish(Data, PredefinedTopicId, MsgId, TopicIdTypeVal::PredefinedTopicId, Qos2, Retain, true); @@ -2344,9 +2344,9 @@ void SessionTest::test19() static const DataBuf Data2 = {10, 11, 12, 13, 14, 15, 16}; static const DataBuf Data3 = {20, 21, 22, 23, 24, 25, 26}; static const DataBuf Data4 = {30, 31, 32, 33, 34, 35, 36}; - static const auto Qos0 = mqtt311::field::QosVal::AtMostOnceDelivery; - static const auto Qos1 = mqtt311::field::QosVal::AtLeastOnceDelivery; - static const auto Qos2 = mqtt311::field::QosVal::ExactlyOnceDelivery; + static const auto Qos0 = cc_mqtt311::field::QosVal::AtMostOnceDelivery; + static const auto Qos1 = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto Qos2 = cc_mqtt311::field::QosVal::ExactlyOnceDelivery; static const bool Retain = true; static const bool Dup = false; @@ -2381,7 +2381,7 @@ void SessionTest::test19() verifyNoOtherEvent(state, handler); state.m_elapsed.push_back(1000); - auto ack1 = handler.prepareClientPuback(TopicId, msgId1, mqttsn::field::ReturnCodeVal::Accepted); + auto ack1 = handler.prepareClientPuback(TopicId, msgId1, cc_mqttsn::field::ReturnCodeVal::Accepted); dataFromClient(*session, ack1, "PUBACK"); verifySentToClient_PublishMsg(state, handler, TopicId, Data3, TopicIdTypeVal::PredefinedTopicId, translateQos(Qos0), Retain, Dup); verifyNoOtherEvent(state, handler); @@ -2475,7 +2475,7 @@ void SessionTest::test21() doConnect(*session, state, handler); - static const auto Qos = mqttsn::field::QosVal::ExactlyOnceDelivery; + static const auto Qos = cc_mqttsn::field::QosVal::ExactlyOnceDelivery; static const std::uint16_t SubMsgId1 = 0x1234; auto subMsg1 = handler.prepareClientSubscribe(PredefinedTopicId, SubMsgId1, Qos); dataFromClient(*session, subMsg1, "SUBSCRIBE"); @@ -2485,7 +2485,7 @@ void SessionTest::test21() using SubackReturnCodeVal = SubackMsg::Field_list::ValueType::value_type::ValueType; auto subackMsg1 = handler.prepareBrokerSuback(SubMsgId1, SubackReturnCodeVal::Qos2); dataFromBroker(*session, subackMsg1, "SUBACK"); - auto subackTopicId1 = verifySentToClient_SubackMsg(state, handler, SubMsgId1, Qos, mqttsn::field::ReturnCodeVal::Accepted); + auto subackTopicId1 = verifySentToClient_SubackMsg(state, handler, SubMsgId1, Qos, cc_mqttsn::field::ReturnCodeVal::Accepted); TS_ASSERT_EQUALS(subackTopicId1, PredefinedTopicId); verifyNoOtherEvent(state, handler); @@ -2499,7 +2499,7 @@ void SessionTest::test21() using SubackReturnCodeVal = SubackMsg::Field_list::ValueType::value_type::ValueType; auto subackMsg2 = handler.prepareBrokerSuback(SubMsgId2, SubackReturnCodeVal::Qos1); dataFromBroker(*session, subackMsg2, "SUBACK"); - auto subackTopicId2 = verifySentToClient_SubackMsg(state, handler, SubMsgId2, mqttsn::field::QosVal::AtLeastOnceDelivery, mqttsn::field::ReturnCodeVal::Accepted); + auto subackTopicId2 = verifySentToClient_SubackMsg(state, handler, SubMsgId2, cc_mqttsn::field::QosVal::AtLeastOnceDelivery, cc_mqttsn::field::ReturnCodeVal::Accepted); TS_ASSERT_DIFFERS(subackTopicId2, 0U); verifyNoOtherEvent(state, handler); @@ -2511,7 +2511,7 @@ void SessionTest::test21() auto subackMsg3 = handler.prepareBrokerSuback(SubMsgId3, SubackReturnCodeVal::Qos2); dataFromBroker(*session, subackMsg3, "SUBACK"); - auto subackTopicId3 = verifySentToClient_SubackMsg(state, handler, SubMsgId3, Qos, mqttsn::field::ReturnCodeVal::Accepted); + auto subackTopicId3 = verifySentToClient_SubackMsg(state, handler, SubMsgId3, Qos, cc_mqttsn::field::ReturnCodeVal::Accepted); TS_ASSERT_DIFFERS(subackTopicId3, 0U); verifyNoOtherEvent(state, handler); @@ -2524,7 +2524,7 @@ void SessionTest::test21() auto subackMsg4 = handler.prepareBrokerSuback(SubMsgId4, SubackReturnCodeVal::Qos2); dataFromBroker(*session, subackMsg4, "SUBACK"); - auto subackTopicId4 = verifySentToClient_SubackMsg(state, handler, SubMsgId4, Qos, mqttsn::field::ReturnCodeVal::Accepted); + auto subackTopicId4 = verifySentToClient_SubackMsg(state, handler, SubMsgId4, Qos, cc_mqttsn::field::ReturnCodeVal::Accepted); TS_ASSERT_EQUALS(subackTopicId4, shortTopicNameToId(ShortTopic)); verifyNoOtherEvent(state, handler); @@ -2538,7 +2538,7 @@ void SessionTest::test21() auto subackMsg5 = handler.prepareBrokerSuback(SubMsgId5, SubackReturnCodeVal::Qos2); dataFromBroker(*session, subackMsg5, "SUBACK"); - auto subackTopicId5 = verifySentToClient_SubackMsg(state, handler, SubMsgId5, Qos, mqttsn::field::ReturnCodeVal::Accepted); + auto subackTopicId5 = verifySentToClient_SubackMsg(state, handler, SubMsgId5, Qos, cc_mqttsn::field::ReturnCodeVal::Accepted); TS_ASSERT_EQUALS(subackTopicId5, 0U); verifyNoOtherEvent(state, handler); @@ -2595,7 +2595,7 @@ void SessionTest::test22() static const std::string WillTopic1("will/topic/1"); static const DataBuf WillData1 = {0, 1, 2}; - static const auto WillQos1 = mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto WillQos1 = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; static const bool WillRetain1 = true; WillInfo will1; will1.m_topic = WillTopic1; @@ -2621,7 +2621,7 @@ void SessionTest::test23() static const std::string WillTopic1("will/topic/1"); static const DataBuf WillData1 = {0, 1, 2}; - static const auto WillQos1 = mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto WillQos1 = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; static const bool WillRetain1 = true; WillInfo will1; will1.m_topic = WillTopic1; @@ -2634,7 +2634,7 @@ void SessionTest::test23() auto willTopicUpdMsg1 = handler.prepareClientWilltopicupd(WillTopic1, translateQos(WillQos1), WillRetain1); dataFromClient(*session, willTopicUpdMsg1, "WILLTOPICUPD"); - verifySentToClient_WilltopicrespMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_WilltopicrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); static const std::string WillTopic2("will/topic/2"); @@ -2665,10 +2665,10 @@ void SessionTest::test23() state.m_elapsed.push_back(1000); auto connackMsg1 = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted, true); dataFromBroker(*session, connackMsg1, "CONNACK"); - verifySentToClient_WilltopicrespMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_WilltopicrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); - static const auto WillQos2 = mqtt311::field::QosVal::ExactlyOnceDelivery; + static const auto WillQos2 = cc_mqtt311::field::QosVal::ExactlyOnceDelivery; auto willTopicUpdMsg3 = handler.prepareClientWilltopicupd(WillTopic2, translateQos(WillQos2), WillRetain1); dataFromClient(*session, willTopicUpdMsg3, "WILLTOPICUPD"); verifySentToBroker_DisconnectMsg(state, handler); @@ -2695,7 +2695,7 @@ void SessionTest::test23() state.m_elapsed.push_back(1000); auto connackMsg2 = handler.prepareBrokerConnack(ConnackResponseCodeVal::BadAuth, false); dataFromBroker(*session, connackMsg2, "CONNACK"); - verifySentToClient_WilltopicrespMsg(state, handler, mqttsn::field::ReturnCodeVal::NotSupported); + verifySentToClient_WilltopicrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::NotSupported); verifySentToClient_DisconnectMsg(state, handler); verifyTermReq(state); verifyNoOtherEvent(state, handler); @@ -2703,7 +2703,7 @@ void SessionTest::test23() session = allocSession(state, handler); dataFromClient(*session, willTopicUpdMsg1, "WILLTOPICUPD"); - verifySentToClient_WilltopicrespMsg(state, handler, mqttsn::field::ReturnCodeVal::NotSupported); + verifySentToClient_WilltopicrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::NotSupported); verifyNoOtherEvent(state, handler); doConnect(*session, state, handler, &will1); @@ -2730,7 +2730,7 @@ void SessionTest::test23() verifyNoOtherEvent(state, handler); doTick(state, *session, DefaultRetryPeriod * 1000); - verifySentToClient_WilltopicrespMsg(state, handler, mqttsn::field::ReturnCodeVal::NotSupported); + verifySentToClient_WilltopicrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::NotSupported); verifySentToClient_DisconnectMsg(state, handler); verifyTermReq(state); verifyNoOtherEvent(state, handler); @@ -2746,7 +2746,7 @@ void SessionTest::test24() static const std::string WillTopic("will/topic"); static const DataBuf WillData1 = {0, 1, 2}; - static const auto WillQos = mqtt311::field::QosVal::AtLeastOnceDelivery; + static const auto WillQos = cc_mqtt311::field::QosVal::AtLeastOnceDelivery; static const bool WillRetain = true; WillInfo will; @@ -2760,7 +2760,7 @@ void SessionTest::test24() auto willMsgUpdMsg1 = handler.prepareClientWillmsgupd(WillData1); dataFromClient(*session, willMsgUpdMsg1, "WILLMSGUPD"); - verifySentToClient_WillmsgrespMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_WillmsgrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifySentToBroker_PingreqMsg(state, handler); static const DataBuf WillData2 = {10, 11, 12}; @@ -2787,7 +2787,7 @@ void SessionTest::test24() state.m_elapsed.push_back(1000); auto connackMsg1 = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted, true); dataFromBroker(*session, connackMsg1, "CONNACK"); - verifySentToClient_WillmsgrespMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_WillmsgrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyNoOtherEvent(state, handler); dataFromClient(*session, willMsgUpdMsg1, "WILLMSGUPD"); @@ -2811,7 +2811,7 @@ void SessionTest::test24() state.m_elapsed.push_back(1000); auto connackMsg2 = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted, false); dataFromBroker(*session, connackMsg2, "CONNACK"); - verifySentToClient_WillmsgrespMsg(state, handler, mqttsn::field::ReturnCodeVal::NotSupported); + verifySentToClient_WillmsgrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::NotSupported); verifySentToClient_DisconnectMsg(state, handler); verifyTermReq(state); verifyNoOtherEvent(state, handler); @@ -2841,7 +2841,7 @@ void SessionTest::test24() state.m_elapsed.push_back(1000); auto connackMsg3 = handler.prepareBrokerConnack(ConnackResponseCodeVal::NotAuthorized, false); dataFromBroker(*session, connackMsg3, "CONNACK"); - verifySentToClient_WillmsgrespMsg(state, handler, mqttsn::field::ReturnCodeVal::NotSupported); + verifySentToClient_WillmsgrespMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::NotSupported); verifySentToClient_DisconnectMsg(state, handler); verifyTermReq(state); verifyNoOtherEvent(state, handler); @@ -2877,7 +2877,7 @@ void SessionTest::test25() static const DataBuf Data = {0, 1, 2, 3, 4 }; static const std::uint16_t MsgId = 1234; - static const auto Qos = mqtt311::field::QosVal::AtMostOnceDelivery; + static const auto Qos = cc_mqtt311::field::QosVal::AtMostOnceDelivery; static const bool Retain = false; state.m_elapsed.push_back(1000); @@ -2936,7 +2936,7 @@ void SessionTest::test26() static const DataBuf Data1 = {0, 1, 2, 5, 8}; static const std::uint16_t MsgId = 0x0001; - auto pub1 = handler.prepareClientPublish(Data1, TopicId, MsgId, TopicIdTypeVal::PredefinedTopicId, mqttsn::field::QosVal::NoGwPublish, false, false); + auto pub1 = handler.prepareClientPublish(Data1, TopicId, MsgId, TopicIdTypeVal::PredefinedTopicId, cc_mqttsn::field::QosVal::NoGwPublish, false, false); dataFromClient(*session, pub1, "PUBLISH"); verifySentToBroker_ConnectMsg(state, handler, ClientId, DefaultKeepAlivePeriod, true); verifyTickReq(state, DefaultRetryPeriod * 1000); @@ -2949,7 +2949,7 @@ void SessionTest::test26() static const DataBuf Data2 = {0, 1, 2, 5, 8, 10, 16}; state.m_elapsed.push_back(1000); - auto pub2 = handler.prepareClientPublish(Data2, TopicId, MsgId + 1, TopicIdTypeVal::PredefinedTopicId, mqttsn::field::QosVal::NoGwPublish, false, false); + auto pub2 = handler.prepareClientPublish(Data2, TopicId, static_cast(MsgId + 1), TopicIdTypeVal::PredefinedTopicId, cc_mqttsn::field::QosVal::NoGwPublish, false, false); dataFromClient(*session, pub2, "PUBLISH"); verifyTickReq(state, DefaultRetryPeriod * 1000 - 1000); verifyNoOtherEvent(state, handler); @@ -2958,13 +2958,13 @@ void SessionTest::test26() state.m_elapsed.push_back(1000); auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted, false); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToBroker_PublishMsg(state, handler, Topic, Data1, 0, mqtt311::field::QosVal::AtMostOnceDelivery, false, false); - verifySentToBroker_PublishMsg(state, handler, Topic, Data2, 0, mqtt311::field::QosVal::AtMostOnceDelivery, false, false); + verifySentToBroker_PublishMsg(state, handler, Topic, Data1, 0, cc_mqtt311::field::QosVal::AtMostOnceDelivery, false, false); + verifySentToBroker_PublishMsg(state, handler, Topic, Data2, 0, cc_mqtt311::field::QosVal::AtMostOnceDelivery, false, false); verifyConnectedClient(state, ClientId); verifyNoOtherEvent(state, handler); dataFromClient(*session, pub1, "PUBLISH"); - verifySentToBroker_PublishMsg(state, handler, Topic, Data1, 0, mqtt311::field::QosVal::AtMostOnceDelivery, false, false); + verifySentToBroker_PublishMsg(state, handler, Topic, Data1, 0, cc_mqtt311::field::QosVal::AtMostOnceDelivery, false, false); verifyNoOtherEvent(state, handler); } @@ -2989,7 +2989,7 @@ void SessionTest::test27() using ConnackResponseCodeVal = ConnackMsg::Field_returnCode::ValueType; auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyConnectedClient(state, ClientId); verifyNoOtherEvent(state, handler); } @@ -3007,7 +3007,7 @@ void SessionTest::test28() verifyNoOtherEvent(state, handler); doTick(state, *session, DefaultRetryPeriod * 1000); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Congestion); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Congestion); verifyTermReq(state); verifyNoOtherEvent(state, handler); @@ -3024,7 +3024,7 @@ void SessionTest::test28() using ConnackResponseCodeVal = ConnackMsg::Field_returnCode::ValueType; auto connackMsg = handler.prepareBrokerConnack(ConnackResponseCodeVal::Accepted); dataFromBroker(*session, connackMsg, "CONNACK"); - verifySentToClient_ConnackMsg(state, handler, mqttsn::field::ReturnCodeVal::Accepted); + verifySentToClient_ConnackMsg(state, handler, cc_mqttsn::field::ReturnCodeVal::Accepted); verifyConnectedClient(state, DefaultClientId); verifyNoOtherEvent(state, handler); } diff --git a/gateway/test/TestMsgHandler.cpp b/gateway/test/TestMsgHandler.cpp index 09b2bdce..127778c8 100644 --- a/gateway/test/TestMsgHandler.cpp +++ b/gateway/test/TestMsgHandler.cpp @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -541,7 +541,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientConnect( TestMsgHandler::DataBuf TestMsgHandler::prepareClientWilltopic( const std::string& topic, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain) { WilltopicMsg_SN msg; @@ -584,7 +584,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientRegister( TestMsgHandler::DataBuf TestMsgHandler::prepareClientRegack( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { RegackMsg_SN msg; msg.field_topicId().value() = topicId; @@ -598,7 +598,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientPublish( std::uint16_t topicId, std::uint16_t msgId, TopicIdTypeVal topicIdType, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain, bool dup) { @@ -616,7 +616,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientPublish( TestMsgHandler::DataBuf TestMsgHandler::prepareClientPuback( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal rc) + cc_mqttsn::field::ReturnCodeVal rc) { PubackMsg_SN msg; msg.field_topicId().value() = topicId; @@ -662,7 +662,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientPingresp() TestMsgHandler::DataBuf TestMsgHandler::prepareClientSubscribe( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::QosVal qos) + cc_mqttsn::field::QosVal qos) { SubscribeMsg_SN msg; @@ -678,7 +678,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientSubscribe( TestMsgHandler::DataBuf TestMsgHandler::prepareClientSubscribe( const std::string& topic, std::uint16_t msgId, - mqttsn::field::QosVal qos) + cc_mqttsn::field::QosVal qos) { SubscribeMsg_SN msg; msg.field_flags().field_qos().value() = qos; @@ -743,7 +743,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareClientUnsubscribe( TestMsgHandler::DataBuf TestMsgHandler::prepareClientWilltopicupd( const std::string& topic, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain) { WilltopicupdMsg_SN msg; @@ -790,7 +790,7 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareBrokerPublish( const std::string& topic, const DataBuf& msgData, std::uint16_t packetId, - mqtt311::field::QosVal qos, + cc_mqtt311::field::QosVal qos, bool retain, bool duplicate) { @@ -805,9 +805,9 @@ TestMsgHandler::DataBuf TestMsgHandler::prepareBrokerPublish( flags.field_dup().setBitValue_bit(duplicate); msg.doRefresh(); - assert((qos == mqtt311::field::QosVal::AtMostOnceDelivery) || + assert((qos == cc_mqtt311::field::QosVal::AtMostOnceDelivery) || (msg.field_packetId().doesExist())); - assert((mqtt311::field::QosVal::AtMostOnceDelivery < qos) || + assert((cc_mqtt311::field::QosVal::AtMostOnceDelivery < qos) || (msg.field_packetId().isMissing())); return prepareInput(msg); } diff --git a/gateway/test/TestMsgHandler.h b/gateway/test/TestMsgHandler.h index 5e756145..72604914 100644 --- a/gateway/test/TestMsgHandler.h +++ b/gateway/test/TestMsgHandler.h @@ -1,5 +1,5 @@ // -// Copyright 2016 - 2020 (C). Alex Robenko. All rights reserved. +// Copyright 2016 - 2023 (C). Alex Robenko. All rights reserved. // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,14 +10,14 @@ #include #include "comms/comms.h" -#include "mqttsn/Message.h" -#include "mqttsn/frame/Frame.h" -#include "mqtt311/Message.h" -#include "mqtt311/frame/Frame.h" +#include "cc_mqttsn/Message.h" +#include "cc_mqttsn/frame/Frame.h" +#include "cc_mqtt311/Message.h" +#include "cc_mqtt311/frame/Frame.h" class TestMsgHandler; -typedef mqttsn::Message< +typedef cc_mqttsn::Message< comms::option::IdInfoInterface, comms::option::ReadIterator, comms::option::WriteIterator, @@ -26,7 +26,7 @@ typedef mqttsn::Message< comms::option::RefreshInterface > TestMqttsnMessage; -typedef mqtt311::Message< +typedef cc_mqtt311::Message< comms::option::IdInfoInterface, comms::option::ReadIterator, comms::option::WriteIterator, @@ -35,59 +35,59 @@ typedef mqtt311::Message< comms::option::RefreshInterface > TestMqttMessage; -typedef mqttsn::message::Advertise AdvertiseMsg_SN; -typedef mqttsn::message::Searchgw SearchgwMsg_SN; -typedef mqttsn::message::Gwinfo GwinfoMsg_SN; -typedef mqttsn::message::Connect ConnectMsg_SN; -typedef mqttsn::message::Connack ConnackMsg_SN; -typedef mqttsn::message::Willtopicreq WilltopicreqMsg_SN; -typedef mqttsn::message::Willtopic WilltopicMsg_SN; -typedef mqttsn::message::Willmsgreq WillmsgreqMsg_SN; -typedef mqttsn::message::Willmsg WillmsgMsg_SN; -typedef mqttsn::message::Register RegisterMsg_SN; -typedef mqttsn::message::Regack RegackMsg_SN; -typedef mqttsn::message::Publish PublishMsg_SN; -typedef mqttsn::message::Puback PubackMsg_SN; -typedef mqttsn::message::Pubrec PubrecMsg_SN; -typedef mqttsn::message::Pubrel PubrelMsg_SN; -typedef mqttsn::message::Pubcomp PubcompMsg_SN; -typedef mqttsn::message::Subscribe SubscribeMsg_SN; -typedef mqttsn::message::Suback SubackMsg_SN; -typedef mqttsn::message::Unsubscribe UnsubscribeMsg_SN; -typedef mqttsn::message::Unsuback UnsubackMsg_SN; -typedef mqttsn::message::Pingreq PingreqMsg_SN; -typedef mqttsn::message::Pingresp PingrespMsg_SN; -typedef mqttsn::message::Disconnect DisconnectMsg_SN; -typedef mqttsn::message::Willtopicupd WilltopicupdMsg_SN; -typedef mqttsn::message::Willtopicresp WilltopicrespMsg_SN; -typedef mqttsn::message::Willmsgupd WillmsgupdMsg_SN; -typedef mqttsn::message::Willmsgresp WillmsgrespMsg_SN; -typedef mqttsn::frame::Frame TestMqttsnProtStack; - -typedef mqtt311::message::Connect ConnectMsg; -typedef mqtt311::message::Connack ConnackMsg; -typedef mqtt311::message::Publish PublishMsg; -typedef mqtt311::message::Puback PubackMsg; -typedef mqtt311::message::Pubrec PubrecMsg; -typedef mqtt311::message::Pubrel PubrelMsg; -typedef mqtt311::message::Pubcomp PubcompMsg; -typedef mqtt311::message::Subscribe SubscribeMsg; -typedef mqtt311::message::Suback SubackMsg; -typedef mqtt311::message::Unsubscribe UnsubscribeMsg; -typedef mqtt311::message::Unsuback UnsubackMsg; -typedef mqtt311::message::Pingreq PingreqMsg; -typedef mqtt311::message::Pingresp PingrespMsg; -typedef mqtt311::message::Disconnect DisconnectMsg; -typedef mqtt311::frame::Frame TestMqttProtStack; +typedef cc_mqttsn::message::Advertise AdvertiseMsg_SN; +typedef cc_mqttsn::message::Searchgw SearchgwMsg_SN; +typedef cc_mqttsn::message::Gwinfo GwinfoMsg_SN; +typedef cc_mqttsn::message::Connect ConnectMsg_SN; +typedef cc_mqttsn::message::Connack ConnackMsg_SN; +typedef cc_mqttsn::message::Willtopicreq WilltopicreqMsg_SN; +typedef cc_mqttsn::message::Willtopic WilltopicMsg_SN; +typedef cc_mqttsn::message::Willmsgreq WillmsgreqMsg_SN; +typedef cc_mqttsn::message::Willmsg WillmsgMsg_SN; +typedef cc_mqttsn::message::Register RegisterMsg_SN; +typedef cc_mqttsn::message::Regack RegackMsg_SN; +typedef cc_mqttsn::message::Publish PublishMsg_SN; +typedef cc_mqttsn::message::Puback PubackMsg_SN; +typedef cc_mqttsn::message::Pubrec PubrecMsg_SN; +typedef cc_mqttsn::message::Pubrel PubrelMsg_SN; +typedef cc_mqttsn::message::Pubcomp PubcompMsg_SN; +typedef cc_mqttsn::message::Subscribe SubscribeMsg_SN; +typedef cc_mqttsn::message::Suback SubackMsg_SN; +typedef cc_mqttsn::message::Unsubscribe UnsubscribeMsg_SN; +typedef cc_mqttsn::message::Unsuback UnsubackMsg_SN; +typedef cc_mqttsn::message::Pingreq PingreqMsg_SN; +typedef cc_mqttsn::message::Pingresp PingrespMsg_SN; +typedef cc_mqttsn::message::Disconnect DisconnectMsg_SN; +typedef cc_mqttsn::message::Willtopicupd WilltopicupdMsg_SN; +typedef cc_mqttsn::message::Willtopicresp WilltopicrespMsg_SN; +typedef cc_mqttsn::message::Willmsgupd WillmsgupdMsg_SN; +typedef cc_mqttsn::message::Willmsgresp WillmsgrespMsg_SN; +typedef cc_mqttsn::frame::Frame TestMqttsnProtStack; + +typedef cc_mqtt311::message::Connect ConnectMsg; +typedef cc_mqtt311::message::Connack ConnackMsg; +typedef cc_mqtt311::message::Publish PublishMsg; +typedef cc_mqtt311::message::Puback PubackMsg; +typedef cc_mqtt311::message::Pubrec PubrecMsg; +typedef cc_mqtt311::message::Pubrel PubrelMsg; +typedef cc_mqtt311::message::Pubcomp PubcompMsg; +typedef cc_mqtt311::message::Subscribe SubscribeMsg; +typedef cc_mqtt311::message::Suback SubackMsg; +typedef cc_mqtt311::message::Unsubscribe UnsubscribeMsg; +typedef cc_mqtt311::message::Unsuback UnsubackMsg; +typedef cc_mqtt311::message::Pingreq PingreqMsg; +typedef cc_mqtt311::message::Pingresp PingrespMsg; +typedef cc_mqtt311::message::Disconnect DisconnectMsg; +typedef cc_mqtt311::frame::Frame TestMqttProtStack; using TestMqttsnMsgHandler = comms::GenericHandler< TestMqttsnMessage, - mqttsn::input::AllMessages + cc_mqttsn::input::AllMessages >; using TestMqttMsgHandler = comms::GenericHandler< TestMqttMessage, - mqtt311::input::AllMessages + cc_mqtt311::input::AllMessages >; @@ -225,7 +225,7 @@ class TestMsgHandler : public TestMqttsnMsgHandler, public TestMqttMsgHandler virtual void handle(UnsubscribeMsg& msg) override; virtual void handle(TestMqttMessage& msg) override; - using TopicIdTypeVal = mqttsn::field::FlagsMembersCommon::TopicIdTypeVal; + using TopicIdTypeVal = cc_mqttsn::field::TopicIdTypeVal; void processDataForClient(const DataBuf& data); void processDataForBroker(const DataBuf& data); @@ -237,7 +237,7 @@ class TestMsgHandler : public TestMqttsnMsgHandler, public TestMqttMsgHandler DataBuf prepareClientConnect(const std::string& id, std::uint16_t keepAlive, bool hasWill, bool clean); DataBuf prepareClientWilltopic( const std::string& topic, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain); DataBuf prepareClientWillmsg(const DataBuf& data); DataBuf prepareClientDisconnect(std::uint16_t duration = 0); @@ -245,19 +245,19 @@ class TestMsgHandler : public TestMqttsnMsgHandler, public TestMqttMsgHandler DataBuf prepareClientRegack( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal rc); + cc_mqttsn::field::ReturnCodeVal rc); DataBuf prepareClientPublish( const DataBuf& data, std::uint16_t topicId, std::uint16_t msgId, TopicIdTypeVal topicIdType, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain, bool dup); DataBuf prepareClientPuback( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::ReturnCodeVal rc); + cc_mqttsn::field::ReturnCodeVal rc); DataBuf prepareClientPubrec(std::uint16_t msgId); DataBuf prepareClientPubrel(std::uint16_t msgId); DataBuf prepareClientPubcomp(std::uint16_t msgId); @@ -266,11 +266,11 @@ class TestMsgHandler : public TestMqttsnMsgHandler, public TestMqttMsgHandler DataBuf prepareClientSubscribe( std::uint16_t topicId, std::uint16_t msgId, - mqttsn::field::QosVal qos); + cc_mqttsn::field::QosVal qos); DataBuf prepareClientSubscribe( const std::string& topic, std::uint16_t msgId, - mqttsn::field::QosVal qos); + cc_mqttsn::field::QosVal qos); DataBuf prepareClientUnsubscribe( std::uint16_t topicId, std::uint16_t msgId); @@ -279,7 +279,7 @@ class TestMsgHandler : public TestMqttsnMsgHandler, public TestMqttMsgHandler std::uint16_t msgId); DataBuf prepareClientWilltopicupd( const std::string& topic, - mqttsn::field::QosVal qos, + cc_mqttsn::field::QosVal qos, bool retain); DataBuf prepareClientWillmsgupd(const DataBuf& data); @@ -292,7 +292,7 @@ class TestMsgHandler : public TestMqttsnMsgHandler, public TestMqttMsgHandler const std::string& topic, const DataBuf& msgData, std::uint16_t packetId, - mqtt311::field::QosVal qos, + cc_mqtt311::field::QosVal qos, bool retain, bool duplicate); DataBuf prepareBrokerPuback(std::uint16_t packetId); diff --git a/gateway/version.h b/gateway/version.h deleted file mode 100644 index 8f46b5bb..00000000 --- a/gateway/version.h +++ /dev/null @@ -1,69 +0,0 @@ -// -// Copyright 2018 - 2020 (C). Alex Robenko. All rights reserved. -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/// @file -/// Contains version information of the library - -#pragma once - -/// @brief Major verion of the library -#define COMMS_MAJOR_VERSION 3U - -/// @brief Minor verion of the library -#define COMMS_MINOR_VERSION 0U - -/// @brief Patch level of the library -#define COMMS_PATCH_VERSION 1U - -/// @brief Macro to create numeric version as single unsigned number -#define COMMS_MAKE_VERSION(major_, minor_, patch_) \ - ((static_cast(major_) << 24) | \ - (static_cast(minor_) << 8) | \ - (static_cast(patch_))) - -/// @brief Version of the COMMS library as single numeric value -#define COMMS_VERSION COMMS_MAKE_VERSION(COMMS_MAJOR_VERSION, COMMS_MINOR_VERSION, COMMS_PATCH_VERSION) - -namespace comms -{ - -/// @brief Major verion of the library -inline -constexpr unsigned versionMajor() -{ - return COMMS_MAJOR_VERSION; -} - -/// @brief Minor verion of the library -inline -constexpr unsigned versionMinor() -{ - return COMMS_MINOR_VERSION; -} - -/// @brief Patch level of the library -inline -constexpr unsigned versionPatch() -{ - return COMMS_PATCH_VERSION; -} - -/// @brief Create version of the library as single unsigned numeric value. -inline -constexpr unsigned versionCreate(unsigned major, unsigned minor, unsigned patch) -{ - return COMMS_MAKE_VERSION(major, minor, patch); -} - -/// @brief Version of the COMMS library as single numeric value -inline -constexpr unsigned version() -{ - return COMMS_VERSION; -} - -} // namespace comms diff --git a/script/appveyor_install.bat b/script/appveyor_install.bat index fc15b742..78f97019 100644 --- a/script/appveyor_install.bat +++ b/script/appveyor_install.bat @@ -23,8 +23,8 @@ IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( ) ELSE IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" ( set TOOLCHAIN=msvc16 - set QT_SUBDIR=msvc2017 - set QT_VER=5.14 + set QT_SUBDIR=msvc2019 + set QT_VER=5.15.2 IF "%PLATFORM%"=="x86" ( echo Performing x86 build in VS2019 call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" @@ -32,6 +32,17 @@ IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( echo Performing amd64 build in VS2019 call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" ) +) ELSE IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" ( + set TOOLCHAIN=msvc17 + set QT_SUBDIR=msvc2019 + set QT_VER=5.15.2 + IF "%PLATFORM%"=="x86" ( + echo Performing x86 build in VS2022 + call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat" + ) ELSE ( + echo Performing amd64 build in VS2022 + call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" + ) ) ELSE ( echo Toolchain %TOOLCHAIN% is not supported exit -1 diff --git a/script/env_dev.sh b/script/env_dev.sh new file mode 100755 index 00000000..2383c760 --- /dev/null +++ b/script/env_dev.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ -z "${CC}" -o -z "${CXX}" ]; then + echo "ERROR: Compilers are not provided" + exit 1 +fi + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT_DIR=$( dirname ${SCRIPT_DIR} ) +BUILD_DIR="${ROOT_DIR}/build.${CC}" +mkdir -p ${BUILD_DIR} +cd ${BUILD_DIR} + +cmake .. -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug "$@" diff --git a/script/env_dev_clang.sh b/script/env_dev_clang.sh new file mode 100755 index 00000000..c9e59f97 --- /dev/null +++ b/script/env_dev_clang.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +export CC=clang +export CXX=clang++ + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source ${SCRIPT_DIR}/env_dev.sh "$@" diff --git a/script/full_debug_build.sh b/script/full_debug_build.sh new file mode 100755 index 00000000..a0cb20b9 --- /dev/null +++ b/script/full_debug_build.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ -z "${CC}" -o -z "${CXX}" ]; then + echo "ERROR: Compilers are not provided" + exit 1 +fi + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT_DIR=$( dirname ${SCRIPT_DIR} ) +export BUILD_DIR="${ROOT_DIR}/build.full.${CC}" +export COMMON_INSTALL_DIR=${BUILD_DIR}/install +export COMMON_BUILD_TYPE=Debug +export EXTERNALS_DIR=${ROOT_DIR}/externals +mkdir -p ${BUILD_DIR} + +${SCRIPT_DIR}/prepare_externals.sh + +cd ${BUILD_DIR} +cmake .. -DCMAKE_INSTALL_PREFIX=${COMMON_INSTALL_DIR} -DCMAKE_BUILD_TYPE=Debug \ + -DCC_MQTTSN_WITH_SANITIZERS=ON -DCC_MQTTSN_BUILD_UNIT_TESTS=ON "$@" + +procs=$(nproc) +if [ -n "${procs}" ]; then + procs_param="--parallel ${procs}" +fi + +cmake --build ${BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param} diff --git a/script/full_debug_build_clang.sh b/script/full_debug_build_clang.sh new file mode 100755 index 00000000..fc808781 --- /dev/null +++ b/script/full_debug_build_clang.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export CC=clang +export CXX=clang++ + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +${SCRIPT_DIR}/full_debug_build.sh "$@" + diff --git a/script/full_debug_build_gcc.sh b/script/full_debug_build_gcc.sh new file mode 100755 index 00000000..10191349 --- /dev/null +++ b/script/full_debug_build_gcc.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export CC=gcc +export CXX=g++ + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +${SCRIPT_DIR}/full_debug_build.sh "$@" + diff --git a/script/prepare_externals.bat b/script/prepare_externals.bat new file mode 100755 index 00000000..9bdd5a06 --- /dev/null +++ b/script/prepare_externals.bat @@ -0,0 +1,132 @@ +rem Input +rem BUILD_DIR - Main build directory +rem GENERATOR - CMake generator +rem EXTERNALS_DIR - (Optional) Directory where externals need to be located +rem COMMS_REPO - (Optional) Repository of the COMMS library +rem COMMS_TAG - (Optional) Tag of the COMMS library +rem CC_MQTTSN_REPO - (Optional) Repository of the cc.mqttsn.generated +rem CC_MQTTSN_TAG - (Optional) Tag of the cc.mqttsn.generated +rem CC_MQTT311_REPO - (Optional) Repository of the cc.mqtt311.generated +rem CC_MQTT311_TAG - (Optional) Tag of the cc.mqtt311.generated +rem COMMON_INSTALL_DIR - (Optional) Common directory to perform installations +rem COMMON_BUILD_TYPE - (Optional) CMake build type +rem COMMON_CXX_STANDARD - (Optional) CMake C++ standard + +rem ----------------------------------------------------- + +if [%BUILD_DIR%] == [] echo "BUILD_DIR hasn't been specified" & exit /b 1 + +if [%GENERATOR%] == [] set GENERATOR="NMake Makefiles" + +if [%EXTERNALS_DIR%] == [] set EXTERNALS_DIR=%BUILD_DIR%/externals + +if [%COMMS_REPO%] == [] set COMMS_REPO="https://github.com/commschamp/comms.git" + +if [%COMMS_TAG%] == [] set COMMS_TAG="master" + +if [%CC_MQTTSN_REPO%] == [] set CC_MQTTSN_REPO="https://github.com/commschamp/cc.mqttsn.generated.git" + +if [%CC_MQTTSN_TAG%] == [] set CC_MQTTSN_TAG="master" + +if [%CC_MQTT311_REPO%] == [] set CC_MQTT311_REPO="https://github.com/commschamp/cc.mqtt311.generated.git" + +if [%CC_MQTT311_TAG%] == [] set CC_MQTT311_TAG="master" + +if [%COMMON_BUILD_TYPE%] == [] set COMMON_BUILD_TYPE=Debug + +set COMMS_SRC_DIR=%EXTERNALS_DIR%/comms +set COMMS_BUILD_DIR=%BUILD_DIR%/externals/comms/build +set COMMS_INSTALL_DIR=%COMMS_BUILD_DIR%/install +if NOT [%COMMON_INSTALL_DIR%] == [] set COMMS_INSTALL_DIR=%COMMON_INSTALL_DIR% + +set CC_MQTTSN_SRC_DIR=%EXTERNALS_DIR%/cc.mqttsn.generated +set CC_MQTTSN_BUILD_DIR=%BUILD_DIR%/externals/cc.mqttsn.generated/build +set CC_MQTTSN_INSTALL_DIR=%COMMSDSL_BUILD_DIR%/install +if NOT [%COMMON_INSTALL_DIR%] == [] set CC_MQTTSN_INSTALL_DIR=%COMMON_INSTALL_DIR% + +set CC_MQTT311_SRC_DIR=%EXTERNALS_DIR%/cc.mqtt311.generated +set CC_MQTT311_BUILD_DIR=%BUILD_DIR%/externals/cc.mqtt311.generated/build +set CC_MQTT311_INSTALL_DIR=%COMMSDSL_BUILD_DIR%/install +if NOT [%COMMON_INSTALL_DIR%] == [] set CC_MQTT311_INSTALL_DIR=%COMMON_INSTALL_DIR% + +rem ---------------------------------------------------- + +mkdir "%EXTERNALS_DIR%" +if exist %COMMS_SRC_DIR%/.git goto comms_update +echo "Cloning COMMS library..." +git clone -b %COMMS_TAG% %COMMS_REPO% %COMMS_SRC_DIR% +if %errorlevel% neq 0 exit /b %errorlevel% +goto comms_build + +:comms_update +echo "Updating COMMS library..." +cd "%COMMS_SRC_DIR%" +git fetch --all +git checkout . +git checkout %COMMS_TAG% +git pull --all +if %errorlevel% neq 0 exit /b %errorlevel% + +:comms_build +echo "Building COMMS library..." +mkdir "%COMMS_BUILD_DIR%" +cd %COMMS_BUILD_DIR% +cmake -G %GENERATOR% -S %COMMS_SRC_DIR% -B %COMMS_BUILD_DIR% ^ + -DCMAKE_INSTALL_PREFIX=%COMMS_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% ^ + -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% +if %errorlevel% neq 0 exit /b %errorlevel% +cmake --build %COMMS_BUILD_DIR% --config %COMMON_BUILD_TYPE% --target install +if %errorlevel% neq 0 exit /b %errorlevel% + +if exist %CC_MQTTSN_SRC_DIR%/.git goto mqttsn_update +echo "Cloning cc.mqttsn.generated library..." +git clone -b %CC_MQTTSN_TAG% %CC_MQTTSN_REPO% %CC_MQTTSN_SRC_DIR% +if %errorlevel% neq 0 exit /b %errorlevel% +goto mqttsn_build + +:mqttsn_update +echo "Updating cc.mqttsn.generated library..." +cd "%CC_MQTTSN_SRC_DIR%" +git fetch --all +git checkout . +git checkout %CC_MQTTSN_TAG% +git pull --all +if %errorlevel% neq 0 exit /b %errorlevel% + +:mqttsn_build +echo "Building cc.mqttsn.generated library..." +mkdir "%CC_MQTTSN_BUILD_DIR%" +cd %CC_MQTTSN_BUILD_DIR% +cmake -G %GENERATOR% -S %CC_MQTTSN_SRC_DIR% -B %CC_MQTTSN_BUILD_DIR% ^ + -DCMAKE_INSTALL_PREFIX=%CC_MQTTSN_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% ^ + -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% -DOPT_REQUIRE_COMMS_LIB=OFF +if %errorlevel% neq 0 exit /b %errorlevel% +cmake --build %CC_MQTTSN_BUILD_DIR% --config %COMMON_BUILD_TYPE% --target install +if %errorlevel% neq 0 exit /b %errorlevel% + +if exist %CC_MQTT311_SRC_DIR%/.git goto mqtt311_update +echo "Cloning cc.mqtt311.generated library..." +git clone -b %CC_MQTT311_TAG% %CC_MQTT311_REPO% %CC_MQTT311_SRC_DIR% +if %errorlevel% neq 0 exit /b %errorlevel% +goto mqtt311_build + +:mqtt311_update +echo "Updating cc.mqtt311.generated library..." +cd "%CC_MQTT311_SRC_DIR%" +git fetch --all +git checkout . +git checkout %CC_MQTT311_TAG% +git pull --all +if %errorlevel% neq 0 exit /b %errorlevel% + +:mqtt311_build +echo "Building cc.mqtt311.generated library..." +mkdir "%CC_MQTT311_BUILD_DIR%" +cd %CC_MQTT311_BUILD_DIR% +cmake -G %GENERATOR% -S %CC_MQTT311_SRC_DIR% -B %CC_MQTT311_BUILD_DIR% ^ + -DCMAKE_INSTALL_PREFIX=%CC_MQTT311_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% ^ + -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% -DOPT_REQUIRE_COMMS_LIB=OFF +if %errorlevel% neq 0 exit /b %errorlevel% +cmake --build %CC_MQTT311_BUILD_DIR% --config %COMMON_BUILD_TYPE% --target install +if %errorlevel% neq 0 exit /b %errorlevel% + diff --git a/script/prepare_externals.sh b/script/prepare_externals.sh new file mode 100755 index 00000000..ef71bf8a --- /dev/null +++ b/script/prepare_externals.sh @@ -0,0 +1,157 @@ +#!/bin/bash + +# Input +# BUILD_DIR - Main build directory +# CC - Main C compiler +# CXX - Main C++ compiler +# EXTERNALS_DIR - (Optional) Directory where externals need to be located +# COMMS_REPO - (Optional) Repository of the COMMS library +# COMMS_TAG - (Optional) Tag of the COMMS library +# CC_MQTTSN_REPO - (Optional) Repository of the cc.mqttsn.generated +# CC_MQTTSN_TAG - (Optional) Tag of the cc.mqttsn.generated +# CC_MQTT311_REPO - (Optional) Repository of the cc.mqtt311.generated +# CC_MQTT311_TAG - (Optional) Tag of the cc.mqtt311.generated +# COMMON_INSTALL_DIR - (Optional) Common directory to perform installations +# COMMON_BUILD_TYPE - (Optional) CMake build type +# COMMON_CXX_STANDARD - (Optional) CMake C++ standard + +##################################### + +if [ -z "${BUILD_DIR}" ]; then + echo "BUILD_DIR hasn't been specified" + exit 1 +fi + +if [ -z "${EXTERNALS_DIR}" ]; then + EXTERNALS_DIR=${BUILD_DIR}/externals +fi + +if [ -z "${COMMS_REPO}" ]; then + COMMS_REPO=https://github.com/commschamp/comms.git +fi + +if [ -z "${COMMS_TAG}" ]; then + COMMS_TAG=master +fi + +if [ -z "${CC_MQTTSN_REPO}" ]; then + CC_MQTTSN_REPO=https://github.com/commschamp/cc.mqttsn.generated.git +fi + +if [ -z "${CC_MQTTSN_TAG}" ]; then + CC_MQTTSN_TAG=master +fi + +if [ -z "${CC_MQTT311_REPO}" ]; then + CC_MQTT311_REPO=https://github.com/commschamp/cc.mqtt311.generated.git +fi + +if [ -z "${CC_MQTT311_TAG}" ]; then + CC_MQTT311_TAG=master +fi + +if [ -z "${COMMON_BUILD_TYPE}" ]; then + COMMON_BUILD_TYPE=Debug +fi + +COMMS_SRC_DIR=${EXTERNALS_DIR}/comms +COMMS_BUILD_DIR=${BUILD_DIR}/externals/comms/build +COMMS_INSTALL_DIR=${COMMS_BUILD_DIR}/install +if [ -n "${COMMON_INSTALL_DIR}" ]; then + COMMS_INSTALL_DIR=${COMMON_INSTALL_DIR} +fi + +CC_MQTTSN_SRC_DIR=${EXTERNALS_DIR}/cc.mqttsn.generated +CC_MQTTSN_BUILD_DIR=${BUILD_DIR}/externals/cc.mqttsn.generated/build +CC_MQTTSN_INSTALL_DIR=${CC_MQTTSN_BUILD_DIR}/install +if [ -n "${COMMON_INSTALL_DIR}" ]; then + CC_MQTTSN_INSTALL_DIR=${COMMON_INSTALL_DIR} +fi + +CC_MQTT311_SRC_DIR=${EXTERNALS_DIR}/cc.mqtt311.generated +CC_MQTT311_BUILD_DIR=${BUILD_DIR}/externals/cc.mqtt311.generated/build +CC_MQTT311_INSTALL_DIR=${CC_MQTT311_BUILD_DIR}/install +if [ -n "${COMMON_INSTALL_DIR}" ]; then + CC_MQTT311_INSTALL_DIR=${COMMON_INSTALL_DIR} +fi + +procs=$(nproc) +if [ -n "${procs}" ]; then + procs_param="-- -j${procs}" +fi + +##################################### + +function build_comms() { + if [ -e ${COMMS_SRC_DIR}/.git ]; then + echo "Updating COMMS library..." + cd ${COMMS_SRC_DIR} + git fetch --all + git checkout . + git checkout ${COMMS_TAG} + git pull --all + else + echo "Cloning COMMS library..." + mkdir -p ${EXTERNALS_DIR} + git clone -b ${COMMS_TAG} ${COMMS_REPO} ${COMMS_SRC_DIR} + fi + + echo "Building COMMS library..." + mkdir -p ${COMMS_BUILD_DIR} + cmake -S ${COMMS_SRC_DIR} -B ${COMMS_BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${COMMS_INSTALL_DIR} \ + -DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} -DCMAKE_CXX_STANDARD=${COMMON_CXX_STANDARD} + cmake --build ${COMMS_BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param} +} + +function build_mqttsn() { + if [ -e ${CC_MQTTSN_SRC_DIR}/.git ]; then + echo "Updating cc.mqttsn.generated library..." + cd ${CC_MQTTSN_SRC_DIR} + git fetch --all + git checkout . + git checkout ${CC_MQTTSN_TAG} + git pull --all + else + echo "Cloning cc.mqttsn.generated library..." + mkdir -p ${EXTERNALS_DIR} + git clone -b ${CC_MQTTSN_TAG} ${CC_MQTTSN_REPO} ${CC_MQTTSN_SRC_DIR} + fi + + echo "Building cc.mqttsn.generated library..." + mkdir -p ${CC_MQTTSN_BUILD_DIR} + cmake -S ${CC_MQTTSN_SRC_DIR} -B ${CC_MQTTSN_BUILD_DIR} \ + -DCMAKE_INSTALL_PREFIX=${CC_MQTTSN_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} \ + -DCMAKE_CXX_STANDARD=${COMMON_CXX_STANDARD} -DOPT_REQUIRE_COMMS_LIB=OFF + cmake --build ${CC_MQTTSN_BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param} +} + +function build_mqtt311() { + if [ -e ${CC_MQTT311_SRC_DIR}/.git ]; then + echo "Updating cc.mqtt311.generated library..." + cd ${CC_MQTT311_SRC_DIR} + git fetch --all + git checkout . + git checkout ${CC_MQTT311_TAG} + git pull --all + else + echo "Cloning cc.mqtt311.generated library..." + mkdir -p ${EXTERNALS_DIR} + git clone -b ${CC_MQTT311_TAG} ${CC_MQTT311_REPO} ${CC_MQTT311_SRC_DIR} + fi + + echo "Building cc.mqtt311.generated library..." + mkdir -p ${CC_MQTT311_BUILD_DIR} + cmake -S ${CC_MQTT311_SRC_DIR} -B ${CC_MQTT311_BUILD_DIR} \ + -DCMAKE_INSTALL_PREFIX=${CC_MQTT311_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} \ + -DCMAKE_CXX_STANDARD=${COMMON_CXX_STANDARD} -DOPT_REQUIRE_COMMS_LIB=OFF + cmake --build ${CC_MQTT311_BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param} +} + +set -e +export VERBOSE=1 +build_comms +build_mqttsn +build_mqtt311 + + +