Added ability to send Broadcast UnconfirmedPrivateTransfer using 'broadcast' argument.

This commit is contained in:
skarg
2012-07-11 16:21:09 +00:00
parent b6b852ef08
commit 5244c2368a
+23 -10
View File
@@ -58,6 +58,7 @@
static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/* converted command line arguments */ /* converted command line arguments */
static bool Target_Broadcast;
static uint32_t Target_Device_Object_Instance = BACNET_MAX_INSTANCE; static uint32_t Target_Device_Object_Instance = BACNET_MAX_INSTANCE;
static uint16_t Target_Vendor_Identifier = 260; static uint16_t Target_Vendor_Identifier = 260;
static uint32_t Target_Service_Number = 0; static uint32_t Target_Service_Number = 0;
@@ -179,6 +180,7 @@ int main(
"to try and bind with the device using Who-Is and\r\n" "to try and bind with the device using Who-Is and\r\n"
"I-Am services. For example, if you were transferring to\r\n" "I-Am services. For example, if you were transferring to\r\n"
"Device Object 123, the device-instance would be 123.\r\n" "Device Object 123, the device-instance would be 123.\r\n"
"For Broadcast, use the word broadcast.\r\n"
"\r\n" "vendor_id:\r\n" "\r\n" "vendor_id:\r\n"
"the unique vendor identification code for the type of\r\n" "the unique vendor identification code for the type of\r\n"
"vendor proprietary service to be performed.\r\n" "\r\n" "vendor proprietary service to be performed.\r\n" "\r\n"
@@ -206,10 +208,15 @@ int main(
return 0; return 0;
} }
/* decode the command line parameters */ /* decode the command line parameters */
Target_Device_Object_Instance = strtol(argv[1], NULL, 0); if (strcmp(argv[1], "broadcast") == 0) {
Target_Broadcast = true;
} else {
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
}
Target_Vendor_Identifier = strtol(argv[2], NULL, 0); Target_Vendor_Identifier = strtol(argv[2], NULL, 0);
Target_Service_Number = strtol(argv[3], NULL, 0); Target_Service_Number = strtol(argv[3], NULL, 0);
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) { if ((!Target_Broadcast) &&
(Target_Device_Object_Instance > BACNET_MAX_INSTANCE)) {
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n", fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
Target_Device_Object_Instance, BACNET_MAX_INSTANCE); Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
return 1; return 1;
@@ -272,14 +279,20 @@ int main(
atexit(datalink_cleanup); atexit(datalink_cleanup);
/* configure the timeout values */ /* configure the timeout values */
last_seconds = time(NULL); last_seconds = time(NULL);
timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); if (Target_Broadcast) {
/* try to bind with the device */ datalink_get_broadcast_address(&Target_Address);
found = found = true;
address_bind_request(Target_Device_Object_Instance, &max_apdu, timeout_seconds = 0;
&Target_Address); } else {
if (!found) { timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
Send_WhoIs(Target_Device_Object_Instance, /* try to bind with the device */
Target_Device_Object_Instance); found =
address_bind_request(Target_Device_Object_Instance, &max_apdu,
&Target_Address);
if (!found) {
Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
}
} }
/* loop forever */ /* loop forever */
for (;;) { for (;;) {