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
commit a09fa371fa662bed300d3c921b1f4b83c72eb378 Author: Christopher Collins <ccoll...@apache.org> AuthorDate: Wed Aug 9 14:25:58 2017 -0700 newtmgr - revendor --- newtmgr/Godeps/Godeps.json | 56 +++++++++++----------- .../newtmgr/nmxact/bledefs/bledefs.go | 27 +++++++---- .../newtmgr/nmxact/nmble/ble_sesn.go | 45 ++++++++++------- .../newtmgr/nmxact/nmble/ble_util.go | 12 +++++ 4 files changed, 86 insertions(+), 54 deletions(-) diff --git a/newtmgr/Godeps/Godeps.json b/newtmgr/Godeps/Godeps.json index 71f7194..f35cbe9 100644 --- a/newtmgr/Godeps/Godeps.json +++ b/newtmgr/Godeps/Godeps.json @@ -127,73 +127,73 @@ }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/adv", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/bledefs", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/mgmt", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmble", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmp", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmserial", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmxutil", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/oic", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/omp", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/scan", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/sesn", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/udp", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/xact", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" }, { "ImportPath": "mynewt.apache.org/newtmgr/nmxact/xport", - "Comment": "mynewt_1_1_0_tag-26-ga8e52fd", - "Rev": "a8e52fd9143c904cbdf1b45445a678b4b598864d" + "Comment": "mynewt_1_1_0_tag-28-ga1eb1c2", + "Rev": "a1eb1c28dad0c19919d624039c042de9ae63ce8a" } ] } diff --git a/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/bledefs/bledefs.go b/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/bledefs/bledefs.go index fe0322a..780587e 100644 --- a/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/bledefs/bledefs.go +++ b/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/bledefs/bledefs.go @@ -33,6 +33,18 @@ const BLE_ATT_MTU_DFLT = 23 const CccdUuid = 0x2902 +const PublicSvcUuid = "40e32721-9153-43a3-9ab3-ee7d4c84fcb2" +const PublicReqChrUuid = "223387b6-63e6-4d16-8a58-988542253a54" +const PublicRspChrUuid = "cb9564db-184c-4b9d-b221-6362679cad10" + +const UnauthSvcUuid = "0c08c213-98ed-4e43-a499-7e1137c39567" +const UnauthReqChrUuid = "69b8a928-2ab2-487b-923e-54ce53a18bc1" +const UnauthRspChrUuid = "bca10aea-5df1-4248-b72b-f52955ad9c88" + +const SecureSvcUuid = 0xfe18 +const SecureReqChrUuid = 0x1000 +const SecureRspChrUuid = 0x1001 + const NmpPlainSvcUuid = "8d53dc1d-1db7-4cd3-868b-8a527460aa84" const NmpPlainChrUuid = "da2e7828-fbce-4e01-ae9e-261174997c48" @@ -40,13 +52,9 @@ const OmpUnsecSvcUuid = "ade3d529-c784-4f63-a987-eb69f70ee816" const OmpUnsecReqChrUuid = "ad7b334f-4637-4b86-90b6-9d787f03d218" const OmpUnsecRspChrUuid = "e9241982-4580-42c4-8831-95048216b256" -const OmpSecSvcUuid = 0xfe18 -const OmpSecReqChrUuid = 0x1000 -const OmpSecRspChrUuid = 0x1001 - -const UnauthSvcUuid = "0c08c213-98ed-4e43-a499-7e1137c39567" -const UnauthReqChrUuid = "69b8a928-2ab2-487b-923e-54ce53a18bc1" -const UnauthRspChrUuid = "bca10aea-5df1-4248-b72b-f52955ad9c88" +const OmpSecSvcUuid = SecureSvcUuid +const OmpSecReqChrUuid = SecureReqChrUuid +const OmpSecRspChrUuid = SecureRspChrUuid type BleAddrType int @@ -252,7 +260,6 @@ type BleUuid struct { // Set to 0 if the 128-bit UUID should be used. U16 BleUuid16 - // Set to nil if the 16-bit UUID should be used. U128 BleUuid128 } @@ -283,6 +290,10 @@ func ParseUuid(uuidStr string) (BleUuid, error) { return bu, err } +func NewBleUuid16(uuid16 uint16) BleUuid { + return BleUuid{BleUuid16(uuid16), BleUuid128{}} +} + func (bu *BleUuid) MarshalJSON() ([]byte, error) { if bu.U16 != 0 { return json.Marshal(bu.U16) diff --git a/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_sesn.go b/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_sesn.go index 00aef91..5f03153 100644 --- a/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_sesn.go +++ b/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_sesn.go @@ -23,6 +23,7 @@ import ( "fmt" "sync" + log "github.com/Sirupsen/logrus" "github.com/runtimeco/go-coap" . "mynewt.apache.org/newtmgr/nmxact/bledefs" @@ -33,8 +34,6 @@ import ( "mynewt.apache.org/newtmgr/nmxact/sesn" ) -var dummyNotifyListener = NewNotifyListener() - type BleSesn struct { cfg sesn.SesnCfg bx *BleXport @@ -111,8 +110,8 @@ func (s *BleSesn) disconnectListen() { func (s *BleSesn) getChr(chrId *BleChrId) (*Characteristic, error) { if chrId == nil { - return nil, fmt.Errorf("BLE session not configured with required "+ - "characteristic: %s", *chrId) + return nil, fmt.Errorf("BLE session not configured with required " + + "characteristic") } chr := s.conn.Profile().FindChrByUuid(*chrId) @@ -124,22 +123,25 @@ func (s *BleSesn) getChr(chrId *BleChrId) (*Characteristic, error) { return chr, nil } -func (s *BleSesn) createNotifyListener(chrId *BleChrId) *NotifyListener { - chr, _ := s.getChr(chrId) - if chr == nil { - return dummyNotifyListener - } +func (s *BleSesn) createNotifyListener(chrId *BleChrId) ( + *NotifyListener, error) { - nl := s.conn.ListenForNotifications(chr) - if nl == nil { - return dummyNotifyListener + chr, err := s.getChr(chrId) + if err != nil { + return nil, err } - return nl + return s.conn.ListenForNotifications(chr), nil } -func (s *BleSesn) notifyListen() { - nmpRspNl := s.createNotifyListener(s.mgmtChrs.NmpRspChr) +func (s *BleSesn) notifyListenOnce(chrId *BleChrId, + dispatchCb func(b []byte)) { + + nl, err := s.createNotifyListener(chrId) + if err != nil { + log.Debugf("error listening for notifications: %s", err.Error()) + return + } s.wg.Add(1) go func() { @@ -147,14 +149,14 @@ func (s *BleSesn) notifyListen() { for { select { - case <-nmpRspNl.ErrChan: + case <-nl.ErrChan: return - case n, ok := <-nmpRspNl.NotifyChan: + case n, ok := <-nl.NotifyChan: if !ok { return } - s.txvr.DispatchNmpRsp(n.Data) + dispatchCb(n.Data) case <-s.stopChan: return @@ -163,6 +165,13 @@ func (s *BleSesn) notifyListen() { }() } +func (s *BleSesn) notifyListen() { + s.notifyListenOnce(s.mgmtChrs.NmpRspChr, s.txvr.DispatchNmpRsp) + s.notifyListenOnce(s.mgmtChrs.ResPublicRspChr, s.txvr.DispatchCoap) + s.notifyListenOnce(s.mgmtChrs.ResUnauthRspChr, s.txvr.DispatchCoap) + s.notifyListenOnce(s.mgmtChrs.ResSecureRspChr, s.txvr.DispatchCoap) +} + func (s *BleSesn) openOnce() (bool, error) { if s.IsOpen() { return false, nmxutil.NewSesnAlreadyOpenError( diff --git a/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_util.go b/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_util.go index 470db01..8a11ec0 100644 --- a/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_util.go +++ b/newtmgr/vendor/mynewt.apache.org/newtmgr/nmxact/nmble/ble_util.go @@ -765,10 +765,18 @@ func BuildMgmtChrs(mgmtProto sesn.MgmtProto) (BleMgmtChrs, error) { ompReqChrUuid, _ := ParseUuid(OmpUnsecReqChrUuid) ompRspChrUuid, _ := ParseUuid(OmpUnsecRspChrUuid) + publicSvcUuid, _ := ParseUuid(PublicSvcUuid) + publicReqChrUuid, _ := ParseUuid(PublicReqChrUuid) + publicRspChrUuid, _ := ParseUuid(PublicRspChrUuid) + unauthSvcUuid, _ := ParseUuid(UnauthSvcUuid) unauthReqChrUuid, _ := ParseUuid(UnauthReqChrUuid) unauthRspChrUuid, _ := ParseUuid(UnauthRspChrUuid) + secureSvcUuid := NewBleUuid16(SecureSvcUuid) + secureReqChrUuid := NewBleUuid16(SecureReqChrUuid) + secureRspChrUuid := NewBleUuid16(SecureRspChrUuid) + switch mgmtProto { case sesn.MGMT_PROTO_NMP: mgmtChrs.NmpReqChr = &BleChrId{nmpSvcUuid, nmpChrUuid} @@ -783,8 +791,12 @@ func BuildMgmtChrs(mgmtProto sesn.MgmtProto) (BleMgmtChrs, error) { fmt.Errorf("invalid management protocol: %+v", mgmtProto) } + mgmtChrs.ResPublicReqChr = &BleChrId{publicSvcUuid, publicReqChrUuid} + mgmtChrs.ResPublicRspChr = &BleChrId{publicSvcUuid, publicRspChrUuid} mgmtChrs.ResUnauthReqChr = &BleChrId{unauthSvcUuid, unauthReqChrUuid} mgmtChrs.ResUnauthRspChr = &BleChrId{unauthSvcUuid, unauthRspChrUuid} + mgmtChrs.ResSecureReqChr = &BleChrId{secureSvcUuid, secureReqChrUuid} + mgmtChrs.ResSecureRspChr = &BleChrId{secureSvcUuid, secureRspChrUuid} return mgmtChrs, nil } -- To stop receiving notification emails like this one, please contact "commits@mynewt.apache.org" <commits@mynewt.apache.org>.