1 /* ****************************************************************
3 * Copyright 2016 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 ******************************************************************/
21 #ifndef CA_UTILS_INTERFACE_H_
22 #define CA_UTILS_INTERFACE_H_
34 * this level depends on transmission time.
35 * unicast based UDP will be checked by caretransmission.
45 /** address for all **/
46 char addr[MAX_ADDR_STR_SIZE_CA];
48 /** adapter priority of all transmissions. **/
49 CATransportAdapter_t adapter;
51 /** level about speed of response. **/
56 * CAUtilConfig_t structure.
60 CATransportBTFlags_t bleFlags;
61 CMConfigureInfo_t cmInfo;
65 * Callback function type for connection status changes delivery.
66 * @param[out] info Remote endpoint information.
67 * @param[out] isConnected Current connection status info.
69 typedef void (*CAConnectionStateChangedCB)(const CAEndpoint_t *info, bool isConnected);
72 * Callback function type for adapter status changes delivery.
73 * @param[out] adapter Transport type information.
74 * @param[out] enabled Current adapter status info.
76 typedef void (*CAAdapterStateChangedCB)(CATransportAdapter_t adapter, bool enabled);
79 * Register network monitoring callback.
80 * Network status changes are delivered these callback.
81 * @param[in] adapterStateCB Adapter state monitoring callback.
82 * @param[in] connStateCB Connection state monitoring callback.
84 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
86 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
87 CAConnectionStateChangedCB connStateCB);
90 * Unregister network monitoring callback.
91 * @param[in] adapterStateCB Adapter state monitoring callback.
92 * @param[in] connStateCB Connection state monitoring callback.
94 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
96 CAResult_t CAUnregisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
97 CAConnectionStateChangedCB connStateCB);
100 * Set device to handle for auto connection.
101 * @param[in] address LE address to set.
103 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
105 CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
108 * Unset device to handle for auto connection.
109 * @param[in] address LE address to unset.
111 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
113 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
116 * Set the port number to assign .
117 * @param[in] adapter Transport adapter information.
118 * @param[in] flag Transport flag information.
119 * @param[in] port The port number to use.
121 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
123 CAResult_t CASetPortNumberToAssign(CATransportAdapter_t adapter,
124 CATransportFlags_t flag, uint16_t port);
127 * Get the assigned port number currently.
128 * @param[in] adapter Transport adapter information.
129 * @param[in] flag Transport flag information.
131 * @return assigned port number information.
133 uint16_t CAGetAssignedPortNumber(CATransportAdapter_t adapter, CATransportFlags_t flag);
135 //custom advertisement data setting
136 #if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
138 CAResult_t CASetAdvertisementData(const char* data, int length);
140 void CASetAdvertisementDataGetter(CAAdvertisementDataGetterCB getter);
142 void CASetAutoAdvertisement(bool autoAdvertisement);
144 CAResult_t CASetScanResponseData(const char* data, int length);
150 * initialize client connection manager
152 CAResult_t CAUtilClientInitialize();
155 * terminate client connection manager
157 CAResult_t CAUtilClientTerminate();
161 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
163 CAResult_t CAUtilStopLEScan();
167 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
169 CAResult_t CAUtilStartLEScan();
173 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
175 CAResult_t CAUtilClientDisconnect();
180 * initialize util client for android
181 * @param[in] env JNI interface pointer.
182 * @param[in] jvm invocation inferface for JAVA virtual machine.
183 * @param[in] context application context.
185 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
187 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context);
190 * terminate util client for android
191 * @param[in] env JNI interface pointer.
193 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
195 CAResult_t CAUtilClientTerminate(JNIEnv *env);
199 * start discovery for BT device which has iotivity UUID.
200 * @param[in] env JNI interface pointer.
202 CAResult_t CAUtilStartScan(JNIEnv *env);
206 * @param[in] env JNI interface pointer.
208 CAResult_t CAUtilStopScan(JNIEnv *env);
211 * bonding between devices.
212 * @param[in] env JNI interface pointer.
213 * @param[in] device bluetooth device object.
215 CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device);
219 * set callback listener of found device.
220 * @param[in] listener callback listener
222 void CAUtilSetFoundDeviceListener(jobject listener);
225 * set interval time and working count for LE scan.
226 * @param[in] intervalTime interval time(Seconds).
227 * @param[in] workingCount working cycle for selected interval time.
229 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
231 CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount);
236 * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
238 CAResult_t CAUtilStopLEScan();
243 * start BLE advertising.
244 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
246 CAResult_t CAUtilStartLEAdvertising();
249 * stop BLE advertising.
250 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
252 CAResult_t CAUtilStopLEAdvertising();
255 * set CAUtil BT configure.
256 * @param[in] config ::CAUtilConfig_t value
257 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
259 CAResult_t CAUtilSetBTConfigure(CAUtilConfig_t config);
262 * set CAUtil log preference.
263 * @param[in] level ::CAUtilLogLevel_t value
264 * @param[in] hidePrivateLogEntries Private Log Entries.
266 * true : hide private log.
267 * false : show private log.
268 * (privacy : uid, did, access token, etc)
270 void CAUtilSetLogLevel(CAUtilLogLevel_t level, bool hidePrivateLogEntries);
273 * Set multicast time to live value to control the scope of the multicasts.
274 * @param[in] ttl To be set to any value from 0 to 255.
276 * 0: Are restricted to the same host.
277 * 1: Are restricted to the same subnet.
278 * 32: Are restricted to the same site.
279 * 64: Are restricted to the same region.
280 * 128: Are restricted to the same continent.
281 * 255: Are unrestricted in scope.
282 * We cannot support region, continent and unrestricted in scope.
284 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
286 CAResult_t CAUtilSetMulticastTTL(size_t ttl);
289 * Get multicast time to live value.
290 * @param[out] ttl TTL pointer to get the stored multicast time to live.
292 * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
294 CAResult_t CAUtilGetMulticastTTL(size_t *ttl);
297 * Disconnect TCP session.
298 * When there is no transmission for a long time.
299 * Some carrier Vendor is blocking data.
300 * Thur, TCP Session is cleaned through this function.
301 * @param[in] address Address.
302 * @param[in] port Port.
303 * @param[in] flags Transport flag.
305 CAResult_t CAUtilTCPDisconnectSession(const char *address,
307 CATransportFlags_t flags);
309 CAResult_t CAUtilStartGattServer();
310 CAResult_t CAUtilStopGattServer();
316 #endif /* CA_UTILS_INTERFACE_H_ */