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 2016/05/17 21:05:05 UTC

[2/3] incubator-mynewt-newt git commit: newtmgr; add sequence number to request header.

newtmgr; add sequence number to request header.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/51d5ad14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/51d5ad14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/51d5ad14

Branch: refs/heads/master
Commit: 51d5ad1418041b8e4bde21a0cfc6e7a7f32e7106
Parents: cb5b1c0
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue May 3 15:36:33 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon May 9 08:30:38 2016 -0700

----------------------------------------------------------------------
 newtmgr/protocol/nmgr.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/51d5ad14/newtmgr/protocol/nmgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/nmgr.go b/newtmgr/protocol/nmgr.go
index 4c60517..331c8b2 100644
--- a/newtmgr/protocol/nmgr.go
+++ b/newtmgr/protocol/nmgr.go
@@ -33,7 +33,8 @@ type NmgrReq struct {
 	Flags uint8
 	Len   uint16
 	Group uint16
-	Id    uint16
+	Seq   uint8
+	Id    uint8
 	Data  []byte
 }
 
@@ -63,7 +64,8 @@ func DeserializeNmgrReq(data []byte) (*NmgrReq, error) {
 	nmr.Flags = uint8(data[1])
 	nmr.Len = binary.BigEndian.Uint16(data[2:4])
 	nmr.Group = binary.BigEndian.Uint16(data[4:6])
-	nmr.Id = binary.BigEndian.Uint16(data[6:8])
+	nmr.Seq = uint8(data[6])
+	nmr.Id = uint8(data[7])
 
 	data = data[8:]
 	if int(nmr.Len) != len(data) {
@@ -74,6 +76,8 @@ func DeserializeNmgrReq(data []byte) (*NmgrReq, error) {
 	}
 	nmr.Data = data
 
+	log.Debugf("Deserialized response %+v", nmr)
+
 	return nmr, nil
 }
 
@@ -90,8 +94,8 @@ func (nmr *NmgrReq) SerializeRequest(data []byte) ([]byte, error) {
 	binary.BigEndian.PutUint16(u16b, nmr.Group)
 	data = append(data, u16b...)
 
-	binary.BigEndian.PutUint16(u16b, nmr.Id)
-	data = append(data, u16b...)
+	data = append(data, byte(nmr.Seq))
+	data = append(data, byte(nmr.Id))
 
 	data = append(data, nmr.Data...)