Skip to content
Snippets Groups Projects
Verified Commit cb23f406 authored by Anian Bühler's avatar Anian Bühler
Browse files

changed int checkData to bool checkDataAvailable

parent 84a4fe6d
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ void DidacticPSNet::setStream(Stream& stream){
bool DidacticPSNet::handleNetwork(){
//if(_waitingTime <= millis()){
if(checkData()){
if(checkDataAvailable()){
if(recieveData()){
//Serial.print("Message filter: ");Serial.println(_readBufferMessage[1]);
//Serial.print("Check Message filter: ");Serial.println(getMessageFilter(_readBufferMessage[1]));
......@@ -52,7 +52,7 @@ bool DidacticPSNet::handleNetwork(){
unsigned long delayStartTime = micros();
while(micros() < delayStartTime + CSMA_CHECK_DELAY_US);
//delayMicroseconds(CSMA_CHECK_DELAY_US); //removed: blocking SoftSerial-interrupts
if(!checkData()){
if(!checkDataAvailable()){
sendData();
_dataToSend = false;
//_waitingTime = millis()+ random(CSMA_MID_DELAY_MS, CSMA_MAX_DELAY_MS);
......@@ -111,8 +111,8 @@ int DidacticPSNet::extractData(int startCounter, int maxLength, char* buffer, ch
return counter-startCounter; //length
}
int DidacticPSNet::checkData(){
return (int)_port->available();
bool DidacticPSNet::checkDataAvailable(){
return _port->available() > 0;
}
bool DidacticPSNet::recieveData() {
......@@ -122,7 +122,7 @@ bool DidacticPSNet::recieveData() {
//if(msgCounter == NULL){ msgCounter = 0; }
//if(topicCounter == NULL){ topicCounter = 0; }
//if(dataCounter == NULL){ dataCounter = 0; }
while (checkData()) {
while (checkDataAvailable()) {
char localBuffer = _port->read();
if (localBuffer == MSG_PRELIMITER) {
msgCounter = 0;
......@@ -321,7 +321,7 @@ bool DidacticPSNetClient::handleData(){
int DidacticPSNetClient::getTopicOrWildcardNr(char* topic){
for (int i = 0; i < MAX_NR_TOPICS_CLIENT; i++) {
if (strcmp(_topic[i], topic) == 0 || _topic[i][0] == MSG_TOPIC_MULTI) { //TODO: check ... or equal MSG_TOPIC_MULTI
if (strcmp(_topic[i], topic) == 0 || _topic[i][0] == MSG_TOPIC_MULTI) {
return i;
}
}
......
......
......@@ -127,7 +127,7 @@ class DidacticPSNet
void setStream(Stream& _port);
int checkData();
bool checkDataAvailable();
bool recieveData();
void sendData();
int extractData(int, int, char*, char);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment