Bugfix/example-app-uevent-event-parsing (#1221)
* Added Send_UEvent_Notify_Device function for device-specific unconfirmed event notifications. * Fixed event_notify_parse() loop index to start from zero. * Added device ID binding support in the UEvent command-line application. * Fixed the UEvent command-line application help output. * Fixed initialization of event data in the UEvent command-line application by adding static CharacterString for message text and handling the failure case.
This commit is contained in:
+10
-6
@@ -226,12 +226,14 @@ static void print_help(const char *filename)
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
(void)filename;
|
||||
printf("Example:\n");
|
||||
printf("%s 123 1 2 binary-value 4 5 6 7 message event\n", filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BACNET_EVENT_NOTIFICATION_DATA event_data = { 0 };
|
||||
BACNET_CHARACTER_STRING event_data_message_text = { 0 };
|
||||
unsigned long long_value = 0;
|
||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||
unsigned timeout = 100; /* milliseconds */
|
||||
@@ -251,6 +253,7 @@ int main(int argc, char *argv[])
|
||||
unsigned int target_args = 0;
|
||||
const char *filename = NULL;
|
||||
|
||||
event_data.messageText = &event_data_message_text;
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
if (strcmp(argv[argi], "--help") == 0) {
|
||||
@@ -305,11 +308,12 @@ int main(int argc, char *argv[])
|
||||
Target_Device_Object_Instance = (uint32_t)long_value;
|
||||
target_args++;
|
||||
} else if (target_args == 1) {
|
||||
if (!event_notify_parse(
|
||||
&event_data, argc - argi, &argv[argi])) {
|
||||
fprintf(stderr, "event=%s invalid\n", argv[argi]);
|
||||
} else {
|
||||
if (event_notify_parse(&event_data, argc - argi, &argv[argi])) {
|
||||
target_args++;
|
||||
break;
|
||||
} else {
|
||||
fprintf(stderr, "event parsing invalid\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
print_usage(filename);
|
||||
@@ -317,7 +321,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target_args < 14) {
|
||||
if (target_args < 2) {
|
||||
print_usage(filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user