mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-15 16:36:52 +01:00
Merge pull request #130 from eclipse/develop
Install the gateway into any directories. #124
This commit is contained in:
@@ -18,6 +18,9 @@ OS := linux
|
|||||||
SENSORNET := udp
|
SENSORNET := udp
|
||||||
TEST := tests
|
TEST := tests
|
||||||
|
|
||||||
|
INSTALL_DIR=../../
|
||||||
|
CONFIG_DIR=../../
|
||||||
|
|
||||||
CPPSRCS := \
|
CPPSRCS := \
|
||||||
$(SRCDIR)/MQTTGWConnectionHandler.cpp \
|
$(SRCDIR)/MQTTGWConnectionHandler.cpp \
|
||||||
$(SRCDIR)/MQTTGWPacket.cpp \
|
$(SRCDIR)/MQTTGWPacket.cpp \
|
||||||
@@ -143,11 +146,11 @@ clean:
|
|||||||
rm -rf $(OUTDIR)
|
rm -rf $(OUTDIR)
|
||||||
|
|
||||||
install:
|
install:
|
||||||
cp -pf $(PROG) ../../
|
cp -pf $(PROG) $(INSTALL_DIR)
|
||||||
cp -pf $(LPROG) ../../
|
cp -pf $(LPROG) $(INSTALL_DIR)
|
||||||
cp -pf $(CONFIG) ../../
|
cp -pf $(CONFIG) $(CONFIG_DIR)
|
||||||
cp -pf $(CLIENTS) ../../
|
cp -pf $(CLIENTS) $(CONFIG_DIR)
|
||||||
cp -pf $(PREDEFTOPIC) ../../
|
cp -pf $(PREDEFTOPIC) $(CONFIG_DIR)
|
||||||
|
|
||||||
|
|
||||||
exectest:
|
exectest:
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ $ make
|
|||||||
$ make install
|
$ make install
|
||||||
$ make clean
|
$ 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.**
|
### **step2. Execute the Gateway.**
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ typedef struct
|
|||||||
unsigned char version; /**< MQTT version number */
|
unsigned char version; /**< MQTT version number */
|
||||||
} Connect;
|
} 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_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, \
|
#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}} }
|
MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }
|
||||||
@@ -173,6 +174,7 @@ typedef struct
|
|||||||
int payloadlen; /**< payload length */
|
int payloadlen; /**< payload length */
|
||||||
} Publish;
|
} Publish;
|
||||||
|
|
||||||
|
#define MQTTPacket_Publish_Initializer {{0}, nullptr, 0, 0, nullptr, 0}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data for one of the ack packets.
|
* Data for one of the ack packets.
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ void BrokerRecvTask::run(void)
|
|||||||
{
|
{
|
||||||
client = _gateway->getClientList()->getClient(0);
|
client = _gateway->getClientList()->getClient(0);
|
||||||
|
|
||||||
while (client > 0)
|
while ( client )
|
||||||
{
|
{
|
||||||
_light->blueLight(false);
|
_light->blueLight(false);
|
||||||
if (client->getNetwork()->isValid())
|
if (client->getNetwork()->isValid())
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ Client::Client(bool secure)
|
|||||||
_clientId = nullptr;
|
_clientId = nullptr;
|
||||||
_willTopic = nullptr;
|
_willTopic = nullptr;
|
||||||
_willMsg = nullptr;
|
_willMsg = nullptr;
|
||||||
_connectData = {0, 0, 0, 0, 0, 0, 0};
|
_connectData = MQTTPacket_Connect_Initializer;
|
||||||
_network = new Network(secure);
|
_network = new Network(secure);
|
||||||
_secureNetwork = secure;
|
_secureNetwork = secure;
|
||||||
_sensorNetype = true;
|
_sensorNetype = true;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void sendStoredPublish(Client* client);
|
void sendStoredPublish(Client* client);
|
||||||
|
|
||||||
char _pbuf[MQTTSNGW_MAX_PACKET_SIZE * 3];
|
|
||||||
Gateway* _gateway;
|
Gateway* _gateway;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ MQTTGWPacket* MQTTSNPublishHandler::handlePublish(Client* client, MQTTSNPacket*
|
|||||||
uint8_t* payload;
|
uint8_t* payload;
|
||||||
MQTTSN_topicid topicid;
|
MQTTSN_topicid topicid;
|
||||||
int payloadlen;
|
int payloadlen;
|
||||||
Publish pub = {0, 0, 0, 0, 0, 0};
|
Publish pub = MQTTPacket_Publish_Initializer;
|
||||||
|
|
||||||
char shortTopic[2];
|
char shortTopic[2];
|
||||||
|
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ TopicIdMapElement* TopicIdMap::add(uint16_t msgId, uint16_t topicId, MQTTSN_topi
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( getElement(msgId) > 0 )
|
if ( getElement(msgId) )
|
||||||
{
|
{
|
||||||
erase(msgId);
|
erase(msgId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,11 +191,6 @@ void Gateway::initialize(int argc, char** argv)
|
|||||||
_params.keepAlive = atoi(param);
|
_params.keepAlive = atoi(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_params.keepAlive > 65536)
|
|
||||||
{
|
|
||||||
throw Exception("Gateway::initialize: KeepAliveTime is grater than 65536 Secs");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getParam("LoginID", param) == 0)
|
if (getParam("LoginID", param) == 0)
|
||||||
{
|
{
|
||||||
_params.loginId = strdup(param);
|
_params.loginId = strdup(param);
|
||||||
|
|||||||
@@ -274,4 +274,20 @@ exit:
|
|||||||
return rc;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ void writeCString(unsigned char** pptr, char* string);
|
|||||||
void writeMQTTSNString(unsigned char** pptr, MQTTSNString mqttstring);
|
void writeMQTTSNString(unsigned char** pptr, MQTTSNString mqttstring);
|
||||||
|
|
||||||
int MQTTSNPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));
|
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 */
|
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user