up
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user