upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
device.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright (C) 2005 Steve Karg <skarg@users.sourceforge.net>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 *********************************************************************/
25 
29 #ifndef DEVICE_H
30 #define DEVICE_H
31 
32 #include <stdbool.h>
33 #include <stdint.h>
34 #include "bacdef.h"
35 #include "bacenum.h"
36 #include "wp.h"
37 #include "rd.h"
38 #include "rp.h"
39 #include "rpm.h"
40 #include "readrange.h"
41 
45 typedef void (
47  void);
48 
53 typedef unsigned (
55  void);
56 
62 typedef uint32_t(
64  (
65  unsigned index);
66 
75 typedef bool(
77  (
78  uint32_t object_instance,
79  BACNET_CHARACTER_STRING * object_name);
80 
87 typedef bool(
89  uint32_t object_instance);
90 
101 typedef unsigned (
103  unsigned current_index);
104 
111 typedef bool(
113  uint32_t object_instance,
114  BACNET_PROPERTY_VALUE * value_list);
115 
121 typedef bool(
123  uint32_t object_instance);
124 
129 typedef void (
131  uint32_t object_instance);
132 
137 typedef void (
139  uint32_t object_instance);
140 
141 
151 typedef struct object_functions {
152  BACNET_OBJECT_TYPE Object_Type;
153  object_init_function Object_Init;
154  object_count_function Object_Count;
155  object_index_to_instance_function Object_Index_To_Instance;
156  object_valid_instance_function Object_Valid_Instance;
157  object_name_function Object_Name;
158  read_property_function Object_Read_Property;
159  write_property_function Object_Write_Property;
160  rpm_property_lists_function Object_RPM_List;
161  rr_info_function Object_RR_Info;
162  object_iterate_function Object_Iterator;
163  object_value_list_function Object_Value_List;
164  object_cov_function Object_COV;
165  object_cov_clear_function Object_COV_Clear;
166  object_intrinsic_reporting_function Object_Intrinsic_Reporting;
168 
169 /* String Lengths - excluding any nul terminator */
170 #define MAX_DEV_NAME_LEN 32
171 #define MAX_DEV_LOC_LEN 64
172 #define MAX_DEV_MOD_LEN 32
173 #define MAX_DEV_VER_LEN 16
174 #define MAX_DEV_DESC_LEN 64
175 
177 typedef struct commonBacObj_s {
178 
183  BACNET_OBJECT_TYPE mObject_Type;
184 
187 
192  char Object_Name[MAX_DEV_NAME_LEN];
193 
195 
196 
205 typedef struct devObj_s {
207  BACNET_ADDRESS bacDevAddr;
208 
211 
213  char Description[MAX_DEV_DESC_LEN];
214 
218 
219 
220 #ifdef __cplusplus
221 extern "C" {
222 #endif /* __cplusplus */
223 
224  void Device_Init(
225  object_functions_t * object_table);
226 
227  bool Device_Reinitialize(
228  BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
229 
230  BACNET_REINITIALIZED_STATE Device_Reinitialized_State(
231  void);
232 
233  rr_info_function Device_Objects_RR_Info(
234  BACNET_OBJECT_TYPE object_type);
235 
236  void Device_getCurrentDateTime(
237  BACNET_DATE_TIME * DateTime);
238  int32_t Device_UTC_Offset(void);
239  bool Device_Daylight_Savings_Status(void);
240 
241  void Device_Property_Lists(
242  const int **pRequired,
243  const int **pOptional,
244  const int **pProprietary);
245  void Device_Objects_Property_List(
246  BACNET_OBJECT_TYPE object_type,
247  struct special_property_list_t *pPropertyList);
248  /* functions to support COV */
249  bool Device_Encode_Value_List(
250  BACNET_OBJECT_TYPE object_type,
251  uint32_t object_instance,
252  BACNET_PROPERTY_VALUE * value_list);
253  bool Device_Value_List_Supported(
254  BACNET_OBJECT_TYPE object_type);
255  bool Device_COV(
256  BACNET_OBJECT_TYPE object_type,
257  uint32_t object_instance);
258  void Device_COV_Clear(
259  BACNET_OBJECT_TYPE object_type,
260  uint32_t object_instance);
261 
263  void);
264  bool Device_Set_Object_Instance_Number(
265  uint32_t object_id);
266  bool Device_Valid_Object_Instance_Number(
267  uint32_t object_id);
268  unsigned Device_Object_List_Count(
269  void);
271  unsigned array_index,
272  int *object_type,
273  uint32_t * instance);
274 
275  unsigned Device_Count(
276  void);
277  uint32_t Device_Index_To_Instance(
278  unsigned index);
279 
280  bool Device_Object_Name(
281  uint32_t object_instance,
282  BACNET_CHARACTER_STRING * object_name);
283  bool Device_Set_Object_Name(
284  BACNET_CHARACTER_STRING * object_name);
285  /* Copy a child object name, given its ID. */
287  BACNET_OBJECT_TYPE object_type,
288  uint32_t object_instance,
289  BACNET_CHARACTER_STRING * object_name);
290  bool Device_Object_Name_ANSI_Init(const char * value);
291 
292  BACNET_DEVICE_STATUS Device_System_Status(
293  void);
294  int Device_Set_System_Status(
295  BACNET_DEVICE_STATUS status,
296  bool local);
297 
298  const char *Device_Vendor_Name(
299  void);
300 
301  uint16_t Device_Vendor_Identifier(
302  void);
303  void Device_Set_Vendor_Identifier(
304  uint16_t vendor_id);
305 
306  const char *Device_Model_Name(
307  void);
308  bool Device_Set_Model_Name(
309  const char *name,
310  size_t length);
311 
312  const char *Device_Firmware_Revision(
313  void);
314 
315  const char *Device_Application_Software_Version(
316  void);
317  bool Device_Set_Application_Software_Version(
318  const char *name,
319  size_t length);
320 
321  const char *Device_Description(
322  void);
323  bool Device_Set_Description(
324  const char *name,
325  size_t length);
326 
327  const char *Device_Location(
328  void);
329  bool Device_Set_Location(
330  const char *name,
331  size_t length);
332 
333  /* some stack-centric constant values - no set methods */
334  uint8_t Device_Protocol_Version(
335  void);
336  uint8_t Device_Protocol_Revision(
337  void);
338  BACNET_SEGMENTATION Device_Segmentation_Supported(
339  void);
340 
341  uint32_t Device_Database_Revision(
342  void);
343  void Device_Set_Database_Revision(
344  uint32_t revision);
345  void Device_Inc_Database_Revision(
346  void);
347 
349  BACNET_CHARACTER_STRING * object_name,
350  int *object_type,
351  uint32_t * object_instance);
353  int object_type,
354  uint32_t object_instance);
355 
357  BACNET_READ_PROPERTY_DATA * rpdata);
358  bool Device_Write_Property(
359  BACNET_WRITE_PROPERTY_DATA * wp_data);
360 
361  bool DeviceGetRRInfo(
362  BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
363  RR_PROP_INFO * pInfo); /* Where to put the information */
364 
365  int Device_Read_Property_Local(
366  BACNET_READ_PROPERTY_DATA * rpdata);
367  bool Device_Write_Property_Local(
368  BACNET_WRITE_PROPERTY_DATA * wp_data);
369 
370 #if defined(INTRINSIC_REPORTING)
371  void Device_local_reporting(
372  void);
373 #endif
374 
375 /* Prototypes for Routing functionality in the Device Object.
376  * Enable by defining BAC_ROUTING in config.h and including gw_device.c
377  * in the build (lib/Makefile).
378  */
379  void Routing_Device_Init(
380  uint32_t first_object_instance);
381 
382  uint16_t Add_Routed_Device(
383  uint32_t Object_Instance,
384  BACNET_CHARACTER_STRING * Object_Name,
385  const char *Description);
386  DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
387  int idx);
388  BACNET_ADDRESS *Get_Routed_Device_Address(
389  int idx);
390 
391  void routed_get_my_address(
392  BACNET_ADDRESS * my_address);
393 
394  bool Routed_Device_Address_Lookup(
395  int idx,
396  uint8_t address_len,
397  uint8_t * mac_adress);
398  bool Routed_Device_GetNext(
399  BACNET_ADDRESS * dest,
400  int *DNET_list,
401  int *cursor);
402  bool Routed_Device_Is_Valid_Network(
403  uint16_t dest_net,
404  int *DNET_list);
405 
406  uint32_t Routed_Device_Index_To_Instance(
407  unsigned index);
408  bool Routed_Device_Valid_Object_Instance_Number(
409  uint32_t object_id);
410  bool Routed_Device_Name(
411  uint32_t object_instance,
412  BACNET_CHARACTER_STRING * object_name);
413  uint32_t Routed_Device_Object_Instance_Number(
414  void);
415  bool Routed_Device_Set_Object_Instance_Number(
416  uint32_t object_id);
417  bool Routed_Device_Set_Object_Name(
418  uint8_t encoding,
419  const char *value,
420  size_t length);
421  bool Routed_Device_Set_Description(
422  const char *name,
423  size_t length);
424  void Routed_Device_Inc_Database_Revision(
425  void);
426  int Routed_Device_Service_Approval(
427  BACNET_CONFIRMED_SERVICE service,
428  int service_argument,
429  uint8_t * apdu_buff,
430  uint8_t invoke_id);
431 
432 
433 
434 #ifdef __cplusplus
435 }
436 #endif /* __cplusplus */
437 
466 #endif
bool Device_Object_Name_Copy(BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
Definition: device-client.c:661
bool(* object_cov_function)(uint32_t object_instance)
Definition: device.h:122
bool(* object_valid_instance_function)(uint32_t object_instance)
Definition: device.h:88
unsigned(* object_iterate_function)(unsigned current_index)
Definition: device.h:102
bool(* object_value_list_function)(uint32_t object_instance, BACNET_PROPERTY_VALUE *value_list)
Definition: device.h:112
uint32_t Device_Object_Instance_Number(void)
Definition: device-client.c:225
bool(* object_name_function)(uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
Definition: device.h:77
unsigned Device_Object_List_Count(void)
Definition: device-client.c:512
void(* object_cov_clear_function)(uint32_t object_instance)
Definition: device.h:130
void(* object_init_function)(void)
Definition: device.h:46
struct devObj_s DEVICE_OBJECT_DATA
BACNET_ADDRESS bacDevAddr
Definition: device.h:207
Definition: device.h:177
uint32_t Database_Revision
Definition: device.h:216
void Device_Init(object_functions_t *object_table)
Definition: device-client.c:1013
uint16_t Device_Vendor_Identifier(void)
Definition: device-client.c:364
uint32_t Object_Instance_Number
Definition: device.h:186
bool Device_Valid_Object_Id(int object_type, uint32_t object_instance)
Definition: device-client.c:640
Definition: device.h:205
struct object_functions object_functions_t
struct commonBacObj_s COMMON_BAC_OBJECT
void(* object_intrinsic_reporting_function)(uint32_t object_instance)
Definition: device.h:138
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name, int *object_type, uint32_t *object_instance)
Definition: device-client.c:599
COMMON_BAC_OBJECT bacObj
Definition: device.h:210
Definition: device.h:151
BACNET_OBJECT_TYPE mObject_Type
Definition: device.h:183
int Device_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
Definition: device-client.c:977
bool Device_Object_List_Identifier(unsigned array_index, int *object_type, uint32_t *instance)
Definition: device-client.c:540
uint32_t(* object_index_to_instance_function)(unsigned index)
Definition: device.h:64
unsigned(* object_count_function)(void)
Definition: device.h:54