зеркало из https://github.com/Azure/azure-umqtt-c.git
Update mqtt repo with initial files
This commit is contained in:
Родитель
b1f3d20567
Коммит
c871cf9c0c
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Microsoft Azure IoT SDKs
|
||||
Microsoft Azure Mqtt Client
|
||||
Copyright (c) Microsoft Corporation
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
@ -21,17 +21,17 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|||
if(WIN32)
|
||||
get_filename_component(REPO_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
|
||||
get_filename_component(REPO_DIR ${REPO_DIR} DIRECTORY)
|
||||
|
||||
|
||||
set(SHARED_UTIL_INC_FOLDER ${REPO_DIR}/azure-c-shared-utility/c/inc)
|
||||
set(SHARED_UTIL_SRC_FOLDER ${REPO_DIR}/azure-c-shared-utility/c/src)
|
||||
set(SHARED_UTIL_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32")
|
||||
set(MICROMOCK_UNITTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/micromock/")
|
||||
set(CTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/ctest/")
|
||||
set(SHARED_UTIL_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32")
|
||||
set(MICROMOCK_UNITTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/micromock/")
|
||||
set(CTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/ctest/")
|
||||
else()
|
||||
set(SHARED_UTIL_INC_FOLDER /usr/include/azuresharedutil)
|
||||
set(SHARED_UTIL_LIB_DIR "/usr/lib")
|
||||
#set(MICROMOCK_UNITTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/micromock/")
|
||||
#set(CTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/ctest/")
|
||||
set(SHARED_UTIL_LIB_DIR "/usr/lib")
|
||||
#set(MICROMOCK_UNITTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/micromock/")
|
||||
#set(CTEST_LIB_DIR "$ENV{USERPROFILE}/shared-util_Win32/testtools/ctest/")
|
||||
endif(WIN32)
|
||||
|
||||
enable_testing()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
##Overview
|
||||
|
||||
Mqtt_Client is the library that encapsulates the mqtt protocol
|
||||
Mqtt_Client is the library that encapsulates the [MQTT Protocol](http://mqtt.org/documentation)
|
||||
|
||||
##Exposed API
|
||||
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef CONNECT_PACKET_H
|
||||
#define CONNECT_PACKET_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include <cstddef>
|
||||
extern "C" {
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "xio.h"
|
||||
#include "mqttconst.h"
|
||||
#include "buffer_.h"
|
||||
|
||||
|
@ -32,7 +31,6 @@ extern int ctrlpacket_unsubscribe(CTRL_PACKET_IO_SEND ioSendFn, void* callContex
|
|||
extern int ctrlpacket_ping(CTRL_PACKET_IO_SEND ioSendFn, void* callContext);
|
||||
|
||||
extern CONTROL_PACKET_TYPE ctrlpacket_processControlPacketType(BYTE pktByte, int* flags);
|
||||
extern int ctrlpacket_processVariableHeader(CONTROL_PACKET_TYPE type, BUFFER_HANDLE packetData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "mqttconst.h"
|
||||
|
||||
|
@ -23,6 +23,6 @@ extern void byteutil_writeUTF(char** buffer, const char* stringData, size_t len)
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // DATA_BYTE_UTIL_H
|
||||
|
|
|
@ -37,7 +37,6 @@ extern int mqttclient_subscribe(MQTTCLIENT_HANDLE handle, BYTE packetId, const c
|
|||
extern int mqttclient_unsubscribe(MQTTCLIENT_HANDLE handle, BYTE packetId, const char* unsubscribeTopic, QOS_VALUE qosValue);
|
||||
|
||||
extern int mqttclient_publish(MQTTCLIENT_HANDLE handle, MQTT_MESSAGE_HANDLE msgHandle);
|
||||
|
||||
extern void mqttclient_dowork(MQTTCLIENT_HANDLE handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef MQTT_CODEC_H
|
||||
#define MQTT_CODEC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "xio.h"
|
||||
#include "mqttconst.h"
|
||||
#include "buffer_.h"
|
||||
|
||||
|
@ -26,6 +25,6 @@ extern int mqttcodec_bytesReceived(MQTTCODEC_HANDLE handle, const void* buffer,
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // MQTT_CODEC_H
|
||||
|
|
|
@ -4,16 +4,12 @@
|
|||
#ifndef MQTT_MESSAGE_H
|
||||
#define MQTT_MESSAGE_H
|
||||
|
||||
#include "macro_utils.h"
|
||||
#include "map.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "mqttconst.h"
|
||||
|
||||
|
@ -32,6 +28,6 @@ extern const BYTE* mqttmsg_applicationMsg(MQTT_MESSAGE_HANDLE handle);
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // MQTT_MESSAGE_H
|
|
@ -32,7 +32,8 @@ typedef enum QOS_VALUE_TAG
|
|||
{
|
||||
DELIVER_AT_MOST_ONCE = 0x00,
|
||||
DELIVER_AT_LEAST_ONCE = 0x01,
|
||||
DELIVER_EXACTLY_ONCE = 0x02
|
||||
DELIVER_EXACTLY_ONCE = 0x02,
|
||||
DELIVER_FAILURE = 0x80
|
||||
} QOS_VALUE;
|
||||
|
||||
typedef struct MQTTCLIENT_OPTIONS_TAG
|
||||
|
@ -65,4 +66,10 @@ typedef struct CONNECT_ACK_TAG
|
|||
CONNECT_RETURN_CODE returnCode;
|
||||
} CONNECT_ACK;
|
||||
|
||||
typedef struct SUBSCRIBE_ACK_TAG
|
||||
{
|
||||
BYTE packetId;
|
||||
QOS_VALUE qosReturn;
|
||||
} SUBSCRIBE_ACK;
|
||||
|
||||
#endif // MQTTCONST_H
|
|
@ -6,23 +6,23 @@
|
|||
compileAsC11()
|
||||
|
||||
set(mqtt_client_sample_c_files
|
||||
mqtt_client_sample.c
|
||||
mqtt_client_sample.c
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(mqtt_client_sample_c_files ${mqtt_client_sample_c_files} ./windows/main.c)
|
||||
set(mqtt_client_sample_c_files ${mqtt_client_sample_c_files} ./windows/main.c)
|
||||
else()
|
||||
set(mqtt_client_sample_c_files ${mqtt_client_sample_c_files} ./linux/main.c)
|
||||
set(mqtt_client_sample_c_files ${mqtt_client_sample_c_files} ./linux/main.c)
|
||||
endif()
|
||||
|
||||
set(mqtt_client_sample_h_files
|
||||
mqtt_client_sample.h
|
||||
mqtt_client_sample.h
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
#windows needs this define
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC)
|
||||
#windows needs this define
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC)
|
||||
ENDIF(WIN32)
|
||||
|
||||
include_directories(.)
|
||||
|
@ -30,23 +30,23 @@ include_directories(.)
|
|||
add_executable(mqtt_client_sample ${mqtt_client_sample_c_files} ${mqtt_client_sample_h_files})
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(mqtt_client_sample
|
||||
azuremqtt
|
||||
${SHARED_UTIL_LIB_DIR}/Debug/aziotsharedutil.lib
|
||||
secur32
|
||||
ws2_32)
|
||||
if(${tls_openssl})
|
||||
target_link_libraries(mqtt_client_sample $ENV{OpenSSLDir}/lib/ssleay32.lib $ENV{OpenSSLDir}/lib/libeay32.lib)
|
||||
file(COPY $ENV{OpenSSLDir}/bin/libeay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug)
|
||||
file(COPY $ENV{OpenSSLDir}/bin/ssleay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug)
|
||||
endif()
|
||||
target_link_libraries(mqtt_client_sample
|
||||
azuremqtt
|
||||
${SHARED_UTIL_LIB_DIR}/Debug/aziotsharedutil.lib
|
||||
secur32
|
||||
ws2_32)
|
||||
if(${tls_openssl})
|
||||
target_link_libraries(mqtt_client_sample $ENV{OpenSSLDir}/lib/ssleay32.lib $ENV{OpenSSLDir}/lib/libeay32.lib)
|
||||
file(COPY $ENV{OpenSSLDir}/bin/libeay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug)
|
||||
file(COPY $ENV{OpenSSLDir}/bin/ssleay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(mqtt_client_sample
|
||||
pthread
|
||||
azuremqtt
|
||||
aziotsharedutil)
|
||||
#if(${tls_openssl})
|
||||
target_link_libraries(mqtt_client_sample ssl crypto)
|
||||
#endif()
|
||||
target_link_libraries(mqtt_client_sample
|
||||
pthread
|
||||
azuremqtt
|
||||
aziotsharedutil)
|
||||
#if(${tls_openssl})
|
||||
target_link_libraries(mqtt_client_sample ssl crypto)
|
||||
#endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ static int OnOperationComplete(MQTTCLIENT_ACTION_RESULT actionResult, void* cont
|
|||
|
||||
void mqtt_client_sample_run()
|
||||
{
|
||||
|
||||
#ifdef _CRT_DBG_MAP_ALLOC
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
|
||||
#ifndef MQTT_CLIENT_SAMPLE_H
|
||||
#define MQTT_CLIENT_SAMPLE_H
|
||||
|
||||
|
|
|
@ -10,4 +10,29 @@
|
|||
#include "control_packet.h"
|
||||
#include "data_byte_util.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "gballoc.h"
|
||||
#include "tickcounter.h"
|
||||
|
||||
#define KEEP_ALIVE_BUFFER_SEC 2
|
||||
#define VARIABLE_HEADER_OFFSET 2
|
||||
#define RETAIN_FLAG_MASK 0x1
|
||||
#define QOS_LEAST_ONCE_FLAG_MASK 0x2
|
||||
#define QOS_EXACTLY_ONCE_FLAG_MASK 0x4
|
||||
#define DUPLICATE_FLAG_MASK 0x8
|
||||
|
||||
typedef struct MQTTCLIENT_DATA_INSTANCE_TAG
|
||||
{
|
||||
XIO_HANDLE ioHandle;
|
||||
MQTTCODEC_HANDLE codec_handle;
|
||||
CONTROL_PACKET_TYPE packetState;
|
||||
LOGGER_LOG logFunc;
|
||||
TICK_COUNTER_HANDLE packetTickCntr;
|
||||
uint64_t packetSendTimeMs;
|
||||
ON_MQTT_OPERATION_CALLBACK fnOperationCallback;
|
||||
ON_MQTT_MESSAGE_RECV_CALLBACK fnMessageRecv;
|
||||
void* ctx;
|
||||
QOS_VALUE qosValue;
|
||||
int keepAliveInterval;
|
||||
} MQTTCLIENT_DATA_INSTANCE;
|
||||
|
||||
|
|
|
@ -1,2 +1,9 @@
|
|||
# Microsoft Azure MQTT
|
||||
|
||||
azure-mqtt is a general purpose library build for MQTT protocol
|
||||
|
||||
## Dependencies
|
||||
|
||||
azure-mqtt client use the azure-c-shared-utility, which is a C library provising common functionality for basic tasks (like string, list manipulation, IO, etc.).
|
||||
azure-c-shared-utility is available here: https://github.com/Azure/azure-c-shared-utility.
|
||||
azure-c-shared-utility needs to be built before building uAMQP.
|
||||
|
|
Загрузка…
Ссылка в новой задаче