1 /* ****************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
24 * This file contains common utility functions to manage the CA msg
25 * fragmentation and reassemebly.
28 #ifndef CA_FRAGMENTATION_H_
29 #define CA_FRAGMENTATION_H_
35 * From the adapter level, this is the maximum data length is supported
36 * for the data transmission.
38 #define MAX_DATA_LENGTH_SUPPORTED 4095
41 * The number of bits allocated to represent data length in header.
43 #define NUMBER_OF_BITS_TO_IDENTIFY_DATA 12
46 * The length of the header in bits.
48 #define NUMBER_OF_BITS_IN_CA_HEADER 15
51 * The length of the header in bytes.
53 #define CA_HEADER_LENGTH 2
56 * The MTU supported for BLE adapter
58 #define CA_SUPPORTED_BLE_MTU_SIZE 20
62 * Reserved bit to differentiating the platform. Currently not in use.
64 #define PLATFORM_IDENTIFIER_BIT 1
67 * The MTU supported from Tizen platform for EDR adapter.
69 #define CA_SUPPORTED_EDR_MTU_SIZE 512
73 * Reserved bit to differentiating the platform. Currently not in use.
75 #define PLATFORM_IDENTIFIER_BIT 0
78 * The MTU supported from Android platform for EDR adapter.
80 #define CA_SUPPORTED_EDR_MTU_SIZE 200
84 * Reserved bit to differentiating the platform. Currently not in use.
86 #define PLATFORM_IDENTIFIER_BIT 0
89 * The MTU supported from Arduino platform for EDR adapter.
91 #define CA_SUPPORTED_EDR_MTU_SIZE 200
93 #else //Other Platforms
95 * Reserved bit to differentiating the platform. Currently not in use.
97 #define PLATFORM_IDENTIFIER_BIT 0
100 * The MTU supported for EDR adapter
102 #define CA_SUPPORTED_EDR_MTU_SIZE 200
107 * Current Header version.
109 #define HEADER_VERSION 1
116 /*****************************************************************
117 * @file The CA Header format
118 * CA Header will be defined by 2 bytes of Header.
119 * First two bits : Header version(Currently Its not being used)
120 * Third bit and fourth bit: Reserved bits for future use.
121 * 5th to 16th bit : 12 bits to provide the length of the data.
122 *****************************************************************/
125 * This function is used to generate the CA specific header to
126 * maintain the fragmentation logic. The header structure
127 * explained above will be formed and returned to the caller.
129 * @param[in,out] header Pointer to the octet array that will contain
130 * the generated header.
131 * @param[in] length The total length of the data. The length will
132 * be embedded in bits 5-16 of the header,
133 * meaning the maximum overall length of the
134 * data to be fragmented can be no more than 4096
137 * @return ::CA_STATUS_OK on success. One of the ::CA_STATUS_FAILED or
138 * other error values on error.
139 * @retval ::CA_STATUS_OK Successful
140 * @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments
141 * @retval ::CA_STATUS_FAILED Operation failed
143 CAResult_t CAGenerateHeader(char *header, uint32_t length);
146 * This function is used to parse the header in the receiver
147 * end. This function will provide the information of the total
148 * length of the data which has been fragmented.
150 * @param[in] header Pointer to the octet array data which contains the
151 * header information. Note that pointer should
152 * point to two bytes of data header which needs to
155 * @return Overall length of the data to be reassembled, or 0 on
158 uint32_t CAParseHeader(const char *header);
164 #endif /* CA_FRAGMENTATION_H_ */