You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/08/28 18:31:17 UTC

[mynewt-newtmgr] branch master updated: nmxact - Fix CoAP over UDP.

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git


The following commit(s) were added to refs/heads/master by this push:
     new ced7c22  nmxact - Fix CoAP over UDP.
ced7c22 is described below

commit ced7c225aade745d4cbe9807e7a8f9b631783293
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Aug 28 11:30:45 2017 -0700

    nmxact - Fix CoAP over UDP.
---
 newtmgr/bll/bll_sesn.go        | 4 ++++
 nmxact/nmble/ble_sesn.go       | 4 ++++
 nmxact/nmserial/serial_sesn.go | 4 ++++
 nmxact/sesn/sesn.go            | 3 +++
 nmxact/sesn/sesn_util.go       | 8 ++++----
 nmxact/udp/udp_sesn.go         | 4 ++++
 6 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/newtmgr/bll/bll_sesn.go b/newtmgr/bll/bll_sesn.go
index 853db30..51c8d4c 100644
--- a/newtmgr/bll/bll_sesn.go
+++ b/newtmgr/bll/bll_sesn.go
@@ -422,3 +422,7 @@ func (s *BllSesn) TxCoapOnce(m coap.Message, resType sesn.ResourceType,
 func (s *BllSesn) MgmtProto() sesn.MgmtProto {
 	return s.cfg.MgmtProto
 }
+
+func (s *BllSesn) CoapIsTcp() bool {
+	return true
+}
diff --git a/nmxact/nmble/ble_sesn.go b/nmxact/nmble/ble_sesn.go
index a980141..56b3af4 100644
--- a/nmxact/nmble/ble_sesn.go
+++ b/nmxact/nmble/ble_sesn.go
@@ -312,6 +312,10 @@ func (s *BleSesn) MtuOut() int {
 	return util.IntMin(s.MtuIn(), BLE_ATT_ATTR_MAX_LEN)
 }
 
+func (s *BleSesn) CoapIsTcp() bool {
+	return true
+}
+
 func (s *BleSesn) MgmtProto() sesn.MgmtProto {
 	return s.cfg.MgmtProto
 }
diff --git a/nmxact/nmserial/serial_sesn.go b/nmxact/nmserial/serial_sesn.go
index 2cc5692..955dac8 100644
--- a/nmxact/nmserial/serial_sesn.go
+++ b/nmxact/nmserial/serial_sesn.go
@@ -166,3 +166,7 @@ func (s *SerialSesn) TxCoapOnce(m coap.Message, resType sesn.ResourceType,
 func (s *SerialSesn) MgmtProto() sesn.MgmtProto {
 	return s.cfg.MgmtProto
 }
+
+func (s *SerialSesn) CoapIsTcp() bool {
+	return false
+}
diff --git a/nmxact/sesn/sesn.go b/nmxact/sesn/sesn.go
index 9fd67ae..fefa02a 100644
--- a/nmxact/sesn/sesn.go
+++ b/nmxact/sesn/sesn.go
@@ -79,6 +79,9 @@ type Sesn interface {
 
 	MgmtProto() MgmtProto
 
+	// Indicates whether the session uses the TCP form of CoAP.
+	CoapIsTcp() bool
+
 	// Stops a receive operation in progress.  This must be called from a
 	// separate thread, as sesn receive operations are blocking.
 	AbortRx(nmpSeq uint8) error
diff --git a/nmxact/sesn/sesn_util.go b/nmxact/sesn/sesn_util.go
index 26eec86..6a9bc81 100644
--- a/nmxact/sesn/sesn_util.go
+++ b/nmxact/sesn/sesn_util.go
@@ -44,7 +44,7 @@ func TxNmp(s Sesn, m *nmp.NmpMsg, o TxOptions) (nmp.NmpRsp, error) {
 func getResourceOnce(s Sesn, resType ResourceType,
 	uri string, opt TxOptions) (coap.COAPCode, []byte, error) {
 
-	req, err := oic.CreateGet(true, uri, nmxutil.NextToken())
+	req, err := oic.CreateGet(s.CoapIsTcp(), uri, nmxutil.NextToken())
 	if err != nil {
 		return 0, nil, err
 	}
@@ -56,7 +56,7 @@ func putResourceOnce(s Sesn, resType ResourceType,
 	uri string, value []byte,
 	opt TxOptions) (coap.COAPCode, []byte, error) {
 
-	req, err := oic.CreatePut(true, uri, nmxutil.NextToken(), value)
+	req, err := oic.CreatePut(s.CoapIsTcp(), uri, nmxutil.NextToken(), value)
 	if err != nil {
 		return 0, nil, err
 	}
@@ -68,7 +68,7 @@ func postResourceOnce(s Sesn, resType ResourceType,
 	uri string, value []byte,
 	opt TxOptions) (coap.COAPCode, []byte, error) {
 
-	req, err := oic.CreatePost(true, uri, nmxutil.NextToken(), value)
+	req, err := oic.CreatePost(s.CoapIsTcp(), uri, nmxutil.NextToken(), value)
 	if err != nil {
 		return 0, nil, err
 	}
@@ -79,7 +79,7 @@ func postResourceOnce(s Sesn, resType ResourceType,
 func deleteResourceOnce(s Sesn, resType ResourceType,
 	uri string, opt TxOptions) (coap.COAPCode, []byte, error) {
 
-	req, err := oic.CreateDelete(true, uri, nmxutil.NextToken())
+	req, err := oic.CreateDelete(s.CoapIsTcp(), uri, nmxutil.NextToken())
 	if err != nil {
 		return 0, nil, err
 	}
diff --git a/nmxact/udp/udp_sesn.go b/nmxact/udp/udp_sesn.go
index feae2a6..5e5a0d5 100644
--- a/nmxact/udp/udp_sesn.go
+++ b/nmxact/udp/udp_sesn.go
@@ -141,3 +141,7 @@ func (s *UdpSesn) TxCoapOnce(m coap.Message, resType sesn.ResourceType,
 func (s *UdpSesn) MgmtProto() sesn.MgmtProto {
 	return s.cfg.MgmtProto
 }
+
+func (s *UdpSesn) CoapIsTcp() bool {
+	return false
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@mynewt.apache.org" <co...@mynewt.apache.org>'].