Skip to content

Commit

Permalink
Release v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Apr 13, 2024
2 parents 3d14da0 + 0d113aa commit 688a126
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 113 deletions.
8 changes: 4 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ configuration:
- Release

environment:
COMMS_TAG: v5.2.2
CC_TOOLS_QT_TAG: v5.2
CC_MQTT5_GENERATED_TAG: v2.6
CC_MQTT5_LIBS_TAG: v0.3.1
COMMS_TAG: v5.2.3
CC_TOOLS_QT_TAG: v5.2.1
CC_MQTT5_GENERATED_TAG: v2.7
CC_MQTT5_LIBS_TAG: v0.4
matrix:
- CPP_STD: 17
QT_MAJOR: 5
Expand Down
71 changes: 64 additions & 7 deletions .github/workflows/actions_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Github Actions Build
on: [push]

env:
COMMS_TAG: v5.2.2
CC_TOOLS_QT_TAG: v5.2
CC_MQTT5_GENERATED_TAG: v2.6
CC_MQTT5_LIBS_TAG: v0.3.1
COMMS_TAG: v5.2.3
CC_TOOLS_QT_TAG: v5.2.1
CC_MQTT5_GENERATED_TAG: v2.7
CC_MQTT5_LIBS_TAG: v0.4

jobs:

Expand All @@ -21,7 +21,7 @@ jobs:
qt_ver: [5, 6]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare Install
run: sudo apt-get update --fix-missing
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
cpp: 20

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare Install
run: sudo apt-get update --fix-missing
Expand Down Expand Up @@ -132,4 +132,61 @@ jobs:
run: cmake --build . --config ${{matrix.type}} --target install
env:
VERBOSE: 1


build_msvc_2019:
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
type: [Debug, Release, MinSizeRel]
arch: [x64]
cpp: [17]
qt_ver: [5]

steps:
- uses: actions/checkout@v4

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Install Qt
shell: cmd
run: |
choco install curl
curl -L ${{env.QT5_MSVC2019_URL}} -o ${{runner.workspace}}/qt.7z
7z x ${{runner.workspace}}/qt.7z -o${{runner.workspace}}/qt
env:
QT5_MSVC2019_URL: https://github.com/martinrotter/qt-minimalistic-builds/releases/download/5.15.3/qt-5.15.3-dynamic-msvc2019-x86_64.7z

- name: Prepare externals
shell: cmd
run: |
%GITHUB_WORKSPACE%\script\prepare_externals.bat
env:
BUILD_DIR: ${{runner.workspace}}/build
PLATFORM: ${{matrix.arch}}
EXTERNALS_DIR: ${{runner.workspace}}/externals
COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install
COMMON_BUILD_TYPE: ${{matrix.type}}
COMMON_CXX_STANDARD: ${{matrix.cpp}}
COMMON_QT_VER: ${{matrix.qt_ver}}
COMMS_TAG: ${{env.COMMS_TAG}}
CC_TOOLS_QT_TAG: ${{env.CC_TOOLS_QT_TAG}}
CC_MQTT5_GENERATED_TAG: ${{env.CC_MQTT5_GENERATED_TAG}}
CC_MQTT5_LIBS_TAG: ${{env.CC_MQTT5_LIBS_TAG}}
QTDIR: ${{runner.workspace}}/qt/qt-5.15.3-dynamic-msvc2019-x86_64

- name: Configure CMake
shell: cmd
working-directory: ${{runner.workspace}}/build
run: |
cmake %GITHUB_WORKSPACE% -A ${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_INSTALL_PREFIX=install ^
-DCMAKE_PREFIX_PATH="${{runner.workspace}}/build/install;${{runner.workspace}}/qt/qt-5.15.3-dynamic-msvc2019-x86_64" -DCMAKE_CXX_STANDARD=${{matrix.cpp}} ^
-DOPT_QT_MAJOR_VERSION=${{matrix.qt_ver}}
- name: Build Target
working-directory: ${{runner.workspace}}/build
shell: cmd
run: cmake --build . --config ${{matrix.type}} --target install
env:
VERBOSE: 1
120 changes: 58 additions & 62 deletions script/prepare_externals.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rem -----------------------------------------------------

if [%BUILD_DIR%] == [] echo "BUILD_DIR hasn't been specified" & exit /b 1

if [%GENERATOR%] == [] set GENERATOR="NMake Makefiles"
if NOT [%GENERATOR%] == [] set GENERATOR_PARAM=-G %GENERATOR%

if NOT [%PLATFORM%] == [] set PLATFORM_PARAM=-A %PLATFORM%

Expand Down Expand Up @@ -72,101 +72,97 @@ if NOT [%COMMON_INSTALL_DIR%] == [] set CC_MQTT5_LIBS_INSTALL_DIR=%COMMON_INSTAL
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%

if exist %COMMS_SRC_DIR%/.git (
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%
) else (
echo "Cloning COMMS library..."
git clone -b %COMMS_TAG% %COMMS_REPO% %COMMS_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
)

:comms_build
echo "Building COMMS library..."
mkdir "%COMMS_BUILD_DIR%"
cd %COMMS_BUILD_DIR%
cmake -G %GENERATOR% %PLATFORM_PARAM% -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 %GENERATOR_PARAM% %PLATFORM_PARAM% -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%

rem ----------------------------------------------------

if exist %CC_TOOLS_QT_SRC_DIR%/.git goto cc_tools_qt_update
echo "Cloning cc_tools_qt ..."
git clone -b %CC_TOOLS_QT_TAG% %CC_TOOLS_QT_REPO% %CC_TOOLS_QT_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
goto cc_tools_qt_build

:cc_tools_qt_update
echo "Updating cc_tools_qt..."
cd %CC_TOOLS_QT_SRC_DIR%
git fetch --all
git checkout .
git checkout %CC_TOOLS_QT_TAG%
git pull --all
if exist %CC_TOOLS_QT_SRC_DIR%/.git (
echo "Updating cc_tools_qt..."
cd %CC_TOOLS_QT_SRC_DIR%
git fetch --all
git checkout .
git checkout %CC_TOOLS_QT_TAG%
git pull --all
) else (
echo "Cloning cc_tools_qt ..."
git clone -b %CC_TOOLS_QT_TAG% %CC_TOOLS_QT_REPO% %CC_TOOLS_QT_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
)

:cc_tools_qt_build
echo "Building cc_tools_qt ..."
mkdir "%CC_TOOLS_QT_BUILD_DIR%"
cd %CC_TOOLS_QT_BUILD_DIR%
cmake -G %GENERATOR% %PLATFORM_PARAM% -S %CC_TOOLS_QT_SRC_DIR% -B %CC_TOOLS_QT_BUILD_DIR% -DCMAKE_INSTALL_PREFIX=%CC_TOOLS_QT_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% -DCC_TOOLS_QT_BUILD_APPS=OFF -DCMAKE_PREFIX_PATH=%COMMS_INSTALL_DIR%;%QTDIR% -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% -DCC_TOOLS_QT_MAJOR_QT_VERSION=%COMMON_QT_VER%
cmake %GENERATOR_PARAM% %PLATFORM_PARAM% -S %CC_TOOLS_QT_SRC_DIR% -B %CC_TOOLS_QT_BUILD_DIR% -DCMAKE_INSTALL_PREFIX=%CC_TOOLS_QT_INSTALL_DIR% ^
-DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% -DCC_TOOLS_QT_BUILD_APPS=OFF -DCMAKE_PREFIX_PATH=%COMMS_INSTALL_DIR%;%QTDIR% ^
-DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% %CC_TOOLS_QT_VERSION_OPT%
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build %CC_TOOLS_QT_BUILD_DIR% --config %COMMON_BUILD_TYPE% --target install
if %errorlevel% neq 0 exit /b %errorlevel%

rem ----------------------------------------------------

if exist %CC_MQTT5_GENERATED_SRC_DIR%/.git goto cc_mqtt_generated_update
echo "Cloning cc.mqtt5.generated ..."
git clone -b %CC_MQTT5_GENERATED_TAG% %CC_MQTT5_GENERATED_REPO% %CC_MQTT5_GENERATED_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
goto cc_mqtt5_generated_build

:cc_mqtt5_generated_update
echo "Updating cc.mqtt5.generated..."
cd %CC_MQTT5_GENERATED_SRC_DIR%
git fetch --all
git checkout .
git checkout %CC_MQTT5_GENERATED_TAG%
git pull --all
if exist %CC_MQTT5_GENERATED_SRC_DIR%/.git (
echo "Updating cc.mqtt5.generated..."
cd %CC_MQTT5_GENERATED_SRC_DIR%
git fetch --all
git checkout .
git checkout %CC_MQTT5_GENERATED_TAG%
git pull --all
) else (
echo "Cloning cc.mqtt5.generated ..."
git clone -b %CC_MQTT5_GENERATED_TAG% %CC_MQTT5_GENERATED_REPO% %CC_MQTT5_GENERATED_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
)

:cc_mqtt5_generated_build
echo "Building cc.mqtt5.generated ..."
mkdir "%CC_MQTT5_GENERATED_BUILD_DIR%"
cd %CC_MQTT5_GENERATED_BUILD_DIR%
cmake -G %GENERATOR% %PLATFORM_PARAM% -S %CC_MQTT5_GENERATED_SRC_DIR% -B %CC_MQTT5_GENERATED_BUILD_DIR% -DCMAKE_INSTALL_PREFIX=%CC_MQTT5_GENERATED_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% -DOPT_REQUIRE_COMMS_LIB=OFF -DCMAKE_PREFIX_PATH=%COMMS_INSTALL_DIR% -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD%
cmake %GENERATOR_PARAM% %PLATFORM_PARAM% -S %CC_MQTT5_GENERATED_SRC_DIR% -B %CC_MQTT5_GENERATED_BUILD_DIR% -DCMAKE_INSTALL_PREFIX=%CC_MQTT5_GENERATED_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% -DOPT_REQUIRE_COMMS_LIB=OFF -DCMAKE_PREFIX_PATH=%COMMS_INSTALL_DIR% -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD%
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build %CC_MQTT5_GENERATED_BUILD_DIR% --config %COMMON_BUILD_TYPE% --target install
if %errorlevel% neq 0 exit /b %errorlevel%

rem ----------------------------------------------------

if exist %CC_MQTT5_LIBS_SRC_DIR%/.git goto cc_mqtt_libs_update
echo "Cloning cc.mqtt5.libs ..."
git clone -b %CC_MQTT5_LIBS_TAG% %CC_MQTT5_LIBS_REPO% %CC_MQTT5_LIBS_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
goto cc_mqtt5_libs_build

:cc_mqtt5_libs_update
echo "Updating cc.mqtt5.libs..."
cd %CC_MQTT5_LIBS_SRC_DIR%
git fetch --all
git checkout .
git checkout %CC_MQTT5_LIBSD_TAG%
git pull --all

:cc_mqtt5_libs_build
if exist %CC_MQTT5_LIBS_SRC_DIR%/.git (
echo "Updating cc.mqtt5.libs..."
cd %CC_MQTT5_LIBS_SRC_DIR%
git fetch --all
git checkout .
git checkout %CC_MQTT5_LIBSD_TAG%
git pull --all
) else (
echo "Cloning cc.mqtt5.libs ..."
git clone -b %CC_MQTT5_LIBS_TAG% %CC_MQTT5_LIBS_REPO% %CC_MQTT5_LIBS_SRC_DIR%
if %errorlevel% neq 0 exit /b %errorlevel%
)

echo "Building cc.mqtt5.libs ..."
mkdir "%CC_MQTT5_LIBS_BUILD_DIR%"
cd %CC_MQTT5_LIBS_BUILD_DIR%
cmake -G %GENERATOR% %PLATFORM_PARAM% -S %CC_MQTT5_LIBS_SRC_DIR% -B %CC_MQTT5_LIBS_BUILD_DIR% -DCMAKE_INSTALL_PREFIX=%CC_MQTT5_LIBS_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% -DCMAKE_PREFIX_PATH=%COMMS_INSTALL_DIR%;%CC_MQTT5_GENERATED_INSTALL_DIR% -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% -DCC_MQTT5_CLIENT_LIB_FORCE_PIC=ON -DCC_MQTT5_CLIENT_APPS=OFF
cmake %GENERATOR_PARAM% %PLATFORM_PARAM% -S %CC_MQTT5_LIBS_SRC_DIR% -B %CC_MQTT5_LIBS_BUILD_DIR% -DCMAKE_INSTALL_PREFIX=%CC_MQTT5_LIBS_INSTALL_DIR% -DCMAKE_BUILD_TYPE=%COMMON_BUILD_TYPE% -DCMAKE_PREFIX_PATH=%COMMS_INSTALL_DIR%;%CC_MQTT5_GENERATED_INSTALL_DIR% -DCMAKE_CXX_STANDARD=%COMMON_CXX_STANDARD% -DCC_MQTT5_CLIENT_LIB_FORCE_PIC=ON -DCC_MQTT5_CLIENT_APPS=OFF
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build %CC_MQTT5_LIBS_BUILD_DIR% --config %COMMON_BUILD_TYPE% --target install
if %errorlevel% neq 0 exit /b %errorlevel%
56 changes: 22 additions & 34 deletions src/Mqtt5ClientFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ const QString& errorCodeStr(CC_Mqtt5ErrorCode ec)
/* CC_Mqtt5ErrorCode_Terminating */ "Terminating",
/* CC_Mqtt5ErrorCode_NetworkDisconnected */ "Network is Disconnected",
/* CC_Mqtt5ErrorCode_NotAuthenticated */ "Not Authenticated",
/* CC_Mqtt5ErrorCode_PreparationLocked */ "Preparation Locked",
};
static const std::size_t MapSize = std::extent<decltype(Map)>::value;
static_assert(MapSize == CC_Mqtt5ErrorCode_ValuesLimit);
Expand Down Expand Up @@ -427,13 +428,7 @@ Mqtt5ClientFilter::~Mqtt5ClientFilter() noexcept = default;

bool Mqtt5ClientFilter::startImpl()
{
auto ec = cc_mqtt5_client_init(m_client.get());
if (ec != CC_Mqtt5ErrorCode_Success) {
reportError(tr("Failed to initialize MQTT5 client"));
return false;
}

ec = ::cc_mqtt5_client_set_default_response_timeout(m_client.get(), m_config.m_respTimeout);
auto ec = ::cc_mqtt5_client_set_default_response_timeout(m_client.get(), m_config.m_respTimeout);
if (ec != CC_Mqtt5ErrorCode_Success) {
reportError(tr("Failed to update MQTT5 default response timeout"));
return false;
Expand Down Expand Up @@ -875,18 +870,6 @@ void Mqtt5ClientFilter::doTick()

void Mqtt5ClientFilter::socketConnected()
{
auto ec = cc_mqtt5_client_init(m_client.get());
if (ec != CC_Mqtt5ErrorCode_Success) {
reportError(tr("Failed to (re)initialize MQTT5 client"));
return;
}

CC_Mqtt5ConnectHandle connect = cc_mqtt5_client_connect_prepare(m_client.get(), nullptr);
if (connect == nullptr) {
reportError(tr("Failed to allocate CONNECT message in MQTT5 client"));
return;
}

auto basicConfig = CC_Mqtt5ConnectBasicConfig();
::cc_mqtt5_client_connect_init_config_basic(&basicConfig);

Expand All @@ -901,33 +884,42 @@ void Mqtt5ClientFilter::socketConnected()
basicConfig.m_username = username.c_str();
basicConfig.m_password = password.data();
basicConfig.m_passwordLen = static_cast<decltype(basicConfig.m_passwordLen)>(password.size());
basicConfig.m_keepAlive = m_config.m_keepAlive;
basicConfig.m_cleanStart =
(m_config.m_forcedCleanStart) ||
(clientId.empty()) ||
(clientId != m_prevClientId) ||
(m_firstConnect);

auto extraConfig = CC_Mqtt5ConnectExtraConfig();
::cc_mqtt5_client_connect_init_config_extra(&extraConfig);
extraConfig.m_sessionExpiryInterval = m_config.m_sessionExpiryInterval;
if (m_config.m_sessionExpiryInfinite) {
extraConfig.m_sessionExpiryInterval = CC_MQTT5_SESSION_NEVER_EXPIRES;
}
extraConfig.m_topicAliasMaximum = m_config.m_topicAliasMaximum;

auto ec =
cc_mqtt5_client_connect_full(
m_client.get(),
&basicConfig,
nullptr,
&extraConfig,
nullptr,
&Mqtt5ClientFilter::connectCompleteCb,
this);

ec = ::cc_mqtt5_client_connect_config_basic(connect, &basicConfig);
if (ec != CC_Mqtt5ErrorCode_Success) {
reportError(tr("Failed to configure CONNECT message in MQTT5 client"));
cc_mqtt5_client_connect_cancel(connect);
reportError(tr("Failed to initiate MQTT v5 connection"));
return;
}

ec = cc_mqtt5_client_connect_send(connect, &Mqtt5ClientFilter::connectCompleteCb, this);
if (ec != CC_Mqtt5ErrorCode_Success) {
reportError(tr("Failed to send MQTT5 CONNECT message"));
return;
}

m_prevClientId = clientId;
}

void Mqtt5ClientFilter::socketDisconnected()
{
m_waitingForDisconnect = true;
::cc_mqtt5_client_notify_network_disconnected(m_client.get(), true);
::cc_mqtt5_client_notify_network_disconnected(m_client.get());
}

void Mqtt5ClientFilter::sendPendingData()
Expand Down Expand Up @@ -965,10 +957,6 @@ void Mqtt5ClientFilter::sendDataInternal(const unsigned char* buf, unsigned bufL

void Mqtt5ClientFilter::brokerDisconnectedInternal()
{
if (m_waitingForDisconnect) {
return;
}

static const QString BrokerDisconnecteError =
tr("MQTT5 Broker is disconnected");

Expand Down
Loading

0 comments on commit 688a126

Please sign in to comment.