You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/07/12 17:13:26 UTC

[GitHub] ccollins476ad closed pull request #94: Allow "conn_timeout" for ble and bll types.

ccollins476ad closed pull request #94: Allow "conn_timeout" for ble and bll types.
URL: https://github.com/apache/mynewt-newtmgr/pull/94
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newtmgr/config/ble_config.go b/newtmgr/config/ble_config.go
index f4875c31..82e7d163 100644
--- a/newtmgr/config/ble_config.go
+++ b/newtmgr/config/ble_config.go
@@ -40,6 +40,9 @@ type BleConfig struct {
 	OwnAddrType bledefs.BleAddrType
 	OwnAddr     bledefs.BleAddr
 
+	// Connection timeout, in seconds.
+	ConnTimeout float64
+
 	BlehostdPath   string
 	ControllerPath string
 }
@@ -47,6 +50,7 @@ type BleConfig struct {
 func NewBleConfig() *BleConfig {
 	return &BleConfig{
 		OwnAddrType:  bledefs.BLE_ADDR_TYPE_RANDOM,
+		ConnTimeout:  nmutil.Timeout,
 		BlehostdPath: "blehostd",
 	}
 }
@@ -138,7 +142,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.Central.ConnTimeout =
+		time.Duration(bc.ConnTimeout*1000000000) * time.Nanosecond
 	sc.Ble.CloseTimeout = 10000 * time.Millisecond
 
 	sc.Ble.WriteRsp = nmutil.BleWriteRsp
diff --git a/newtmgr/config/bll_config.go b/newtmgr/config/bll_config.go
index 9235d02c..070d9ffd 100644
--- a/newtmgr/config/bll_config.go
+++ b/newtmgr/config/bll_config.go
@@ -23,7 +23,9 @@ package config
 
 import (
 	"fmt"
+	"strconv"
 	"strings"
+	"time"
 
 	"github.com/go-ble/ble"
 
@@ -38,10 +40,15 @@ type BllConfig struct {
 	OwnAddrType bledefs.BleAddrType
 	PeerId      string
 	PeerName    string
+
+	// Connection timeout, in seconds.
+	ConnTimeout float64
 }
 
 func NewBllConfig() *BllConfig {
-	return &BllConfig{}
+	return &BllConfig{
+		ConnTimeout: nmutil.Timeout,
+	}
 }
 
 func einvalBllConnString(f string, args ...interface{}) error {
@@ -80,6 +87,13 @@ func ParseBllConnString(cs string) (*BllConfig, error) {
 			bc.PeerId = v
 		case "peer_name":
 			bc.PeerName = v
+		case "conn_timeout":
+			var err error
+			bc.ConnTimeout, err = strconv.ParseFloat(v, 64)
+			if err != nil {
+				return nil, einvalBleConnString("Invalid conn_timeout: %s", v)
+			}
+
 		default:
 			return nil, einvalBllConnString("Unrecognized key: %s", k)
 		}
@@ -108,6 +122,7 @@ func BuildBllSesnCfg(bc *BllConfig) (bll.BllSesnCfg, error) {
 	}
 
 	sc.WriteRsp = nmutil.BleWriteRsp
+	sc.ConnTimeout = time.Duration(bc.ConnTimeout*1000000000) * time.Nanosecond
 
 	return sc, nil
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services