AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/atmega8/h_rp.c
int Encode_Property_APDU(
    uint8_t * apdu,
    BACNET_READ_PROPERTY_DATA * rp_data,
    BACNET_ERROR_CLASS * error_class,
    BACNET_ERROR_CODE * error_code)
{
    int apdu_len = -1;

    /* handle each object type */
    switch (rp_data->object_type) {
        case OBJECT_DEVICE:
            if (Device_Valid_Object_Instance_Number(rp_data->object_instance)) {
                apdu_len =
                    Device_Encode_Property_APDU(&apdu[0],
                    rp_data->object_instance, rp_data->object_property,
                    rp_data->array_index, error_class, error_code);
            }
            break;
#if MAX_ANALOG_VALUES
        case OBJECT_ANALOG_VALUE:
            if (Analog_Value_Valid_Instance(rp_data->object_instance)) {
                apdu_len =
                    Analog_Value_Encode_Property_APDU(&apdu[0],
                    rp_data->object_instance, rp_data->object_property,
                    rp_data->array_index, error_class, error_code);
            }
            break;
#endif
#if MAX_BINARY_VALUES
        case OBJECT_BINARY_VALUE:
            if (Binary_Value_Valid_Instance(rp_data->object_instance)) {
                apdu_len =
                    Binary_Value_Encode_Property_APDU(&apdu[0],
                    rp_data->object_instance, rp_data->object_property,
                    rp_data->array_index, error_class, error_code);
            }
            break;
#endif
        default:
            *error_class = ERROR_CLASS_OBJECT;
            *error_code = ERROR_CODE_UNKNOWN_OBJECT;
            break;
    }

    return apdu_len;
}
/* Encodes the property APDU and returns the length,
   or sets the error, and returns -1 */
Encodes the property APDU and returns the length,
or sets the error, and returns -1
Encodes the property APDU and returns the length or sets the error and returns - 1
int Encode_Property_APDU(
    uint8_t * apdu,
    BACNET_READ_PROPERTY_DATA * rp_data,
    BACNET_ERROR_CLASS * error_class,
    BACNET_ERROR_CODE * error_code)
{
    int apdu_len = -1;
    switch (rp_data->object_type) {
        case OBJECT_DEVICE:
            if (Device_Valid_Object_Instance_Number(rp_data->object_instance)) {
                apdu_len =
                    Device_Encode_Property_APDU(&apdu[0],
                    rp_data->object_instance, rp_data->object_property,
                    rp_data->array_index, error_class, error_code);
            }
            break;
#if MAX_ANALOG_VALUES
        case OBJECT_ANALOG_VALUE:
            if (Analog_Value_Valid_Instance(rp_data->object_instance)) {
                apdu_len =
                    Analog_Value_Encode_Property_APDU(&apdu[0],
                    rp_data->object_instance, rp_data->object_property,
                    rp_data->array_index, error_class, error_code);
            }
            break;
#endif
#if MAX_BINARY_VALUES
        case OBJECT_BINARY_VALUE:
            if (Binary_Value_Valid_Instance(rp_data->object_instance)) {
                apdu_len =
                    Binary_Value_Encode_Property_APDU(&apdu[0],
                    rp_data->object_instance, rp_data->object_property,
                    rp_data->array_index, error_class, error_code);
            }
            break;
#endif
        default:
            *error_class = ERROR_CLASS_OBJECT;
            *error_code = ERROR_CODE_UNKNOWN_OBJECT;
            break;
    }
    return apdu_len;
}
int Encode_Property_APDU ( uint8_t * apdu , BACNET_READ_PROPERTY_DATA * rp_data , BACNET_ERROR_CLASS * error_class , BACNET_ERROR_CODE * error_code ) { int apdu_len = -1 ; switch ( rp_data -> object_type ) { case OBJECT_DEVICE : if ( Device_Valid_Object_Instance_Number ( rp_data -> object_instance ) ) { apdu_len = Device_Encode_Property_APDU ( & apdu [ 0 ] , rp_data -> object_instance , rp_data -> object_property , rp_data -> array_index , error_class , error_code ) ; } break ; #if MAX_ANALOG_VALUES case OBJECT_ANALOG_VALUE : if ( Analog_Value_Valid_Instance ( rp_data -> object_instance ) ) { apdu_len = Analog_Value_Encode_Property_APDU ( & apdu [ 0 ] , rp_data -> object_instance , rp_data -> object_property , rp_data -> array_index , error_class , error_code ) ; } break ; #endif #if MAX_BINARY_VALUES case OBJECT_BINARY_VALUE : if ( Binary_Value_Valid_Instance ( rp_data -> object_instance ) ) { apdu_len = Binary_Value_Encode_Property_APDU ( & apdu [ 0 ] , rp_data -> object_instance , rp_data -> object_property , rp_data -> array_index , error_class , error_code ) ; } break ; #endif default : * error_class = ERROR_CLASS_OBJECT ; * error_code = ERROR_CODE_UNKNOWN_OBJECT ; break ; } return apdu_len ; }
Encodes the property APDU and returns the length,
or sets the error, and returns -1
Encodes the property APDU and returns the length or sets the error and returns - 1
/* handle each object type */