BACnetStack_SendWriteProperty
bool BACnetStack_SendWriteProperty( uint8_t * sentInvokeId, const uint8_t serviceType, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint32_t networkPortInstance, const uint16_t destinationNetwork, const uint8_t * destinationAddress, const uint8_t destinationAddressLength, const uint32_t propertyArraysCount, const void * propertyArrays, const uint32_t propertyArraysLength);Sends a WriteProperty or WritePropertyMultiple request.
One call serves both WriteProperty and WritePropertyMultiple, selected by serviceType: serviceType = 15 (WriteProperty) -> propertyArraysCount must be 1 serviceType = 16 (WritePropertyMultiple) -> propertyArraysCount >= 1
propertyArrays: propertyArraysCount packed elements, each at least CASBACnetStack::BACnetStackWritePropertyAsync::BACNET_WRITE_PROPERTY_ASYNC_MIN_ARRAY_SIZE bytes plus the value. Multi-byte fields are little-endian, the byte order of every host the stack supports:
* +-[0]-----------*-[1][2]--------------*-[3][4][5][6]------------*-[7][8][9][10]---------------*-[11][12][13][14]------------*-[15]-------------*-[16]-------------*-[17][18]-------------*-[19+]- Variable -----** | uint8_t flags | uint16_t objectType | uint32_t objectInstance | uint32_t propertyIdentifier | uint32_t propertyArrayIndex | uint8_t dataType | uint8_t priority | uint16_t valueLength | char * valueAsString |* +---------------*---------------------*-------------------------*-----------------------------*-----------------------------*------------------*------------------*----------------------*----------------------**uint8_t flags 1 (0) = Use propertyArrayIndex 2 (1) = Use priorty 4 (2) = (Reserved) 8 (3) = (Reserved) 16 (4) = (Reserved) 32 (5) = (Reserved) 64 (6) = (Reserved)128 (7) = (Reserved)
uint8_t dataType: a BACnet primitive application datatype tag, 0..12 (Null, Boolean, UnsignedInteger, SignedInteger, Real, Double, OctetString, CharacterString, BitString, Enumerated, Date, Time, BACnetObjectIdentifier), PLUS two constructed types built from the value string: 27 = DateTime and 64 = DeviceObjectPropertyReference. Every OTHER value above 12 is rejected and the whole call returns false without sending anything.
propertyArraysLength is the total byte length of propertyArrays (all elements concatenated).VALUE ENCODING - READ THIS. The valueAsString bytes are the value written as TEXT: valueLength bytes, not NUL-terminated. BACnetStack_SendCreateObject() and BACnetStack_SendWriteGroup() take raw binary instead. The whole text must parse as the element’s dataType, or the call returns false without sending anything. Except in a CharacterString, leading and trailing spaces are not allowed. Null -> empty (valueLength 0) Boolean -> “0” or “1” UnsignedInteger -> decimal digits, e.g. “42” SignedInteger -> decimal, e.g. “-7” Real, Double -> decimal, e.g. “72.5” OctetString -> ‘x’ then an even number of hex digits, e.g. “x0A1B” CharacterString -> the characters themselves, at least one, sent as UTF-8 BitString -> ‘b’ then one ‘0’ or ‘1’ per bit, e.g. “b0110” Enumerated -> decimal digits, e.g. “3” Date -> “yyyy-mm-dd (w)”, weekday 1 = Monday .. 7 = Sunday, e.g. “2026-01-15 (4)”; 255 in a field means unspecified Time -> “HH:MM:SS.hh”, e.g. “16:25:50.90”; “.9” is 9 hundredths; 255 in a field means unspecified ObjectIdentifier (12) -> “<objectType>,<objectInstance>”, e.g. “8,1234” DateTime (27) -> “<date>;<time>” in the Date and Time forms above DeviceObjectPropertyReference (64) -> “<objectType>,<objectInstance>,<propertyIdentifier>[,<arrayIndex>]”
See also: Client response hooks
BACnet reference: ANSI/ASHRAE 135-2024 clause 15.9 (WriteProperty Service); clause 15.10 (WritePropertyMultiple Service).
Parameters
Section titled “Parameters”| Parameter | Direction | Description |
|---|---|---|
sentInvokeId |
out | The invoke-id of the sent request, valid only if this function returns true. |
serviceType |
in | 15 = WriteProperty, 16 = WritePropertyMultiple; selects which service is sent. |
connectionString, connectionStringLength |
in | The datalink address to send TO (the destination) - not the local address to send from. For IPv4 this is 6 bytes: 4 octets of IPv4 address followed by 2 octets of port, big-endian (e.g. 0xC0,0xA8,0x01,0x05,0xBA,0xC0 = 192.168.1.5:47808; see BACnetStack_SendRegisterForeignDevice() for a worked example); on BACnet/IPv4 the stack refuses to send to a connection string of any other length, except that a broadcast from a device registered as a foreign device goes to its BBMD and does not use the connection string. MS/TP and BACnet/SC use a different connection-string shape; see their respective Set/Send exports. |
networkPortInstance |
in | The Network Port object instance to send the message on, or BACNET_NETWORK_PORT_DEFAULT (4194303) for the default/single port. |
destinationNetwork, destinationAddress, destinationAddressLength |
in | The destination to send the request to. |
propertyArraysCount, propertyArrays, propertyArraysLength |
in | The packed property-value array described above. |
Returns
Section titled “Returns”True if the request was sent, otherwise false.
Topic: Client requests. Declared in CASBACnetStackDLL.h.