Skip to content
Version 6.1.0
Contact Us

BACnetStack_RegisterCallbackInitiateWebsocket

void BACnetStack_RegisterCallbackInitiateWebsocket(
bool (*FPCallbackInitiateWebsocket)(const char *websocketUri, const uint32_t websocketUriLength));

Registers the callback the stack calls to ask the host to OPEN a WebSocket/TLS connection to a URI.

The stack implements no WebSocket or TLS itself. Fires from inside BACnetStack_Tick(), from the BACnet/SC connection state machines.

RETURN true to say you will attempt the connection, false to say you cannot. A false return is a failure to establish the WebSocket: the hub connector and the direct-connect initiator both go back to idle at once (cl. AB.6.2.2), and the hub connector counts the failed attempt and waits its reconnect timeout before trying again. A true return is a promise to attempt the connection, not a report that it succeeded: the real answer must come back through BACnetStack_SetBACnetSCWebSocketStatus(). The socket is already marked “connecting” when you are called, so you may report its status from inside this call; if you then return false, the status you reported is discarded. Do not block; open asynchronously and report status later.

The URI is stack-owned and NUL-terminated, valid only for the duration of the call; the length excludes the terminator.

Unregistered, the stack logs and simply never attempts a connection - there is no error and no retry ceiling. Registering has no effect if BACnet/SC was not compiled (STACK_OPTION_DATA_LINK_LAYER_SC).

See also: CASBACnetStack::FPCallbackInitiateWebsocket

Parameter Direction Description
FPCallbackInitiateWebsocket in The function pointer for the CallbackInitiateWebsocket function. See CASBACnetStack::FPCallbackInitiateWebsocket for more info.

FPCallbackInitiateWebsocket

Topic: BACnet/SC. Declared in CASBACnetStackDLL.h.