Merge pull request #130 from eclipse/develop

Install the gateway into any directories. #124
This commit is contained in:
Tomoaki Yamaguchi
2018-08-18 12:23:19 +09:00
committed by GitHub
11 changed files with 37 additions and 16 deletions

View File

@@ -18,6 +18,9 @@ OS := linux
SENSORNET := udp
TEST := tests
INSTALL_DIR=../../
CONFIG_DIR=../../
CPPSRCS := \
$(SRCDIR)/MQTTGWConnectionHandler.cpp \
$(SRCDIR)/MQTTGWPacket.cpp \
@@ -143,11 +146,11 @@ clean:
rm -rf $(OUTDIR)
install:
cp -pf $(PROG) ../../
cp -pf $(LPROG) ../../
cp -pf $(CONFIG) ../../
cp -pf $(CLIENTS) ../../
cp -pf $(PREDEFTOPIC) ../../
cp -pf $(PROG) $(INSTALL_DIR)
cp -pf $(LPROG) $(INSTALL_DIR)
cp -pf $(CONFIG) $(CONFIG_DIR)
cp -pf $(CLIENTS) $(CONFIG_DIR)
cp -pf $(PREDEFTOPIC) $(CONFIG_DIR)
exectest:

View File

@@ -8,7 +8,11 @@ $ make
$ make install
$ make clean
````
MQTT-SNGateway, MQTT-SNLogmonitor and param.conf are copied into ../ directory.
MQTT-SNGateway, MQTT-SNLogmonitor and *.conf files are copied into ../ directory.
If you want to install the gateway into specific directories, enter a command line as follows:
````
$ make install INSTALL_DIR=/path/to/your_directory CONFIG_DIR=/path/to/your_directory
````
### **step2. Execute the Gateway.**

View File

@@ -116,6 +116,7 @@ typedef struct
unsigned char version; /**< MQTT version number */
} Connect;
#define MQTTPacket_Connect_Initializer {{0}, 0, nullptr, nullptr, nullptr, nullptr, 0, 0}
#define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }
#define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \
MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }
@@ -173,6 +174,7 @@ typedef struct
int payloadlen; /**< payload length */
} Publish;
#define MQTTPacket_Publish_Initializer {{0}, nullptr, 0, 0, nullptr, 0}
/**
* Data for one of the ack packets.

View File

@@ -104,7 +104,7 @@ void BrokerRecvTask::run(void)
{
client = _gateway->getClientList()->getClient(0);
while (client > 0)
while ( client )
{
_light->blueLight(false);
if (client->getNetwork()->isValid())

View File

@@ -44,7 +44,7 @@ Client::Client(bool secure)
_clientId = nullptr;
_willTopic = nullptr;
_willMsg = nullptr;
_connectData = {0, 0, 0, 0, 0, 0, 0};
_connectData = MQTTPacket_Connect_Initializer;
_network = new Network(secure);
_secureNetwork = secure;
_sensorNetype = true;

View File

@@ -39,7 +39,6 @@ public:
private:
void sendStoredPublish(Client* client);
char _pbuf[MQTTSNGW_MAX_PACKET_SIZE * 3];
Gateway* _gateway;
};

View File

@@ -44,7 +44,7 @@ MQTTGWPacket* MQTTSNPublishHandler::handlePublish(Client* client, MQTTSNPacket*
uint8_t* payload;
MQTTSN_topicid topicid;
int payloadlen;
Publish pub = {0, 0, 0, 0, 0, 0};
Publish pub = MQTTPacket_Publish_Initializer;
char shortTopic[2];

View File

@@ -443,7 +443,7 @@ TopicIdMapElement* TopicIdMap::add(uint16_t msgId, uint16_t topicId, MQTTSN_topi
{
return 0;
}
if ( getElement(msgId) > 0 )
if ( getElement(msgId) )
{
erase(msgId);
}

View File

@@ -191,11 +191,6 @@ void Gateway::initialize(int argc, char** argv)
_params.keepAlive = atoi(param);
}
if (_params.keepAlive > 65536)
{
throw Exception("Gateway::initialize: KeepAliveTime is grater than 65536 Secs");
}
if (getParam("LoginID", param) == 0)
{
_params.loginId = strdup(param);

View File

@@ -274,4 +274,20 @@ exit:
return rc;
}
int MQTTSNPacket_read_nb(unsigned char* buf, int buflen)
{
int rc = MQTTSNPACKET_READ_ERROR;
int len = buflen; /* the length of the whole packet including length field */
int lenlen = 0;
int datalen = 0;
/* 2. read the length. This is variable in itself */
lenlen = MQTTSNPacket_decode(buf, len, &datalen);
if (datalen != len)
goto exit; /* there was an error */
rc = buf[lenlen]; /* return the packet type */
exit:
return rc;
}

View File

@@ -143,6 +143,8 @@ void writeCString(unsigned char** pptr, char* string);
void writeMQTTSNString(unsigned char** pptr, MQTTSNString mqttstring);
int MQTTSNPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));
int MQTTSNPacket_read_nb(unsigned char* buf, int buflen);
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
}