scanning should be stopped for saving battery when BLE is not using.
Change-Id: I0e12afb4f0961bd1fa4ec579b3e0412796cacf23
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14309
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
CAUtilSetLEScanInterval(intervalTime, workignCount);
}
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_stopLeScanImpl(JNIEnv *env, jclass clazz)
+{
+ LOGI("stopLeScan");
+ (void)env;
+ (void)clazz;
+ CAUtilStopLEScan();
+}
+
JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl
(JNIEnv *env, jclass clazz, jint cipherSuite, jint adapter)
{
* @param intervalTime interval time(Seconds).
* @param workingCount working count with interval time.
*/
-
public synchronized static void setLeScanIntervalTime(int intervalTime, int workingCount){
CaInterface.setLeScanIntervalTimeImpl(intervalTime, workingCount);
}
-
private static native void setLeScanIntervalTimeImpl(int intervalTime, int workingCount);
+ /**
+ * stop BLE scan.
+ * if you want to start scan, it can be triggered by setLeScanIntervalTime or
+ * other request API like findResource.
+ */
+ public synchronized static void stopLeScan(){
+ CaInterface.stopLeScanImpl();
+ }
+ private static native void stopLeScanImpl();
public synchronized static int setCipherSuite(OicCipher cipher, OcConnectivityType connType){
return CaInterface.setCipherSuiteImpl(cipher.getValue(), connType.getValue());
* @param[in] intervalTime interval time(Seconds).
* @param[in] workingCount working cycle for selected interval time.
*
- * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
+ * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
*/
CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount);
+/**
+ * stop LE scan.
+ * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED
+ */
+CAResult_t CAUtilStopLEScan();
#endif
#ifdef __cplusplus
*/
void CAManagerLESetScanInterval(jint intervalTime, jint workingCount);
+/**
+ * stop BLE scan.
+ */
+void CAManagerLEStopScan();
+
#endif
#ifdef __cplusplus
CALERestartScanWithInterval(interval, count, BLE_SCAN_ENABLE);
}
+void CAManagerLEStopScan()
+{
+ OIC_LOG(DEBUG, TAG, "CAManagerLEStopScan");
+ CALERestartScanWithInterval(0, 0, BLE_SCAN_DISABLE);
+}
+
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
JNIEnv *env, jobject obj, jint state)
return CA_NOT_SUPPORTED;
#endif
}
+
+CAResult_t CAUtilStopLEScan()
+{
+ OIC_LOG(DEBUG, TAG, "CAUtilStopLEScan");
+#ifdef LE_ADAPTER
+ CAManagerLEStopScan();
+ return CA_STATUS_OK;
+#else
+ OIC_LOG(DEBUG, TAG, "it is not supported");
+ return CA_NOT_SUPPORTED;
+#endif
+}
#endif