int ucov_notify_encode_pdu( uint8_t * buffer, BACNET_ADDRESS * dest, BACNET_NPDU_DATA * npdu_data, BACNET_COV_DATA * cov_data) { int len = 0; int pdu_len = 0; BACNET_ADDRESS my_address; datalink_get_my_address(&my_address); /* unconfirmed is a broadcast */ datalink_get_broadcast_address(dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data); /* encode the APDU portion of the packet */ len = ucov_notify_encode_apdu(&buffer[pdu_len], cov_data); pdu_len += len; return pdu_len; }
static bool cov_send_request( BACNET_COV_SUBSCRIPTION * cov_subscription, BACNET_PROPERTY_VALUE * value_list) { int len = 0; int pdu_len = 0; BACNET_NPDU_DATA npdu_data; BACNET_ADDRESS my_address; int bytes_sent = 0; uint8_t invoke_id = 0; bool status = false; /* return value */ BACNET_COV_DATA cov_data; if (!dcc_communication_enabled()) { return status; } #if PRINT_ENABLED fprintf(stderr, "COVnotification: requested\n"); #endif datalink_get_my_address(&my_address); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &cov_subscription->dest, &my_address, &npdu_data); /* load the COV data structure for outgoing message */ cov_data.subscriberProcessIdentifier = cov_subscription->subscriberProcessIdentifier; cov_data.initiatingDeviceIdentifier = Device_Object_Instance_Number(); cov_data.monitoredObjectIdentifier.type = cov_subscription->monitoredObjectIdentifier.type; cov_data.monitoredObjectIdentifier.instance = cov_subscription->monitoredObjectIdentifier.instance; cov_data.timeRemaining = cov_subscription->lifetime; cov_data.listOfValues = value_list; if (cov_subscription->flag.issueConfirmedNotifications) { invoke_id = tsm_next_free_invokeID(); if (invoke_id) { cov_subscription->invokeID = invoke_id; len = ccov_notify_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, &cov_data); } else { goto COV_FAILED; } } else { len = ucov_notify_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &cov_data); } pdu_len += len; if (cov_subscription->flag.issueConfirmedNotifications) { tsm_set_confirmed_unsegmented_transaction(invoke_id, &cov_subscription->dest, &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len); } bytes_sent = datalink_send_pdu(&cov_subscription->dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); if (bytes_sent > 0) { status = true; } COV_FAILED: return status; }