Update: DISCONNECT (Issue #31) and others

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2016-10-03 11:17:35 +09:00
parent 76f58a60a3
commit 93df7db12e
22 changed files with 192 additions and 150 deletions

View File

@@ -248,6 +248,7 @@ Network::~Network()
{
if (_ssl)
{
SSL_shutdown(_ssl);
SSL_free(_ssl);
_numOfInstance--;
}
@@ -351,7 +352,7 @@ bool Network::connect(const char* host, const char* port, const char* caPath, co
SSL_free(_ssl);
}
SSL_set_options(_ssl, SSL_OP_NO_TICKET);
//SSL_set_options(_ssl, SSL_OP_NO_TICKET);
if ( cert )
{
@@ -535,6 +536,7 @@ int Network::recv(uint8_t* buf, uint16_t len)
case SSL_ERROR_ZERO_RETURN:
SSL_shutdown(_ssl);
_ssl = 0;
_numOfInstance--;
TCPStack::close();
_busy = false;
_mutex.unlock();

View File

@@ -236,7 +236,7 @@ void Semaphore::timedwait(uint16_t millsec)
=========================================*/
RingBuffer::RingBuffer()
{
RingBuffer(MQTTSNGW_CONFIG_DIRECTORY);
RingBuffer(MQTTSNGW_KEY_DIRECTORY);
}
RingBuffer::RingBuffer(const char* keyDirectory)

View File

@@ -23,7 +23,7 @@
namespace MQTTSNGW
{
#define MQTTSNGW_KEY_DIRECTORY "./"
#define MQTTSNGW_RINGBUFFER_KEY "ringbuffer.key"
#define MQTTSNGW_RB_MUTEX_KEY "rbmutex.key"
#define MQTTSNGW_RB_SEMAPHOR_NAME "/rbsemaphor"

View File

@@ -180,24 +180,30 @@ void LightIndicator::init()
pinMode(LIGHT_INDICATOR_BLUE);
}
void LightIndicator::lit(int gpioNo, const char* onoff)
int LightIndicator::lit(int gpioNo, const char* onoff)
{
int rc = 0;
if( _gpio[gpioNo] )
{
write(_gpio[gpioNo], onoff, 1);
rc = write(_gpio[gpioNo], onoff, 1);
}
return rc;
}
void LightIndicator::pinMode(int gpioNo)
{
int fd = open("/sys/class/gpio/export", O_WRONLY);
int rc = 0;
int fd = rc; // eliminate unused warnning of compiler
fd = open("/sys/class/gpio/export", O_WRONLY);
if ( fd < 0 )
{
return;
}
char no[4];
sprintf(no,"%d", gpioNo);
write(fd, no, strlen(no));
rc = write(fd, no, strlen(no));
close(fd);
char fileName[64];
@@ -208,9 +214,8 @@ void LightIndicator::pinMode(int gpioNo)
{
return;
}
write(fd,"out", 3);
rc = write(fd,"out", 3);
close(fd);
sprintf( fileName, "/sys/class/gpio/gpio%d/value", gpioNo);
fd = open(fileName, O_WRONLY);
if ( fd > 0 )

View File

@@ -61,7 +61,7 @@ public:
private:
void init();
void lit(int gpioNo, const char* onoff);
int lit(int gpioNo, const char* onoff);
void pinMode(int gpioNo);
bool _greenStatus;
int _gpio[MAX_GPIO + 1];

View File

@@ -141,7 +141,7 @@ int SensorNetwork::initialize(void)
if (theProcess->getParam("GatewayPortNo", param) == 0)
{
unicastPortNo = atoi(param);
_description += " and Gateway Port ";
_description += " Gateway Port ";
_description += param;
}