Feature/raspberry pi blinkt color objects (#503)
* fixed BACnetXYcolor and BACnetColorCommand encode and decoding and improved unit test coverage. Refactored BACnetXYcolor to/from ascii into lighting module. * added to the color, color temperature, and lighting output objects a fade/ramp/step engine. Added color and color command coercion into the channel object and enabled color temperature object coercion. Added CreateObject and DeleteObject service handling to the color, color temperature, lighting output, and channel objects. * added blinkt demo app for Raspberry Pi [WIP] * updated gitignore to simplify handling of apps folder contents * fixed piface demo build * added RaspiOS to pipeline for piface and blinkt! demo builds * added device object timer function for child object types into example Device object. Refactored device object to increment database revision for create or delete object services. Refactored example app/server to use mstimer library and device child object timers. --------- Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -45,8 +45,11 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/color_rgb.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
${SRC_DIR}/bacnet/basic/sys/linear.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
@@ -57,6 +60,10 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
m)
|
||||
|
||||
@@ -30,36 +30,104 @@ static void testLightingOutput(void)
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata;
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
const int *required_property = NULL;
|
||||
const uint32_t instance = 1;
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
const uint32_t instance = 123;
|
||||
BACNET_WRITE_PROPERTY_DATA wpdata = { 0 };
|
||||
bool status = false;
|
||||
unsigned index;
|
||||
uint16_t milliseconds = 10;
|
||||
|
||||
Lighting_Output_Init();
|
||||
Lighting_Output_Create(instance);
|
||||
status = Lighting_Output_Valid_Instance(instance);
|
||||
zassert_true(status, NULL);
|
||||
index = Lighting_Output_Instance_To_Index(instance);
|
||||
zassert_equal(index, 0, NULL);
|
||||
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_LIGHTING_OUTPUT;
|
||||
rpdata.object_instance = instance;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
Lighting_Output_Property_Lists(&required_property, NULL, NULL);
|
||||
while ((*required_property) >= 0) {
|
||||
rpdata.object_property = *required_property;
|
||||
Lighting_Output_Property_Lists(&pRequired, &pOptional, &pProprietary);
|
||||
while ((*pRequired) >= 0) {
|
||||
rpdata.object_property = *pRequired;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_true(len >= 0, NULL);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(rpdata.application_data,
|
||||
len, &value, rpdata.object_type, rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
if (rpdata.object_property != PROP_PRIORITY_ARRAY) {
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
wpdata.object_instance = rpdata.object_instance;
|
||||
wpdata.object_property = rpdata.object_property;
|
||||
wpdata.array_index = rpdata.array_index;
|
||||
memcpy(&wpdata.application_data, rpdata.application_data, MAX_APDU);
|
||||
wpdata.application_data_len = len;
|
||||
wpdata.error_code = ERROR_CODE_SUCCESS;
|
||||
status = Lighting_Output_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
}
|
||||
required_property++;
|
||||
pRequired++;
|
||||
}
|
||||
while ((*pOptional) != -1) {
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR,
|
||||
"property '%s': failed to ReadProperty!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
(uint8_t)rpdata.application_data_len, &value);
|
||||
zassert_equal(len, test_len, "property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
/* check WriteProperty properties */
|
||||
wpdata.object_type = rpdata.object_type;
|
||||
wpdata.object_instance = rpdata.object_instance;
|
||||
wpdata.object_property = rpdata.object_property;
|
||||
wpdata.array_index = rpdata.array_index;
|
||||
memcpy(&wpdata.application_data, rpdata.application_data, MAX_APDU);
|
||||
wpdata.application_data_len = len;
|
||||
wpdata.error_code = ERROR_CODE_SUCCESS;
|
||||
status = Lighting_Output_Write_Property(&wpdata);
|
||||
if (!status) {
|
||||
/* verify WriteProperty property is known */
|
||||
zassert_not_equal(wpdata.error_code,
|
||||
ERROR_CODE_UNKNOWN_PROPERTY,
|
||||
"property '%s': WriteProperty Unknown!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
}
|
||||
pOptional++;
|
||||
}
|
||||
/* check for unsupported property - use ALL */
|
||||
rpdata.object_property = PROP_ALL;
|
||||
len = Lighting_Output_Read_Property(&rpdata);
|
||||
zassert_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
status = Lighting_Output_Write_Property(&wpdata);
|
||||
zassert_false(status, NULL);
|
||||
/* check the dimming/ramping/stepping engine*/
|
||||
Lighting_Output_Timer(instance, milliseconds);
|
||||
/* check the delete function */
|
||||
status = Lighting_Output_Delete(instance);
|
||||
zassert_true(status, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user