Added DeviceCommunicationControl in the demos and into the stack.
This commit is contained in:
@@ -30,6 +30,7 @@ SRCS = main.c \
|
||||
$(BACNET_HANDLER)/h_rp.c \
|
||||
$(BACNET_HANDLER)/h_iam.c \
|
||||
$(BACNET_HANDLER)/s_whois.c \
|
||||
$(BACNET_HANDLER)/s_rd.c \
|
||||
$(BACNET_OBJECT)/device.c \
|
||||
$(BACNET_OBJECT)/ai.c \
|
||||
$(BACNET_OBJECT)/ao.c \
|
||||
@@ -50,6 +51,7 @@ SRCS = main.c \
|
||||
$(BACNET_ROOT)/datalink.c \
|
||||
$(BACNET_ROOT)/address.c \
|
||||
$(BACNET_ROOT)/arf.c \
|
||||
$(BACNET_ROOT)/dcc.c \
|
||||
$(BACNET_ROOT)/abort.c \
|
||||
$(BACNET_ROOT)/reject.c \
|
||||
$(BACNET_ROOT)/bacerror.c \
|
||||
|
||||
@@ -61,72 +61,6 @@ static char *Reinitialize_Password = NULL;
|
||||
|
||||
static bool Error_Detected = false;
|
||||
|
||||
static uint8_t Send_Reinitialize_Device_Request(
|
||||
uint32_t device_id,
|
||||
BACNET_REINITIALIZED_STATE state,
|
||||
char *password)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS my_address;
|
||||
unsigned max_apdu = 0;
|
||||
uint8_t invoke_id = 0;
|
||||
bool status = false;
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
BACNET_CHARACTER_STRING password_string;
|
||||
|
||||
/* is the device bound? */
|
||||
status = address_get_by_device(device_id, &max_apdu, &dest);
|
||||
/* is there a tsm available? */
|
||||
if (status)
|
||||
status = tsm_transaction_available();
|
||||
if (status)
|
||||
{
|
||||
datalink_get_my_address(&my_address);
|
||||
pdu_len = npdu_encode_apdu(
|
||||
&Handler_Transmit_Buffer[0],
|
||||
&dest,
|
||||
&my_address,
|
||||
true, // true for confirmed messages
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
// load the data for the encoding
|
||||
characterstring_init_ansi(&password_string,password);
|
||||
pdu_len += rd_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len],
|
||||
invoke_id,
|
||||
state,
|
||||
password?&password_string:NULL);
|
||||
/* will it fit in the sender?
|
||||
note: if there is a bottleneck router in between
|
||||
us and the destination, we won't know unless
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned)pdu_len < max_apdu)
|
||||
{
|
||||
tsm_set_confirmed_unsegmented_transaction(
|
||||
invoke_id,
|
||||
&dest,
|
||||
&Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
bytes_sent = datalink_send_pdu(
|
||||
&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0],
|
||||
pdu_len); // number of bytes of data
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,"Failed to Send ReinitializeDevice Request (%s)!\n",
|
||||
strerror(errno));
|
||||
}
|
||||
else
|
||||
fprintf(stderr,"Failed to Send ReinitializeDevice Request "
|
||||
"(exceeds destination maximum APDU)!\n");
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
}
|
||||
|
||||
|
||||
static void MyErrorHandler(
|
||||
BACNET_ADDRESS *src,
|
||||
uint8_t invoke_id,
|
||||
|
||||
@@ -40,6 +40,7 @@ SRCS = main.c \
|
||||
..\..\wp.c \
|
||||
..\..\arf.c \
|
||||
..\..\awf.c \
|
||||
..\..\dcc.c \
|
||||
..\..\demo\object\bacfile.c \
|
||||
..\..\demo\object\device.c \
|
||||
..\..\demo\object\ai.c \
|
||||
|
||||
Reference in New Issue
Block a user