From e341d1a3264c5791bb0100682d64f5d137ad6f84 Mon Sep 17 00:00:00 2001 From: tomoaki Date: Mon, 8 May 2017 18:49:10 +0900 Subject: [PATCH] Update: change a macro name from ASSERT to DISPLAY Signed-off-by: tomoaki --- .../GatewayTester/samples/mainTemplate.cpp | 2 +- .../GatewayTester/samples/mainTest.cpp | 14 +++++++------- MQTTSNGateway/GatewayTester/src/LGwProxy.cpp | 8 ++++---- .../GatewayTester/src/LMqttsnClient.cpp | 4 ++-- .../GatewayTester/src/LMqttsnClientApp.h | 6 +++--- .../GatewayTester/src/LNetworkUdp.cpp | 12 ++++++------ .../GatewayTester/src/LPublishManager.cpp | 6 +++--- .../GatewayTester/src/LSubscribeManager.cpp | 18 +++++++++--------- .../GatewayTester/src/LTaskManager.cpp | 8 ++++---- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp b/MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp index 86bccd7..432b367 100644 --- a/MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp +++ b/MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp @@ -40,7 +40,7 @@ extern int run(void); * * void DISCONNECT ( uint16_t sleepInSecs ); * - * void ASSERT( format, valiables, .....); <== instead of printf() + * void DISPLAY( format, valiables, .....); <== instead of printf() * */ diff --git a/MQTTSNGateway/GatewayTester/samples/mainTest.cpp b/MQTTSNGateway/GatewayTester/samples/mainTest.cpp index 7ef2fa7..aad9d77 100644 --- a/MQTTSNGateway/GatewayTester/samples/mainTest.cpp +++ b/MQTTSNGateway/GatewayTester/samples/mainTest.cpp @@ -40,7 +40,7 @@ extern int run(void); * * 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) { - ASSERT("\n\nTopic1 recv.\n"); + DISPLAY("\n\nTopic1 recv.\n"); char c = pload[ploadlen-1]; 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; } 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 - ASSERT("Payload -->%s <--\n\n",pload); + DISPLAY("Payload -->%s <--\n\n",pload); return 0; } 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 - ASSERT("Payload -->%s <--\n\n",pload); + DISPLAY("Payload -->%s <--\n\n",pload); return 0; } diff --git a/MQTTSNGateway/GatewayTester/src/LGwProxy.cpp b/MQTTSNGateway/GatewayTester/src/LGwProxy.cpp index a7aff0c..47cc88a 100644 --- a/MQTTSNGateway/GatewayTester/src/LGwProxy.cpp +++ b/MQTTSNGateway/GatewayTester/src/LGwProxy.cpp @@ -165,7 +165,7 @@ int LGwProxy::getConnectResponce(void){ _connectRetry = MQTTSN_RETRY_COUNT; _keepAliveTimer.start(_tkeepAlive * 1000); _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 }else{ _status = GW_CONNECTING; @@ -201,7 +201,7 @@ void LGwProxy::disconnect(uint16_t secs){ while ( _status != GW_DISCONNECTED && _status != GW_SLEPT){ if (getDisconnectResponce() < 0){ _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; } } @@ -331,7 +331,7 @@ int LGwProxy::writeMsg(const uint8_t* msg){ if (rc > 0){ 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; } @@ -365,7 +365,7 @@ int LGwProxy::readMsg(void){ } 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; } diff --git a/MQTTSNGateway/GatewayTester/src/LMqttsnClient.cpp b/MQTTSNGateway/GatewayTester/src/LMqttsnClient.cpp index 71b192b..1779930 100644 --- a/MQTTSNGateway/GatewayTester/src/LMqttsnClient.cpp +++ b/MQTTSNGateway/GatewayTester/src/LMqttsnClient.cpp @@ -61,14 +61,14 @@ int run(void) { 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(""); return 0; } } 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(""); break; } diff --git a/MQTTSNGateway/GatewayTester/src/LMqttsnClientApp.h b/MQTTSNGateway/GatewayTester/src/LMqttsnClientApp.h index 37e1c61..6457abb 100644 --- a/MQTTSNGateway/GatewayTester/src/LMqttsnClientApp.h +++ b/MQTTSNGateway/GatewayTester/src/LMqttsnClientApp.h @@ -96,11 +96,11 @@ struct LUdpConfig{ #define UDPCONF LUdpConfig theNetcon #define MQTTSNCONF LMqttsnConfig theMqcon #ifdef CLIENT_MODE -#define ASSERT(...) +#define DISPLAY(...) #define PROMPT(...) -#define CHECKKEYIN(...) +#define CHECKKEYIN(...) theScreen->checkKeyIn(__VA_ARGS__) #else -#define ASSERT(...) theScreen->display(__VA_ARGS__) +#define DISPLAY(...) theScreen->display(__VA_ARGS__) #define PROMPT(...) theScreen->prompt(__VA_ARGS__) #define CHECKKEYIN(...) theScreen->checkKeyIn(__VA_ARGS__) #endif diff --git a/MQTTSNGateway/GatewayTester/src/LNetworkUdp.cpp b/MQTTSNGateway/GatewayTester/src/LNetworkUdp.cpp index ac850b3..9fc8a1f 100644 --- a/MQTTSNGateway/GatewayTester/src/LNetworkUdp.cpp +++ b/MQTTSNGateway/GatewayTester/src/LNetworkUdp.cpp @@ -191,7 +191,7 @@ bool LUdpPort::open(LUdpConfig config){ 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"); - 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(); return false; } @@ -202,7 +202,7 @@ bool LUdpPort::open(LUdpConfig config){ 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"); - 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(); 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) ); if( status < 0){ 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{ D_NWLOG("sendto %-15s:%-6u",inet_ntoa(dest.sin_addr),htons(port)); 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) ); if( status < 0){ 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; }else{ D_NWLOG("sendto %-15s:%-6u",inet_ntoa(dest.sin_addr),htons(_gPortNo)); for(uint16_t i = 0; i < length ; i++){ D_NWLOG(" %02x", *(buf + i)); - ASSERT(" %02x", *(buf + i)); + DISPLAY(" %02x", *(buf + i)); } 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) { 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){ *ipAddressPtr = sender.sin_addr.s_addr; *portPtr = sender.sin_port; diff --git a/MQTTSNGateway/GatewayTester/src/LPublishManager.cpp b/MQTTSNGateway/GatewayTester/src/LPublishManager.cpp index 3c7dac7..94d0886 100644 --- a/MQTTSNGateway/GatewayTester/src/LPublishManager.cpp +++ b/MQTTSNGateway/GatewayTester/src/LPublishManager.cpp @@ -153,7 +153,7 @@ void LPublishManager::sendPublish(PubElement* elm) theClient->getGwProxy()->resetPingReqTimer(); 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 return; } @@ -234,7 +234,7 @@ void LPublishManager::responce(const uint8_t* msg, uint16_t msglen) { 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 } } @@ -270,7 +270,7 @@ void LPublishManager::responce(const uint8_t* msg, uint16_t msglen) } 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 } } diff --git a/MQTTSNGateway/GatewayTester/src/LSubscribeManager.cpp b/MQTTSNGateway/GatewayTester/src/LSubscribeManager.cpp index 7df5bc3..3133476 100644 --- a/MQTTSNGateway/GatewayTester/src/LSubscribeManager.cpp +++ b/MQTTSNGateway/GatewayTester/src/LSubscribeManager.cpp @@ -60,7 +60,7 @@ LSubscribeManager::~LSubscribeManager() 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) { for (uint8_t i = 0; theOnPublishList[i].topic != 0; i++) @@ -89,8 +89,8 @@ void LSubscribeManager::onConnect(void) { theClient->getGwProxy()->getMessage(); } - ASSERT("\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 OnConnect complete\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) @@ -194,9 +194,9 @@ void LSubscribeManager::checkTimeout(void) { 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{ - 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; } @@ -222,12 +222,12 @@ void LSubscribeManager::responce(const uint8_t* msg) { tt->add((char*) elm->topicName, topicId, elm->topicType, elm->callback); 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 { 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(); 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)); } 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)); } } diff --git a/MQTTSNGateway/GatewayTester/src/LTaskManager.cpp b/MQTTSNGateway/GatewayTester/src/LTaskManager.cpp index 8b84418..f38182d 100644 --- a/MQTTSNGateway/GatewayTester/src/LTaskManager.cpp +++ b/MQTTSNGateway/GatewayTester/src/LTaskManager.cpp @@ -71,14 +71,14 @@ void LTaskManager::run(void){ 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(""); cancelFlg = true; break; } 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(""); (_tests[i].testTask)(); cancelFlg = false; @@ -108,10 +108,10 @@ void LTaskManager::run(void){ } 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 {