Commit 575936a8 authored by Javier Guerra Melgares's avatar Javier Guerra Melgares
parents 8107706c 2718e939
......@@ -46,7 +46,7 @@ mvn install:install-file \
-DgeneratePom=true
```
6. Add the following command, to link the previous libraries with iotivity.jar, in the run/debug configuration:
To run or to debug the OTGC application in an IDE, the following command as to be added as VM argument to link iotivity-lite library to the project:
```
-Djava.library.path=<otgc-linux>/lib/jni
```
......@@ -65,6 +65,9 @@ git checkout swig
2. Apply all patchs of the OTGC in IoTivity-lite
```
git apply <otgc-linux>/extlibs/patchs/remove_cred_by_credid.patch
git apply <otgc-linux>/extlibs/patchs/fix_config.patch
git apply <otgc-linux>/extlibs/patchs/bwt_fix.patch
git apply <otgc-linux>/extlibs/patchs/timeout_fix.patch
```
3. Go to the linux directory.
```
......@@ -137,12 +140,18 @@ To uninstall the aplication, use the next command:
sudo dpkg -r otgc
## script to build and install
the following command executes all steps indicated above for building and installing on Linux (ubuntu 16)
## Script to build and install
The following command executes all steps indicated above for building and installing on Linux (ubuntu 18)
curl https://openconnectivity.github.io/otgc-linux/setup.sh | bash
note: when the executable does start, please reinstall jfx manually by entering on the commandline:
sudo apt-get install openjfx=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2
and start otgc on the command line: /usr/bin/otgc.sh
For rasbian (stretch) use:
......
......@@ -11,7 +11,7 @@
# Constants
PROJECT_NAME="otgc"
VERSION="2.2.0"
VERSION="2.9.0"
program=$0
......@@ -117,7 +117,7 @@ else
echo "cd /usr/share/$PROJECT_NAME" >> "$(pwd)/out/$PROJECT_NAME.sh"
echo "mkdir logs"$'\n' >> "$(pwd)/out/$PROJECT_NAME.sh"
echo "DATE=\$(date +\"%Y%m%d%H%M\")"$'\n' >> "$(pwd)/out/$PROJECT_NAME.sh"
echo "java -jar /usr/lib/$PROJECT_NAME/$PROJECT_NAME-$VERSION-jfx.jar > logs/otgc_\$DATE.log"$'\n' >> "$(pwd)/out/$PROJECT_NAME.sh"
echo "java -Dprism.order=sw -jar /usr/lib/$PROJECT_NAME/$PROJECT_NAME-$VERSION-jfx.jar > logs/otgc_\$DATE.log"$'\n' >> "$(pwd)/out/$PROJECT_NAME.sh"
chmod 755 "$(pwd)/out/$PROJECT_NAME.sh"
cp "$(pwd)/out/$PROJECT_NAME.sh" $(pwd)/out/$PROJECT_NAME-$VERSION/usr/bin
rm $(pwd)/out/$PROJECT_NAME.sh
......
diff --git a/api/oc_server_api.c b/api/oc_server_api.c
index 198fef46..e94cbcb3 100644
--- a/api/oc_server_api.c
+++ b/api/oc_server_api.c
@@ -395,7 +395,13 @@ oc_send_separate_response(oc_separate_response_t *handle,
oc_string(cur->uri), oc_string_len(cur->uri), &cur->endpoint,
cur->method, NULL, 0, OC_BLOCKWISE_SERVER);
if (response_state) {
- goto next_separate_request;
+ if (response_state->payload_size ==
+ response_state->next_block_offset) {
+ oc_blockwise_free_response_buffer(response_state);
+ response_state = NULL;
+ } else {
+ continue;
+ }
}
response_state = oc_blockwise_alloc_response_buffer(
oc_string(cur->uri), oc_string_len(cur->uri), &cur->endpoint,
diff --git a/messaging/coap/engine.c b/messaging/coap/engine.c
index f7bcfce3..b7c1b91a 100644
--- a/messaging/coap/engine.c
+++ b/messaging/coap/engine.c
@@ -274,6 +274,15 @@ coap_receive(oc_message_t *msg)
href, href_len, &msg->endpoint, message->code, message->uri_query,
message->uri_query_len, OC_BLOCKWISE_SERVER);
+ if (request_buffer && request_buffer->payload_size ==
+ request_buffer->next_block_offset) {
+ if ((request_buffer->next_block_offset - incoming_block_len) !=
+ block1_offset) {
+ oc_blockwise_free_request_buffer(request_buffer);
+ request_buffer = NULL;
+ }
+ }
+
if (!request_buffer && block1_num == 0) {
OC_DBG("creating new block-wise request buffer");
request_buffer = oc_blockwise_alloc_request_buffer(
@@ -307,7 +316,6 @@ coap_receive(oc_message_t *msg)
block1_size);
request_buffer->payload_size =
request_buffer->next_block_offset;
- request_buffer->ref_count = 0;
goto request_handler;
}
}
@@ -325,6 +333,13 @@ coap_receive(oc_message_t *msg)
response_buffer = oc_blockwise_find_response_buffer(
href, href_len, &msg->endpoint, message->code, message->uri_query,
message->uri_query_len, OC_BLOCKWISE_SERVER);
+
+ if (response_buffer && (response_buffer->next_block_offset -
+ block2_offset) > block2_size) {
+ oc_blockwise_free_response_buffer(response_buffer);
+ response_buffer = NULL;
+ }
+
if (response_buffer) {
OC_DBG("continuing ongoing block-wise transfer");
uint32_t payload_size = 0;
@@ -342,7 +357,6 @@ coap_receive(oc_message_t *msg)
(oc_blockwise_response_state_t *)response_buffer;
coap_set_header_etag(response, response_state->etag,
COAP_ETAG_LEN);
- response_buffer->ref_count = more;
goto send_message;
} else {
OC_ERR("could not dispatch block");
@@ -410,6 +424,13 @@ coap_receive(oc_message_t *msg)
request_buffer->payload_size = incoming_block_len;
request_buffer->ref_count = 0;
}
+ response_buffer = oc_blockwise_find_response_buffer(
+ href, href_len, &msg->endpoint, message->code, message->uri_query,
+ message->uri_query_len, OC_BLOCKWISE_SERVER);
+ if (response_buffer) {
+ oc_blockwise_free_response_buffer(response_buffer);
+ response_buffer = NULL;
+ }
goto request_handler;
} else {
OC_ERR("incoming payload size exceeds block size");
diff --git a/messaging/coap/observe.c b/messaging/coap/observe.c
index 62192fa5..2847d526 100644
--- a/messaging/coap/observe.c
+++ b/messaging/coap/observe.c
@@ -313,7 +313,12 @@ coap_notify_collection_observers(oc_resource_t *resource,
oc_string_len(obs->resource->uri) - 1, &obs->endpoint, OC_GET, NULL, 0,
OC_BLOCKWISE_SERVER);
if (response_state) {
- continue;
+ if (response_state->payload_size == response_state->next_block_offset) {
+ oc_blockwise_free_response_buffer(response_state);
+ response_state = NULL;
+ } else {
+ continue;
+ }
}
response_state = oc_blockwise_alloc_response_buffer(
oc_string(obs->resource->uri) + 1,
@@ -480,8 +485,7 @@ coap_remove_observers_on_dos_change(size_t device, bool reset)
coap_observer_t *obs = (coap_observer_t *)oc_list_head(observers_list);
while (obs != NULL) {
if (obs->endpoint.device == device &&
- (reset ||
- !oc_sec_check_acl(OC_GET, obs->resource, &obs->endpoint))) {
+ (reset || !oc_sec_check_acl(OC_GET, obs->resource, &obs->endpoint))) {
coap_observer_t *o = obs;
coap_packet_t notification[1];
#ifdef OC_TCP
@@ -638,7 +642,13 @@ coap_notify_observers(oc_resource_t *resource,
oc_string_len(obs->resource->uri) - 1, &obs->endpoint, OC_GET,
NULL, 0, OC_BLOCKWISE_SERVER);
if (response_state) {
- continue;
+ if (response_state->payload_size ==
+ response_state->next_block_offset) {
+ oc_blockwise_free_response_buffer(response_state);
+ response_state = NULL;
+ } else {
+ continue;
+ }
}
response_state = oc_blockwise_alloc_response_buffer(
oc_string(obs->resource->uri) + 1,
diff --git a/port/linux/oc_config.h b/port/linux/oc_config.h
index 8e801156..7c8fbd78 100644
--- a/port/linux/oc_config.h
+++ b/port/linux/oc_config.h
@@ -34,7 +34,7 @@ typedef uint64_t oc_clock_time_t;
/* Add support for the oic.if.create interface in Collections */
#define OC_COLLECTIONS_IF_CREATE
/* Add support for the maintenance resource */
-#define OC_MNT
+//#define OC_MNT
/* If we selected support for dynamic memory allocation */
#ifdef OC_DYNAMIC_ALLOCATION
#define OC_COLLECTIONS
diff --git a/include/oc_pki.h b/include/oc_pki.h
index acbab8c..c16b512 100644
index acbab8c7..c16b512b 100644
--- a/include/oc_pki.h
+++ b/include/oc_pki.h
@@ -45,6 +45,9 @@ int oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
......@@ -13,10 +13,10 @@ index acbab8c..c16b512 100644
}
#endif
diff --git a/security/oc_pki.c b/security/oc_pki.c
index a9306c2..c9b3b15 100644
index a9306c23..52755576 100644
--- a/security/oc_pki.c
+++ b/security/oc_pki.c
@@ -354,6 +354,16 @@ oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
@@ -354,6 +354,17 @@ oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
return pki_add_trust_anchor(device, cert, cert_size, OC_CREDUSAGE_TRUSTCA);
}
......@@ -27,6 +27,7 @@ index a9306c2..c9b3b15 100644
+ if (cred)
+ {
+ oc_sec_remove_cred(cred, device);
+ oc_sec_dump_cred(device);
+ }
+}
+
......@@ -34,7 +35,7 @@ index a9306c2..c9b3b15 100644
typedef int dummy_declaration;
#endif /* !OC_PKI */
diff --git a/swig/swig_interfaces/oc_pki.i b/swig/swig_interfaces/oc_pki.i
index 2765e56..9910770 100644
index 2765e562..9910770c 100644
--- a/swig/swig_interfaces/oc_pki.i
+++ b/swig/swig_interfaces/oc_pki.i
@@ -105,4 +105,6 @@ void jni_pki_set_security_profile(size_t device,
......
diff --git a/onboarding_tool/obtmain.c b/onboarding_tool/obtmain.c
index 65bf47fa..a4b066ad 100644
--- a/onboarding_tool/obtmain.c
+++ b/onboarding_tool/obtmain.c
@@ -301,7 +301,7 @@ unowned_device_cb(oc_uuid_t *uuid, oc_endpoint_t *eps, void *data)
eps = eps->next;
}
- oc_do_get("/oic/d", ep, NULL, &get_device, LOW_QOS, unowned_devices);
+ oc_do_get("/oic/d", ep, NULL, &get_device, HIGH_QOS, unowned_devices);
}
static void
@@ -319,7 +319,7 @@ owned_device_cb(oc_uuid_t *uuid, oc_endpoint_t *eps, void *data)
eps = eps->next;
}
- oc_do_get("/oic/d", ep, NULL, &get_device, LOW_QOS, owned_devices);
+ oc_do_get("/oic/d", ep, NULL, &get_device, HIGH_QOS, owned_devices);
}
static void
@@ -1270,9 +1270,9 @@ main(void)
int init;
- static const oc_handler_t handler = {.init = app_init,
- .signal_event_loop = signal_event_loop,
- .requests_entry = issue_requests };
+ static const oc_handler_t handler = { .init = app_init,
+ .signal_event_loop = signal_event_loop,
+ .requests_entry = issue_requests };
oc_storage_config("./onboarding_tool_creds");
oc_set_factory_presets_cb(factory_presets_cb, NULL);
diff --git a/security/oc_obt.c b/security/oc_obt.c
index b6c28499..ebcc8320 100644
--- a/security/oc_obt.c
+++ b/security/oc_obt.c
@@ -358,17 +358,9 @@ free_otm_state(oc_otm_ctx_t *o, int status, oc_obt_otm_t otm)
oc_memb_free(&oc_otm_ctx_m, o);
}
-oc_event_callback_retval_t
-oc_obt_otm_request_timeout_cb(void *data)
-{
- free_otm_state(data, -1, 0);
- return OC_EVENT_DONE;
-}
-
void
oc_obt_free_otm_ctx(oc_otm_ctx_t *ctx, int status, oc_obt_otm_t otm)
{
- oc_remove_delayed_callback(ctx, oc_obt_otm_request_timeout_cb);
free_otm_state(ctx, status, otm);
}
@@ -772,13 +764,6 @@ free_hard_reset_ctx(oc_hard_reset_ctx_t *ctx, int status)
oc_memb_free(&oc_hard_reset_ctx_m, ctx);
}
-static oc_event_callback_retval_t
-hard_reset_timeout_cb(void *data)
-{
- free_hard_reset_ctx(data, -1);
- return OC_EVENT_DONE;
-}
-
static void
hard_reset_cb(int status, void *data)
{
@@ -787,7 +772,6 @@ hard_reset_cb(int status, void *data)
return;
}
d->switch_dos = NULL;
- oc_remove_delayed_callback(data, hard_reset_timeout_cb);
free_hard_reset_ctx(data, status);
}
@@ -821,7 +805,6 @@ oc_obt_device_hard_reset(oc_uuid_t *uuid, oc_obt_device_status_cb_t cb,
}
oc_list_add(oc_hard_reset_ctx_l, d);
- oc_set_delayed_callback(d, hard_reset_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
@@ -855,17 +838,9 @@ free_credprov_state(oc_credprov_ctx_t *p, int status)
oc_memb_free(&oc_credprov_ctx_m, p);
}
-static oc_event_callback_retval_t
-credprov_request_timeout_cb(void *data)
-{
- free_credprov_state(data, -1);
- return OC_EVENT_DONE;
-}
-
static void
free_credprov_ctx(oc_credprov_ctx_t *ctx, int status)
{
- oc_remove_delayed_callback(ctx, credprov_request_timeout_cb);
free_credprov_state(ctx, status);
}
@@ -1382,7 +1357,6 @@ oc_obt_provision_role_certificate(oc_role_t *roles, oc_uuid_t *uuid,
}
oc_list_add(oc_credprov_ctx_l, p);
- oc_set_delayed_callback(p, credprov_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
@@ -1431,7 +1405,6 @@ oc_obt_provision_identity_certificate(oc_uuid_t *uuid, oc_obt_status_cb_t cb,
}
oc_list_add(oc_credprov_ctx_l, p);
- oc_set_delayed_callback(p, credprov_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
@@ -1479,7 +1452,6 @@ oc_obt_provision_pairwise_credentials(oc_uuid_t *uuid1, oc_uuid_t *uuid2,
}
oc_list_add(oc_credprov_ctx_l, p);
- oc_set_delayed_callback(p, credprov_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
@@ -1683,17 +1655,9 @@ free_acl2prov_state(oc_acl2prov_ctx_t *request, int status)
oc_memb_free(&oc_acl2prov_m, request);
}
-static oc_event_callback_retval_t
-acl2prov_timeout_cb(void *data)
-{
- free_acl2prov_state(data, -1);
- return OC_EVENT_DONE;
-}
-
static void
free_acl2prov_ctx(oc_acl2prov_ctx_t *r, int status)
{
- oc_remove_delayed_callback(r, acl2prov_timeout_cb);
free_acl2prov_state(r, status);
}
@@ -1861,7 +1825,6 @@ oc_obt_provision_ace(oc_uuid_t *uuid, oc_sec_ace_t *ace,
}
oc_list_add(oc_acl2prov_l, r);
- oc_set_delayed_callback(r, acl2prov_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
diff --git a/security/oc_obt_internal.h b/security/oc_obt_internal.h
index d2f0dd3d..9d4d7f71 100644
--- a/security/oc_obt_internal.h
+++ b/security/oc_obt_internal.h
@@ -28,9 +28,7 @@ extern "C"
{
#endif
-#define DISCOVERY_CB_PERIOD (5)
-/* Worst case timeout for all onboarding/provisioning sequences */
-#define OBT_CB_TIMEOUT (15)
+#define DISCOVERY_CB_PERIOD (60)
/* Used for tracking owned/unowned devices in oc_obt's internal caches */
typedef struct oc_device_t
diff --git a/security/oc_obt_otm_cert.c b/security/oc_obt_otm_cert.c
index 062b38cb..0f511a64 100644
--- a/security/oc_obt_otm_cert.c
+++ b/security/oc_obt_otm_cert.c
@@ -396,7 +396,7 @@ obt_cert_7(oc_client_response_t *data)
}
/** 7) post acl rowneruuid
- */
+ */
oc_device_t *device = o->device;
oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint);
@@ -648,7 +648,6 @@ oc_obt_perform_cert_otm(oc_uuid_t *uuid, oc_obt_device_status_cb_t cb,
*/
oc_endpoint_t *ep = oc_obt_get_unsecure_endpoint(device->endpoint);
if (oc_do_get("/oic/d", ep, NULL, &obt_cert_2, HIGH_QOS, o)) {
- oc_set_delayed_callback(o, oc_obt_otm_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
diff --git a/security/oc_obt_otm_justworks.c b/security/oc_obt_otm_justworks.c
index c1ea607e..f4ffeaab 100644
--- a/security/oc_obt_otm_justworks.c
+++ b/security/oc_obt_otm_justworks.c
@@ -395,7 +395,7 @@ obt_jw_7(oc_client_response_t *data)
}
/** 7) post acl rowneruuid
- */
+ */
oc_device_t *device = o->device;
oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint);
@@ -647,7 +647,6 @@ oc_obt_perform_just_works_otm(oc_uuid_t *uuid, oc_obt_device_status_cb_t cb,
*/
oc_endpoint_t *ep = oc_obt_get_unsecure_endpoint(device->endpoint);
if (oc_do_get("/oic/d", ep, NULL, &obt_jw_2, HIGH_QOS, o)) {
- oc_set_delayed_callback(o, oc_obt_otm_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
diff --git a/security/oc_obt_otm_randompin.c b/security/oc_obt_otm_randompin.c
index 98fb7b1e..b1d03198 100644
--- a/security/oc_obt_otm_randompin.c
+++ b/security/oc_obt_otm_randompin.c
@@ -396,7 +396,7 @@ obt_rdp_6(oc_client_response_t *data)
}
/** 6) post acl rowneruuid
- */
+ */
oc_device_t *device = o->device;
oc_endpoint_t *ep = oc_obt_get_secure_endpoint(device->endpoint);
@@ -645,7 +645,6 @@ oc_obt_perform_random_pin_otm(oc_uuid_t *uuid, const unsigned char *pin,
oc_tls_close_connection(ep);
oc_tls_select_psk_ciphersuite();
if (oc_do_get("/oic/d", ep, NULL, &obt_rdp_2, HIGH_QOS, o)) {
- oc_set_delayed_callback(o, oc_obt_otm_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
@@ -718,7 +717,6 @@ oc_obt_request_random_pin(oc_uuid_t *uuid, oc_obt_device_status_cb_t cb,
oc_rep_set_int(root, oxmsel, 1);
oc_rep_end_root_object();
if (oc_do_post()) {
- oc_set_delayed_callback(o, oc_obt_otm_request_timeout_cb, OBT_CB_TIMEOUT);
return 0;
}
}
diff --git a/security/oc_tls.c b/security/oc_tls.c
index ba25168f..983ecbe2 100644
--- a/security/oc_tls.c
+++ b/security/oc_tls.c
@@ -338,6 +338,7 @@ oc_tls_inactive(void *data)
return OC_EVENT_CONTINUE;
}
mbedtls_ssl_close_notify(&peer->ssl_ctx);
+ mbedtls_ssl_close_notify(&peer->ssl_ctx);
oc_tls_free_peer(peer, true);
}
OC_DBG("oc_tls: Terminating DTLS inactivity callback");
@@ -1292,6 +1293,7 @@ oc_tls_close_connection(oc_endpoint_t *endpoint)
{
oc_tls_peer_t *peer = oc_tls_get_peer(endpoint);
if (peer) {
+ mbedtls_ssl_close_notify(&peer->ssl_ctx);
mbedtls_ssl_close_notify(&peer->ssl_ctx);
oc_tls_free_peer(peer, false);
}
@@ -1687,6 +1689,7 @@ read_application_data(oc_tls_peer_t *peer)
if (peer->role == MBEDTLS_SSL_IS_SERVER &&
(peer->endpoint.flags & TCP) == 0) {
mbedtls_ssl_close_notify(&peer->ssl_ctx);
+ mbedtls_ssl_close_notify(&peer->ssl_ctx);
}
oc_tls_free_peer(peer, false);
return;
......@@ -6,7 +6,7 @@
<groupId>otgc</groupId>
<artifactId>otgc</artifactId>
<version>2.2.0</version>
<version>2.9.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -28,9 +28,9 @@ sudo apt-get -y install openjfx
sudo apt-get -y install libopenjfx-jni
sudo apt-get -y install libopenjfx-java
# install downgraded java components
sudo apt-get -y install openjfx=8u161-b12-1ubuntu2
sudo apt-get -y install libopenjfx-java=8u161-b12-1ubuntu2
sudo apt-get -y install libopenjfx-jni=8u161-b12-1ubuntu2
sudo apt-get -y install openjfx=8u161-b12-1ubuntu2 --allow-downgrades
sudo apt-get -y install libopenjfx-java=8u161-b12-1ubuntu2 --allow-downgrades
sudo apt-get -y install libopenjfx-jni=8u161-b12-1ubuntu2 --allow-downgrades
rm -rf otgc-linux
git clone https://github.com/openconnectivity/otgc-linux.git
......
......@@ -2,14 +2,14 @@
set -x #echo on
# build setup script to be used with an curl command
#
OTGC_VERSION=2.2.0
OTGC_VERSION=2.9.0
#
# system update
#
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y update
#sudo apt-get -y update
#sudo apt-get -y upgrade
#sudo apt-get -y update
# make sure that git is there, because the scripts are using git.
# nano is just good to have,
......@@ -29,13 +29,16 @@ sudo apt-get -y install swig
#
sudo apt-get -y install openjdk-8-jdk
# install java components, but later overwrite them with the downgraded versions if they exist on the system
sudo apt-get -y install openjfx
sudo apt-get -y install libopenjfx-jni
sudo apt-get -y install libopenjfx-java
#sudo apt-get -y install openjfx
#sudo apt-get -y install libopenjfx-jni
#sudo apt-get -y install libopenjfx-java
# install downgraded java components
sudo apt-get -y install openjfx=8u161-b12-1ubuntu2
sudo apt-get -y install libopenjfx-java=8u161-b12-1ubuntu2
sudo apt-get -y install libopenjfx-jni=8u161-b12-1ubuntu2
sudo apt-get -y autoremove openjfx
sudo apt-get -y autoremove libopenjfx-java
sudo apt-get -y autoremove libopenjfx-jni
sudo apt-get -y install openjfx=8u161-b12-1ubuntu2 --allow-downgrades
sudo apt-get -y install libopenjfx-java=8u161-b12-1ubuntu2 --allow-downgrades
sudo apt-get -y install libopenjfx-jni=8u161-b12-1ubuntu2 --allow-downgrades
rm -rf otgc-linux
git clone https://github.com/openconnectivity/otgc-linux.git
......@@ -81,6 +84,8 @@ cp ./iotivity-lite/swig/iotivity-lite-java/libs/*.jar ./otgc-linux/lib/.
#
cd otgc-linux
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
# install the create lib, so that maven can find it during the build
mvn install:install-file \
-Dfile=lib/iotivity-lite.jar \
......
......@@ -62,8 +62,9 @@ public class DoxsRepository {
} else if (oxm == OcfOxmType.OC_OXMTYPE_RDP) {
ret = OCObt.requestRandomPin(uuid, (OCUuid ocUuid, int status) -> {
if (status >= 0) {
LOG.debug("Successfully request Random PIN " + OCUuidUtil.uuidToString(ocUuid));
String pin = randomPinHandler.handler();
String id = OCUuidUtil.uuidToString(ocUuid);
LOG.debug("Successfully request Random PIN " + id);
String pin = randomPinHandler.handler(id);
if (OCObt.performRandomPinOtm(uuid, pin, handler) != -1){
emitter.onComplete();
} else {
......
......@@ -162,7 +162,10 @@ public class IotivityRepository {
deviceDao.insert(new DeviceEntity(deviceId, device.getName(), endpoints, DeviceType.UNOWNED, Device.NOTHING_PERMITS));
}
unownedDevices.add(new Device(DeviceType.UNOWNED, deviceId, new OcDeviceInfo(), endpoints, Device.NOTHING_PERMITS));
Device device1 = new Device(DeviceType.UNOWNED, deviceId, new OcDeviceInfo(), endpoints, Device.NOTHING_PERMITS);
if (!unownedDevices.contains(device1)) {
unownedDevices.add(device1);
}
};
int ret;
......@@ -202,7 +205,10 @@ public class IotivityRepository {
deviceDao.insert(new DeviceEntity(deviceId, device.getName(), endpoints, DeviceType.OWNED_BY_SELF, Device.FULL_PERMITS));
}
ownedDevices.add(new Device(DeviceType.OWNED_BY_SELF, deviceId, new OcDeviceInfo(), endpoints, Device.FULL_PERMITS));
Device device1 = new Device(DeviceType.OWNED_BY_SELF, deviceId, new OcDeviceInfo(), endpoints, Device.FULL_PERMITS);
if (!ownedDevices.contains(device1)) {
ownedDevices.add(device1);
}
};
int ret;
......@@ -568,6 +574,38 @@ public class IotivityRepository {
});
}
public Completable post(String host, String uri, String deviceId, Map<String, Object> values) {
return Completable.create(emitter -> {
OCEndpoint ep = OCEndpointUtil.stringToEndpoint(host, new String[1]);
OCUuid uuid = OCUuidUtil.stringToUuid(deviceId);
OCEndpointUtil.setDi(ep, uuid);
OCResponseHandler handler = (OCClientResponse response) -> {
OCStatus code = response.getCode();
if (code == OCStatus.OC_STATUS_OK
|| code == OCStatus.OC_STATUS_CHANGED) {
emitter.onComplete();
} else {
emitter.onError(new Exception("POST " + uri + " error - code: " + code));
}
};
if (OCMain.initPost(uri, ep, null, handler, OCQos.HIGH_QOS)) {
CborEncoder root = OCRep.beginRootObject();
parseOCRepresentionToCbor(root, values);
OCRep.endRootObject();
if (!OCMain.doPost()) {
emitter.onError(new Exception("Do POST " + uri + " error"));
}
} else {
emitter.onError(new Exception("Init POST " + uri + " error"));