AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/demo/object/lo.c
bool Lighting_Output_Write_Property(
    BACNET_WRITE_PROPERTY_DATA * wp_data)
{
    bool status = false;        /* return value */
    int len = 0;
    BACNET_APPLICATION_DATA_VALUE value;

    /* decode the some of the request */
    len =
        bacapp_decode_application_data(wp_data->application_data,
        wp_data->application_data_len, &value);
    /* FIXME: len < application_data_len: more data? */
    if (len < 0) {
        /* error while decoding - a value larger than we can handle */
        wp_data->error_class = ERROR_CLASS_PROPERTY;
        wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
        return false;
    }
    if ((wp_data->object_property != PROP_PRIORITY_ARRAY) &&
        (wp_data->array_index != BACNET_ARRAY_ALL)) {
        /*  only array properties can have array options */
        wp_data->error_class = ERROR_CLASS_PROPERTY;
        wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
        return false;
    }
    switch (wp_data->object_property) {
        case PROP_PRESENT_VALUE:
            if (value.tag == BACNET_APPLICATION_TAG_REAL) {
                /* Command priority 6 is reserved for use by Minimum On/Off
                   algorithm and may not be used for other purposes in any
                   object. */
                status =
                    Lighting_Output_Present_Value_Set(wp_data->object_instance,
                    value.type.Real, wp_data->priority);
                if (wp_data->priority == 6) {
                    /* Command priority 6 is reserved for use by Minimum On/Off
                       algorithm and may not be used for other purposes in any
                       object. */
                    wp_data->error_class = ERROR_CLASS_PROPERTY;
                    wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
                } else if (!status) {
                    wp_data->error_class = ERROR_CLASS_PROPERTY;
                    wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
                }
            } else {
                status =
                    WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
                    &wp_data->error_class, &wp_data->error_code);
                if (status) {
                    if (wp_data->priority == 6) {
                        /* Command priority 6 is reserved for use by Minimum On/Off
                           algorithm and may not be used for other purposes in any
                           object.  - Note Lighting_Output_Present_Value_Relinquish()
                           will have returned false because of this */
                        wp_data->error_class = ERROR_CLASS_PROPERTY;
                        wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
                    } else {
                        status = Lighting_Output_Present_Value_Relinquish(
                            wp_data->object_instance, wp_data->priority);
                        if (!status) {
                            wp_data->error_class = ERROR_CLASS_PROPERTY;
                            wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
                        }
                    }
                }
            }
            break;
        case PROP_LIGHTING_COMMAND:
            if (value.tag == BACNET_APPLICATION_TAG_LIGHTING_COMMAND) {
                status = Lighting_Output_Lighting_Command_Set(
                    wp_data->object_instance,
                    &value.type.Lighting_Command);
                if (!status) {
                    wp_data->error_class = ERROR_CLASS_PROPERTY;
                    wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
                }
            } else {
                wp_data->error_class = ERROR_CLASS_PROPERTY;
                wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
            }
            break;
        case PROP_OUT_OF_SERVICE:
            status =
                WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
                &wp_data->error_class, &wp_data->error_code);
            if (status) {
                Lighting_Output_Out_Of_Service_Set(
                    wp_data->object_instance,
                    value.type.Boolean);
            }
            break;
        case PROP_OBJECT_IDENTIFIER:
        case PROP_OBJECT_NAME:
        case PROP_OBJECT_TYPE:
        case PROP_TRACKING_VALUE:
        case PROP_IN_PROGRESS:
        case PROP_STATUS_FLAGS:
        case PROP_BLINK_WARN_ENABLE:
        case PROP_EGRESS_TIME:
        case PROP_EGRESS_ACTIVE:
        case PROP_DEFAULT_FADE_TIME:
        case PROP_DEFAULT_RAMP_RATE:
        case PROP_DEFAULT_STEP_INCREMENT:
        case PROP_PRIORITY_ARRAY:
        case PROP_RELINQUISH_DEFAULT:
            wp_data->error_class = ERROR_CLASS_PROPERTY;
            wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
            break;
        default:
            wp_data->error_class = ERROR_CLASS_PROPERTY;
            wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
            break;
    }

    return status;
}
/**
 * WriteProperty handler for this object.  For the given WriteProperty
 * data, the application_data is loaded or the error flags are set.
 *
 * @param  wp_data - BACNET_WRITE_PROPERTY_DATA data, including
 * requested data and space for the reply, or error response.
 *
 * @return false if an error is loaded, true if no errors
 */
WriteProperty handler for this object.  For the given WriteProperty
data, the application_data is loaded or the error flags are set.

@param  wp_data - BACNET_WRITE_PROPERTY_DATA data, including
requested data and space for the reply, or error response.

@return false if an error is loaded, true if no errors
WriteProperty handler for this object . For the given WriteProperty data the application_data is loaded or the error flags are set . @param wp_data - BACNET_WRITE_PROPERTY_DATA data including requested data and space for the reply or error response . @return false if an error is loaded true if no errors
bool Lighting_Output_Write_Property(
    BACNET_WRITE_PROPERTY_DATA * wp_data)
{
    bool status = false;        
    int len = 0;
    BACNET_APPLICATION_DATA_VALUE value;
    len =
        bacapp_decode_application_data(wp_data->application_data,
        wp_data->application_data_len, &value);
    if (len < 0) {
        wp_data->error_class = ERROR_CLASS_PROPERTY;
        wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
        return false;
    }
    if ((wp_data->object_property != PROP_PRIORITY_ARRAY) &&
        (wp_data->array_index != BACNET_ARRAY_ALL)) {
        wp_data->error_class = ERROR_CLASS_PROPERTY;
        wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
        return false;
    }
    switch (wp_data->object_property) {
        case PROP_PRESENT_VALUE:
            if (value.tag == BACNET_APPLICATION_TAG_REAL) {
                status =
                    Lighting_Output_Present_Value_Set(wp_data->object_instance,
                    value.type.Real, wp_data->priority);
                if (wp_data->priority == 6) {
                    wp_data->error_class = ERROR_CLASS_PROPERTY;
                    wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
                } else if (!status) {
                    wp_data->error_class = ERROR_CLASS_PROPERTY;
                    wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
                }
            } else {
                status =
                    WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
                    &wp_data->error_class, &wp_data->error_code);
                if (status) {
                    if (wp_data->priority == 6) {
                        wp_data->error_class = ERROR_CLASS_PROPERTY;
                        wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
                    } else {
                        status = Lighting_Output_Present_Value_Relinquish(
                            wp_data->object_instance, wp_data->priority);
                        if (!status) {
                            wp_data->error_class = ERROR_CLASS_PROPERTY;
                            wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
                        }
                    }
                }
            }
            break;
        case PROP_LIGHTING_COMMAND:
            if (value.tag == BACNET_APPLICATION_TAG_LIGHTING_COMMAND) {
                status = Lighting_Output_Lighting_Command_Set(
                    wp_data->object_instance,
                    &value.type.Lighting_Command);
                if (!status) {
                    wp_data->error_class = ERROR_CLASS_PROPERTY;
                    wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
                }
            } else {
                wp_data->error_class = ERROR_CLASS_PROPERTY;
                wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
            }
            break;
        case PROP_OUT_OF_SERVICE:
            status =
                WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
                &wp_data->error_class, &wp_data->error_code);
            if (status) {
                Lighting_Output_Out_Of_Service_Set(
                    wp_data->object_instance,
                    value.type.Boolean);
            }
            break;
        case PROP_OBJECT_IDENTIFIER:
        case PROP_OBJECT_NAME:
        case PROP_OBJECT_TYPE:
        case PROP_TRACKING_VALUE:
        case PROP_IN_PROGRESS:
        case PROP_STATUS_FLAGS:
        case PROP_BLINK_WARN_ENABLE:
        case PROP_EGRESS_TIME:
        case PROP_EGRESS_ACTIVE:
        case PROP_DEFAULT_FADE_TIME:
        case PROP_DEFAULT_RAMP_RATE:
        case PROP_DEFAULT_STEP_INCREMENT:
        case PROP_PRIORITY_ARRAY:
        case PROP_RELINQUISH_DEFAULT:
            wp_data->error_class = ERROR_CLASS_PROPERTY;
            wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
            break;
        default:
            wp_data->error_class = ERROR_CLASS_PROPERTY;
            wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
            break;
    }
    return status;
}
bool Lighting_Output_Write_Property ( BACNET_WRITE_PROPERTY_DATA * wp_data ) { bool status = false ; int len = 0 ; BACNET_APPLICATION_DATA_VALUE value ; len = bacapp_decode_application_data ( wp_data -> application_data , wp_data -> application_data_len , & value ) ; if ( len < 0 ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_VALUE_OUT_OF_RANGE ; return false ; } if ( ( wp_data -> object_property != PROP_PRIORITY_ARRAY ) && ( wp_data -> array_index != BACNET_ARRAY_ALL ) ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY ; return false ; } switch ( wp_data -> object_property ) { case PROP_PRESENT_VALUE : if ( value . tag == BACNET_APPLICATION_TAG_REAL ) { status = Lighting_Output_Present_Value_Set ( wp_data -> object_instance , value . type . Real , wp_data -> priority ) ; if ( wp_data -> priority == 6 ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_WRITE_ACCESS_DENIED ; } else if ( ! status ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_VALUE_OUT_OF_RANGE ; } } else { status = WPValidateArgType ( & value , BACNET_APPLICATION_TAG_NULL , & wp_data -> error_class , & wp_data -> error_code ) ; if ( status ) { if ( wp_data -> priority == 6 ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_WRITE_ACCESS_DENIED ; } else { status = Lighting_Output_Present_Value_Relinquish ( wp_data -> object_instance , wp_data -> priority ) ; if ( ! status ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_VALUE_OUT_OF_RANGE ; } } } } break ; case PROP_LIGHTING_COMMAND : if ( value . tag == BACNET_APPLICATION_TAG_LIGHTING_COMMAND ) { status = Lighting_Output_Lighting_Command_Set ( wp_data -> object_instance , & value . type . Lighting_Command ) ; if ( ! status ) { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_VALUE_OUT_OF_RANGE ; } } else { wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_INVALID_DATA_TYPE ; } break ; case PROP_OUT_OF_SERVICE : status = WPValidateArgType ( & value , BACNET_APPLICATION_TAG_BOOLEAN , & wp_data -> error_class , & wp_data -> error_code ) ; if ( status ) { Lighting_Output_Out_Of_Service_Set ( wp_data -> object_instance , value . type . Boolean ) ; } break ; case PROP_OBJECT_IDENTIFIER : case PROP_OBJECT_NAME : case PROP_OBJECT_TYPE : case PROP_TRACKING_VALUE : case PROP_IN_PROGRESS : case PROP_STATUS_FLAGS : case PROP_BLINK_WARN_ENABLE : case PROP_EGRESS_TIME : case PROP_EGRESS_ACTIVE : case PROP_DEFAULT_FADE_TIME : case PROP_DEFAULT_RAMP_RATE : case PROP_DEFAULT_STEP_INCREMENT : case PROP_PRIORITY_ARRAY : case PROP_RELINQUISH_DEFAULT : wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_WRITE_ACCESS_DENIED ; break ; default : wp_data -> error_class = ERROR_CLASS_PROPERTY ; wp_data -> error_code = ERROR_CODE_UNKNOWN_PROPERTY ; break ; } return status ; }
WriteProperty handler for this object.
WriteProperty handler for this object .
/* return value */ /* decode the some of the request */ /* FIXME: len < application_data_len: more data? */ /* error while decoding - a value larger than we can handle */ /*  only array properties can have array options */ /* Command priority 6 is reserved for use by Minimum On/Off
                   algorithm and may not be used for other purposes in any
                   object. */ /* Command priority 6 is reserved for use by Minimum On/Off
                       algorithm and may not be used for other purposes in any
                       object. */ /* Command priority 6 is reserved for use by Minimum On/Off
                           algorithm and may not be used for other purposes in any
                           object.  - Note Lighting_Output_Present_Value_Relinquish()
                           will have returned false because of this */