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 <[email protected]> Authored: Wed Apr 12 11:21:35 2017 -0700 Committer: Christopher Collins <[email protected]> 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 }
