Update: change a macro name from ASSERT to DISPLAY

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2017-05-08 18:49:10 +09:00
parent 0adfac47da
commit e341d1a326
9 changed files with 39 additions and 39 deletions

View File

@@ -40,7 +40,7 @@ extern int run(void);
* *
* void DISCONNECT ( uint16_t sleepInSecs ); * void DISCONNECT ( uint16_t sleepInSecs );
* *
* void ASSERT( format, valiables, .....); <== instead of printf() * void DISPLAY( format, valiables, .....); <== instead of printf()
* *
*/ */

View File

@@ -40,7 +40,7 @@ extern int run(void);
* *
* void DISCONNECT ( uint16_t sleepInSecs ); * void DISCONNECT ( uint16_t sleepInSecs );
* *
* void ASSERT( format, .....); <== instead of printf() * void DISPLAY( format, .....); <== instead of printf()
* *
*/ */
/*------------------------------------------------------ /*------------------------------------------------------
@@ -81,26 +81,26 @@ const char* topic3 = "ty4tw/topic3";
*------------------------------------------------------*/ *------------------------------------------------------*/
int on_Topic01(uint8_t* pload, uint16_t ploadlen) int on_Topic01(uint8_t* pload, uint16_t ploadlen)
{ {
ASSERT("\n\nTopic1 recv.\n"); DISPLAY("\n\nTopic1 recv.\n");
char c = pload[ploadlen-1]; char c = pload[ploadlen-1];
pload[ploadlen-1]= 0; // set null terminator pload[ploadlen-1]= 0; // set null terminator
ASSERT("Payload -->%s%c<--\n\n",pload, c); DISPLAY("Payload -->%s%c<--\n\n",pload, c);
return 0; return 0;
} }
int on_Topic02(uint8_t* pload, uint16_t ploadlen) int on_Topic02(uint8_t* pload, uint16_t ploadlen)
{ {
ASSERT("\n\nTopic2 recv.\n"); DISPLAY("\n\nTopic2 recv.\n");
pload[ploadlen-1]= 0; // set null terminator pload[ploadlen-1]= 0; // set null terminator
ASSERT("Payload -->%s <--\n\n",pload); DISPLAY("Payload -->%s <--\n\n",pload);
return 0; return 0;
} }
int on_Topic03(uint8_t* pload, uint16_t ploadlen) int on_Topic03(uint8_t* pload, uint16_t ploadlen)
{ {
ASSERT("\n\nNew callback recv Topic2\n"); DISPLAY("\n\nNew callback recv Topic2\n");
pload[ploadlen-1]= 0; // set null terminator pload[ploadlen-1]= 0; // set null terminator
ASSERT("Payload -->%s <--\n\n",pload); DISPLAY("Payload -->%s <--\n\n",pload);
return 0; return 0;
} }

View File

@@ -165,7 +165,7 @@ int LGwProxy::getConnectResponce(void){
_connectRetry = MQTTSN_RETRY_COUNT; _connectRetry = MQTTSN_RETRY_COUNT;
_keepAliveTimer.start(_tkeepAlive * 1000); _keepAliveTimer.start(_tkeepAlive * 1000);
_topicTbl.clearTopic(); _topicTbl.clearTopic();
ASSERT("\033[0m\033[0;32m\n\n Connected to the Broker\033[0m\033[0;37m\n\n"); DISPLAY("\033[0m\033[0;32m\n\n Connected to the Broker\033[0m\033[0;37m\n\n");
theClient->onConnect(); // SUBSCRIBEs are conducted theClient->onConnect(); // SUBSCRIBEs are conducted
}else{ }else{
_status = GW_CONNECTING; _status = GW_CONNECTING;
@@ -201,7 +201,7 @@ void LGwProxy::disconnect(uint16_t secs){
while ( _status != GW_DISCONNECTED && _status != GW_SLEPT){ while ( _status != GW_DISCONNECTED && _status != GW_SLEPT){
if (getDisconnectResponce() < 0){ if (getDisconnectResponce() < 0){
_status = GW_LOST; _status = GW_LOST;
ASSERT("\033[0m\033[0;31m\n\n!!!!!! DISCONNECT Error !!!!!\033[0m\033[0;37m \n\n"); DISPLAY("\033[0m\033[0;31m\n\n!!!!!! DISCONNECT Error !!!!!\033[0m\033[0;37m \n\n");
return; return;
} }
} }
@@ -331,7 +331,7 @@ int LGwProxy::writeMsg(const uint8_t* msg){
if (rc > 0){ if (rc > 0){
if ( msg[pos] >= MQTTSN_TYPE_ADVERTISE && msg[pos] <= MQTTSN_TYPE_WILLMSGRESP ) if ( msg[pos] >= MQTTSN_TYPE_ADVERTISE && msg[pos] <= MQTTSN_TYPE_WILLMSGRESP )
{ {
ASSERT(" send %s\n", packet_names[msg[pos]]); DISPLAY(" send %s\n", packet_names[msg[pos]]);
} }
return rc; return rc;
} }
@@ -365,7 +365,7 @@ int LGwProxy::readMsg(void){
} }
if ( *_mqttsnMsg >= MQTTSN_TYPE_ADVERTISE && *_mqttsnMsg <= MQTTSN_TYPE_WILLMSGRESP ) if ( *_mqttsnMsg >= MQTTSN_TYPE_ADVERTISE && *_mqttsnMsg <= MQTTSN_TYPE_WILLMSGRESP )
{ {
ASSERT(" recv %s\n", packet_names[*_mqttsnMsg]); DISPLAY(" recv %s\n", packet_names[*_mqttsnMsg]);
} }
return len; return len;
} }

View File

@@ -61,14 +61,14 @@ int run(void)
{ {
if ( toupper(c) == 'N' ) if ( toupper(c) == 'N' )
{ {
ASSERT("\033[0;31m\n**** Sorry ****\033[0;37m\n\n"); DISPLAY("\033[0;31m\n**** Sorry ****\033[0;37m\n\n");
PROMPT(""); PROMPT("");
return 0; return 0;
} }
} }
else if ( toupper(c) == 'Y' ) else if ( toupper(c) == 'Y' )
{ {
ASSERT("\033[0m\033[0;32mAttempting to Connect the Broker.....\033[0m\033[0;37m\n"); DISPLAY("\033[0m\033[0;32mAttempting to Connect the Broker.....\033[0m\033[0;37m\n");
PROMPT(""); PROMPT("");
break; break;
} }

View File

@@ -96,11 +96,11 @@ struct LUdpConfig{
#define UDPCONF LUdpConfig theNetcon #define UDPCONF LUdpConfig theNetcon
#define MQTTSNCONF LMqttsnConfig theMqcon #define MQTTSNCONF LMqttsnConfig theMqcon
#ifdef CLIENT_MODE #ifdef CLIENT_MODE
#define ASSERT(...) #define DISPLAY(...)
#define PROMPT(...) #define PROMPT(...)
#define CHECKKEYIN(...) #define CHECKKEYIN(...) theScreen->checkKeyIn(__VA_ARGS__)
#else #else
#define ASSERT(...) theScreen->display(__VA_ARGS__) #define DISPLAY(...) theScreen->display(__VA_ARGS__)
#define PROMPT(...) theScreen->prompt(__VA_ARGS__) #define PROMPT(...) theScreen->prompt(__VA_ARGS__)
#define CHECKKEYIN(...) theScreen->checkKeyIn(__VA_ARGS__) #define CHECKKEYIN(...) theScreen->checkKeyIn(__VA_ARGS__)
#endif #endif

View File

@@ -191,7 +191,7 @@ bool LUdpPort::open(LUdpConfig config){
if(setsockopt(_sockfdMcast, IPPROTO_IP, IP_MULTICAST_LOOP,(char*)&loopch, sizeof(loopch)) <0 ){ if(setsockopt(_sockfdMcast, IPPROTO_IP, IP_MULTICAST_LOOP,(char*)&loopch, sizeof(loopch)) <0 ){
D_NWLOG("\033[0m\033[0;31merror IP_MULTICAST_LOOP in UdpPPort::open\033[0m\033[0;37m\n"); D_NWLOG("\033[0m\033[0;31merror IP_MULTICAST_LOOP in UdpPPort::open\033[0m\033[0;37m\n");
ASSERT("\033[0m\033[0;31m\nerror IP_MULTICAST_LOOP in UdpPPort::open\033[0m\033[0;37m\n"); DISPLAY("\033[0m\033[0;31m\nerror IP_MULTICAST_LOOP in UdpPPort::open\033[0m\033[0;37m\n");
close(); close();
return false; return false;
} }
@@ -202,7 +202,7 @@ bool LUdpPort::open(LUdpConfig config){
if( setsockopt(_sockfdMcast, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq) )< 0){ if( setsockopt(_sockfdMcast, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq) )< 0){
D_NWLOG("\033[0m\033[0;31merror IP_ADD_MEMBERSHIP in UdpPort::open\033[0m\033[0;37m\n"); D_NWLOG("\033[0m\033[0;31merror IP_ADD_MEMBERSHIP in UdpPort::open\033[0m\033[0;37m\n");
ASSERT("\033[0m\033[0;31m\nerror IP_ADD_MEMBERSHIP in UdpPort::open\033[0m\033[0;37m\n"); DISPLAY("\033[0m\033[0;31m\nerror IP_ADD_MEMBERSHIP in UdpPort::open\033[0m\033[0;37m\n");
close(); close();
return false; return false;
} }
@@ -223,7 +223,7 @@ int LUdpPort::unicast(const uint8_t* buf, uint32_t length, uint32_t ipAddress, u
int status = ::sendto( _sockfdUcast, buf, length, 0, (const sockaddr*)&dest, sizeof(dest) ); int status = ::sendto( _sockfdUcast, buf, length, 0, (const sockaddr*)&dest, sizeof(dest) );
if( status < 0){ if( status < 0){
D_NWLOG("errno == %d in UdpPort::unicast\n", errno); D_NWLOG("errno == %d in UdpPort::unicast\n", errno);
ASSERT("errno == %d in UdpPort::unicast\n", errno); DISPLAY("errno == %d in UdpPort::unicast\n", errno);
}else{ }else{
D_NWLOG("sendto %-15s:%-6u",inet_ntoa(dest.sin_addr),htons(port)); D_NWLOG("sendto %-15s:%-6u",inet_ntoa(dest.sin_addr),htons(port));
for(uint16_t i = 0; i < length ; i++){ for(uint16_t i = 0; i < length ; i++){
@@ -262,14 +262,14 @@ int LUdpPort::multicast( const uint8_t* buf, uint32_t length ){
int status = ::sendto( _sockfdMcast, buf, length, 0, (const sockaddr*)&dest, sizeof(dest) ); int status = ::sendto( _sockfdMcast, buf, length, 0, (const sockaddr*)&dest, sizeof(dest) );
if( status < 0){ if( status < 0){
D_NWLOG("\033[0m\033[0;31merrno == %d in UdpPort::multicast\033[0m\033[0;37m\n", errno); D_NWLOG("\033[0m\033[0;31merrno == %d in UdpPort::multicast\033[0m\033[0;37m\n", errno);
ASSERT("\033[0m\033[0;31merrno == %d in UdpPort::multicast\033[0m\033[0;37m\n", errno); DISPLAY("\033[0m\033[0;31merrno == %d in UdpPort::multicast\033[0m\033[0;37m\n", errno);
return errno; return errno;
}else{ }else{
D_NWLOG("sendto %-15s:%-6u",inet_ntoa(dest.sin_addr),htons(_gPortNo)); D_NWLOG("sendto %-15s:%-6u",inet_ntoa(dest.sin_addr),htons(_gPortNo));
for(uint16_t i = 0; i < length ; i++){ for(uint16_t i = 0; i < length ; i++){
D_NWLOG(" %02x", *(buf + i)); D_NWLOG(" %02x", *(buf + i));
ASSERT(" %02x", *(buf + i)); DISPLAY(" %02x", *(buf + i));
} }
D_NWLOG("\n"); D_NWLOG("\n");
@@ -352,7 +352,7 @@ int LUdpPort::recvfrom (uint8_t* buf, uint16_t length, int flags, uint32_t* ipAd
if (status < 0 && errno != EAGAIN) { if (status < 0 && errno != EAGAIN) {
D_NWLOG("\033[0m\033[0;31merrno == %d in UdpPort::recvfrom \033[0m\033[0;37m\n", errno); D_NWLOG("\033[0m\033[0;31merrno == %d in UdpPort::recvfrom \033[0m\033[0;37m\n", errno);
ASSERT("\033[0m\033[0;31merrno == %d in UdpPort::recvfrom \033[0m\033[0;37m\n", errno); DISPLAY("\033[0m\033[0;31merrno == %d in UdpPort::recvfrom \033[0m\033[0;37m\n", errno);
}else if(status > 0){ }else if(status > 0){
*ipAddressPtr = sender.sin_addr.s_addr; *ipAddressPtr = sender.sin_addr.s_addr;
*portPtr = sender.sin_port; *portPtr = sender.sin_port;

View File

@@ -153,7 +153,7 @@ void LPublishManager::sendPublish(PubElement* elm)
theClient->getGwProxy()->resetPingReqTimer(); theClient->getGwProxy()->resetPingReqTimer();
if ((elm->flag & 0x60) == MQTTSN_FLAG_QOS_0) if ((elm->flag & 0x60) == MQTTSN_FLAG_QOS_0)
{ {
ASSERT("\033[0m\033[0;32m Topic \"%s\" was Published. \033[0m\033[0;37m\n\n", elm->topicName); DISPLAY("\033[0m\033[0;32m Topic \"%s\" was Published. \033[0m\033[0;37m\n\n", elm->topicName);
remove(elm); // PUBLISH Done remove(elm); // PUBLISH Done
return; return;
} }
@@ -234,7 +234,7 @@ void LPublishManager::responce(const uint8_t* msg, uint16_t msglen)
{ {
if (elm->status == WAIT_PUBACK) if (elm->status == WAIT_PUBACK)
{ {
ASSERT("\033[0m\033[0;32m Topic \"%s\" Id : %d was Published. \033[0m\033[0;37m\n\n", elm->topicName, elm->topicId); DISPLAY("\033[0m\033[0;32m Topic \"%s\" Id : %d was Published. \033[0m\033[0;37m\n\n", elm->topicName, elm->topicId);
remove(elm); // PUBLISH Done remove(elm); // PUBLISH Done
} }
} }
@@ -270,7 +270,7 @@ void LPublishManager::responce(const uint8_t* msg, uint16_t msglen)
} }
if (elm->status == WAIT_PUBCOMP) if (elm->status == WAIT_PUBCOMP)
{ {
ASSERT("\033[0m\033[0;32m Topic \"%s\" Id : %d was Published. \033[0m\033[0;37m\n\n", elm->topicName, elm->topicId); DISPLAY("\033[0m\033[0;32m Topic \"%s\" Id : %d was Published. \033[0m\033[0;37m\n\n", elm->topicName, elm->topicId);
remove(elm); // PUBLISH Done remove(elm); // PUBLISH Done
} }
} }

View File

@@ -60,7 +60,7 @@ LSubscribeManager::~LSubscribeManager()
void LSubscribeManager::onConnect(void) void LSubscribeManager::onConnect(void)
{ {
ASSERT("\033[0m\033[0;32m Attempting OnConnect.....\033[0m\033[0;37m\n"); DISPLAY("\033[0m\033[0;32m Attempting OnConnect.....\033[0m\033[0;37m\n");
if (_first == 0) if (_first == 0)
{ {
for (uint8_t i = 0; theOnPublishList[i].topic != 0; i++) for (uint8_t i = 0; theOnPublishList[i].topic != 0; i++)
@@ -89,8 +89,8 @@ void LSubscribeManager::onConnect(void)
{ {
theClient->getGwProxy()->getMessage(); theClient->getGwProxy()->getMessage();
} }
ASSERT("\033[0m\033[0;32m OnConnect complete\033[0m\033[0;37m\n"); DISPLAY("\033[0m\033[0;32m OnConnect complete\033[0m\033[0;37m\n");
ASSERT("\033[0m\033[0;32m Test is Ready.\033[0m\033[0;37m\n"); DISPLAY("\033[0m\033[0;32m Test is Ready.\033[0m\033[0;37m\n");
} }
bool LSubscribeManager::isDone(void) bool LSubscribeManager::isDone(void)
@@ -194,9 +194,9 @@ void LSubscribeManager::checkTimeout(void)
{ {
if (elm->msgType == MQTTSN_TYPE_SUBSCRIBE) if (elm->msgType == MQTTSN_TYPE_SUBSCRIBE)
{ {
ASSERT("\033[0m\033[0;31m\n!!!!!! SUBSCRIBE Error !!!!! Topic : %s\033[0m\033[0;37m\n\n", (char*)elm->topicName); DISPLAY("\033[0m\033[0;31m\n!!!!!! SUBSCRIBE Error !!!!! Topic : %s\033[0m\033[0;37m\n\n", (char*)elm->topicName);
}else{ }else{
ASSERT("\033[0m\033[0;31m\n!!!!!! UNSUBSCRIBE Error !!!!! Topic : %s\033[0m\033[0;37m\n\n", (char*)elm->topicName); DISPLAY("\033[0m\033[0;31m\n!!!!!! UNSUBSCRIBE Error !!!!! Topic : %s\033[0m\033[0;37m\n\n", (char*)elm->topicName);
} }
elm->done = SUB_DONE; elm->done = SUB_DONE;
} }
@@ -222,12 +222,12 @@ void LSubscribeManager::responce(const uint8_t* msg)
{ {
tt->add((char*) elm->topicName, topicId, elm->topicType, elm->callback); tt->add((char*) elm->topicName, topicId, elm->topicType, elm->callback);
getElement(msgId)->done = SUB_DONE; getElement(msgId)->done = SUB_DONE;
ASSERT("\033[0m\033[0;32m Topic \"%s\" Id : %d was Subscribed. \033[0m\033[0;37m\n\n", getElement(msgId)->topicName, getElement(msgId)->topicId); DISPLAY("\033[0m\033[0;32m Topic \"%s\" Id : %d was Subscribed. \033[0m\033[0;37m\n\n", getElement(msgId)->topicName, getElement(msgId)->topicId);
} }
else else
{ {
remove(elm); remove(elm);
ASSERT("\033[0m\033[0;31m SUBACK Invalid messageId. %s\033[0m\033[0;37m\n\n", getElement(msgId)->topicName); DISPLAY("\033[0m\033[0;31m SUBACK Invalid messageId. %s\033[0m\033[0;37m\n\n", getElement(msgId)->topicName);
} }
} }
} }
@@ -239,12 +239,12 @@ void LSubscribeManager::responce(const uint8_t* msg)
{ {
LTopicTable* tt = theClient->getGwProxy()->getTopicTable(); LTopicTable* tt = theClient->getGwProxy()->getTopicTable();
tt->setCallback(elm->topicName, 0); tt->setCallback(elm->topicName, 0);
ASSERT("\033[0m\033[0;32m Topic \"%s\" Id : %d was Unsubscribed. \033[0m\033[0;37m\n\n", getElement(msgId)->topicName, getElement(msgId)->topicId); DISPLAY("\033[0m\033[0;32m Topic \"%s\" Id : %d was Unsubscribed. \033[0m\033[0;37m\n\n", getElement(msgId)->topicName, getElement(msgId)->topicId);
remove(getElement(msgId)); remove(getElement(msgId));
} }
else else
{ {
ASSERT("\033[0m\033[0;31m UNSUBACK Invalid messageId. %s\033[0m\033[0;37m\n\n", getElement(msgId)->topicName); DISPLAY("\033[0m\033[0;31m UNSUBACK Invalid messageId. %s\033[0m\033[0;37m\n\n", getElement(msgId)->topicName);
remove(getElement(msgId)); remove(getElement(msgId));
} }
} }

View File

@@ -71,14 +71,14 @@ void LTaskManager::run(void){
if ( toupper(c) == 'N' ) if ( toupper(c) == 'N' )
{ {
ASSERT("\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);
theScreen->prompt(""); theScreen->prompt("");
cancelFlg = true; cancelFlg = true;
break; break;
} }
else if ( toupper(c) == 'Y' ) else if ( toupper(c) == 'Y' )
{ {
ASSERT("\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("");
(_tests[i].testTask)(); (_tests[i].testTask)();
cancelFlg = false; cancelFlg = false;
@@ -108,10 +108,10 @@ void LTaskManager::run(void){
} }
if ( !cancelFlg ) if ( !cancelFlg )
{ {
ASSERT("\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);
} }
} }
ASSERT("\033[0m\033[0;32m\n\n######### All tests complete! ###########\033[0m\033[0;37m\n\n"); DISPLAY("\033[0m\033[0;32m\n\n######### All tests complete! ###########\033[0m\033[0;37m\n\n");
} }
else else
{ {