First Commit of MQTT-SN Gateway

Add    new SensorNetwork XBee
Add    a sensor network type in a start message.
Update MQTTSNClient to avoid build warning.
Update WiringPi's functions to my original ones. 
BugFix check msgId before adding waitdTopicId table.
BugFix Process termination procedures
Update print curent time in millseconds.
update move currentDateTime() to linux directory.
Bugfix: blink blue lightiIndicator.
Bugfix: Register returns wrong id.
change a status of the client to Disconnected.
change client status procedure
Update README
BugFix: change Network Disconnect procedures.

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2016-05-13 19:18:47 +09:00
parent 826b2a83b0
commit 64fa07b391
63 changed files with 9206 additions and 1138 deletions

View File

@@ -1,36 +1,145 @@
/**************************************************************************************
* Copyright (c) 2016, Tomoaki Yamaguchi
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
**************************************************************************************/
#ifndef THREADING_H_
#define THREADING_H_
extern "C"
{
#include "Thread.h"
}
#include <pthread.h>
#include <semaphore.h>
#include "MQTTSNGWDefines.h"
class Thread
namespace MQTTSNGW
{
/*
Thread(void (*fn)(void const *argument), void *argument)
{
Thread_start(fn, arg);
}*/
public:
Thread(void (*fn)(void const *argument))
{
const void* arg = NULL;
//Thread_start((void (*)(void *))fn, arg);
}
};
#define MQTTSNGW_RINGBUFFER_KEY "/usr/local/etc/mqttsnGateway/config/ringbuffer.key"
#define MQTTSNGW_RB_MUTEX_KEY "/usr/local/etc/mqttsnGateway/config/rbmutex.key"
#define MQTTSNGW_RB_SEMAPHOR_NAME "/rbsemaphor"
/*=====================================
Class Mutex
====================================*/
class Mutex
{
public:
Mutex();
Mutex(const char* name);
~Mutex();
void lock(void);
void unlock(void);
private:
pthread_mutex_t _mutex;
pthread_mutex_t* _pmutex;
int _shmid;
};
/*=====================================
Class Semaphore
====================================*/
class Semaphore
{
public:
Semaphore();
Semaphore(unsigned int val);
Semaphore(const char* name, unsigned int val);
~Semaphore();
void post(void);
void wait(void);
void timedwait(uint16_t millsec);
private:
sem_t* _psem;
sem_t _sem;
char* _name;
};
/*=====================================
Class RingBuffer
=====================================*/
class RingBuffer
{
public:
RingBuffer();
~RingBuffer();
void put(char* buffer);
int get(char* buffer, int bufferLength);
void reset();
private:
void* _shmaddr;
uint16_t* _length;
uint16_t* _start;
uint16_t* _end;
char* _buffer;
int _shmid;
Mutex* _pmx;
bool _createFlg;
};
/*=====================================
Class Runnable
====================================*/
class Runnable
{
public:
Runnable(){}
virtual ~Runnable(){}
virtual void EXECRUN(){}
};
#define MAGIC_WORD_FOR_THREAD \
public: void EXECRUN() \
{ \
try \
{ \
run(); \
} \
catch(Exception& ex) \
{ \
ex.writeMessage();\
stopProcess(); \
} \
catch(...) \
{ \
throw; \
} \
}
/*=====================================
Class Thread
====================================*/
class Thread : virtual public Runnable{
public:
Thread();
~Thread();
int start(void);
static pthread_t getID();
static bool equals(pthread_t*, pthread_t*);
virtual void initialize(int argc, char** argv);
void stopProcess(void);
void testThreadCancel(void);
private:
pthread_t _threadID;
Semaphore* _stopProcessEvent;
static void* _run(void*);
};
}
#endif /* THREADING_H_ */