if target_os == 'android':
if target_arch == 'armeabi-v7a-hard':
target_arch = 'armeabi-v7a'
- env.AppendUnique(CCFLAGS=['-D__JAVA__'])
+ env.AppendUnique(CPPDEFINES=['__JAVA__'])
if target_os == 'darwin':
- env.AppendUnique(CPPPATH=['/usr/local/include'])
- env.AppendUnique(LIBPATH=['/usr/local/lib'])
+ env.AppendUnique(CPPPATH = ['/usr/local/include'])
+ env.AppendUnique(LIBPATH = ['/usr/local/lib'])
if env.get('BUILD_JAVA') == True and target_os != 'android':
if env.get('JAVA_HOME') != None:
- env.AppendUnique(CCFLAGS=['-D__JAVA__'])
- env.AppendUnique(CPPPATH=[
+ env.AppendUnique(CPPDEFINES=['__JAVA__'])
+ if target_os in ['windows', 'winrt']:
+ env.AppendUnique(CPPPATH=[
+ env.get('JAVA_HOME') + '/include',
+ env.get('JAVA_HOME') + '/include/win32'
+ ])
+ else:
+ env.AppendUnique(CPPPATH=[
env.get('JAVA_HOME') + '/include',
env.get('JAVA_HOME') + '/include/' + target_os
])
# External library include files are in <src_dir>/deps/<target_os>/include
# the library binaries are in <src_dir>/deps/<target_os>/lib/<arch>
if target_os not in ['windows']:
- env.AppendUnique(CPPPATH=[
- os.path.join(env.get('SRC_DIR'), 'deps', target_os, 'include')
- ])
- env.AppendUnique(LIBPATH=[
- os.path.join(
- env.get('SRC_DIR'), 'deps', target_os, 'lib', target_arch)
- ])
+ env.AppendUnique(CPPPATH = [os.path.join(env.get('SRC_DIR'), 'deps', target_os, 'include')])
+ env.AppendUnique(LIBPATH = [os.path.join(env.get('SRC_DIR'), 'deps', target_os, 'lib', target_arch)])
# tinycbor build/fetch
SConscript(os.path.join(env.get('SRC_DIR'), 'extlibs', 'tinycbor', 'SConscript'))
Import('env')
import os.path
+help_vars = Variables()
+if env.get('BUILD_JAVA') == True:
+ if not env.get('ANDROID_GRADLE'):
+ SConscript('../../extlibs/android/gradle/SConscript')
+ help_vars.Add(PathVariable('ANDROID_GRADLE', 'Android Gradle directory', os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'gradle', 'gradle-2.2.1/bin/gradle')))
+
+ if env.get('ANDROID_GRADLE'):
+ android_gradle = env.get('ANDROID_GRADLE')
+ else:
+ print(
+'''
+*************************************** Info **********************************
+* Android Gradle path isn't set, the default will be used. You can set *
+* environment variable ANDROID_GRADLE or add it in command line as: *
+* # scons ANDROID_GRADLE=<path to android GRADLE> ... *
+*******************************************************************************
+''')
+ android_gradle = os.path.join(env.get('SRC_DIR'), 'extlibs', 'android', 'gradle', 'gradle-2.2.1', 'bin', 'gradle')
+
+help_vars.Update(env)
+Help(help_vars.GenerateHelpText(env))
+
# Set common flags
if env['CC'] == 'cl':
if env.get('UWP_APP') == '1':
ndk_env = env.Clone()
target_os = env.get('TARGET_OS')
-host_os = sys.platform
-print host_os
######################################################################
# Build flags
######################################################################
'gradle2.2.1.zip',
'https://services.gradle.org/distributions/gradle-2.2.1-all.zip')
gradle_dir = env.UnpackAll('gradle-2.2.1', gradle_zip)
- print '''
+ print( '''
***********************************************************************
-* Downloading gradle: *
-*******************************************************************************
-'''
+* Downloading gradle: *
+***********************************************************************
+''')
os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
if not os.path.exists(android_home + '/platforms/android-21') or \
not os.path.exists(android_home + '/build-tools/20.0.0'):
- print '''
+ print(
+'''
***************************************** Info ********************************
* Either 'Android API 21' is not installed or 'Android SDK Build Tools *
* 20.0.0' is not installed. The Android SDK Manager will now open. Please *
*******************************************************************************
...Opening Android SDK Manager now. Once you are finished, the build will continue.
-'''
+''')
os.system(android_home + '/tools/android')
def ensure_libs(target, source, env):
- return target, [
- source,
- env.get('BUILD_DIR') + 'libca-interface.so',
- env.get('BUILD_DIR') + 'liboc.so',
- env.get('BUILD_DIR') + 'liboc_logger.so',
- env.get('BUILD_DIR') + 'libocstack-jni.so'
- ]
+ if platform.system() == 'Windows':
+ return target, [source, env.get('BUILD_DIR') + 'ca-interface.dll',
+ env.get('BUILD_DIR') + 'ocstack-jni.dll']
+ else:
+ return target, [source, env.get('BUILD_DIR') + 'libca-interface.so',
+ env.get('BUILD_DIR') + 'libocstack-jni.so']
jniOut = SConscript('jni/SConscript')
+target_variant = "java"
+if target_os == 'android':
+ target_variant = "android"
+
jdk_env = Environment(ENV=os.environ)
jdk_env['BUILDERS']['Gradle'] = Builder(
action=env.get('ANDROID_GRADLE') + ' build -b ' + env.get('SRC_DIR') +
'/java/iotivity-%s/build.gradle -PPROJECT_VERSION=%s -PWITH_TRANSPORT_EDR=%s -PWITH_TRANSPORT_BLE=%s -PWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace'
- % (target_os, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC,
+ % (target_variant, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC,
TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB,
MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')),
emitter=ensure_libs)
target="base/objs",
source="common/src/main/java/org/iotivity/base/OcResource.java")
-examples_target = "java"
-if target_os == 'android':
- examples_target = "android"
jdk_env['BUILDERS']['Gradle'] = Builder(
action=env.get('ANDROID_GRADLE') + ' build -b ' +
'java/examples-%s/build.gradle -PPROJECT_VERSION=%s -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_OS=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace'
- % (examples_target, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE,
+ % (target_variant, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE,
TRANSPORT_NFC, target_os, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD,
RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER,
env.get('BUILD_DIR')))
-#cmdBuildExamples=jdk_env.Gradle(target="../examples-%s/devicediscoveryclient/apk" % (examples_target, ), source="examples-%s/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java" % (examples_target, ))
+#cmdBuildExamples=jdk_env.Gradle(target="../examples-%s/devicediscoveryclient/apk" % (target_variant, ), source="examples-%s/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java" % (target_variant, ))
cmdBuildExamples = jdk_env.Gradle(
- target="examples-%s/simpleclient/jar" % (examples_target, ),
+ target="examples-%s/simpleclient/jar" % (target_variant, ),
source=
"examples-%s/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java"
- % (examples_target, ))
+ % (target_variant, ))
if target_os != 'android':
exampleAclFiles = jdk_env.Install(
public class OcRepresentation {
static {
- System.loadLibrary("oc");
System.loadLibrary("ocstack-jni");
}
public class OcResourceResponse {
static {
- System.loadLibrary("oc");
System.loadLibrary("ocstack-jni");
}
jcenter()\r
}\r
dependencies {\r
- compile fileTree(dir: "../../iotivity-$TARGET_OS/build/libs/", include: '*.jar')\r
+ compile fileTree(dir: "../../iotivity-java/build/libs/", include: '*.jar')\r
}\r
}\r
static {
System.loadLibrary("gnustl_shared");
- System.loadLibrary("connectivity_abstraction");
- System.loadLibrary("oc_logger");
- System.loadLibrary("octbstack");
- System.loadLibrary("oc");
if (0 != BuildConfig.SECURED)
{
System.loadLibrary("ocprovision");
public class CaInterface {
static {
- System.loadLibrary("connectivity_abstraction");
System.loadLibrary("ca-interface");
}
private static volatile boolean isConnectionManagerInitialized = false;
--- /dev/null
+/*
+ *******************************************************************
+ *
+ * Copyright 2017 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+ rootProject.name='iotivity'
\ No newline at end of file
public final class OcPlatform {
static {
- System.loadLibrary("oc_logger");
- System.loadLibrary("octbstack");
- System.loadLibrary("oc");
System.loadLibrary("ocstack-jni");
}
#include <jni.h>
#include "logger.h"
#include <stdio.h>
+#include "caadapterutils.h"
#include "cainterface.h"
#include "JniCaInterface.h"
#include "cautilinterface.h"
static jclass g_jni_cls_enum = NULL;
static jmethodID g_jni_mid_enum = NULL;
-JNIEXPORT jint JNI_OnLoad(JavaVM *jvm, void *reserved)
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *jvm, void *reserved)
{
- LOGI("JNI_OnLoad");
+ OC_UNUSED(reserved);
+ LOGI("CaInterface_initialize");
g_jvm = jvm;
CANativeJNISetJavaVM(jvm);
return JNI_VERSION_1_6;
}
-void JNI_OnUnload(JavaVM *jvm, void *reserved)
+JNIEXPORT void JNICALL
+JNI_OnUnload(JavaVM *jvm, void *reserved)
{
+ OC_UNUSED(jvm);
+ OC_UNUSED(reserved);
return;
}
}
#else
JNIEXPORT void JNICALL
-Java_org_iotivity_ca_CaInterface_initialize
-(JNIEnv *env, jclass clazz)
+Java_org_iotivity_ca_CaInterface_initialize(JNIEnv *env, jclass clazz)
{
+ OC_UNUSED(env);
+ OC_UNUSED(clazz);
LOGI("CaInterface_initialize");
}
#endif
Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz,
jobject listener)
{
- LOGI("CaManager_initialize");
+ OC_UNUSED(clazz);
+ LOGI("CaManagere_initialize");
g_listenerObject = (*env)->NewGlobalRef(env, listener);
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaInterface_caManagerTerminate(JNIEnv *env, jclass clazz)
{
+ OC_UNUSED(clazz);
LOGI("CaManager_terminate");
CAUtilClientTerminate(env);
jclass clazz,
jstring jaddress)
{
+ OC_UNUSED(clazz);
LOGI("CaManager_setAutoConnectionDeviceInfo");
if (!jaddress)
{
jclass clazz,
jstring jaddress)
{
+ OC_UNUSED(clazz);
LOGI("CaManager_unsetAutoConnectionDeviceInfo");
if (!jaddress)
{
LOGI("setCipherSuiteImpl");
(void)env;
(void)clazz;
- CAResult_t ret = CASelectCipherSuite(cipherSuite, (CATransportAdapter_t) adapter);
+ CAResult_t ret = CASelectCipherSuite((uint16_t)cipherSuite, (CATransportAdapter_t) adapter);
if (CA_STATUS_OK != ret)
{
LOGE("CASelectCipherSuite has failed");
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include <climits>
#include "JniOcPlatform.h"
#include "OCPlatform.h"
#include "JniOcResource.h"
(JNIEnv *env, jclass clazz, jint jServiceType, jint jModeType, jstring jIpAddress, jint jPort,
jint jQOS, jstring jDbPath, jint jTransport)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_configure");
std::string ipAddress;
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stop
(JNIEnv *env, jclass clazz)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform.stop");
try {
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_start
(JNIEnv *env, jclass clazz)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform.start");
try {
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0
(JNIEnv *env, jclass clazz, jobject jResourceHandle)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_notifyAllObservers");
if (!jResourceHandle)
{
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1
(JNIEnv *env, jclass clazz, jobject jResourceHandle, jint jQoS)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_notifyAllObservers1");
if (!jResourceHandle)
jbyteArray jObservationIdArr,
jobject jResourceResponse)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_notifyListOfObservers2");
if (!jResourceHandle)
{
jobject jResourceResponse,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_notifyListOfObservers3");
if (!jResourceHandle)
{
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_findResource");
std::string host;
if (jHost)
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_findResource");
std::string host;
if (jHost)
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_findResources0");
if (!jListener)
{
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_findResources1");
if (!jListener)
{
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findDirectPairingDevices
(JNIEnv * env, jclass clazz, jint jTimeout, jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_findDirectPairingDevices");
-
+ if (jTimeout > USHRT_MAX)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "timeout exceeds max timeout.");
+ return;
+ }
if (!jListener)
{
ThrowOcException(OC_STACK_INVALID_PARAM, "onDPDevicesFoundListener cannot be null");
DPFunc::FIND_DIRECT_PAIRED_DEV_LIST);
};
+
try
{
- OCStackResult result = OCPlatform::findDirectPairingDevices(jTimeout,
- getDirectPairedCallback);
+ OCStackResult result = OCPlatform::findDirectPairingDevices(
+ static_cast<unsigned short>(jTimeout), getDirectPairedCallback);
if (OC_STACK_OK != result)
{
ThrowOcException(result, "OCPlatform::findDirectPairingDevices has failed");
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDirectPairedDevices
(JNIEnv *env, jclass jclazz, jobject jListener)
{
+ OC_UNUSED(jclazz);
LOGD("OcPlatform_getDirectPairedDevices");
if (!jListener)
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_doDirectPairing0
(JNIEnv *env, jclass clazz, jobject jpeer, jint jprmType, jstring jpin, jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_doDirectPairing");
if (!jListener)
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_getDeviceInfo0");
std::string host;
if (jHost)
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_getDeviceInfo1");
std::string host;
if (jHost)
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_getPlatformInfo0");
std::string host;
if (jHost)
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_getPlatformInfo1");
std::string host;
if (jHost)
JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0(
JNIEnv *env, jclass clazz, jobject jResource)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_registerResource");
if (!jResource)
{
jstring jResourceInterface,
jobject jListener, jint jResourceProperty)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_registerResource1");
std::string resourceUri;
if (jResourceUri)
resourceTypeName,
resourceInterface,
handleEntityCallback,
- static_cast<int>(jResourceProperty));
+ // jResoruceProperty comes from an enum and should always fit in
+ // uint8_t see ResourceProperty.java
+ static_cast<uint8_t>(jResourceProperty));
if (OC_STACK_OK != result)
{
jstring jDeviceName,
jobjectArray jDeviceTypes)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_registerDeviceInfo");
if (!jDeviceName)
}
catch (std::exception &e)
{
+ OC_UNUSED(e);
+ LOGE("%s", e.what());
ThrowOcException(JNI_EXCEPTION, "Failed to construct device info");
return;
}
jstring jSupportUrl,
jstring jSystemTime)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_registerPlatformInfo");
}
catch (std::exception &e)
{
+ OC_UNUSED(e);
+ LOGE("%s", e.what());
ThrowOcException(JNI_EXCEPTION, "Failed to construct platform info");
return;
}
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setPropertyValue0
(JNIEnv *env, jclass clazz, jint jType, jstring jPropName, jobjectArray jPropValue)
{
+ OC_UNUSED(clazz);
try
{
OCPayloadType type = (OCPayloadType)jType;
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setPropertyValue1
(JNIEnv *env, jclass clazz, jint jType, jstring jPropName, jstring jPropValue)
{
+ OC_UNUSED(clazz);
try
{
OCPayloadType type = (OCPayloadType)jType;
JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcPlatform_getPropertyValue0
(JNIEnv *env, jclass clazz, jint jType, jstring jPropName)
{
+ OC_UNUSED(clazz);
try
{
OCPayloadType type = (OCPayloadType) jType;
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0(
JNIEnv *env, jclass clazz, jobject jResourceHandle)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_unregisterResource");
if (!jResourceHandle)
{
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0
(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_bindResource");
if (!jResourceCollectionHandle)
{
jobject jResourceCollectionHandle,
jobjectArray jResourceHandleArray)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_bindResources");
if (!jResourceCollectionHandle)
jobject jResourceCollectionHandle,
jobject jResourceHandle)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_unbindResource");
if (!jResourceCollectionHandle)
{
jobject jResourceCollectionHandle,
jobjectArray jResourceHandleArray)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_unbindResources");
if (!jResourceCollectionHandle)
{
jobject jResourceHandle,
jstring jResourceTypeName)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_bindTypeToResource");
if (!jResourceHandle)
{
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0
(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceInterfaceName)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_bindInterfaceToResource");
if (!jResourceHandle)
{
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0(
JNIEnv *env, jclass clazz, jint ttl)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_startPresence");
try
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0(
JNIEnv *env, jclass clazz)
{
+ OC_UNUSED(clazz);
LOGI("OcPlatform_stopPresence");
try
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_subscribePresence");
std::string host;
if (jHost)
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_subscribePresence1");
std::string host;
if (jHost)
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0(
JNIEnv *env, jclass clazz, jobject jPresenceHandle)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_unsubscribePresence");
if (!jPresenceHandle)
{
jint jConnectivityType,
jobject jListener)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_subscribeDevicePresence0");
#ifdef WITH_CLOUD
std::string host;
}
return jPresenceHandle;
#else
+ OC_UNUSED(env);
+ OC_UNUSED(jHost);
+ OC_UNUSED(jDiArray);
+ OC_UNUSED(jConnectivityType);
+ OC_UNUSED(jListener);
ThrowOcException(JNI_NO_SUPPORT, "Not supported");
return nullptr;
#endif
jobjectArray jResourceTypeArray,
jobjectArray jInterfaceArray)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_constructResourceObject");
std::string host;
if (jHost)
host,
uri,
static_cast<OCConnectivityType>(jConnectivityType),
- static_cast<bool>(jIsObservable),
+ (jIsObservable != 0),
resourceTypes,
interfaces);
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0(
JNIEnv *env, jclass clazz, jobject jResourceResponse)
{
+ OC_UNUSED(clazz);
LOGD("OcPlatform_sendResponse");
if (!jResourceResponse)
{
jstring jHost,
jint jConnectivityType)
{
+ OC_UNUSED(clazz);
#ifndef WITH_CLOUD
+ OC_UNUSED(env);
+ OC_UNUSED(jHost);
+ OC_UNUSED(jConnectivityType);
ThrowOcException(OC_STACK_ERROR,
"OCAccountManager is not supported. (Please build with WITH_CLOUD=1 option)");
return nullptr;
JNIEXPORT jbyteArray JNICALL Java_org_iotivity_base_OcPlatform_getDeviceId
(JNIEnv *env, jobject thiz)
{
+ OC_UNUSED(thiz);
LOGD("OcPlatform_getDeviceId");
OCUUIdentity deviceId;
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_setDeviceId(
JNIEnv *env, jobject thiz, jbyteArray data)
{
+ OC_UNUSED(thiz);
LOGI("OcPlatform_setDeviceId");
OCUUIdentity deviceId;
try
JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcPlatform_getIoTivityVersion(
JNIEnv *env, jclass thiz)
{
+ OC_UNUSED(thiz);
LOGI("OcPlatform_getIoTivityVersion");
return env->NewStringUTF(IOTIVITY_VERSION);
}
#include "oxmverifycommon.h"
#include "JniDisplayVerifyNumListener.h"
#include "JniConfirmNumListener.h"
+#include <climits>
using namespace OC;
namespace PH = std::placeholders;
static JniDisplayVerifyNumListener *jniDisplayMutualVerifyNumListener = nullptr;
static JniConfirmNumListener *jniConfirmMutualVerifyNumListener = nullptr;
-void Callback(char *buf, size_t size)
+void JNICALL Callback(char *buf, size_t size)
{
if (jniPinListener)
{
}
}
-void displayPinCB(char *pinBuf, size_t pinSize)
+void JNICALL displayPinCB(char *pinBuf, size_t pinSize)
{
if (jniDisplayPinListener)
{
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_ownershipTransferCBdata
(JNIEnv *env, jobject thiz, jint OxmType, jobject jListener)
{
+ OC_UNUSED(thiz);
LOGD("OcProvisioning_ownershipTransferCBdata");
OCStackResult result = OC_STACK_ERROR;
JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverUnownedDevices1
(JNIEnv *env, jclass clazz, jint timeout)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_discoverUnownedDevices");
DeviceList_t list;
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_provisionInit
- (JNIEnv *env, jclass calzz, jstring jdbPath)
+ (JNIEnv *env, jclass clazz, jstring jdbPath)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_provisionInit");
char *dbpath;
JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverOwnedDevices1
(JNIEnv *env, jclass clazz , jint timeout)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_discoverOwnedDevices");
DeviceList_t list;
JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_getDeviceStatusList1
(JNIEnv *env, jclass clazz, jint timeout)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_getDeviceStatusList");
DeviceList_t ownedDevList, unownedDevList;
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayNumListener
(JNIEnv *env, jclass clazz, jobject jListener)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_setDisplayNumListener");
if (!jListener)
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_unsetDisplayNumListener
(JNIEnv * env, jclass clazz)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_unsetDisplayNumListener");
OCStackResult result = OCSecure::deregisterDisplayNumCallback();
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setPinType0
(JNIEnv *env, jclass thiz, jint pinSize, jint pinType)
{
+ OC_UNUSED(thiz);
LOGI("OcProvisioning_setPinType0");
OCStackResult result = OC_STACK_ERROR;
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setConfirmNumListener
(JNIEnv *env, jclass clazz, jobject jListener)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_setConfirmNumListener");
if (!jListener)
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_unsetConfirmNumListener
(JNIEnv *env, jclass clazz)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_unsetConfirmNumListener");
OCStackResult result = OCSecure::deregisterUserConfirmCallback();
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setMVJustWorksOptions0
(JNIEnv *env, jclass clazz, jint options)
{
+ OC_UNUSED(clazz);
LOGI("OcProvisioning_setMVJustWorksOptions0");
OCStackResult result = OCSecure::setVerifyOptionMask((VerifyOptionBitmask_t)options);
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_setDisplayPinListener
(JNIEnv *env, jclass thiz, jobject jListener)
{
-
+ OC_UNUSED(thiz);
LOGI("OcProvisioning_setDisplayPinListener");
if (!jListener)
JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverMOTEnabledDevices1
(JNIEnv *env, jclass thiz, jint timeout)
{
+ OC_UNUSED(thiz);
LOGI("OcProvisioning_discoverMOTEnabledDevices1");
#if defined(MULTIPLE_OWNER)
DeviceList_t list;
return nullptr;
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(timeout);
ThrowOcException(OC_STACK_INVALID_PARAM, "MULTIPLE_OWNER not enabled");
return nullptr;
#endif
JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverMOTEnabledOwnedDevices1
(JNIEnv *env, jclass thiz, jint timeout)
{
+ OC_UNUSED(thiz);
LOGI("OcProvisioning_discoverMOTEnabledOwnedDevices1");
#if defined(MULTIPLE_OWNER)
DeviceList_t list;
return nullptr;
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(timeout);
ThrowOcException(OC_STACK_INVALID_PARAM, "MULTIPLE_OWNER not enabled");
return nullptr;
#endif
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_saveTrustCertChain1
(JNIEnv *env, jobject thiz, jbyteArray trustCertChain, jint encodingType)
{
+ OC_UNUSED(thiz);
LOGD("OcProvisioning_saveTrustCertChain1");
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
jbyte* trustCertChainBytes = env->GetByteArrayElements(trustCertChain, 0);
+ // TODO figure out why trustCertChainBytes is created an not used.
+ OC_UNUSED(trustCertChainBytes);
jsize arrayLength = env->GetArrayLength(trustCertChain);
- uint16_t credId = -1;
+ uint16_t credId = USHRT_MAX;
unsigned char* trustedCertChar = new unsigned char[arrayLength];
try
{
}
return (jint)credId;
#else
+ OC_UNUSED(env);
+ OC_UNUSED(trustCertChain);
+ OC_UNUSED(encodingType);
ThrowOcException(OC_STACK_INVALID_PARAM, "WITH_TLS not enabled");
return -1;
#endif // __WITH_DTLS__ || __WITH_TLS__
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_saveACL
(JNIEnv *env , jclass thiz, jobject jacl)
{
+ OC_UNUSED(thiz);
LOGD("OcProvisioning_saveACL");
if (!jacl)
JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_doSelfOwnershiptransfer
(JNIEnv *env, jclass thiz)
{
-
+ OC_UNUSED(thiz);
LOGD("OcProvisioning_doSelfOwnershiptransfer");
try
{
JNIEXPORT jint JNICALL Java_org_iotivity_base_OcProvisioning_setDeviceIdSeed1
(JNIEnv *env, jobject thiz, jbyteArray seed)
{
+ OC_UNUSED(thiz);
LOGD("OcProvisioning_setDeviceIdSeed1");
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
jbyte* byteSeed = env->GetByteArrayElements(seed, 0);
}
return 0;
#else
+ OC_UNUSED(env);
+ OC_UNUSED(seed);
ThrowOcException(OC_STACK_INVALID_PARAM, "WITH_TLS not enabled");
return -1;
#endif // __WITH_DTLS__ || __WITH_TLS__
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcRDClient_publishResourceToRD");
#ifdef RD_CLIENT
std::string host;
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(clazz);
+ OC_UNUSED(jHost)
+ OC_UNUSED(jConnectivityType);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "Not supported");
return;
#endif
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcRDClient_publishResourceToRD");
#ifdef RD_CLIENT
if (!env)
};
std::vector<OCResourceHandle> resourceHandleList;
- size_t len = env->GetArrayLength(jResourceHandleArray);
- for (size_t i = 0; i < len; ++i)
+ jsize len = env->GetArrayLength(jResourceHandleArray);
+ for (jsize i = 0; i < len; ++i)
{
jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);
if (!jResourceHandle)
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(jHost);
+ OC_UNUSED(jConnectivityType);
+ OC_UNUSED(jResourceHandleArray);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "Not supported");
return;
#endif
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcRDClient_deleteResourceFromRD");
#ifdef RD_CLIENT
std::string host;
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(clazz);
+ OC_UNUSED(jHost);
+ OC_UNUSED(jConnectivityType);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "Not supported");
return;
#endif
jobject jListener,
jint jQoS)
{
+ OC_UNUSED(clazz);
LOGD("OcRDClient_deleteResourceFromRD");
#ifdef RD_CLIENT
if (!env)
};
std::vector<OCResourceHandle> resourceHandleList;
- size_t len = env->GetArrayLength(jResourceHandleArray);
- for (size_t i = 0; i < len; ++i)
+ jsize len = env->GetArrayLength(jResourceHandleArray);
+ for (jsize i = 0; i < len; ++i)
{
jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);
if (!jResourceHandle)
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(jHos);
+ OC_UNUSED(jConnectivityType);
+ OC_UNUSED(jResourceHandleArray);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "Not supported");
return;
#endif
}
std::string str = env->GetStringUTFChars(jKey, nullptr);
- rep->setValue(str, static_cast<bool>(jValue));
+ rep->setValue(str, (jValue != 0));
}
/*
std::vector<bool> value;
for (jsize i = 0; i < len; ++i)
{
- value.push_back(static_cast<bool>(booleans[i]));
+ value.push_back((booleans[i] != 0));
}
env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT);
std::vector<bool> innerVector;
for (jsize i = 0; i < lenInner; ++i)
{
- innerVector.push_back(static_cast<bool>(booleans[i]));
+ innerVector.push_back((booleans[i] != 0));
}
env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);
env->DeleteLocalRef(jInnerArray);
std::vector<bool> innerVector;
for (jsize i = 0; i < lenInner; ++i)
{
- innerVector.push_back(static_cast<bool>(booleans[i]));
+ innerVector.push_back((booleans[i] != 0));
}
env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);
env->DeleteLocalRef(jInnerArray);
// Sequences:
jobject operator()(const std::vector<int>& val) const
{
- size_t len = val.size();
+ jsize len = static_cast<jsize>(val.size());
jintArray jIntArray = env->NewIntArray(len);
if (!jIntArray)
{
}
jobject operator()(const std::vector<double>& val) const
{
- size_t len = val.size();
+ jsize len = static_cast<jsize>(val.size());
jdoubleArray jDoubleArray = env->NewDoubleArray(len);
if (!jDoubleArray)
{
}
jobject operator()(const std::vector<bool>& val) const
{
- size_t len = val.size();
+ jsize len = static_cast<jsize>(val.size());
jbooleanArray jBooleanArray = env->NewBooleanArray(len);
if (!jBooleanArray)
{
return nullptr;
}
jboolean* booleans = new jboolean[len];
- for (size_t i = 0; i < len; ++i)
+ for (jsize i = 0; i < len; ++i)
{
booleans[i] = static_cast<jboolean>(val[i]);
}
}
jobject operator()(const std::vector<std::string>& val) const
{
- size_t len = val.size();
+ jsize len = static_cast<jsize>(val.size());
jobjectArray strArr = env->NewObjectArray(len, g_cls_String, nullptr);
if (!strArr)
{
return nullptr;
}
- for (size_t i = 0; i < len; ++i)
+ for (jsize i = 0; i < len; ++i)
{
jstring jString = env->NewStringUTF(val[i].c_str());
env->SetObjectArrayElement(strArr, static_cast<jsize>(i), jString);
// OCByteString and arrays:
jobject operator()(const OCByteString &val) const
{
- jbyteArray jByteArray = env->NewByteArray(val.len);
+ jsize len = static_cast<jsize>(val.len);
+ jbyteArray jByteArray = env->NewByteArray(len);
if (!jByteArray)
{
return nullptr;
}
- env->SetByteArrayRegion(jByteArray, 0, val.len, reinterpret_cast<const jbyte *>(val.bytes));
+ env->SetByteArrayRegion(jByteArray, 0, len, reinterpret_cast<const jbyte *>(val.bytes));
if (env->ExceptionCheck())
{
env->DeleteLocalRef(jByteArray);
}
jobject operator()(const std::vector<uint8_t>& val) const
{
- size_t len = val.size();
+ jsize len = static_cast<jsize>(val.size());
jbyteArray jByteArray = env->NewByteArray(len);
if (!jByteArray)
{
}
for (jsize i = 0; i < lenOuter; ++i)
{
- size_t lenInner = val[i].size();
+ jsize lenInner = static_cast<jsize>(val[i].size());
jintArray jIntArray = env->NewIntArray(lenInner);
if (!jIntArray)
{
for (jsize i = 0; i < lenOuter; ++i)
{
- size_t lenInner = val[i].size();
+ jsize lenInner = static_cast<jsize>(val[i].size());
jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
if (!jDoubleArray)
{
}
for (jsize i = 0; i < lenOuter; ++i)
{
- size_t lenInner = val[i].size();
+ jsize lenInner = static_cast<jsize>(val[i].size());
jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
if (!jBooleanArray)
{
return nullptr;
}
jboolean* booleans = new jboolean[lenInner];
- for (size_t j = 0; j < lenInner; ++j)
+ for (jsize j = 0; j < lenInner; ++j)
{
booleans[j] = static_cast<jboolean>(val[i][j]);
}
}
for (jsize i = 0; i < lenMiddle; ++i)
{
- size_t lenInner = val[k][i].size();
+ jsize lenInner = static_cast<jsize>(val[k][i].size());
jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
jboolean* booleans = new jboolean[lenInner];
- for (size_t j = 0; j < lenInner; ++j)
+ for (jsize j = 0; j < lenInner; ++j)
{
booleans[j] = val[k][i][j];
}
(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener, jint jQoS)
{
LOGD("OcResource_discoveryMQTopicsImpl");
-
#ifdef WITH_MQ
if (!jQueryParamsMap)
{
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(thiz);
+ OC_UNUSED(jQueryParamsMap);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "not support");
#endif
}
jobject jQueryParamsMap, jobject jListener, jint jQoS)
{
LOGD("OcResource_createMQTopicImpl");
-
#ifdef WITH_MQ
if (!jQueryParamsMap)
{
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(thiz);
+ OC_UNUSED(jRepresentation);
+ OC_UNUSED(jUri);
+ OC_UNUSED(jQueryParamsMap);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "not support");
#endif
}
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(thiz);
+ OC_UNUSED(jQueryParamsMap);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "not support");
#endif
}
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(thiz);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "not support");
#endif
}
JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_requestMQPublishImpl
(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener, jint jQoS)
{
+ OC_UNUSED(thiz);
LOGD("OcResource_requestMQPublishImpl");
#ifdef MQ_SUBSCRIBER
if (!jQueryParamsMap)
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(jQueryParamsMap);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "not support");
#endif
}
(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap,
jobject jListener, jint jQoS)
{
+ OC_UNUSED(thiz);
LOGD("OcResource_publishMQTopicImpl");
#ifdef MQ_PUBLISHER
if (!jRepresentation)
ThrowOcException(e.code(), e.reason().c_str());
}
#else
+ OC_UNUSED(env);
+ OC_UNUSED(jRepresentation);
+ OC_UNUSED(jQueryParamsMap);
+ OC_UNUSED(jListener);
+ OC_UNUSED(jQoS);
ThrowOcException(JNI_NO_SUPPORT, "not support");
#endif
}
OCStackResult JniOcSecureResource::getLinkedDevices(JNIEnv *env, UuidList_t &uuidList)
{
+ OC_UNUSED(env);
return m_sharedSecureResource->getLinkedDevices(uuidList);
}
OCStackResult JniOcSecureResource::removeDevice(JNIEnv* env, jint timeout, jobject jListener)
{
+ if (timeout > USHRT_MAX)
+ {
+ return OC_STACK_INVALID_PARAM;
+ }
JniProvisionResultListner *resultListener = AddProvisionResultListener(env, jListener);
ResultCallBack resultCallback = [resultListener](PMResultList_t *result, int hasError)
resultListener->ProvisionResultCallback(result, hasError, ListenerFunc::REMOVEDEVICE);
};
- return m_sharedSecureResource->removeDevice((int)timeout, resultCallback);
+ return m_sharedSecureResource->removeDevice(static_cast<unsigned short>(timeout), resultCallback);
}
OCStackResult JniOcSecureResource::unlinkDevices(JNIEnv* env, jobject _device2, jobject jListener)
resultListener->ProvisionResultCallback(result, hasError, ListenerFunc::PROVISIONTRUSTCERTCHAIN);
};
- return m_sharedSecureResource->provisionTrustCertChain((OicSecCredType_t)type, credId,
- resultCallback);
+ return m_sharedSecureResource->provisionTrustCertChain((OicSecCredType_t)type,
+ static_cast<uint16_t>(credId), resultCallback);
}
#endif
pconf = new OicSecPconf_t;
memset(pconf, 0, sizeof(OicSecPconf_t));
- pconf->edp = edp;
+ pconf->edp = (edp != 0);
pconf->prmLen = prms.size();
pconf->prm = new OicSecPrm_t[pconf->prmLen];
pconf->pddevLen = 0;
- for (int i = 0 ; i < prms.size(); i++)
+ for (size_t i = 0 ; i < prms.size(); i++)
pconf->prm[i] = (OicSecPrm_t)prms[i];
memcpy(pconf->pin.val, pin.c_str(), DP_PIN_LENGTH);
OCStackResult JniOcSecureResource::addPreconfigPIN(JNIEnv* env, std::string pin, int size)
{
+ OC_UNUSED(env);
OCStackResult ret;
ret = m_sharedSecureResource->addPreconfigPIN(pin.c_str(), (size_t) size);
return ret;
try
{
+
OCStackResult result = secureResource->removeDevice(env, timeout, jListener);
if (OC_STACK_OK != result)
{
}
// JNI OnLoad
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM* vm, void* reserved)
{
+ OC_UNUSED(reserved);
LOGI("JNI_OnLoad");
JNIEnv* env = nullptr;
g_jvm = vm;
return JNI_CURRENT_VERSION;
}
-JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
+JNIEXPORT void JNICALL
+JNI_OnUnload(JavaVM *vm, void *reserved)
{
+ OC_UNUSED(reserved);
LOGI("JNI_OnUnload");
JNIEnv* env = nullptr;
jvalue argv[1];
tmp->recurrences = (char**)OICCalloc(jrecurrenceLen, sizeof(char*));
- for (int i = 0 ; i < jrecurrenceLen; i++)
+ for (int j = 0 ; j < jrecurrenceLen; j++)
{
- argv[0].i = i;
+ argv[0].i = j;
jData = (jstring)env->CallObjectMethodA(element, g_mid_OcOicSecAcl_validity_get_recurrences, argv);
if (!jData || env->ExceptionCheck())
{
return nullptr;
}
- tmp->recurrences[i] = (char*)env->GetStringUTFChars(jData, 0);
+ tmp->recurrences[j] = (char*)env->GetStringUTFChars(jData, 0);
}
}
if (NULL == valHead)
jvalue argv[1];
tmp->types = (char**)OICCalloc(len, sizeof(char*));
- for (int i = 0 ; i < len; i++)
+ for (int j = 0 ; j < len; j++)
{
- argv[0].i = i;
+ argv[0].i = j;
jData = (jstring)env->CallObjectMethodA(element, g_mid_OcOicSecAcl_resr_get_types, argv);
if (!jData || env->ExceptionCheck())
{
return nullptr;
}
- tmp->types[i] = (char*)env->GetStringUTFChars(jData, 0);
+ tmp->types[j] = (char*)env->GetStringUTFChars(jData, 0);
}
}
jvalue argv[1];
tmp->interfaces = (char**)OICCalloc(len, sizeof(char*));
- for (int i = 0 ; i < len; i++)
+ for (int j = 0 ; j < len; j++)
{
- argv[0].i = i;
+ argv[0].i = j;
jData = (jstring)env->CallObjectMethodA(element, g_mid_OcOicSecAcl_resr_get_interfaces, argv);
if (!jData || env->ExceptionCheck())
{
return nullptr;
}
- tmp->interfaces[i] = (char*)env->GetStringUTFChars(jData, 0);
+ tmp->interfaces[j] = (char*)env->GetStringUTFChars(jData, 0);
}
}
return OC_STACK_ERROR;
}
- pdacl->permission = jCount;
+ pdacl->permission = static_cast<uint16_t>(jCount);
jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecPdAcl_get_periods_cnt);
if (env->ExceptionCheck())
{
jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id);
jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data);
OC::HeaderOption::OCHeaderOption hopt(
- static_cast<int>(jId),
+ // jId comes from an enumerated list and should always fit in the
+ // down case uint16_t see getOptionId method
+ static_cast<uint16_t>(jId),
env->GetStringUTFChars(jData, nullptr));
headerOptions.push_back(hopt);
SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
jni_env = lib_env.Clone()
+rd_mode = jni_env.get('RD_MODE')
######################################################################
# Build flags
env.get('SRC_DIR') + '/resource/c_common/oic_string/include',
env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
env.get('SRC_DIR') + '/resource/csdk/include',
+ env.get('SRC_DIR') + '/resource/csdk/connectivity/inc',
+ env.get('SRC_DIR') + '/resource/csdk/connectivity/common/inc',
env.get('SRC_DIR') + '/resource/csdk/stack/include',
env.get('SRC_DIR') + '/resource/csdk/ocsocket/include',
env.get('SRC_DIR') + '/resource/csdk/resource-directory/include',
])
target_os = env.get('TARGET_OS')
-jni_env.AppendUnique(CCFLAGS=[
- '-Wno-error', '-Wno-comment', '-Wno-unused-function',
- '-Wno-unused-parameter'
-])
if target_os not in ['windows', 'winrt']:
+ jni_env.AppendUnique(CCFLAGS=[
+ '-Wno-error', '-Wno-comment', '-Wno-unused-function',
+ '-Wno-unused-parameter'
+ ])
jni_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-pthread'])
-
# Note: 'pthread' is in libc for android. On other platform, if use
# new gcc(>4.9?) it isn't required, otherwise, it's required
if target_os != 'android':
jni_env.AppendUnique(LIBS=['-lpthread'])
-
-jni_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR')])
+else:
+ # Disable the following warnings:
+ # - warning C4047: different levels of indirection
+ # - Disabled due un-avoidable error when using AttachCurrentThread
+ # - warning C4022: pointer missmatch for actual parameter
+ # - Disabled due un-avoidable error when using AttachCurrentThread
+ # - waring C4505: unreferenced local function has been removed
+ # - Disabled due to compiler incorrectly specifying JNI functions as
+ # unreferenced
+ jni_env.AppendUnique(CCFLAGS=['/wd4047', '/wd4022', '/wd4505',])
+jni_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR'), '#/exlibs/sqlite3'])
jni_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
+# make sure we link with the static oc library. This is important since Windows does not build a shared library for the oc library
+# The oc library can not be imported into the Java on all of the platfroms so must be statically linked to make Java code work on
+# all platforms.
jni_env.PrependUnique(LIBS=[
- 'resource_directory', 'oc', 'octbstack', 'oc_logger',
- 'connectivity_abstraction'
+ 'resource_directory',
+ 'oc_logger_internal',
+ 'coap',
+ 'octbstack_internal',
+ 'connectivity_abstraction_internal',
+ 'ocsrm',
+ 'routingmanager'
])
+
+if target_os not in ['windows', 'winrt']:
+ jni_env.PrependUnique(LIBS=['oc_internal'])
+else:
+ jni_env.PrependUnique(LIBS=[
+ 'oc',
+ 'mbedcrypto',
+ 'resource_directory_internal',
+ 'sqlite3'
+ ])
+
if env.get('SECURED') == '1':
jni_env.AppendUnique(CPPDEFINES=['__WITH_TLS__'])
- jni_env.PrependUnique(LIBS=['mbedtls', 'ocprovision', 'ocpmapi'])
- jni_env.AppendUnique(
- CPPPATH=['#resource/csdk/security/include/internal', '#extlibs/cjson'])
+ jni_env.PrependUnique(LIBS=['mbedtls', 'mbedx509', 'ocprovision'])
+ if target_os not in ['windows', 'winrt']:
+ jni_env.PrependUnique(LIBS=['ocpmapi'])
+ else:
+ jni_env.PrependUnique(LIBS=['ocpmapi_internal',])
+ jni_env.AppendUnique(CPPPATH=['#resource/csdk/security/include/internal',
+ '#extlibs/cjson'])
if env.get('WITH_CLOUD') == '1':
jni_env.AppendUnique(
CPPPATH=['#resource/csdk/security/provisioning/include/cloud'])
void CADeleteGlobalReferences(JNIEnv *env)
{
+ OC_UNUSED(env);
#ifdef __ANDROID__
if (g_Context)
{
# TODO: Add OC_EXPORT prefixes to enable DLL generation
oclib = oclib_env.StaticLibrary('oc', oclib_src)
else:
- oclib = oclib_env.SharedLibrary('oc', oclib_src)
+ oclib = oclib_env.StaticLibrary('oc_internal', oclib_src)
+ oclib += oclib_env.SharedLibrary('oc', oclib_src)
oclib_env.InstallTarget(oclib, 'oc')
oclib_env.UserInstallTargetLib(oclib, 'oc')
header_dir = os.path.join(oclib_env.get('SRC_DIR') , 'resource' , 'include') + os.sep
set UWP_APP=0
)
+if "%BUILD_JAVA%" == "" (
+ REM Do not build Java by default
+ set BUILD_JAVA=0
+)
+
set THREAD_COUNT=%NUMBER_OF_PROCESSORS%
set ROUTING=EP
IF /I "%1"=="-uwp" (
set UWP_APP=1
)
+ IF /I "%1"=="-java" (
+ set BUILD_JAVA=1
+ )
SHIFT
GOTO :processArgs
set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin
)
-set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% UWP_APP=%UWP_APP% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% LOG_LEVEL=%LOG_LEVEL% RD_MODE=%RD_MODE% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
+set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% UWP_APP=%UWP_APP% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% LOG_LEVEL=%LOG_LEVEL% RD_MODE=%RD_MODE% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE% BUILD_JAVA=%BUILD_JAVA%
REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015.
REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version.
echo MSVC_VERSION=%MSVC_VERSION%
echo THREAD_COUNT=%THREAD_COUNT%
echo AUTOMATIC_UPDATE=%AUTOMATIC_UPDATE%
+ echo BUILD_JAVA=%BUILD_JAVA%
REM First step:
REM - Generate coap.h, to avoid race conditions during second step below (see IOT-2376).
echo.
echo -uwp - Build for the Universal Windows Platform (UWP).
echo.
+echo -java - Build Java. The JDK path must be set in the JAVA_HOME environment variable.
+echo.
echo.
echo. Usage examples:
echo.