Digi XBee(R) ANSI C Host Library
Files | Data Structures | Macros | Typedefs | Functions | Variables

Files

file  zcl_types.h
 Macros and structures related to the ZCL datatypes.
 
file  zcl_types.c
 Information on each ZCL datatype; see zcl_type_info[] for additional documentation.
 

Data Structures

struct  zcl_timeofday_t
 Time of Day (for ZCL_TYPE_TIME_TIMEOFDAY Data Type) More...
 
struct  zcl_date_t
 Date (for ZCL_TYPE_TIME_DATE Data Type) More...
 
union  zcl40_t
 40-bit unsigned in host-byte-order More...
 
union  zcl48_t
 48-bit unsigned in host-byte-order More...
 

Macros

#define ZCL_UTCTIME_INVALID   0xFFFFFFFF
 
#define ZCL_TYPE_IS_ANALOG(t)   (zcl_type_info[t] & ZCL_T_ANALOG)
 ZCL data type t is an analog type.
 
#define ZCL_TYPE_IS_DISCRETE(t)   (zcl_type_info[t] & ZCL_T_DISCRETE)
 ZCL data type t is a discrete type.
 
#define ZCL_TYPE_IS_SIGNED(t)   (zcl_type_info[t] & ZCL_T_SIGNED)
 ZCL data type t is a signed type.
 
#define ZCL_TYPE_IS_REPORTABLE(t)   (zcl_type_info[t] & ZCL_T_REPORTABLE)
 ZCL data type t is a reportable type.
 
#define ZCL_TYPE_IS_INVALID(t)   (zcl_type_info[t] == ZCL_T_INVALID)
 ZCL data type t is an invalid (unsupported/unrecognized) type.
 
#define ZCL_SIZE_SHORT   -1
 
#define ZCL_SIZE_LONG   -2
 
#define ZCL_SIZE_VARIABLE   -3
 
#define ZCL_SIZE_INVALID   -127
 
#define zcl_types_debug
 

Typedefs

typedef uint32_t zcl_utctime_t
 

Functions

int zcl_sizeof_type (uint8_t type)
 Return the number of octets used by a given ZCL datatype. More...
 
const char * zcl_type_name (uint8_t type)
 Return a descriptive string for a given ZCL attribute type. More...
 

Variables

const uint8_t zcl_type_info [256]
 Table to store information on each ZCL datatype. More...
 
const uint8_t zcl_type_info [256]
 Table to store information on each ZCL datatype. More...
 

ZCL Null Types

#define ZCL_TYPE_NO_DATA   0x00
 

ZCL General Data (discrete) Types

#define ZCL_TYPE_GENERAL_8BIT   0x08
 
#define ZCL_TYPE_GENERAL_16BIT   0x09
 
#define ZCL_TYPE_GENERAL_24BIT   0x0a
 
#define ZCL_TYPE_GENERAL_32BIT   0x0b
 
#define ZCL_TYPE_GENERAL_40BIT   0x0c
 
#define ZCL_TYPE_GENERAL_48BIT   0x0d
 
#define ZCL_TYPE_GENERAL_56BIT   0x0e
 
#define ZCL_TYPE_GENERAL_64BIT   0x0f
 

ZCL Logical (discrete) Types

#define ZCL_TYPE_LOGICAL_BOOLEAN   0x10
 

Values for #ZCL_TYPE_LOGICAL_BOOLEAN

#define ZCL_BOOL_FALSE   0x00
 
#define ZCL_BOOL_TRUE   0x01
 
#define ZCL_BOOL_INVALID   0xff
 

ZCL Bitmap (discrete) Types

#define ZCL_TYPE_BITMAP_8BIT   0x18
 
#define ZCL_TYPE_BITMAP_16BIT   0x19
 
#define ZCL_TYPE_BITMAP_24BIT   0x1a
 
#define ZCL_TYPE_BITMAP_32BIT   0x1b
 
#define ZCL_TYPE_BITMAP_40BIT   0x1c
 
#define ZCL_TYPE_BITMAP_48BIT   0x1d
 
#define ZCL_TYPE_BITMAP_56BIT   0x1e
 
#define ZCL_TYPE_BITMAP_64BIT   0x1f
 

ZCL Unsigned integer (analog) Types

#define ZCL_TYPE_UNSIGNED_8BIT   0x20
 
#define ZCL_TYPE_UNSIGNED_16BIT   0x21
 
#define ZCL_TYPE_UNSIGNED_24BIT   0x22
 
#define ZCL_TYPE_UNSIGNED_32BIT   0x23
 
#define ZCL_TYPE_UNSIGNED_40BIT   0x24
 
#define ZCL_TYPE_UNSIGNED_48BIT   0x25
 
#define ZCL_TYPE_UNSIGNED_56BIT   0x26
 
#define ZCL_TYPE_UNSIGNED_64BIT   0x27
 

ZCL Signed integer (analog) Types

#define ZCL_TYPE_SIGNED_8BIT   0x28
 
#define ZCL_TYPE_SIGNED_16BIT   0x29
 
#define ZCL_TYPE_SIGNED_24BIT   0x2a
 
#define ZCL_TYPE_SIGNED_32BIT   0x2b
 
#define ZCL_TYPE_SIGNED_40BIT   0x2c
 
#define ZCL_TYPE_SIGNED_48BIT   0x2d
 
#define ZCL_TYPE_SIGNED_56BIT   0x2e
 
#define ZCL_TYPE_SIGNED_64BIT   0x2f
 

ZCL Enumeration (discrete) Types

#define ZCL_TYPE_ENUM_8BIT   0x30
 
#define ZCL_TYPE_ENUM_16BIT   0x31
 

ZCL Floating point (analog) Types

#define ZCL_TYPE_FLOAT_SEMI   0x38
 semi-precision (16-bit) floating point (unsupported)
 
#define ZCL_TYPE_FLOAT_SINGLE   0x39
 single-precision (32-bit) IEEE 754 floating point
 
#define ZCL_TYPE_FLOAT_DOUBLE   0x3a
 double-precision (64-bit) IEEE 754 floating point
 

ZCL String (discrete) Types

#define ZCL_TYPE_STRING_OCTET   0x41
 First octet is number of bytes in string or 0xff for invalid.
 
#define ZCL_TYPE_STRING_CHAR   0x42
 First octet is number of characters in string or 0xff for invalid. More...
 
#define ZCL_TYPE_STRING_LONG_OCTET   0x43
 First two octets are number of bytes in string or 0xffff for invalid. More...
 
#define ZCL_TYPE_STRING_LONG_CHAR   0x44
 First two octets are number of characters in string or 0xffff for invalid. More...
 

ZCL Ordered Sequence (discrete) Types

#define ZCL_TYPE_ARRAY   0x48
 ZCL Array (unsupported)
 
#define ZCL_TYPE_STRUCT   0x4C
 ZCL Struct (unsupported)
 

ZCL Collection (discrete) Types

#define ZCL_TYPE_SET   0x50
 ZCL Set (unsupported)
 
#define ZCL_TYPE_BAG   0x51
 ZCL Bag (unsupported)
 

ZCL Time (analog) Types

#define ZCL_TYPE_TIME_TIMEOFDAY   0xE0
 see zcl_timeofday_t
 
#define ZCL_TYPE_TIME_DATE   0xE1
 see zcl_date_t
 
#define ZCL_TYPE_TIME_UTCTIME   0xE2
 number of seconds (stored in uint32_t) since Midnight on 1/1/2000 UTC
 

ZCL Identifier (discrete) Types

#define ZCL_TYPE_ID_CLUSTER   0xE8
 16-bit cluster ID
 
#define ZCL_TYPE_ID_ATTRIB   0xE9
 16-bit attribute ID
 
#define ZCL_TYPE_ID_BACNET_OID   0xEA
 32-bit BACnet OID
 

ZCL Miscellaneous Types

#define ZCL_TYPE_IEEE_ADDR   0xF0
 64-bit IEEE address
 
#define ZCL_TYPE_SECURITY_KEY   0xF1
 128-bit security key
 

ZCL Unknown Type

#define ZCL_TYPE_UNKNOWN   0xFF
 Unknown ZCL Type.
 

Settings for zcl_type_info[]

These bitfields should only be used internally by the library, and should be exposed to user code via public APIs.

#define ZCL_T_INVALID   0x0F
 Not a valid ZCL type.
 
#define ZCL_T_DISCRETE   0x80
 Discrete values (bitmap, enum, etc.) that can't be added/subtracted or (if reportable) have a reportable change. More...
 
#define ZCL_T_ANALOG   0x20
 If an attribute isn't discrete, it's analog (signed, unsigned, float, etc.)
 
#define ZCL_T_SIGNED   0x40
 Type is signed (default is unsigned). Only analog types can be signed.
 
#define ZCL_T_FLOAT   0x10
 Type is floating point (single, double or semi-precision).
 
#define ZCL_T_REPORTABLE   (ZCL_T_ANALOG | ZCL_T_DISCRETE)
 Type is reportable. More...
 
#define ZCL_T_SIZE_MASK   0x0F
 0x00 to 0x08 represent 0 to 8 bytes; 0x0C is 16 bytes; 0x0D is two-octet size prefix, 0x0E is one-octet size prefix; 0x0F is invalid; 0x09, 0x0A and 0x0B are still available to encode special size information. More...
 
#define ZCL_T_SIZE_INVALID   (ZCL_T_INVALID & ZCL_T_SIZE_MASK)
 Macro used when type is invalid or doesn't have a known size.
 
#define ZCL_T_SIZE_SHORT   0x0E
 First octet of attribute's value is its size.
 
#define ZCL_T_SIZE_LONG   0x0D
 First two octets of attribute's value are its size.
 
#define ZCL_T_SIZE_128BIT   0x0C
 128-bit (16-byte) value
 
#define ZCL_T_SIZE_VARIABLE   0x0B
 variable-length value (array, set, bag, struct)
 

Detailed Description

Macro Definition Documentation

#define ZCL_T_DISCRETE   0x80

Discrete values (bitmap, enum, etc.) that can't be added/subtracted or (if reportable) have a reportable change.

Default is analog.

#define ZCL_T_REPORTABLE   (ZCL_T_ANALOG | ZCL_T_DISCRETE)

Type is reportable.

Both the type AND attribute must have reportable flags set if they are reportable.

#define ZCL_T_SIZE_MASK   0x0F

0x00 to 0x08 represent 0 to 8 bytes; 0x0C is 16 bytes; 0x0D is two-octet size prefix, 0x0E is one-octet size prefix; 0x0F is invalid; 0x09, 0x0A and 0x0B are still available to encode special size information.

Be sure to update zcl_sizeof_type when adding to or changing these macros. Low nibble of each zcl_type_info byte stores the type's size.

Referenced by zcl_sizeof_type().

#define ZCL_TYPE_STRING_CHAR   0x42

First octet is number of characters in string or 0xff for invalid.

Note that each character may be more than one byte depending on the "language and character set field of the complex descriptor contained in the character data [following the first octet]". See ZCL for details.

Referenced by zcl_decode_attribute(), zcl_encode_attribute_value(), and zcl_print_attribute_value().

#define ZCL_TYPE_STRING_LONG_CHAR   0x44

First two octets are number of characters in string or 0xffff for invalid.

Note that each character may be more than one byte depending on the "language and character set field of the complex descriptor contained in the character data [following the first octet]". See ZCL for details.

#define ZCL_TYPE_STRING_LONG_OCTET   0x43

First two octets are number of bytes in string or 0xffff for invalid.

This will come in so handy for a protcol with frames of 256 bytes max (he said sarcastically).

Function Documentation

int zcl_sizeof_type ( uint8_t  type)

Return the number of octets used by a given ZCL datatype.

Parameters
[in]typeType to look up. Typically one of the ZCL_TYPE_* macros, or the type element of an attribute record.
Return values
ZCL_SIZE_INVALIDunknown or invalid type
ZCL_SIZE_SHORT1-octet size prefix
ZCL_SIZE_LONG2-octet size prefix
ZCL_SIZE_VARIABLEvariable-length type (array, struct, set, bag)
>=0number of octets used by type (0 to 8, 16)
See also
zigbee/zcl_types.h

References ZCL_T_SIZE_128BIT, ZCL_T_SIZE_INVALID, ZCL_T_SIZE_LONG, ZCL_T_SIZE_MASK, ZCL_T_SIZE_SHORT, ZCL_T_SIZE_VARIABLE, and zcl_type_info.

Referenced by zcl_check_minmax(), zcl_decode_attribute(), zcl_encode_attribute_value(), zcl_parse_attribute_record(), and zcl_print_attribute_value().

const char * zcl_type_name ( uint8_t  type)

Return a descriptive string for a given ZCL attribute type.

Parameters
[in]typeZCL attribute type
Returns
Pointer to a string description of the type, or "INVALID_0xHH" on unrecognized types (where HH is the hex representation of the type). Never returns NULL.

Referenced by zcl_print_array_value(), and zcl_print_struct_value().

Variable Documentation

const uint8_t zcl_type_info[256]

Table to store information on each ZCL datatype.

Lower 4 bits encode size (0 to 8 octets, 16 octets, one-byte size prefix, two-byte size prefix), upper 4 bits encode additional information.

Need to represent 0 to 8 octets, 16 octets, size in first octet, size in first two octets. 12 possible values.

Using this table, it may be possible to simplify the encode/decode functions greatly – just use memcpy or swapcpy to copy the given number of bytes.

Special case for floating point values if the platform doesn't use IEEE floats, and to convert from 2-byte semi-precision float to 4-byte float.

Referenced by zcl_check_minmax(), zcl_print_attribute_value(), and zcl_sizeof_type().

const uint8_t zcl_type_info[256]

Table to store information on each ZCL datatype.

Lower 4 bits encode size (0 to 8 octets, 16 octets, one-byte size prefix, two-byte size prefix), upper 4 bits encode additional information.

Need to represent 0 to 8 octets, 16 octets, size in first octet, size in first two octets. 12 possible values.

Using this table, it may be possible to simplify the encode/decode functions greatly – just use memcpy or swapcpy to copy the given number of bytes.

Special case for floating point values if the platform doesn't use IEEE floats, and to convert from 2-byte semi-precision float to 4-byte float.

Referenced by zcl_check_minmax(), zcl_print_attribute_value(), and zcl_sizeof_type().