Commit b4e4d805 authored by George Nash's avatar George Nash Committed by Rick Bell

Add obt random pin functions to Java

- simplified the swig interface code for oc_obt_init
- added oc_obt_shutdown to swig interface file
- added oc_obt_request_random_pin function
- added oc_obt_perform_random_pin_otm function
	- pin and pin_len are exposed as a single java string

Change-Id: Iabe3c82925a7ed0391a7270a2789c1bfa4c32953
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/29401Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: Larry Sachs's avatarLarry Sachs <larry.j.sachs@intel.com>
Reviewed-by: default avatarRick Bell <richard.s.bell@intel.com>
parent 092c4cb5
...@@ -30,13 +30,8 @@ ...@@ -30,13 +30,8 @@
JCALL1(GetJavaVM, jenv, &jvm); JCALL1(GetJavaVM, jenv, &jvm);
} }
%ignore oc_obt_init; %rename(init) oc_obt_init;
%rename(init) jni_obt_init; %rename(shutdown) oc_obt_shutdown;
%inline %{
void jni_obt_init(void* dummy) {
oc_obt_init();
}
%}
/* code and typemaps for mapping the oc_obt_discover_cb to the java OCObtDiscoveryHandler */ /* code and typemaps for mapping the oc_obt_discover_cb to the java OCObtDiscoveryHandler */
%{ %{
...@@ -202,6 +197,51 @@ int jni_obt_perform_just_works_otm(oc_uuid_t *uuid, oc_obt_device_status_cb_t ca ...@@ -202,6 +197,51 @@ int jni_obt_perform_just_works_otm(oc_uuid_t *uuid, oc_obt_device_status_cb_t ca
} }
%} %}
%ignore oc_obt_request_random_pin;
%rename(requestRandomPin) jni_obt_request_random_pin;
%inline %{
int jni_obt_request_random_pin(oc_uuid_t *uuid, oc_obt_device_status_cb_t callback, jni_callback_data *jcb)
{
OC_DBG("JNI: %s\n", __func__);
OC_DBG("JNI: - lock %s\n", __func__);
jni_mutex_lock(jni_sync_lock);
int return_value = oc_obt_request_random_pin(uuid, callback, jcb);
jni_mutex_unlock(jni_sync_lock);
OC_DBG("JNI: - unlock %s\n", __func__);
return return_value;
}
%}
/* For oc_obt_perform_random_pin_otm use Java String as the pin input.
Use the Java String length to input the pin_len */
%typemap(in,numinputs=1) (const char *pin, size_t pin_len)
{
$1 = ($1_type)JCALL2(GetStringUTFChars, jenv, $input, 0);
$2 = ($2_type)JCALL1(GetStringUTFLength, jenv, $input);
}
%typemap(freearg,numinputs=1) (const char *pin, size_t pin_len)
{
JCALL2(ReleaseStringUTFChars, jenv, $input, $1);
}
%ignore oc_obt_perform_random_pin_otm;
%rename(performRandomPinOtm) jni_obt_perform_random_pin_otm;
%inline %{
int jni_obt_perform_random_pin_otm(oc_uuid_t *uuid, const char *pin, size_t pin_len,
oc_obt_device_status_cb_t callback, jni_callback_data *jcb)
{
OC_DBG("JNI: %s\n", __func__);
OC_DBG("JNI: - lock %s\n", __func__);
jni_mutex_lock(jni_sync_lock);
int return_value = oc_obt_perform_random_pin_otm(uuid, (const unsigned char*)pin, pin_len, callback, jcb);
jni_mutex_unlock(jni_sync_lock);
OC_DBG("JNI: - unlock %s\n", __func__);
return return_value;
}
%}
%ignore oc_obt_device_hard_reset; %ignore oc_obt_device_hard_reset;
%rename(deviceHardReset) jni_obt_device_hard_reset; %rename(deviceHardReset) jni_obt_device_hard_reset;
%inline %{ %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