зеркало из https://github.com/Azure/azure-umqtt-c.git
Update umqtt to use the new runtime configurable logging functions
This commit is contained in:
Родитель
a73f93c707
Коммит
4f62bb9b73
|
@ -1 +1 @@
|
|||
Subproject commit 6a643221b9abe4499b53f917a7e448f73a3014b9
|
||||
Subproject commit 2f473952921b9c4eb52a5debed6302efbe8587ec
|
|
@ -25,7 +25,7 @@ DEFINE_ENUM(MQTT_CLIENT_ACTION_RESULT, MQTT_CLIENT_ACTION_VALUES);
|
|||
typedef void(*ON_MQTT_OPERATION_CALLBACK)(MQTT_CLIENT_ACTION_RESULT actionResult, const void* msgInfo, void* callbackCtx);
|
||||
typedef void(*ON_MQTT_MESSAGE_RECV_CALLBACK)(MQTT_MESSAGE_HANDLE msgHandle, void* callbackCtx);
|
||||
|
||||
extern MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx, LOGGER_LOG logger);
|
||||
extern MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx);
|
||||
extern void mqtt_client_deinit(MQTT_CLIENT_HANDLE handle);
|
||||
|
||||
extern int mqtt_client_connect(MQTT_CLIENT_HANDLE handle, XIO_HANDLE ioHandle, MQTT_CLIENT_OPTIONS* mqttOptions);
|
||||
|
@ -41,7 +41,7 @@ extern void mqtt_client_dowork(MQTT_CLIENT_HANDLE handle);
|
|||
|
||||
##mqtt_client_init
|
||||
```
|
||||
extern MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx, LOGGER_LOG logger)
|
||||
extern MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx)
|
||||
```
|
||||
**SRS_MQTT_CLIENT_07_001: [**If the parameters ON_MQTT_MESSAGE_RECV_CALLBACK is NULL then mqttclient_init shall return NULL.**]**
|
||||
**SRS_MQTT_CLIENT_07_002: [**If any failure is encountered then mqttclient_init shall return NULL.**]**
|
||||
|
|
|
@ -12,7 +12,6 @@ extern "C" {
|
|||
#endif // __cplusplus
|
||||
|
||||
#include "azure_c_shared_utility/xio.h"
|
||||
#include "azure_c_shared_utility/xlogging.h"
|
||||
#include "azure_c_shared_utility/macro_utils.h"
|
||||
#include "azure_c_shared_utility/list.h"
|
||||
#include "azure_umqtt_c/mqttconst.h"
|
||||
|
@ -37,7 +36,7 @@ DEFINE_ENUM(MQTT_CLIENT_EVENT_RESULT, MQTT_CLIENT_EVENT_VALUES);
|
|||
typedef void(*ON_MQTT_OPERATION_CALLBACK)(MQTT_CLIENT_HANDLE handle, MQTT_CLIENT_EVENT_RESULT actionResult, const void* msgInfo, void* callbackCtx);
|
||||
typedef void(*ON_MQTT_MESSAGE_RECV_CALLBACK)(MQTT_MESSAGE_HANDLE msgHandle, void* callbackCtx);
|
||||
|
||||
extern MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx, LOGGER_LOG logger);
|
||||
extern MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx);
|
||||
extern void mqtt_client_deinit(MQTT_CLIENT_HANDLE handle);
|
||||
|
||||
extern int mqtt_client_connect(MQTT_CLIENT_HANDLE handle, XIO_HANDLE xioHandle, MQTT_CLIENT_OPTIONS* mqttOptions);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "azure_umqtt_c/mqtt_client.h"
|
||||
#include "azure_c_shared_utility/socketio.h"
|
||||
#include "azure_c_shared_utility/platform.h"
|
||||
#include "azure_c_shared_utility/xlogging.h"
|
||||
#include "azure_c_shared_utility/consolelogger.h"
|
||||
|
||||
static const char* TOPIC_NAME_A = "msgA";
|
||||
static const char* TOPIC_NAME_B = "msgB";
|
||||
|
@ -29,19 +31,6 @@ static bool g_continue = true;
|
|||
|
||||
#define DEFAULT_MSG_TO_SEND 1
|
||||
|
||||
static void PrintLogFunction(unsigned int options, char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
(void)vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
if (options & LOG_LINE)
|
||||
{
|
||||
(void)printf("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static const char* QosToString(QOS_VALUE qosValue)
|
||||
{
|
||||
switch (qosValue)
|
||||
|
@ -58,7 +47,7 @@ static void OnRecvCallback(MQTT_MESSAGE_HANDLE msgHandle, void* context)
|
|||
{
|
||||
const APP_PAYLOAD* appMsg = mqttmessage_getApplicationMsg(msgHandle);
|
||||
|
||||
PrintLogFunction(0, "Incoming Msg: Packet Id: %d\r\nQOS: %s\r\nTopic Name: %s\r\nIs Retained: %s\r\nIs Duplicate: %s\r\nApp Msg: ", mqttmessage_getPacketId(msgHandle),
|
||||
(void)printf("Incoming Msg: Packet Id: %d\r\nQOS: %s\r\nTopic Name: %s\r\nIs Retained: %s\r\nIs Duplicate: %s\r\nApp Msg: ", mqttmessage_getPacketId(msgHandle),
|
||||
QosToString(mqttmessage_getQosType(msgHandle) ),
|
||||
mqttmessage_getTopicName(msgHandle),
|
||||
mqttmessage_getIsRetained(msgHandle) ? "true" : "fale",
|
||||
|
@ -66,14 +55,15 @@ static void OnRecvCallback(MQTT_MESSAGE_HANDLE msgHandle, void* context)
|
|||
);
|
||||
for (size_t index = 0; index < appMsg->length; index++)
|
||||
{
|
||||
PrintLogFunction(0, "0x%x", appMsg->message[index]);
|
||||
(void)printf("0x%x", appMsg->message[index]);
|
||||
}
|
||||
PrintLogFunction(0, "\r\n");
|
||||
|
||||
(void)printf("\r\n");
|
||||
}
|
||||
|
||||
static void OnCloseComplete(void* context)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "%d: On Close Connection failed", __LINE__);
|
||||
(void)printf("%d: On Close Connection failed\r\n", __LINE__);
|
||||
}
|
||||
|
||||
static void OnOperationComplete(MQTT_CLIENT_HANDLE handle, MQTT_CLIENT_EVENT_RESULT actionResult, const void* msgInfo, void* callbackCtx)
|
||||
|
@ -83,7 +73,7 @@ static void OnOperationComplete(MQTT_CLIENT_HANDLE handle, MQTT_CLIENT_EVENT_RES
|
|||
{
|
||||
case MQTT_CLIENT_ON_CONNACK:
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "ConnAck function called");
|
||||
(void)printf("ConnAck function called\r\n");
|
||||
const CONNECT_ACK* connack = (CONNECT_ACK*)msgInfo;
|
||||
SUBSCRIBE_PAYLOAD subscribe[] = {
|
||||
{ TOPIC_NAME_A, DELIVER_AT_MOST_ONCE },
|
||||
|
@ -91,7 +81,7 @@ static void OnOperationComplete(MQTT_CLIENT_HANDLE handle, MQTT_CLIENT_EVENT_RES
|
|||
};
|
||||
if (mqtt_client_subscribe(handle, PACKET_ID_VALUE++, subscribe, sizeof(subscribe) / sizeof(subscribe[0])) != 0)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "%d: mqtt_client_subscribe failed", __LINE__);
|
||||
(void)printf("%d: mqtt_client_subscribe failed\r\n", __LINE__);
|
||||
g_continue = false;
|
||||
}
|
||||
break;
|
||||
|
@ -102,14 +92,14 @@ static void OnOperationComplete(MQTT_CLIENT_HANDLE handle, MQTT_CLIENT_EVENT_RES
|
|||
MQTT_MESSAGE_HANDLE msg = mqttmessage_create(PACKET_ID_VALUE++, TOPIC_NAME_A, DELIVER_EXACTLY_ONCE, APP_NAME_A, strlen(APP_NAME_A));
|
||||
if (msg == NULL)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "%d: mqttmessage_create failed", __LINE__);
|
||||
(void)printf("%d: mqttmessage_create failed\r\n", __LINE__);
|
||||
g_continue = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mqtt_client_publish(handle, msg))
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "%d: mqtt_client_publish failed", __LINE__);
|
||||
(void)printf("%d: mqtt_client_publish failed\r\n", __LINE__);
|
||||
g_continue = false;
|
||||
}
|
||||
mqttmessage_destroy(msg);
|
||||
|
@ -148,16 +138,18 @@ static void OnOperationComplete(MQTT_CLIENT_HANDLE handle, MQTT_CLIENT_EVENT_RES
|
|||
|
||||
void mqtt_client_sample_run()
|
||||
{
|
||||
xlogging_set_log_function(consolelogger_log);
|
||||
|
||||
if (platform_init() != 0)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "platform_init failed");
|
||||
(void)printf("platform_init failed\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(OnRecvCallback, OnOperationComplete, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(OnRecvCallback, OnOperationComplete, NULL);
|
||||
if (mqttHandle == NULL)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "mqtt_client_init failed");
|
||||
(void)printf("mqtt_client_init failed\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -172,16 +164,16 @@ void mqtt_client_sample_run()
|
|||
|
||||
SOCKETIO_CONFIG config = {"test.mosquitto.org", PORT_NUM_UNENCRYPTED, NULL};
|
||||
|
||||
XIO_HANDLE xio = xio_create(socketio_get_interface_description(), &config, PrintLogFunction);
|
||||
XIO_HANDLE xio = xio_create(socketio_get_interface_description(), &config);
|
||||
if (xio == NULL)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "xio_create failed");
|
||||
(void)printf("xio_create failed\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mqtt_client_connect(mqttHandle, xio, &options) != 0)
|
||||
{
|
||||
PrintLogFunction(LOG_LINE, "mqtt_client_connect failed");
|
||||
(void)printf("mqtt_client_connect failed\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "azure_c_shared_utility/platform.h"
|
||||
#include "azure_c_shared_utility/tickcounter.h"
|
||||
#include "azure_c_shared_utility/crt_abstractions.h"
|
||||
#include "azure_c_shared_utility/xlogging.h"
|
||||
|
||||
#include "azure_umqtt_c/mqtt_client.h"
|
||||
#include "azure_umqtt_c/mqtt_codec.h"
|
||||
|
@ -28,7 +29,6 @@ typedef struct MQTT_CLIENT_TAG
|
|||
XIO_HANDLE xioHandle;
|
||||
MQTTCODEC_HANDLE codec_handle;
|
||||
CONTROL_PACKET_TYPE packetState;
|
||||
LOGGER_LOG logFunc;
|
||||
TICK_COUNTER_HANDLE packetTickCntr;
|
||||
uint64_t packetSendTimeMs;
|
||||
ON_MQTT_OPERATION_CALLBACK fnOperationCallback;
|
||||
|
@ -154,12 +154,13 @@ static void logOutgoingingMsgTrace(MQTT_CLIENT* clientData, const uint8_t* data,
|
|||
char tmBuffer[TIME_MAX_BUFFER];
|
||||
getLogTime(tmBuffer, TIME_MAX_BUFFER);
|
||||
|
||||
LOG(clientData->logFunc, 0, "-> %s %s: ", tmBuffer, retrievePacketType((unsigned char)data[0]));
|
||||
LOG(LOG_TRACE, 0, "-> %s %s: ", tmBuffer, retrievePacketType((unsigned char)data[0]));
|
||||
for (size_t index = 0; index < length; index++)
|
||||
{
|
||||
LOG(clientData->logFunc, 0, (char*)FORMAT_HEX_CHAR, data[index]);
|
||||
LOG(LOG_TRACE, 0, (char*)FORMAT_HEX_CHAR, data[index]);
|
||||
}
|
||||
LOG(clientData->logFunc, LOG_LINE, "");
|
||||
|
||||
LOG(LOG_TRACE, LOG_LINE, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,19 +173,20 @@ static void logIncomingMsgTrace(MQTT_CLIENT* clientData, CONTROL_PACKET_TYPE pac
|
|||
char tmBuffer[TIME_MAX_BUFFER];
|
||||
getLogTime(tmBuffer, TIME_MAX_BUFFER);
|
||||
|
||||
LOG(clientData->logFunc, 0, "<- %s %s: 0x%02x 0x%02x ", tmBuffer, retrievePacketType((unsigned char)packet), (unsigned char)(packet | flags), length);
|
||||
LOG(LOG_TRACE, 0, "<- %s %s: 0x%02x 0x%02x ", tmBuffer, retrievePacketType((unsigned char)packet), (unsigned char)(packet | flags), length);
|
||||
for (size_t index = 0; index < length; index++)
|
||||
{
|
||||
LOG(clientData->logFunc, 0, (char*)FORMAT_HEX_CHAR, data[index]);
|
||||
LOG(LOG_TRACE, 0, (char*)FORMAT_HEX_CHAR, data[index]);
|
||||
}
|
||||
LOG(clientData->logFunc, LOG_LINE, "");
|
||||
|
||||
LOG(LOG_TRACE, LOG_LINE, "");
|
||||
}
|
||||
else if (packet == PINGRESP_TYPE)
|
||||
{
|
||||
char tmBuffer[TIME_MAX_BUFFER];
|
||||
getLogTime(tmBuffer, TIME_MAX_BUFFER);
|
||||
|
||||
LOG(clientData->logFunc, LOG_LINE, "<- %s %s: 0x%02x 0x%02x ", tmBuffer, retrievePacketType((unsigned char)packet), (unsigned char)(packet | flags), length);
|
||||
LOG(LOG_TRACE, LOG_LINE, "<- %s %s: 0x%02x 0x%02x ", tmBuffer, retrievePacketType((unsigned char)packet), (unsigned char)(packet | flags), length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +198,7 @@ static int sendPacketItem(MQTT_CLIENT* clientData, const int8_t* data, size_t le
|
|||
|
||||
if (tickcounter_get_current_ms(clientData->packetTickCntr, &clientData->packetSendTimeMs) != 0)
|
||||
{
|
||||
LOG(clientData->logFunc, LOG_LINE, "Failure getting current ms tickcounter");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Failure getting current ms tickcounter");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -204,7 +206,7 @@ static int sendPacketItem(MQTT_CLIENT* clientData, const int8_t* data, size_t le
|
|||
result = xio_send(clientData->xioHandle, data, length, sendComplete, clientData);
|
||||
if (result != 0)
|
||||
{
|
||||
LOG(clientData->logFunc, LOG_LINE, "%d: Failure sending control packet data", result);
|
||||
LOG(LOG_ERROR, LOG_LINE, "%d: Failure sending control packet data", result);
|
||||
result = __LINE__;
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +227,7 @@ static void onOpenComplete(void* context, IO_OPEN_RESULT open_result)
|
|||
if (connPacket == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_007: [If any failure is encountered then mqtt_client_connect shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_codec_connect failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_codec_connect failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -233,7 +235,7 @@ static void onOpenComplete(void* context, IO_OPEN_RESULT open_result)
|
|||
if (sendPacketItem(mqttData, BUFFER_u_char(connPacket), BUFFER_length(connPacket)) != 0)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_007: [If any failure is encountered then mqtt_client_connect shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_codec_connect failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_codec_connect failed");
|
||||
}
|
||||
BUFFER_delete(connPacket);
|
||||
}
|
||||
|
@ -380,7 +382,7 @@ static void recvCompleteCallback(void* context, CONTROL_PACKET_TYPE packet, int
|
|||
MQTT_MESSAGE_HANDLE msgHandle = mqttmessage_create(packetId, topicName, qosValue, iterator, length);
|
||||
if (msgHandle == NULL)
|
||||
{
|
||||
LOG(mqttData->logFunc, LOG_LINE, "failure in mqttmessage_create");
|
||||
LOG(LOG_ERROR, LOG_LINE, "failure in mqttmessage_create");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -491,7 +493,7 @@ static void recvCompleteCallback(void* context, CONTROL_PACKET_TYPE packet, int
|
|||
}
|
||||
}
|
||||
|
||||
MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx, LOGGER_LOG logger)
|
||||
MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQTT_OPERATION_CALLBACK opCallback, void* callbackCtx)
|
||||
{
|
||||
MQTT_CLIENT* result;
|
||||
/*Codes_SRS_MQTT_CLIENT_07_001: [If the parameters ON_MQTT_MESSAGE_RECV_CALLBACK is NULL then mqttclient_init shall return NULL.]*/
|
||||
|
@ -505,14 +507,13 @@ MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQ
|
|||
if (result == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_002: [If any failure is encountered then mqttclient_init shall return NULL.]*/
|
||||
LOG(logger, LOG_LINE, "mqtt_client_inti failure: Allocation Failure");
|
||||
LOG(LOG_ERROR, LOG_LINE, "mqtt_client_init failure: Allocation Failure");
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_003: [mqttclient_init shall allocate MQTTCLIENT_DATA_INSTANCE and return the MQTTCLIENT_HANDLE on success.]*/
|
||||
result->xioHandle = NULL;
|
||||
result->packetState = UNKNOWN_TYPE;
|
||||
result->logFunc = logger;
|
||||
result->packetSendTimeMs = 0;
|
||||
result->fnOperationCallback = opCallback;
|
||||
result->fnMessageRecv = msgRecv;
|
||||
|
@ -534,7 +535,7 @@ MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQ
|
|||
if (result->packetTickCntr == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_002: [If any failure is encountered then mqttclient_init shall return NULL.]*/
|
||||
LOG(logger, LOG_LINE, "mqtt_client_init failure: tickcounter_create failure");
|
||||
LOG(LOG_ERROR, LOG_LINE, "mqtt_client_init failure: tickcounter_create failure");
|
||||
free(result);
|
||||
result = NULL;
|
||||
}
|
||||
|
@ -544,7 +545,7 @@ MQTT_CLIENT_HANDLE mqtt_client_init(ON_MQTT_MESSAGE_RECV_CALLBACK msgRecv, ON_MQ
|
|||
if (result->codec_handle == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_002: [If any failure is encountered then mqttclient_init shall return NULL.]*/
|
||||
LOG(logger, LOG_LINE, "mqtt_client_init failure: mqtt_codec_create failure");
|
||||
LOG(LOG_ERROR, LOG_LINE, "mqtt_client_init failure: mqtt_codec_create failure");
|
||||
tickcounter_destroy(result->packetTickCntr);
|
||||
free(result);
|
||||
result = NULL;
|
||||
|
@ -587,7 +588,7 @@ int mqtt_client_connect(MQTT_CLIENT_HANDLE handle, XIO_HANDLE xioHandle, MQTT_CL
|
|||
if (xioHandle == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_007: [If any failure is encountered then mqtt_client_connect shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqttcodec_connect failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqttcodec_connect failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -599,14 +600,14 @@ int mqtt_client_connect(MQTT_CLIENT_HANDLE handle, XIO_HANDLE xioHandle, MQTT_CL
|
|||
mqttData->maxPingRespTime = (DEFAULT_MAX_PING_RESPONSE_TIME < mqttOptions->keepAliveInterval/2) ? DEFAULT_MAX_PING_RESPONSE_TIME : mqttOptions->keepAliveInterval/2;
|
||||
if (cloneMqttOptions(mqttData, mqttOptions) != 0)
|
||||
{
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: Clone Mqtt Options failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: Clone Mqtt Options failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
/*Codes_SRS_MQTT_CLIENT_07_008: [mqtt_client_connect shall open the XIO_HANDLE by calling into the xio_open interface.]*/
|
||||
else if (xio_open(xioHandle, onOpenComplete, mqttData, onBytesReceived, mqttData, onIoError, mqttData) != 0)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_007: [If any failure is encountered then mqtt_client_connect shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: io_open failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: io_open failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -634,7 +635,7 @@ int mqtt_client_publish(MQTT_CLIENT_HANDLE handle, MQTT_MESSAGE_HANDLE msgHandle
|
|||
if (payload == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_020: [If any failure is encountered then mqtt_client_unsubscribe shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqttmessage_getApplicationMsg failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqttmessage_getApplicationMsg failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -644,7 +645,7 @@ int mqtt_client_publish(MQTT_CLIENT_HANDLE handle, MQTT_MESSAGE_HANDLE msgHandle
|
|||
if (publishPacket == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_020: [If any failure is encountered then mqtt_client_unsubscribe shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_codec_publish failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_codec_publish failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -655,7 +656,7 @@ int mqtt_client_publish(MQTT_CLIENT_HANDLE handle, MQTT_MESSAGE_HANDLE msgHandle
|
|||
if (sendPacketItem(mqttData, BUFFER_u_char(publishPacket), BUFFER_length(publishPacket)) != 0)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_020: [If any failure is encountered then mqtt_client_unsubscribe shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_client_publish send failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_client_publish send failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -684,7 +685,7 @@ int mqtt_client_subscribe(MQTT_CLIENT_HANDLE handle, uint16_t packetId, SUBSCRIB
|
|||
if (subPacket == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_014: [If any failure is encountered then mqtt_client_subscribe shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_codec_subscribe failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_codec_subscribe failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -695,7 +696,7 @@ int mqtt_client_subscribe(MQTT_CLIENT_HANDLE handle, uint16_t packetId, SUBSCRIB
|
|||
if (sendPacketItem(mqttData, BUFFER_u_char(subPacket), BUFFER_length(subPacket)) != 0)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_014: [If any failure is encountered then mqtt_client_subscribe shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_client_subscribe send failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_client_subscribe send failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -723,7 +724,7 @@ int mqtt_client_unsubscribe(MQTT_CLIENT_HANDLE handle, uint16_t packetId, const
|
|||
if (unsubPacket == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_017: [If any failure is encountered then mqtt_client_unsubscribe shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_codec_unsubscribe failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_codec_unsubscribe failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -731,11 +732,11 @@ int mqtt_client_unsubscribe(MQTT_CLIENT_HANDLE handle, uint16_t packetId, const
|
|||
mqttData->packetState = UNSUBSCRIBE_TYPE;
|
||||
|
||||
/*Codes_SRS_MQTT_CLIENT_07_018: [On success mqtt_client_unsubscribe shall send the MQTT SUBCRIBE packet to the endpoint.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "MQTT unsubscribe");
|
||||
LOG(LOG_ERROR, LOG_LINE, "MQTT unsubscribe");
|
||||
if (sendPacketItem(mqttData, BUFFER_u_char(unsubPacket), BUFFER_length(unsubPacket)) != 0)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_017: [If any failure is encountered then mqtt_client_unsubscribe shall return a non-zero value.].]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_client_unsubscribe send failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_client_unsubscribe send failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -764,7 +765,7 @@ int mqtt_client_disconnect(MQTT_CLIENT_HANDLE handle)
|
|||
if (disconnectPacket == NULL)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_011: [If any failure is encountered then mqtt_client_disconnect shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_client_disconnect failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_client_disconnect failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -775,7 +776,7 @@ int mqtt_client_disconnect(MQTT_CLIENT_HANDLE handle)
|
|||
if (sendPacketItem(mqttData, BUFFER_u_char(disconnectPacket), BUFFER_length(disconnectPacket)) != 0)
|
||||
{
|
||||
/*Codes_SRS_MQTT_CLIENT_07_011: [If any failure is encountered then mqtt_client_disconnect shall return a non-zero value.]*/
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: mqtt_client_disconnect send failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: mqtt_client_disconnect send failed");
|
||||
result = __LINE__;
|
||||
}
|
||||
else
|
||||
|
@ -803,7 +804,7 @@ void mqtt_client_dowork(MQTT_CLIENT_HANDLE handle)
|
|||
uint64_t current_ms;
|
||||
if (tickcounter_get_current_ms(mqttData->packetTickCntr, ¤t_ms) != 0)
|
||||
{
|
||||
LOG(mqttData->logFunc, LOG_LINE, "Error: tickcounter_get_current_ms failed");
|
||||
LOG(LOG_ERROR, LOG_LINE, "Error: tickcounter_get_current_ms failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -202,12 +202,6 @@ TEST_FUNCTION_CLEANUP(method_cleanup)
|
|||
TEST_MUTEX_RELEASE(test_serialize_mutex);
|
||||
}
|
||||
|
||||
static void PrintLogFunction(unsigned int options, char* format, ...)
|
||||
{
|
||||
(void)options;
|
||||
(void)format;
|
||||
}
|
||||
|
||||
static void TestRecvCallback(MQTT_MESSAGE_HANDLE msgHandle, void* context)
|
||||
{
|
||||
(void)msgHandle;
|
||||
|
@ -340,7 +334,7 @@ TEST_FUNCTION(mqtt_client_init_succeeds)
|
|||
EXPECTED_CALL(mqtt_codec_create(IGNORED_PTR_ARG, IGNORED_PTR_ARG));
|
||||
|
||||
// act
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NOT_NULL(result);
|
||||
|
@ -359,7 +353,7 @@ TEST_FUNCTION(mqtt_client_init_mqtt_tickcounter_create_NULL_fail)
|
|||
EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
|
||||
|
||||
// act
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(result);
|
||||
|
@ -379,7 +373,7 @@ TEST_FUNCTION(mqtt_client_init_mqtt_codec_create_NULL_fail)
|
|||
EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
|
||||
|
||||
// act
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(result);
|
||||
|
@ -394,7 +388,7 @@ TEST_FUNCTION(mqtt_client_init_ON_MQTT_MESSAGE_RECV_CALLBACK_NULL_fails)
|
|||
// arrange
|
||||
|
||||
// act
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(NULL, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE result = mqtt_client_init(NULL, TestOpCallback, NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(result);
|
||||
|
@ -417,7 +411,7 @@ TEST_FUNCTION(mqtt_client_deinit_succeeds)
|
|||
// arrange
|
||||
MQTT_CLIENT_OPTIONS mqttOptions = { 0 };
|
||||
SetupMqttLibOptions(&mqttOptions, TEST_CLIENT_ID, NULL, NULL, TEST_USERNAME, TEST_PASSWORD, TEST_KEEP_ALIVE_INTERVAL, false, true, DELIVER_AT_MOST_ONCE);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
|
@ -456,7 +450,7 @@ TEST_FUNCTION(mqtt_client_connect_MQTT_CLIENT_HANDLE_NULL_fails)
|
|||
TEST_FUNCTION(mqtt_client_connect_XIO_HANDLE_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -478,7 +472,7 @@ TEST_FUNCTION(mqtt_client_connect_XIO_HANDLE_NULL_fails)
|
|||
TEST_FUNCTION(mqtt_client_connect_MQTT_CLIENT_OPTIONS_NULL_fails)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -498,7 +492,7 @@ TEST_FUNCTION(mqtt_client_connect_MQTT_CLIENT_OPTIONS_NULL_fails)
|
|||
TEST_FUNCTION(mqtt_client_connect_xio_open_fails)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -532,7 +526,7 @@ TEST_FUNCTION(mqtt_client_connect_xio_open_fails)
|
|||
TEST_FUNCTION(mqtt_client_connect_mqtt_codec_connect_fails)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -568,7 +562,7 @@ TEST_FUNCTION(mqtt_client_connect_mqtt_codec_connect_fails)
|
|||
TEST_FUNCTION(mqtt_client_connect_xio_send_fails)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -610,7 +604,7 @@ TEST_FUNCTION(mqtt_client_connect_xio_send_fails)
|
|||
TEST_FUNCTION(mqtt_client_connect_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -651,7 +645,7 @@ TEST_FUNCTION(mqtt_client_connect_succeeds)
|
|||
TEST_FUNCTION(mqtt_client_connect_multiple_completes_one_connect_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -709,7 +703,7 @@ TEST_FUNCTION(mqtt_client_subscribe_handle_NULL_fail)
|
|||
TEST_FUNCTION(mqtt_client_subscribe_subscribeList_NULL_fail)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -731,7 +725,7 @@ TEST_FUNCTION(mqtt_client_subscribe_subscribeList_NULL_fail)
|
|||
TEST_FUNCTION(mqtt_client_subscribe_count_0_fail)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// Arrange
|
||||
|
@ -753,7 +747,7 @@ TEST_FUNCTION(mqtt_client_subscribe_count_0_fail)
|
|||
TEST_FUNCTION(mqtt_client_subscribe_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqtt_codec_subscribe(TEST_PACKET_ID, TEST_SUBSCRIBE_PAYLOAD, 2));
|
||||
|
@ -793,7 +787,7 @@ TEST_FUNCTION(mqtt_client_unsubscribe_handle_NULL_fails)
|
|||
TEST_FUNCTION(mqtt_client_unsubscribe_unsubscribeList_NULL_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -811,7 +805,7 @@ TEST_FUNCTION(mqtt_client_unsubscribe_unsubscribeList_NULL_succeeds)
|
|||
TEST_FUNCTION(mqtt_client_unsubscribe_count_0_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -829,7 +823,7 @@ TEST_FUNCTION(mqtt_client_unsubscribe_count_0_succeeds)
|
|||
TEST_FUNCTION(mqtt_client_unsubscribe_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqtt_codec_unsubscribe(TEST_PACKET_ID, TEST_UNSUBSCRIPTION_TOPIC, 2));
|
||||
|
@ -867,7 +861,7 @@ TEST_FUNCTION(mqtt_client_publish_handle_NULL_fail)
|
|||
TEST_FUNCTION(mqtt_client_publish_MQTT_MESSAGE_HANDLE_NULL_fail)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -884,7 +878,7 @@ TEST_FUNCTION(mqtt_client_publish_MQTT_MESSAGE_HANDLE_NULL_fail)
|
|||
TEST_FUNCTION(mqtt_client_publish_getApplicationMsg_fail)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqttmessage_getApplicationMsg(TEST_MESSAGE_HANDLE)).SetReturn((const APP_PAYLOAD*)NULL);
|
||||
|
@ -903,7 +897,7 @@ TEST_FUNCTION(mqtt_client_publish_getApplicationMsg_fail)
|
|||
TEST_FUNCTION(mqtt_client_publish_mqtt_codec_publish_fail)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqttmessage_getApplicationMsg(TEST_MESSAGE_HANDLE));
|
||||
|
@ -930,7 +924,7 @@ TEST_FUNCTION(mqtt_client_publish_mqtt_codec_publish_fail)
|
|||
TEST_FUNCTION(mqtt_client_publish_xio_send_fails)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqttmessage_getApplicationMsg(TEST_MESSAGE_HANDLE));
|
||||
|
@ -960,7 +954,7 @@ TEST_FUNCTION(mqtt_client_publish_xio_send_fails)
|
|||
TEST_FUNCTION(mqtt_client_publish_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqttmessage_getApplicationMsg(TEST_MESSAGE_HANDLE));
|
||||
|
@ -1004,7 +998,7 @@ TEST_FUNCTION(mqtt_client_disconnect_handle_NULL_fail)
|
|||
TEST_FUNCTION(mqtt_client_disconnect_mqtt_codec_NULL_fail)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
EXPECTED_CALL(mqtt_codec_disconnect()).SetReturn((BUFFER_HANDLE)NULL);
|
||||
|
@ -1023,7 +1017,7 @@ TEST_FUNCTION(mqtt_client_disconnect_mqtt_codec_NULL_fail)
|
|||
TEST_FUNCTION(mqtt_client_disconnect_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
STRICT_EXPECTED_CALL(mqtt_codec_disconnect());
|
||||
|
@ -1064,7 +1058,7 @@ TEST_FUNCTION(mqtt_client_dowork_ping_handle_NULL_fails)
|
|||
TEST_FUNCTION(mqtt_client_dowork_ping_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
MQTT_CLIENT_OPTIONS mqttOptions = { 0 };
|
||||
SetupMqttLibOptions(&mqttOptions, TEST_CLIENT_ID, NULL, NULL, TEST_USERNAME, TEST_PASSWORD, TEST_KEEP_ALIVE_INTERVAL, false, true, DELIVER_AT_MOST_ONCE);
|
||||
|
@ -1106,7 +1100,7 @@ TEST_FUNCTION(mqtt_client_dowork_ping_succeeds)
|
|||
TEST_FUNCTION(mqtt_client_dowork_ping_No_ping_response_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
MQTT_CLIENT_OPTIONS mqttOptions ={ 0 };
|
||||
SetupMqttLibOptions(&mqttOptions, TEST_CLIENT_ID, NULL, NULL, TEST_USERNAME, TEST_PASSWORD, TEST_KEEP_ALIVE_INTERVAL, false, true, DELIVER_AT_MOST_ONCE);
|
||||
|
@ -1148,7 +1142,7 @@ TEST_FUNCTION(mqtt_client_dowork_ping_No_ping_response_succeeds)
|
|||
TEST_FUNCTION(mqtt_client_dowork_no_keepalive_no_ping_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
MQTT_CLIENT_OPTIONS mqttOptions = { 0 };
|
||||
SetupMqttLibOptions(&mqttOptions, TEST_CLIENT_ID, NULL, NULL, TEST_USERNAME, TEST_PASSWORD, 0, false, true, DELIVER_AT_MOST_ONCE);
|
||||
|
@ -1185,7 +1179,7 @@ TEST_FUNCTION(mqtt_client_dowork_no_ping_succeeds)
|
|||
// arrange
|
||||
g_current_ms = (TEST_KEEP_ALIVE_INTERVAL-5)*1000;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
MQTT_CLIENT_OPTIONS mqttOptions = { 0 };
|
||||
SetupMqttLibOptions(&mqttOptions, TEST_CLIENT_ID, NULL, NULL, TEST_USERNAME, TEST_PASSWORD, TEST_KEEP_ALIVE_INTERVAL, false, true, DELIVER_AT_MOST_ONCE);
|
||||
|
@ -1219,7 +1213,7 @@ TEST_FUNCTION(mqtt_client_dowork_tickcounter_fails_succeeds)
|
|||
// arrange
|
||||
g_current_ms = (TEST_KEEP_ALIVE_INTERVAL - 5) * 1000;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
|
||||
MQTT_CLIENT_OPTIONS mqttOptions = { 0 };
|
||||
SetupMqttLibOptions(&mqttOptions, TEST_CLIENT_ID, NULL, NULL, TEST_USERNAME, TEST_PASSWORD, TEST_KEEP_ALIVE_INTERVAL, false, true, DELIVER_AT_MOST_ONCE);
|
||||
|
@ -1266,7 +1260,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_context_NULL_fails)
|
|||
BUFFER_HANDLE connack_handle = TEST_BUFFER_HANDLE;
|
||||
STRICT_EXPECTED_CALL(BUFFER_u_char(TEST_BUFFER_HANDLE)).SetReturn(CONNACK_RESP);
|
||||
STRICT_EXPECTED_CALL(BUFFER_length(TEST_BUFFER_HANDLE)).SetReturn(length);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -1294,7 +1288,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_BUFFER_HANDLE_NULL_fails)
|
|||
testData.actionResult = MQTT_CLIENT_ON_CONNACK;
|
||||
testData.msgInfo = &connack;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
@ -1322,7 +1316,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_CONNACK_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_CONNACK;
|
||||
testData.msgInfo = &connack;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE connack_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1350,7 +1344,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_EXACTLY_ONCE_succeeds)
|
|||
|
||||
uint8_t flag = 0x0d;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&PUBLISH_RESP, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&PUBLISH_RESP);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE publish_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1392,7 +1386,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_AT_LEAST_ONCE_succeeds)
|
|||
|
||||
uint8_t flag = 0x0a;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&PUBLISH_RESP, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&PUBLISH_RESP);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE publish_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1433,7 +1427,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_AT_MOST_ONCE_succeeds)
|
|||
|
||||
uint8_t flag = 0x00;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&PUBLISH_VALUE, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&PUBLISH_VALUE);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE publish_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1472,7 +1466,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_ACK_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_PUBLISH_ACK;
|
||||
testData.msgInfo = &puback;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1503,7 +1497,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_RECIEVE_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_PUBLISH_RECV;
|
||||
testData.msgInfo = &puback;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1540,7 +1534,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_RELEASE_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_PUBLISH_REL;
|
||||
testData.msgInfo = &puback;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1577,7 +1571,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PUBLISH_COMPLETE_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_PUBLISH_COMP;
|
||||
testData.msgInfo = &puback;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1615,7 +1609,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_SUBACK_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_SUBSCRIBE_ACK;
|
||||
testData.msgInfo = &suback;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1651,7 +1645,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_UNSUBACK_succeeds)
|
|||
testData.actionResult = MQTT_CLIENT_ON_UNSUBSCRIBE_ACK;
|
||||
testData.msgInfo = &unsuback;
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, (void*)&testData);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1675,7 +1669,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PINGRESP_succeeds)
|
|||
unsigned char PINGRESP_ACK_RESP[] = { 0x0d, 0x00 };
|
||||
size_t length = sizeof(PINGRESP_ACK_RESP) / sizeof(PINGRESP_ACK_RESP[0]);
|
||||
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
BUFFER_HANDLE packet_handle = TEST_BUFFER_HANDLE;
|
||||
|
@ -1696,7 +1690,7 @@ TEST_FUNCTION(mqtt_client_recvCompleteCallback_PINGRESP_succeeds)
|
|||
TEST_FUNCTION(mqtt_client_set_trace_succeeds)
|
||||
{
|
||||
// arrange
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL, PrintLogFunction);
|
||||
MQTT_CLIENT_HANDLE mqttHandle = mqtt_client_init(TestRecvCallback, TestOpCallback, NULL);
|
||||
umock_c_reset_all_calls();
|
||||
|
||||
// act
|
||||
|
|
Загрузка…
Ссылка в новой задаче