void TemperatureObject_Create(AwaStaticClient * awaClient)
{
    // Define Temperature objects
    AwaStaticClient_DefineObject(awaClient, IPSO_TEMPERATURE_OBJECT, "Temperature", 0, TEMPERATURE_INSTANCES);
    AwaStaticClient_DefineResource(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_SENSOR_VALUE, "Value", AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
	AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_SENSOR_VALUE, &temperatureObject[0].Value, sizeof(temperatureObject[0].Value), sizeof(temperatureObject[0]));
    AwaStaticClient_DefineResource(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_UNITS, "Units", AwaResourceType_String, 0, 1, AwaResourceOperations_ReadOnly);
	AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_UNITS, &temperatureObject[0].Units, sizeof(temperatureObject[0].Units), sizeof(temperatureObject[0]));
    AwaStaticClient_DefineResource(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_MIN_MEASURED_VALUE, "Min", AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
	AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_MIN_MEASURED_VALUE, &temperatureObject[0].Min, sizeof(temperatureObject[0].Min), sizeof(temperatureObject[0]));
    AwaStaticClient_DefineResource(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_MAX_MEASURED_VALUE, "Max", AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
	AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_TEMPERATURE_OBJECT, IPSO_MAX_MEASURED_VALUE, &temperatureObject[0].Max, sizeof(temperatureObject[0].Max), sizeof(temperatureObject[0]));

    // Create object instances
    memset(&temperatureObject, 0, sizeof(temperatureObject));
    memset(&temperatureInput, 0, sizeof(temperatureInput));
    int instance;
    for (instance = 0; instance < TEMPERATURE_INSTANCES; instance++)
    {
        AwaStaticClient_CreateObjectInstance(awaClient, IPSO_TEMPERATURE_OBJECT, instance);
        AwaStaticClient_CreateResource(awaClient, IPSO_TEMPERATURE_OBJECT, instance, IPSO_SENSOR_VALUE);
        AwaStaticClient_CreateResource(awaClient, IPSO_TEMPERATURE_OBJECT, instance, IPSO_UNITS);
        AwaStaticClient_CreateResource(awaClient, IPSO_TEMPERATURE_OBJECT, instance, IPSO_MIN_MEASURED_VALUE);
        AwaStaticClient_CreateResource(awaClient, IPSO_TEMPERATURE_OBJECT, instance, IPSO_MAX_MEASURED_VALUE);
        strncpy(temperatureObject[instance].Units, TEMPERATURE_UNITS_CELSIUS, TEMPERATURE_UNITS_SIZE);
    }
}
int LightControl_AddLightControl(AwaStaticClient *awaClient, ObjectInstanceIDType objectInstanceID,
    LightControlCallBack callback, void *callbackContext)
{
    if ((awaClient == NULL) || (objectInstanceID < 0) || (objectInstanceID >= LIGHT_CONTROLS))
    {
        printf("Invalid arguments passed to %s", __func__);
        return -1;
    }

    AwaStaticClient_CreateObjectInstance(awaClient, IPSO_LIGHT_CONTROL_OBJECT, objectInstanceID);
    AwaStaticClient_CreateResource(awaClient, IPSO_LIGHT_CONTROL_OBJECT, objectInstanceID, IPSO_LIGHT_CONTROL_COLOUR);
    AwaStaticClient_CreateResource(awaClient, IPSO_LIGHT_CONTROL_OBJECT, objectInstanceID, IPSO_LIGHT_CONTROL_ON_TIME);
    lightControls[objectInstanceID].OnOff = false;
    snprintf(lightControls[objectInstanceID].Colour, sizeof(lightControls[objectInstanceID].Colour), "Red%d", objectInstanceID+1);
    lightControls[objectInstanceID].callback = callback;
    lightControls[objectInstanceID].context = callbackContext;
    if (callback != NULL)
    {
        lightControls[objectInstanceID].callback(lightControls[objectInstanceID].context,
            lightControls[objectInstanceID].OnOff, lightControls[objectInstanceID].Dimmer,
            lightControls[objectInstanceID].Colour);
    }
    return 0;
}
AwaError BarometerObject_DefineObjectsAndResources(AwaStaticClient *awaClient, AwaFloat minRange, AwaFloat maxRange)
{
    BarometerStorage.MaxRangeValue = maxRange;
    BarometerStorage.MinRangeValue = minRange;

    AwaError error;

    error = AwaStaticClient_DefineObject(awaClient, IPSO_BAROMETER_OBJECT, "Barometer", 0, 1);
    if (error != AwaError_Success)
    {
        printf("Failed to register Barometer IPSO object\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_SENSOR_VALUE, "Sensor Value", AwaResourceType_Float,
        1, 1, AwaResourceOperations_ReadOnly);
    AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_SENSOR_VALUE, &BarometerStorage.Value,
        sizeof(BarometerStorage.Value), 0);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Sensor Value' resource\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_UNITS, "Units", AwaResourceType_String, 0, 1,
        AwaResourceOperations_ReadOnly);
    AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_UNITS, BarometerStorage.Units,
        strlen(BarometerStorage.Units), 0);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Units' resource\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MIN_MEASURED_VALUE, "Min Measured Value",
        AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
    AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MIN_MEASURED_VALUE,
        &BarometerStorage.MinMeasuredValue, sizeof(BarometerStorage.MinMeasuredValue), 0);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Min Measured Value' resource\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MAX_MEASURED_VALUE, "Max Measured Value",
        AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
    AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MAX_MEASURED_VALUE, &BarometerStorage.MaxMeasuredValue,
        sizeof(BarometerStorage.MaxMeasuredValue), 0);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Max Measured Value' resource\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MIN_RANGE_VALUE, "Min Range Value",
        AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
    AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MIN_RANGE_VALUE, &BarometerStorage.MinRangeValue,
        sizeof(BarometerStorage.MinRangeValue), 0);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Min Range Value' resource\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MAX_RANGE_VALUE, "Max Range Value",
        AwaResourceType_Float, 0, 1, AwaResourceOperations_ReadOnly);
    AwaStaticClient_SetResourceStorageWithPointer(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_MAX_RANGE_VALUE, &BarometerStorage.MaxRangeValue,
        sizeof(BarometerStorage.MaxRangeValue), 0);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Max Range Value' resource\n");
        return error;
    }

    error = AwaStaticClient_DefineResource(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_RESET_MIN_AND_MAX_MEASURED_VALUES,
        "Reset Min and Max Measured Values", AwaResourceType_Opaque, 0, 1, AwaResourceOperations_Execute);
    AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_BAROMETER_OBJECT, IPSO_BAROMETER_RESET_MIN_AND_MAX_MEASURED_VALUES,
        BarometerObject_Handler);
    if (error != AwaError_Success)
    {
        printf("Failed to define 'Reset Min and Max Measured Values' resource\n");
        return error;
    }

    int instance = 0;
    error = AwaStaticClient_CreateObjectInstance(awaClient, IPSO_BAROMETER_OBJECT, instance);
    if (error != AwaError_Success) {
        // if the object instance already exists,
        // the object already contains a maximum number of object instances,
        // or if no object is defined for the specified object ID.
        printf("Failed to CreateObjectInstance\n");
        return error;
    }

    //Since it's mandatory resource, you don't need to create it explicit. Awa will handle this for you
    //error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_SENSOR_VALUE);
    error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_UNITS);
    if (error != AwaError_Success)
    {
        printf("Failed to create resource 'Units'\n");
        return error;
    }

    error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_MAX_RANGE_VALUE);
    if (error != AwaError_Success)
    {
        printf("Failed to create resource 'Max Range Value'\n");
        return error;
    }

    error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_MIN_RANGE_VALUE);
    if (error != AwaError_Success)
    {
        printf("Failed to create resource 'Min Range Value'\n");
        return error;
    }

    error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_MIN_MEASURED_VALUE);
    if (error != AwaError_Success)
    {
        printf("Failed to create resource 'Min Measured Value'\n");
        return error;
    }

    error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_MAX_MEASURED_VALUE);
    if (error != AwaError_Success)
    {
        printf("Failed to create resource 'Max Measured Value'\n");
        return error;
    }

    error = AwaStaticClient_CreateResource(awaClient, IPSO_BAROMETER_OBJECT, instance, IPSO_BAROMETER_RESET_MIN_AND_MAX_MEASURED_VALUES);
    if (error != AwaError_Success)
    {
        printf("Failed to create resource 'Reset Min and Max Measured Values'\n");
        return error;
    }
    return AwaError_Success;
}
int DefineDigitalInputObject(AwaStaticClient *awaClient)
{
    AwaError error;
    int i;

    AwaStaticClient_DefineObject(awaClient, IPSO_DIGITAL_INPUT_OBJECT, "DigitalInput", 0, DIGITAL_INPUTS);
    error = AwaStaticClient_SetObjectOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to register flow access object\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_STATE, "State", AwaResourceType_Boolean, 1, 1,
        AwaResourceOperations_ReadOnly);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_STATE, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define State resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_COUNTER, "Counter", AwaResourceType_Integer, 0, 1,
        AwaResourceOperations_ReadOnly);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_COUNTER, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define Counter resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_POLARITY, "Polarity", AwaResourceType_Boolean, 0, 1,
        AwaResourceOperations_ReadWrite);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_POLARITY, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define Polarity resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_DEBOUNCE_PERIOD, "DebouncePeriod", AwaResourceType_Time, 0, 1,
        AwaResourceOperations_ReadWrite);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_DEBOUNCE_PERIOD, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define DebouncePeriod resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_EDGE_SELECTION, "EdgeSelection", AwaResourceType_Integer, 0, 1,
        AwaResourceOperations_ReadWrite);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_EDGE_SELECTION, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define EdgeSelection resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_APPLICATION_TYPE, "ApplicationType", AwaResourceType_String, 0, 1,
        AwaResourceOperations_ReadOnly);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_APPLICATION_TYPE, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define ApplicationType resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_SENSOR_TYPE, "SensorType", AwaResourceType_String, 0, 1,
        AwaResourceOperations_ReadOnly);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT , IPSO_SENSOR_TYPE, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define SensorType resource\n");
        return 1;
    }

    AwaStaticClient_DefineResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, IPSO_DIGITAL_INPUT_COUNTER_RESET, "CounterReset", AwaResourceType_Opaque, 0, 1,
        AwaResourceOperations_Execute);
    error = AwaStaticClient_SetResourceOperationHandler(awaClient, IPSO_DIGITAL_INPUT_OBJECT , IPSO_DIGITAL_INPUT_COUNTER_RESET, digitalInputHandler);
    if (error != AwaError_Success)
    {
        printf("Failed to define CounterReset resource\n");
        return 1;
    }

    for (i = 0; i < DIGITAL_INPUTS; i++)
    {
        AwaStaticClient_CreateObjectInstance(awaClient, IPSO_DIGITAL_INPUT_OBJECT, i);
        AwaStaticClient_CreateResource(awaClient, IPSO_DIGITAL_INPUT_OBJECT, i, IPSO_DIGITAL_INPUT_COUNTER);
    }
    return 0;
}