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/04/12 18:23:26 UTC
[1/3] incubator-mynewt-newtmgr git commit: newtmgr - Allow ble name
on cmdline.
Repository: incubator-mynewt-newtmgr
Updated Branches:
refs/heads/master b6629b106 -> 41cf27469
newtmgr - Allow ble name on cmdline.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/commit/34c5eb87
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/tree/34c5eb87
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/diff/34c5eb87
Branch: refs/heads/master
Commit: 34c5eb878ee6d3ea7456608244c0cb2cafa4faa1
Parents: b6629b1
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 12 11:20:13 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 12 11:20:13 2017 -0700
----------------------------------------------------------------------
newtmgr/cli/commands.go | 3 +++
newtmgr/config/ble_config.go | 5 +++++
newtmgr/nmutil/nmutil.go | 1 +
3 files changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/34c5eb87/newtmgr/cli/commands.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/commands.go b/newtmgr/cli/commands.go
index 72f4999..45eab81 100644
--- a/newtmgr/cli/commands.go
+++ b/newtmgr/cli/commands.go
@@ -65,6 +65,9 @@ func Commands() *cobra.Command {
nmCmd.PersistentFlags().StringVarP(&logLevelStr, "loglevel", "l", "info",
"log level to use")
+ nmCmd.PersistentFlags().StringVarP(&nmutil.DeviceName, "devicename", "n",
+ "", "name of target BLE device; overrides profile setting")
+
nmCmd.AddCommand(crashCmd())
nmCmd.AddCommand(dateTimeCmd())
nmCmd.AddCommand(fsCmd())
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/34c5eb87/newtmgr/config/ble_config.go
----------------------------------------------------------------------
diff --git a/newtmgr/config/ble_config.go b/newtmgr/config/ble_config.go
index 5cb93df..d501a71 100644
--- a/newtmgr/config/ble_config.go
+++ b/newtmgr/config/ble_config.go
@@ -25,6 +25,7 @@ import (
"time"
"mynewt.apache.org/newt/util"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
"mynewt.apache.org/newtmgr/nmxact/bledefs"
"mynewt.apache.org/newtmgr/nmxact/nmble"
"mynewt.apache.org/newtmgr/nmxact/sesn"
@@ -106,6 +107,10 @@ func ParseBleConnString(cs string) (*BleConfig, error) {
func FillSesnCfg(bc *BleConfig, sc *sesn.SesnCfg) {
sc.Ble.OwnAddrType = bc.OwnAddrType
+ if nmutil.DeviceName != "" {
+ bc.PeerName = nmutil.DeviceName
+ }
+
if bc.PeerName != "" {
sc.Ble.PeerSpec = sesn.BlePeerSpecName(bc.PeerName)
} else {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/34c5eb87/newtmgr/nmutil/nmutil.go
----------------------------------------------------------------------
diff --git a/newtmgr/nmutil/nmutil.go b/newtmgr/nmutil/nmutil.go
index aca8111..9cce127 100644
--- a/newtmgr/nmutil/nmutil.go
+++ b/newtmgr/nmutil/nmutil.go
@@ -28,6 +28,7 @@ import (
var Timeout float64
var Tries int
var ConnProfile string
+var DeviceName string
func TxOptions() sesn.TxOptions {
return sesn.TxOptions{
[2/3] incubator-mynewt-newtmgr git commit: nmxact ble_dual ex: send
more commands.
Posted by cc...@apache.org.
nmxact ble_dual ex: send more commands.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/commit/9e80738e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/tree/9e80738e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/diff/9e80738e
Branch: refs/heads/master
Commit: 9e80738e6f3296469b8469f10f846312767d9922
Parents: 34c5eb8
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 12 11:21:09 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 12 11:21:09 2017 -0700
----------------------------------------------------------------------
nmxact/example/ble_dual/ble_dual.go | 113 +++++++++++++++++++++++++++----
1 file changed, 99 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/9e80738e/nmxact/example/ble_dual/ble_dual.go
----------------------------------------------------------------------
diff --git a/nmxact/example/ble_dual/ble_dual.go b/nmxact/example/ble_dual/ble_dual.go
index e4615fe..b1e2a67 100644
--- a/nmxact/example/ble_dual/ble_dual.go
+++ b/nmxact/example/ble_dual/ble_dual.go
@@ -59,6 +59,91 @@ func configExitHandler(x xport.Xport) {
}()
}
+func sendEcho(s sesn.Sesn) error {
+ c := xact.NewEchoCmd()
+ c.Payload = fmt.Sprintf("hello %p", s)
+
+ res, err := c.Run(s)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error executing echo command: %s\n",
+ err.Error())
+ return err
+ }
+
+ if res.Status() != 0 {
+ fmt.Printf("Peer responded negatively to echo command; status=%d\n",
+ res.Status())
+ }
+
+ eres := res.(*xact.EchoResult)
+ fmt.Printf("Peer echoed back: %s\n", eres.Rsp.Payload)
+
+ return nil
+}
+
+func sendImageState(s sesn.Sesn) error {
+ c := xact.NewImageStateReadCmd()
+
+ res, err := c.Run(s)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error executing image state command: %s\n",
+ err.Error())
+ return err
+ }
+
+ if res.Status() != 0 {
+ fmt.Printf("Peer responded negatively to image state command; "+
+ "status=%d\n", res.Status())
+ }
+
+ eres := res.(*xact.ImageStateReadResult)
+ fmt.Printf("Peer responded with image state: %#v\n", eres.Rsp)
+
+ return nil
+}
+
+func sendMpStat(s sesn.Sesn) error {
+ c := xact.NewMempoolStatCmd()
+
+ res, err := c.Run(s)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error executing mempool stat command: %s\n",
+ err.Error())
+ return err
+ }
+
+ if res.Status() != 0 {
+ fmt.Printf("Peer responded negatively to mempool stat command; "+
+ "status=%d\n", res.Status())
+ }
+
+ eres := res.(*xact.MempoolStatResult)
+ fmt.Printf("Peer responded with mempool stat: %#v\n", eres.Rsp)
+
+ return nil
+}
+
+func sendTaskStat(s sesn.Sesn) error {
+ c := xact.NewTaskStatCmd()
+
+ res, err := c.Run(s)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error executing task stat command: %s\n",
+ err.Error())
+ return err
+ }
+
+ if res.Status() != 0 {
+ fmt.Printf("Peer responded negatively to task stat command; "+
+ "status=%d\n", res.Status())
+ }
+
+ eres := res.(*xact.TaskStatResult)
+ fmt.Printf("Peer responded with task stat: %#v\n", eres.Rsp)
+
+ return nil
+}
+
func sendOne(s sesn.Sesn) {
// Repeatedly:
// * Connect to peer if unconnected.
@@ -74,27 +159,27 @@ func sendOne(s sesn.Sesn) {
return
}
}
+ defer s.Close()
// Send an echo command to the peer.
- c := xact.NewEchoCmd()
- c.Payload = fmt.Sprintf("hello %p", s)
-
- res, err := c.Run(s)
- if err != nil {
- fmt.Fprintf(os.Stderr, "error executing echo command: %s\n",
- err.Error())
+ if err := sendEcho(s); err != nil {
return
}
- if res.Status() != 0 {
- fmt.Printf("Peer responded negatively to echo command; status=%d\n",
- res.Status())
+ // Image list
+ if err := sendImageState(s); err != nil {
+ return
}
- eres := res.(*xact.EchoResult)
- fmt.Printf("Peer echoed back: %s\n", eres.Rsp.Payload)
+ // MP stat
+ if err := sendMpStat(s); err != nil {
+ return
+ }
- s.Close()
+ // Task stat
+ if err := sendTaskStat(s); err != nil {
+ return
+ }
}
func main() {
@@ -124,7 +209,7 @@ func main() {
configExitHandler(x)
peerNames := []string{
- "ccollins",
+ "ccollins1",
"ccollins2",
"ccollins3",
}
[3/3] incubator-mynewt-newtmgr git commit: nmxact - More logging.
Posted by cc...@apache.org.
nmxact - More logging.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/commit/41cf2746
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/tree/41cf2746
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/diff/41cf2746
Branch: refs/heads/master
Commit: 41cf27469bf26b791334380676457ba80fc0ccb2
Parents: 9e80738
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 12 11:21:35 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 12 11:23:19 2017 -0700
----------------------------------------------------------------------
nmxact/nmble/ble_fsm.go | 13 ++++++++-----
nmxact/nmble/ble_oic_sesn.go | 13 +++++++++++++
nmxact/nmble/ble_plain_sesn.go | 13 +++++++++++++
nmxact/nmble/ble_xport.go | 1 +
nmxact/nmxutil/nmxutil.go | 3 ++-
5 files changed, 37 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/41cf2746/nmxact/nmble/ble_fsm.go
----------------------------------------------------------------------
diff --git a/nmxact/nmble/ble_fsm.go b/nmxact/nmble/ble_fsm.go
index 9a01a70..4dd8e66 100644
--- a/nmxact/nmble/ble_fsm.go
+++ b/nmxact/nmble/ble_fsm.go
@@ -139,7 +139,7 @@ func (bf *BleFsm) addBleListener(name string, base BleMsgBase) (
_, file, line, _ := runtime.Caller(2)
file = path.Base(file)
- nmxutil.ListenLog.Debugf("[%d] {add-listener} [%s:%d] %s: base=%+v",
+ nmxutil.ListenLog.Debugf("[%d] {add-ble-listener} [%s:%d] %s: base=%+v",
bf.id, file, line, name, base)
bl := NewBleListener()
@@ -177,7 +177,7 @@ func (bf *BleFsm) addBleSeqListener(name string, seq BleSeq) (
func (bf *BleFsm) removeBleListener(name string, base BleMsgBase) {
_, file, line, _ := runtime.Caller(2)
file = path.Base(file)
- nmxutil.ListenLog.Debugf("[%d] {remove-listener} [%s:%d] %s: base=%+v",
+ nmxutil.ListenLog.Debugf("[%d] {remove-ble-listener} [%s:%d] %s: base=%+v",
bf.id, file, line, name, base)
bf.blsMtx.Lock()
@@ -399,8 +399,6 @@ func (bf *BleFsm) nmpRspListen() error {
bf.params.RxNmpCb(msg.Data.Bytes)
}
-
- default:
}
}
}
@@ -868,7 +866,12 @@ func (bf *BleFsm) TxNmp(payload []byte, nl *nmp.NmpListener,
return rsp, nil
}
case <-nl.AfterTimeout(timeout):
- return nil, nmxutil.NewNmpTimeoutError("NMP timeout")
+ msg := fmt.Sprintf(
+ "NMP timeout; op=%d group=%d id=%d seq=%d peer=%#v",
+ payload[0], payload[4]+payload[5]<<8,
+ payload[7], payload[6], bf.peerDev)
+
+ return nil, nmxutil.NewNmpTimeoutError(msg)
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/41cf2746/nmxact/nmble/ble_oic_sesn.go
----------------------------------------------------------------------
diff --git a/nmxact/nmble/ble_oic_sesn.go b/nmxact/nmble/ble_oic_sesn.go
index 0c7b052..433ecb0 100644
--- a/nmxact/nmble/ble_oic_sesn.go
+++ b/nmxact/nmble/ble_oic_sesn.go
@@ -2,12 +2,15 @@ package nmble
import (
"fmt"
+ "path"
+ "runtime"
"sync"
"time"
"mynewt.apache.org/newt/util"
. "mynewt.apache.org/newtmgr/nmxact/bledefs"
"mynewt.apache.org/newtmgr/nmxact/nmp"
+ "mynewt.apache.org/newtmgr/nmxact/nmxutil"
"mynewt.apache.org/newtmgr/nmxact/omp"
"mynewt.apache.org/newtmgr/nmxact/sesn"
)
@@ -67,6 +70,11 @@ func (bos *BleOicSesn) addNmpListener(seq uint8) (*nmp.NmpListener, error) {
bos.mtx.Lock()
defer bos.mtx.Unlock()
+ _, file, line, _ := runtime.Caller(1)
+ file = path.Base(file)
+ nmxutil.ListenLog.Debugf("{add-nmp-listener} [%s:%d] seq=%+v",
+ file, line, seq)
+
nl := nmp.NewNmpListener()
if err := bos.od.AddListener(seq, nl); err != nil {
return nil, err
@@ -80,6 +88,11 @@ func (bos *BleOicSesn) removeNmpListener(seq uint8) {
bos.mtx.Lock()
defer bos.mtx.Unlock()
+ _, file, line, _ := runtime.Caller(1)
+ file = path.Base(file)
+ nmxutil.ListenLog.Debugf("{remove-nmp-listener} [%s:%d] seq=%+v",
+ file, line, seq)
+
listener := bos.od.RemoveListener(seq)
if listener != nil {
delete(bos.nls, listener)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/41cf2746/nmxact/nmble/ble_plain_sesn.go
----------------------------------------------------------------------
diff --git a/nmxact/nmble/ble_plain_sesn.go b/nmxact/nmble/ble_plain_sesn.go
index 9e1f70d..2bcd950 100644
--- a/nmxact/nmble/ble_plain_sesn.go
+++ b/nmxact/nmble/ble_plain_sesn.go
@@ -2,12 +2,15 @@ package nmble
import (
"fmt"
+ "path"
+ "runtime"
"sync"
"time"
"mynewt.apache.org/newt/util"
. "mynewt.apache.org/newtmgr/nmxact/bledefs"
"mynewt.apache.org/newtmgr/nmxact/nmp"
+ "mynewt.apache.org/newtmgr/nmxact/nmxutil"
"mynewt.apache.org/newtmgr/nmxact/sesn"
)
@@ -61,6 +64,11 @@ func (bps *BlePlainSesn) addNmpListener(seq uint8) (*nmp.NmpListener, error) {
bps.mtx.Lock()
defer bps.mtx.Unlock()
+ _, file, line, _ := runtime.Caller(1)
+ file = path.Base(file)
+ nmxutil.ListenLog.Debugf("{add-nmp-listener} [%s:%d] seq=%+v",
+ file, line, seq)
+
nl := nmp.NewNmpListener()
if err := bps.nd.AddListener(seq, nl); err != nil {
return nil, err
@@ -74,6 +82,11 @@ func (bps *BlePlainSesn) removeNmpListener(seq uint8) {
bps.mtx.Lock()
defer bps.mtx.Unlock()
+ _, file, line, _ := runtime.Caller(1)
+ file = path.Base(file)
+ nmxutil.ListenLog.Debugf("{remove-nmp-listener} [%s:%d] seq=%+v",
+ file, line, seq)
+
listener := bps.nd.RemoveListener(seq)
if listener != nil {
delete(bps.nls, listener)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/41cf2746/nmxact/nmble/ble_xport.go
----------------------------------------------------------------------
diff --git a/nmxact/nmble/ble_xport.go b/nmxact/nmble/ble_xport.go
index d78a000..4f53255 100644
--- a/nmxact/nmble/ble_xport.go
+++ b/nmxact/nmble/ble_xport.go
@@ -322,6 +322,7 @@ func (bx *BleXport) setStateFrom(from BleXportState, to BleXportState) bool {
}
func (bx *BleXport) Stop() error {
+ // XXX: Reset controller to terminate all connections.
bx.shutdown(false, nmxutil.NewXportError("xport stopped"))
return nil
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/41cf2746/nmxact/nmxutil/nmxutil.go
----------------------------------------------------------------------
diff --git a/nmxact/nmxutil/nmxutil.go b/nmxact/nmxutil/nmxutil.go
index 2f967a0..707b1bc 100644
--- a/nmxact/nmxutil/nmxutil.go
+++ b/nmxact/nmxutil/nmxutil.go
@@ -15,12 +15,13 @@ var seqMutex sync.Mutex
var ListenLog = &log.Logger{
Out: os.Stderr,
- Formatter: new(log.TextFormatter),
+ Formatter: &log.TextFormatter{ForceColors: true},
Level: log.DebugLevel,
}
func SetLogLevel(level log.Level) {
log.SetLevel(level)
+ log.SetFormatter(&log.TextFormatter{ForceColors: true})
ListenLog.Level = level
}