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 2019/04/04 03:47:19 UTC
[mynewt-newtmgr] branch master updated: Allow alternate omgr
resource
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 c636cae Allow alternate omgr resource
new 74199a3 Merge pull request #119 from ccollins476ad/ompres
c636cae is described below
commit c636cae26b9343bf4bcd0df8135f4f707356ede2
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Apr 2 14:24:32 2019 -0700
Allow alternate omgr resource
This commit adds the `--ompres` (OMP resource) command line switch. If
specified, newtmgr sends its OMP request to the specified resource
instead of `/omgr`.
---
newtmgr/cli/commands.go | 3 +++
nmxact/nmxutil/nmxutil.go | 1 +
nmxact/omp/dispatch.go | 2 +-
nmxact/omp/omp.go | 4 ++--
4 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/newtmgr/cli/commands.go b/newtmgr/cli/commands.go
index 5bfebbe..6bdbbf0 100644
--- a/newtmgr/cli/commands.go
+++ b/newtmgr/cli/commands.go
@@ -83,6 +83,9 @@ func Commands() *cobra.Command {
nmCmd.PersistentFlags().StringVar(&nmutil.ConnExtra, "connextra", "",
"Additional key-value pair to append to the connstring")
+ nmCmd.PersistentFlags().StringVar(&nmxutil.OmpRes, "ompres", "/omgr",
+ "Use this CoAP resource instead of /omgr")
+
versCmd := &cobra.Command{
Use: "version",
Short: "Display the " + nmutil.ToolInfo.ShortName + " version number",
diff --git a/nmxact/nmxutil/nmxutil.go b/nmxact/nmxutil/nmxutil.go
index f8779c4..974f5a5 100644
--- a/nmxact/nmxutil/nmxutil.go
+++ b/nmxact/nmxutil/nmxutil.go
@@ -39,6 +39,7 @@ import (
const DURATION_FOREVER time.Duration = math.MaxInt64
var Debug bool
+var OmpRes string = "/omgr"
var nextNmpSeq uint8
var nmpSeqBeenRead bool
diff --git a/nmxact/omp/dispatch.go b/nmxact/omp/dispatch.go
index d61ff69..e3afb34 100644
--- a/nmxact/omp/dispatch.go
+++ b/nmxact/omp/dispatch.go
@@ -24,7 +24,7 @@ import (
"sync/atomic"
log "github.com/Sirupsen/logrus"
- "github.com/runtimeco/go-coap"
+ "github.com/runtimeco/go-coap"
"mynewt.apache.org/newtmgr/nmxact/nmcoap"
"mynewt.apache.org/newtmgr/nmxact/nmp"
diff --git a/nmxact/omp/omp.go b/nmxact/omp/omp.go
index 59d2c4f..d4f76f1 100644
--- a/nmxact/omp/omp.go
+++ b/nmxact/omp/omp.go
@@ -30,6 +30,7 @@ import (
"mynewt.apache.org/newtmgr/nmxact/nmcoap"
"mynewt.apache.org/newtmgr/nmxact/nmp"
+ "mynewt.apache.org/newtmgr/nmxact/nmxutil"
)
// OIC wrapping adds this many bytes to an NMP message. Calculated by
@@ -46,7 +47,6 @@ type OicMsg struct {
* newtmgr response part.
*/
func DecodeOmp(m coap.Message, rxFilterCb nmcoap.MsgFilter) (nmp.NmpRsp, error) {
-
// Ignore non-responses.
if m.Code() == coap.GET || m.Code() == coap.PUT || m.Code() == coap.POST ||
m.Code() == coap.DELETE {
@@ -115,7 +115,7 @@ func encodeOmpBase(txFilterCb nmcoap.MsgFilter, isTcp bool, nmr *nmp.NmpMsg) (en
er.m = coap.NewDgramMessage(mp)
}
- er.m.SetPathString("/omgr")
+ er.m.SetPathString(nmxutil.OmpRes)
payload := []byte{}
enc := codec.NewEncoderBytes(&payload, new(codec.CborHandle))