void port_cancel_socket_update(port_state_t* port_state, sock_state_t* sock_state) { unused_var(port_state); if (!queue_enqueued(sock_state_to_queue_node(sock_state))) return; queue_remove(sock_state_to_queue_node(sock_state)); }
static time_rep_type get_time_rep(const date_type& day, const time_duration_type& tod, date_time::dst_flags dst=not_dst) { unused_var(dst); return time_rep_type(day, tod); }
void port_remove_deleted_socket(port_state_t* port_state, sock_state_t* sock_state) { unused_var(port_state); if (!queue_enqueued(sock_state_to_queue_node(sock_state))) return; queue_remove(sock_state_to_queue_node(sock_state)); }
/*************************************************** ** ** Decodes the service data part of Event Notification ** ****************************************************/ int alarm_ack_decode_service_request( uint8_t * apdu, unsigned apdu_len, BACNET_ALARM_ACK_DATA * data) { int len = 0; int section_len; uint32_t enumValue; /* unused parameter */ unused_var(apdu_len); if (-1 == (section_len = decode_context_unsigned(&apdu[len], 0, &data->ackProcessIdentifier))) { return -1; } len += section_len; if (-1 == (section_len = decode_context_object_id(&apdu[len], 1, &data->eventObjectIdentifier.type, &data->eventObjectIdentifier.instance))) { return -1; } len += section_len; if (-1 == (section_len = decode_context_enumerated(&apdu[len], 2, &enumValue))) { return -1; } data->eventStateAcked = (BACNET_EVENT_STATE) enumValue; len += section_len; if (-1 == (section_len = bacapp_decode_context_timestamp(&apdu[len], 3, &data->eventTimeStamp))) { return -1; } len += section_len; if (-1 == (section_len = decode_context_character_string(&apdu[len], 4, &data->ackSource))) { return -1; } len += section_len; if (-1 == (section_len = bacapp_decode_context_timestamp(&apdu[len], 5, &data->ackTimeStamp))) { return -1; } len += section_len; return len; }
void handler_conf_private_trans_ack( uint8_t * service_request, uint16_t service_len, BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data) { BACNET_PRIVATE_TRANSFER_DATA data; int len; /* * Note: * We currently don't look at the source address and service data * but we probably should to verify that the ack is oneit is what * we were expecting. But this is just to silence some compiler * warnings from Borland. */ unused_var(src); unused_var(service_data); len = 0; #if PRINT_ENABLED printf("Received Confirmed Private Transfer Ack!\n"); #endif len = ptransfer_decode_service_request(service_request, service_len, &data); /* Same decode for ack as for service request! */ if (len < 0) { #if PRINT_ENABLED printf("cpta: Bad Encoding!\n"); #endif } ProcessPTA(&data); /* See what to do with the response */ return; }
/* encode service */ static int pt_encode_apdu( uint8_t * apdu, uint16_t max_apdu, BACNET_PRIVATE_TRANSFER_DATA * private_data) { int len = 0; /* length of each encoding */ int apdu_len = 0; /* total length of the apdu, return value */ /* Unconfirmed/ConfirmedPrivateTransfer-Request ::= SEQUENCE { vendorID [0] Unsigned, serviceNumber [1] Unsigned, serviceParameters [2] ABSTRACT-SYNTAX.&Type OPTIONAL } */ /* unused parameter */ unused_var(max_apdu); if (apdu) { len = encode_context_unsigned(&apdu[apdu_len], 0, private_data->vendorID); apdu_len += len; len = encode_context_unsigned(&apdu[apdu_len], 1, private_data->serviceNumber); apdu_len += len; len = encode_opening_tag(&apdu[apdu_len], 2); apdu_len += len; for (len = 0; len < private_data->serviceParametersLen; len++) { apdu[apdu_len] = private_data->serviceParameters[len]; apdu_len++; } len = encode_closing_tag(&apdu[apdu_len], 2); apdu_len += len; } return apdu_len; }
/** Handler for an Unconfirmed COV Notification. * @ingroup DSCOV * Decodes the received list of Properties to update, * and print them out with the subscription information. * @note Nothing is specified in BACnet about what to do with the * information received from Unconfirmed COV Notifications. * * @param service_request [in] The contents of the service request. * @param service_len [in] The length of the service_request. * @param src [in] BACNET_ADDRESS of the source of the message (unused) */ void handler_ucov_notification( uint8_t * service_request, uint16_t service_len, BACNET_ADDRESS * src) { BACNET_COV_DATA cov_data; BACNET_PROPERTY_VALUE property_value[MAX_COV_PROPERTIES]; BACNET_PROPERTY_VALUE *pProperty_value = NULL; int len = 0; unsigned index = 0; /* src not needed for this application */ unused_var(src); /* create linked list to store data if more than one property value is expected */ pProperty_value = &property_value[0]; while (pProperty_value) { index++; if (index < MAX_COV_PROPERTIES) { pProperty_value->next = &property_value[index]; } else { pProperty_value->next = NULL; } pProperty_value = pProperty_value->next; } cov_data.listOfValues = &property_value[0]; #if PRINT_ENABLED fprintf(stderr, "UCOV: Received Notification!\n"); #endif /* decode the service request only */ len = cov_notify_decode_service_request(service_request, service_len, &cov_data); #if PRINT_ENABLED if (len > 0) { fprintf(stderr, "UCOV: PID=%u ", cov_data.subscriberProcessIdentifier); fprintf(stderr, "instance=%u ", cov_data.initiatingDeviceIdentifier); fprintf(stderr, "%s %u ", bactext_object_type_name(cov_data.monitoredObjectIdentifier.type), cov_data.monitoredObjectIdentifier.instance); fprintf(stderr, "time remaining=%u seconds ", cov_data.timeRemaining); fprintf(stderr, "\n"); pProperty_value = &property_value[0]; while (pProperty_value) { fprintf(stderr, "UCOV: "); if (pProperty_value->propertyIdentifier < 512) { fprintf(stderr, "%s ", bactext_property_name (pProperty_value->propertyIdentifier)); } else { fprintf(stderr, "proprietary %u ", pProperty_value->propertyIdentifier); } if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) { fprintf(stderr, "%u ", pProperty_value->propertyArrayIndex); } fprintf(stderr, "\n"); pProperty_value = pProperty_value->next; } } else { fprintf(stderr, "UCOV: Unable to decode service request!\n"); } #endif }
static int cov_encode_subscription( uint8_t * apdu, int max_apdu, BACNET_COV_SUBSCRIPTION * cov_subscription) { int len = 0; int apdu_len = 0; BACNET_OCTET_STRING octet_string; BACNET_ADDRESS *dest = NULL; /* FIXME: unused parameter */ unused_var(max_apdu); if (!cov_subscription) { return 0; } dest = cov_address_get(cov_subscription->dest_index); if (!dest) { return 0; } /* Recipient [0] BACnetRecipientProcess - opening */ len = encode_opening_tag(&apdu[apdu_len], 0); apdu_len += len; /* recipient [0] BACnetRecipient - opening */ len = encode_opening_tag(&apdu[apdu_len], 0); apdu_len += len; /* CHOICE - address [1] BACnetAddress - opening */ len = encode_opening_tag(&apdu[apdu_len], 1); apdu_len += len; /* network-number Unsigned16, */ /* -- A value of 0 indicates the local network */ len = encode_application_unsigned(&apdu[apdu_len], dest->net); apdu_len += len; /* mac-address OCTET STRING */ /* -- A string of length 0 indicates a broadcast */ if (dest->net) { octetstring_init(&octet_string, &dest->adr[0], dest->len); } else { octetstring_init(&octet_string, &dest->mac[0], dest->mac_len); } len = encode_application_octet_string(&apdu[apdu_len], &octet_string); apdu_len += len; /* CHOICE - address [1] BACnetAddress - closing */ len = encode_closing_tag(&apdu[apdu_len], 1); apdu_len += len; /* recipient [0] BACnetRecipient - closing */ len = encode_closing_tag(&apdu[apdu_len], 0); apdu_len += len; /* processIdentifier [1] Unsigned32 */ len = encode_context_unsigned(&apdu[apdu_len], 1, cov_subscription->subscriberProcessIdentifier); apdu_len += len; /* Recipient [0] BACnetRecipientProcess - closing */ len = encode_closing_tag(&apdu[apdu_len], 0); apdu_len += len; /* MonitoredPropertyReference [1] BACnetObjectPropertyReference, */ len = encode_opening_tag(&apdu[apdu_len], 1); apdu_len += len; /* objectIdentifier [0] */ len = encode_context_object_id(&apdu[apdu_len], 0, cov_subscription->monitoredObjectIdentifier.type, cov_subscription->monitoredObjectIdentifier.instance); apdu_len += len; /* propertyIdentifier [1] */ /* FIXME: we are monitoring 2 properties! How to encode? */ len = encode_context_enumerated(&apdu[apdu_len], 1, PROP_PRESENT_VALUE); apdu_len += len; /* MonitoredPropertyReference [1] - closing */ len = encode_closing_tag(&apdu[apdu_len], 1); apdu_len += len; /* IssueConfirmedNotifications [2] BOOLEAN, */ len = encode_context_boolean(&apdu[apdu_len], 2, cov_subscription->flag.issueConfirmedNotifications); apdu_len += len; /* TimeRemaining [3] Unsigned, */ len = encode_context_unsigned(&apdu[apdu_len], 3, cov_subscription->lifetime); apdu_len += len; return apdu_len; }
/** * Decodes from bytes into the lighting-command structure * * @param apdu - buffer to hold the bytes * @param apdu_max_len - number of bytes in the buffer to decode * @param value - lighting command value to place the decoded values * * @return number of bytes encoded */ int lighting_command_decode( uint8_t * apdu, unsigned apdu_max_len, BACNET_LIGHTING_COMMAND * data) { int len = 0; int apdu_len = 0; uint8_t tag_number = 0; uint32_t len_value_type = 0; uint32_t unsigned_value = 0; float real_value = 0.0; unused_var(apdu_max_len); /* check for value pointers */ if (apdu_max_len && data) { /* Tag 0: operation */ if (!decode_is_context_tag(&apdu[apdu_len], 0)) return BACNET_STATUS_ERROR; len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value_type); apdu_len += len; len = decode_enumerated(&apdu[apdu_len], len_value_type, &unsigned_value); if (len > 0) { data->operation = unsigned_value; } apdu_len += len; /* Tag 1: target-level - OPTIONAL */ if (decode_is_context_tag(&apdu[apdu_len], 1)) { len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value_type); apdu_len += len; len = decode_real(&apdu[apdu_len], &real_value); data->target_level = real_value; apdu_len += len; data->use_target_level = true; } else { data->use_target_level = false; } /* Tag 2: ramp-rate - OPTIONAL */ if (decode_is_context_tag(&apdu[apdu_len], 2)) { len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value_type); apdu_len += len; len = decode_real(&apdu[apdu_len], &real_value); data->ramp_rate = real_value; data->use_ramp_rate = true; } else { data->use_ramp_rate = false; } /* Tag 3: step-increment - OPTIONAL */ if (decode_is_context_tag(&apdu[apdu_len], 3)) { len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value_type); apdu_len += len; len = decode_real(&apdu[apdu_len], &real_value); data->step_increment = real_value; data->use_step_increment = true; } else { data->use_step_increment = false; } /* Tag 4: fade-time - OPTIONAL */ if (decode_is_context_tag(&apdu[apdu_len], 4)) { len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value_type); apdu_len += len; len = decode_unsigned(&apdu[apdu_len], len_value_type, &unsigned_value); data->fade_time = unsigned_value; data->use_fade_time = true; } else { data->use_fade_time = false; } /* Tag 5: priority - OPTIONAL */ if (decode_is_context_tag(&apdu[apdu_len], 4)) { len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value_type); apdu_len += len; len = decode_unsigned(&apdu[apdu_len], len_value_type, &unsigned_value); data->priority = unsigned_value; data->use_priority = true; } else { data->use_priority = false; } } return len; }