You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/12/17 00:19:41 UTC
[1/3] incubator-mynewt-core git commit: bleprph_oic;
app does not need extra mbufs anymore.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 132615a37 -> 9f854b1f4
bleprph_oic; app does not need extra mbufs anymore.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/27603ce2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/27603ce2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/27603ce2
Branch: refs/heads/develop
Commit: 27603ce2c52b974b91afc70db107dc2795bfcd30
Parents: 132615a
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 16 15:38:59 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 16 15:38:59 2016 -0800
----------------------------------------------------------------------
apps/bleprph_oic/syscfg.yml | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/27603ce2/apps/bleprph_oic/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/bleprph_oic/syscfg.yml b/apps/bleprph_oic/syscfg.yml
index 677c5fe..220978c 100644
--- a/apps/bleprph_oic/syscfg.yml
+++ b/apps/bleprph_oic/syscfg.yml
@@ -38,9 +38,6 @@ syscfg.vals:
# Disable unused eddystone feature.
BLE_EDDYSTONE: 0
- # Need to get this down. XXXXX
- MSYS_1_BLOCK_COUNT: 18
-
# Log reboot messages to a flash circular buffer.
REBOOT_LOG_FCB: 1
LOG_FCB: 1
[2/3] incubator-mynewt-core git commit: oic;
fix endpoint logging at RX, used wrong pointer as data.
Posted by ma...@apache.org.
oic; fix endpoint logging at RX, used wrong pointer as data.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/8daf849d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8daf849d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8daf849d
Branch: refs/heads/develop
Commit: 8daf849d612657c66e0d1ca6436c01686fecb318
Parents: 27603ce
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 16 15:39:39 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 16 15:39:39 2016 -0800
----------------------------------------------------------------------
net/oic/src/api/oc_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8daf849d/net/oic/src/api/oc_buffer.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_buffer.c b/net/oic/src/api/oc_buffer.c
index 7c3b477..7bca928 100644
--- a/net/oic/src/api/oc_buffer.c
+++ b/net/oic/src/api/oc_buffer.c
@@ -160,7 +160,7 @@ oc_buffer_rx(struct os_event *ev)
goto free_msg;
}
OC_LOG_DEBUG("oc_buffer_rx: ");
- OC_LOG_ENDPOINT(LOG_LEVEL_DEBUG, &msg->endpoint);
+ OC_LOG_ENDPOINT(LOG_LEVEL_DEBUG, OC_MBUF_ENDPOINT(m));
if (OS_MBUF_PKTHDR(m)->omp_len > MAX_PAYLOAD_SIZE) {
STATS_INC(coap_stats, itoobig);
[3/3] incubator-mynewt-core git commit: oic;
make oc_endpoint structure size dependent on type of transport. For
IPv6 it needs a full v6 address/port, while ble only needs 2 bytes for
connection handle.
Posted by ma...@apache.org.
oic; make oc_endpoint structure size dependent on type of transport.
For IPv6 it needs a full v6 address/port, while ble only needs 2 bytes
for connection handle.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9f854b1f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9f854b1f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9f854b1f
Branch: refs/heads/develop
Commit: 9f854b1f418c9c6b2aca4f321db628659abfedee
Parents: 8daf849
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 16 15:41:10 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 16 16:19:11 2016 -0800
----------------------------------------------------------------------
net/oic/src/api/oc_buffer.c | 2 +-
net/oic/src/api/oc_client_api.c | 2 +-
net/oic/src/api/oc_discovery.c | 10 ++---
net/oic/src/port/mynewt/adaptor.c | 4 +-
net/oic/src/port/mynewt/ble_adaptor.c | 46 ++++++++++++---------
net/oic/src/port/mynewt/ip_adaptor.c | 19 +++++----
net/oic/src/port/mynewt/log.c | 8 ++--
net/oic/src/port/mynewt/serial_adaptor.c | 4 +-
net/oic/src/port/oc_connectivity.h | 59 +++++++++++++++++++--------
9 files changed, 93 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/api/oc_buffer.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_buffer.c b/net/oic/src/api/oc_buffer.c
index 7bca928..1df8b8d 100644
--- a/net/oic/src/api/oc_buffer.c
+++ b/net/oic/src/api/oc_buffer.c
@@ -118,7 +118,7 @@ oc_buffer_tx(struct os_event *ev)
OC_LOG_DEBUG("oc_buffer_tx: ");
OC_LOG_ENDPOINT(LOG_LEVEL_DEBUG, OC_MBUF_ENDPOINT(m));
#ifdef OC_CLIENT
- if (OC_MBUF_ENDPOINT(m)->flags & MULTICAST) {
+ if (OC_MBUF_ENDPOINT(m)->oe.flags & MULTICAST) {
oc_send_multicast_message(m);
} else {
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/api/oc_client_api.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_client_api.c b/net/oic/src/api/oc_client_api.c
index bc29fe1..692e0f6 100644
--- a/net/oic/src/api/oc_client_api.c
+++ b/net/oic/src/api/oc_client_api.c
@@ -273,7 +273,7 @@ oc_do_ip_discovery(const char *rt, oc_discovery_cb_t handler)
oc_make_ip_endpoint(mcast, IP | MULTICAST, 5683,
0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xfd);
- mcast.ipv6_addr.scope = 0;
+ mcast.oe_ip.v6.scope = 0;
memcpy(&handle.endpoint, &mcast, sizeof(oc_endpoint_t));
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/api/oc_discovery.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_discovery.c b/net/oic/src/api/oc_discovery.c
index be5be0c..6427056 100644
--- a/net/oic/src/api/oc_discovery.c
+++ b/net/oic/src/api/oc_discovery.c
@@ -190,7 +190,7 @@ oc_ri_process_discovery_payload(uint8_t *payload, int len,
.os_str = NULL
};
bool secure = false;
- uint16_t dtls_port = 0, default_port = endpoint->ipv6_addr.port;
+ uint16_t dtls_port = 0, default_port = endpoint->oe_ip.v6.port;
oc_string_array_t types = {};
oc_interface_mask_t interfaces = 0;
oc_server_handle_t handle;
@@ -269,11 +269,11 @@ oc_ri_process_discovery_payload(uint8_t *payload, int len,
resource_info = resource_info->next;
}
if (secure) {
- handle.endpoint.ipv6_addr.port = dtls_port;
- handle.endpoint.flags |= SECURED;
+ handle.endpoint.oe_ip.v6.port = dtls_port;
+ handle.endpoint.oe_ip.flags |= SECURED;
} else {
- handle.endpoint.ipv6_addr.port = default_port;
- handle.endpoint.flags &= ~SECURED;
+ handle.endpoint.oe_ip.v6.port = default_port;
+ handle.endpoint.oe_ip.flags &= ~SECURED;
}
if (handler(oc_string(di), oc_string(uri), types, interfaces,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/port/mynewt/adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/adaptor.c b/net/oic/src/port/mynewt/adaptor.c
index 22edda3..6f4134e 100644
--- a/net/oic/src/port/mynewt/adaptor.c
+++ b/net/oic/src/port/mynewt/adaptor.c
@@ -75,7 +75,7 @@ oc_send_buffer(struct os_mbuf *m)
oe = OC_MBUF_ENDPOINT(m);
- switch (oe->flags) {
+ switch (oe->oe.flags) {
#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1)
case IP:
oc_send_buffer_ip(m);
@@ -92,7 +92,7 @@ oc_send_buffer(struct os_mbuf *m)
break;
#endif
default:
- OC_LOG_ERROR("Unknown transport option %u\n", oe->flags);
+ OC_LOG_ERROR("Unknown transport option %u\n", oe->oe.flags);
os_mbuf_free_chain(m);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/port/mynewt/ble_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/ble_adaptor.c b/net/oic/src/port/mynewt/ble_adaptor.c
index 39ceac9..8ede614 100644
--- a/net/oic/src/port/mynewt/ble_adaptor.c
+++ b/net/oic/src/port/mynewt/ble_adaptor.c
@@ -117,7 +117,7 @@ int
oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle)
{
struct os_mbuf_pkthdr *pkt1;
- struct oc_endpoint *oe;
+ struct oc_endpoint_ble *oe_ble;
struct os_mbuf *om2;
struct os_mbuf_pkthdr *pkt2;
uint8_t hdr[6]; /* sizeof(coap_tcp_hdr32) */
@@ -133,8 +133,8 @@ oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle)
STAILQ_FOREACH(pkt2, &oc_ble_reass_q, omp_next) {
om2 = OS_MBUF_PKTHDR_TO_MBUF(pkt2);
- oe = OC_MBUF_ENDPOINT(om2);
- if (conn_handle == oe->bt_addr.conn_handle) {
+ oe_ble = (struct oc_endpoint_ble *)OC_MBUF_ENDPOINT(om2);
+ if (conn_handle == oe_ble->conn_handle) {
/*
* Data from same connection. Append.
*/
@@ -151,20 +151,25 @@ oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle)
}
if (pkt1) {
/*
- * New frame
+ * New frame, need to add oc_endpoint_ble in the front.
+ * Check if there is enough space available. If not, allocate a
+ * new pkthdr.
*/
- om2 = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint));
- if (!om2) {
- OC_LOG_ERROR("oc_gatt_rx: Could not allocate mbuf\n");
- STATS_INC(oc_ble_stats, ierr);
- return -1;
+ if (OS_MBUF_USRHDR_LEN(om1) < sizeof(struct oc_endpoint_ble)) {
+ om2 = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint_ble));
+ if (!om2) {
+ OC_LOG_ERROR("oc_gatt_rx: Could not allocate mbuf\n");
+ STATS_INC(oc_ble_stats, ierr);
+ return -1;
+ }
+ OS_MBUF_PKTHDR(om2)->omp_len = pkt1->omp_len;
+ SLIST_NEXT(om2, om_next) = om1;
+ } else {
+ om2 = om1;
}
- OS_MBUF_PKTHDR(om2)->omp_len = pkt1->omp_len;
- SLIST_NEXT(om2, om_next) = om1;
-
- oe = OC_MBUF_ENDPOINT(om2);
- oe->flags = GATT;
- oe->bt_addr.conn_handle = conn_handle;
+ oe_ble = (struct oc_endpoint_ble *)OC_MBUF_ENDPOINT(om2);
+ oe_ble->flags = GATT;
+ oe_ble->conn_handle = conn_handle;
pkt2 = OS_MBUF_PKTHDR(om2);
if (os_mbuf_copydata(om2, 0, sizeof(hdr), hdr) ||
@@ -239,13 +244,13 @@ oc_ble_coap_conn_del(uint16_t conn_handle)
{
struct os_mbuf_pkthdr *pkt;
struct os_mbuf *m;
- struct oc_endpoint *oe;
+ struct oc_endpoint_ble *oe_ble;
OC_LOG_DEBUG("oc_gatt endconn %x\n", conn_handle);
STAILQ_FOREACH(pkt, &oc_ble_reass_q, omp_next) {
m = OS_MBUF_PKTHDR_TO_MBUF(pkt);
- oe = OC_MBUF_ENDPOINT(m);
- if (oe->bt_addr.conn_handle == conn_handle) {
+ oe_ble = (struct oc_endpoint_ble *)OC_MBUF_ENDPOINT(m);
+ if (oe_ble->conn_handle == conn_handle) {
STAILQ_REMOVE(&oc_ble_reass_q, pkt, os_mbuf_pkthdr, omp_next);
os_mbuf_free_chain(m);
break;
@@ -318,8 +323,9 @@ oc_send_buffer_gatt(struct os_mbuf *m)
uint16_t mtu;
uint16_t conn_handle;
+ assert(OS_MBUF_USRHDR_LEN(m) >= sizeof(struct oc_endpoint_ble));
oe = OC_MBUF_ENDPOINT(m);
- conn_handle = oe->bt_addr.conn_handle;
+ conn_handle = oe->oe_ble.conn_handle;
#if (MYNEWT_VAL(OC_CLIENT) == 1)
OC_LOG_ERROR("oc_gatt send not supported on client");
@@ -330,7 +336,7 @@ oc_send_buffer_gatt(struct os_mbuf *m)
STATS_INC(oc_ble_stats, oseg);
STATS_INCN(oc_ble_stats, obytes, OS_MBUF_PKTLEN(m));
- mtu = ble_att_mtu(oe->bt_addr.conn_handle);
+ mtu = ble_att_mtu(conn_handle);
assert(mtu > 4);
mtu -= 3; /* # of bytes for ATT notification base */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/port/mynewt/ip_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/ip_adaptor.c b/net/oic/src/port/mynewt/ip_adaptor.c
index 634417a..9d8a300 100644
--- a/net/oic/src/port/mynewt/ip_adaptor.c
+++ b/net/oic/src/port/mynewt/ip_adaptor.c
@@ -69,13 +69,14 @@ oc_send_buffer_ip_int(struct os_mbuf *m, int is_mcast)
struct os_mbuf *n;
int rc;
+ assert(OS_MBUF_USRHDR_LEN(m) >= sizeof(struct oc_endpoint_ip));
oe = OC_MBUF_ENDPOINT(m);
to.msin6_len = sizeof(to);
to.msin6_family = MN_AF_INET6;
- to.msin6_port = htons(oe->ipv6_addr.port);
- to.msin6_scope_id = oe->ipv6_addr.scope;
- memcpy(&to.msin6_addr, oe->ipv6_addr.address, sizeof(to.msin6_addr));
+ to.msin6_port = htons(oe->oe_ip.v6.port);
+ to.msin6_scope_id = oe->oe_ip.v6.scope;
+ memcpy(&to.msin6_addr, oe->oe_ip.v6.address, sizeof(to.msin6_addr));
if (is_mcast) {
memset(&itf, 0, sizeof(itf));
@@ -156,7 +157,7 @@ oc_attempt_rx_ip_sock(struct mn_socket *rxsock)
}
assert(OS_MBUF_IS_PKTHDR(n));
- m = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint));
+ m = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint_ip));
if (!m) {
OC_LOG_ERROR("Could not allocate RX buffer\n");
goto rx_attempt_err;
@@ -166,11 +167,11 @@ oc_attempt_rx_ip_sock(struct mn_socket *rxsock)
oe = OC_MBUF_ENDPOINT(m);
- oe->flags = IP;
- memcpy(&oe->ipv6_addr.address, &from.msin6_addr,
- sizeof(oe->ipv6_addr.address));
- oe->ipv6_addr.scope = from.msin6_scope_id;
- oe->ipv6_addr.port = ntohs(from.msin6_port);
+ oe->oe_ip.flags = IP;
+ memcpy(&oe->oe_ip.v6.address, &from.msin6_addr,
+ sizeof(oe->oe_ip.v6.address));
+ oe->oe_ip.v6.scope = from.msin6_scope_id;
+ oe->oe_ip.v6.port = ntohs(from.msin6_port);
return m;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/port/mynewt/log.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/log.c b/net/oic/src/port/mynewt/log.c
index b2f1b88..85f7e5d 100644
--- a/net/oic/src/port/mynewt/log.c
+++ b/net/oic/src/port/mynewt/log.c
@@ -34,21 +34,21 @@ oc_log_endpoint(uint16_t lvl, struct oc_endpoint *oe)
(void)tmp;
- switch (oe->flags) {
+ switch (oe->oe.flags) {
#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1)
case IP: {
int len;
- mn_inet_ntop(MN_PF_INET6, oe->ipv6_addr.address, tmp, sizeof(tmp));
+ mn_inet_ntop(MN_PF_INET6, oe->oe_ip.v6.address, tmp, sizeof(tmp));
len = strlen(tmp);
- snprintf(tmp + len, sizeof(tmp) - len, "-%u\n", oe->ipv6_addr.port);
+ snprintf(tmp + len, sizeof(tmp) - len, "-%u\n", oe->oe_ip.v6.port);
str = tmp;
break;
}
#endif
#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
case GATT:
- snprintf(tmp, sizeof(tmp), "%u\n", oe->bt_addr.conn_handle);
+ snprintf(tmp, sizeof(tmp), "ble %u\n", oe->oe_ble.conn_handle);
str = tmp;
break;
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/port/mynewt/serial_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/serial_adaptor.c b/net/oic/src/port/mynewt/serial_adaptor.c
index 130e26d..6e6450b 100644
--- a/net/oic/src/port/mynewt/serial_adaptor.c
+++ b/net/oic/src/port/mynewt/serial_adaptor.c
@@ -102,7 +102,7 @@ oc_attempt_rx_serial(void)
return NULL;
}
- m = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint));
+ m = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint_plain));
if (!m) {
OC_LOG_ERROR("Could not allocate OC message buffer\n");
goto rx_attempt_err;
@@ -111,7 +111,7 @@ oc_attempt_rx_serial(void)
SLIST_NEXT(m, om_next) = n;
oe = OC_MBUF_ENDPOINT(m);
- oe->flags = SERIAL;
+ oe->oe.flags = SERIAL;
return m;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f854b1f/net/oic/src/port/oc_connectivity.h
----------------------------------------------------------------------
diff --git a/net/oic/src/port/oc_connectivity.h b/net/oic/src/port/oc_connectivity.h
index 7f50a6b..b86ec19 100644
--- a/net/oic/src/port/oc_connectivity.h
+++ b/net/oic/src/port/oc_connectivity.h
@@ -30,22 +30,47 @@ typedef struct {
uint8_t scope;
} oc_ipv6_addr_t;
-typedef struct {
+enum oc_transport_flags {
+ IP = 1 << 0,
+ GATT = 1 << 1,
+ IPSP = 1 << 2,
+ MULTICAST = 1 << 3,
+ SECURED = 1 << 4,
+ SERIAL = 1 << 5,
+};
+
+/*
+ * OC endpoint data structure comes in different variations,
+ * depending on flags field.
+ */
+/*
+ * oc_endpoint for IPv6 source
+ */
+struct oc_endpoint_ip {
+ enum oc_transport_flags flags;
+ oc_ipv6_addr_t v6;
+};
+
+/*
+ * oc_endpoint for BLE source.
+ */
+struct oc_endpoint_ble {
+ enum oc_transport_flags flags;
uint16_t conn_handle;
-} oc_le_addr_t;
+};
+
+/*
+ * oc_endpoint for multicast target and serial port.
+ */
+struct oc_endpoint_plain {
+ enum oc_transport_flags flags;
+};
typedef struct oc_endpoint {
- enum transport_flags {
- IP = 1 << 0,
- GATT = 1 << 1,
- IPSP = 1 << 2,
- MULTICAST = 1 << 3,
- SECURED = 1 << 4,
- SERIAL = 1 << 5,
- } flags;
union {
- oc_ipv6_addr_t ipv6_addr;
- oc_le_addr_t bt_addr;
+ struct oc_endpoint_ip oe_ip;
+ struct oc_endpoint_ble oe_ble;
+ struct oc_endpoint_plain oe;
};
} oc_endpoint_t;
@@ -54,10 +79,10 @@ typedef struct oc_endpoint {
sizeof(struct os_mbuf_pkthdr)))
-#define oc_make_ip_endpoint(__name__, __flags__, __port__, ...) \
- oc_endpoint_t __name__ = {.flags = __flags__, \
- .ipv6_addr = {.port = __port__, \
- .address = { __VA_ARGS__ } } }
+#define oc_make_ip_endpoint(__name__, __flags__, __port__, ...) \
+ oc_endpoint_t __name__ = {.oe_ip = {.flags = __flags__, \
+ .v6 = {.port = __port__, \
+ .address = { __VA_ARGS__ } } } }
typedef struct oc_message {
oc_endpoint_t endpoint;
@@ -76,7 +101,7 @@ void oc_connectivity_shutdown(void);
static inline int
oc_endpoint_use_tcp(struct oc_endpoint *oe)
{
- if (oe->flags & GATT) {
+ if (oe->oe.flags & GATT) {
return 1;
}
return 0;