You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libiec61850/examples/sntp_example/sntp_example.c

49 lines
800 B
C

/*
* sntp_example.c
*/
#include "sntp_client.h"
#include "hal_thread.h"
#include <signal.h>
#include <stdio.h>
static bool running = true;
void
sigint_handler(int signalId)
{
running = false;
}
static void
sntpUserCallback(void* parameter, bool isSynced)
{
if (isSynced)
printf("SNTP: Clock synchronized\n");
else
printf("SNTP: Clock not synchronized\n");
}
int
main(int argc, char** argv)
{
SNTPClient client = SNTPClient_create();
SNTPClient_addServer(client, "192.168.178.74", 123);
SNTPClient_setUserCallback(client, sntpUserCallback, NULL);
SNTPClient_setPollInterval(client, 16);
SNTPClient_start(client);
signal(SIGINT, sigint_handler);
while (running) {
Thread_sleep(100);
}
SNTPClient_destroy(client);
}