Last active
July 31, 2018 18:37
-
-
Save funvill/52f8e736fa31e3c4e325efad7deeed1e to your computer and use it in GitHub Desktop.
Sending a BACnet I-AM via BACnet stack 1.x version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://bacnetstack.com/ | |
// To be a good BACnet Server we should announce our-self when joining a network. | |
// Generate the IAM message and send it. | |
char packet[MAXIMUM_BACNET_MESSAGE]; | |
unsigned short payloadSize = fpIAm(SETTING_SERVER_BACNET_NETWORK, (unsigned char *)&deviceOffset, sizeof(unsigned int), packet, MAXIMUM_BACNET_MESSAGE, deviceOffset); | |
if (payloadSize > 0) { | |
// Generate the connection string. | |
BYTE connectionString[10]; | |
sscanf_s("255.255.255.255", "%d.%d.%d.%d", &connectionString[0], &connectionString[1], &connectionString[2], &connectionString[3]); | |
connectionString[4] = SETTING_BACNET_UDP_PORT / 256; | |
connectionString[5] = SETTING_BACNET_UDP_PORT % 256; | |
// Send the message | |
if (!SendUDPMessage(NULL, connectionString, 6, (BYTE *)packet, payloadSize, true)) { | |
printf("Error: Could not send foreign device registration message\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment