static int ProcessExecuteOperation(const AwaServerSession * session, AwaServerExecuteOperation * operation, const char * clientID) { int result = 0; if (AwaServerExecuteOperation_Perform(operation, OPERATION_PERFORM_TIMEOUT) != AwaError_Success) { Error("AwaServerExecuteOperation_Perform failed\n"); result = 1; } const AwaServerExecuteResponse * response = AwaServerExecuteOperation_GetResponse(operation, clientID); if (response != NULL) { AwaPathIterator * pathIterator = AwaServerExecuteResponse_NewPathIterator(response); if (pathIterator != NULL) { while (AwaPathIterator_Next(pathIterator)) { const char * path = AwaPathIterator_Get(pathIterator); const AwaPathResult * result = AwaServerExecuteResponse_GetPathResult(response, path); AwaError error = AwaPathResult_GetError(result); if (error == AwaError_Success) { printf("Target %s executed successfully\n", path); } else { if (error != AwaError_LWM2MError) { Error("Failed to execute target %s: %s\n", path, AwaError_ToString(error)); } else { Error("Failed to execute target %s: %s\n", path, AwaLWM2MError_ToString(AwaPathResult_GetLWM2MError(result))); } } } AwaPathIterator_Free(&pathIterator); } else { Error("AwaServerExecuteResponse_NewPathIterator returned NULL"); } } else { Error("AwaServerExecuteOperation_GetResponse returned NULL"); } return result; }
static int ProcessWriteOperation(AwaServerWriteOperation * operation, const char * clientID) { int result = 0; if (AwaServerWriteOperation_Perform(operation, clientID, OPERATION_PERFORM_TIMEOUT) != AwaError_Success) { Error("AwaServerWriteOperation_Perform failed\n"); result = 1; } else { Verbose("Write operation completed successfully.\n"); } const AwaServerWriteResponse * response = AwaServerWriteOperation_GetResponse(operation, clientID); if (response != NULL) { AwaPathIterator * iterator = AwaServerWriteResponse_NewPathIterator(response); while (AwaPathIterator_Next(iterator)) { const char * path = AwaPathIterator_Get(iterator); const AwaPathResult * result = AwaServerWriteResponse_GetPathResult(response, path); AwaError error = AwaPathResult_GetError(result); if (error != AwaError_Success) { if (error != AwaError_LWM2MError) { Error("Failed to write to path %s: %s\n", path, AwaError_ToString(error)); } else { Error("Failed to write to path %s: %s\n", path, AwaLWM2MError_ToString(AwaPathResult_GetLWM2MError(result))); } } } AwaPathIterator_Free(&iterator); } return result; }