Skip to content
Version 6.1.0
Contact Us

BACnetStack_SendWriteGroup

bool BACnetStack_SendWriteGroup(
const uint32_t groupNumber,
const uint8_t writePriority,
const uint32_t changeListCount,
const void * changeList,
const uint32_t changeListLength,
const bool useInhibitDelay,
const bool inhibitDelay,
const uint8_t * connectionString,
const uint8_t connectionStringLength,
const uint32_t networkPortInstance,
const bool broadcast,
const uint16_t destinationNetwork,
const uint8_t * destinationAddress,
const uint8_t destinationAddressLength);

Sends a WriteGroup request, which distributes values to the Channel objects of a numbered control group.

WriteGroup is an unconfirmed service (135-2024 clause 15.11). changeList is changeListCount packed elements, each 6 BYTES of header + a variable-length value. Multi-byte SCALAR HEADER fields are little-endian; the buffer is fully packed, no padding.

* +-[0][1]------------*-[2]---------------------*-[3]----------------*-[4][5]-------------*-[6+]- Variable -*
* | uint16_t channel | uint8_t overridPriority | uint8_t dataType | uint16_t valueLen | value bytes |
* +-------------------*-------------------------*--------------------*--------------------*-----------------*
*

overridingPriority 0 = absent (valid priorities 1..16). dataType is a BACnet primitive application tag. changeListLength is the total byte length of changeList - the sum over all elements of (6 + valueLen). Elements are NOT a fixed stride.

VALUE ENCODING - READ THIS. The value bytes are the value’s RAW BINARY wire form, NOT ASCII/UTF-8 text (not a dual-supported option). The stack parses them with BACnetAbstractSyntaxType::DecodeBinary(dataType, …). Multi-byte numeric fields are little-endian, matching every other scalar field in this buffer: Null -> 0 bytes (valueLen 0) Boolean -> 1 byte: 0x00 or 0x01 UnsignedInteger -> 4 bytes, uint32_t, little-endian SignedInteger -> 4 bytes, int32_t, little-endian, two’s complement Real -> 4 bytes, IEEE-754 float, little-endian (e.g. 23.5f -> 00 00 BC 41) Double -> 8 bytes, IEEE-754 double, little-endian OctetString -> raw bytes, as-is (valueLen-bounded) CharacterString -> raw UTF-8 bytes, as-is (valueLen-bounded) BitString -> 1 byte “unused bits in last octet” (0..7, ASHRAE cl. 20.2.10) + packed octets, MSB-first within each octet Enumerated -> 4 bytes, uint32_t, little-endian Date -> 4 bytes: yearMinus1900, month, day, weekday (0xFF = wildcard per field) Time -> 4 bytes: hour, minute, second, hundredths (0xFF = wildcard per field) BACnetObjectIdentifier -> 6 bytes: uint16_t objectType (LE) + uint32_t objectInstance (LE) - the two-field split, NOT the internal packed-32-bit form DateTime -> 8 bytes: Date (4) then Time (4), concatenated DeviceObjectPropertyReference is not supported on this export. DecodeBinary checks length before content, so passing the old TEXT form USUALLY fails the decode and returns false - but this is NOT guaranteed for every value: a text value whose character count happens to equal its type’s binary width passes the length check and is silently misinterpreted (e.g. Real “23.5” is 4 ASCII bytes, the same width as a 4-byte float, so it decodes as garbage instead of failing). Re-encode every caller of this export in the new binary form - do not rely on the decode failing to catch a caller you missed.

Worked example - channel 7, no overriding priority, Real 23.5:

* 07 00 00 04 04 00 00 00 BC 41 (10 bytes total)
* |chan| |pri||typ| |len| | 23.5f as IEEE-754 LE |
*

changeListCount = 1, changeListLength = 10.

NOTE: this matches the convention used by the references buffer of BACnetStack_SendSubscribeCOVPropertyMultiple() below, whose covIncrement is a RAW 4-byte little-endian IEEE-754 float.

Use your language adapter’s WriteGroup packer to build the buffer rather than packing it by hand. All seven adapters ship one and all seven agree with the encoding described above: adapters/csharp/PropertyBufferHelper.cs adapters/java/…/PropertyBufferHelper.java adapters/python/property_buffer_helper.py adapters/rust/property_buffer_helper.rs adapters/golang/propertybufferhelper/ adapters/cpp/CASBACnetStackPackHelpers.h adapters/node/…/property-arrays.ts Returns true on success.

BACnet reference: ANSI/ASHRAE 135-2024 clause 15.11 (WriteGroup Service).

Parameter Direction Description
groupNumber in The control group number (Channel objects’ Control_Groups membership) to write to.
writePriority in The BACnet write priority (1..16) to write the values at.
changeListCount, changeList, changeListLength in The packed change-list array described above.
useInhibitDelay, inhibitDelay in If useInhibitDelay is true, overrides each Channel’s own Execution_Delay handling for this write.
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.
broadcast, destinationNetwork, destinationAddress, destinationAddressLength in broadcast selects a broadcast or a unicast where the data link has the choice: on BACnet/IP an Original-Broadcast-NPDU or an Original-Unicast-NPDU (a broadcast from a device registered as a foreign device goes to its BBMD as a Distribute-Broadcast-To-Network); on BACnet/SC the broadcast VMAC; on MS/TP it is ignored and connectionString decides. destinationNetwork 0 keeps the message on the local network; 1 to 65534 routes it to that network, to the device whose MAC address is destinationAddress/destinationAddressLength or, with NULL and 0 there, to every device on that network; 65535 is a global broadcast to every network.

True if the request was sent, otherwise false.

Topic: Client requests. Declared in CASBACnetStackDLL.h.