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/07/19 20:30:23 UTC
[3/9] incubator-mynewt-newt git commit: MYNEWT-266 newtmgr over BLE
MYNEWT-266 newtmgr over BLE
- Add BLE MTU to transport
- default mtu is 120 if transport is not BLE
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/b3a8cc84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/b3a8cc84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/b3a8cc84
Branch: refs/heads/develop
Commit: b3a8cc84ca89b5ac95f1ea82858ec7834a44fd80
Parents: d2660af
Author: admin <vr...@gmail.com>
Authored: Mon Jul 11 16:47:55 2016 -0700
Committer: Vipul Rahane <vi...@runtime.io>
Committed: Tue Jul 19 13:06:58 2016 -0700
----------------------------------------------------------------------
newtmgr/cli/image.go | 9 +++++++--
newtmgr/transport/connble.go | 7 +++++--
2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b3a8cc84/newtmgr/cli/image.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index f68f980..c638408 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -36,7 +36,6 @@ import (
"github.com/spf13/cobra"
)
-const bleMTU = 240
var (
coreElfify bool
@@ -169,9 +168,16 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
}
}
var currOff uint32 = 0
+ var mtu uint32 = 0
imageSz := uint32(len(imageFile))
rexmits := 0
+ if (profile.Type() == "ble") {
+ mtu = uint32((transport.BleMTU - 33) * 3/4)
+ } else {
+ mtu = 120
+ }
+
for currOff < imageSz {
imageUpload, err := protocol.NewImageUpload()
if err != nil {
@@ -179,7 +185,6 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
}
blockSz := imageSz - currOff
- mtu := uint32((bleMTU - 33) * 3/4)
if blockSz > mtu {
blockSz = mtu
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b3a8cc84/newtmgr/transport/connble.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connble.go b/newtmgr/transport/connble.go
index 4a49780..bd38474 100644
--- a/newtmgr/transport/connble.go
+++ b/newtmgr/transport/connble.go
@@ -24,12 +24,15 @@ import (
log "github.com/Sirupsen/logrus"
"time"
- "github.com/paypal/gatt"
+ "github.com/runtimeinc/gatt"
"mynewt.apache.org/newt/newtmgr/config"
"mynewt.apache.org/newt/util"
)
+/* This is used by different command handlers */
+var BleMTU uint16 = 180
+
var rxBLEPkt = make(chan []byte)
var CharDisc = make(chan bool)
@@ -98,7 +101,7 @@ func onPeriphConnected(p gatt.Peripheral, err error) {
p.SetNotifyValue(c, newtmgrNotifyCB)
deviceChar = c
devicePerph = p
- p.SetMTU(240)
+ p.SetMTU(BleMTU)
<-CharDisc
}
}