Quote Originally Posted by laserlight View Post
I wrote a quick program to check that I didn't make some silly mistake:
Code:
#include <stdio.h>

int main(void)
{
    unsigned char tableID = 101;
    char expected[14]; // NNN_available
    snprintf(expected, sizeof(expected), "%u_available", (unsigned int)tableID);
    printf("%s\n", expected);
    return 0;
}
Compiling and running the above program results in this output, which is exactly what I expected:
Code:
101_available
Therefore, what you have described is impossible (unless there is undefined behaviour elsewhere): there can be no value of tableID that will result in expected being an empty string.

To confirm, are you saying that you wrote this:
Code:
char expected[14]; // NNN_available
snprintf(expected, sizeof(expected), "%u_available", (unsigned int)tableID);
Serial.println(expected);
if (strcmp(packetBuffer, expected) == 0) {
    modeAvailable();
    Serial.println("This works!");
}
and it didn't print anything where Serial.println(expected) was supposed to print something?

This actually works now! I do have to clean up a bit but this my result from the serial monitor.

Code:
11:12:19.369 -> Received packet of size 13
11:12:19.369 -> From 10.168.1.100, port 9101
11:12:19.369 -> Command: 215_available
11:12:19.404 -> --END--
11:12:19.404 -> 215_available
11:12:19.404 -> Confirmed
11:12:19.404 -> This works!
11:12:19.404 -> Expected: 215_available


11:12:25.782 -> Received packet of size 13
11:12:25.782 -> From 10.168.1.100, port 9101
11:12:25.782 -> Command: 101_available
11:12:25.782 -> --END--
11:12:25.782 -> 215_available
So, the tableID is currently 215, which is correct.
With the 101_available it does print 'Expected' which obviously is correct when you look at the code, it's printing what it expects.

This is what I have;
Code:
        snprintf(expected, sizeof(expected), "%u_available", (unsigned int)tableID);
        Serial.println(expected);
          if (strcmp(packetBuffer, expected) == 0) 
          {
            modeAvailable();
            Serial.println("This works!");
            Serial.print("Expected: ");
            Serial.println(expected);
            
          }

I do think this did the trick, I'll work my code out today to see if it works as supposed with all the functions.

Really thanks for all the help! I'm happy now!