Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2018-02-27 11:50:13 +09:00
parent e17c29978d
commit 301814cc26
3 changed files with 24 additions and 10 deletions

View File

@@ -735,6 +735,7 @@ uint16_t Topic::getTopicId(void)
bool Topic::isMatch(string* topicName)
{
string::size_type tlen = _topicName->size();
if (topicName->size() < tlen - 2)
{
return false;

View File

@@ -17,6 +17,6 @@
#ifndef MQTTSNGWVERSION_H_IN_
#define MQTTSNGWVERSION_H_IN_
#define PAHO_GATEWAY_VERSION "1.0.0"
#define PAHO_GATEWAY_VERSION "1.0.1"
#endif /* MQTTSNGWVERSION_H_IN_ */

View File

@@ -20,6 +20,9 @@
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>
#include "SensorNetwork.h"
#include "MQTTSNGWProcess.h"
@@ -238,6 +241,10 @@ int XBee::recv(uint8_t* buf, uint16_t bufLen, SensorNetAddress* clientAddr)
_sem.post();
}
}
else
{
return 0;
}
}
}
@@ -451,15 +458,21 @@ bool SerialPort::send(unsigned char b)
bool SerialPort::recv(unsigned char* buf)
{
if (read(_fd, buf, 1) == 0)
struct timeval timeout;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(_fd, &rfds);
timeout.tv_sec = 0;
timeout.tv_usec = 500000; // 500ms
if ( select(1, &rfds, 0, 0, &timeout) > 0 )
{
return false;
}
else
if (read(_fd, buf, 1) > 0)
{
D_NWSTACK( " %02x",buf[0] );
return true;
}
}
return false;
}
void SerialPort::flush(void)