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/03/28 22:42:04 UTC
[67/67] [abbrv] incubator-mynewt-newtmgr git commit: newtmgr - use
newtmgr repo, not newt repo.
newtmgr - use newtmgr repo, not newt repo.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/commit/15498bdc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/tree/15498bdc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/diff/15498bdc
Branch: refs/heads/master
Commit: 15498bdcff2206a39e062527090f21269ff34983
Parents: e31a7d3
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Mar 28 15:31:40 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Mar 28 15:38:37 2017 -0700
----------------------------------------------------------------------
newtmgr/Godeps/Godeps.json | 80 +-
newtmgr/cli/commands.go | 2 +-
newtmgr/cli/common.go | 10 +-
newtmgr/cli/config.go | 6 +-
newtmgr/cli/connprofile.go | 2 +-
newtmgr/cli/crash.go | 4 +-
newtmgr/cli/datetime.go | 6 +-
newtmgr/cli/echo.go | 4 +-
newtmgr/cli/fs.go | 6 +-
newtmgr/cli/image.go | 8 +-
newtmgr/cli/log.go | 6 +-
newtmgr/cli/mpstat.go | 4 +-
newtmgr/cli/reset.go | 4 +-
newtmgr/cli/run.go | 4 +-
newtmgr/cli/stat.go | 4 +-
newtmgr/cli/taskstat.go | 4 +-
newtmgr/config/ble_config.go | 6 +-
newtmgr/config/serial_config.go | 4 +-
newtmgr/newtmgr.go | 6 +-
newtmgr/nmutil/nmutil.go | 2 +-
.../newt/nmxact/bledefs/bledefs.go | 270 ------
.../newt/nmxact/nmble/ble_act.go | 363 --------
.../newt/nmxact/nmble/ble_fsm.go | 766 -----------------
.../newt/nmxact/nmble/ble_oic_sesn.go | 198 -----
.../newt/nmxact/nmble/ble_plain_sesn.go | 186 -----
.../newt/nmxact/nmble/ble_proto.go | 829 -------------------
.../newt/nmxact/nmble/ble_util.go | 174 ----
.../newt/nmxact/nmble/ble_xport.go | 319 -------
.../newt/nmxact/nmble/dispatch.go | 297 -------
.../mynewt.apache.org/newt/nmxact/nmp/config.go | 80 --
.../mynewt.apache.org/newt/nmxact/nmp/crash.go | 46 -
.../newt/nmxact/nmp/datetime.go | 78 --
.../mynewt.apache.org/newt/nmxact/nmp/decode.go | 121 ---
.../mynewt.apache.org/newt/nmxact/nmp/defs.go | 88 --
.../newt/nmxact/nmp/dispatch.go | 167 ----
.../mynewt.apache.org/newt/nmxact/nmp/echo.go | 47 --
.../mynewt.apache.org/newt/nmxact/nmp/frag.go | 61 --
.../mynewt.apache.org/newt/nmxact/nmp/fs.go | 86 --
.../mynewt.apache.org/newt/nmxact/nmp/image.go | 215 -----
.../mynewt.apache.org/newt/nmxact/nmp/log.go | 260 ------
.../mynewt.apache.org/newt/nmxact/nmp/mpstat.go | 46 -
.../mynewt.apache.org/newt/nmxact/nmp/nmp.go | 165 ----
.../mynewt.apache.org/newt/nmxact/nmp/reset.go | 44 -
.../mynewt.apache.org/newt/nmxact/nmp/run.go | 79 --
.../mynewt.apache.org/newt/nmxact/nmp/stat.go | 81 --
.../newt/nmxact/nmp/taskstat.go | 46 -
.../newt/nmxact/nmserial/packet.go | 40 -
.../newt/nmxact/nmserial/serial_plain_sesn.go | 137 ---
.../newt/nmxact/nmserial/serial_xport.go | 217 -----
.../newt/nmxact/nmxutil/nmxerr.go | 160 ----
.../newt/nmxact/nmxutil/nmxutil.go | 25 -
.../newt/nmxact/omp/dispatch.go | 66 --
.../mynewt.apache.org/newt/nmxact/omp/frag.go | 47 --
.../mynewt.apache.org/newt/nmxact/omp/omp.go | 125 ---
.../mynewt.apache.org/newt/nmxact/sesn/sesn.go | 79 --
.../newt/nmxact/sesn/sesn_cfg.go | 65 --
.../mynewt.apache.org/newt/nmxact/xact/cmd.go | 65 --
.../newt/nmxact/xact/config.go | 88 --
.../mynewt.apache.org/newt/nmxact/xact/crash.go | 87 --
.../newt/nmxact/xact/datetime.go | 84 --
.../mynewt.apache.org/newt/nmxact/xact/echo.go | 42 -
.../mynewt.apache.org/newt/nmxact/xact/fs.go | 178 ----
.../mynewt.apache.org/newt/nmxact/xact/image.go | 332 --------
.../mynewt.apache.org/newt/nmxact/xact/log.go | 202 -----
.../newt/nmxact/xact/mpstat.go | 40 -
.../mynewt.apache.org/newt/nmxact/xact/reset.go | 41 -
.../mynewt.apache.org/newt/nmxact/xact/run.go | 86 --
.../mynewt.apache.org/newt/nmxact/xact/stat.go | 84 --
.../newt/nmxact/xact/taskstat.go | 40 -
.../mynewt.apache.org/newt/nmxact/xact/xact.go | 47 --
.../newt/nmxact/xport/xport.go | 15 -
.../newtmgr/nmxact/bledefs/bledefs.go | 270 ++++++
.../newtmgr/nmxact/nmble/ble_act.go | 363 ++++++++
.../newtmgr/nmxact/nmble/ble_fsm.go | 766 +++++++++++++++++
.../newtmgr/nmxact/nmble/ble_oic_sesn.go | 198 +++++
.../newtmgr/nmxact/nmble/ble_plain_sesn.go | 186 +++++
.../newtmgr/nmxact/nmble/ble_proto.go | 829 +++++++++++++++++++
.../newtmgr/nmxact/nmble/ble_util.go | 174 ++++
.../newtmgr/nmxact/nmble/ble_xport.go | 319 +++++++
.../newtmgr/nmxact/nmble/dispatch.go | 297 +++++++
.../newtmgr/nmxact/nmp/config.go | 80 ++
.../newtmgr/nmxact/nmp/crash.go | 46 +
.../newtmgr/nmxact/nmp/datetime.go | 78 ++
.../newtmgr/nmxact/nmp/decode.go | 121 +++
.../newtmgr/nmxact/nmp/defs.go | 88 ++
.../newtmgr/nmxact/nmp/dispatch.go | 167 ++++
.../newtmgr/nmxact/nmp/echo.go | 47 ++
.../newtmgr/nmxact/nmp/frag.go | 61 ++
.../mynewt.apache.org/newtmgr/nmxact/nmp/fs.go | 86 ++
.../newtmgr/nmxact/nmp/image.go | 215 +++++
.../mynewt.apache.org/newtmgr/nmxact/nmp/log.go | 260 ++++++
.../newtmgr/nmxact/nmp/mpstat.go | 46 +
.../mynewt.apache.org/newtmgr/nmxact/nmp/nmp.go | 165 ++++
.../newtmgr/nmxact/nmp/reset.go | 44 +
.../mynewt.apache.org/newtmgr/nmxact/nmp/run.go | 79 ++
.../newtmgr/nmxact/nmp/stat.go | 81 ++
.../newtmgr/nmxact/nmp/taskstat.go | 46 +
.../newtmgr/nmxact/nmserial/packet.go | 40 +
.../nmxact/nmserial/serial_plain_sesn.go | 137 +++
.../newtmgr/nmxact/nmserial/serial_xport.go | 217 +++++
.../newtmgr/nmxact/nmxutil/nmxerr.go | 160 ++++
.../newtmgr/nmxact/nmxutil/nmxutil.go | 25 +
.../newtmgr/nmxact/omp/dispatch.go | 66 ++
.../newtmgr/nmxact/omp/frag.go | 47 ++
.../mynewt.apache.org/newtmgr/nmxact/omp/omp.go | 125 +++
.../newtmgr/nmxact/sesn/sesn.go | 79 ++
.../newtmgr/nmxact/sesn/sesn_cfg.go | 65 ++
.../newtmgr/nmxact/xact/cmd.go | 65 ++
.../newtmgr/nmxact/xact/config.go | 88 ++
.../newtmgr/nmxact/xact/crash.go | 87 ++
.../newtmgr/nmxact/xact/datetime.go | 84 ++
.../newtmgr/nmxact/xact/echo.go | 42 +
.../mynewt.apache.org/newtmgr/nmxact/xact/fs.go | 178 ++++
.../newtmgr/nmxact/xact/image.go | 332 ++++++++
.../newtmgr/nmxact/xact/log.go | 202 +++++
.../newtmgr/nmxact/xact/mpstat.go | 40 +
.../newtmgr/nmxact/xact/reset.go | 41 +
.../newtmgr/nmxact/xact/run.go | 86 ++
.../newtmgr/nmxact/xact/stat.go | 84 ++
.../newtmgr/nmxact/xact/taskstat.go | 40 +
.../newtmgr/nmxact/xact/xact.go | 47 ++
.../newtmgr/nmxact/xport/xport.go | 15 +
nmxact/example/ble_plain/ble_plain.go | 8 +-
nmxact/example/serial_plain/serial_plain.go | 6 +-
nmxact/nmble/ble_act.go | 2 +-
nmxact/nmble/ble_fsm.go | 8 +-
nmxact/nmble/ble_oic_sesn.go | 8 +-
nmxact/nmble/ble_plain_sesn.go | 6 +-
nmxact/nmble/ble_proto.go | 2 +-
nmxact/nmble/ble_util.go | 4 +-
nmxact/nmble/ble_xport.go | 4 +-
nmxact/nmp/nmp.go | 2 +-
nmxact/nmserial/serial_plain_sesn.go | 6 +-
nmxact/nmserial/serial_xport.go | 4 +-
nmxact/omp/dispatch.go | 2 +-
nmxact/omp/omp.go | 2 +-
nmxact/sesn/sesn.go | 4 +-
nmxact/sesn/sesn_cfg.go | 2 +-
nmxact/xact/cmd.go | 2 +-
nmxact/xact/config.go | 4 +-
nmxact/xact/crash.go | 4 +-
nmxact/xact/datetime.go | 4 +-
nmxact/xact/echo.go | 4 +-
nmxact/xact/fs.go | 4 +-
nmxact/xact/image.go | 4 +-
nmxact/xact/log.go | 4 +-
nmxact/xact/mpstat.go | 4 +-
nmxact/xact/reset.go | 4 +-
nmxact/xact/run.go | 4 +-
nmxact/xact/stat.go | 4 +-
nmxact/xact/taskstat.go | 4 +-
nmxact/xact/xact.go | 4 +-
nmxact/xport/xport.go | 2 +-
153 files changed, 7653 insertions(+), 7653 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/Godeps/Godeps.json
----------------------------------------------------------------------
diff --git a/newtmgr/Godeps/Godeps.json b/newtmgr/Godeps/Godeps.json
index 48ffcc0..fbbd835 100644
--- a/newtmgr/Godeps/Godeps.json
+++ b/newtmgr/Godeps/Godeps.json
@@ -1,5 +1,5 @@
{
- "ImportPath": "mynewt.apache.org/newt/newtmgr",
+ "ImportPath": "mynewt.apache.org/newtmgr/newtmgr",
"GoVersion": "go1.7",
"GodepVersion": "v74",
"Deps": [
@@ -75,69 +75,69 @@
"Rev": "629574ca2a5df945712d3079857300b5e4da0236"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/bledefs",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newt/util",
+ "Comment": "mynewt_1_0_0_b1_tag-208-g150c666",
+ "Rev": "150c6666bab17ce5a5805c1eda8a223d88cd109e"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/nmble",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newt/util/unixchild",
+ "Comment": "mynewt_1_0_0_b1_tag-208-g150c666",
+ "Rev": "150c6666bab17ce5a5805c1eda8a223d88cd109e"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/nmp",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newt/viper",
+ "Comment": "mynewt_1_0_0_b1_tag-208-g150c666",
+ "Rev": "150c6666bab17ce5a5805c1eda8a223d88cd109e"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/nmserial",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newt/yaml",
+ "Comment": "mynewt_1_0_0_b1_tag-208-g150c666",
+ "Rev": "150c6666bab17ce5a5805c1eda8a223d88cd109e"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/nmxutil",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/bledefs",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/omp",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmble",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/sesn",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmp",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/xact",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmserial",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/nmxact/xport",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/nmxutil",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/util",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/omp",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/util/unixchild",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/sesn",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/viper",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/xact",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
},
{
- "ImportPath": "mynewt.apache.org/newt/yaml",
- "Comment": "mynewt_1_0_0_b1_tag-209-gba7af48",
- "Rev": "ba7af483399e5b3de83f3995d6f092546b199751"
+ "ImportPath": "mynewt.apache.org/newtmgr/nmxact/xport",
+ "Comment": "mynewt_0_9_0_tag-446-gabaa035",
+ "Rev": "abaa03594e726b6d2b749bc405f4006eb4820c1b"
}
]
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/commands.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/commands.go b/newtmgr/cli/commands.go
index 91828e7..d0ab758 100644
--- a/newtmgr/cli/commands.go
+++ b/newtmgr/cli/commands.go
@@ -23,7 +23,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/common.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/common.go b/newtmgr/cli/common.go
index 07703e9..da3c348 100644
--- a/newtmgr/cli/common.go
+++ b/newtmgr/cli/common.go
@@ -22,11 +22,11 @@ package cli
import (
"fmt"
- "mynewt.apache.org/newt/newtmgr/config"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/nmserial"
- "mynewt.apache.org/newt/nmxact/sesn"
- "mynewt.apache.org/newt/nmxact/xport"
+ "mynewt.apache.org/newtmgr/newtmgr/config"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/nmserial"
+ "mynewt.apache.org/newtmgr/nmxact/sesn"
+ "mynewt.apache.org/newtmgr/nmxact/xport"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/config.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/config.go b/newtmgr/cli/config.go
index cf9ba1e..1287557 100644
--- a/newtmgr/cli/config.go
+++ b/newtmgr/cli/config.go
@@ -24,9 +24,9 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/sesn"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/sesn"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/connprofile.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/connprofile.go b/newtmgr/cli/connprofile.go
index 33de3bd..5558156 100644
--- a/newtmgr/cli/connprofile.go
+++ b/newtmgr/cli/connprofile.go
@@ -23,7 +23,7 @@ import (
"fmt"
"strings"
- "mynewt.apache.org/newt/newtmgr/config"
+ "mynewt.apache.org/newtmgr/newtmgr/config"
"mynewt.apache.org/newt/util"
"github.com/spf13/cobra"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/crash.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/crash.go b/newtmgr/cli/crash.go
index b1abade..c32c135 100644
--- a/newtmgr/cli/crash.go
+++ b/newtmgr/cli/crash.go
@@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/datetime.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/datetime.go b/newtmgr/cli/datetime.go
index ce1336f..67598d3 100644
--- a/newtmgr/cli/datetime.go
+++ b/newtmgr/cli/datetime.go
@@ -24,9 +24,9 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/sesn"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/sesn"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/echo.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/echo.go b/newtmgr/cli/echo.go
index 6859cac..13bfc9d 100644
--- a/newtmgr/cli/echo.go
+++ b/newtmgr/cli/echo.go
@@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/fs.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/fs.go b/newtmgr/cli/fs.go
index 3ea6652..a866e08 100644
--- a/newtmgr/cli/fs.go
+++ b/newtmgr/cli/fs.go
@@ -26,9 +26,9 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/nmp"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/nmp"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/image.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 65f7af5..78739c8 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -28,10 +28,10 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/core"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/nmp"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/core"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/nmp"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/log.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/log.go b/newtmgr/cli/log.go
index cba1e5b..e3a2586 100644
--- a/newtmgr/cli/log.go
+++ b/newtmgr/cli/log.go
@@ -26,9 +26,9 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/nmp"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/nmp"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/mpstat.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/mpstat.go b/newtmgr/cli/mpstat.go
index 65dffff..3a5e9e2 100644
--- a/newtmgr/cli/mpstat.go
+++ b/newtmgr/cli/mpstat.go
@@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/reset.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/reset.go b/newtmgr/cli/reset.go
index 6329354..85f3952 100644
--- a/newtmgr/cli/reset.go
+++ b/newtmgr/cli/reset.go
@@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/run.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/run.go b/newtmgr/cli/run.go
index 5550d53..801d000 100644
--- a/newtmgr/cli/run.go
+++ b/newtmgr/cli/run.go
@@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/stat.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/stat.go b/newtmgr/cli/stat.go
index a6b9c82..7615278 100644
--- a/newtmgr/cli/stat.go
+++ b/newtmgr/cli/stat.go
@@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/cli/taskstat.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/taskstat.go b/newtmgr/cli/taskstat.go
index bfb82d4..7102a49 100644
--- a/newtmgr/cli/taskstat.go
+++ b/newtmgr/cli/taskstat.go
@@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/xact"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/xact"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/config/ble_config.go
----------------------------------------------------------------------
diff --git a/newtmgr/config/ble_config.go b/newtmgr/config/ble_config.go
index 77e98a3..d8fd643 100644
--- a/newtmgr/config/ble_config.go
+++ b/newtmgr/config/ble_config.go
@@ -24,9 +24,9 @@ import (
"strings"
"time"
- "mynewt.apache.org/newt/nmxact/bledefs"
- "mynewt.apache.org/newt/nmxact/nmble"
- "mynewt.apache.org/newt/nmxact/sesn"
+ "mynewt.apache.org/newtmgr/nmxact/bledefs"
+ "mynewt.apache.org/newtmgr/nmxact/nmble"
+ "mynewt.apache.org/newtmgr/nmxact/sesn"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/config/serial_config.go
----------------------------------------------------------------------
diff --git a/newtmgr/config/serial_config.go b/newtmgr/config/serial_config.go
index 8b03116..1b6af08 100644
--- a/newtmgr/config/serial_config.go
+++ b/newtmgr/config/serial_config.go
@@ -5,8 +5,8 @@ import (
"strconv"
"strings"
- "mynewt.apache.org/newt/newtmgr/nmutil"
- "mynewt.apache.org/newt/nmxact/nmserial"
+ "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+ "mynewt.apache.org/newtmgr/nmxact/nmserial"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/newtmgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/newtmgr.go b/newtmgr/newtmgr.go
index 4a841dc..0307020 100644
--- a/newtmgr/newtmgr.go
+++ b/newtmgr/newtmgr.go
@@ -25,9 +25,9 @@ import (
"os/signal"
"syscall"
- "mynewt.apache.org/newt/newtmgr/cli"
- "mynewt.apache.org/newt/newtmgr/config"
- "mynewt.apache.org/newt/nmxact/nmserial"
+ "mynewt.apache.org/newtmgr/newtmgr/cli"
+ "mynewt.apache.org/newtmgr/newtmgr/config"
+ "mynewt.apache.org/newtmgr/nmxact/nmserial"
"mynewt.apache.org/newt/util"
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/nmutil/nmutil.go
----------------------------------------------------------------------
diff --git a/newtmgr/nmutil/nmutil.go b/newtmgr/nmutil/nmutil.go
index 40ba7ac..aca8111 100644
--- a/newtmgr/nmutil/nmutil.go
+++ b/newtmgr/nmutil/nmutil.go
@@ -22,7 +22,7 @@ package nmutil
import (
"time"
- "mynewt.apache.org/newt/nmxact/sesn"
+ "mynewt.apache.org/newtmgr/nmxact/sesn"
)
var Timeout float64
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/vendor/mynewt.apache.org/newt/nmxact/bledefs/bledefs.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/bledefs/bledefs.go b/newtmgr/vendor/mynewt.apache.org/newt/nmxact/bledefs/bledefs.go
deleted file mode 100644
index 3bb2772..0000000
--- a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/bledefs/bledefs.go
+++ /dev/null
@@ -1,270 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package bledefs
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "strconv"
- "strings"
-)
-
-const BLE_ATT_ATTR_MAX_LEN = 512
-
-type BleAddrType int
-
-const (
- BLE_ADDR_TYPE_PUBLIC BleAddrType = 0
- BLE_ADDR_TYPE_RANDOM = 1
- BLE_ADDR_TYPE_RPA_PUB = 2
- BLE_ADDR_TYPE_RPA_RND = 3
-)
-
-var BleAddrTypeStringMap = map[BleAddrType]string{
- BLE_ADDR_TYPE_PUBLIC: "public",
- BLE_ADDR_TYPE_RANDOM: "random",
- BLE_ADDR_TYPE_RPA_PUB: "rpa_pub",
- BLE_ADDR_TYPE_RPA_RND: "rpa_rnd",
-}
-
-func BleAddrTypeToString(addrType BleAddrType) string {
- s := BleAddrTypeStringMap[addrType]
- if s == "" {
- panic(fmt.Sprintf("Invalid BleAddrType: %d", int(addrType)))
- }
-
- return s
-}
-
-func BleAddrTypeFromString(s string) (BleAddrType, error) {
- for addrType, name := range BleAddrTypeStringMap {
- if s == name {
- return addrType, nil
- }
- }
-
- return BleAddrType(0), fmt.Errorf("Invalid BleAddrType string: %s", s)
-}
-
-func (a BleAddrType) MarshalJSON() ([]byte, error) {
- return json.Marshal(BleAddrTypeToString(a))
-}
-
-func (a *BleAddrType) UnmarshalJSON(data []byte) error {
- var err error
-
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- *a, err = BleAddrTypeFromString(s)
- return err
-}
-
-type BleAddr struct {
- Bytes [6]byte
-}
-
-func ParseBleAddr(s string) (BleAddr, error) {
- ba := BleAddr{}
-
- toks := strings.Split(strings.ToLower(s), ":")
- if len(toks) != 6 {
- return ba, fmt.Errorf("invalid BLE addr string: %s", s)
- }
-
- for i, t := range toks {
- u64, err := strconv.ParseUint(t, 16, 8)
- if err != nil {
- return ba, err
- }
- ba.Bytes[i] = byte(u64)
- }
-
- return ba, nil
-}
-
-func (ba *BleAddr) String() string {
- var buf bytes.Buffer
- buf.Grow(len(ba.Bytes) * 3)
-
- for i, b := range ba.Bytes {
- if i != 0 {
- buf.WriteString(":")
- }
- fmt.Fprintf(&buf, "%02x", b)
- }
-
- return buf.String()
-}
-
-func (ba *BleAddr) MarshalJSON() ([]byte, error) {
- return json.Marshal(ba.String())
-}
-
-func (ba *BleAddr) UnmarshalJSON(data []byte) error {
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- var err error
- *ba, err = ParseBleAddr(s)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-type BleDev struct {
- AddrType BleAddrType
- Addr BleAddr
-}
-
-func (bd *BleDev) String() string {
- return fmt.Sprintf("%s,%s",
- BleAddrTypeToString(bd.AddrType),
- bd.Addr.String())
-}
-
-type BleScanFilterPolicy int
-
-const (
- BLE_SCAN_FILT_NO_WL BleScanFilterPolicy = 0
- BLE_SCAN_FILT_USE_WL = 1
- BLE_SCAN_FILT_NO_WL_INITA = 2
- BLE_SCAN_FILT_USE_WL_INITA = 3
-)
-
-var BleScanFilterPolicyStringMap = map[BleScanFilterPolicy]string{
- BLE_SCAN_FILT_NO_WL: "no_wl",
- BLE_SCAN_FILT_USE_WL: "use_wl",
- BLE_SCAN_FILT_NO_WL_INITA: "no_wl_inita",
- BLE_SCAN_FILT_USE_WL_INITA: "use_wl_inita",
-}
-
-func BleScanFilterPolicyToString(filtPolicy BleScanFilterPolicy) string {
- s := BleScanFilterPolicyStringMap[filtPolicy]
- if s == "" {
- panic(fmt.Sprintf("Invalid BleScanFilterPolicy: %d", int(filtPolicy)))
- }
-
- return s
-}
-
-func BleScanFilterPolicyFromString(s string) (BleScanFilterPolicy, error) {
- for filtPolicy, name := range BleScanFilterPolicyStringMap {
- if s == name {
- return filtPolicy, nil
- }
- }
-
- return BleScanFilterPolicy(0),
- fmt.Errorf("Invalid BleScanFilterPolicy string: %s", s)
-}
-
-func (a BleScanFilterPolicy) MarshalJSON() ([]byte, error) {
- return json.Marshal(BleScanFilterPolicyToString(a))
-}
-
-func (a *BleScanFilterPolicy) UnmarshalJSON(data []byte) error {
- var err error
-
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- *a, err = BleScanFilterPolicyFromString(s)
- return err
-}
-
-type BleAdvEventType int
-
-const (
- BLE_ADV_EVENT_IND BleAdvEventType = 0
- BLE_ADV_EVENT_DIRECT_IND_HD = 1
- BLE_ADV_EVENT_SCAN_IND = 2
- BLE_ADV_EVENT_NONCONN_IND = 3
- BLE_ADV_EVENT_DIRECT_IND_LD = 4
-)
-
-var BleAdvEventTypeStringMap = map[BleAdvEventType]string{
- BLE_ADV_EVENT_IND: "ind",
- BLE_ADV_EVENT_DIRECT_IND_HD: "direct_ind_hd",
- BLE_ADV_EVENT_SCAN_IND: "scan_ind",
- BLE_ADV_EVENT_NONCONN_IND: "nonconn_ind",
- BLE_ADV_EVENT_DIRECT_IND_LD: "direct_ind_ld",
-}
-
-func BleAdvEventTypeToString(advEventType BleAdvEventType) string {
- s := BleAdvEventTypeStringMap[advEventType]
- if s == "" {
- panic(fmt.Sprintf("Invalid BleAdvEventType: %d", int(advEventType)))
- }
-
- return s
-}
-
-func BleAdvEventTypeFromString(s string) (BleAdvEventType, error) {
- for advEventType, name := range BleAdvEventTypeStringMap {
- if s == name {
- return advEventType, nil
- }
- }
-
- return BleAdvEventType(0),
- fmt.Errorf("Invalid BleAdvEventType string: %s", s)
-}
-
-func (a BleAdvEventType) MarshalJSON() ([]byte, error) {
- return json.Marshal(BleAdvEventTypeToString(a))
-}
-
-func (a *BleAdvEventType) UnmarshalJSON(data []byte) error {
- var err error
-
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- *a, err = BleAdvEventTypeFromString(s)
- return err
-}
-
-type BleAdvReport struct {
- // These fields are always present.
- EventType BleAdvEventType
- Sender BleDev
- Rssi int8
- Data []byte
-
- // These fields are only present if the sender included them in its
- // advertisement.
- Flags uint8 // 0 if not present.
- Name string // "" if not present.
- NameIsComplete bool // false if not present.
-}
-
-type BleAdvPredicate func(adv BleAdvReport) bool
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_act.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_act.go b/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_act.go
deleted file mode 100644
index 08c396f..0000000
--- a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_act.go
+++ /dev/null
@@ -1,363 +0,0 @@
-package nmble
-
-import (
- "encoding/json"
-
- "mynewt.apache.org/newt/nmxact/nmxutil"
-)
-
-// Blocking
-func connect(x *BleXport, connChan chan error, r *BleConnectReq) error {
- j, err := json.Marshal(r)
- if err != nil {
- return err
- }
-
- if err := x.Tx(j); err != nil {
- return err
- }
-
- err = <-connChan
- if err != nil {
- return err
- }
-
- return nil
-}
-
-// Blocking
-func terminate(x *BleXport, bl *BleListener, r *BleTerminateReq) error {
- j, err := json.Marshal(r)
- if err != nil {
- return err
- }
-
- if err := x.Tx(j); err != nil {
- return err
- }
-
- for {
- select {
- case err := <-bl.ErrChan:
- return err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleTerminateRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return StatusError(MSG_OP_RSP,
- MSG_TYPE_TERMINATE,
- msg.Status)
- } else {
- return nil
- }
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return BhdTimeoutError(MSG_TYPE_TERMINATE)
- }
- }
-}
-
-func connCancel(x *BleXport, bl *BleListener, r *BleConnCancelReq) error {
- j, err := json.Marshal(r)
- if err != nil {
- return err
- }
-
- if err := x.Tx(j); err != nil {
- return err
- }
-
- for {
- select {
- case err := <-bl.ErrChan:
- return err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleConnCancelRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return StatusError(MSG_OP_RSP,
- MSG_TYPE_CONN_CANCEL,
- msg.Status)
- } else {
- return nil
- }
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return BhdTimeoutError(MSG_TYPE_TERMINATE)
- }
- }
-}
-
-// Blocking.
-func discSvcUuid(x *BleXport, bl *BleListener, r *BleDiscSvcUuidReq) (
- *BleSvc, error) {
-
- j, err := json.Marshal(r)
- if err != nil {
- return nil, err
- }
-
- if err := x.Tx(j); err != nil {
- return nil, err
- }
-
- var svc *BleSvc
- for {
- select {
- case err := <-bl.ErrChan:
- return nil, err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleDiscSvcUuidRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return nil, StatusError(MSG_OP_RSP,
- MSG_TYPE_DISC_SVC_UUID,
- msg.Status)
- }
-
- case *BleDiscSvcEvt:
- switch msg.Status {
- case 0:
- svc = &msg.Svc
- case ERR_CODE_EDONE:
- if svc == nil {
- return nil, nmxutil.FmtBleHostError(
- msg.Status,
- "Peer doesn't support required service: %s",
- r.Uuid.String())
- }
- return svc, nil
- default:
- return nil, StatusError(MSG_OP_EVT,
- MSG_TYPE_DISC_SVC_EVT,
- msg.Status)
- }
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return nil, BhdTimeoutError(MSG_TYPE_DISC_SVC_UUID)
- }
- }
-}
-
-// Blocking.
-func discAllChrs(x *BleXport, bl *BleListener, r *BleDiscAllChrsReq) (
- []*BleChr, error) {
-
- j, err := json.Marshal(r)
- if err != nil {
- return nil, err
- }
-
- if err := x.Tx(j); err != nil {
- return nil, err
- }
-
- chrs := []*BleChr{}
- for {
- select {
- case err := <-bl.ErrChan:
- return nil, err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleDiscAllChrsRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return nil, StatusError(MSG_OP_RSP,
- MSG_TYPE_DISC_ALL_CHRS,
- msg.Status)
- }
-
- case *BleDiscChrEvt:
- switch msg.Status {
- case 0:
- chrs = append(chrs, &msg.Chr)
- case ERR_CODE_EDONE:
- return chrs, nil
- default:
- return nil, StatusError(MSG_OP_EVT,
- MSG_TYPE_DISC_CHR_EVT,
- msg.Status)
- }
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return nil, BhdTimeoutError(MSG_TYPE_DISC_ALL_CHRS)
- }
- }
-}
-
-// Blocking.
-func writeCmd(x *BleXport, bl *BleListener, r *BleWriteCmdReq) error {
- j, err := json.Marshal(r)
- if err != nil {
- return err
- }
-
- if err := x.Tx(j); err != nil {
- return err
- }
-
- for {
- select {
- case err := <-bl.ErrChan:
- return err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleWriteCmdRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return StatusError(MSG_OP_RSP,
- MSG_TYPE_WRITE_CMD,
- msg.Status)
- } else {
- return nil
- }
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return BhdTimeoutError(MSG_TYPE_WRITE_CMD)
- }
- }
-}
-
-// Blocking.
-func exchangeMtu(x *BleXport, bl *BleListener, r *BleExchangeMtuReq) (
- int, error) {
-
- j, err := json.Marshal(r)
- if err != nil {
- return 0, err
- }
-
- if err := x.Tx(j); err != nil {
- return 0, err
- }
-
- for {
- select {
- case err := <-bl.ErrChan:
- return 0, err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleExchangeMtuRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return 0, StatusError(MSG_OP_RSP,
- MSG_TYPE_EXCHANGE_MTU,
- msg.Status)
- }
-
- case *BleMtuChangeEvt:
- if msg.Status != 0 {
- return 0, StatusError(MSG_OP_EVT,
- MSG_TYPE_MTU_CHANGE_EVT,
- msg.Status)
- } else {
- return msg.Mtu, nil
- }
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return 0, BhdTimeoutError(MSG_TYPE_EXCHANGE_MTU)
- }
- }
-}
-
-type scanFn func(evt *BleScanEvt)
-
-func scan(x *BleXport, bl *BleListener, r *BleScanReq,
- abortChan chan struct{}, scanCb scanFn) error {
-
- j, err := json.Marshal(r)
- if err != nil {
- return err
- }
-
- if err := x.Tx(j); err != nil {
- return err
- }
-
- for {
- select {
- case err := <-bl.ErrChan:
- return err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleScanRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return StatusError(MSG_OP_RSP, MSG_TYPE_SCAN, msg.Status)
- }
-
- case *BleScanEvt:
- scanCb(msg)
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return BhdTimeoutError(MSG_TYPE_EXCHANGE_MTU)
-
- case <-abortChan:
- return nil
- }
- }
-}
-
-func scanCancel(x *BleXport, bl *BleListener, r *BleScanCancelReq) error {
- j, err := json.Marshal(r)
- if err != nil {
- return err
- }
-
- if err := x.Tx(j); err != nil {
- return err
- }
-
- for {
- select {
- case err := <-bl.ErrChan:
- return err
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleScanCancelRsp:
- bl.Acked = true
- if msg.Status != 0 {
- return StatusError(MSG_OP_RSP, MSG_TYPE_SCAN, msg.Status)
- }
- return nil
-
- default:
- }
-
- case <-bl.AfterTimeout(x.rspTimeout):
- return BhdTimeoutError(MSG_TYPE_EXCHANGE_MTU)
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_fsm.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_fsm.go b/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_fsm.go
deleted file mode 100644
index daa930b..0000000
--- a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_fsm.go
+++ /dev/null
@@ -1,766 +0,0 @@
-package nmble
-
-import (
- "encoding/hex"
- "fmt"
- "sync"
- "time"
-
- log "github.com/Sirupsen/logrus"
-
- . "mynewt.apache.org/newt/nmxact/bledefs"
- "mynewt.apache.org/newt/nmxact/nmp"
- "mynewt.apache.org/newt/nmxact/nmxutil"
- "mynewt.apache.org/newt/nmxact/sesn"
-)
-
-type BleSesnState int32
-
-const DFLT_ATT_MTU = 23
-
-const (
- SESN_STATE_UNCONNECTED BleSesnState = 0
- SESN_STATE_SCANNING = 1
- SESN_STATE_CONNECTING = 2
- SESN_STATE_CONNECTED = 3
- SESN_STATE_EXCHANGING_MTU = 4
- SESN_STATE_EXCHANGED_MTU = 5
- SESN_STATE_DISCOVERING_SVC = 6
- SESN_STATE_DISCOVERED_SVC = 7
- SESN_STATE_DISCOVERING_CHR = 8
- SESN_STATE_DISCOVERED_CHR = 9
- SESN_STATE_TERMINATING = 10
- SESN_STATE_CONN_CANCELLING = 11
-)
-
-type BleRxNmpFn func(data []byte)
-type BleDisconnectFn func(peer BleDev, err error)
-
-type BleFsmParams struct {
- Bx *BleXport
- OwnAddrType BleAddrType
- PeerSpec sesn.BlePeerSpec
- SvcUuid BleUuid
- ReqChrUuid BleUuid
- RspChrUuid BleUuid
- RxNmpCb BleRxNmpFn
- DisconnectCb BleDisconnectFn
-}
-
-type BleFsm struct {
- bx *BleXport
- ownAddrType BleAddrType
- peerSpec sesn.BlePeerSpec
- peerDev *BleDev
- svcUuid BleUuid
- reqChrUuid BleUuid
- rspChrUuid BleUuid
- rxNmpCb BleRxNmpFn
- disconnectCb BleDisconnectFn
-
- connHandle int
- nmpSvc *BleSvc
- nmpReqChr *BleChr
- nmpRspChr *BleChr
- attMtu int
- connChan chan error
-
- mtx sync.Mutex
- lastStateChange time.Time
-
- // These variables must be protected by the mutex.
- bls map[*BleListener]struct{}
- state BleSesnState
-}
-
-func NewBleFsm(p BleFsmParams) *BleFsm {
- bf := &BleFsm{
- bx: p.Bx,
- peerSpec: p.PeerSpec,
- ownAddrType: p.OwnAddrType,
- svcUuid: p.SvcUuid,
- reqChrUuid: p.ReqChrUuid,
- rspChrUuid: p.RspChrUuid,
- rxNmpCb: p.RxNmpCb,
- disconnectCb: p.DisconnectCb,
-
- bls: map[*BleListener]struct{}{},
- attMtu: DFLT_ATT_MTU,
- }
-
- return bf
-}
-
-func (bf *BleFsm) disconnectError(reason int) error {
- str := fmt.Sprintf("BLE peer disconnected; "+
- "reason=\"%s\" (%d) peer=%s handle=%d",
- ErrCodeToString(reason), reason, bf.peerDev.String(), bf.connHandle)
- return nmxutil.NewBleSesnDisconnectError(reason, str)
-}
-
-func (bf *BleFsm) closedError(msg string) error {
- return nmxutil.NewSesnClosedError(fmt.Sprintf(
- "%s; state=%d last-state-change=%s",
- msg, bf.getState(), bf.lastStateChange))
-}
-
-func (bf *BleFsm) getState() BleSesnState {
- bf.mtx.Lock()
- defer bf.mtx.Unlock()
-
- return bf.state
-}
-
-func (bf *BleFsm) setState(toState BleSesnState) {
- bf.mtx.Lock()
- defer bf.mtx.Unlock()
-
- bf.state = toState
- bf.lastStateChange = time.Now()
-}
-
-func (bf *BleFsm) transitionState(fromState BleSesnState,
- toState BleSesnState) error {
-
- bf.mtx.Lock()
- defer bf.mtx.Unlock()
-
- if bf.state != fromState {
- return fmt.Errorf(
- "Can't set BleFsm state to %d; current state != required "+
- "value: %d",
- toState, fromState)
- }
-
- bf.state = toState
- return nil
-}
-
-func (bf *BleFsm) addBleListener(base BleMsgBase) (*BleListener, error) {
- bl := NewBleListener()
-
- bf.mtx.Lock()
- bf.bls[bl] = struct{}{}
- bf.mtx.Unlock()
-
- if err := bf.bx.Bd.AddListener(base, bl); err != nil {
- delete(bf.bls, bl)
- return nil, err
- }
-
- return bl, nil
-}
-
-func (bf *BleFsm) addBleSeqListener(seq int) (*BleListener, error) {
- base := BleMsgBase{
- Op: -1,
- Type: -1,
- Seq: seq,
- ConnHandle: -1,
- }
- bl, err := bf.addBleListener(base)
- if err != nil {
- return nil, err
- }
-
- return bl, nil
-}
-
-func (bf *BleFsm) removeBleListener(base BleMsgBase) {
- bl := bf.bx.Bd.RemoveListener(base)
- if bl != nil {
- bf.mtx.Lock()
- delete(bf.bls, bl)
- bf.mtx.Unlock()
- }
-}
-
-func (bf *BleFsm) removeBleSeqListener(seq int) {
- base := BleMsgBase{
- Op: -1,
- Type: -1,
- Seq: seq,
- ConnHandle: -1,
- }
-
- bf.removeBleListener(base)
-}
-
-func (bf *BleFsm) action(
- preState BleSesnState,
- inState BleSesnState,
- postState BleSesnState,
- cb func() error) error {
-
- if err := bf.transitionState(preState, inState); err != nil {
- return err
- }
-
- if err := cb(); err != nil {
- bf.setState(preState)
- return err
- }
-
- bf.setState(postState)
- return nil
-}
-
-func (bf *BleFsm) connectListen(seq int) error {
- bf.connChan = make(chan error, 1)
-
- bl, err := bf.addBleSeqListener(seq)
- if err != nil {
- return err
- }
-
- go func() {
- defer bf.removeBleSeqListener(seq)
- for {
- select {
- case <-bl.ErrChan:
- return
-
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleConnectRsp:
- bl.Acked = true
- if msg.Status != 0 {
- str := fmt.Sprintf("BLE connection attempt failed; "+
- "status=%s (%d) peer=%s",
- ErrCodeToString(msg.Status), msg.Status,
- bf.peerDev.String())
- log.Debugf(str)
- bf.connChan <- nmxutil.NewBleHostError(msg.Status, str)
- return
- }
-
- case *BleConnectEvt:
- if msg.Status == 0 {
- bl.Acked = true
- log.Debugf("BLE connection attempt succeeded; "+
- "peer=%d handle=%d", bf.peerDev.String(),
- msg.ConnHandle)
- bf.connHandle = msg.ConnHandle
- if err := bf.nmpRspListen(); err != nil {
- bf.connChan <- err
- return
- }
- bf.connChan <- nil
- } else {
- str := fmt.Sprintf("BLE connection attempt failed; "+
- "status=%s (%d) peer=%s",
- ErrCodeToString(msg.Status), msg.Status,
- bf.peerDev.String())
- log.Debugf(str)
- bf.connChan <- nmxutil.NewBleHostError(msg.Status, str)
- return
- }
-
- case *BleMtuChangeEvt:
- if msg.Status != 0 {
- err := StatusError(MSG_OP_EVT,
- MSG_TYPE_MTU_CHANGE_EVT,
- msg.Status)
- log.Debugf(err.Error())
- } else {
- log.Debugf("BLE ATT MTU updated; from=%d to=%d",
- bf.attMtu, msg.Mtu)
- bf.attMtu = msg.Mtu
- }
-
- case *BleDisconnectEvt:
- err := bf.disconnectError(msg.Reason)
- log.Debugf(err.Error())
-
- bf.mtx.Lock()
- bls := make([]*BleListener, 0, len(bf.bls))
- for bl, _ := range bf.bls {
- bls = append(bls, bl)
- }
- bf.mtx.Unlock()
-
- for _, bl := range bls {
- bl.ErrChan <- err
- }
-
- bf.setState(SESN_STATE_UNCONNECTED)
- peer := *bf.peerDev
- bf.peerDev = nil
- bf.disconnectCb(peer, err)
- return
-
- default:
- }
-
- case <-bl.AfterTimeout(bf.bx.rspTimeout):
- bf.connChan <- BhdTimeoutError(MSG_TYPE_CONNECT)
- }
- }
- }()
- return nil
-}
-
-func (bf *BleFsm) nmpRspListen() error {
- base := BleMsgBase{
- Op: MSG_OP_EVT,
- Type: MSG_TYPE_NOTIFY_RX_EVT,
- Seq: -1,
- ConnHandle: bf.connHandle,
- }
-
- bl, err := bf.addBleListener(base)
- if err != nil {
- return err
- }
-
- go func() {
- defer bf.removeBleListener(base)
- for {
- select {
- case <-bl.ErrChan:
- // The session encountered an error; stop listening.
- return
- case bm := <-bl.BleChan:
- switch msg := bm.(type) {
- case *BleNotifyRxEvt:
- if bf.nmpRspChr != nil &&
- msg.AttrHandle == bf.nmpRspChr.ValHandle {
-
- bf.rxNmpCb(msg.Data.Bytes)
- }
-
- default:
- }
- }
- }
- }()
- return nil
-}
-
-func (bf *BleFsm) connect() error {
- r := NewBleConnectReq()
- r.OwnAddrType = bf.ownAddrType
- r.PeerAddrType = bf.peerDev.AddrType
- r.PeerAddr = bf.peerDev.Addr
-
- if err := bf.connectListen(r.Seq); err != nil {
- return err
- }
-
- if err := connect(bf.bx, bf.connChan, r); err != nil {
- return err
- }
-
- return nil
-}
-
-func (bf *BleFsm) scan() error {
- r := NewBleScanReq()
- r.OwnAddrType = bf.ownAddrType
- r.DurationMs = 15000
- r.FilterPolicy = BLE_SCAN_FILT_NO_WL
- r.Limited = false
- r.Passive = false
- r.FilterDuplicates = true
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- abortChan := make(chan struct{}, 1)
-
- // This function gets called for each incoming advertisement.
- scanCb := func(evt *BleScanEvt) {
- r := BleAdvReport{
- EventType: evt.EventType,
- Sender: BleDev{
- AddrType: evt.AddrType,
- Addr: evt.Addr,
- },
- Rssi: evt.Rssi,
- Data: evt.Data.Bytes,
-
- Flags: evt.DataFlags,
- Name: evt.DataName,
- NameIsComplete: evt.DataNameIsComplete,
- }
-
- // Ask client if we should connect to this advertiser.
- if bf.peerSpec.ScanPred(r) {
- bf.peerDev = &r.Sender
- abortChan <- struct{}{}
- }
- }
-
- if err := scan(bf.bx, bl, r, abortChan, scanCb); err != nil {
- return err
- }
-
- // Scanning still in progress; cancel the operation.
- return bf.scanCancel()
-}
-
-func (bf *BleFsm) scanCancel() error {
- r := NewBleScanCancelReq()
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- if err := scanCancel(bf.bx, bl, r); err != nil {
- return err
- }
-
- return nil
-}
-
-func (bf *BleFsm) terminateSetState() error {
- bf.mtx.Lock()
- defer bf.mtx.Unlock()
-
- switch bf.state {
- case SESN_STATE_UNCONNECTED,
- SESN_STATE_CONNECTING,
- SESN_STATE_CONN_CANCELLING:
- return fmt.Errorf("BLE terminate failed; not connected")
- case SESN_STATE_TERMINATING:
- return fmt.Errorf(
- "BLE terminate failed; session already being closed")
- default:
- bf.state = SESN_STATE_TERMINATING
- }
-
- return nil
-}
-
-func (bf *BleFsm) terminate() error {
- if err := bf.terminateSetState(); err != nil {
- return err
- }
-
- r := NewBleTerminateReq()
- r.ConnHandle = bf.connHandle
- r.HciReason = ERR_CODE_HCI_REM_USER_CONN_TERM
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- if err := terminate(bf.bx, bl, r); err != nil {
- return err
- }
-
- return nil
-}
-
-func (bf *BleFsm) connCancel() error {
- if err := bf.transitionState(
- SESN_STATE_CONNECTING,
- SESN_STATE_CONN_CANCELLING); err != nil {
-
- return fmt.Errorf("BLE connect cancel failed; not connecting")
- }
-
- r := NewBleConnCancelReq()
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- if err := connCancel(bf.bx, bl, r); err != nil {
- return err
- }
-
- return nil
-}
-
-func (bf *BleFsm) discSvcUuid() error {
- r := NewBleDiscSvcUuidReq()
- r.ConnHandle = bf.connHandle
- r.Uuid = bf.svcUuid
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- bf.nmpSvc, err = discSvcUuid(bf.bx, bl, r)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (bf *BleFsm) discAllChrs() error {
- r := NewBleDiscAllChrsReq()
- r.ConnHandle = bf.connHandle
- r.StartHandle = bf.nmpSvc.StartHandle
- r.EndHandle = bf.nmpSvc.EndHandle
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- chrs, err := discAllChrs(bf.bx, bl, r)
- if err != nil {
- return err
- }
-
- for _, c := range chrs {
- if CompareUuids(bf.reqChrUuid, c.Uuid) == 0 {
- bf.nmpReqChr = c
- }
- if CompareUuids(bf.rspChrUuid, c.Uuid) == 0 {
- bf.nmpRspChr = c
- }
- }
-
- if bf.nmpReqChr == nil {
- return fmt.Errorf(
- "Peer doesn't support required characteristic: %s",
- bf.reqChrUuid.String())
- }
-
- if bf.nmpRspChr == nil {
- return fmt.Errorf(
- "Peer doesn't support required characteristic: %s",
- bf.rspChrUuid.String())
- }
-
- return nil
-}
-
-func (bf *BleFsm) exchangeMtu() error {
- r := NewBleExchangeMtuReq()
- r.ConnHandle = bf.connHandle
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- mtu, err := exchangeMtu(bf.bx, bl, r)
- if err != nil {
- return err
- }
-
- bf.attMtu = mtu
- return nil
-}
-
-func (bf *BleFsm) writeCmd(data []byte) error {
- r := NewBleWriteCmdReq()
- r.ConnHandle = bf.connHandle
- r.AttrHandle = bf.nmpReqChr.ValHandle
- r.Data.Bytes = data
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- if err := writeCmd(bf.bx, bl, r); err != nil {
- return err
- }
-
- return nil
-}
-
-func (bf *BleFsm) subscribe() error {
- r := NewBleWriteCmdReq()
- r.ConnHandle = bf.connHandle
- r.AttrHandle = bf.nmpRspChr.ValHandle + 1
- r.Data.Bytes = []byte{1, 0}
-
- bl, err := bf.addBleSeqListener(r.Seq)
- if err != nil {
- return err
- }
- defer bf.removeBleSeqListener(r.Seq)
-
- if err := writeCmd(bf.bx, bl, r); err != nil {
- return err
- }
-
- return nil
-}
-
-// Tries to populate the FSM's peerDev field. This function succeeds if the
-// client specified the address of the peer to connect to.
-func (bf *BleFsm) tryFillPeerDev() bool {
- // The peer spec contains one of:
- // * Peer address;
- // * Predicate function to call during scanning.
- // If a peer address is specified, fill in the peer field now so the
- // scanning step can be skipped. Otherwise, the peer field gets populated
- // during scanning.
- if bf.peerSpec.ScanPred == nil {
- bf.peerDev = &bf.peerSpec.Dev
- return true
- }
-
- return false
-}
-
-func (bf *BleFsm) Start() error {
- if bf.getState() != SESN_STATE_UNCONNECTED {
- return nmxutil.NewSesnAlreadyOpenError(
- "Attempt to open an already-open BLE session")
- }
-
- for {
- state := bf.getState()
- switch state {
- case SESN_STATE_UNCONNECTED:
- var err error
-
- // Determine if we can immediately initiate a connection, or if we
- // need to scan for a peer first. If the client specified a peer
- // address, or if we have already successfully scanned, we initiate
- // a connection now. Otherwise, we need to scan to determine which
- // peer meets the specified scan criteria.
- bf.tryFillPeerDev()
- if bf.peerDev == nil {
- // Peer not inferred yet. Initiate scan.
- cb := func() error { return bf.scan() }
- err = bf.action(
- SESN_STATE_UNCONNECTED,
- SESN_STATE_SCANNING,
- SESN_STATE_UNCONNECTED,
- cb)
- } else {
- // We already know the address we want to connect to. Initiate
- // a connection.
- cb := func() error { return bf.connect() }
- err = bf.action(
- SESN_STATE_UNCONNECTED,
- SESN_STATE_CONNECTING,
- SESN_STATE_CONNECTED,
- cb)
- }
-
- if err != nil {
- return err
- }
-
- case SESN_STATE_CONNECTED:
- cb := func() error { return bf.exchangeMtu() }
- err := bf.action(
- SESN_STATE_CONNECTED,
- SESN_STATE_EXCHANGING_MTU,
- SESN_STATE_EXCHANGED_MTU,
- cb)
- if err != nil {
- return err
- }
-
- case SESN_STATE_EXCHANGED_MTU:
- cb := func() error { return bf.discSvcUuid() }
- err := bf.action(
- SESN_STATE_EXCHANGED_MTU,
- SESN_STATE_DISCOVERING_SVC,
- SESN_STATE_DISCOVERED_SVC,
- cb)
- if err != nil {
- return err
- }
-
- case SESN_STATE_DISCOVERED_SVC:
- cb := func() error {
- return bf.discAllChrs()
- }
-
- err := bf.action(
- SESN_STATE_DISCOVERED_SVC,
- SESN_STATE_DISCOVERING_CHR,
- SESN_STATE_DISCOVERED_CHR,
- cb)
- if err != nil {
- return err
- }
-
- if err := bf.subscribe(); err != nil {
- return err
- }
-
- case SESN_STATE_DISCOVERED_CHR:
- /* Open complete. */
- return nil
-
- case SESN_STATE_CONNECTING,
- SESN_STATE_DISCOVERING_SVC,
- SESN_STATE_DISCOVERING_CHR,
- SESN_STATE_TERMINATING:
- return fmt.Errorf("BleFsm already being opened")
- }
- }
-}
-
-// @return bool true if stop complete;
-// false if disconnect is now pending.
-func (bf *BleFsm) Stop() (bool, error) {
- state := bf.getState()
-
- switch state {
- case SESN_STATE_UNCONNECTED,
- SESN_STATE_TERMINATING,
- SESN_STATE_CONN_CANCELLING:
-
- return false,
- bf.closedError("Attempt to close an unopened BLE session")
-
- case SESN_STATE_CONNECTING:
- if err := bf.connCancel(); err != nil {
- return false, err
- }
- return true, nil
-
- default:
- if err := bf.terminate(); err != nil {
- return false, err
- }
- return false, nil
- }
-}
-
-func (bf *BleFsm) IsOpen() bool {
- return bf.getState() == SESN_STATE_DISCOVERED_CHR
-}
-
-func (bf *BleFsm) TxNmp(payload []byte, nl *nmp.NmpListener,
- timeout time.Duration) (nmp.NmpRsp, error) {
-
- log.Debugf("Tx NMP request: %s", hex.Dump(payload))
- if err := bf.writeCmd(payload); err != nil {
- return nil, err
- }
-
- // Now wait for NMP response.
- for {
- select {
- case err := <-nl.ErrChan:
- return nil, err
- case rsp := <-nl.RspChan:
- // Only accept NMP responses if the session is still open. This is
- // to help prevent race conditions in client code.
- if bf.IsOpen() {
- return rsp, nil
- }
- case <-nl.AfterTimeout(timeout):
- return nil, nmxutil.NewNmpTimeoutError("NMP timeout")
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_oic_sesn.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_oic_sesn.go b/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_oic_sesn.go
deleted file mode 100644
index 949d7aa..0000000
--- a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_oic_sesn.go
+++ /dev/null
@@ -1,198 +0,0 @@
-package nmble
-
-import (
- "fmt"
- "sync"
- "time"
-
- . "mynewt.apache.org/newt/nmxact/bledefs"
- "mynewt.apache.org/newt/nmxact/nmp"
- "mynewt.apache.org/newt/nmxact/omp"
- "mynewt.apache.org/newt/nmxact/sesn"
- "mynewt.apache.org/newt/util"
-)
-
-type BleOicSesn struct {
- bf *BleFsm
- nls map[*nmp.NmpListener]struct{}
- od *omp.OmpDispatcher
- closeTimeout time.Duration
- onCloseCb sesn.BleOnCloseFn
-
- closeChan chan error
- mx sync.Mutex
-}
-
-func NewBleOicSesn(bx *BleXport, cfg sesn.SesnCfg) *BleOicSesn {
- bos := &BleOicSesn{
- nls: map[*nmp.NmpListener]struct{}{},
- od: omp.NewOmpDispatcher(),
- closeTimeout: cfg.Ble.CloseTimeout,
- onCloseCb: cfg.Ble.OnCloseCb,
- }
-
- svcUuid, err := ParseUuid(NmpOicSvcUuid)
- if err != nil {
- panic(err.Error())
- }
-
- reqChrUuid, err := ParseUuid(NmpOicReqChrUuid)
- if err != nil {
- panic(err.Error())
- }
-
- rspChrUuid, err := ParseUuid(NmpOicRspChrUuid)
- if err != nil {
- panic(err.Error())
- }
-
- bos.bf = NewBleFsm(BleFsmParams{
- Bx: bx,
- OwnAddrType: cfg.Ble.OwnAddrType,
- PeerSpec: cfg.Ble.PeerSpec,
- SvcUuid: svcUuid,
- ReqChrUuid: reqChrUuid,
- RspChrUuid: rspChrUuid,
- RxNmpCb: func(d []byte) { bos.onRxNmp(d) },
- DisconnectCb: func(p BleDev, e error) { bos.onDisconnect(p, e) },
- })
-
- return bos
-}
-
-func (bos *BleOicSesn) addNmpListener(seq uint8) (*nmp.NmpListener, error) {
- nl := nmp.NewNmpListener()
- bos.nls[nl] = struct{}{}
-
- if err := bos.od.AddListener(seq, nl); err != nil {
- delete(bos.nls, nl)
- return nil, err
- }
-
- return nl, nil
-}
-
-func (bos *BleOicSesn) removeNmpListener(seq uint8) {
- listener := bos.od.RemoveListener(seq)
- if listener != nil {
- delete(bos.nls, listener)
- }
-}
-
-// Returns true if a new channel was assigned.
-func (bos *BleOicSesn) setCloseChan() bool {
- bos.mx.Lock()
- defer bos.mx.Unlock()
-
- if bos.closeChan != nil {
- return false
- }
-
- bos.closeChan = make(chan error, 1)
- return true
-}
-
-func (bos *BleOicSesn) clearCloseChan() {
- bos.mx.Lock()
- defer bos.mx.Unlock()
-
- bos.closeChan = nil
-}
-
-func (bos *BleOicSesn) AbortRx(seq uint8) error {
- return bos.od.FakeRxError(seq, fmt.Errorf("Rx aborted"))
-}
-
-func (bos *BleOicSesn) Open() error {
- return bos.bf.Start()
-}
-
-func (bos *BleOicSesn) Close() error {
- if !bos.setCloseChan() {
- return bos.bf.closedError(
- "Attempt to close an unopened BLE session")
- }
- defer bos.clearCloseChan()
-
- done, err := bos.bf.Stop()
- if err != nil {
- return err
- }
-
- if done {
- // Close complete.
- return nil
- }
-
- // Block until close completes or timeout.
- select {
- case <-bos.closeChan:
- case <-time.After(bos.closeTimeout):
- }
-
- return nil
-}
-
-func (bos *BleOicSesn) IsOpen() bool {
- return bos.bf.IsOpen()
-}
-
-func (bos *BleOicSesn) onRxNmp(data []byte) {
- bos.od.Dispatch(data)
-}
-
-func (bos *BleOicSesn) onDisconnect(peer BleDev, err error) {
- for nl, _ := range bos.nls {
- nl.ErrChan <- err
- }
-
- // If the session is being closed, unblock the close() call.
- if bos.closeChan != nil {
- bos.closeChan <- err
- }
- if bos.onCloseCb != nil {
- bos.onCloseCb(bos, peer, err)
- }
-}
-
-func (bos *BleOicSesn) EncodeNmpMsg(m *nmp.NmpMsg) ([]byte, error) {
- return omp.EncodeOmpTcp(m)
-}
-
-// Blocking.
-func (bos *BleOicSesn) TxNmpOnce(m *nmp.NmpMsg, opt sesn.TxOptions) (
- nmp.NmpRsp, error) {
-
- if !bos.IsOpen() {
- return nil, bos.bf.closedError(
- "Attempt to transmit over closed BLE session")
- }
-
- nl, err := bos.addNmpListener(m.Hdr.Seq)
- if err != nil {
- return nil, err
- }
- defer bos.removeNmpListener(m.Hdr.Seq)
-
- b, err := bos.EncodeNmpMsg(m)
- if err != nil {
- return nil, err
- }
-
- return bos.bf.TxNmp(b, nl, opt.Timeout)
-}
-
-func (bos *BleOicSesn) MtuIn() int {
- return bos.bf.attMtu -
- NOTIFY_CMD_BASE_SZ -
- omp.OMP_MSG_OVERHEAD -
- nmp.NMP_HDR_SIZE
-}
-
-func (bos *BleOicSesn) MtuOut() int {
- mtu := bos.bf.attMtu -
- WRITE_CMD_BASE_SZ -
- omp.OMP_MSG_OVERHEAD -
- nmp.NMP_HDR_SIZE
- return util.IntMin(mtu, BLE_ATT_ATTR_MAX_LEN)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_plain_sesn.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_plain_sesn.go b/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_plain_sesn.go
deleted file mode 100644
index 71133e7..0000000
--- a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_plain_sesn.go
+++ /dev/null
@@ -1,186 +0,0 @@
-package nmble
-
-import (
- "fmt"
- "sync"
- "time"
-
- . "mynewt.apache.org/newt/nmxact/bledefs"
- "mynewt.apache.org/newt/nmxact/nmp"
- "mynewt.apache.org/newt/nmxact/sesn"
- "mynewt.apache.org/newt/util"
-)
-
-type BlePlainSesn struct {
- bf *BleFsm
- nls map[*nmp.NmpListener]struct{}
- nd *nmp.NmpDispatcher
- closeTimeout time.Duration
- onCloseCb sesn.BleOnCloseFn
-
- closeChan chan error
- mx sync.Mutex
-}
-
-func NewBlePlainSesn(bx *BleXport, cfg sesn.SesnCfg) *BlePlainSesn {
- bps := &BlePlainSesn{
- nls: map[*nmp.NmpListener]struct{}{},
- nd: nmp.NewNmpDispatcher(),
- closeTimeout: cfg.Ble.CloseTimeout,
- onCloseCb: cfg.Ble.OnCloseCb,
- }
-
- svcUuid, err := ParseUuid(NmpPlainSvcUuid)
- if err != nil {
- panic(err.Error())
- }
-
- chrUuid, err := ParseUuid(NmpPlainChrUuid)
- if err != nil {
- panic(err.Error())
- }
-
- bps.bf = NewBleFsm(BleFsmParams{
- Bx: bx,
- OwnAddrType: cfg.Ble.OwnAddrType,
- PeerSpec: cfg.Ble.PeerSpec,
- SvcUuid: svcUuid,
- ReqChrUuid: chrUuid,
- RspChrUuid: chrUuid,
- RxNmpCb: func(d []byte) { bps.onRxNmp(d) },
- DisconnectCb: func(p BleDev, e error) { bps.onDisconnect(p, e) },
- })
-
- return bps
-}
-
-func (bps *BlePlainSesn) addNmpListener(seq uint8) (*nmp.NmpListener, error) {
- nl := nmp.NewNmpListener()
- bps.nls[nl] = struct{}{}
-
- if err := bps.nd.AddListener(seq, nl); err != nil {
- delete(bps.nls, nl)
- return nil, err
- }
-
- return nl, nil
-}
-
-func (bps *BlePlainSesn) removeNmpListener(seq uint8) {
- listener := bps.nd.RemoveListener(seq)
- if listener != nil {
- delete(bps.nls, listener)
- }
-}
-
-// Returns true if a new channel was assigned.
-func (bps *BlePlainSesn) setCloseChan() bool {
- bps.mx.Lock()
- defer bps.mx.Unlock()
-
- if bps.closeChan != nil {
- return false
- }
-
- bps.closeChan = make(chan error, 1)
- return true
-}
-
-func (bps *BlePlainSesn) clearCloseChan() {
- bps.mx.Lock()
- defer bps.mx.Unlock()
-
- bps.closeChan = nil
-}
-
-func (bps *BlePlainSesn) AbortRx(seq uint8) error {
- return bps.nd.FakeRxError(seq, fmt.Errorf("Rx aborted"))
-}
-
-func (bps *BlePlainSesn) Open() error {
- return bps.bf.Start()
-}
-
-func (bps *BlePlainSesn) Close() error {
- if !bps.setCloseChan() {
- return bps.bf.closedError(
- "Attempt to close an unopened BLE session")
- }
- defer bps.clearCloseChan()
-
- done, err := bps.bf.Stop()
- if err != nil {
- return err
- }
-
- if done {
- // Close complete.
- return nil
- }
-
- // Block until close completes or timeout.
- select {
- case <-bps.closeChan:
- case <-time.After(bps.closeTimeout):
- }
-
- return nil
-}
-
-func (bps *BlePlainSesn) IsOpen() bool {
- return bps.bf.IsOpen()
-}
-
-func (bps *BlePlainSesn) onRxNmp(data []byte) {
- bps.nd.Dispatch(data)
-}
-
-func (bps *BlePlainSesn) onDisconnect(peer BleDev, err error) {
- for nl, _ := range bps.nls {
- nl.ErrChan <- err
- }
-
- // If the session is being closed, unblock the close() call.
- if bps.closeChan != nil {
- bps.closeChan <- err
- }
- if bps.onCloseCb != nil {
- bps.onCloseCb(bps, peer, err)
- }
-}
-
-func (bps *BlePlainSesn) EncodeNmpMsg(m *nmp.NmpMsg) ([]byte, error) {
- return nmp.EncodeNmpPlain(m)
-}
-
-// Blocking.
-func (bps *BlePlainSesn) TxNmpOnce(msg *nmp.NmpMsg, opt sesn.TxOptions) (
- nmp.NmpRsp, error) {
-
- if !bps.IsOpen() {
- return nil, bps.bf.closedError(
- "Attempt to transmit over closed BLE session")
- }
-
- nl, err := bps.addNmpListener(msg.Hdr.Seq)
- if err != nil {
- return nil, err
- }
- defer bps.removeNmpListener(msg.Hdr.Seq)
-
- b, err := bps.EncodeNmpMsg(msg)
- if err != nil {
- return nil, err
- }
-
- return bps.bf.TxNmp(b, nl, opt.Timeout)
-}
-
-func (bps *BlePlainSesn) MtuIn() int {
- return bps.bf.attMtu - NOTIFY_CMD_BASE_SZ - nmp.NMP_HDR_SIZE
-}
-
-func (bps *BlePlainSesn) MtuOut() int {
- mtu := bps.bf.attMtu - WRITE_CMD_BASE_SZ - nmp.NMP_HDR_SIZE
- return util.IntMin(mtu, BLE_ATT_ATTR_MAX_LEN)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/15498bdc/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_proto.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_proto.go b/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_proto.go
deleted file mode 100644
index 85a26f8..0000000
--- a/newtmgr/vendor/mynewt.apache.org/newt/nmxact/nmble/ble_proto.go
+++ /dev/null
@@ -1,829 +0,0 @@
-package nmble
-
-import (
- "bytes"
- "encoding/json"
- "errors"
- "fmt"
- "strconv"
- "strings"
-
- . "mynewt.apache.org/newt/nmxact/bledefs"
-)
-
-type MsgOp int
-type MsgType int
-
-type BleBytes struct {
- Bytes []byte
-}
-
-type BleUuid struct {
- Bytes [16]byte
-}
-
-const ERR_CODE_ATT_BASE = 0x100
-const ERR_CODE_HCI_BASE = 0x200
-const ERR_CODE_L2C_BASE = 0x300
-const ERR_CODE_SM_US_BASE = 0x400
-const ERR_CODE_SM_PEER_BASE = 0x500
-
-const (
- ERR_CODE_EAGAIN int = 1
- ERR_CODE_EALREADY = 2
- ERR_CODE_EINVAL = 3
- ERR_CODE_EMSGSIZE = 4
- ERR_CODE_ENOENT = 5
- ERR_CODE_ENOMEM = 6
- ERR_CODE_ENOTCONN = 7
- ERR_CODE_ENOTSUP = 8
- ERR_CODE_EAPP = 9
- ERR_CODE_EBADDATA = 10
- ERR_CODE_EOS = 11
- ERR_CODE_ECONTROLLER = 12
- ERR_CODE_ETIMEOUT = 13
- ERR_CODE_EDONE = 14
- ERR_CODE_EBUSY = 15
- ERR_CODE_EREJECT = 16
- ERR_CODE_EUNKNOWN = 17
- ERR_CODE_EROLE = 18
- ERR_CODE_ETIMEOUT_HCI = 19
- ERR_CODE_ENOMEM_EVT = 20
- ERR_CODE_ENOADDR = 21
- ERR_CODE_ENOTSYNCED = 22
-)
-
-var ErrCodeStringMap = map[int]string{
- ERR_CODE_EAGAIN: "eagain",
- ERR_CODE_EALREADY: "ealready",
- ERR_CODE_EINVAL: "einval",
- ERR_CODE_EMSGSIZE: "emsgsize",
- ERR_CODE_ENOENT: "enoent",
- ERR_CODE_ENOMEM: "enomem",
- ERR_CODE_ENOTCONN: "enotconn",
- ERR_CODE_ENOTSUP: "enotsup",
- ERR_CODE_EAPP: "eapp",
- ERR_CODE_EBADDATA: "ebaddata",
- ERR_CODE_EOS: "eos",
- ERR_CODE_ECONTROLLER: "econtroller",
- ERR_CODE_ETIMEOUT: "etimeout",
- ERR_CODE_EDONE: "edone",
- ERR_CODE_EBUSY: "ebusy",
- ERR_CODE_EREJECT: "ereject",
- ERR_CODE_EUNKNOWN: "eunknown",
- ERR_CODE_EROLE: "erole",
- ERR_CODE_ETIMEOUT_HCI: "etimeout_hci",
- ERR_CODE_ENOMEM_EVT: "enomem_evt",
- ERR_CODE_ENOADDR: "enoaddr",
- ERR_CODE_ENOTSYNCED: "enotsynced",
-}
-
-const (
- ERR_CODE_HCI_UNKNOWN_HCI_CMD int = 1
- ERR_CODE_HCI_UNK_CONN_ID = 2
- ERR_CODE_HCI_HW_FAIL = 3
- ERR_CODE_HCI_PAGE_TMO = 4
- ERR_CODE_HCI_AUTH_FAIL = 5
- ERR_CODE_HCI_PINKEY_MISSING = 6
- ERR_CODE_HCI_MEM_CAPACITY = 7
- ERR_CODE_HCI_CONN_SPVN_TMO = 8
- ERR_CODE_HCI_CONN_LIMIT = 9
- ERR_CODE_HCI_SYNCH_CONN_LIMIT = 10
- ERR_CODE_HCI_ACL_CONN_EXISTS = 11
- ERR_CODE_HCI_CMD_DISALLOWED = 12
- ERR_CODE_HCI_CONN_REJ_RESOURCES = 13
- ERR_CODE_HCI_CONN_REJ_SECURITY = 14
- ERR_CODE_HCI_CONN_REJ_BD_ADDR = 15
- ERR_CODE_HCI_CONN_ACCEPT_TMO = 16
- ERR_CODE_HCI_UNSUPPORTED = 17
- ERR_CODE_HCI_INV_HCI_CMD_PARMS = 18
- ERR_CODE_HCI_REM_USER_CONN_TERM = 19
- ERR_CODE_HCI_RD_CONN_TERM_RESRCS = 20
- ERR_CODE_HCI_RD_CONN_TERM_PWROFF = 21
- ERR_CODE_HCI_CONN_TERM_LOCAL = 22
- ERR_CODE_HCI_REPEATED_ATTEMPTS = 23
- ERR_CODE_HCI_NO_PAIRING = 24
- ERR_CODE_HCI_UNK_LMP = 25
- ERR_CODE_HCI_UNSUPP_REM_FEATURE = 26
- ERR_CODE_HCI_SCO_OFFSET = 27
- ERR_CODE_HCI_SCO_ITVL = 28
- ERR_CODE_HCI_SCO_AIR_MODE = 29
- ERR_CODE_HCI_INV_LMP_LL_PARM = 30
- ERR_CODE_HCI_UNSPECIFIED = 31
- ERR_CODE_HCI_UNSUPP_LMP_LL_PARM = 32
- ERR_CODE_HCI_NO_ROLE_CHANGE = 33
- ERR_CODE_HCI_LMP_LL_RSP_TMO = 34
- ERR_CODE_HCI_LMP_COLLISION = 35
- ERR_CODE_HCI_LMP_PDU = 36
- ERR_CODE_HCI_ENCRYPTION_MODE = 37
- ERR_CODE_HCI_LINK_KEY_CHANGE = 38
- ERR_CODE_HCI_UNSUPP_QOS = 39
- ERR_CODE_HCI_INSTANT_PASSED = 40
- ERR_CODE_HCI_UNIT_KEY_PAIRING = 41
- ERR_CODE_HCI_DIFF_TRANS_COLL = 42
- ERR_CODE_HCI_QOS_PARM = 44
- ERR_CODE_HCI_QOS_REJECTED = 45
- ERR_CODE_HCI_CHAN_CLASS = 46
- ERR_CODE_HCI_INSUFFICIENT_SEC = 47
- ERR_CODE_HCI_PARM_OUT_OF_RANGE = 48
- ERR_CODE_HCI_PENDING_ROLE_SW = 50
- ERR_CODE_HCI_RESERVED_SLOT = 52
- ERR_CODE_HCI_ROLE_SW_FAIL = 53
- ERR_CODE_HCI_INQ_RSP_TOO_BIG = 54
- ERR_CODE_HCI_SEC_SIMPLE_PAIR = 55
- ERR_CODE_HCI_HOST_BUSY_PAIR = 56
- ERR_CODE_HCI_CONN_REJ_CHANNEL = 57
- ERR_CODE_HCI_CTLR_BUSY = 58
- ERR_CODE_HCI_CONN_PARMS = 59
- ERR_CODE_HCI_DIR_ADV_TMO = 60
- ERR_CODE_HCI_CONN_TERM_MIC = 61
- ERR_CODE_HCI_CONN_ESTABLISHMENT = 62
- ERR_CODE_HCI_MAC_CONN_FAIL = 63
- ERR_CODE_HCI_COARSE_CLK_ADJ = 64
-)
-
-var HciErrCodeStringMap = map[int]string{
- ERR_CODE_HCI_UNKNOWN_HCI_CMD: "unknown hci cmd",
- ERR_CODE_HCI_UNK_CONN_ID: "unknown connection id",
- ERR_CODE_HCI_HW_FAIL: "hw fail",
- ERR_CODE_HCI_PAGE_TMO: "page tmo",
- ERR_CODE_HCI_AUTH_FAIL: "auth fail",
- ERR_CODE_HCI_PINKEY_MISSING: "pinkey missing",
- ERR_CODE_HCI_MEM_CAPACITY: "mem capacity",
- ERR_CODE_HCI_CONN_SPVN_TMO: "connection supervision timeout",
- ERR_CODE_HCI_CONN_LIMIT: "conn limit",
- ERR_CODE_HCI_SYNCH_CONN_LIMIT: "synch conn limit",
- ERR_CODE_HCI_ACL_CONN_EXISTS: "acl conn exists",
- ERR_CODE_HCI_CMD_DISALLOWED: "cmd disallowed",
- ERR_CODE_HCI_CONN_REJ_RESOURCES: "conn rej resources",
- ERR_CODE_HCI_CONN_REJ_SECURITY: "conn rej security",
- ERR_CODE_HCI_CONN_REJ_BD_ADDR: "conn rej bd addr",
- ERR_CODE_HCI_CONN_ACCEPT_TMO: "conn accept tmo",
- ERR_CODE_HCI_UNSUPPORTED: "unsupported",
- ERR_CODE_HCI_INV_HCI_CMD_PARMS: "inv hci cmd parms",
- ERR_CODE_HCI_REM_USER_CONN_TERM: "rem user conn term",
- ERR_CODE_HCI_RD_CONN_TERM_RESRCS: "rd conn term resrcs",
- ERR_CODE_HCI_RD_CONN_TERM_PWROFF: "rd conn term pwroff",
- ERR_CODE_HCI_CONN_TERM_LOCAL: "conn term local",
- ERR_CODE_HCI_REPEATED_ATTEMPTS: "repeated attempts",
- ERR_CODE_HCI_NO_PAIRING: "no pairing",
- ERR_CODE_HCI_UNK_LMP: "unk lmp",
- ERR_CODE_HCI_UNSUPP_REM_FEATURE: "unsupp rem feature",
- ERR_CODE_HCI_SCO_OFFSET: "sco offset",
- ERR_CODE_HCI_SCO_ITVL: "sco itvl",
- ERR_CODE_HCI_SCO_AIR_MODE: "sco air mode",
- ERR_CODE_HCI_INV_LMP_LL_PARM: "inv lmp ll parm",
- ERR_CODE_HCI_UNSPECIFIED: "unspecified",
- ERR_CODE_HCI_UNSUPP_LMP_LL_PARM: "unsupp lmp ll parm",
- ERR_CODE_HCI_NO_ROLE_CHANGE: "no role change",
- ERR_CODE_HCI_LMP_LL_RSP_TMO: "lmp ll rsp tmo",
- ERR_CODE_HCI_LMP_COLLISION: "lmp collision",
- ERR_CODE_HCI_LMP_PDU: "lmp pdu",
- ERR_CODE_HCI_ENCRYPTION_MODE: "encryption mode",
- ERR_CODE_HCI_LINK_KEY_CHANGE: "link key change",
- ERR_CODE_HCI_UNSUPP_QOS: "unsupp qos",
- ERR_CODE_HCI_INSTANT_PASSED: "instant passed",
- ERR_CODE_HCI_UNIT_KEY_PAIRING: "unit key pairing",
- ERR_CODE_HCI_DIFF_TRANS_COLL: "diff trans coll",
- ERR_CODE_HCI_QOS_PARM: "qos parm",
- ERR_CODE_HCI_QOS_REJECTED: "qos rejected",
- ERR_CODE_HCI_CHAN_CLASS: "chan class",
- ERR_CODE_HCI_INSUFFICIENT_SEC: "insufficient sec",
- ERR_CODE_HCI_PARM_OUT_OF_RANGE: "parm out of range",
- ERR_CODE_HCI_PENDING_ROLE_SW: "pending role sw",
- ERR_CODE_HCI_RESERVED_SLOT: "reserved slot",
- ERR_CODE_HCI_ROLE_SW_FAIL: "role sw fail",
- ERR_CODE_HCI_INQ_RSP_TOO_BIG: "inq rsp too big",
- ERR_CODE_HCI_SEC_SIMPLE_PAIR: "sec simple pair",
- ERR_CODE_HCI_HOST_BUSY_PAIR: "host busy pair",
- ERR_CODE_HCI_CONN_REJ_CHANNEL: "conn rej channel",
- ERR_CODE_HCI_CTLR_BUSY: "ctlr busy",
- ERR_CODE_HCI_CONN_PARMS: "conn parms",
- ERR_CODE_HCI_DIR_ADV_TMO: "dir adv tmo",
- ERR_CODE_HCI_CONN_TERM_MIC: "conn term mic",
- ERR_CODE_HCI_CONN_ESTABLISHMENT: "conn establishment",
- ERR_CODE_HCI_MAC_CONN_FAIL: "mac conn fail",
- ERR_CODE_HCI_COARSE_CLK_ADJ: "coarse clk adj",
-}
-
-const (
- MSG_OP_REQ MsgOp = 0
- MSG_OP_RSP = 1
- MSG_OP_EVT = 2
-)
-
-const (
- MSG_TYPE_ERR MsgType = 1
- MSG_TYPE_SYNC = 2
- MSG_TYPE_CONNECT = 3
- MSG_TYPE_TERMINATE = 4
- MSG_TYPE_DISC_ALL_SVCS = 5
- MSG_TYPE_DISC_SVC_UUID = 6
- MSG_TYPE_DISC_ALL_CHRS = 7
- MSG_TYPE_DISC_CHR_UUID = 8
- MSG_TYPE_WRITE = 9
- MSG_TYPE_WRITE_CMD = 10
- MSG_TYPE_EXCHANGE_MTU = 11
- MSG_TYPE_GEN_RAND_ADDR = 12
- MSG_TYPE_SET_RAND_ADDR = 13
- MSG_TYPE_CONN_CANCEL = 14
- MSG_TYPE_SCAN = 15
- MSG_TYPE_SCAN_CANCEL = 16
-
- MSG_TYPE_SYNC_EVT = 2049
- MSG_TYPE_CONNECT_EVT = 2050
- MSG_TYPE_DISCONNECT_EVT = 2051
- MSG_TYPE_DISC_SVC_EVT = 2052
- MSG_TYPE_DISC_CHR_EVT = 2053
- MSG_TYPE_WRITE_ACK_EVT = 2054
- MSG_TYPE_NOTIFY_RX_EVT = 2055
- MSG_TYPE_MTU_CHANGE_EVT = 2056
- MSG_TYPE_SCAN_EVT = 2057
-)
-
-var MsgOpStringMap = map[MsgOp]string{
- MSG_OP_REQ: "request",
- MSG_OP_RSP: "response",
- MSG_OP_EVT: "event",
-}
-
-var MsgTypeStringMap = map[MsgType]string{
- MSG_TYPE_ERR: "error",
- MSG_TYPE_SYNC: "sync",
- MSG_TYPE_CONNECT: "connect",
- MSG_TYPE_TERMINATE: "terminate",
- MSG_TYPE_DISC_SVC_UUID: "disc_svc_uuid",
- MSG_TYPE_DISC_CHR_UUID: "disc_chr_uuid",
- MSG_TYPE_DISC_ALL_CHRS: "disc_all_chrs",
- MSG_TYPE_WRITE_CMD: "write_cmd",
- MSG_TYPE_EXCHANGE_MTU: "exchange_mtu",
- MSG_TYPE_CONN_CANCEL: "conn_cancel",
- MSG_TYPE_SCAN: "scan",
- MSG_TYPE_SCAN_CANCEL: "scan_cancel",
-
- MSG_TYPE_SYNC_EVT: "sync_evt",
- MSG_TYPE_CONNECT_EVT: "connect_evt",
- MSG_TYPE_DISCONNECT_EVT: "disconnect_evt",
- MSG_TYPE_DISC_SVC_EVT: "disc_svc_evt",
- MSG_TYPE_DISC_CHR_EVT: "disc_chr_evt",
- MSG_TYPE_NOTIFY_RX_EVT: "notify_rx_evt",
- MSG_TYPE_MTU_CHANGE_EVT: "mtu_change_evt",
- MSG_TYPE_SCAN_EVT: "scan_evt",
-}
-
-type BleHdr struct {
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-}
-
-type BleMsg interface{}
-
-type BleSvc struct {
- StartHandle int `json:"start_handle"`
- EndHandle int `json:"end_handle"`
- Uuid BleUuid `json:"uuid"`
-}
-
-type BleChr struct {
- DefHandle int `json:"def_handle"`
- ValHandle int `json:"val_handle"`
- Properties int `json:"properties"`
- Uuid BleUuid `json:"uuid"`
-}
-
-type BleSyncReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-}
-
-type BleConnectReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- OwnAddrType BleAddrType `json:"own_addr_type"`
- PeerAddrType BleAddrType `json:"peer_addr_type"`
- PeerAddr BleAddr `json:"peer_addr"`
-
- // Optional
- DurationMs int `json:"duration_ms"`
- ScanItvl int `json:"scan_itvl"`
- ScanWindow int `json:"scan_window"`
- ItvlMin int `json:"itvl_min"`
- ItvlMax int `json:"itvl_max"`
- Latency int `json:"latency"`
- SupervisionTimeout int `json:"supervision_timeout"`
- MinCeLen int `json:"min_ce_len"`
- MaxCeLen int `json:"max_ce_len"`
-}
-
-type BleConnectRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleConnectEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
- ConnHandle int `json:"conn_handle"`
- OwnIdAddrType BleAddrType `json:"own_id_addr_type"`
- OwnIdAddr BleAddr `json:"own_id_addr"`
- OwnOtaAddrType BleAddrType `json:"own_ota_addr_type"`
- OwnOtaAddr BleAddr `json:"own_ota_addr"`
- PeerIdAddrType BleAddrType `json:"peer_id_addr_type"`
- PeerIdAddr BleAddr `json:"peer_id_addr"`
- PeerOtaAddrType BleAddrType `json:"peer_ota_addr_type"`
- PeerOtaAddr BleAddr `json:"peer_ota_addr"`
-}
-
-type BleTerminateReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- ConnHandle int `json:"conn_handle"`
- HciReason int `json:"hci_reason"`
-}
-
-type BleTerminateRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleConnCancelReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-}
-
-type BleConnCancelRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleDisconnectEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Reason int `json:"reason"`
- ConnHandle int `json:"conn_handle"`
-}
-
-type BleDiscSvcUuidReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- ConnHandle int `json:"conn_handle"`
- Uuid BleUuid `json:"svc_uuid"`
-}
-
-type BleDiscSvcUuidRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleDiscSvcEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
- Svc BleSvc `json:"service"`
-}
-
-type BleDiscChrUuidReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- ConnHandle int `json:"conn_handle"`
- StartHandle int `json:"start_handle"`
- EndHandle int `json:"end_handle"`
- Uuid BleUuid `json:"chr_uuid"`
-}
-
-type BleDiscAllChrsReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- ConnHandle int `json:"conn_handle"`
- StartHandle int `json:"start_handle"`
- EndHandle int `json:"end_handle"`
-}
-
-type BleDiscAllChrsRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleErrRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
- Msg string `json:"msg"`
-}
-
-type BleSyncRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Synced bool `json:"synced"`
-}
-
-type BleDiscChrUuidRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleDiscChrEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
- Chr BleChr `json:"characteristic"`
-}
-
-type BleWriteCmdReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- ConnHandle int `json:"conn_handle"`
- AttrHandle int `json:"attr_handle"`
- Data BleBytes `json:"data"`
-}
-
-type BleWriteCmdRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleSyncEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Synced bool `json:"synced"`
-}
-
-type BleNotifyRxEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- ConnHandle int `json:"conn_handle"`
- AttrHandle int `json:"attr_handle"`
- Indication bool `json:"indication"`
- Data BleBytes `json:"data"`
-}
-
-type BleExchangeMtuReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- ConnHandle int `json:"conn_handle"`
-}
-
-type BleExchangeMtuRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleMtuChangeEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
- ConnHandle int `json:"conn_handle"`
- Mtu int `json:"mtu"`
-}
-
-type BleScanReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- OwnAddrType BleAddrType `json:"own_addr_type"`
- DurationMs int `json:"duration_ms"`
- Itvl int `json:"itvl"`
- Window int `json:"window"`
- FilterPolicy BleScanFilterPolicy `json:"filter_policy"`
- Limited bool `json:"limited"`
- Passive bool `json:"passive"`
- FilterDuplicates bool `json:"filter_duplicates"`
-}
-
-type BleScanRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-type BleScanEvt struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- EventType BleAdvEventType `json:"event_type"`
- AddrType BleAddrType `json:"addr_type"`
- Addr BleAddr `json:"addr"`
- Rssi int8 `json:"rssi"`
- Data BleBytes `json:"data"`
-
- // Optional
- DataFlags uint8 `json:"data_flags"`
- DataName string `json:"data_name"`
- DataNameIsComplete bool `json:"data_name_is_complete"`
-}
-
-type BleScanCancelReq struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-}
-
-type BleScanCancelRsp struct {
- // Header
- Op MsgOp `json:"op"`
- Type MsgType `json:"type"`
- Seq int `json:"seq"`
-
- // Mandatory
- Status int `json:"status"`
-}
-
-func ErrCodeToString(e int) string {
- var s string
-
- switch {
- case e >= ERR_CODE_SM_PEER_BASE:
- case e >= ERR_CODE_SM_US_BASE:
- case e >= ERR_CODE_L2C_BASE:
- case e >= ERR_CODE_HCI_BASE:
- s = HciErrCodeStringMap[e-ERR_CODE_HCI_BASE]
-
- case e >= ERR_CODE_ATT_BASE:
- default:
- s = ErrCodeStringMap[e]
- }
-
- if s == "" {
- s = "unknown"
- }
-
- return s
-}
-
-func MsgOpToString(op MsgOp) string {
- s := MsgOpStringMap[op]
- if s == "" {
- panic(fmt.Sprintf("Invalid MsgOp: %d", int(op)))
- }
-
- return s
-}
-
-func MsgOpFromString(s string) (MsgOp, error) {
- for op, name := range MsgOpStringMap {
- if s == name {
- return op, nil
- }
- }
-
- return MsgOp(0), errors.New("Invalid MsgOp string: " + s)
-}
-
-func MsgTypeToString(msgType MsgType) string {
- s := MsgTypeStringMap[msgType]
- if s == "" {
- panic(fmt.Sprintf("Invalid MsgType: %d", int(msgType)))
- }
-
- return s
-}
-
-func MsgTypeFromString(s string) (MsgType, error) {
- for addrType, name := range MsgTypeStringMap {
- if s == name {
- return addrType, nil
- }
- }
-
- return MsgType(0), errors.New("Invalid MsgType string: " + s)
-}
-
-func (o MsgOp) MarshalJSON() ([]byte, error) {
- return json.Marshal(MsgOpToString(o))
-}
-
-func (o *MsgOp) UnmarshalJSON(data []byte) error {
- var err error
-
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- *o, err = MsgOpFromString(s)
- return err
-}
-
-func (t MsgType) MarshalJSON() ([]byte, error) {
- return json.Marshal(MsgTypeToString(t))
-}
-
-func (t *MsgType) UnmarshalJSON(data []byte) error {
- var err error
-
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- *t, err = MsgTypeFromString(s)
- return err
-}
-
-func (bb *BleBytes) MarshalJSON() ([]byte, error) {
- var buf bytes.Buffer
- buf.Grow(len(bb.Bytes) * 5)
-
- for i, b := range bb.Bytes {
- if i != 0 {
- buf.WriteString(":")
- }
- fmt.Fprintf(&buf, "0x%02x", b)
- }
-
- s := buf.String()
- return json.Marshal(s)
-
- return buf.Bytes(), nil
-}
-
-func (bb *BleBytes) UnmarshalJSON(data []byte) error {
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- // strings.Split() appears to return { nil } when passed an empty string.
- if len(s) == 0 {
- return nil
- }
-
- toks := strings.Split(strings.ToLower(s), ":")
- bb.Bytes = make([]byte, len(toks))
-
- for i, t := range toks {
- if !strings.HasPrefix(t, "0x") {
- return fmt.Errorf(
- "Byte stream contains invalid token; token=%s stream=%s", t, s)
- }
-
- u64, err := strconv.ParseUint(t, 0, 8)
- if err != nil {
- return err
- }
- bb.Bytes[i] = byte(u64)
- }
-
- return nil
-}
-
-func (bu *BleUuid) String() string {
- var buf bytes.Buffer
- buf.Grow(len(bu.Bytes)*2 + 3)
-
- // XXX: For now, only support 128-bit UUIDs.
-
- for i, b := range bu.Bytes {
- switch i {
- case 4, 6, 8, 10:
- buf.WriteString("-")
- }
-
- fmt.Fprintf(&buf, "%02x", b)
- }
-
- return buf.String()
-}
-
-func (bu *BleUuid) MarshalJSON() ([]byte, error) {
- return json.Marshal(bu.String())
-}
-
-func (bu *BleUuid) UnmarshalJSON(data []byte) error {
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- var err error
- *bu, err = ParseUuid(s)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func CompareUuids(a BleUuid, b BleUuid) int {
- return bytes.Compare(a.Bytes[:], b.Bytes[:])
-}