This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 32f52623a4666ad6188dc392306a1734d67e3af8
Author: Szymon Janc <[email protected]>
AuthorDate: Thu Oct 22 00:20:49 2026 +0200

    newtmgr/config: Apply --hci index with an empty bll connstring
    
    ParseBllConnString() returned early for an empty connstring before
    copying nmutil.HciIdx into the config. Running e.g.
    "newtmgr --conntype ble -n mydev -i 1 echo hi" without a connstring
    therefore silently used HCI controller 0 instead of the requested
    one. Set the HCI index before the early return.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newtmgr/config/bll_config.go      | 3 +--
 newtmgr/config/bll_config_test.go | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/newtmgr/config/bll_config.go b/newtmgr/config/bll_config.go
index fe39a09..4fe2f12 100644
--- a/newtmgr/config/bll_config.go
+++ b/newtmgr/config/bll_config.go
@@ -60,6 +60,7 @@ func einvalBllConnString(f string, args ...interface{}) error 
{
 
 func ParseBllConnString(cs string) (*BllConfig, error) {
        bc := NewBllConfig()
+       bc.HciIdx = nmutil.HciIdx
 
        if strings.TrimSpace(cs) == "" {
                return bc, nil
@@ -101,8 +102,6 @@ func ParseBllConnString(cs string) (*BllConfig, error) {
                }
        }
 
-       bc.HciIdx = nmutil.HciIdx
-
        return bc, nil
 }
 
diff --git a/newtmgr/config/bll_config_test.go 
b/newtmgr/config/bll_config_test.go
index cc6474a..d3b1b65 100644
--- a/newtmgr/config/bll_config_test.go
+++ b/newtmgr/config/bll_config_test.go
@@ -54,6 +54,10 @@ func TestParseBllConnString(t *testing.T) {
                cs   string
                want BllConfig
        }{
+               // The --hci index must be applied even without a connstring
+               // (e.g. when the peer is given with -n).
+               {"empty", "", BllConfig{ConnTimeout: 4, HciIdx: 1}},
+               {"whitespace", "  ", BllConfig{ConnTimeout: 4, HciIdx: 1}},
                {"peer_name", "peer_name=mydev",
                        BllConfig{PeerName: "mydev", ConnTimeout: 4, HciIdx: 
1}},
                {"all keys",

Reply via email to