Moved APDU Timeout and Retries to apdu module.
This commit is contained in:
@@ -115,7 +115,7 @@ void MyDeviceCommunicationControlSimpleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* handle i-am to support binding to other devices */
|
||||
@@ -274,7 +274,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
|
||||
/* loop forever */
|
||||
|
||||
@@ -432,7 +432,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
found =
|
||||
address_bind_request(Target_Device_Object_Instance, &max_apdu,
|
||||
|
||||
@@ -127,7 +127,6 @@ static char Description[16] = "server";
|
||||
/* Protocol_Services_Supported - dynamically generated */
|
||||
/* Protocol_Object_Types_Supported - in RP encoding */
|
||||
/* Object_List - dynamically generated */
|
||||
/* static uint16_t Max_APDU_Length_Accepted = MAX_APDU; - constant */
|
||||
/* static BACNET_SEGMENTATION Segmentation_Supported = SEGMENTATION_NONE; */
|
||||
/* static uint8_t Max_Segments_Accepted = 0; */
|
||||
/* VT_Classes_Supported */
|
||||
@@ -137,9 +136,6 @@ BACNET_DATE Local_Date; /* rely on OS, if there is one */
|
||||
/* BACnet UTC is inverse of standard offset - i.e. relative to local */
|
||||
static int UTC_Offset = 5;
|
||||
static bool Daylight_Savings_Status = false; /* rely on OS */
|
||||
/* APDU_Segment_Timeout */
|
||||
static uint16_t APDU_Timeout = 3000;
|
||||
static uint8_t Number_Of_APDU_Retries = 3;
|
||||
/* List_Of_Session_Keys */
|
||||
/* Time_Synchronization_Recipients */
|
||||
/* Max_Master - rely on MS/TP subsystem, if there is one */
|
||||
@@ -341,43 +337,12 @@ uint8_t Device_Protocol_Revision(
|
||||
return BACNET_PROTOCOL_REVISION;
|
||||
}
|
||||
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
BACNET_SEGMENTATION Device_Segmentation_Supported(
|
||||
void)
|
||||
{
|
||||
return SEGMENTATION_NONE;
|
||||
}
|
||||
|
||||
uint16_t Device_APDU_Timeout(
|
||||
void)
|
||||
{
|
||||
return APDU_Timeout;
|
||||
}
|
||||
|
||||
/* in milliseconds */
|
||||
void Device_Set_APDU_Timeout(
|
||||
uint16_t timeout)
|
||||
{
|
||||
APDU_Timeout = timeout;
|
||||
}
|
||||
|
||||
uint8_t Device_Number_Of_APDU_Retries(
|
||||
void)
|
||||
{
|
||||
return Number_Of_APDU_Retries;
|
||||
}
|
||||
|
||||
void Device_Set_Number_Of_APDU_Retries(
|
||||
uint8_t retries)
|
||||
{
|
||||
Number_Of_APDU_Retries = retries;
|
||||
}
|
||||
|
||||
uint8_t Device_Database_Revision(
|
||||
void)
|
||||
{
|
||||
@@ -842,8 +807,7 @@ int Device_Encode_Property_APDU(
|
||||
break;
|
||||
case PROP_MAX_APDU_LENGTH_ACCEPTED:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Device_Max_APDU_Length_Accepted());
|
||||
encode_application_unsigned(&apdu[0],MAX_APDU);
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
apdu_len =
|
||||
@@ -851,11 +815,11 @@ int Device_Encode_Property_APDU(
|
||||
Device_Segmentation_Supported());
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
apdu_len = encode_application_unsigned(&apdu[0], APDU_Timeout);
|
||||
apdu_len = encode_application_unsigned(&apdu[0], apdu_timeout());
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0], Number_Of_APDU_Retries);
|
||||
encode_application_unsigned(&apdu[0], apdu_retries());
|
||||
break;
|
||||
case PROP_DEVICE_ADDRESS_BINDING:
|
||||
/* FIXME: encode the list here, if it exists */
|
||||
@@ -930,7 +894,7 @@ bool Device_Write_Property(
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_Number_Of_APDU_Retries((uint8_t) value.type.
|
||||
apdu_retries_set((uint8_t) value.type.
|
||||
Unsigned_Int);
|
||||
status = true;
|
||||
} else {
|
||||
@@ -941,7 +905,7 @@ bool Device_Write_Property(
|
||||
case PROP_APDU_TIMEOUT:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_APDU_Timeout((uint16_t) value.type.Unsigned_Int);
|
||||
apdu_timeout_set((uint16_t) value.type.Unsigned_Int);
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -174,7 +174,7 @@ static void LocalIAmHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* handle i-am to support binding to other devices */
|
||||
@@ -326,7 +326,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
|
||||
/* loop forever */
|
||||
|
||||
@@ -307,7 +307,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
found =
|
||||
address_bind_request(Target_Device_Object_Instance, &max_apdu,
|
||||
|
||||
@@ -113,7 +113,7 @@ void MyReinitializeDeviceSimpleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* handle i-am to support binding to other devices */
|
||||
@@ -268,7 +268,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
|
||||
/* loop forever */
|
||||
|
||||
@@ -85,7 +85,7 @@ void MyRejectHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* set the handler for all the services we don't implement
|
||||
@@ -230,7 +230,7 @@ int main(int argc, char *argv[]) {
|
||||
Init_DataLink();
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds = Device_APDU_Timeout() / 1000;
|
||||
timeout_seconds = apdu_timeout() / 1000;
|
||||
/* send the request */
|
||||
time(&rawtime);
|
||||
my_time = localtime(&rawtime);
|
||||
|
||||
@@ -88,7 +88,7 @@ void MyRejectHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* set the handler for all the services we don't implement
|
||||
@@ -234,7 +234,7 @@ int main(int argc, char *argv[]) {
|
||||
Init_DataLink();
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds = Device_APDU_Timeout() / 1000;
|
||||
timeout_seconds = apdu_timeout() / 1000;
|
||||
/* send the request */
|
||||
if (argc < 3)
|
||||
Send_WhoHas_Name(-1, -1, Target_Object_Name);
|
||||
|
||||
@@ -294,7 +294,7 @@ int main(int argc, char *argv[]) {
|
||||
Init_DataLink();
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds = Device_APDU_Timeout() / 1000;
|
||||
timeout_seconds = apdu_timeout() / 1000;
|
||||
/* send the request */
|
||||
Send_WhoIs(Target_Object_Instance_Min, Target_Object_Instance_Max);
|
||||
/* loop forever */
|
||||
|
||||
@@ -131,7 +131,7 @@ static void LocalIAmHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* handle i-am to support binding to other devices */
|
||||
@@ -283,7 +283,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
|
||||
/* loop forever */
|
||||
|
||||
@@ -126,7 +126,7 @@ void MyWritePropertySimpleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* we need to handle who-is
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
/* handle i-am to support binding to other devices */
|
||||
@@ -403,7 +403,7 @@ int main(int argc, char *argv[]) {
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds =
|
||||
(Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries();
|
||||
(apdu_timeout() / 1000) * apdu_retries();
|
||||
/* try to bind with the device */
|
||||
found =
|
||||
address_bind_request(Target_Device_Object_Instance, &max_apdu,
|
||||
|
||||
@@ -176,6 +176,11 @@ extern "C" {
|
||||
uint8_t ** service_request,
|
||||
uint16_t * service_request_len);
|
||||
|
||||
uint16_t apdu_timeout(void);
|
||||
void apdu_timeout_set(uint16_t value);
|
||||
uint8_t apdu_retries(void);
|
||||
void apdu_retries_set(uint8_t value);
|
||||
|
||||
void apdu_handler(
|
||||
BACNET_ADDRESS * src, /* source address */
|
||||
uint8_t * apdu, /* APDU data */
|
||||
|
||||
@@ -105,21 +105,9 @@ extern "C" {
|
||||
void);
|
||||
uint8_t Device_Protocol_Revision(
|
||||
void);
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void);
|
||||
BACNET_SEGMENTATION Device_Segmentation_Supported(
|
||||
void);
|
||||
|
||||
uint16_t Device_APDU_Timeout(
|
||||
void);
|
||||
void Device_Set_APDU_Timeout(
|
||||
uint16_t timeout);
|
||||
|
||||
uint8_t Device_Number_Of_APDU_Retries(
|
||||
void);
|
||||
void Device_Set_Number_Of_APDU_Retries(
|
||||
uint8_t retries);
|
||||
|
||||
uint8_t Device_Database_Revision(
|
||||
void);
|
||||
void Device_Set_Database_Revision(
|
||||
|
||||
@@ -137,32 +137,12 @@ uint8_t Device_Protocol_Revision(
|
||||
return 5;
|
||||
}
|
||||
|
||||
/* FIXME: MAX_APDU is defined in config.ini - set it! */
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
BACNET_SEGMENTATION Device_Segmentation_Supported(
|
||||
void)
|
||||
{
|
||||
return SEGMENTATION_NONE;
|
||||
}
|
||||
|
||||
uint16_t Device_APDU_Timeout(
|
||||
void)
|
||||
{
|
||||
return 60000;
|
||||
}
|
||||
|
||||
|
||||
uint8_t Device_Number_Of_APDU_Retries(
|
||||
void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Device_Database_Revision(
|
||||
void)
|
||||
{
|
||||
@@ -418,8 +398,7 @@ int Device_Encode_Property_APDU(
|
||||
break;
|
||||
case PROP_MAX_APDU_LENGTH_ACCEPTED:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Device_Max_APDU_Length_Accepted());
|
||||
encode_application_unsigned(&apdu[0], MAX_APDU);
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
apdu_len =
|
||||
@@ -428,12 +407,12 @@ int Device_Encode_Property_APDU(
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0], Device_APDU_Timeout());
|
||||
encode_application_unsigned(&apdu[0], apdu_timeout());
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Device_Number_Of_APDU_Retries());
|
||||
apdu_retries());
|
||||
break;
|
||||
case PROP_DEVICE_ADDRESS_BINDING:
|
||||
/* FIXME: encode the list here, if it exists */
|
||||
|
||||
@@ -137,32 +137,12 @@ uint8_t Device_Protocol_Revision(
|
||||
return 5;
|
||||
}
|
||||
|
||||
/* FIXME: MAX_APDU is defined in config.ini - set it! */
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
BACNET_SEGMENTATION Device_Segmentation_Supported(
|
||||
void)
|
||||
{
|
||||
return SEGMENTATION_NONE;
|
||||
}
|
||||
|
||||
uint16_t Device_APDU_Timeout(
|
||||
void)
|
||||
{
|
||||
return 60000;
|
||||
}
|
||||
|
||||
|
||||
uint8_t Device_Number_Of_APDU_Retries(
|
||||
void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Device_Database_Revision(
|
||||
void)
|
||||
{
|
||||
@@ -430,8 +410,7 @@ int Device_Encode_Property_APDU(
|
||||
break;
|
||||
case PROP_MAX_APDU_LENGTH_ACCEPTED:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Device_Max_APDU_Length_Accepted());
|
||||
encode_application_unsigned(&apdu[0], MAX_APDU);
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
apdu_len =
|
||||
@@ -440,12 +419,12 @@ int Device_Encode_Property_APDU(
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0], Device_APDU_Timeout());
|
||||
encode_application_unsigned(&apdu[0], apdu_timeout());
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Device_Number_Of_APDU_Retries());
|
||||
apdu_retries());
|
||||
break;
|
||||
case PROP_DEVICE_ADDRESS_BINDING:
|
||||
/* FIXME: encode the list here, if it exists */
|
||||
|
||||
@@ -43,6 +43,11 @@
|
||||
#include "dcc.h"
|
||||
#include "iam.h"
|
||||
|
||||
/* APDU Timeout in Milliseconds */
|
||||
static uint16_t Timeout_Milliseconds = 3000;
|
||||
/* Number of APDU Retries */
|
||||
static uint8_t Number_Of_Retries = 3;
|
||||
|
||||
/* a simple table for crossing the services supported */
|
||||
static BACNET_SERVICES_SUPPORTED
|
||||
confirmed_service_supported[MAX_BACNET_CONFIRMED_SERVICE] = {
|
||||
@@ -280,6 +285,26 @@ uint16_t apdu_decode_confirmed_service_request(
|
||||
return len;
|
||||
}
|
||||
|
||||
uint16_t apdu_timeout(void)
|
||||
{
|
||||
return Timeout_Milliseconds;
|
||||
}
|
||||
|
||||
void apdu_timeout_set(uint16_t milliseconds)
|
||||
{
|
||||
Timeout_Milliseconds = milliseconds;
|
||||
}
|
||||
|
||||
uint8_t apdu_retries(void)
|
||||
{
|
||||
return Number_Of_Retries;
|
||||
}
|
||||
|
||||
void apdu_retries_set(uint8_t value)
|
||||
{
|
||||
Number_Of_Retries = value;
|
||||
}
|
||||
|
||||
void apdu_handler(
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t * apdu, /* APDU data */
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "bacenum.h"
|
||||
#include "bacdcode.h"
|
||||
#include "bacdef.h"
|
||||
#include "device.h"
|
||||
#include "arf.h"
|
||||
|
||||
/* Atomic Read File */
|
||||
@@ -51,7 +50,7 @@ int arf_encode_apdu(
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] =
|
||||
encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted());
|
||||
encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_ATOMIC_READ_FILE; /* service choice */
|
||||
apdu_len = 4;
|
||||
@@ -185,7 +184,7 @@ int arf_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_ATOMIC_READ_FILE)
|
||||
return -1;
|
||||
@@ -497,12 +496,6 @@ void testAtomicReadFile(
|
||||
}
|
||||
|
||||
#ifdef TEST_ATOMIC_READ_FILE
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
|
||||
+2
-10
@@ -35,7 +35,6 @@
|
||||
#include "bacenum.h"
|
||||
#include "bacdcode.h"
|
||||
#include "bacdef.h"
|
||||
#include "device.h"
|
||||
#include "awf.h"
|
||||
|
||||
/* Atomic Write File */
|
||||
@@ -50,8 +49,7 @@ int awf_encode_apdu(
|
||||
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] =
|
||||
encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted());
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_ATOMIC_WRITE_FILE; /* service choice */
|
||||
apdu_len = 4;
|
||||
@@ -198,7 +196,7 @@ int awf_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_ATOMIC_WRITE_FILE)
|
||||
return -1;
|
||||
@@ -419,12 +417,6 @@ void testAtomicWriteFileAck(
|
||||
}
|
||||
|
||||
#ifdef TEST_ATOMIC_WRITE_FILE
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
|
||||
+6
-16
@@ -37,7 +37,6 @@
|
||||
#include "bacdef.h"
|
||||
#include "bacapp.h"
|
||||
#include "cov.h"
|
||||
#include "device.h"
|
||||
#include "datalink.h"
|
||||
#include "npdu.h"
|
||||
|
||||
@@ -132,11 +131,10 @@ int ccov_notify_encode_apdu(
|
||||
{
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
uint16_t max_apdu = Device_Max_APDU_Length_Accepted();
|
||||
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] = encode_max_segs_max_apdu(0, max_apdu);
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_COV_NOTIFICATION;
|
||||
apdu_len = 4;
|
||||
@@ -314,11 +312,10 @@ int cov_subscribe_encode_adpu(
|
||||
{
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
uint16_t max_apdu = Device_Max_APDU_Length_Accepted();
|
||||
|
||||
if (apdu && data) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] = encode_max_segs_max_apdu(0, max_apdu);
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_SUBSCRIBE_COV;
|
||||
apdu_len = 4;
|
||||
@@ -444,11 +441,10 @@ int cov_subscribe_property_encode_adpu(
|
||||
{
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
uint16_t max_apdu = Device_Max_APDU_Length_Accepted();
|
||||
|
||||
if (apdu && data) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] = encode_max_segs_max_apdu(0, max_apdu);
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_SUBSCRIBE_COV_PROPERTY;
|
||||
apdu_len = 4;
|
||||
@@ -641,7 +637,7 @@ int ccov_notify_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -2;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_COV_NOTIFICATION)
|
||||
return -3;
|
||||
@@ -697,7 +693,7 @@ int cov_subscribe_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -2;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_SUBSCRIBE_COV)
|
||||
return -3;
|
||||
@@ -727,7 +723,7 @@ int cov_subscribe_property_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -2;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_SUBSCRIBE_COV_PROPERTY)
|
||||
return -3;
|
||||
@@ -784,12 +780,6 @@ void datalink_get_broadcast_address(
|
||||
}
|
||||
|
||||
/* dummy function stubs */
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
void testCOVNotifyData(
|
||||
Test * pTest,
|
||||
BACNET_COV_DATA * data,
|
||||
|
||||
@@ -232,7 +232,7 @@ int dcc_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL)
|
||||
return -1;
|
||||
|
||||
@@ -125,7 +125,7 @@ int rd_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_REINITIALIZE_DEVICE)
|
||||
return -1;
|
||||
|
||||
@@ -272,7 +272,7 @@ int rp_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_READ_PROPERTY)
|
||||
return -1;
|
||||
|
||||
@@ -149,7 +149,7 @@ int rpm_decode_object_end(
|
||||
/* decode the object property portion of the service request only */
|
||||
/* BACnetPropertyReference ::= SEQUENCE {
|
||||
propertyIdentifier [0] BACnetPropertyIdentifier,
|
||||
propertyArrayIndex [1] Unsigned OPTIONAL
|
||||
propertyArrayIndex [1] Unsigned OPTIONAL
|
||||
--used only with array datatype
|
||||
-- if omitted with an array the entire array is referenced
|
||||
}
|
||||
@@ -442,7 +442,7 @@ int rpm_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_READ_PROP_MULTIPLE)
|
||||
return -1;
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "bacenum.h"
|
||||
#include "tsm.h"
|
||||
#include "config.h"
|
||||
#include "device.h"
|
||||
#include "datalink.h"
|
||||
#include "handlers.h"
|
||||
#include "address.h"
|
||||
@@ -151,7 +150,7 @@ uint8_t tsm_next_free_invokeID(
|
||||
if (index != MAX_TSM_TRANSACTIONS) {
|
||||
TSM_List[index].InvokeID = invokeID = current_invokeID;
|
||||
TSM_List[index].state = TSM_STATE_IDLE;
|
||||
TSM_List[index].RequestTimer = Device_APDU_Timeout();
|
||||
TSM_List[index].RequestTimer = apdu_timeout();
|
||||
/* update for the next call or check */
|
||||
current_invokeID++;
|
||||
/* skip zero - we treat that internally as invalid or no free */
|
||||
@@ -189,9 +188,9 @@ void tsm_set_confirmed_unsegmented_transaction(
|
||||
if (index < MAX_TSM_TRANSACTIONS) {
|
||||
/* assign the transaction */
|
||||
TSM_List[index].state = TSM_STATE_AWAIT_CONFIRMATION;
|
||||
TSM_List[index].RetryCount = Device_Number_Of_APDU_Retries();
|
||||
TSM_List[index].RetryCount = apdu_retries();
|
||||
/* start the timer */
|
||||
TSM_List[index].RequestTimer = Device_APDU_Timeout();
|
||||
TSM_List[index].RequestTimer = apdu_timeout();
|
||||
/* copy the data */
|
||||
for (j = 0; j < apdu_len; j++) {
|
||||
TSM_List[index].apdu[j] = apdu[j];
|
||||
@@ -254,7 +253,7 @@ void tsm_timer_milliseconds(
|
||||
/* timeout. retry? */
|
||||
if (TSM_List[i].RequestTimer == 0) {
|
||||
TSM_List[i].RetryCount--;
|
||||
TSM_List[i].RequestTimer = Device_APDU_Timeout();
|
||||
TSM_List[i].RequestTimer = apdu_timeout();
|
||||
if (TSM_List[i].RetryCount) {
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&TSM_List[i].dest,
|
||||
|
||||
+2
-10
@@ -35,7 +35,6 @@
|
||||
#include "bacenum.h"
|
||||
#include "bacdcode.h"
|
||||
#include "bacdef.h"
|
||||
#include "device.h"
|
||||
#include "wp.h"
|
||||
|
||||
/* encode service */
|
||||
@@ -49,8 +48,7 @@ int wp_encode_apdu(
|
||||
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] =
|
||||
encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted());
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_WRITE_PROPERTY; /* service choice */
|
||||
apdu_len = 4;
|
||||
@@ -194,7 +192,7 @@ int wp_decode_apdu(
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
return -1;
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, Device_Max_APDU_Length_Accepted()); */
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_WRITE_PROPERTY)
|
||||
return -1;
|
||||
@@ -365,12 +363,6 @@ void testWriteProperty(
|
||||
}
|
||||
|
||||
#ifdef TEST_WRITE_PROPERTY
|
||||
uint16_t Device_Max_APDU_Length_Accepted(
|
||||
void)
|
||||
{
|
||||
return MAX_APDU;
|
||||
}
|
||||
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user