Xin Zhang / azure-iot-c-sdk-f767zi

Dependents:   samplemqtt

Committer:
XinZhangMS
Date:
Thu Aug 23 06:52:14 2018 +0000
Revision:
0:f7f1f0d76dd6
azure-c-sdk for mbed os supporting NUCLEO_F767ZI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
XinZhangMS 0:f7f1f0d76dd6 1 // Copyright (c) Microsoft. All rights reserved.
XinZhangMS 0:f7f1f0d76dd6 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
XinZhangMS 0:f7f1f0d76dd6 3
XinZhangMS 0:f7f1f0d76dd6 4 #ifndef FRAME_CODEC_H
XinZhangMS 0:f7f1f0d76dd6 5 #define FRAME_CODEC_H
XinZhangMS 0:f7f1f0d76dd6 6
XinZhangMS 0:f7f1f0d76dd6 7 #include "azure_uamqp_c/amqpvalue.h"
XinZhangMS 0:f7f1f0d76dd6 8
XinZhangMS 0:f7f1f0d76dd6 9 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 10 extern "C" {
XinZhangMS 0:f7f1f0d76dd6 11 #include <cstdint>
XinZhangMS 0:f7f1f0d76dd6 12 #include <cstddef>
XinZhangMS 0:f7f1f0d76dd6 13 #else
XinZhangMS 0:f7f1f0d76dd6 14 #include <stdint.h>
XinZhangMS 0:f7f1f0d76dd6 15 #include <stddef.h>
XinZhangMS 0:f7f1f0d76dd6 16 #include <stdbool.h>
XinZhangMS 0:f7f1f0d76dd6 17 #endif /* __cplusplus */
XinZhangMS 0:f7f1f0d76dd6 18
XinZhangMS 0:f7f1f0d76dd6 19 #include "azure_c_shared_utility/umock_c_prod.h"
XinZhangMS 0:f7f1f0d76dd6 20
XinZhangMS 0:f7f1f0d76dd6 21 typedef struct PAYLOAD_TAG
XinZhangMS 0:f7f1f0d76dd6 22 {
XinZhangMS 0:f7f1f0d76dd6 23 const unsigned char* bytes;
XinZhangMS 0:f7f1f0d76dd6 24 size_t length;
XinZhangMS 0:f7f1f0d76dd6 25 } PAYLOAD;
XinZhangMS 0:f7f1f0d76dd6 26
XinZhangMS 0:f7f1f0d76dd6 27 /* Codes_SRS_FRAME_CODEC_01_016: [The type code indicates the format and purpose of the frame.] */
XinZhangMS 0:f7f1f0d76dd6 28 /* Codes_SRS_FRAME_CODEC_01_017: [The subsequent bytes in the frame header MAY be interpreted differently depending on the type of the frame.] */
XinZhangMS 0:f7f1f0d76dd6 29 /* Codes_SRS_FRAME_CODEC_01_070: [The type code indicates the format and purpose of the frame.] */
XinZhangMS 0:f7f1f0d76dd6 30 /* Codes_SRS_FRAME_CODEC_01_071: [The subsequent bytes in the frame header MAY be interpreted differently depending on the type of the frame.] */
XinZhangMS 0:f7f1f0d76dd6 31 /* Codes_SRS_FRAME_CODEC_01_018: [A type code of 0x00 indicates that the frame is an AMQP frame.] */
XinZhangMS 0:f7f1f0d76dd6 32 /* Codes_SRS_FRAME_CODEC_01_072: [A type code of 0x00 indicates that the frame is an AMQP frame.] */
XinZhangMS 0:f7f1f0d76dd6 33 #define FRAME_TYPE_AMQP (uint8_t)0x00
XinZhangMS 0:f7f1f0d76dd6 34
XinZhangMS 0:f7f1f0d76dd6 35 /* Codes_SRS_FRAME_CODEC_01_073: [A type code of 0x01 indicates that the frame is a SASL frame] */
XinZhangMS 0:f7f1f0d76dd6 36 /* Codes_SRS_FRAME_CODEC_01_019: [A type code of 0x01 indicates that the frame is a SASL frame] */
XinZhangMS 0:f7f1f0d76dd6 37 #define FRAME_TYPE_SASL (uint8_t)0x01
XinZhangMS 0:f7f1f0d76dd6 38
XinZhangMS 0:f7f1f0d76dd6 39 typedef struct FRAME_CODEC_INSTANCE_TAG* FRAME_CODEC_HANDLE;
XinZhangMS 0:f7f1f0d76dd6 40 typedef void(*ON_FRAME_RECEIVED)(void* context, const unsigned char* type_specific, uint32_t type_specific_size, const unsigned char* frame_body, uint32_t frame_body_size);
XinZhangMS 0:f7f1f0d76dd6 41 typedef void(*ON_FRAME_CODEC_ERROR)(void* context);
XinZhangMS 0:f7f1f0d76dd6 42 typedef void(*ON_BYTES_ENCODED)(void* context, const unsigned char* bytes, size_t length, bool encode_complete);
XinZhangMS 0:f7f1f0d76dd6 43
XinZhangMS 0:f7f1f0d76dd6 44 MOCKABLE_FUNCTION(, FRAME_CODEC_HANDLE, frame_codec_create, ON_FRAME_CODEC_ERROR, on_frame_codec_error, void*, callback_context);
XinZhangMS 0:f7f1f0d76dd6 45 MOCKABLE_FUNCTION(, void, frame_codec_destroy, FRAME_CODEC_HANDLE, frame_codec);
XinZhangMS 0:f7f1f0d76dd6 46 MOCKABLE_FUNCTION(, int, frame_codec_set_max_frame_size, FRAME_CODEC_HANDLE, frame_codec, uint32_t, max_frame_size);
XinZhangMS 0:f7f1f0d76dd6 47 MOCKABLE_FUNCTION(, int, frame_codec_subscribe, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type, ON_FRAME_RECEIVED, on_frame_received, void*, callback_context);
XinZhangMS 0:f7f1f0d76dd6 48 MOCKABLE_FUNCTION(, int, frame_codec_unsubscribe, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type);
XinZhangMS 0:f7f1f0d76dd6 49 MOCKABLE_FUNCTION(, int, frame_codec_receive_bytes, FRAME_CODEC_HANDLE, frame_codec, const unsigned char*, buffer, size_t, size);
XinZhangMS 0:f7f1f0d76dd6 50 MOCKABLE_FUNCTION(, int, frame_codec_encode_frame, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type, const PAYLOAD*, payloads, size_t, payload_count, const unsigned char*, type_specific_bytes, uint32_t, type_specific_size, ON_BYTES_ENCODED, on_bytes_encoded, void*, callback_context);
XinZhangMS 0:f7f1f0d76dd6 51
XinZhangMS 0:f7f1f0d76dd6 52 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 53 }
XinZhangMS 0:f7f1f0d76dd6 54 #endif /* __cplusplus */
XinZhangMS 0:f7f1f0d76dd6 55
XinZhangMS 0:f7f1f0d76dd6 56 #endif /* FRAME_CODEC_H */