Added ability to send Broadcast UnconfirmedPrivateTransfer using 'broadcast' argument.
This commit is contained in:
@@ -58,6 +58,7 @@
|
||||
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
||||
|
||||
/* converted command line arguments */
|
||||
static bool Target_Broadcast;
|
||||
static uint32_t Target_Device_Object_Instance = BACNET_MAX_INSTANCE;
|
||||
static uint16_t Target_Vendor_Identifier = 260;
|
||||
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"
|
||||
"I-Am services. For example, if you were transferring to\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"
|
||||
"the unique vendor identification code for the type of\r\n"
|
||||
"vendor proprietary service to be performed.\r\n" "\r\n"
|
||||
@@ -206,10 +208,15 @@ int main(
|
||||
return 0;
|
||||
}
|
||||
/* 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_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",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
@@ -272,14 +279,20 @@ int main(
|
||||
atexit(datalink_cleanup);
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
found =
|
||||
address_bind_request(Target_Device_Object_Instance, &max_apdu,
|
||||
&Target_Address);
|
||||
if (!found) {
|
||||
Send_WhoIs(Target_Device_Object_Instance,
|
||||
Target_Device_Object_Instance);
|
||||
if (Target_Broadcast) {
|
||||
datalink_get_broadcast_address(&Target_Address);
|
||||
found = true;
|
||||
timeout_seconds = 0;
|
||||
} else {
|
||||
timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
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 */
|
||||
for (;;) {
|
||||
|
||||
Reference in New Issue
Block a user