}
JNIEXPORT void JNICALL
-Java_org_iotivity_ca_service_RMInterface_RMInitialize(JNIEnv *env, jobject obj, jobject context)
+Java_org_iotivity_ca_service_RMInterface_RMInitialize(JNIEnv *env, jobject obj, jobject context,
+ jobject activity)
{
LOGI("RMInitialize");
- if (!env || !obj || !context)
+ if (!env || !obj || !context || !activity)
{
LOGI("Invalid input parameter");
return;
//Currently set context for Android Platform
CANativeJNISetContext(env, context);
+ CANativeSetActivity(env, activity);
CAResult_t res = CAInitialize();
free(requestData.payload);
free(requestData.resourceUri);
+ LOGI("send request success");
}
JNIEXPORT void JNICALL
CAResult_t res = get_network_type(selectedNetwork, &flags);
if (CA_STATUS_OK != res)
{
+ LOGE("Not supported network type");
return;
}
CAResult_t get_network_type(uint32_t selectedNetwork, CATransportFlags_t *flags)
{
+
uint32_t number = selectedNetwork;
- switch (number)
+ if (!(number & CA_ALL_ADAPTERS))
{
- case CA_ADAPTER_IP:
- *flags = CA_IPV4;
- case CA_ADAPTER_GATT_BTLE:
- case CA_ADAPTER_RFCOMM_BTEDR:
- case CA_ADAPTER_TCP:
- g_selectedNwType = number;
- return CA_STATUS_OK;
- default:
- return CA_NOT_SUPPORTED;
+ LOGE("get_network_type Out of range");
+ return CA_NOT_SUPPORTED;
+ }
+ if ((number & CA_ADAPTER_IP) == CA_ADAPTER_IP)
+ {
+ *flags = CA_IPV4;
+ g_selectedNwType = CA_ADAPTER_IP;
+ return CA_STATUS_OK;
+ }
+ if ((number & CA_ADAPTER_RFCOMM_BTEDR) == CA_ADAPTER_RFCOMM_BTEDR)
+ {
+ g_selectedNwType = CA_ADAPTER_RFCOMM_BTEDR;
+ return CA_STATUS_OK;
}
+ if ((number & CA_ADAPTER_GATT_BTLE) == CA_ADAPTER_GATT_BTLE)
+ {
+ g_selectedNwType = CA_ADAPTER_GATT_BTLE;
+ return CA_STATUS_OK;
+ }
+ if ((number & CA_ADAPTER_TCP) == CA_ADAPTER_TCP)
+ {
+ g_selectedNwType = CA_ADAPTER_TCP;
+ return CA_STATUS_OK;
+ }
+ if ((number & CA_ADAPTER_NFC) == CA_ADAPTER_NFC)
+ {
+ g_selectedNwType = CA_ADAPTER_NFC;
+ return CA_STATUS_OK;
+ }
+
+ LOGE("Invalid transport");
+ return CA_NOT_SUPPORTED;
}
void callback(char *subject, char *receivedData)
if (res == -1)
{
LOGE("address parse error");
-
return;
}
}
return;
}
+ CADeleteGlobalReferences(env);
(*env)->DeleteGlobalRef(env, g_responseListenerObject);
}