Corrected @file tags and restored 'Files' section.
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / camsgparser.h
1 /* ****************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 /**
22  * @file
23  *
24  * This file contains common utility functions to manage the CA msg
25  * fragmentation and reassemebly.
26  */
27
28 #ifndef _CA_MSG_PARSER_H_
29 #define _CA_MSG_PARSER_H_
30
31 #include "cacommon.h"
32 #include "logger.h"
33
34 /**
35  * @var MAX_DATA_LENGTH_SUPPORTED
36  * @brief From the adapter level, this is the maximum data length is supported
37  *           for the data transmission.
38  */
39 #define MAX_DATA_LENGTH_SUPPORTED 4095
40
41 /**
42  * @var NUMBER_OF_BITS_TO_IDENTIFY_DATA
43  * @brief The number of bits allocated to represent data length in header.
44  */
45 #define NUMBER_OF_BITS_TO_IDENTIFY_DATA 12
46
47 /**
48  * @var NUMBER_OF_BITS_IN_CA_HEADER
49  * @brief The length of the header in bits.
50  */
51 #define NUMBER_OF_BITS_IN_CA_HEADER 15
52
53 /**
54  * @var CA_HEADER_LENGTH
55  * @brief The length of the header in bytes.
56  */
57 #define CA_HEADER_LENGTH 2
58
59 #ifdef __TIZEN__
60 /**
61  * @var PLATFORM_IDENTIFIER_BIT
62  * @brief Reserved bit to differentiating the platform. Currently not in use.
63  */
64 #define PLATFORM_IDENTIFIER_BIT 1
65
66 /**
67  * @var CA_SUPPORTED_BLE_MTU_SIZE
68  * @brief The MTU supported from Tizen platform for LE adapter.
69  */
70 #define CA_SUPPORTED_BLE_MTU_SIZE  200
71 #else // #endif __TIZEN__
72
73 /**
74  * @var PLATFORM_IDENTIFIER_BIT
75  * @brief Reserved bit to differentiating the platform. Currently not in use.
76  */
77 #define PLATFORM_IDENTIFIER_BIT 0
78
79 /**
80  * @var CA_SUPPORTED_BLE_MTU_SIZE
81  * @brief The MTU supported from Arduino platform for LE adapter.
82  */
83 #define CA_SUPPORTED_BLE_MTU_SIZE  200
84 #endif //#endif __ARDUINO__
85
86 /**
87  * @var HEADER_VERSION
88  * @brief Current Header version.
89  */
90 #define HEADER_VERSION 1
91
92 #ifdef __cplusplus
93 extern "C"
94 {
95 #endif
96
97 /*****************************************************************
98  * @file The CA Header format
99  * @brief CA Header will be difined by 2 bytes of Header.
100  * First two bits : Header version(Currently Its not being used)
101  * Third bit and fourth bit: Reserved bits for future use.
102  * 5th to 16th bit : 12 bits to provide the length of the data.
103  *****************************************************************/
104
105 /**
106 * @fn CAGenerateHeader
107 * @brief This function is used to generate the CA specific header to maintain the fragmentation
108 *           logic. The header sturcture explained above will be formed and returned to the caller.
109 *
110 * @param[in]  data    Pointer to the charcter data which needs to be printed.
111 * @param[in]  length The total legth of the data which will be represented from 5th -16th bits
112 *                              in the header.
113 *
114 * @return  CA_STATUS_OK on success. One of theCA_STATUS_FAILED or other error values on error.
115 * @retval  CA_STATUS_OK  Successful
116 * @retval  CA_STATUS_INVALID_PARAM  Invalid input argumets
117 * @retval  CA_STATUS_FAILED Operation failed
118 */
119 CAResult_t CAGenerateHeader(char *header, uint32_t length);
120
121 /**
122 * @fn CAParseHeader
123 * @brief This function is used to parse the header in the receiver end. This function will
124 *            provide the information of the total length of the data which has been fragmented.
125 *
126 * @param[in]  header  Pointer to the charcter data which contains the header information.
127 *                                Note that pointer should point to two bytes of data header
128 *                                 which needs to be parsed.
129 *
130 */
131 uint32_t CAParseHeader(const char *header);
132
133 #ifdef __cplusplus
134 } /* extern "C" */
135 #endif
136
137 #endif  // _CA_MSG_PARSER_H_
138