Skip to content

Commit

Permalink
unixs scheme aka local unix socket with serial protocol supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Jan 29, 2024
1 parent 1085eaa commit f49cc98
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libshv
Submodule libshv updated 105 files
2 changes: 1 addition & 1 deletion shvspy/src/appversion.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#define APP_VERSION "1.6.1"
#define APP_VERSION "1.7.0"

5 changes: 3 additions & 2 deletions shvspy/src/dlgbrokerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DlgBrokerProperties::DlgBrokerProperties(QWidget *parent) :
cbx->addItem(Socket::schemeToString(Scheme::WebSocketSecure), static_cast<int>(Scheme::WebSocketSecure));
cbx->addItem(Socket::schemeToString(Scheme::SerialPort), static_cast<int>(Scheme::SerialPort));
cbx->addItem(Socket::schemeToString(Scheme::LocalSocket), static_cast<int>(Scheme::LocalSocket));
cbx->addItem(Socket::schemeToString(Scheme::LocalSocketSerial), static_cast<int>(Scheme::LocalSocketSerial));
cbx->setCurrentIndex(0);
}
connect(ui->cbxScheme, qOverload<int>(&QComboBox::currentIndexChanged), this, [this] (int ix) {
Expand All @@ -49,8 +50,8 @@ DlgBrokerProperties::DlgBrokerProperties(QWidget *parent) :
ui->cbxConnectionType->setCurrentIndex(0);

ui->rpc_protocolType->addItem(Rpc::protocolTypeToString(Rpc::ProtocolType::ChainPack), static_cast<int>(Rpc::ProtocolType::ChainPack));
ui->rpc_protocolType->addItem(Rpc::protocolTypeToString(Rpc::ProtocolType::Cpon), static_cast<int>(Rpc::ProtocolType::Cpon));
ui->rpc_protocolType->addItem(Rpc::protocolTypeToString(Rpc::ProtocolType::JsonRpc), static_cast<int>(Rpc::ProtocolType::JsonRpc));
//ui->rpc_protocolType->addItem(Rpc::protocolTypeToString(Rpc::ProtocolType::Cpon), static_cast<int>(Rpc::ProtocolType::Cpon));
//ui->rpc_protocolType->addItem(Rpc::protocolTypeToString(Rpc::ProtocolType::JsonRpc), static_cast<int>(Rpc::ProtocolType::JsonRpc));
ui->rpc_protocolType->setCurrentIndex(0);

using shv::iotqt::rpc::ClientConnection;
Expand Down
32 changes: 19 additions & 13 deletions shvspy/src/servertreemodel/shvbrokernodeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,20 @@ void ShvBrokerNodeItem::open()
auto host = m_brokerPropeties.value(brokerProperty::HOST).toString().toStdString();
auto port = m_brokerPropeties.value(brokerProperty::PORT).toInt();
std::string pwd = m_brokerPropeties.value(brokerProperty::PASSWORD).toString().toStdString();
if(scheme_enum == shv::iotqt::rpc::Socket::Scheme::LocalSocket || scheme_enum == shv::iotqt::rpc::Socket::Scheme::SerialPort) {
if(scheme_enum == shv::iotqt::rpc::Socket::Scheme::LocalSocket || scheme_enum == shv::iotqt::rpc::Socket::Scheme::LocalSocketSerial || scheme_enum == shv::iotqt::rpc::Socket::Scheme::SerialPort) {
host = scheme + ":" + host;
cli->setLoginType(shv::iotqt::rpc::ClientConnection::LoginType::None);
}
else {
host = scheme + "://" + host;
if(port > 0)
if(port > 0) {
host += ':' + QString::number(port).toStdString();
}
}
bool skip_login = m_brokerPropeties.value(brokerProperty::SKIPLOGINPHASE).toBool();
if (skip_login) {
cli->setLoginType(shv::iotqt::rpc::ClientConnection::LoginType::None);
}
else {
//cli->setLoginType(pwd.size() == 40? cp::IRpcConnection::LoginType::Sha1: cp::IRpcConnection::LoginType::Plain);
if(scheme_enum == shv::iotqt::rpc::Socket::Scheme::Ssl) {
// SSL encryption is enough
Expand Down Expand Up @@ -330,15 +336,15 @@ shv::iotqt::rpc::ClientConnection *ShvBrokerNodeItem::clientConnection()
QString conn_type = m_brokerPropeties.value(brokerProperty::CONNECTIONTYPE).toString();

shv::iotqt::rpc::DeviceAppCliOptions opts;
{
int proto_type = m_brokerPropeties.value(brokerProperty::RPC_PROTOCOLTYPE).toInt();
if(proto_type == static_cast<int>(cp::Rpc::ProtocolType::JsonRpc))
opts.setProtocolType("jsonrpc");
else if(proto_type == static_cast<int>(cp::Rpc::ProtocolType::Cpon))
opts.setProtocolType("cpon");
else
opts.setProtocolType("chainpack");
}
//{
// int proto_type = m_brokerPropeties.value(brokerProperty::RPC_PROTOCOLTYPE).toInt();
// if(proto_type == static_cast<int>(cp::Rpc::ProtocolType::JsonRpc))
// opts.setProtocolType("jsonrpc");
// else if(proto_type == static_cast<int>(cp::Rpc::ProtocolType::Cpon))
// opts.setProtocolType("cpon");
// else
// opts.setProtocolType("chainpack");
//}
{
QVariant v = m_brokerPropeties.value(brokerProperty::RPC_RECONNECTINTERVAL);
if(v.isValid())
Expand Down Expand Up @@ -536,7 +542,7 @@ void ShvBrokerNodeItem::onRpcMessageReceived(const shv::chainpack::RpcMessage &m
catch (shv::core::Exception &e) {
resp.setError(cp::RpcResponse::Error::create(cp::RpcResponse::Error::MethodCallException, e.message()));
}
m_rpcConnection->sendMessage(resp);
m_rpcConnection->sendRpcMessage(resp);
}
else if(msg.isSignal()) {
shvDebug() << msg.toCpon();
Expand Down

0 comments on commit f49cc98

Please sign in to comment.