Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #553 (NETMF solution not compiling) #738

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[submodule "c/parson"]
path = c/parson
url = https://github.com/kgabis/parson
[submodule "c/iothub_service_client/parson"]
path = c/iothub_service_client/parson
[submodule "c/service/iothub_service_client/parson"]
path = c/service/iothub_service_client/parson
url = https://github.com/kgabis/parson
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion build/linux_slow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ c/build_all/linux/build.sh --run-e2e-tests #-x
[ $? -eq 0 ] || exit $?

# -- Node.js --
jenkins/linux_node.sh
build/linux_node.sh
[ $? -eq 0 ] || exit $?
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion jenkins/windowsce_c.cmd → build/windowsce_c.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ for %%i in ("%build-root%") do set build-root=%%~fi

REM -- C --
cd %build-root%\c\build_all\windowsce
call build.cmd
call build.cmd --run-e2e-tests
if errorlevel 1 goto :eof
cd %build-root%
2 changes: 1 addition & 1 deletion c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ else()
set(THREAD_C_FILE ${SHARED_UTIL_ADAPTER_FOLDER}/threadapi_pthreads.c)
endif()

add_subdirectory(iothub_service_client)
add_subdirectory(service)

if(${run_e2e_tests} OR ${run_longhaul_tests})
add_subdirectory(testtools)
Expand Down
16 changes: 15 additions & 1 deletion c/build_all/windowsce/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,23 @@ cmake -DWINCE=TRUE -DCMAKE_SYSTEM_NAME=WindowsCE -DCMAKE_SYSTEM_VERSION=8.0 -DCM

if not %errorlevel%==0 exit /b %errorlevel%

rem Currently, only building of HTTP sample is supported
rem Currently only building of HTTP sample is supported
msbuild "%USERPROFILE%\cmake_ce8\iothub_client\samples\iothub_client_sample_http\iothub_client_sample_http.vcxproj
if not %errorlevel%==0 exit /b %errorlevel%

rem -- Copy all libraries to the repo directory to be able to build solutions
xcopy /q /y /R "%USERPROFILE%\cmake_ce8\iothub_client\Debug\*.*" "%build-root%\build_output\c\wec2013\debug\*.*"
if %errorlevel% neq 0 exit /b %errorlevel%

xcopy /q /y /R "%USERPROFILE%\cmake_ce8\common\Debug\*.*" "%build-root%\build_output\c\wec2013\debug\*.*"
if %errorlevel% neq 0 exit /b %errorlevel%

xcopy /q /y /R "%USERPROFILE%\cmake_ce8\serializer\Debug\*.*" "%build-root%\build_output\c\wec2013\debug\*.*"
if %errorlevel% neq 0 exit /b %errorlevel%

rem currently only debug binaries are built
xcopy /q /y /R "%USERPROFILE%\cmake_ce8\iothub_client\Release\*.*" "%build-root%\build_output\c\wec2013\release\*.*"
xcopy /q /y /R "%USERPROFILE%\cmake_ce8\common\Release\*.*" "%build-root%\build_output\c\wec2013\release\*.*"
xcopy /q /y /R "%USERPROFILE%\cmake_ce8\serializer\Release\*.*" "%build-root%\build_output\c\wec2013\release\*.*"


Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# IoTHubTransportAMQP Requirements



## Overview

Expand Down Expand Up @@ -231,10 +232,6 @@ The below requirements only apply when authentication type is x509:

**SRS_IOTHUBTRANSPORTAMQP_09_070: [**IoTHubTransportAMQP_DoWork shall create the AMQP message sender using messagesender_create() AMQP API**]**

**SRS_IOTHUBTRANSPORTAMQP_09_191: [**IoTHubTransportAMQP_DoWork shall create each AMQP message sender tracking its state changes with a callback function**]**

**SRS_IOTHUBTRANSPORTAMQP_09_192: [**If a message sender instance changes its state to MESSAGE_SENDER_STATE_ERROR (first transition only) the connection retry logic shall be triggered**]**

**SRS_IOTHUBTRANSPORTAMQP_09_071: [**IoTHubTransportAMQP_DoWork shall fail and return immediately if the AMQP message sender instance fails to be created, flagging the connection to be re-established**]**

**SRS_IOTHUBTRANSPORTAMQP_09_072: [**IoTHubTransportAMQP_DoWork shall open the AMQP message sender using messagesender_open() AMQP API**]**
Expand All @@ -251,10 +248,6 @@ The below requirements only apply when authentication type is x509:

**SRS_IOTHUBTRANSPORTAMQP_09_077: [**IoTHubTransportAMQP_DoWork shall create the AMQP message receiver using messagereceiver_create() AMQP API**]**

**SRS_IOTHUBTRANSPORTAMQP_09_189: [**IoTHubTransportAMQP_DoWork shall create each AMQP message receiver tracking its state changes with a callback function**]**

**SRS_IOTHUBTRANSPORTAMQP_09_190: [**If a message receiver instance changes its state to MESSAGE_RECEIVER_STATE_ERROR (first transition only) the connection retry logic shall be triggered**]**

**SRS_IOTHUBTRANSPORTAMQP_09_078: [**IoTHubTransportAMQP_DoWork shall fail and return immediately if the AMQP message receiver instance fails to be created, flagging the connection to be re-established**]**

**SRS_IOTHUBTRANSPORTAMQP_09_079: [**IoTHubTransportAMQP_DoWork shall open the AMQP message receiver using messagereceiver_open() AMQP API, passing a callback function for handling C2D incoming messages**]**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static void SendConfirmationCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result, v
{
EVENT_INSTANCE* eventInstance = (EVENT_INSTANCE*)userContextCallback;

(void)printf("Confirmation[%d] received for message tracking id = %u with result = %s\r\n", callbackCounter, (unsigned int)eventInstance->messageTrackingId, ENUM_TO_STRING(IOTHUB_CLIENT_CONFIRMATION_RESULT, result));
(void)printf("Confirmation[%d] received for message tracking id = %u with result = %s\r\n", callbackCounter, eventInstance->messageTrackingId, ENUM_TO_STRING(IOTHUB_CLIENT_CONFIRMATION_RESULT, result));

/* Some device specific action code goes here... */
callbackCounter++;
Expand Down Expand Up @@ -182,7 +182,7 @@ void iothub_client_sample_http_run(void)
messages[iterator].messageTrackingId = iterator;

propMap = IoTHubMessage_Properties(messages[iterator].messageHandle);
(void)sprintf_s(propText, sizeof(propText), "PropMsg_%u", (unsigned int)iterator);
(void)sprintf_s(propText, sizeof(propText), "PropMsg_%u", iterator);
if (Map_AddOrUpdate(propMap, "PropName", propText) != MAP_OK)
{
(void)printf("ERROR: Map_AddOrUpdate Failed!\r\n");
Expand All @@ -194,7 +194,7 @@ void iothub_client_sample_http_run(void)
}
else
{
(void)printf("IoTHubClient_LL_SendEventAsync accepted message [%u] for transmission to IoT Hub.\r\n", (unsigned int)iterator);
(void)printf("IoTHubClient_LL_SendEventAsync accepted message [%u] for transmission to IoT Hub.\r\n", iterator);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

compileAsC99()

if(NOT ${use_http})
message(FATAL_ERROR "iothub_client_sample_x509 being generated without HTTP support")
endif()

set(iothub_client_sample_x509_c_files
iothub_client_sample_x509.c
)
Expand Down
10 changes: 6 additions & 4 deletions c/iothub_client/src/iothub_client_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,11 +936,13 @@ IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetOption(IOTHUB_CLIENT_LL_HANDLE iotHubCli
(uploadToBlob_result == IOTHUB_CLIENT_ERROR) ? IOTHUB_CLIENT_ERROR :
(handleData->IoTHubTransport_SetOption(handleData->transportHandle, optionName, value) == IOTHUB_CLIENT_ERROR) ? IOTHUB_CLIENT_ERROR : IOTHUB_CLIENT_OK;

if (result != IOTHUB_CLIENT_OK)
{
LogError("underlying transport failed, returned = %s", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result));
if (result != IOTHUB_CLIENT_OK)
{
LogError("underlying transport failed, returned = %s", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result));
}
#ifndef DONT_USE_UPLOADTOBLOB
}
}
#endif
}
return result;
}
Expand Down
41 changes: 4 additions & 37 deletions c/iothub_client/src/iothubtransportamqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,21 +1085,9 @@ static void destroyEventSender(AMQP_TRANSPORT_INSTANCE* transport_state)

void on_event_sender_state_changed(void* context, MESSAGE_SENDER_STATE new_state, MESSAGE_SENDER_STATE previous_state)
{
if (context != NULL)
{
AMQP_TRANSPORT_INSTANCE* transport_state = (AMQP_TRANSPORT_INSTANCE*)context;

if (transport_state->is_trace_on)
{
LogInfo("Event sender state changed [%d->%d]", previous_state, new_state);
}

// Codes_SRS_IOTHUBTRANSPORTAMQP_09_192: [If a message sender instance changes its state to MESSAGE_SENDER_STATE_ERROR (first transition only) the connection retry logic shall be triggered]
if (new_state != previous_state && new_state == MESSAGE_SENDER_STATE_ERROR)
{
transport_state->connection_state = AMQP_MANAGEMENT_STATE_ERROR;
}
}
(void)context;
(void)new_state;
(void)previous_state;
}

static int createEventSender(AMQP_TRANSPORT_INSTANCE* transport_state)
Expand Down Expand Up @@ -1136,7 +1124,6 @@ static int createEventSender(AMQP_TRANSPORT_INSTANCE* transport_state)
attachDeviceClientTypeToLink(transport_state->sender_link);

// Codes_SRS_IOTHUBTRANSPORTAMQP_09_070: [IoTHubTransportAMQP_DoWork shall create the AMQP message sender using messagesender_create() AMQP API]
// Codes_SRS_IOTHUBTRANSPORTAMQP_09_191: [IoTHubTransportAMQP_DoWork shall create each AMQP message sender tracking its state changes with a callback function]
if ((transport_state->message_sender = messagesender_create(transport_state->sender_link, on_event_sender_state_changed, (void*)transport_state)) == NULL)
{
// Codes_SRS_IOTHUBTRANSPORTAMQP_09_071: [IoTHubTransportAMQP_DoWork shall fail and return immediately if the AMQP message sender instance fails to be created, flagging the connection to be re-established]
Expand Down Expand Up @@ -1191,25 +1178,6 @@ static int destroyMessageReceiver(AMQP_TRANSPORT_INSTANCE* transport_state)
return result;
}

void on_message_receiver_state_changed(const void* context, MESSAGE_RECEIVER_STATE new_state, MESSAGE_RECEIVER_STATE previous_state)
{
if (context != NULL)
{
AMQP_TRANSPORT_INSTANCE* transport_state = (AMQP_TRANSPORT_INSTANCE*)context;

if (transport_state->is_trace_on)
{
LogInfo("Message receiver state changed [%d->%d]", previous_state, new_state);
}

// Codes_SRS_IOTHUBTRANSPORTAMQP_09_190: [If a message_receiver instance changes its state to MESSAGE_RECEIVER_STATE_ERROR (first transition only) the connection retry logic shall be triggered]
if (new_state != previous_state && new_state == MESSAGE_RECEIVER_STATE_ERROR)
{
transport_state->connection_state = AMQP_MANAGEMENT_STATE_ERROR;
}
}
}

static int createMessageReceiver(AMQP_TRANSPORT_INSTANCE* transport_state, IOTHUB_CLIENT_LL_HANDLE iothub_client_handle)
{
int result = RESULT_FAILURE;
Expand Down Expand Up @@ -1250,8 +1218,7 @@ static int createMessageReceiver(AMQP_TRANSPORT_INSTANCE* transport_state, IOTHU
attachDeviceClientTypeToLink(transport_state->receiver_link);

// Codes_SRS_IOTHUBTRANSPORTAMQP_09_077: [IoTHubTransportAMQP_DoWork shall create the AMQP message receiver using messagereceiver_create() AMQP API]
// Codes_SRS_IOTHUBTRANSPORTAMQP_09_189: [IoTHubTransportAMQP_DoWork shall create each AMQP message_receiver tracking its state changes with a callback function]
if ((transport_state->message_receiver = messagereceiver_create(transport_state->receiver_link, on_message_receiver_state_changed, (void*)transport_state)) == NULL)
if ((transport_state->message_receiver = messagereceiver_create(transport_state->receiver_link, NULL, NULL)) == NULL)
{
// Codes_SRS_IOTHUBTRANSPORTAMQP_09_078: [IoTHubTransportAMQP_DoWork shall fail and return immediately if the AMQP message receiver instance fails to be created, flagging the connection to be re-established]
LogError("Could not allocate AMQP message receiver.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ static bool fail_STRING_construct = false;
static STRING_HANDLE test_STRING_HANDLE_EMPTY;
static STRING_HANDLE test_iotHubHostFqdn;

ON_MESSAGE_SENDER_STATE_CHANGED saved_on_message_sender_state_changed_callback;
void* saved_on_message_sender_state_changed_context;
ON_MESSAGE_RECEIVER_STATE_CHANGED saved_on_message_receiver_state_changed_callback;
void* saved_on_message_receiver_state_changed_context;

static ON_MESSAGE_RECEIVED saved_on_message_received_callback;
static const void* saved_on_message_received_context;
static BINARY_DATA* saved_message_get_body_amqp_data_binary_data;
Expand Down Expand Up @@ -652,12 +647,10 @@ TYPED_MOCK_CLASS(CIoTHubTransportAMQPMocks, CGlobalMock)

MOCK_STATIC_METHOD_2(, int, message_get_body_type, MESSAGE_HANDLE, message, MESSAGE_BODY_TYPE*, body_type)
*body_type = test_message_get_body_type;
MOCK_METHOD_END(int, 0)
MOCK_METHOD_END(int, 0)

// message_receiver.h
MOCK_STATIC_METHOD_3(, MESSAGE_RECEIVER_HANDLE, messagereceiver_create, LINK_HANDLE, link, ON_MESSAGE_RECEIVER_STATE_CHANGED, on_message_receiver_state_changed, void*, context)
saved_on_message_receiver_state_changed_callback = on_message_receiver_state_changed;
saved_on_message_receiver_state_changed_context = context;
// message_receiver.h
MOCK_STATIC_METHOD_3(, MESSAGE_RECEIVER_HANDLE, messagereceiver_create, LINK_HANDLE, link, ON_MESSAGE_RECEIVER_STATE_CHANGED, on_message_receiver_state_changed, void*, context)
MOCK_METHOD_END(MESSAGE_RECEIVER_HANDLE, 0)

MOCK_STATIC_METHOD_1(, void, messagereceiver_destroy, MESSAGE_RECEIVER_HANDLE, message_receiver)
Expand All @@ -674,8 +667,6 @@ TYPED_MOCK_CLASS(CIoTHubTransportAMQPMocks, CGlobalMock)

// message_sender.h
MOCK_STATIC_METHOD_3(, MESSAGE_SENDER_HANDLE, messagesender_create, LINK_HANDLE, link, ON_MESSAGE_SENDER_STATE_CHANGED, on_message_sender_state_changed, void*, context)
saved_on_message_sender_state_changed_callback = on_message_sender_state_changed;
saved_on_message_sender_state_changed_context = context;
MOCK_METHOD_END(MESSAGE_SENDER_HANDLE, 0)

MOCK_STATIC_METHOD_1(, void, messagesender_destroy, MESSAGE_SENDER_HANDLE, message_sender)
Expand Down Expand Up @@ -1502,10 +1493,6 @@ static void resetTestSuiteState()
saved_on_message_received_context = NULL;
saved_message_get_body_amqp_data_binary_data = NULL;
test_amqpvalue_get_string_index = 0;
saved_on_message_receiver_state_changed_callback = NULL;
saved_on_message_receiver_state_changed_context = NULL;
saved_on_message_sender_state_changed_callback = NULL;
saved_on_message_sender_state_changed_context = NULL;
}

static time_t addSecondsToTime(time_t reference_time, int seconds_to_add)
Expand Down Expand Up @@ -3158,84 +3145,6 @@ TEST_FUNCTION(AMQP_DoWork_send_one_message_succeeds)
cleanupList(config.waitingToSend);
}

// Tests_SRS_IOTHUBTRANSPORTAMQP_09_191: [IoTHubTransportAMQP_DoWork shall create each AMQP message sender tracking its state changes with a callback function]
// Tests_SRS_IOTHUBTRANSPORTAMQP_09_192: [If a message sender instance changes its state to MESSAGE_SENDER_STATE_ERROR (first transition only) the connection retry logic shall be triggered]
TEST_FUNCTION(AMQP_messagesender_ERROR_state_change_triggers_reconnection)
{
// arrange
resetTestSuiteState();

CIoTHubTransportAMQPMocks mocks;

DLIST_ENTRY wts;
BASEIMPLEMENTATION::DList_InitializeListHead(&wts);
TRANSPORT_PROVIDER* transport_interface = (TRANSPORT_PROVIDER*)AMQP_Protocol();
IOTHUB_CLIENT_CONFIG client_config = { (IOTHUB_CLIENT_TRANSPORT_PROVIDER)transport_interface,
TEST_DEVICE_ID, TEST_DEVICE_KEY, NULL, TEST_IOT_HUB_NAME, TEST_IOT_HUB_SUFFIX, TEST_PROT_GW_HOSTNAME };
IOTHUBTRANSPORT_CONFIG config = { &client_config, &wts };
time_t current_time = time(NULL);

TRANSPORT_LL_HANDLE transport = transport_interface->IoTHubTransport_Create(&config);

setupSuccessfulDoWorkAndAuthenticate(transport, mocks, current_time);

mocks.ResetAllCalls();
setExpectedCallsForConnectionDestroyUpTo(mocks, STEP_DOWORK_CREATE_CBS);
setExpectedCallsForDestroyEventSender(mocks);

// act
saved_on_message_sender_state_changed_callback(saved_on_message_sender_state_changed_context, MESSAGE_SENDER_STATE_ERROR, MESSAGE_SENDER_STATE_OPEN);

transport_interface->IoTHubTransport_DoWork(transport, TEST_IOTHUB_CLIENT_LL_HANDLE);

// assert
mocks.AssertActualAndExpectedCalls();

// cleanup
transport_interface->IoTHubTransport_Destroy(transport);
}

// Tests_SRS_IOTHUBTRANSPORTAMQP_09_189: [IoTHubTransportAMQP_DoWork shall create each AMQP message receiver tracking its state changes with a callback function]
// Tests_SRS_IOTHUBTRANSPORTAMQP_09_190: [If a message receiver instance changes its state to MESSAGE_RECEIVER_STATE_ERROR (first transition only) the connection retry logic shall be triggered]
TEST_FUNCTION(AMQP_messagereceiver_ERROR_state_change_triggers_reconnection)
{
// arrange
resetTestSuiteState();

CIoTHubTransportAMQPMocks mocks;

DLIST_ENTRY wts;
BASEIMPLEMENTATION::DList_InitializeListHead(&wts);
TRANSPORT_PROVIDER* transport_interface = (TRANSPORT_PROVIDER*)AMQP_Protocol();
IOTHUB_CLIENT_CONFIG client_config = { (IOTHUB_CLIENT_TRANSPORT_PROVIDER)transport_interface,
TEST_DEVICE_ID, TEST_DEVICE_KEY, NULL, TEST_IOT_HUB_NAME, TEST_IOT_HUB_SUFFIX, TEST_PROT_GW_HOSTNAME };
IOTHUBTRANSPORT_CONFIG config = { &client_config, &wts };
time_t current_time = time(NULL);

TRANSPORT_LL_HANDLE transport = transport_interface->IoTHubTransport_Create(&config);

transport_interface->IoTHubTransport_Subscribe(transport);
setExpectedCallsForCreateMessageReceiver(mocks);
setupSuccessfulDoWorkAndAuthenticate(transport, mocks, current_time);

mocks.ResetAllCalls();
setExpectedCallsForConnectionDestroyUpTo(mocks, STEP_DOWORK_CREATE_CBS);
setExpectedCallsForDestroyEventSender(mocks);
setExpectedCallsForDestroyMessageReceiver(mocks);

// act
saved_on_message_receiver_state_changed_callback(saved_on_message_receiver_state_changed_context, MESSAGE_RECEIVER_STATE_ERROR, MESSAGE_RECEIVER_STATE_OPEN);

transport_interface->IoTHubTransport_DoWork(transport, TEST_IOTHUB_CLIENT_LL_HANDLE);

// assert
mocks.AssertActualAndExpectedCalls();

// cleanup
transport_interface->IoTHubTransport_Destroy(transport);
}


/* Test_SRS_IOTHUBTRANSPORTAMQP_09_155: [uAMQP message properties shall be retrieved using message_get_properties.] */
/* Test_SRS_IOTHUBTRANSPORTAMQP_09_157: [The message-id property shall be read from the uAMQP message by calling properties_get_message_id.] */
/* Test_SRS_IOTHUBTRANSPORTAMQP_09_159: [The message-id value shall be retrieved from the AMQP_VALUE as char* by calling amqpvalue_get_string.] */
Expand Down
2 changes: 1 addition & 1 deletion c/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Contains libraries that provide modeling and JSON serialization capabilities on
* samples: contains the send event and receive message samples (with ports for the supported platforms).
* tests: unit tests and end-to-end tests for source code.

### /iothub_service_client
### /service

Contains libraries that enable interactions with the IoT Hub service to perform operations such as sending messages to devices and managing the device identity registry.

Expand Down
Binary file not shown.
Loading