Skip to content

Commit

Permalink
Release v0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Jan 21, 2018
2 parents 389c517 + 685e19c commit 21c9be9
Show file tree
Hide file tree
Showing 18 changed files with 288 additions and 192 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ matrix:
- os: linux
env: _CC=gcc-6 _CXX=g++-6 _BUILD=-DCMAKE_BUILD_TYPE=Release
- os: linux
env: _CC=gcc-6 _CXX=g++-6 _BUILD=-DCMAKE_BUILD_TYPE=MinSizeRel
env: _CC=gcc-6 _CXX=g++-6 _BUILD=-DCMAKE_BUILD_TYPE=MinSizeRel
- os: linux
env: _CC=gcc-6 _CXX=g++-6 _BUILD=-DCMAKE_CXX_STANDARD=14
- os: linux
env: _CC=gcc-6 _CXX=g++-6 _BUILD="-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=14"
- os: linux
env: _CC=gcc-6 _CXX=g++-6 _BUILD="-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_CXX_STANDARD=14"
- os: linux
env: _CC=clang-3.9 _CXX=clang++-3.9 _BUILD=-DCMAKE_CXX_STANDARD=14
- os: linux
Expand All @@ -31,18 +37,18 @@ matrix:
env: _CC=clang-3.9 _CXX=clang++-3.9 _BUILD="-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_CXX_STANDARD=14"

before_install:
- sudo add-apt-repository ppa:beineri/opt-qt551 -y
- sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo add-apt-repository ppa:george-edison55/precise-backports -y
- sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
- wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
- sudo apt-add-repository "deb http://apt.llvm.org/precise/ llvm-toolchain-precise-3.9 main" -y
- sudo apt-get update -q
- sudo apt-get install g++-5 g++-6 clang-3.9 cmake cmake-data qt55declarative qt55serialport -y
- sudo apt-get install g++-5 g++-6 clang-3.9 cmake cmake-data qt56base qt56serialport -y

before_script:
- mkdir build
- cd build
- source /opt/qt55/bin/qt55-env.sh
- source /opt/qt56/bin/qt56-env.sh
- CC=${_CC} CXX=${_CXX} cmake .. -DCC_MQTTSN_FULL_SOLUTION=ON ${_BUILD}

script:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ set (CC_MQTT_EXTERNAL_TGT "mqtt_external")
macro (externals install_dir build_cc mqtt_headers)
include(ExternalProject)

set (cc_tag "v0.18.1")
set (cc_tag "v0.23")
set (cc_main_dir "${CMAKE_BINARY_DIR}/comms_champion")
set (cc_src_dir "${cc_main_dir}/src")
set (cc_bin_dir "${cc_main_dir}/build")
Expand Down Expand Up @@ -186,7 +186,7 @@ macro (externals install_dir build_cc mqtt_headers)
set (CC_COMMS_FOUND TRUE)

if (${mqtt_headers})
set (cc_mqtt_tag "v0.7")
set (cc_mqtt_tag "v0.7.2")
ExternalProject_Add(
"${CC_MQTT_EXTERNAL_TGT}"
PREFIX "${cc_mqtt_bin_dir}"
Expand Down
59 changes: 38 additions & 21 deletions client/src/basic/BasicClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <algorithm>
#include <iterator>
#include <limits>
#include <cstring>

#include "comms/comms.h"
#include "comms/util/ScopeGuard.h"
Expand Down Expand Up @@ -265,16 +266,18 @@ class BasicClient

typedef void (BasicClient<TClientOpts, TProtOpts>::*FinaliseFunc)(MqttsnAsyncOpStatus);

struct NoOrigDataViewProtOpts : TProtOpts
{
static const bool HasOrigDataView = false;
};

public:
typedef typename Message::Field FieldBase;
typedef typename mqttsn::protocol::field::GwId<FieldBase>::ValueType GwIdValueType;
//typedef typename mqttsn::protocol::field::GwAdd<FieldBase, TProtOpts>::ValueType GwAddValueType;
typedef typename mqttsn::protocol::field::WillTopic<FieldBase, TProtOpts>::ValueType WillTopicType;
typedef typename mqttsn::protocol::field::WillMsg<FieldBase, TProtOpts>::ValueType WillMsgType;
typedef typename mqttsn::protocol::field::TopicName<FieldBase, TProtOpts>::ValueType TopicNameType;
typedef typename mqttsn::protocol::field::Data<FieldBase, TProtOpts>::ValueType DataType;
typedef typename mqttsn::protocol::field::TopicName<FieldBase, NoOrigDataViewProtOpts>::ValueType TopicNameType;
typedef typename mqttsn::protocol::field::Data<FieldBase, NoOrigDataViewProtOpts>::ValueType DataType;
typedef typename mqttsn::protocol::field::TopicId<FieldBase>::ValueType TopicIdType;
typedef typename mqttsn::protocol::field::ClientId<FieldBase, TProtOpts>::ValueType ClientIdType;
typedef typename mqttsn::protocol::field::ClientId<FieldBase, NoOrigDataViewProtOpts>::ValueType ClientIdType;

struct GwInfo
{
Expand Down Expand Up @@ -317,7 +320,7 @@ class BasicClient
typedef mqttsn::protocol::message::Willmsgresp<Message, TProtOpts> WillmsgrespMsg;

BasicClient() = default;
virtual ~BasicClient() = default;
~BasicClient() noexcept = default;

typedef typename Message::ReadIterator ReadIterator;

Expand Down Expand Up @@ -1208,7 +1211,9 @@ class BasicClient
WillmsgMsg outMsg;

if (op->m_willInfo.msg != nullptr) {
outMsg.field_willMsg().value().assign(op->m_willInfo.msg, op->m_willInfo.msg + op->m_willInfo.msgLen);
auto& dataStorage = outMsg.field_willMsg().value();
using DataStorage = typename std::decay<decltype(dataStorage)>::type;
dataStorage = DataStorage(op->m_willInfo.msg, op->m_willInfo.msgLen);
}

op->m_willMsgSent = true;
Expand All @@ -1217,7 +1222,8 @@ class BasicClient

void handle(RegisterMsg& msg)
{
updateRegInfo(msg.field_topicName().value().c_str(), msg.field_topicId().value(), true);
auto& topic = msg.field_topicName().value();
updateRegInfo(topic.data(), topic.size(), msg.field_topicId().value(), true);

RegackMsg ackMsg;
ackMsg.field_topicId().value() = msg.field_topicId().value();
Expand Down Expand Up @@ -1254,7 +1260,7 @@ class BasicClient
op->m_topicId = msg.field_topicId().value();
op->m_attempt = 0;

updateRegInfo(op->m_topic, op->m_topicId);
updateRegInfo(op->m_topic, std::strlen(op->m_topic), op->m_topicId);
bool result = doPublish();
static_cast<void>(result);
GASSERT(result);
Expand Down Expand Up @@ -1350,7 +1356,8 @@ class BasicClient
midFlags.getBitValue(MidFlags::BitIdx_retain);
}

m_lastInMsg.m_msgData = msg.field_data().value();
auto& msgData = msg.field_data().value();
m_lastInMsg.m_msgData.assign(msgData.begin(), msgData.end());

PubrecMsg recMsg;
recMsg.field_msgId().value() = msg.field_msgId().value();
Expand Down Expand Up @@ -1534,7 +1541,8 @@ class BasicClient
}

if ((m_currOp == Op::Subscribe) && (msg.field_topicId().value() != 0U)) {
updateRegInfo(opPtr<SubscribeOp>()->m_topic, msg.field_topicId().value(), true);
auto* topicStr = opPtr<SubscribeOp>()->m_topic;
updateRegInfo(topicStr, std::strlen(topicStr), msg.field_topicId().value(), true);
}

op->m_qos = qosValue;
Expand Down Expand Up @@ -1691,13 +1699,16 @@ class BasicClient
bool m_reported = false;
};

void updateRegInfo(const char* topic, TopicIdType topicId, bool locked = false)
void updateRegInfo(const char* topic, std::size_t topicLen, TopicIdType topicId, bool locked = false)
{
auto iter = std::find_if(
m_regInfos.begin(), m_regInfos.end(),
[topic, topicId](typename RegInfosList::const_reference elem) -> bool
[topic, topicLen, topicId](typename RegInfosList::const_reference elem) -> bool
{
return elem.m_allocated && (elem.m_topic == topic);
return
elem.m_allocated &&
elem.m_topic.size() == topicLen &&
std::equal(elem.m_topic.begin(), elem.m_topic.end(), topic);
});

if (iter != m_regInfos.end()) {
Expand All @@ -1716,7 +1727,7 @@ class BasicClient

if (iter != m_regInfos.end()) {
iter->m_timestamp = m_timestamp;
iter->m_topic = topic;
iter->m_topic.assign(topic, topic + topicLen);
iter->m_topicId = topicId;
iter->m_allocated = true;
iter->m_locked = locked;
Expand All @@ -1725,7 +1736,7 @@ class BasicClient

RegInfo info;
info.m_timestamp = m_timestamp;
info.m_topic = topic;
info.m_topic.assign(topic, topicLen);
info.m_topicId = topicId;
info.m_allocated = true;
info.m_locked = locked;
Expand Down Expand Up @@ -2425,8 +2436,9 @@ class BasicClient
WillmsgupdMsg msg;
auto* msgBodyBeg = op->m_msg;
if (msgBodyBeg != nullptr) {
auto* msgBodyEnd = msgBodyBeg + op->m_msgLen;
msg.field_willMsg().value().assign(msgBodyBeg, msgBodyEnd);
auto& dataStorage = msg.field_willMsg().value();
using DataStorage = typename std::decay<decltype(dataStorage)>::type;
dataStorage = DataStorage(msgBodyBeg, op->m_msgLen);
}
sendMessage(msg);
return true;
Expand Down Expand Up @@ -2462,7 +2474,9 @@ class BasicClient
++op->m_attempt;

PingreqMsg msg;
msg.field_clientId().value() = m_clientId;
auto& clientIdStorage = msg.field_clientId().value();
using ClientIdStorage = typename std::decay<decltype(clientIdStorage)>::type;
clientIdStorage = ClientIdStorage(m_clientId.c_str(), m_clientId.size());
sendMessage(msg);
return true;
}
Expand Down Expand Up @@ -2535,7 +2549,10 @@ class BasicClient
dupFlagsField.setBitValue(DupFlags::BitIdx_bit, duplicate);
pubMsg.field_topicId().value() = topicId;
pubMsg.field_msgId().value() = msgId;
pubMsg.field_data().value().assign(msg, msg + msgLen);

auto& dataStorage = pubMsg.field_data().value();
using DataStorage = typename std::decay<decltype(dataStorage)>::type;
dataStorage = DataStorage(msg, msgLen);

sendMessage(pubMsg);
}
Expand Down
3 changes: 2 additions & 1 deletion client/templ/client.cpp.templ
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ typedef std::tuple<

typedef mqttsn::protocol::ParsedOptions<
ProtocolOptions,
mqttsn::protocol::option::ClientOnlyVariant
mqttsn::protocol::option::ClientOnlyVariant,
mqttsn::protocol::option::UseOrigDataView
> ParsedProtocolOptions;

typedef std::tuple<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endfunction ()
#################################################################

if (CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib --std=c++11")
endif ()

bin_client_build()
12 changes: 12 additions & 0 deletions client/test/bare_metal_app/test_client_build/stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ void* memcpy( void* dest, const void* src, std::size_t count )
return nullptr;
}

extern "C"
int memcmp(const void*, const void*, std::size_t)
{
return 0;
}

extern "C"
std::size_t strlen(const char*)
{
return 0U;
}

extern "C"
void __aeabi_uidiv()
{
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/lib/SessionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ void SessionImpl::handle(RegisterMsg_SN& msg)
auto& respMsgIdField = std::get<decltype(respMsg)::FieldIdx_msgId>(respFields);
auto& respRetCodeField = std::get<decltype(respMsg)::FieldIdx_returnCode>(respFields);

auto& topicView = topicField.value();
respTopicIdField.value() =
m_state.m_regMgr.mapTopicNoInfo(topicField.value());
m_state.m_regMgr.mapTopicNoInfo(std::string(topicView.data(), topicView.size()));

respMsgIdField.value() = msgIdField.value();
assert(respRetCodeField.value() == mqttsn::protocol::field::ReturnCodeVal_Accepted);
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/lib/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ typedef mqtt::protocol::v311::MessageT<
> MqttMessage;

typedef protocol::ParsedOptions<
protocol::option::GatewayOnlyVariant
protocol::option::GatewayOnlyVariant,
protocol::option::UseOrigDataView
> GwOptions;

typedef mqttsn::protocol::message::Advertise<MqttsnMessage, GwOptions> AdvertiseMsg_SN;
Expand Down
18 changes: 10 additions & 8 deletions gateway/src/lib/session_op/Connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,28 @@ void Connect::handle(ConnectMsg_SN& msg)
typedef typename std::decay<decltype(midFlagsField)>::type MidFlags;

auto& st = state();
auto* reqClientId = &(msg.field_clientId().value());
if (reqClientId->empty()) {
reqClientId = &(st.m_defaultClientId);
auto reqClientId = msg.field_clientId().value().substr();
if (reqClientId.empty()) {
reqClientId = st.m_defaultClientId;
}

if ((st.m_connStatus != ConnectionStatus::Disconnected) &&
(*reqClientId != st.m_clientId)) {
(reqClientId != st.m_clientId)) {
sendDisconnectToClient();
state().m_connStatus = ConnectionStatus::Disconnected;
termRequest();
return;
}


assert(st.m_clientId.empty() || st.m_clientId == *reqClientId);
assert(st.m_clientId.empty() || (st.m_clientId == reqClientId));
if (m_internalState.m_hasClientId) {
m_internalState = State();
}

m_internalState.m_hasClientId = true;

m_clientId = *reqClientId;
m_clientId = std::move(reqClientId);
m_keepAlive = msg.field_duration().value();
m_clean = midFlagsField.getBitValue(MidFlags::BitIdx_cleanSession);

Expand Down Expand Up @@ -125,7 +125,8 @@ void Connect::handle(WilltopicMsg_SN& msg)
auto& midFlagsField = msg.field_flags().field().field_midFlags();
typedef typename std::decay<decltype(midFlagsField)>::type MidFlags;

m_will.m_topic = msg.field_willTopic().value();
auto& topicView = msg.field_willTopic().value();
m_will.m_topic.assign(topicView.begin(), topicView.end());
m_will.m_qos = translateQos(msg.field_flags().field().field_qos().value());
m_will.m_retain = midFlagsField.getBitValue(MidFlags::BitIdx_retain);

Expand All @@ -150,7 +151,8 @@ void Connect::handle(WillmsgMsg_SN& msg)
m_internalState.m_hasWillMsg = true;
m_internalState.m_attempt = 0;

m_will.m_msg = msg.field_willMsg().value();
auto& data = msg.field_willMsg().value();
m_will.m_msg.assign(data.begin(), data.end());
doNextStep();
}

Expand Down
Loading

0 comments on commit 21c9be9

Please sign in to comment.