Commit acd16fc5 authored by Ivan Tyagov's avatar Ivan Tyagov

Set default ID of coupler.

Handle CLI switches related to hear_beat / keep-alive functionality.
parent f7eb4b77
......@@ -8,6 +8,9 @@ static unsigned int HEART_BEATS = 0;
// the heart beat interval$
static int HEART_BEAT_INTERVAL = 250;
// the list of couplers onto which we depend for properly running
static char *HEART_BEAT_ID_LIST[20];
// the interval for publishing messages
const int PUBLISHING_INTERVAL = 100;
......
......@@ -44,6 +44,7 @@ UA_Server *server;
// The default port of OPC-UA server
const int DEFAULT_OPC_UA_PORT = 4840;
const int DEFAULT_MODE = 0;
const int DEFAULT_ID = 0;
// CLI arguments handling
const char *argp_program_version = "OSIE OPC-UA coupler 0.0.1";
......@@ -79,6 +80,9 @@ struct arguments
char *key;
char *certificate;
int id;
bool heart_beat;
int heart_beat_interval;
char *heart_beat_id_list;
};
static error_t parse_opt(int key, char *arg, struct argp_state *state)
......@@ -110,7 +114,16 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
arguments->key = arg;
break;
case 'i':
arguments->id = arg ? atoi (arg) : 0;
arguments->id = arg ? atoi (arg) : DEFAULT_ID;
break;
case 'b':
arguments->heart_beat = atoi (arg);
break;
case 't':
arguments->heart_beat_interval = atoi (arg);
break;
case 'l':
arguments->heart_beat_id_list = arg;
break;
case ARGP_KEY_ARG:
return 0;
......@@ -158,6 +171,9 @@ int main(int argc, char **argv)
printf("Key=%s\n", arguments.key);
printf("Certificate=%s\n", arguments.certificate);
printf("ID=%d\n", arguments.id);
printf("Heart beat=%d\n", arguments.heart_beat);
printf("Heart beat interval=%d ms\n", arguments.heart_beat_interval);
printf("Heart beat ID list=%s\n", arguments.heart_beat_id_list);
// transfer to global variables (CLI input)
COUPLER_ID = arguments.id;
......@@ -239,7 +255,9 @@ int main(int argc, char **argv)
#endif
// enable keep-alive
enablePublishHeartBeat(server, config);
if (arguments.heart_beat) {
enablePublishHeartBeat(server, config);
}
// run server
UA_StatusCode retval = UA_Server_run(server, &running);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment