Commit f97575f2 authored by Ivan Tyagov's avatar Ivan Tyagov

Make network address url data type configurable so we can support both IPv4 /...

Make network address url data type configurable so we can support both IPv4 / IPv6 multicast from  CLI.
parent 5661b82b
...@@ -177,7 +177,7 @@ static void enablePublishHeartBeat(UA_Server *server, UA_ServerConfig *config){ ...@@ -177,7 +177,7 @@ static void enablePublishHeartBeat(UA_Server *server, UA_ServerConfig *config){
UA_String transportProfile = UA_STRING(DEFAULT_TRANSPORT_PROFILE); UA_String transportProfile = UA_STRING(DEFAULT_TRANSPORT_PROFILE);
UA_NetworkAddressUrlDataType networkAddressUrl = UA_NetworkAddressUrlDataType networkAddressUrl =
{UA_STRING_NULL , UA_STRING(DEFAULT_NETWORK_ADDRESS_URL)}; {UA_STRING_NULL , UA_STRING(NETWORK_ADDRESS_URL_DATA_TYPE)};
addPubSubConnection(server, &transportProfile, &networkAddressUrl); addPubSubConnection(server, &transportProfile, &networkAddressUrl);
addPublishedDataSet(server); addPublishedDataSet(server);
for(i = 0; i < countof(publishedVariableArray); i++) { for(i = 0; i < countof(publishedVariableArray); i++) {
......
...@@ -291,7 +291,7 @@ void callbackCheckHeartBeat() { ...@@ -291,7 +291,7 @@ void callbackCheckHeartBeat() {
static int enableSubscribeToHeartBeat(UA_Server *server, UA_ServerConfig *config){ static int enableSubscribeToHeartBeat(UA_Server *server, UA_ServerConfig *config){
// enable subscribe to keep-alive messages // enable subscribe to keep-alive messages
UA_String transportProfile = UA_STRING(DEFAULT_TRANSPORT_PROFILE); UA_String transportProfile = UA_STRING(DEFAULT_TRANSPORT_PROFILE);
UA_NetworkAddressUrlDataType networkAddressUrl = {UA_STRING_NULL , UA_STRING(DEFAULT_NETWORK_ADDRESS_URL)}; UA_NetworkAddressUrlDataType networkAddressUrl = {UA_STRING_NULL , UA_STRING(NETWORK_ADDRESS_URL_DATA_TYPE)};
addPubSubConnectionXXX(server, &transportProfile, &networkAddressUrl); addPubSubConnectionXXX(server, &transportProfile, &networkAddressUrl);
/* Add ReaderGroup to the created PubSubConnection */ /* Add ReaderGroup to the created PubSubConnection */
......
...@@ -49,7 +49,7 @@ const int DEFAULT_ID = 0; ...@@ -49,7 +49,7 @@ const int DEFAULT_ID = 0;
// OPC UA's Pub/Sub profile // OPC UA's Pub/Sub profile
char *DEFAULT_TRANSPORT_PROFILE = "http://opcfoundation.org/UA-Profile/Transport/pubsub-udp-uadp"; char *DEFAULT_TRANSPORT_PROFILE = "http://opcfoundation.org/UA-Profile/Transport/pubsub-udp-uadp";
char *DEFAULT_NETWORK_ADDRESS_URL = "opc.udp://224.0.0.22:4840/"; char *NETWORK_ADDRESS_URL_DATA_TYPE = "opc.udp://224.0.0.22:4840/";
#include "keep_alive_publisher.h" #include "keep_alive_publisher.h"
#include "keep_alive_subscriber.h" #include "keep_alive_subscriber.h"
...@@ -74,6 +74,8 @@ static struct argp_option options[] = { ...@@ -74,6 +74,8 @@ static struct argp_option options[] = {
{"heart-beat-interval", 't', "500", 0, "Heart beat interval in ms."}, {"heart-beat-interval", 't', "500", 0, "Heart beat interval in ms."},
{"heart-beat-id-list", 'l', "", 0, "Comma separated list of IDs of couplers to watch for heart beats. \ {"heart-beat-id-list", 'l', "", 0, "Comma separated list of IDs of couplers to watch for heart beats. \
If heart beat is missing coupler goes to safe mode."}, If heart beat is missing coupler goes to safe mode."},
{"network-address-url-data-type", 'n', "opc.udp://224.0.0.22:4840/", 0, "Netwrok address URL type used for Pub/Sub."},
{0} {0}
}; };
...@@ -91,6 +93,7 @@ struct arguments ...@@ -91,6 +93,7 @@ struct arguments
bool heart_beat; bool heart_beat;
int heart_beat_interval; int heart_beat_interval;
char *heart_beat_id_list; char *heart_beat_id_list;
char *network_address_url_data_type;
}; };
static error_t parse_opt(int key, char *arg, struct argp_state *state) static error_t parse_opt(int key, char *arg, struct argp_state *state)
...@@ -133,6 +136,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) ...@@ -133,6 +136,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
case 'l': case 'l':
arguments->heart_beat_id_list = arg; arguments->heart_beat_id_list = arg;
break; break;
case 'n':
arguments->network_address_url_data_type = arg;
break;
case ARGP_KEY_ARG: case ARGP_KEY_ARG:
return 0; return 0;
default: default:
...@@ -176,6 +182,7 @@ int main(int argc, char **argv) ...@@ -176,6 +182,7 @@ int main(int argc, char **argv)
arguments.certificate = ""; arguments.certificate = "";
arguments.id = DEFAULT_ID; arguments.id = DEFAULT_ID;
arguments.heart_beat_interval = DEFAULT_HEART_BEAT_INTERVAL; arguments.heart_beat_interval = DEFAULT_HEART_BEAT_INTERVAL;
arguments.network_address_url_data_type = NETWORK_ADDRESS_URL_DATA_TYPE;
argp_parse(&argp, argc, argv, 0, 0, &arguments); argp_parse(&argp, argc, argv, 0, 0, &arguments);
printf("Mode=%d\n", arguments.mode); printf("Mode=%d\n", arguments.mode);
...@@ -188,12 +195,14 @@ int main(int argc, char **argv) ...@@ -188,12 +195,14 @@ int main(int argc, char **argv)
printf("Heart beat=%d\n", arguments.heart_beat); printf("Heart beat=%d\n", arguments.heart_beat);
printf("Heart beat interval=%d ms\n", arguments.heart_beat_interval); printf("Heart beat interval=%d ms\n", arguments.heart_beat_interval);
printf("Heart beat ID list=%s\n", arguments.heart_beat_id_list); printf("Heart beat ID list=%s\n", arguments.heart_beat_id_list);
printf("Network address URL data type=%s\n", arguments.network_address_url_data_type);
// transfer to global variables (CLI input) // transfer to global variables (CLI input)
COUPLER_ID = arguments.id; COUPLER_ID = arguments.id;
I2C_VIRTUAL_MODE = arguments.mode; I2C_VIRTUAL_MODE = arguments.mode;
I2C_BLOCK_DEVICE_NAME = arguments.device; I2C_BLOCK_DEVICE_NAME = arguments.device;
HEART_BEAT_INTERVAL = arguments.heart_beat_interval; HEART_BEAT_INTERVAL = arguments.heart_beat_interval;
NETWORK_ADDRESS_URL_DATA_TYPE = arguments.network_address_url_data_type;
// convert arguments.slave_address_list -> I2C_SLAVE_ADDR_LIST // convert arguments.slave_address_list -> I2C_SLAVE_ADDR_LIST
i = 0; i = 0;
......
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