platformConfig.getIpAddress(),
platformConfig.getPort(),
platformConfig.getQualityOfService().getValue(),
- platformConfig.getSvrDbPath()
+ platformConfig.getSvrDbPath(),
+ platformConfig.getAvailableTransportType()
);
sIsPlatformInitialized = true;
String ipAddress,
int port,
int qualityOfService,
- String dbPath);
+ String dbPath,
+ int transport);
/**
* API for stop all process of the OcPlatform.
import android.content.Context;
import android.app.Activity;
-
+import java.util.EnumSet;
/**
* Data structure to provide the configuration.
*/
private QualityOfService mQualityOfService;
private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage.
//this is only for 0.9.2
+ private int mTransportType;
/**
* @param activity app activity
* @param context app context
this.mPort = port;
this.mQualityOfService = qualityOfService;
this.mSvrDbPath = dbPath;
+ this.mTransportType = 0;
}
/**
return mActivity;
}
+ public void setAvailableTransportType(EnumSet<OcConnectivityType> type) {
+ for (OcConnectivityType connType : OcConnectivityType.values()) {
+ if (type.contains(connType))
+ mTransportType |= connType.getValue();
+ }
+ }
+
+ public int getAvailableTransportType() {
+ return mTransportType;
+ }
}
platformConfig.getIpAddress(),
platformConfig.getPort(),
platformConfig.getQualityOfService().getValue(),
- platformConfig.getSvrDbPath()
+ platformConfig.getSvrDbPath(),
+ platformConfig.getAvailableTransportType()
);
sIsPlatformInitialized = true;
String ipAddress,
int port,
int qualityOfService,
- String dbPath);
+ String dbPath,
+ int transport);
/**
* API for stop all process of the OcPlatform.
package org.iotivity.base;
+import java.util.EnumSet;
+
/**
* Data structure to provide the configuration.
*/
private QualityOfService mQualityOfService;
private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage.
//this is only for 0.9.2
+ private int mTransportType;
/**
* @param serviceType indicate IN_PROC or OUT_OF_PROC
* @param modeType indicate whether we want to do server, client or both
this.mPort = port;
this.mQualityOfService = qualityOfService;
this.mSvrDbPath = dbPath;
+ this.mTransportType = 0;
}
/**
return mSvrDbPath;
}
+ public void setAvailableTransportType(EnumSet<OcConnectivityType> type) {
+ for (OcConnectivityType connType : OcConnectivityType.values()) {
+ if (type.contains(connType))
+ mTransportType |= connType.getValue();
+ }
+ }
+
+ public int getAvailableTransportType() {
+ return mTransportType;
+ }
}
/*
* Class: org_iotivity_base_OcPlatform
* Method: configure
-* Signature: (IILjava/lang/String;II)V
+* Signature: (IILjava/lang/String;IILjava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure
(JNIEnv *env, jclass clazz, jint jServiceType, jint jModeType, jstring jIpAddress, jint jPort,
- jint jQOS, jstring jDbPath)
+ jint jQOS, jstring jDbPath, jint jTransport)
{
LOGI("OcPlatform_configure");
JniUtils::getModeType(env, jModeType),
ipAddress,
port,
+ JniUtils::getOCTransportAdapter(jTransport),
JniUtils::getQOS(env, static_cast<int>(jQOS)),
JniOcSecurity::getOCPersistentStorage()
};
/*
* Class: org_iotivity_base_OcPlatform
* Method: configure
- * Signature: (IILjava/lang/String;II)V
+ * Signature: (IILjava/lang/String;IILjava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure
- (JNIEnv *, jclass, jint, jint, jstring, jint, jint, jstring);
+ (JNIEnv *, jclass, jint, jint, jstring, jint, jint, jstring, jint);
/*
* Class: org_iotivity_base_OcPlatform
}
}
+ static OCTransportAdapter getOCTransportAdapter(int adapter)
+ {
+ int transport = OCTransportAdapter::OC_DEFAULT_ADAPTER;
+ if (adapter & CT_ADAPTER_IP)
+ {
+ transport |= OCTransportAdapter::OC_ADAPTER_IP;
+ }
+
+ if (adapter & CT_ADAPTER_GATT_BTLE)
+ {
+ transport |= OCTransportAdapter::OC_ADAPTER_GATT_BTLE;
+ }
+
+ if (adapter & CT_ADAPTER_RFCOMM_BTEDR)
+ {
+ transport |= OCTransportAdapter::OC_ADAPTER_RFCOMM_BTEDR;
+ }
+
+ if (adapter & CT_ADAPTER_TCP)
+ {
+ transport |= OCTransportAdapter::OC_ADAPTER_TCP;
+ }
+
+ if (adapter & CT_ADAPTER_NFC)
+ {
+ transport |= OCTransportAdapter::OC_ADAPTER_NFC;
+ }
+ return (OCTransportAdapter)transport;
+ }
+
static std::string stackResultToStr(const int result)
{
switch (result)
{}
PlatformConfig(const ServiceType serviceType_,
const ModeType mode_,
+ const std::string& ipAddress_,
+ const uint16_t port_,
+ const OCTransportAdapter transportType_,
+ const QualityOfService QoS_,
+ OCPersistentStorage *ps_ = nullptr)
+ : serviceType(serviceType_),
+ mode(mode_),
+ serverConnectivity(CT_DEFAULT),
+ clientConnectivity(CT_DEFAULT),
+ transportType(transportType_),
+ ipAddress(ipAddress_),
+ port(port_),
+ QoS(QoS_),
+ ps(ps_)
+ {}
+ PlatformConfig(const ServiceType serviceType_,
+ const ModeType mode_,
OCTransportAdapter transportType_,
const QualityOfService QoS_,
OCPersistentStorage *ps_ = nullptr)