mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 23:46:51 +01:00
Generate the QoSm1Proxy Name from the Gateway Id.
Bugfix of AggregatePublish Memory leak of ClientList Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -36,17 +36,16 @@ BrokerSecurePortNo=8883
|
|||||||
# All clients must be specified by the ClientList File
|
# All clients must be specified by the ClientList File
|
||||||
#
|
#
|
||||||
|
|
||||||
#ClientsList=/path/to/your_clients.conf
|
|
||||||
|
|
||||||
ClientAuthentication=NO
|
ClientAuthentication=NO
|
||||||
AggregateGateway=NO
|
AggregateGateway=NO
|
||||||
Forwarder=NO
|
|
||||||
QoS-1=NO
|
QoS-1=NO
|
||||||
OoS-1ProxyName=Proxy007
|
Forwarder=NO
|
||||||
|
|
||||||
|
#ClientsList=/path/to/your_clients.conf
|
||||||
|
|
||||||
|
PredefinedTopic=NO
|
||||||
#PredefinedTopicList=/path/to/your_predefinedTopic.conf
|
#PredefinedTopicList=/path/to/your_predefinedTopic.conf
|
||||||
|
|
||||||
|
|
||||||
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
||||||
#RootCApath=/etc/ssl/certs/
|
#RootCApath=/etc/ssl/certs/
|
||||||
#CertsFile=/path/to/certKey.pem
|
#CertsFile=/path/to/certKey.pem
|
||||||
@@ -79,10 +78,11 @@ ShearedMemory=NO;
|
|||||||
Client should know the MulticastIP and MulticastPortNo to send a SEARCHGW message.
|
Client should know the MulticastIP and MulticastPortNo to send a SEARCHGW message.
|
||||||
**GatewayId** is used by GWINFO message.
|
**GatewayId** is used by GWINFO message.
|
||||||
**KeepAlive** is a duration of ADVERTISE message in seconds.
|
**KeepAlive** is a duration of ADVERTISE message in seconds.
|
||||||
when **AggregateGateway** or **ClientAuthentication** is **YES**, All clients which connect to the gateway must be declared by a **ClientsList** file.
|
when **AggregateGateway** or **ClientAuthentication** is **YES**, All clients which connect to the gateway must be declared by a **ClientsList** file.
|
||||||
Format of the file is ClientId and SensorNetwork Address. e.g. IP address and Port No etc, in CSV. more detail see clients.conf
|
Format of the file is ClientId and SensorNetwork Address. e.g. IP address and Port No etc, in CSV. more detail see clients.conf.
|
||||||
|
When **QoS-1** is **YES**, QoS-1 PUBLISH is available. All clients which send QoS-1 PUBLISH must be specified by Client.conf file.
|
||||||
When **PredefinedTopic** is **YES**, **Pre-definedTopicId**s specified by **PredefinedTopicList** are effective. This file defines Pre-definedTopics of the clients. In this file, ClientID,TopicName and TopicID are declared in CSV format.
|
When **PredefinedTopic** is **YES**, **Pre-definedTopicId**s specified by **PredefinedTopicList** are effective. This file defines Pre-definedTopics of the clients. In this file, ClientID,TopicName and TopicID are declared in CSV format.
|
||||||
When **Forwarder** is **YE**S, Forwarder Encapsulation Message is available. Connectable Forwarders must be declared by a **ClientsList** file.
|
When **Forwarder** is **YES**, Forwarder Encapsulation Message is available. Connectable Forwarders must be declared by a **ClientsList** file.
|
||||||
|
|
||||||
|
|
||||||
### ** How to monitor the gateway from remote. **
|
### ** How to monitor the gateway from remote. **
|
||||||
|
|||||||
@@ -23,20 +23,16 @@ BrokerSecurePortNo=8883
|
|||||||
# All clients must be specified by the ClientList File
|
# All clients must be specified by the ClientList File
|
||||||
#
|
#
|
||||||
|
|
||||||
AggregateGateway=NO
|
|
||||||
ClientAuthentication=NO
|
ClientAuthentication=NO
|
||||||
|
AggregateGateway=NO
|
||||||
|
QoS-1=NO
|
||||||
|
Forwarder=NO
|
||||||
|
|
||||||
#ClientsList=/path/to/your_clients.conf
|
#ClientsList=/path/to/your_clients.conf
|
||||||
|
|
||||||
QoS-1=NO
|
|
||||||
OoS-1ProxyName=Proxy007
|
|
||||||
|
|
||||||
PredefinedTopic=NO
|
PredefinedTopic=NO
|
||||||
#PredefinedTopicList=/path/to/your_predefinedTopic.conf
|
#PredefinedTopicList=/path/to/your_predefinedTopic.conf
|
||||||
|
|
||||||
Forwarder=NO
|
|
||||||
#ForwardersList=/path/to/your_forwarers.conf
|
|
||||||
|
|
||||||
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
||||||
#RootCApath=/etc/ssl/certs/
|
#RootCApath=/etc/ssl/certs/
|
||||||
#CertsFile=/path/to/certKey.pem
|
#CertsFile=/path/to/certKey.pem
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ void AdapterManager::checkConnection(void)
|
|||||||
{
|
{
|
||||||
_aggregater->checkConnection();
|
_aggregater->checkConnection();
|
||||||
}
|
}
|
||||||
else if ( _qosm1Proxy->isActive())
|
|
||||||
|
if ( _qosm1Proxy->isActive())
|
||||||
{
|
{
|
||||||
_qosm1Proxy->checkConnection();
|
_qosm1Proxy->checkConnection();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ void Aggregater::initialize(void)
|
|||||||
{
|
{
|
||||||
/* Create Aggregated Clients */
|
/* Create Aggregated Clients */
|
||||||
_gateway->getClientList()->setClientList(AGGREGATER_TYPE);
|
_gateway->getClientList()->setClientList(AGGREGATER_TYPE);
|
||||||
setup((const char*)(_gateway->getGWParams()->gatewayName), Atype_Aggregater);
|
|
||||||
|
string name = _gateway->getGWParams()->gatewayName;
|
||||||
|
setup(name.c_str(), Atype_Aggregater);
|
||||||
_isActive = true;
|
_isActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ void ClientList::setClientList(int type)
|
|||||||
{
|
{
|
||||||
throw Exception("ClientList::initialize(): No client list defined by the configuration.");
|
throw Exception("ClientList::initialize(): No client list defined by the configuration.");
|
||||||
}
|
}
|
||||||
params->clientListName = strdup(fileName.c_str());
|
|
||||||
|
if ( params->clientListName == nullptr )
|
||||||
|
{
|
||||||
|
params->clientListName = strdup(fileName.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientList::setPredefinedTopics(bool aggrecate)
|
void ClientList::setPredefinedTopics(bool aggrecate)
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ void ClientRecvTask::initialize(int argc, char** argv)
|
|||||||
void ClientRecvTask::run()
|
void ClientRecvTask::run()
|
||||||
{
|
{
|
||||||
Event* ev = nullptr;
|
Event* ev = nullptr;
|
||||||
Client* client = nullptr;
|
|
||||||
AdapterManager* adpMgr = _gateway->getAdapterManager();
|
AdapterManager* adpMgr = _gateway->getAdapterManager();
|
||||||
QoSm1Proxy* qosm1Proxy = adpMgr->getQoSm1Proxy();
|
QoSm1Proxy* qosm1Proxy = adpMgr->getQoSm1Proxy();
|
||||||
bool isAggrActive = adpMgr->isAggregaterActive();
|
bool isAggrActive = adpMgr->isAggregaterActive();
|
||||||
@@ -69,6 +68,7 @@ void ClientRecvTask::run()
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Client* client = nullptr;
|
||||||
Forwarder* fwd = nullptr;
|
Forwarder* fwd = nullptr;
|
||||||
WirelessNodeId nodeId;
|
WirelessNodeId nodeId;
|
||||||
|
|
||||||
@@ -105,7 +105,6 @@ void ClientRecvTask::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Client* client = nullptr;
|
|
||||||
SensorNetAddress* senderAddr = _gateway->getSensorNetwork()->getSenderAddress();
|
SensorNetAddress* senderAddr = _gateway->getSensorNetwork()->getSenderAddress();
|
||||||
|
|
||||||
if ( packet->getType() == MQTTSN_ENCAPSULATED )
|
if ( packet->getType() == MQTTSN_ENCAPSULATED )
|
||||||
@@ -124,12 +123,6 @@ void ClientRecvTask::run()
|
|||||||
nodeId.setId( encap.getWirelessNodeId() );
|
nodeId.setId( encap.getWirelessNodeId() );
|
||||||
client = fwd->getClient(&nodeId);
|
client = fwd->getClient(&nodeId);
|
||||||
packet = encap.getMQTTSNPacket();
|
packet = encap.getMQTTSNPacket();
|
||||||
|
|
||||||
if ( client == nullptr )
|
|
||||||
{
|
|
||||||
/* get client of Forwarder or QoSm1Proxy */
|
|
||||||
client = _gateway->getClientList()->getClient(senderAddr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -138,8 +131,7 @@ void ClientRecvTask::run()
|
|||||||
|
|
||||||
if ( qosm1Proxy->isActive() )
|
if ( qosm1Proxy->isActive() )
|
||||||
{
|
{
|
||||||
/* get ClientId not Client which can send QoS-1 PUBLISH */
|
const char* clientName = qosm1Proxy->getClientId(senderAddr);
|
||||||
const char* clientName = qosm1Proxy->getClientId(senderAddr);
|
|
||||||
|
|
||||||
if ( clientName )
|
if ( clientName )
|
||||||
{
|
{
|
||||||
@@ -152,13 +144,11 @@ void ClientRecvTask::run()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
client = _gateway->getClientList()->getClient(senderAddr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client = _gateway->getClientList()->getClient(senderAddr);
|
||||||
|
|
||||||
if ( client )
|
if ( client )
|
||||||
{
|
{
|
||||||
/* write log and post Event */
|
/* write log and post Event */
|
||||||
|
|||||||
@@ -114,17 +114,17 @@ MQTTGWPacket* MQTTSNPublishHandler::handlePublish(Client* client, MQTTSNPacket*
|
|||||||
MQTTGWPacket* publish = new MQTTGWPacket();
|
MQTTGWPacket* publish = new MQTTGWPacket();
|
||||||
publish->setPUBLISH(&pub);
|
publish->setPUBLISH(&pub);
|
||||||
|
|
||||||
if ( !_gateway->getAdapterManager()->isAggregaterActive() )
|
if ( _gateway->getAdapterManager()->isAggregaterActive() && client->isAggregated() )
|
||||||
|
{
|
||||||
|
return publish;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Event* ev1 = new Event();
|
Event* ev1 = new Event();
|
||||||
ev1->setBrokerSendEvent(client, publish);
|
ev1->setBrokerSendEvent(client, publish);
|
||||||
_gateway->getBrokerSendQue()->post(ev1);
|
_gateway->getBrokerSendQue()->post(ev1);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return publish;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MQTTSNPublishHandler::handlePuback(Client* client, MQTTSNPacket* packet)
|
void MQTTSNPublishHandler::handlePuback(Client* client, MQTTSNPacket* packet)
|
||||||
|
|||||||
@@ -54,14 +54,9 @@ void QoSm1Proxy::initialize(void)
|
|||||||
/* Create QoS-1 Clients */
|
/* Create QoS-1 Clients */
|
||||||
_gateway->getClientList()->setClientList(QOSM1PROXY_TYPE);
|
_gateway->getClientList()->setClientList(QOSM1PROXY_TYPE);
|
||||||
|
|
||||||
/* set ClientId of this Proxy */
|
|
||||||
const char* name = CLIENTPROXY;
|
|
||||||
if (_gateway->getParam("QoS-1ProxyName", param) == 0 )
|
|
||||||
{
|
|
||||||
name = param;
|
|
||||||
}
|
|
||||||
/* initialize Adapter */
|
/* initialize Adapter */
|
||||||
setup(name, Atype_QoSm1Proxy);
|
string name = string(_gateway->getGWParams()->gatewayName) + "QoS-1";
|
||||||
|
setup(name.c_str(), Atype_QoSm1Proxy);
|
||||||
_isActive = true;
|
_isActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ namespace MQTTSNGW
|
|||||||
#define CLIENT "Client"
|
#define CLIENT "Client"
|
||||||
#define CLIENTS "Clients"
|
#define CLIENTS "Clients"
|
||||||
#define UNKNOWNCL "Unknown Client !"
|
#define UNKNOWNCL "Unknown Client !"
|
||||||
#define CLIENTPROXY "ClientProxy"
|
|
||||||
#define CLIENTPROXY_SECURE "ClientProxyS"
|
|
||||||
|
|
||||||
#define LEFTARROW "<---"
|
#define LEFTARROW "<---"
|
||||||
#define RIGHTARROW "--->"
|
#define RIGHTARROW "--->"
|
||||||
|
|||||||
Reference in New Issue
Block a user