diff --git a/ports/atmega328/Makefile b/ports/atmega328/Makefile
index 9e322856..556b1b3b 100644
--- a/ports/atmega328/Makefile
+++ b/ports/atmega328/Makefile
@@ -112,6 +112,7 @@ BFLAGS += -DBACAPP_OBJECT_ID
BFLAGS += -DBACAPP_UNSIGNED
BFLAGS += -DBACAPP_ENUMERATED
BFLAGS += -DBACAPP_CHARACTER_STRING
+BFLAGS += -DBACNET_USE_DOUBLE=0
BFLAGS += -DWRITE_PROPERTY
BFLAGS += -DBACNET_PROTOCOL_REVISION=9
ifeq (${LEGACY},true)
diff --git a/ports/bdk-atxx4-mstp/Makefile b/ports/bdk-atxx4-mstp/Makefile
index 0f948668..5e3d49d7 100644
--- a/ports/bdk-atxx4-mstp/Makefile
+++ b/ports/bdk-atxx4-mstp/Makefile
@@ -223,6 +223,7 @@ BFLAGS += -DBACAPP_UNSIGNED
BFLAGS += -DBACAPP_ENUMERATED
BFLAGS += -DBACAPP_CHARACTER_STRING
BFLAGS += -DBACAPP_OCTET_STRING
+BFLAGS += -DBACNET_USE_DOUBLE=0
BFLAGS += -DWRITE_PROPERTY
ifeq (${LEGACY},true)
# disable deprecated function warnings for legacy builds
diff --git a/ports/xplained/Makefile b/ports/xplained/Makefile
index 86391c83..181a7f1e 100644
--- a/ports/xplained/Makefile
+++ b/ports/xplained/Makefile
@@ -186,6 +186,7 @@ BFLAGS += -DMAX_ADDRESS_CACHE=32
BFLAGS += -DMAX_ANALOG_INPUTS=8
BFLAGS += -DBACNET_PROTOCOL_REVISION=9
BFLAGS += -DBACAPP_MINIMAL
+BFLAGS += -DBACNET_USE_DOUBLE=0
ifeq (${LEGACY},true)
# disable deprecated function warnings for legacy builds
BFLAGS += -DBACNET_STACK_DEPRECATED_DISABLE
diff --git a/ports/xplained/bacnet.cproj b/ports/xplained/bacnet.cproj
index 29bf21cc..e335f869 100644
--- a/ports/xplained/bacnet.cproj
+++ b/ports/xplained/bacnet.cproj
@@ -231,6 +231,7 @@
MSTP_PDU_PACKET_COUNT=2
MAX_ADDRESS_CACHE=32
MAX_ANALOG_INPUTS=8
+ BACNET_USE_DOUBLE=0
BACNET_PROTOCOL_REVISION=9
BOARD=XMEGA_A3BU_XPLAINED
NDEBUG
@@ -337,6 +338,7 @@
MSTP_PDU_PACKET_COUNT=2
MAX_ADDRESS_CACHE=32
MAX_ANALOG_INPUTS=8
+ BACNET_USE_DOUBLE=0
BACNET_PROTOCOL_REVISION=9
DEBUG
@@ -444,6 +446,7 @@
MSTP_PDU_PACKET_COUNT=2
MAX_ADDRESS_CACHE=32
MAX_ANALOG_INPUTS=8
+ BACNET_USE_DOUBLE=0
BACNET_PROTOCOL_REVISION=9
BOARD=XMEGA_A3BU_XPLAINED
CONF_BOARD_ENABLE_RS485_XPLAINED
diff --git a/src/bacnet/bacint.c b/src/bacnet/bacint.c
index 88e43208..3ace653c 100644
--- a/src/bacnet/bacint.c
+++ b/src/bacnet/bacint.c
@@ -13,6 +13,10 @@
/* BACnet Stack API */
#include "bacnet/bacint.h"
+#ifndef BACNET_USE_SIGNED
+#define BACNET_USE_SIGNED 1
+#endif
+
int encode_unsigned16(uint8_t *apdu, uint16_t value)
{
if (apdu) {
diff --git a/src/bacnet/bacreal.c b/src/bacnet/bacreal.c
index fed116f1..d6810c7e 100644
--- a/src/bacnet/bacreal.c
+++ b/src/bacnet/bacreal.c
@@ -90,7 +90,6 @@ int encode_bacnet_real(float value, uint8_t *apdu)
}
#if BACNET_USE_DOUBLE
-
/* from clause 20.2.7 Encoding of a Double Precision Real Number Value */
/* returns the number of apdu bytes consumed */
int decode_double(const uint8_t *apdu, double *double_value)
diff --git a/src/bacnet/bacstr.c b/src/bacnet/bacstr.c
index fed102ef..081e3da6 100644
--- a/src/bacnet/bacstr.c
+++ b/src/bacnet/bacstr.c
@@ -19,6 +19,10 @@
/* BACnet Stack API */
#include "bacnet/bacstr.h"
+#ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */
+#define BACNET_USE_OCTETSTRING 1
+#endif
+
#ifndef BACNET_STRING_UTF8_VALIDATION
#define BACNET_STRING_UTF8_VALIDATION 1
#endif
diff --git a/src/bacnet/config.h b/src/bacnet/config.h
index cb440364..6dae7576 100644
--- a/src/bacnet/config.h
+++ b/src/bacnet/config.h
@@ -331,6 +331,34 @@
#define MAX_OCTET_STRING_BYTES (MAX_APDU - 6)
#endif
+/* Do we need any octet strings? */
+#ifndef BACNET_USE_OCTETSTRING
+#define BACNET_USE_OCTETSTRING 1
+#endif
+
+/* Do we need any doubles? */
+#ifndef BACNET_USE_DOUBLE
+#define BACNET_USE_DOUBLE 1
+#endif
+
+/* Do we need any signed integers */
+#ifndef BACNET_USE_SIGNED
+#define BACNET_USE_SIGNED 1
+#endif
+
+/* if a datatype is not enabled, the BACapp helper cannot use it */
+#if (BACNET_USE_OCTETSTRING == 0)
+#undef BACAPP_OCTET_STRING
+#endif
+
+#if (BACNET_USE_DOUBLE == 0)
+#undef BACAPP_DOUBLE
+#endif
+
+#if (BACNET_USE_SIGNED == 0)
+#undef BACAPP_SIGNED
+#endif
+
/**
* @note Control the selection of services etc to enable code size reduction
* for those compiler suites which do not handle removing of unused functions
@@ -339,12 +367,16 @@
* We will start with the A type services code first as these are least likely
* to be required in embedded systems using the stack.
*/
-#ifndef BACNET_SVC_SERVER
+#if !( \
+ defined(BACNET_SVC_I_HAVE_A) || defined(BACNET_SVC_WP_A) || \
+ defined(BACNET_SVC_RP_A) || defined(BACNET_SVC_RPM_A) || \
+ defined(BACNET_SVC_DCC_A) || defined(BACNET_SVC_RD_A) || \
+ defined(BACNET_SVC_TS_A) || defined(BACNET_SVC_SERVER))
/* default to client-server device for the example apps to build. */
#define BACNET_SVC_SERVER 0
#endif
-#if (BACNET_SVC_SERVER == 0)
+#if defined(BACNET_SVC_SERVER) && (BACNET_SVC_SERVER == 0)
/* client-server device */
#define BACNET_SVC_I_HAVE_A 1
#define BACNET_SVC_WP_A 1
@@ -353,9 +385,6 @@
#define BACNET_SVC_DCC_A 1
#define BACNET_SVC_RD_A 1
#define BACNET_SVC_TS_A 1
-#define BACNET_USE_OCTETSTRING 1
-#define BACNET_USE_DOUBLE 1
-#define BACNET_USE_SIGNED 1
#endif
/* Do them one by one */
@@ -383,16 +412,4 @@
#define BACNET_SVC_RD_A 0
#endif
-#ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */
-#define BACNET_USE_OCTETSTRING 0
-#endif
-
-#ifndef BACNET_USE_DOUBLE /* Do we need any doubles? */
-#define BACNET_USE_DOUBLE 0
-#endif
-
-#ifndef BACNET_USE_SIGNED /* Do we need any signed integers */
-#define BACNET_USE_SIGNED 0
-#endif
-
#endif
diff --git a/src/bacnet/proplist.c b/src/bacnet/proplist.c
index 102fa0a2..e0d1c5ad 100644
--- a/src/bacnet/proplist.c
+++ b/src/bacnet/proplist.c
@@ -378,9 +378,11 @@ static const int Properties_BACnetARRAY[] = {
PROP_EXCEPTION_SCHEDULE,
PROP_TAGS,
PROP_ISSUER_CERTIFICATE_FILES,
- PROP_SC_HUB_FUNCTION_ACCEPT_URIS,
PROP_NEGATIVE_ACCESS_RULES,
PROP_POSITIVE_ACCESS_RULES,
+#if (INT_MAX > 0xFFFF)
+ PROP_SC_HUB_FUNCTION_ACCEPT_URIS,
+#endif
-1
};
diff --git a/src/bacnet/whois.h b/src/bacnet/whois.h
index c0a6ecc2..02be8e23 100644
--- a/src/bacnet/whois.h
+++ b/src/bacnet/whois.h
@@ -19,6 +19,8 @@ extern "C" {
/* encode service - use -1 for limit if you want unlimited */
BACNET_STACK_EXPORT
+int whois_request_encode(uint8_t *apdu, int32_t low_limit, int32_t high_limit);
+BACNET_STACK_EXPORT
int whois_encode_apdu(uint8_t *apdu, int32_t low_limit, int32_t high_limit);
BACNET_STACK_EXPORT