mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-15 16:36:52 +01:00
Bugfix check network status after initialization.
future branch is merged into develop. #69 Change Tab to 4 spaces Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -68,7 +68,11 @@ LGwProxy::~LGwProxy()
|
|||||||
|
|
||||||
void LGwProxy::initialize(SENSORNET_CONFIG_t* netconf, LMqttsnConfig* mqconf)
|
void LGwProxy::initialize(SENSORNET_CONFIG_t* netconf, LMqttsnConfig* mqconf)
|
||||||
{
|
{
|
||||||
_network.initialize(netconf);
|
if (_network.initialize(netconf) == false)
|
||||||
|
{
|
||||||
|
DISPLAY("Can't open SensorNetwork\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
_clientId = netconf->clientId;
|
_clientId = netconf->clientId;
|
||||||
_willTopic = mqconf->willTopic;
|
_willTopic = mqconf->willTopic;
|
||||||
_willMsg = mqconf->willMsg;
|
_willMsg = mqconf->willMsg;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
|
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
|
||||||
**************************************************************************************/
|
**************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -34,32 +33,37 @@ extern bool theClientMode;
|
|||||||
/*=====================================
|
/*=====================================
|
||||||
TaskManager
|
TaskManager
|
||||||
======================================*/
|
======================================*/
|
||||||
LTaskManager::LTaskManager(void){
|
LTaskManager::LTaskManager(void)
|
||||||
|
{
|
||||||
_tasks = 0;
|
_tasks = 0;
|
||||||
_tests = 0;
|
_tests = 0;
|
||||||
_index = 0;
|
_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LTaskManager::~LTaskManager(void){
|
LTaskManager::~LTaskManager(void)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTaskManager::add(TaskList* task){
|
void LTaskManager::add(TaskList* task)
|
||||||
|
{
|
||||||
_tasks = task;
|
_tasks = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTaskManager::add(TestList* test){
|
void LTaskManager::add(TestList* test)
|
||||||
|
{
|
||||||
_tests = test;
|
_tests = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTaskManager::run(void){
|
void LTaskManager::run(void)
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char c = 0;
|
char c = 0;
|
||||||
bool cancelFlg = false;
|
bool cancelFlg = false;
|
||||||
TestList test = {0};
|
TestList test = { 0 };
|
||||||
TaskList task = {0};
|
TaskList task = { 0 };
|
||||||
|
|
||||||
if ( !theClientMode )
|
if (!theClientMode)
|
||||||
{
|
{
|
||||||
theClient->getGwProxy()->getMessage();
|
theClient->getGwProxy()->getMessage();
|
||||||
|
|
||||||
@@ -70,7 +74,7 @@ void LTaskManager::run(void){
|
|||||||
{
|
{
|
||||||
if (CHECKKEYIN(&c))
|
if (CHECKKEYIN(&c))
|
||||||
{
|
{
|
||||||
if ( toupper(c) == 'N' )
|
if (toupper(c) == 'N')
|
||||||
{
|
{
|
||||||
|
|
||||||
DISPLAY("\033[0m\033[0;32m\n**** %s is canceled ****\033[0m\033[0;37m\n\n", _tests[i].testLabel);
|
DISPLAY("\033[0m\033[0;32m\n**** %s is canceled ****\033[0m\033[0;37m\n\n", _tests[i].testLabel);
|
||||||
@@ -78,7 +82,7 @@ void LTaskManager::run(void){
|
|||||||
cancelFlg = true;
|
cancelFlg = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ( toupper(c) == 'Y' )
|
else if (toupper(c) == 'Y')
|
||||||
{
|
{
|
||||||
DISPLAY("\033[0m\033[0;32m\n\n**** %s start ****\033[0m\033[0;37m\n", _tests[i].testLabel);
|
DISPLAY("\033[0m\033[0;32m\n\n**** %s start ****\033[0m\033[0;37m\n", _tests[i].testLabel);
|
||||||
theScreen->prompt("");
|
theScreen->prompt("");
|
||||||
@@ -93,22 +97,21 @@ void LTaskManager::run(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( true )
|
while (true)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
theClient->getGwProxy()->getMessage();
|
theClient->getGwProxy()->getMessage();
|
||||||
}
|
}
|
||||||
while(theClient->getPublishManager()->isMaxFlight() ||
|
while (theClient->getPublishManager()->isMaxFlight() || !theClient->getSubscribeManager()->isDone()
|
||||||
!theClient->getSubscribeManager()->isDone() ||
|
|| !theClient->getRegisterManager()->isDone());
|
||||||
!theClient->getRegisterManager()->isDone());
|
|
||||||
|
|
||||||
if (theClient->getPublishManager()->isDone())
|
if (theClient->getPublishManager()->isDone())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !cancelFlg )
|
if (!cancelFlg)
|
||||||
{
|
{
|
||||||
DISPLAY("\033[0m\033[0;32m\n**** %s complete ****\033[0m\033[0;37m\n\n", _tests[i].testLabel);
|
DISPLAY("\033[0m\033[0;32m\n**** %s complete ****\033[0m\033[0;37m\n\n", _tests[i].testLabel);
|
||||||
}
|
}
|
||||||
@@ -122,8 +125,7 @@ void LTaskManager::run(void){
|
|||||||
theClient->getGwProxy()->getMessage();
|
theClient->getGwProxy()->getMessage();
|
||||||
for (_index = 0; _tasks[_index].callback > task.callback; _index++)
|
for (_index = 0; _tasks[_index].callback > task.callback; _index++)
|
||||||
{
|
{
|
||||||
if ((_tasks[_index].prevTime + _tasks[_index].interval <= time(NULL)) &&
|
if ((_tasks[_index].prevTime + _tasks[_index].interval <= time(NULL)) && _tasks[_index].count == 0)
|
||||||
_tasks[_index].count == 0)
|
|
||||||
{
|
{
|
||||||
_tasks[_index].prevTime = time(NULL);
|
_tasks[_index].prevTime = time(NULL);
|
||||||
(_tasks[_index].callback)();
|
(_tasks[_index].callback)();
|
||||||
@@ -134,9 +136,8 @@ void LTaskManager::run(void){
|
|||||||
{
|
{
|
||||||
theClient->getGwProxy()->getMessage();
|
theClient->getGwProxy()->getMessage();
|
||||||
}
|
}
|
||||||
while(theClient->getPublishManager()->isMaxFlight() ||
|
while (theClient->getPublishManager()->isMaxFlight() || !theClient->getSubscribeManager()->isDone()
|
||||||
!theClient->getSubscribeManager()->isDone() ||
|
|| !theClient->getRegisterManager()->isDone());
|
||||||
!theClient->getRegisterManager()->isDone());
|
|
||||||
|
|
||||||
if (theClient->getPublishManager()->isDone())
|
if (theClient->getPublishManager()->isDone())
|
||||||
{
|
{
|
||||||
@@ -146,19 +147,21 @@ void LTaskManager::run(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t LTaskManager::getIndex(void){
|
uint8_t LTaskManager::getIndex(void)
|
||||||
|
{
|
||||||
return _index;
|
return _index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTaskManager::done(uint8_t index){
|
void LTaskManager::done(uint8_t index)
|
||||||
if (_tasks )
|
{
|
||||||
|
if (_tasks)
|
||||||
{
|
{
|
||||||
if (_tasks[index].count > 0)
|
if (_tasks[index].count > 0)
|
||||||
{
|
{
|
||||||
_tasks[index].count--;
|
_tasks[index].count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_tests )
|
if (_tests)
|
||||||
{
|
{
|
||||||
if (_tests[index].count > 0)
|
if (_tests[index].count > 0)
|
||||||
{
|
{
|
||||||
@@ -167,12 +170,13 @@ void LTaskManager::done(uint8_t index){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LTaskManager::suspend(uint8_t index){
|
void LTaskManager::suspend(uint8_t index)
|
||||||
if ( _tasks )
|
{
|
||||||
|
if (_tasks)
|
||||||
{
|
{
|
||||||
_tasks[index].count++;
|
_tasks[index].count++;
|
||||||
}
|
}
|
||||||
if ( _tests )
|
if (_tests)
|
||||||
{
|
{
|
||||||
_tests[index].count++;
|
_tests[index].count++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user