MQTT-Gateway/command.c
2024-01-22 21:20:10 +01:00

35 lines
700 B
C

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "network.h"
int main(int argc, char *argv[])
{
int xPlaneSocket;
// check argument
if (argc != 2)
{
fprintf(stderr, "Usage: %s <command>\n", argv[0]);
exit(EXIT_FAILURE);
}
// network
xPlaneSocket = createSocket(SRC_PORT);
if (xPlaneSocket < 0)
{
exit(EXIT_FAILURE);
}
// send payload
if (sendToXPlane(xPlaneSocket, DEST_SERVER, DEST_PORT, "CMND", argv[1], strlen(argv[1])) < 0)
{
exit(EXIT_FAILURE);
}
// bye bye (and no, I don't care about error anymore; I'll exit anyway?!)
closeSocket(xPlaneSocket);
exit(EXIT_SUCCESS);
}