Problems splitting a string to get authentication and command
The command array created inside get_command() is local data. That means it's only available while that function is being executed.

However, you're returning a pointer to it. That means when you're trying to use command afterwards from inside loop(), you're trying to refer to data which has been deallocated. By that point, it's getting used for something else.

There are various solutions to this. A fairly simple approach would be to have the caller allocate the command array, passing a pointer to it into get_command(). For example:



void get_command(char *data, char *command) {
    strncpy(command, data + 24, 3);
}


From loop(), you would call it like this:

char command[3];
get_command(received_data, command);


The command array is still local data in this case. However, it's local to the loop() function (or wherever else you put that code). That means it will still be available when get_command() is called.