diff --git a/keywords.txt b/keywords.txt index 1342edfdace97ea73d70a8bd63fbe83a099d6c43..60c736ca642600c2f9c29ce5d0c3cb6d16a8d402 100644 --- a/keywords.txt +++ b/keywords.txt @@ -5,7 +5,6 @@ ####################################### # Datatypes (KEYWORD1) ####################################### - didacticPSNet KEYWORD1 didacticPSNetBroker KEYWORD1 didacticPSNetClient KEYWORD1 diff --git a/src/didacticNet.cpp b/src/didacticNet.cpp index ddc2d7b588065a933e035bfab0c390abfd6bf1c6..0df22f51873c77aab9637725fe5fcd04d6a99cda 100644 --- a/src/didacticNet.cpp +++ b/src/didacticNet.cpp @@ -150,8 +150,7 @@ int didacticPSNet::extractData(int startCounter, int maxLength, char* buffer, ch buffer[counter-startCounter] = _readBufferMessage[counter]; counter++; if((counter-startCounter) > maxLength){ - //return -1; - Serial.print("\nextractData - Return on MAX length\n"); + counter--; break; //if > maxLenght -> leave while and return } } @@ -232,24 +231,6 @@ int didacticPSNetClient::publish(char* topic, char* payload){ for(int i = 0; i < payloadLength; i++){ _sendBufferMessage[2+topicLength+1+i] = payload[i]; } -/* - if(topicLength <= MAX_LEN_TOPICS){ - for(int i = 0; i < topicLength; i++){ - _sendBufferMessage[2+i] = topic[i]; - } - }else { //cut topic if longer than max - _dataToSend = false; - return false; - } - if(payloadLength <= MAX_LEN_PAYLOAD){ - for(int i = 0; i < payloadLength; i++){ - _sendBufferMessage[2+topicLength+1+i] = payload[i]; - } - }else { //cut message if longer than max - _dataToSend = false; - return false; - } - */ _dataToSend = true; return error; @@ -264,7 +245,7 @@ int didacticPSNetClient::publish(char* topic, int topicLength, char* payload , i _sendBufferMessage[2+topicLength+1+payloadLength] = MSG_DELIMITER; _sendBufferMessage[2+topicLength+1+payloadLength+1] = '\0'; - //TODO: check + //TODO: check if(topicLength > MAX_LEN_TOPICS){ topicLength = MAX_LEN_TOPICS; error += DN_ERROR_TOPIC_LEN; @@ -280,24 +261,7 @@ int didacticPSNetClient::publish(char* topic, int topicLength, char* payload , i for(int i = 0; i < payloadLength; i++){ _sendBufferMessage[2+topicLength+1+i] = payload[i]; } -/* - if(topicLength <= MAX_LEN_TOPICS){ - for(int i = 0; i < topicLength; i++){ - _sendBufferMessage[2+i] = topic[i]; - } - }else { //cut topic if longer than max - _dataToSend = false; - return false; - } - if(payloadLength <= MAX_LEN_PAYLOAD){ - for(int i = 0; i < payloadLength; i++){ - _sendBufferMessage[2+topicLength+1+i] = payload[i]; - } - }else { //cut message if longer than max - _dataToSend = false; - return false; - } - */ + _dataToSend = true; return error; } @@ -323,8 +287,6 @@ int didacticPSNetClient::subscribe(char* topic){ if(topicNumber < 0){ topicNumber = 0; } - - // if( topicLength <= MAX_LEN_TOPICS){ for(int i = 0; i < topicLength; i++){ _topic[topicNumber][i] = topic[i]; _sendBufferMessage[2+i]= topic[i]; @@ -332,21 +294,13 @@ int didacticPSNetClient::subscribe(char* topic){ _topic[topicNumber][topicLength] = '\0'; _sendBufferMessage[2+topicLength+1]= '\0'; _dataToSend = true; - /* } - else { - _dataToSend = false; - return false; - }*/ - } else{ - //if( topicLength <= MAX_LEN_TOPICS){ for(int i = 0; i < topicLength; i++){ _sendBufferMessage[2+i]= topic[i]; } _sendBufferMessage[2+topicLength+1]= '\0'; _dataToSend = true; - //} } while(_dataToSend){ handleNetwork(); @@ -373,8 +327,6 @@ int didacticPSNetClient::subscribe(char* topic, int topicLength){ if(topicNumber < 0){ topicNumber = 0; } - - // if( topicLength <= MAX_LEN_TOPICS){ for(int i = 0; i < topicLength; i++){ _topic[topicNumber][i] = topic[i]; _sendBufferMessage[2+i]= topic[i]; @@ -382,21 +334,13 @@ int didacticPSNetClient::subscribe(char* topic, int topicLength){ _topic[topicNumber][topicLength] = '\0'; _sendBufferMessage[2+topicLength+1]= '\0'; _dataToSend = true; - /* } - else { - _dataToSend = false; - return false; - }*/ - } else{ - //if( topicLength <= MAX_LEN_TOPICS){ for(int i = 0; i < topicLength; i++){ _sendBufferMessage[2+i]= topic[i]; } _sendBufferMessage[2+topicLength+1]= '\0'; _dataToSend = true; - //} } while(_dataToSend){ handleNetwork();