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:
tomoaki
2021-06-07 18:49:51 +09:00
parent 85ae4e3596
commit 83c30d662f
2 changed files with 130 additions and 122 deletions

View File

@@ -68,7 +68,11 @@ LGwProxy::~LGwProxy()
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;
_willTopic = mqconf->willTopic;
_willMsg = mqconf->willMsg;

View File

@@ -14,7 +14,6 @@
* Tomoaki Yamaguchi - initial API and implementation and/or initial documentation
**************************************************************************************/
#include <stdio.h>
#include <string.h>
@@ -34,32 +33,37 @@ extern bool theClientMode;
/*=====================================
TaskManager
======================================*/
LTaskManager::LTaskManager(void){
LTaskManager::LTaskManager(void)
{
_tasks = 0;
_tests = 0;
_index = 0;
}
LTaskManager::~LTaskManager(void){
LTaskManager::~LTaskManager(void)
{
}
void LTaskManager::add(TaskList* task){
void LTaskManager::add(TaskList* task)
{
_tasks = task;
}
void LTaskManager::add(TestList* test){
void LTaskManager::add(TestList* test)
{
_tests = test;
}
void LTaskManager::run(void){
void LTaskManager::run(void)
{
int i = 0;
char c = 0;
bool cancelFlg = false;
TestList test = {0};
TaskList task = {0};
TestList test = { 0 };
TaskList task = { 0 };
if ( !theClientMode )
if (!theClientMode)
{
theClient->getGwProxy()->getMessage();
@@ -70,7 +74,7 @@ void LTaskManager::run(void){
{
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);
@@ -78,7 +82,7 @@ void LTaskManager::run(void){
cancelFlg = true;
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);
theScreen->prompt("");
@@ -93,22 +97,21 @@ void LTaskManager::run(void){
}
}
while ( true )
while (true)
{
do
{
theClient->getGwProxy()->getMessage();
}
while(theClient->getPublishManager()->isMaxFlight() ||
!theClient->getSubscribeManager()->isDone() ||
!theClient->getRegisterManager()->isDone());
while (theClient->getPublishManager()->isMaxFlight() || !theClient->getSubscribeManager()->isDone()
|| !theClient->getRegisterManager()->isDone());
if (theClient->getPublishManager()->isDone())
{
break;
}
}
if ( !cancelFlg )
if (!cancelFlg)
{
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();
for (_index = 0; _tasks[_index].callback > task.callback; _index++)
{
if ((_tasks[_index].prevTime + _tasks[_index].interval <= time(NULL)) &&
_tasks[_index].count == 0)
if ((_tasks[_index].prevTime + _tasks[_index].interval <= time(NULL)) && _tasks[_index].count == 0)
{
_tasks[_index].prevTime = time(NULL);
(_tasks[_index].callback)();
@@ -134,9 +136,8 @@ void LTaskManager::run(void){
{
theClient->getGwProxy()->getMessage();
}
while(theClient->getPublishManager()->isMaxFlight() ||
!theClient->getSubscribeManager()->isDone() ||
!theClient->getRegisterManager()->isDone());
while (theClient->getPublishManager()->isMaxFlight() || !theClient->getSubscribeManager()->isDone()
|| !theClient->getRegisterManager()->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;
}
void LTaskManager::done(uint8_t index){
if (_tasks )
void LTaskManager::done(uint8_t index)
{
if (_tasks)
{
if (_tasks[index].count > 0)
{
_tasks[index].count--;
}
}
if (_tests )
if (_tests)
{
if (_tests[index].count > 0)
{
@@ -167,12 +170,13 @@ void LTaskManager::done(uint8_t index){
}
}
void LTaskManager::suspend(uint8_t index){
if ( _tasks )
void LTaskManager::suspend(uint8_t index)
{
if (_tasks)
{
_tasks[index].count++;
}
if ( _tests )
if (_tests)
{
_tests[index].count++;
}