37 lines
601 B
C
37 lines
601 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "api.h"
|
|
|
|
int main() {
|
|
void* thread_handle;
|
|
start_api(&thread_handle);
|
|
|
|
char* command;
|
|
while(1) {
|
|
// Clear buffer
|
|
command = get_command();
|
|
printf("Recieved: %s\n", command);
|
|
if (cmp(command, "ping")) {
|
|
send_reply("pong");
|
|
printf("Sended: pong\n");
|
|
}
|
|
else if (cmp(command, "hello")) {
|
|
send_reply("hi!");
|
|
printf("Sended: hello\n");
|
|
}
|
|
else {
|
|
send_reply("Unknown command.");
|
|
printf("Sended: Unknown command.\n");
|
|
}
|
|
sleep(0.01);
|
|
}
|
|
|
|
stop_api(thread_handle);
|
|
|
|
return 0;
|
|
}
|
|
|