Commit 9584f0f3 authored by George Nash's avatar George Nash

Expose oc_cps_t and oc_cloud_discover_resources from cloud.h

Exposed oc_cps_t enum as OCCloudProvisioningStatus. Removed
the `OC_CPS_` prefix from the enums when exposed to Java.

The OCDiscoveryAllHandler typemap was moved from oc_api.i to
the iotivity.swg file so it can be picked up in oc_cloud.i
oc_api.i, and oc_obt.i files. Had to move the typemap instead
of importing oc_api.i to avoid name conflicts.

The oc_cloud_discover_resources was exposed as
OCCloud.discoverResources.
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parent 4e119e60
Pipeline #740 passed with stage
in 6 minutes and 26 seconds
......@@ -295,4 +295,23 @@ $2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
%typemap(jni) (const unsigned char * BYTE, size_t LENGTH) "jbyteArray"
%typemap(jtype) (const unsigned char * BYTE, size_t LENGTH) "byte[]"
%typemap(jstype) (const unsigned char * BYTE, size_t LENGTH) "byte[]"
%typemap(javain) (const unsigned char * BYTE, size_t LENGTH) "$javainput"
\ No newline at end of file
%typemap(javain) (const unsigned char * BYTE, size_t LENGTH) "$javainput"
/********************************************************************
* Code and typemaps for mapping the oc_discovery_all_handler_t to the
* java OCDiscoveryAllHandler
********************************************************************/
%typemap(jni) oc_discovery_all_handler_t handler "jobject";
%typemap(jtype) oc_discovery_all_handler_t handler "OCDiscoveryAllHandler";
%typemap(jstype) oc_discovery_all_handler_t handler "OCDiscoveryAllHandler";
%typemap(javain) oc_discovery_all_handler_t handler "$javainput";
%typemap(in,numinputs=1) (oc_discovery_all_handler_t handler, jni_callback_data *jcb) {
jni_callback_data *user_data = (jni_callback_data *)malloc(sizeof *user_data);
user_data->jenv = jenv;
user_data->jcb_obj = JCALL1(NewGlobalRef, jenv, $input);
// TODO figure out the lifetime of the oc_discovery_all_handler_t
user_data->cb_valid = OC_CALLBACK_VALID_UNKNOWN;
jni_list_add(user_data);
$1 = jni_oc_discovery_all_handler_callback;
$2 = user_data;
}
\ No newline at end of file
......@@ -1199,25 +1199,6 @@ jni_oc_discovery_handler_callback(const char *anchor, const char *uri,
$2 = user_data;
}
/*
* Code and typemaps for mapping the oc_do_ip_discovery and oc_do_ip_discovery_at_endpoint to the
* java OCDiscoveryHandler
*/
%typemap(jni) oc_discovery_all_handler_t handler "jobject";
%typemap(jtype) oc_discovery_all_handler_t handler "OCDiscoveryAllHandler";
%typemap(jstype) oc_discovery_all_handler_t handler "OCDiscoveryAllHandler";
%typemap(javain) oc_discovery_all_handler_t handler "$javainput";
%typemap(in,numinputs=1) (oc_discovery_all_handler_t handler, jni_callback_data *jcb) {
jni_callback_data *user_data = (jni_callback_data *)malloc(sizeof *user_data);
user_data->jenv = jenv;
user_data->jcb_obj = JCALL1(NewGlobalRef, jenv, $input);
// TODO figure out the lifetime of the oc_discovery_all_handler_t
user_data->cb_valid = OC_CALLBACK_VALID_UNKNOWN;
jni_list_add(user_data);
$1 = jni_oc_discovery_all_handler_callback;
$2 = user_data;
}
%ignore oc_do_site_local_ipv6_discovery;
%rename(doSiteLocalIPv6Discovery) jni_do_site_local_ipv6_discovery;
%inline %{
......
......@@ -2,6 +2,7 @@
%module OCCloud
%include "enums.swg"
%javaconst(1);
%include "iotivity.swg"
%include "stdint.i"
......@@ -92,7 +93,13 @@ static void jni_cloud_cb(oc_cloud_context_t *ctx, oc_cloud_status_t status, void
// oc_cloud_status is a bitmask exposed through OCCloudStatusMask.java as ints
%ignore oc_cloud_status_t;
%ignore oc_cps_t;
%rename (OCCloudPrivisoningStatus) oc_cps_t;
%rename (UNINITIALIZED) OC_CPS_UNINITIALIZED;
%rename (READYTOREGISTER) OC_CPS_READYTOREGISTER;
%rename (REGISTERING) OC_CPS_REGISTERING;
%rename (REGISTERED) OC_CPS_REGISTERED;
%rename (FAILED) OC_CPS_FAILED;
%rename (OCCloudStore) oc_cloud_store_t;
%rename (OCCloudError) oc_cloud_error_t;
%rename (OCCloudContext) oc_cloud_context_t;
......@@ -313,6 +320,29 @@ int jni_cloud_publish_resources(size_t device)
}
%}
%ignore oc_cloud_discover_resources;
%rename (discoverResources) jni_cloud_discover_resources;
%inline %{
int jni_cloud_discover_resources( oc_cloud_context_t *ctx,
oc_discovery_all_handler_t handler,
jni_callback_data *jcb)
{
#ifdef OC_CLOUD
OC_DBG("JNI: %s\n", __func__);
OC_DBG("JNI: - lock %s\n", __func__);
jni_mutex_lock(jni_sync_lock);
int return_value = oc_cloud_discover_resources(ctx, handler, jcb);
jni_mutex_unlock(jni_sync_lock);
OC_DBG("JNI: - unlock %s\n", __func__);
return return_value;
#else /* OC_CLOUD*/
OC_DBG("JNI: %s - Must build with OC_CLOUD defined to use this function.\n", __func__);
return -1;
#endif /* !OC_CLOUD */
}
%}
%ignore oc_cloud_provision_conf_resource;
%rename(provisionConfResource) jni_cloud_provision_conf_resource;
%inline %{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment