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/08/24 19:12:27 UTC
[mynewt-newtmgr] 02/03: newtmgr - --write-rsp option to send acked
req.
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 99060ac9c78908649989e2eff185856de4320135
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Thu Aug 24 12:11:08 2017 -0700
newtmgr - --write-rsp option to send acked req.
---
newtmgr/bll/bll_sesn.go | 2 +-
newtmgr/bll/bll_sesn_cfg.go | 2 ++
newtmgr/cli/commands.go | 3 +++
newtmgr/config/ble_config.go | 2 ++
newtmgr/config/bll_config.go | 2 ++
newtmgr/nmutil/nmutil.go | 1 +
nmxact/nmble/ble_sesn.go | 12 ++++++++++--
nmxact/sesn/sesn_cfg.go | 2 ++
8 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/newtmgr/bll/bll_sesn.go b/newtmgr/bll/bll_sesn.go
index 3ccdc6c..853db30 100644
--- a/newtmgr/bll/bll_sesn.go
+++ b/newtmgr/bll/bll_sesn.go
@@ -406,7 +406,7 @@ func (s *BllSesn) TxCoapOnce(m coap.Message, resType sesn.ResourceType,
}
txRaw := func(b []byte) error {
- return s.txWriteCharacteristic(chr, b, true)
+ return s.txWriteCharacteristic(chr, b, !s.cfg.WriteRsp)
}
rsp, err := s.txvr.TxOic(txRaw, m, s.MtuOut(), opt.Timeout)
diff --git a/newtmgr/bll/bll_sesn_cfg.go b/newtmgr/bll/bll_sesn_cfg.go
index 36327cb..954c921 100644
--- a/newtmgr/bll/bll_sesn_cfg.go
+++ b/newtmgr/bll/bll_sesn_cfg.go
@@ -35,6 +35,7 @@ type BllSesnCfg struct {
PreferredMtu uint16
ConnTimeout time.Duration
ConnTries int
+ WriteRsp bool
}
func NewBllSesnCfg() BllSesnCfg {
@@ -42,5 +43,6 @@ func NewBllSesnCfg() BllSesnCfg {
PreferredMtu: 512,
ConnTimeout: 10 * time.Second,
ConnTries: 3,
+ WriteRsp: false,
}
}
diff --git a/newtmgr/cli/commands.go b/newtmgr/cli/commands.go
index cde0416..0089573 100644
--- a/newtmgr/cli/commands.go
+++ b/newtmgr/cli/commands.go
@@ -68,6 +68,9 @@ func Commands() *cobra.Command {
nmCmd.PersistentFlags().StringVar(&nmutil.DeviceName, "name",
"", "name of target BLE device; overrides profile setting")
+ nmCmd.PersistentFlags().BoolVar(&nmutil.BleWriteRsp, "write-rsp", false,
+ "Send BLE acked write requests instead of unacked write commands")
+
nmCmd.AddCommand(crashCmd())
nmCmd.AddCommand(dateTimeCmd())
nmCmd.AddCommand(fsCmd())
diff --git a/newtmgr/config/ble_config.go b/newtmgr/config/ble_config.go
index 4d8bc35..f4875c3 100644
--- a/newtmgr/config/ble_config.go
+++ b/newtmgr/config/ble_config.go
@@ -141,6 +141,8 @@ func FillSesnCfg(bx *nmble.BleXport, bc *BleConfig, sc *sesn.SesnCfg) error {
// We don't need to stick around until a connection closes.
sc.Ble.CloseTimeout = 10000 * time.Millisecond
+ sc.Ble.WriteRsp = nmutil.BleWriteRsp
+
return nil
}
diff --git a/newtmgr/config/bll_config.go b/newtmgr/config/bll_config.go
index c476a19..d0b995b 100644
--- a/newtmgr/config/bll_config.go
+++ b/newtmgr/config/bll_config.go
@@ -99,5 +99,7 @@ func BuildBllSesnCfg(bc *BllConfig) (bll.BllSesnCfg, error) {
return sc, util.NewNewtError("bll session lacks a peer specifier")
}
+ sc.WriteRsp = nmutil.BleWriteRsp
+
return sc, nil
}
diff --git a/newtmgr/nmutil/nmutil.go b/newtmgr/nmutil/nmutil.go
index c0cb124..79e7ef6 100644
--- a/newtmgr/nmutil/nmutil.go
+++ b/newtmgr/nmutil/nmutil.go
@@ -31,6 +31,7 @@ var Timeout float64
var Tries int
var ConnProfile string
var DeviceName string
+var BleWriteRsp bool
func TxOptions() sesn.TxOptions {
return sesn.TxOptions{
diff --git a/nmxact/nmble/ble_sesn.go b/nmxact/nmble/ble_sesn.go
index ad990e4..a980141 100644
--- a/nmxact/nmble/ble_sesn.go
+++ b/nmxact/nmble/ble_sesn.go
@@ -365,7 +365,11 @@ func (s *BleSesn) TxNmpOnce(req *nmp.NmpMsg, opt sesn.TxOptions) (
}
txRaw := func(b []byte) error {
- return s.conn.WriteChrNoRsp(chr, b, "nmp")
+ if s.cfg.Ble.WriteRsp {
+ return s.conn.WriteChr(chr, b, "nmp")
+ } else {
+ return s.conn.WriteChrNoRsp(chr, b, "nmp")
+ }
}
return s.txvr.TxNmp(txRaw, req, s.MtuOut(), opt.Timeout)
@@ -394,7 +398,11 @@ func (s *BleSesn) TxCoapOnce(m coap.Message,
}
txRaw := func(b []byte) error {
- return s.conn.WriteChrNoRsp(chr, b, "coap")
+ if s.cfg.Ble.WriteRsp {
+ return s.conn.WriteChr(chr, b, "coap")
+ } else {
+ return s.conn.WriteChrNoRsp(chr, b, "coap")
+ }
}
rsp, err := s.txvr.TxOic(txRaw, m, s.MtuOut(), opt.Timeout)
diff --git a/nmxact/sesn/sesn_cfg.go b/nmxact/sesn/sesn_cfg.go
index c3e84f4..005dfa0 100644
--- a/nmxact/sesn/sesn_cfg.go
+++ b/nmxact/sesn/sesn_cfg.go
@@ -79,6 +79,7 @@ type SesnCfgBle struct {
OwnAddrType bledefs.BleAddrType
EncryptWhen bledefs.BleEncryptWhen
CloseTimeout time.Duration
+ WriteRsp bool
// Central configuration.
Central SesnCfgBleCentral
@@ -102,6 +103,7 @@ func NewSesnCfg() SesnCfg {
Ble: SesnCfgBle{
OwnAddrType: bledefs.BLE_ADDR_TYPE_RANDOM,
CloseTimeout: 30 * time.Second,
+ WriteRsp: false,
Central: SesnCfgBleCentral{
ConnTries: 3,
--
To stop receiving notification emails like this one, please contact
"commits@mynewt.apache.org" <co...@mynewt.apache.org>.