You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/01/30 06:51:42 UTC

[GitHub] mkiiskila closed pull request #777: Configurable client response time, variable size oc_endpoint.

mkiiskila closed pull request #777: Configurable client response time, variable size oc_endpoint.
URL: https://github.com/apache/mynewt-core/pull/777
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/kernel/os/src/os_mempool.c b/kernel/os/src/os_mempool.c
index 214482b34..07aaf9a99 100644
--- a/kernel/os/src/os_mempool.c
+++ b/kernel/os/src/os_mempool.c
@@ -323,6 +323,9 @@ os_memblock_put(struct os_mempool *mp, void *block_addr)
 {
     struct os_mempool_ext *mpe;
     int rc;
+#if MYNEWT_VAL(OS_MEMPOOL_CHECK)
+    struct os_memblock *block;
+#endif
 
     /* Make sure parameters are valid */
     if ((mp == NULL) || (block_addr == NULL)) {
diff --git a/net/oic/include/oic/messaging/coap/constants.h b/net/oic/include/oic/messaging/coap/constants.h
index 6279a1727..8da74011e 100644
--- a/net/oic/include/oic/messaging/coap/constants.h
+++ b/net/oic/include/oic/messaging/coap/constants.h
@@ -41,7 +41,7 @@ extern "C" {
 #define COAP_DEFAULT_PORT 5683
 
 #define COAP_DEFAULT_MAX_AGE 60
-#define COAP_RESPONSE_TIMEOUT 2
+#define COAP_RESPONSE_TIMEOUT MYNEWT_VAL(OC_COAP_RESPONSE_TIMEOUT)
 #define COAP_RESPONSE_RANDOM_FACTOR 1.5
 #define COAP_MAX_RETRANSMIT 4
 
diff --git a/net/oic/include/oic/port/mynewt/transport.h b/net/oic/include/oic/port/mynewt/transport.h
index dcd80a0fa..46667deff 100644
--- a/net/oic/include/oic/port/mynewt/transport.h
+++ b/net/oic/include/oic/port/mynewt/transport.h
@@ -36,8 +36,8 @@ struct oc_endpoint;
 enum oc_resource_properties;
 
 struct oc_transport {
-    uint8_t ot_ep_size;
     uint8_t ot_flags;
+    uint8_t (*ot_ep_size)(const struct oc_endpoint *);
     void (*ot_tx_ucast)(struct os_mbuf *);
     void (*ot_tx_mcast)(struct os_mbuf *);
     enum oc_resource_properties
diff --git a/net/oic/include/oic/port/oc_connectivity.h b/net/oic/include/oic/port/oc_connectivity.h
index 22bfc6355..f9247a3ec 100644
--- a/net/oic/include/oic/port/oc_connectivity.h
+++ b/net/oic/include/oic/port/oc_connectivity.h
@@ -18,6 +18,7 @@
 #define OC_CONNECTIVITY_H
 
 #include <stdint.h>
+#include <assert.h>
 
 #include "oic/port/mynewt/config.h"
 #include "oic/port/mynewt/transport.h"
@@ -56,7 +57,8 @@ struct oc_endpoint_plain {
 static inline int
 oc_endpoint_size(struct oc_endpoint *oe)
 {
-    return oc_transports[oe->ep.oe_type]->ot_ep_size;
+    assert(oc_transports[oe->ep.oe_type]);
+    return oc_transports[oe->ep.oe_type]->ot_ep_size(oe);
 }
 
 static inline int
diff --git a/net/oic/src/messaging/coap/separate.c b/net/oic/src/messaging/coap/separate.c
index 6ff7c64fa..9b1259a40 100644
--- a/net/oic/src/messaging/coap/separate.c
+++ b/net/oic/src/messaging/coap/separate.c
@@ -112,7 +112,7 @@ coap_separate_accept(struct coap_packet_rx *coap_req,
             return 0;
         }
     }
-    memcpy(&separate_store->endpoint, endpoint, sizeof(oc_endpoint_t));
+    memcpy(&separate_store->endpoint, endpoint, oc_endpoint_size(endpoint));
 
     /* store correct response type */
     separate_store->type = COAP_TYPE_NON;
diff --git a/net/oic/src/port/mynewt/ble_adaptor.c b/net/oic/src/port/mynewt/ble_adaptor.c
index 14a88f3c9..f66e82380 100644
--- a/net/oic/src/port/mynewt/ble_adaptor.c
+++ b/net/oic/src/port/mynewt/ble_adaptor.c
@@ -36,6 +36,7 @@
 #include "services/gap/ble_svc_gap.h"
 #include "services/gatt/ble_svc_gatt.h"
 
+static uint8_t oc_ep_gatt_size(const struct oc_endpoint *oe);
 static void oc_send_buffer_gatt(struct os_mbuf *m);
 static char *oc_log_ep_gatt(char *ptr, int maxlen, const struct oc_endpoint *);
 enum oc_resource_properties
@@ -44,8 +45,8 @@ static int oc_connectivity_init_gatt(void);
 void oc_connectivity_shutdown_gatt(void);
 
 static const struct oc_transport oc_gatt_transport = {
-    .ot_ep_size = sizeof(struct oc_endpoint_ble),
     .ot_flags = OC_TRANSPORT_USE_TCP,
+    .ot_ep_size = oc_ep_gatt_size,
     .ot_tx_ucast = oc_send_buffer_gatt,
     .ot_tx_mcast = oc_send_buffer_gatt,
     .ot_get_trans_security = oc_get_trans_security_gatt,
@@ -189,6 +190,12 @@ oc_ble_req_attr_to_idx(uint16_t attr_handle)
     return -1;
 }
 
+static uint8_t
+oc_ep_gatt_size(const struct oc_endpoint *oe)
+{
+    return sizeof(struct oc_endpoint_ble);
+}
+
 static char *
 oc_log_ep_gatt(char *ptr, int maxlen, const struct oc_endpoint *oe)
 {
diff --git a/net/oic/src/port/mynewt/ip4_adaptor.c b/net/oic/src/port/mynewt/ip4_adaptor.c
index 53fc1a950..11cf220e5 100644
--- a/net/oic/src/port/mynewt/ip4_adaptor.c
+++ b/net/oic/src/port/mynewt/ip4_adaptor.c
@@ -39,14 +39,15 @@
 
 static void oc_send_buffer_ip4(struct os_mbuf *m);
 static void oc_send_buffer_ip4_mcast(struct os_mbuf *m);
+static uint8_t oc_ep_ip4_size(const struct oc_endpoint *oe);
 static char *oc_log_ep_ip4(char *ptr, int maxlen, const struct oc_endpoint *);
 static int oc_connectivity_init_ip4(void);
 void oc_connectivity_shutdown_ip4(void);
 static void oc_event_ip4(struct os_event *ev);
 
 static const struct oc_transport oc_ip4_transport = {
-    .ot_ep_size = sizeof(struct oc_endpoint_ip),
     .ot_flags = 0,
+    .ot_ep_size = oc_ep_ip4_size,
     .ot_tx_ucast = oc_send_buffer_ip4,
     .ot_tx_mcast = oc_send_buffer_ip4_mcast,
     .ot_get_trans_security = NULL,
@@ -109,6 +110,12 @@ oc_log_ep_ip4(char *ptr, int maxlen, const struct oc_endpoint *oe)
     return ptr;
 }
 
+static uint8_t
+oc_ep_ip4_size(const struct oc_endpoint *oe)
+{
+    return sizeof(struct oc_endpoint_ip);
+}
+
 static void
 oc_send_buffer_ip4_int(struct os_mbuf *m, int is_mcast)
 {
@@ -327,7 +334,7 @@ oc_connectivity_init_ip4(void)
 
     sin.msin_len = sizeof(sin);
     sin.msin_family = MN_AF_INET;
-    sin.msin_port = 11111;
+    sin.msin_port = 0;
     memset(&sin.msin_addr, 0, sizeof(sin.msin_addr));
 
     rc = mn_bind(oc_ucast4, (struct mn_sockaddr *)&sin);
diff --git a/net/oic/src/port/mynewt/ip_adaptor.c b/net/oic/src/port/mynewt/ip_adaptor.c
index b25fa5460..e378d2234 100644
--- a/net/oic/src/port/mynewt/ip_adaptor.c
+++ b/net/oic/src/port/mynewt/ip_adaptor.c
@@ -38,6 +38,7 @@
 #include "oic/port/mynewt/transport.h"
 #include "oic/port/mynewt/ip.h"
 
+static uint8_t oc_ep_ip6_size(const struct oc_endpoint *oe);
 static void oc_send_buffer_ip6(struct os_mbuf *m);
 static void oc_send_buffer_ip6_mcast(struct os_mbuf *m);
 static char *oc_log_ep_ip6(char *ptr, int maxlen, const struct oc_endpoint *);
@@ -46,8 +47,8 @@ void oc_connectivity_shutdown_ip6(void);
 static void oc_event_ip6(struct os_event *ev);
 
 static const struct oc_transport oc_ip6_transport = {
-    .ot_ep_size = sizeof(struct oc_endpoint_ip),
     .ot_flags = 0,
+    .ot_ep_size = oc_ep_ip6_size,
     .ot_tx_ucast = oc_send_buffer_ip6,
     .ot_tx_mcast = oc_send_buffer_ip6_mcast,
     .ot_get_trans_security = NULL,
@@ -113,6 +114,12 @@ oc_log_ep_ip6(char *ptr, int maxlen, const struct oc_endpoint *oe)
     return ptr;
 }
 
+static uint8_t
+oc_ep_ip6_size(const struct oc_endpoint *oe)
+{
+    return sizeof(struct oc_endpoint_ip);
+}
+
 static void
 oc_send_buffer_ip6_int(struct os_mbuf *m, int is_mcast)
 {
diff --git a/net/oic/src/port/mynewt/lora_adaptor.c b/net/oic/src/port/mynewt/lora_adaptor.c
index 2a0c0d7be..5316b7e20 100644
--- a/net/oic/src/port/mynewt/lora_adaptor.c
+++ b/net/oic/src/port/mynewt/lora_adaptor.c
@@ -44,13 +44,14 @@
 #endif
 
 static void oc_send_buffer_lora(struct os_mbuf *m);
+static uint8_t oc_ep_lora_size(const struct oc_endpoint *oe);
 static char *oc_log_ep_lora(char *ptr, int maxlen, const struct oc_endpoint *);
 static int oc_connectivity_init_lora(void);
 void oc_connectivity_shutdown_lora(void);
 
 static const struct oc_transport oc_lora_transport = {
-    .ot_ep_size = sizeof(struct oc_endpoint_lora),
     .ot_flags = 0,
+    .ot_ep_size = oc_ep_lora_size,
     .ot_tx_ucast = oc_send_buffer_lora,
     .ot_tx_mcast = oc_send_buffer_lora,
     .ot_get_trans_security = NULL,
@@ -123,6 +124,12 @@ oc_log_ep_lora(char *ptr, int maxlen, const struct oc_endpoint *oe)
     return ptr;
 }
 
+static uint8_t
+oc_ep_lora_size(const struct oc_endpoint *oe)
+{
+    return sizeof(struct oc_endpoint_lora);
+}
+
 void
 oc_send_frag_lora(struct oc_lora_state *os)
 {
diff --git a/net/oic/src/port/mynewt/serial_adaptor.c b/net/oic/src/port/mynewt/serial_adaptor.c
index f9db379b3..ec2f9bab3 100644
--- a/net/oic/src/port/mynewt/serial_adaptor.c
+++ b/net/oic/src/port/mynewt/serial_adaptor.c
@@ -33,13 +33,14 @@
 #include "oic/port/mynewt/transport.h"
 
 static void oc_send_buffer_serial(struct os_mbuf *m);
+static uint8_t oc_ep_serial_size(const struct oc_endpoint *oe);
 static char *oc_log_ep_serial(char *ptr, int max, const struct oc_endpoint *);
 static int oc_connectivity_init_serial(void);
 void oc_connectivity_shutdown_serial(void);
 
 static const struct oc_transport oc_serial_transport = {
-    .ot_ep_size = sizeof(struct oc_endpoint_plain),
     .ot_flags = 0,
+    .ot_ep_size = oc_ep_serial_size,
     .ot_tx_ucast = oc_send_buffer_serial,
     .ot_tx_mcast = oc_send_buffer_serial,
     .ot_get_trans_security = NULL,
@@ -58,6 +59,12 @@ oc_log_ep_serial(char *ptr, int max, const struct oc_endpoint *oe)
     return "serial";
 }
 
+static uint8_t
+oc_ep_serial_size(const struct oc_endpoint *oe)
+{
+    return sizeof(struct oc_endpoint_plain);
+}
+
 static int
 oc_serial_in(struct os_mbuf *m, void *arg)
 {
diff --git a/net/oic/syscfg.yml b/net/oic/syscfg.yml
index 4add9865f..d7d1f2773 100644
--- a/net/oic/syscfg.yml
+++ b/net/oic/syscfg.yml
@@ -97,3 +97,6 @@ syscfg.defs:
             Enables per-resource transport layer security requirements.
         value: 1
 
+    OC_COAP_RESPONSE_TIMEOUT:
+        description: 'How many seconds before client request times out'
+        value: 4
diff --git a/test/testutil/include/testutil/testutil.h b/test/testutil/include/testutil/testutil.h
index 6a2490e7d..a2695602e 100644
--- a/test/testutil/include/testutil/testutil.h
+++ b/test/testutil/include/testutil/testutil.h
@@ -268,7 +268,7 @@ TEST_SUITE_##suite_name(void);                               \
 
 #define TEST_ASSERT_FULL(fatal, expr, ...) (assert(expr))
 
-#else 
+#else
 
 #define TEST_ASSERT_FULL(fatal, expr, ...) do                 \
 {                                                             \


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services