|
1 /************************************************************************** |
|
2 * |
|
3 * Copyright (C) 2004 Steve Karg <skarg@users.sourceforge.net> |
|
4 * Copyright (C) 2017 Mario de Sousa <msousa@fe.up.pt> |
|
5 * |
|
6 * Permission is hereby granted, free of charge, to any person obtaining |
|
7 * a copy of this software and associated documentation files (the |
|
8 * "Software"), to deal in the Software without restriction, including |
|
9 * without limitation the rights to use, copy, modify, merge, publish, |
|
10 * distribute, sublicense, and/or sell copies of the Software, and to |
|
11 * permit persons to whom the Software is furnished to do so, subject to |
|
12 * the following conditions: |
|
13 * |
|
14 * The above copyright notice and this permission notice shall be included |
|
15 * in all copies or substantial portions of the Software. |
|
16 * |
|
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
24 * |
|
25 *********************************************************************/ |
|
26 |
|
27 |
|
28 #ifndef CONFIG_BACNET_FOR_BEREMIZ_H |
|
29 #define CONFIG_BACNET_FOR_BEREMIZ_H |
|
30 |
|
31 #ifdef CONFIG_H |
|
32 #error "config.h already processed! (config_bacnet_for_beremiz.h should be included before config.h)" |
|
33 #endif |
|
34 |
|
35 /* Compilaton options for BACnet library, configured for the BACnet sserver |
|
36 * running on Beremiz. |
|
37 */ |
|
38 |
|
39 /* declare a single physical layer using your compiler define. |
|
40 * see datalink.h for possible defines. |
|
41 */ |
|
42 /* Use BACnet/IP */ |
|
43 #define BACDL_BIP |
|
44 |
|
45 /* optional configuration for BACnet/IP datalink layers */ |
|
46 /* other BIP defines (define as 1 to enable): |
|
47 USE_INADDR - uses INADDR_BROADCAST for broadcast and binds using INADDR_ANY |
|
48 USE_CLASSADDR = uses IN_CLASSx_HOST where x=A,B,C or D for broadcast |
|
49 */ |
|
50 #define BBMD_ENABLED 1 |
|
51 |
|
52 /* name of file in which BDT table will be stored */ |
|
53 #define BBMD_BACKUP_FILE beremiz_BACnet_BDT_table |
|
54 |
|
55 /* Enable the Gateway (Routing) functionality here, if desired. */ |
|
56 #define MAX_NUM_DEVICES 1 /* Just the one normal BACnet Device Object */ |
|
57 |
|
58 |
|
59 /* Define your processor architecture as |
|
60 Big Endian (PowerPC,68K,Sparc) or Little Endian (Intel,AVR) |
|
61 ARM and MIPS can be either - what is your setup? */ |
|
62 |
|
63 /* WARNING: The following files are being included: |
|
64 * <stdib.h> --> <endian.h> --> <bits/endian.h> |
|
65 * |
|
66 * endian.h defines the following constants as: |
|
67 * #define __LITTLE_ENDIAN and LITTLE_ENDIAN as 1234 |
|
68 * #define __BIG_ENDIAN and BIG_ENDIAN as 4321 |
|
69 * #define __PDP_ENDIAN and PDP_ENDIAN as 3412 |
|
70 * |
|
71 * bits/endian.h defines the constant BYTE_ORDER as: |
|
72 * #define __BYTE_ORDER as __LITTLE_ENDIAN |
|
73 * |
|
74 * endian.h then sets the following constants |
|
75 * (if __USE_BSD is set, which seems to be true): |
|
76 * # define LITTLE_ENDIAN __LITTLE_ENDIAN |
|
77 * # define BIG_ENDIAN __BIG_ENDIAN |
|
78 * # define PDP_ENDIAN __PDP_ENDIAN |
|
79 * # define BYTE_ORDER __BYTE_ORDER |
|
80 * |
|
81 * CONCLUSION: |
|
82 * The bacnet library uses the BIG_ENDIAN constant (set to 0, or anything <>0) |
|
83 * to indicate whether we are compiling on a little or big endian platform. |
|
84 * However, <stdlib.h> is defining this same constant as '4321' !!! |
|
85 * The decision to use BIG_ENDIAN as the constant is a unfortunate |
|
86 * on the part of the bacnet coders, but we live with it for now... |
|
87 * We simply start off by undefining the BIG_ENDIAN constant, and carry |
|
88 * on from there! |
|
89 */ |
|
90 #undef BIG_ENDIAN |
|
91 |
|
92 #ifndef BIG_ENDIAN |
|
93 #if defined(__GNUC__) |
|
94 /* We have GCC, which should define __LITTLE_ENDIAN__ or __BIG_ENDIAN__ */ |
|
95 # if defined(__LITTLE_ENDIAN__) |
|
96 /*# warning "Using gcc to determine platform endianness."*/ |
|
97 # define BIG_ENDIAN 0 |
|
98 # elif defined(__BIG_ENDIAN__) |
|
99 /*# warning "Using gcc to determine platform endianness."*/ |
|
100 # define BIG_ENDIAN 1 |
|
101 # endif |
|
102 #endif /* __GNUC__ */ |
|
103 #endif /* BIG_ENDIAN */ |
|
104 |
|
105 |
|
106 /* If we still don't know byte order, try to get it from <endian.h> */ |
|
107 #ifndef BIG_ENDIAN |
|
108 #include <endian.h> |
|
109 # ifdef BYTE_ORDER |
|
110 # if BYTE_ORDER == LITTLE_ENDIAN |
|
111 /*# warning "Using <endian.h> to determine platform endianness."*/ |
|
112 # undef BIG_ENDIAN |
|
113 # define BIG_ENDIAN 0 |
|
114 # elif BYTE_ORDER == BIG_ENDIAN |
|
115 /*# warning "Using <endian.h> to determine platform endianness."*/ |
|
116 # undef BIG_ENDIAN |
|
117 # define BIG_ENDIAN 1 |
|
118 # else |
|
119 # undef BIG_ENDIAN |
|
120 # endif |
|
121 # endif /* BYTE_ORDER */ |
|
122 #endif /* BIG_ENDIAN */ |
|
123 |
|
124 |
|
125 #ifndef BIG_ENDIAN |
|
126 #error "Unable to determine platform's byte order. Aborting compilation." |
|
127 #elif BIG_ENDIAN |
|
128 /*#warning "Compiling for BIG endian platform."*/ |
|
129 #else |
|
130 /*#warning "Compiling for LITTLE endian platform."*/ |
|
131 #endif |
|
132 |
|
133 |
|
134 |
|
135 /* Define your Vendor Identifier assigned by ASHRAE */ |
|
136 #define BACNET_VENDOR_ID %(BACnet_Vendor_ID)s |
|
137 #define BACNET_VENDOR_NAME "%(BACnet_Vendor_Name)s" |
|
138 #define BACNET_DEVICE_MODEL_NAME "%(BACnet_Model_Name)s" |
|
139 #define BACNET_FIRMWARE_REVISION "Beremiz BACnet Extension, BACnet Stack:" BACNET_VERSION_TEXT |
|
140 #define BACNET_DEVICE_LOCATION "%(BACnet_Device_Location)s" |
|
141 #define BACNET_DEVICE_DESCRIPTION "%(BACnet_Device_Description)s" |
|
142 #define BACNET_DEVICE_APPSOFT_VER "%(BACnet_Device_AppSoft_Version)s" |
|
143 |
|
144 |
|
145 /* Max number of bytes in an APDU. */ |
|
146 /* Typical sizes are 50, 128, 206, 480, 1024, and 1476 octets */ |
|
147 /* This is used in constructing messages and to tell others our limits */ |
|
148 /* 50 is the minimum; adjust to your memory and physical layer constraints */ |
|
149 /* Lon=206, MS/TP=480, ARCNET=480, Ethernet=1476, BACnet/IP=1476 */ |
|
150 #define MAX_APDU 1476 |
|
151 /* #define MAX_APDU 128 enable this IP for testing readrange so you get the More Follows flag set */ |
|
152 |
|
153 |
|
154 /* for confirmed messages, this is the number of transactions */ |
|
155 /* that we hold in a queue waiting for timeout. */ |
|
156 /* Configure to zero if you don't want any confirmed messages */ |
|
157 /* Configure from 1..255 for number of outstanding confirmed */ |
|
158 /* requests available. */ |
|
159 #define MAX_TSM_TRANSACTIONS 255 |
|
160 |
|
161 /* The address cache is used for binding to BACnet devices */ |
|
162 /* The number of entries corresponds to the number of */ |
|
163 /* devices that might respond to an I-Am on the network. */ |
|
164 /* If your device is a simple server and does not need to bind, */ |
|
165 /* then you don't need to use this. */ |
|
166 #define MAX_ADDRESS_CACHE 255 |
|
167 |
|
168 /* some modules have debugging enabled using PRINT_ENABLED */ |
|
169 #define PRINT_ENABLED 0 |
|
170 |
|
171 |
|
172 /* BACAPP decodes WriteProperty service requests |
|
173 Choose the datatypes that your application supports */ |
|
174 #if !(defined(BACAPP_ALL) || \ |
|
175 defined(BACAPP_NULL) || \ |
|
176 defined(BACAPP_BOOLEAN) || \ |
|
177 defined(BACAPP_UNSIGNED) || \ |
|
178 defined(BACAPP_SIGNED) || \ |
|
179 defined(BACAPP_REAL) || \ |
|
180 defined(BACAPP_DOUBLE) || \ |
|
181 defined(BACAPP_OCTET_STRING) || \ |
|
182 defined(BACAPP_CHARACTER_STRING) || \ |
|
183 defined(BACAPP_BIT_STRING) || \ |
|
184 defined(BACAPP_ENUMERATED) || \ |
|
185 defined(BACAPP_DATE) || \ |
|
186 defined(BACAPP_TIME) || \ |
|
187 defined(BACAPP_OBJECT_ID) || \ |
|
188 defined(BACAPP_DEVICE_OBJECT_PROP_REF)) |
|
189 #define BACAPP_ALL |
|
190 #endif |
|
191 |
|
192 #if defined (BACAPP_ALL) |
|
193 #define BACAPP_NULL |
|
194 #define BACAPP_BOOLEAN |
|
195 #define BACAPP_UNSIGNED |
|
196 #define BACAPP_SIGNED |
|
197 #define BACAPP_REAL |
|
198 #define BACAPP_DOUBLE |
|
199 #define BACAPP_OCTET_STRING |
|
200 #define BACAPP_CHARACTER_STRING |
|
201 #define BACAPP_BIT_STRING |
|
202 #define BACAPP_ENUMERATED |
|
203 #define BACAPP_DATE |
|
204 #define BACAPP_TIME |
|
205 #define BACAPP_OBJECT_ID |
|
206 #define BACAPP_DEVICE_OBJECT_PROP_REF |
|
207 #endif |
|
208 |
|
209 /* |
|
210 ** Set the maximum vector type sizes |
|
211 */ |
|
212 #define MAX_BITSTRING_BYTES (15) |
|
213 #define MAX_CHARACTER_STRING_BYTES (MAX_APDU-6) |
|
214 #define MAX_OCTET_STRING_BYTES (MAX_APDU-6) |
|
215 |
|
216 /* |
|
217 ** Control the selection of services etc to enable code size reduction for those |
|
218 ** compiler suites which do not handle removing of unused functions in modules |
|
219 ** so well. |
|
220 ** |
|
221 ** We will start with the A type services code first as these are least likely |
|
222 ** to be required in embedded systems using the stack. |
|
223 */ |
|
224 |
|
225 /* |
|
226 ** Define the services that may be required. |
|
227 ** |
|
228 **/ |
|
229 |
|
230 /* For the moment enable them all to avoid breaking things */ |
|
231 #define BACNET_SVC_I_HAVE_A 1 /* Do we send I_Have requests? */ |
|
232 #define BACNET_SVC_WP_A 1 /* Do we send WriteProperty requests? */ |
|
233 #define BACNET_SVC_RP_A 1 /* Do we send ReadProperty requests? */ |
|
234 #define BACNET_SVC_RPM_A 1 /* Do we send ReadPropertyMultiple requests? */ |
|
235 #define BACNET_SVC_DCC_A 1 /* Do we send DeviceCommunicationControl requests? */ |
|
236 #define BACNET_SVC_RD_A 1 /* Do we send ReinitialiseDevice requests? */ |
|
237 #define BACNET_SVC_TS_A 1 |
|
238 #define BACNET_SVC_SERVER 0 /* Are we a pure server type device? */ |
|
239 #define BACNET_USE_OCTETSTRING 1 /* Do we need any octet strings? */ |
|
240 #define BACNET_USE_DOUBLE 1 /* Do we need any doubles? */ |
|
241 #define BACNET_USE_SIGNED 1 /* Do we need any signed integers */ |
|
242 |
|
243 /* Do them one by one */ |
|
244 #ifndef BACNET_SVC_I_HAVE_A /* Do we send I_Have requests? */ |
|
245 #define BACNET_SVC_I_HAVE_A 0 |
|
246 #endif |
|
247 |
|
248 #ifndef BACNET_SVC_WP_A /* Do we send WriteProperty requests? */ |
|
249 #define BACNET_SVC_WP_A 0 |
|
250 #endif |
|
251 |
|
252 #ifndef BACNET_SVC_RP_A /* Do we send ReadProperty requests? */ |
|
253 #define BACNET_SVC_RP_A 0 |
|
254 #endif |
|
255 |
|
256 #ifndef BACNET_SVC_RPM_A /* Do we send ReadPropertyMultiple requests? */ |
|
257 #define BACNET_SVC_RPM_A 0 |
|
258 #endif |
|
259 |
|
260 #ifndef BACNET_SVC_DCC_A /* Do we send DeviceCommunicationControl requests? */ |
|
261 #define BACNET_SVC_DCC_A 0 |
|
262 #endif |
|
263 |
|
264 #ifndef BACNET_SVC_RD_A /* Do we send ReinitialiseDevice requests? */ |
|
265 #define BACNET_SVC_RD_A 0 |
|
266 #endif |
|
267 |
|
268 #ifndef BACNET_SVC_SERVER /* Are we a pure server type device? */ |
|
269 #define BACNET_SVC_SERVER 1 |
|
270 #endif |
|
271 |
|
272 #ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */ |
|
273 #define BACNET_USE_OCTETSTRING 0 |
|
274 #endif |
|
275 |
|
276 #ifndef BACNET_USE_DOUBLE /* Do we need any doubles? */ |
|
277 #define BACNET_USE_DOUBLE 0 |
|
278 #endif |
|
279 |
|
280 #ifndef BACNET_USE_SIGNED /* Do we need any signed integers */ |
|
281 #define BACNET_USE_SIGNED 0 |
|
282 #endif |
|
283 |
|
284 #endif /* CONFIG_BACNET_FOR_BEREMIZ_H */ |