#include <stdio.h>
#include <ctype.h>
#include <cstring>

#include "echo.h"

// Helper function to handle the echoing and resetting of the buffer
void echo_and_reset(char* buffer, int* index_ptr) {
    if (*index_ptr > 0) {
        buffer[*index_ptr] = '\0';
        // Print to USB serial (ALL CAPS)
        printf("\nEchoed (ALL CAPS): ");
        for (int i = 0; buffer[i] != '\0'; i++) {
            char ch = toupper(buffer[i]);
            printf("%c", ch);
        }
        printf("\n");
    }

    *index_ptr = 0;
    printf("> ");
}