mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-14 07:56:52 +01:00
Update: DISCONNECT (Issue #31) and others
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user