AwaError BarometerObject_SetPressure(AwaStaticClient *awaClient, AwaFloat pressure)
{
    if (awaClient != NULL)
    {
        int objectInstanceID = 0;
        AwaError error;
        BarometerStorage.Value = pressure;
        error = AwaStaticClient_ResourceChanged(awaClient, IPSO_BAROMETER_OBJECT, objectInstanceID, IPSO_BAROMETER_SENSOR_VALUE);

        if (error == AwaError_Success && pressure < BarometerStorage.MinMeasuredValue) {
          BarometerStorage.MinMeasuredValue = pressure;
          error = AwaStaticClient_ResourceChanged(awaClient, IPSO_BAROMETER_OBJECT, objectInstanceID, IPSO_BAROMETER_MIN_MEASURED_VALUE);
        }

        if (error == AwaError_Success && pressure > BarometerStorage.MaxMeasuredValue) {
          BarometerStorage.MaxMeasuredValue = pressure;
          AwaStaticClient_ResourceChanged(awaClient, IPSO_BAROMETER_OBJECT, objectInstanceID, IPSO_BAROMETER_MAX_MEASURED_VALUE);
        }
        return error;
    }
    else
    {
        printf("Invalid arguments passed to %s", __func__);
        return AwaError_Unspecified;
    }
}
void TemperatureObject_Update(AwaStaticClient * awaClient)
{
    int index;
	for (index = 0; index < TEMPERATURE_INSTANCES; index++)
    {
		// Check if temperature changed
        AwaFloat value = temperatureInput[index].Value;
        if (temperatureObject[index].Value != value)
        {
            temperatureObject[index].Value = value;
            if (temperatureObject[index].IsInitialised)
            {
                if (value < temperatureObject[index].Min)
                    temperatureObject[index].Min = value;
                if (value > temperatureObject[index].Max)
                    temperatureObject[index].Max = value;
            }
            else
            {
                //Creator_Log(CreatorLogLevel_Info, "Temperature %d", (int)value);    // TODO - remove (note %lf doesn't work!))
                temperatureObject[index].IsInitialised = true;
                temperatureObject[index].Min = value;
                temperatureObject[index].Max = value;
            }
            //AwaStaticClient_ObjectInstanceChanged(awaClient, IPSO_TEMPERATURE_OBJECT, index); // TODO - missing from static API ?
            AwaStaticClient_ResourceChanged(awaClient, IPSO_TEMPERATURE_OBJECT, index, IPSO_SENSOR_VALUE);
        }
    }
}
static AwaResult BarometerObject_Handler(AwaStaticClient *client, AwaOperation operation, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID,
     AwaResourceID resourceID, AwaResourceInstanceID resourceInstanceID, void **dataPointer, size_t *dataSize, bool *changed)
{
    AwaResult result = AwaResult_InternalError;
    if ((objectID != IPSO_BAROMETER_OBJECT) || (objectInstanceID != 0))
    {
        printf("Incorrect object data\n");
        return result;
    }

    switch (operation)
    {
        case AwaOperation_CreateResource:
            result = AwaResult_SuccessCreated;
            break;

        case AwaOperation_Execute:
            if (resourceID == IPSO_BAROMETER_RESET_MIN_AND_MAX_MEASURED_VALUES)
            {
                BarometerStorage.MinMeasuredValue = BarometerStorage.Value;
                BarometerStorage.MaxMeasuredValue = BarometerStorage.Value;
                AwaStaticClient_ResourceChanged(client, IPSO_BAROMETER_OBJECT, objectInstanceID, IPSO_BAROMETER_MAX_MEASURED_VALUE);
                AwaStaticClient_ResourceChanged(client, IPSO_BAROMETER_OBJECT, objectInstanceID, IPSO_BAROMETER_MIN_MEASURED_VALUE);
                result = AwaResult_Success;
            }
            else
            {
                printf("\n Invalid resource ID for Barometer execute operation");
                result = AwaResult_InternalError;
            }
            break;

        default:
            printf("Barometer - unknown operation (%d)\n", operation);
            result = AwaResult_SuccessContent;
            break;
    }
    return result;
}
int DigitalInput_IncrementCounter(AwaStaticClient *awaClient, AwaObjectInstanceID objectInstanceID)
{
    if ((awaClient != NULL) && (objectInstanceID >= 0) && (objectInstanceID < DIGITAL_INPUTS))
    {
        digitalInputs[objectInstanceID].Counter += 1;
        AwaStaticClient_ResourceChanged(awaClient, IPSO_DIGITAL_INPUT_OBJECT, objectInstanceID, IPSO_DIGITAL_INPUT_COUNTER);
        return 0;
    }
    else
    {
        printf("Invalid arguments passed to %s", __func__);
        return 1;
    }
}
static AwaResult digitalInputHandler(AwaStaticClient *client, AwaOperation operation, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID,
     AwaResourceID resourceID, AwaResourceInstanceID resourceInstanceID, void **dataPointer, size_t *dataSize, bool *changed)
{
    AwaResult result = AwaResult_InternalError;
    if (!((objectID == IPSO_DIGITAL_INPUT_OBJECT) && (objectInstanceID >= 0) && (objectInstanceID < DIGITAL_INPUTS)))
    {
        printf("Incorrect object data\n");
        return result;
    }

    switch (operation)
    {
        case AwaOperation_DeleteObjectInstance:
            result = AwaResult_SuccessDeleted;
            memset(&digitalInputs[objectInstanceID], 0, sizeof(digitalInputs[objectInstanceID]));
            break;

        case AwaOperation_CreateObjectInstance:
            result = AwaResult_SuccessCreated;
            memset(&digitalInputs[objectInstanceID], 0, sizeof(digitalInputs[objectInstanceID]));
            break;

        case AwaOperation_CreateResource:
            result = AwaResult_SuccessCreated;
            break;

        case AwaOperation_Execute:
            if (resourceID == IPSO_DIGITAL_INPUT_COUNTER_RESET)
            {
                digitalInputs[objectInstanceID].Counter = 0;
                AwaStaticClient_ResourceChanged(client, IPSO_DIGITAL_INPUT_OBJECT, objectInstanceID, IPSO_DIGITAL_INPUT_COUNTER);
                result = AwaResult_Success;
            }
            else
            {
                printf("\n Invalid resource ID for DigitalInput execute operation");
                result = AwaResult_InternalError;
            }
            break;

        case AwaOperation_Read:
            result = AwaResult_SuccessContent;
            switch (resourceID)
            {
                case IPSO_DIGITAL_INPUT_STATE:
                    *dataPointer = &digitalInputs[objectInstanceID].State;
                    *dataSize = sizeof(digitalInputs[objectInstanceID].State) ;
                    break;

                case IPSO_DIGITAL_INPUT_COUNTER:
                    *dataPointer = &digitalInputs[objectInstanceID].Counter;
                    *dataSize = sizeof(digitalInputs[objectInstanceID].Counter) ;
                    break;

                case IPSO_DIGITAL_INPUT_POLARITY:
                    *dataPointer = &digitalInputs[objectInstanceID].Polarity;
                    *dataSize = sizeof(digitalInputs[objectInstanceID].Polarity) ;
                    break;

                case IPSO_DIGITAL_INPUT_DEBOUNCE_PERIOD:
                    *dataPointer = &digitalInputs[objectInstanceID].DebouncePeriod;
                    *dataSize = sizeof(digitalInputs[objectInstanceID].DebouncePeriod) ;
                    break;

                case IPSO_DIGITAL_INPUT_EDGE_SELECTION:
                    *dataPointer = &digitalInputs[objectInstanceID].EdgeSelection;
                    *dataSize = sizeof(digitalInputs[objectInstanceID].EdgeSelection) ;
                    break;

                case IPSO_APPLICATION_TYPE:
                    *dataPointer = digitalInputs[objectInstanceID].ApplicationType;
                    *dataSize = strlen(digitalInputs[objectInstanceID].ApplicationType) ;
                    break;

                case IPSO_SENSOR_TYPE:
                    *dataPointer = digitalInputs[objectInstanceID].SensorType;
                    *dataSize = strlen(digitalInputs[objectInstanceID].SensorType) ;
                    break;

                default:
                    printf("\n Invalid resource ID for DigitalInput read operation");
                    result = AwaResult_InternalError;
                    break;
            }
            break;

        case AwaOperation_Write:
            *changed = true;
            result = AwaResult_SuccessChanged;
            switch (resourceID)
            {
                case IPSO_DIGITAL_INPUT_STATE:
                    digitalInputs[objectInstanceID].State = *((AwaBoolean *)*dataPointer);
                    break;

                case IPSO_DIGITAL_INPUT_COUNTER:
                    digitalInputs[objectInstanceID].Counter = *((AwaInteger *)*dataPointer);
                    break;

                case IPSO_DIGITAL_INPUT_POLARITY:
                    digitalInputs[objectInstanceID].Polarity = *((AwaBoolean *)*dataPointer);
                    break;

                case IPSO_DIGITAL_INPUT_DEBOUNCE_PERIOD:
                    digitalInputs[objectInstanceID].DebouncePeriod = *((AwaTime *)*dataPointer);
                    break;

                case IPSO_DIGITAL_INPUT_EDGE_SELECTION:
                    digitalInputs[objectInstanceID].EdgeSelection = *((AwaInteger *)*dataPointer);
                    break;

                case IPSO_APPLICATION_TYPE:
                    if(*dataSize < sizeof(digitalInputs[objectInstanceID].ApplicationType))
                    {
                        memcpy(digitalInputs[objectInstanceID].ApplicationType, *dataPointer, *dataSize);
                        digitalInputs[objectInstanceID].ApplicationType[*dataSize] = '\0';
                    }
                    else
                    {
                        result = AwaResult_BadRequest;
                    }
                    break;

                case IPSO_SENSOR_TYPE:
                    if(*dataSize < sizeof(digitalInputs[objectInstanceID].SensorType))
                    {
                        memcpy(digitalInputs[objectInstanceID].SensorType, *dataPointer, *dataSize);
                        digitalInputs[objectInstanceID].SensorType[*dataSize] = '\0';
                    }
                    else
                    {
                        result = AwaResult_BadRequest;
                    }
                    break;

                default:
                    printf("\n Invalid resource ID for DigitalInput write operation");
                    result = AwaResult_InternalError;
                    break;
            }
            break;
        default:
            printf("DigitalInput - unknown operation\n");
            break;
    }
    return result;
}