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 * Callback function type for connection status changes delivery.
35 * @param[out] info Remote endpoint information.
36 * @param[out] isConnected Current connection status info.
38 typedef void (*CAConnectionStateChangedCB)(const CAEndpoint_t *info, bool isConnected);
41 * Callback function type for adapter status changes delivery.
42 * @param[out] adapter Transport type information.
43 * @param[out] enabled Current adapter status info.
45 typedef void (*CAAdapterStateChangedCB)(CATransportAdapter_t adapter, bool enabled);
48 * Register network monitoring callback.
49 * Network status changes are delivered these callback.
50 * @param[in] adapterStateCB Adapter state monitoring callback.
51 * @param[in] connStateCB Connection state monitoring callback.
53 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
55 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
56 CAConnectionStateChangedCB connStateCB);
59 * Unregister network monitoring callback.
60 * @param[in] adapterStateCB Adapter state monitoring callback.
61 * @param[in] connStateCB Connection state monitoring callback.
63 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
65 CAResult_t CAUnregisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
66 CAConnectionStateChangedCB connStateCB);
69 * Set device to handle for auto connection.
70 * @param[in] address LE address to set.
72 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
74 CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
77 * Unset device to handle for auto connection.
78 * @param[in] address LE address to unset.
80 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
82 CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
85 * Set the port number to assign .
86 * @param[in] adapter Transport adapter information.
87 * @param[in] flag Transport flag information.
88 * @param[in] port The port number to use.
90 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
92 CAResult_t CASetPortNumberToAssign(CATransportAdapter_t adapter,
93 CATransportFlags_t flag, uint16_t port);
96 * Get the assigned port number currently.
97 * @param[in] adapter Transport adapter information.
98 * @param[in] flag Transport flag information.
100 * @return assigned port number information.
102 uint16_t CAGetAssignedPortNumber(CATransportAdapter_t adapter, CATransportFlags_t flag);
106 * initialize util client for android
107 * @param[in] env JNI interface pointer.
108 * @param[in] jvm invocation inferface for JAVA virtual machine.
109 * @param[in] context application context.
111 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
113 CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context);
116 * terminate util client for android
117 * @param[in] env JNI interface pointer.
119 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
121 CAResult_t CAUtilClientTerminate(JNIEnv *env);
125 * start discovery for BT device which has iotivity UUID.
126 * @param[in] env JNI interface pointer.
128 CAResult_t CAUtilStartScan(JNIEnv *env);
132 * @param[in] env JNI interface pointer.
134 CAResult_t CAUtilStopScan(JNIEnv *env);
137 * bonding between devices.
138 * @param[in] env JNI interface pointer.
139 * @param[in] device bluetooth device object.
141 CAResult_t CAUtilCreateBond(JNIEnv *env, jobject device);
145 * set callback listener of found device.
146 * @param[in] listener callback listener
148 void CAUtilSetFoundDeviceListener(jobject listener);
151 * set interval time and working count for LE scan.
152 * @param[in] intervalTime interval time(Seconds).
153 * @param[in] workingCount working cycle for selected interval time.
155 * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
157 CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount);
165 #endif /* CA_UTILS_INTERFACE_H_ */