BACnetStack_SendCreateObject
bool BACnetStack_SendCreateObject( uint8_t * sentInvokeId, const uint16_t objectType, const uint8_t flags, const uint32_t objectInstance, 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 CreateObject request, optionally with initial property values.
BACnetStack_SendCreateObject()
flags 1 (0) = Use objectInstance (CreateObject by Object-Identifier). When clear, the device assigns the instance (CreateObject by Object-Type) and objectInstance is ignored.
RETRIEVING THE ASSIGNED OBJECT INSTANCE (flags bit 0 clear): this export has no ComplexAck hook by design - there is deliberately no callback fired when the CreateObject-Ack arrives. Recover the assigned instance by decoding the raw ComplexAck frame yourself with BACnetStack_DecodeAs() (matched to this request’s sentInvokeId): the rendering’s top-level ObjectIdentifier field is the assigned object. There is no out-parameter for it either - the send is asynchronous, so a same-call out-parameter could not be populated at return time anyway, and would need a new hook to fill in later that this export deliberately does not have.
propertyArrays: propertyArraysCount packed initial-property-value elements, each at least 13 BYTES + value. Field order matches BACnetStack_SendWriteProperty()’s packed element (flags, …, propertyArrayIndex, …, dataType, priority, valueLength, value) so the two layouts are learnable as one. Their value encodings differ: here the value is raw binary (see VALUE ENCODING below), while BACnetStack_SendWriteProperty() takes it as text. The layout:
* +-[0]-----------*-[1][2][3][4]----------------*-[5][6][7][8]------------*-[9]-------------*-[10]-------------*-[11][12]--------------*-[13+]- Variable -----** | uint8_t flags | 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 priority Higher bits are RESERVED and must be 0.
dataType is a BACnet primitive application datatype tag 0..12, or 27 for DateTime; any other value is rejected.propertyArraysLength is the total byte length of propertyArrays. May be empty (count 0).VALUE ENCODING - READ THIS. The valueAsString 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. 72.5f -> 00 00 91 42) 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. 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 - Present_Value (85), no array index, no priority, Real 72.5:
* 00 55000000 00000000 04 00 0400 00009142* |flags||propertyIdentifier| |propertyArrayIndex| |typ| |pri| |len| |72.5f LE|*(17 bytes total)
See also: Client response hooks
BACnet reference: ANSI/ASHRAE 135-2024 clause 15.3 (CreateObject Service).
Parameters
Section titled “Parameters”| Parameter | Direction | Description |
|---|---|---|
sentInvokeId |
out | The invoke-id of the sent request, valid only if this function returns true. |
objectType |
in | The object type to create. See CASBACnetStack::BACnetObjectType for more info. |
flags |
in | See the flags table above (bit 0 = use objectInstance). |
objectInstance |
in | The object instance to create at, if flags bit 0 is set; otherwise ignored. |
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 initial-property-value array described above. |
Returns
Section titled “Returns”True if the request was sent, otherwise false.
Topic: Client requests. Declared in CASBACnetStackDLL.h.