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/03 03:19:43 UTC

[1/7] incubator-mynewt-newt git commit: MYNEWT-653 Change Golang imports to runtimeco

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 0a3ce8e9f -> abf65d3a7


MYNEWT-653 Change Golang imports to runtimeco


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/671a1541
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/671a1541
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/671a1541

Branch: refs/heads/develop
Commit: 671a1541f0712f417dba98351dde71a65b68713f
Parents: 0a3ce8e
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Mar 2 19:12:22 2017 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Mar 2 19:12:22 2017 -0800

----------------------------------------------------------------------
 newtmgr/transport/connble.go        | 10 +++++-----
 newtmgr/transport/connble_darwin.go |  2 +-
 newtmgr/transport/connble_linux.go  |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/671a1541/newtmgr/transport/connble.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connble.go b/newtmgr/transport/connble.go
index e8bcb66..f19b0b8 100644
--- a/newtmgr/transport/connble.go
+++ b/newtmgr/transport/connble.go
@@ -22,7 +22,7 @@ import (
 	log "github.com/Sirupsen/logrus"
 	"time"
 
-	"github.com/runtimeinc/gatt"
+	"github.com/runtimeco/gatt"
 
 	"mynewt.apache.org/newt/newtmgr/config"
 	"mynewt.apache.org/newt/util"
@@ -119,7 +119,7 @@ func onPeriphConnected(p gatt.Peripheral, err error) {
 	for _, service := range services {
 
 		if service.UUID().Equal(newtmgrServiceId) ||
-		   service.UUID().Equal(newtmgrCoapServiceId) {
+			service.UUID().Equal(newtmgrCoapServiceId) {
 			log.Debugf("Newtmgr Service Found %s", service.Name())
 
 			if service.UUID().Equal(newtmgrCoapServiceId) {
@@ -130,9 +130,9 @@ func onPeriphConnected(p gatt.Peripheral, err error) {
 
 			for _, c := range cs {
 				if (isCoap == false &&
-				    c.UUID().Equal(newtmgrServiceCharId)) ||
-				   (isCoap == true &&
-				    c.UUID().Equal(newtmgrCoapServiceCharId)) {
+					c.UUID().Equal(newtmgrServiceCharId)) ||
+					(isCoap == true &&
+						c.UUID().Equal(newtmgrCoapServiceCharId)) {
 					log.Debugf("Newtmgr Characteristic Found")
 					p.SetNotifyValue(c, newtmgrNotifyCB)
 					deviceChar = c

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/671a1541/newtmgr/transport/connble_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connble_darwin.go b/newtmgr/transport/connble_darwin.go
index 8708cb7..ebbdadd 100644
--- a/newtmgr/transport/connble_darwin.go
+++ b/newtmgr/transport/connble_darwin.go
@@ -18,6 +18,6 @@
  */
 package transport
 
-import "github.com/runtimeinc/gatt"
+import "github.com/runtimeco/gatt"
 
 var BleOptions = []gatt.Option{}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/671a1541/newtmgr/transport/connble_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connble_linux.go b/newtmgr/transport/connble_linux.go
index 4074a5b..2c241f0 100644
--- a/newtmgr/transport/connble_linux.go
+++ b/newtmgr/transport/connble_linux.go
@@ -18,7 +18,7 @@
  */
 package transport
 
-import "github.com/runtimeinc/gatt"
+import "github.com/runtimeco/gatt"
 
 var BleOptions = []gatt.Option{
 	gatt.LnxMaxConnections(1),


[4/7] incubator-mynewt-newt git commit: MYNEWT-653 Use runtimeco gatt fork.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/central.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/central.go b/newtmgr/vendor/github.com/runtimeinc/gatt/central.go
deleted file mode 100644
index 55bd2c1..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/central.go
+++ /dev/null
@@ -1,152 +0,0 @@
-package gatt
-
-import (
-	"bytes"
-	"errors"
-	"fmt"
-	"sync"
-)
-
-// Central is the interface that represent a remote central device.
-type Central interface {
-	ID() string   // ID returns platform specific ID of the remote central device.
-	Close() error // Close disconnects the connection.
-	MTU() int     // MTU returns the current connection mtu.
-}
-
-type ResponseWriter interface {
-	// Write writes data to return as the characteristic value.
-	Write([]byte) (int, error)
-
-	// SetStatus reports the result of the read operation. See the Status* constants.
-	SetStatus(byte)
-}
-
-// responseWriter is the default implementation of ResponseWriter.
-type responseWriter struct {
-	capacity int
-	buf      *bytes.Buffer
-	status   byte
-}
-
-func newResponseWriter(c int) *responseWriter {
-	return &responseWriter{
-		capacity: c,
-		buf:      new(bytes.Buffer),
-		status:   StatusSuccess,
-	}
-}
-
-func (w *responseWriter) Write(b []byte) (int, error) {
-	if avail := w.capacity - w.buf.Len(); avail < len(b) {
-		return 0, fmt.Errorf("requested write %d bytes, %d available", len(b), avail)
-	}
-	return w.buf.Write(b)
-}
-
-func (w *responseWriter) SetStatus(status byte) { w.status = status }
-func (w *responseWriter) bytes() []byte         { return w.buf.Bytes() }
-
-// A ReadHandler handles GATT read requests.
-type ReadHandler interface {
-	ServeRead(resp ResponseWriter, req *ReadRequest)
-}
-
-// ReadHandlerFunc is an adapter to allow the use of
-// ordinary functions as ReadHandlers. If f is a function
-// with the appropriate signature, ReadHandlerFunc(f) is a
-// ReadHandler that calls f.
-type ReadHandlerFunc func(resp ResponseWriter, req *ReadRequest)
-
-// ServeRead returns f(r, maxlen, offset).
-func (f ReadHandlerFunc) ServeRead(resp ResponseWriter, req *ReadRequest) {
-	f(resp, req)
-}
-
-// A WriteHandler handles GATT write requests.
-// Write and WriteNR requests are presented identically;
-// the server will ensure that a response is sent if appropriate.
-type WriteHandler interface {
-	ServeWrite(r Request, data []byte) (status byte)
-}
-
-// WriteHandlerFunc is an adapter to allow the use of
-// ordinary functions as WriteHandlers. If f is a function
-// with the appropriate signature, WriteHandlerFunc(f) is a
-// WriteHandler that calls f.
-type WriteHandlerFunc func(r Request, data []byte) byte
-
-// ServeWrite returns f(r, data).
-func (f WriteHandlerFunc) ServeWrite(r Request, data []byte) byte {
-	return f(r, data)
-}
-
-// A NotifyHandler handles GATT notification requests.
-// Notifications can be sent using the provided notifier.
-type NotifyHandler interface {
-	ServeNotify(r Request, n Notifier)
-}
-
-// NotifyHandlerFunc is an adapter to allow the use of
-// ordinary functions as NotifyHandlers. If f is a function
-// with the appropriate signature, NotifyHandlerFunc(f) is a
-// NotifyHandler that calls f.
-type NotifyHandlerFunc func(r Request, n Notifier)
-
-// ServeNotify calls f(r, n).
-func (f NotifyHandlerFunc) ServeNotify(r Request, n Notifier) {
-	f(r, n)
-}
-
-// A Notifier provides a means for a GATT server to send
-// notifications about value changes to a connected device.
-// Notifiers are provided by NotifyHandlers.
-type Notifier interface {
-	// Write sends data to the central.
-	Write(data []byte) (int, error)
-
-	// Done reports whether the central has requested not to
-	// receive any more notifications with this notifier.
-	Done() bool
-
-	// Cap returns the maximum number of bytes that may be sent
-	// in a single notification.
-	Cap() int
-}
-
-type notifier struct {
-	central *central
-	a       *attr
-	maxlen  int
-	donemu  sync.RWMutex
-	done    bool
-}
-
-func newNotifier(c *central, a *attr, maxlen int) *notifier {
-	return &notifier{central: c, a: a, maxlen: maxlen}
-}
-
-func (n *notifier) Write(b []byte) (int, error) {
-	n.donemu.RLock()
-	defer n.donemu.RUnlock()
-	if n.done {
-		return 0, errors.New("central stopped notifications")
-	}
-	return n.central.sendNotification(n.a, b)
-}
-
-func (n *notifier) Cap() int {
-	return n.maxlen
-}
-
-func (n *notifier) Done() bool {
-	n.donemu.RLock()
-	defer n.donemu.RUnlock()
-	return n.done
-}
-
-func (n *notifier) stop() {
-	n.donemu.Lock()
-	n.done = true
-	n.donemu.Unlock()
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/central_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/central_darwin.go b/newtmgr/vendor/github.com/runtimeinc/gatt/central_darwin.go
deleted file mode 100644
index e5eed0a..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/central_darwin.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package gatt
-
-import (
-	"sync"
-
-	"github.com/runtimeinc/gatt/xpc"
-)
-
-type central struct {
-	dev         *device
-	uuid        UUID
-	mtu         int
-	notifiers   map[uint16]*notifier
-	notifiersmu *sync.Mutex
-}
-
-func newCentral(d *device, u UUID) *central {
-	return &central{
-		dev:         d,
-		mtu:         23,
-		uuid:        u,
-		notifiers:   make(map[uint16]*notifier),
-		notifiersmu: &sync.Mutex{},
-	}
-}
-
-func (c *central) ID() string   { return c.uuid.String() }
-func (c *central) Close() error { return nil }
-func (c *central) MTU() int     { return c.mtu }
-
-func (c *central) sendNotification(a *attr, b []byte) (int, error) {
-	data := make([]byte, len(b))
-	copy(data, b) // have to make a copy, why?
-	c.dev.sendCmd(15, xpc.Dict{
-		// "kCBMsgArgUUIDs": [][]byte{reverse(c.uuid.b)}, // connection interrupted
-		// "kCBMsgArgUUIDs": [][]byte{c.uuid.b}, // connection interrupted
-		// "kCBMsgArgUUIDs": []xpc.UUID{xpc.UUID(reverse(c.uuid.b))},
-		// "kCBMsgArgUUIDs": []xpc.UUID{xpc.UUID(c.uuid.b)},
-		// "kCBMsgArgUUIDs": reverse(c.uuid.b),
-		//
-		// FIXME: Sigh... tried to targeting the central, but couldn't get work.
-		// So, broadcast to all subscribed centrals. Either of the following works.
-		// "kCBMsgArgUUIDs": []xpc.UUID{},
-		"kCBMsgArgUUIDs":       [][]byte{},
-		"kCBMsgArgAttributeID": a.h,
-		"kCBMsgArgData":        data,
-	})
-	return len(b), nil
-}
-
-func (c *central) startNotify(a *attr, maxlen int) {
-	c.notifiersmu.Lock()
-	defer c.notifiersmu.Unlock()
-	if _, found := c.notifiers[a.h]; found {
-		return
-	}
-	n := newNotifier(c, a, maxlen)
-	c.notifiers[a.h] = n
-	char := a.pvt.(*Characteristic)
-	go char.nhandler.ServeNotify(Request{Central: c}, n)
-}
-
-func (c *central) stopNotify(a *attr) {
-	c.notifiersmu.Lock()
-	defer c.notifiersmu.Unlock()
-	if n, found := c.notifiers[a.h]; found {
-		n.stop()
-		delete(c.notifiers, a.h)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/central_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/central_linux.go b/newtmgr/vendor/github.com/runtimeinc/gatt/central_linux.go
deleted file mode 100644
index 3ae6994..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/central_linux.go
+++ /dev/null
@@ -1,446 +0,0 @@
-package gatt
-
-import (
-	"encoding/binary"
-	"io"
-	"net"
-	"sync"
-)
-
-type security int
-
-const (
-	securityLow = iota
-	securityMed
-	securityHigh
-)
-
-type central struct {
-	attrs       *attrRange
-	mtu         uint16
-	addr        net.HardwareAddr
-	security    security
-	l2conn      io.ReadWriteCloser
-	notifiers   map[uint16]*notifier
-	notifiersmu *sync.Mutex
-}
-
-func newCentral(a *attrRange, addr net.HardwareAddr, l2conn io.ReadWriteCloser) *central {
-	return &central{
-		attrs:       a,
-		mtu:         23,
-		addr:        addr,
-		security:    securityLow,
-		l2conn:      l2conn,
-		notifiers:   make(map[uint16]*notifier),
-		notifiersmu: &sync.Mutex{},
-	}
-}
-
-func (c *central) ID() string {
-	return c.addr.String()
-}
-
-func (c *central) Close() error {
-	c.notifiersmu.Lock()
-	defer c.notifiersmu.Unlock()
-	for _, n := range c.notifiers {
-		n.stop()
-	}
-	return c.l2conn.Close()
-}
-
-func (c *central) MTU() int {
-	return int(c.mtu)
-}
-
-func (c *central) loop() {
-	for {
-		// L2CAP implementations shall support a minimum MTU size of 48 bytes.
-		// The default value is 672 bytes
-		b := make([]byte, 672)
-		n, err := c.l2conn.Read(b)
-		if n == 0 || err != nil {
-			c.Close()
-			break
-		}
-		if rsp := c.handleReq(b[:n]); rsp != nil {
-			c.l2conn.Write(rsp)
-		}
-	}
-}
-
-// handleReq dispatches a raw request from the central shim
-// to an appropriate handler, based on its type.
-// It panics if len(b) == 0.
-func (c *central) handleReq(b []byte) []byte {
-	var resp []byte
-	switch reqType, req := b[0], b[1:]; reqType {
-	case attOpMtuReq:
-		resp = c.handleMTU(req)
-	case attOpFindInfoReq:
-		resp = c.handleFindInfo(req)
-	case attOpFindByTypeValueReq:
-		resp = c.handleFindByTypeValue(req)
-	case attOpReadByTypeReq:
-		resp = c.handleReadByType(req)
-	case attOpReadReq:
-		resp = c.handleRead(req)
-	case attOpReadBlobReq:
-		resp = c.handleReadBlob(req)
-	case attOpReadByGroupReq:
-		resp = c.handleReadByGroup(req)
-	case attOpWriteReq, attOpWriteCmd:
-		resp = c.handleWrite(reqType, req)
-	case attOpReadMultiReq, attOpPrepWriteReq, attOpExecWriteReq, attOpSignedWriteCmd:
-		fallthrough
-	default:
-		resp = attErrorRsp(reqType, 0x0000, attEcodeReqNotSupp)
-	}
-	return resp
-}
-
-func (c *central) handleMTU(b []byte) []byte {
-	c.mtu = binary.LittleEndian.Uint16(b[:2])
-	if c.mtu < 23 {
-		c.mtu = 23
-	}
-	if c.mtu >= 256 {
-		c.mtu = 256
-	}
-	return []byte{attOpMtuRsp, uint8(c.mtu), uint8(c.mtu >> 8)}
-}
-
-// REQ: FindInfoReq(0x04), StartHandle, EndHandle
-// RSP: FindInfoRsp(0x05), UUIDFormat, Handle, UUID, Handle, UUID, ...
-func (c *central) handleFindInfo(b []byte) []byte {
-	start, end := readHandleRange(b[:4])
-
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpFindInfoRsp)
-
-	uuidLen := -1
-	for _, a := range c.attrs.Subrange(start, end) {
-		if uuidLen == -1 {
-			uuidLen = a.typ.Len()
-			if uuidLen == 2 {
-				w.WriteByteFit(0x01) // TODO: constants for 16bit vs 128bit uuid magic numbers here
-			} else {
-				w.WriteByteFit(0x02)
-			}
-		}
-		if a.typ.Len() != uuidLen {
-			break
-		}
-		w.Chunk()
-		w.WriteUint16Fit(a.h)
-		w.WriteUUIDFit(a.typ)
-		if ok := w.Commit(); !ok {
-			break
-		}
-	}
-
-	if uuidLen == -1 {
-		return attErrorRsp(attOpFindInfoReq, start, attEcodeAttrNotFound)
-	}
-	return w.Bytes()
-}
-
-// REQ: FindByTypeValueReq(0x06), StartHandle, EndHandle, Type(UUID), Value
-// RSP: FindByTypeValueRsp(0x07), AttrHandle, GroupEndHandle, AttrHandle, GroupEndHandle, ...
-func (c *central) handleFindByTypeValue(b []byte) []byte {
-	start, end := readHandleRange(b[:4])
-	t := UUID{b[4:6]}
-	u := UUID{b[6:]}
-
-	// Only support the ATT ReadByGroupReq for GATT Primary Service Discovery.
-	// More sepcifically, the "Discover Primary Services By Service UUID" sub-procedure
-	if !t.Equal(attrPrimaryServiceUUID) {
-		return attErrorRsp(attOpFindByTypeValueReq, start, attEcodeAttrNotFound)
-	}
-
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpFindByTypeValueRsp)
-
-	var wrote bool
-	for _, a := range c.attrs.Subrange(start, end) {
-		if !a.typ.Equal(attrPrimaryServiceUUID) {
-			continue
-		}
-		if !(UUID{a.value}.Equal(u)) {
-			continue
-		}
-		s := a.pvt.(*Service)
-		w.Chunk()
-		w.WriteUint16Fit(s.h)
-		w.WriteUint16Fit(s.endh)
-		if ok := w.Commit(); !ok {
-			break
-		}
-		wrote = true
-	}
-	if !wrote {
-		return attErrorRsp(attOpFindByTypeValueReq, start, attEcodeAttrNotFound)
-	}
-
-	return w.Bytes()
-}
-
-// REQ: ReadByType(0x08), StartHandle, EndHandle, Type(UUID)
-// RSP: ReadByType(0x09), LenOfEachDataField, DataField, DataField, ...
-func (c *central) handleReadByType(b []byte) []byte {
-	start, end := readHandleRange(b[:4])
-	t := UUID{b[4:]}
-
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpReadByTypeRsp)
-	uuidLen := -1
-	for _, a := range c.attrs.Subrange(start, end) {
-		if !a.typ.Equal(t) {
-			continue
-		}
-		if (a.secure&CharRead) != 0 && c.security > securityLow {
-			return attErrorRsp(attOpReadByTypeReq, start, attEcodeAuthentication)
-		}
-		v := a.value
-		if v == nil {
-			rsp := newResponseWriter(int(c.mtu - 1))
-			req := &ReadRequest{
-				Request: Request{Central: c},
-				Cap:     int(c.mtu - 1),
-				Offset:  0,
-			}
-			if c, ok := a.pvt.(*Characteristic); ok {
-				c.rhandler.ServeRead(rsp, req)
-			} else if d, ok := a.pvt.(*Descriptor); ok {
-				d.rhandler.ServeRead(rsp, req)
-			}
-			v = rsp.bytes()
-		}
-		if uuidLen == -1 {
-			uuidLen = len(v)
-			w.WriteByteFit(byte(uuidLen) + 2)
-		}
-		if len(v) != uuidLen {
-			break
-		}
-		w.Chunk()
-		w.WriteUint16Fit(a.h)
-		w.WriteFit(v)
-		if ok := w.Commit(); !ok {
-			break
-		}
-	}
-	if uuidLen == -1 {
-		return attErrorRsp(attOpReadByTypeReq, start, attEcodeAttrNotFound)
-	}
-	return w.Bytes()
-}
-
-// REQ: ReadReq(0x0A), Handle
-// RSP: ReadRsp(0x0B), Value
-func (c *central) handleRead(b []byte) []byte {
-	h := binary.LittleEndian.Uint16(b)
-	a, ok := c.attrs.At(h)
-	if !ok {
-		return attErrorRsp(attOpReadReq, h, attEcodeInvalidHandle)
-	}
-	if a.props&CharRead == 0 {
-		return attErrorRsp(attOpReadReq, h, attEcodeReadNotPerm)
-	}
-	if a.secure&CharRead != 0 && c.security > securityLow {
-		return attErrorRsp(attOpReadReq, h, attEcodeAuthentication)
-	}
-	v := a.value
-	if v == nil {
-		req := &ReadRequest{
-			Request: Request{Central: c},
-			Cap:     int(c.mtu - 1),
-			Offset:  0,
-		}
-		rsp := newResponseWriter(int(c.mtu - 1))
-		if c, ok := a.pvt.(*Characteristic); ok {
-			c.rhandler.ServeRead(rsp, req)
-		} else if d, ok := a.pvt.(*Descriptor); ok {
-			d.rhandler.ServeRead(rsp, req)
-		}
-		v = rsp.bytes()
-	}
-
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpReadRsp)
-	w.Chunk()
-	w.WriteFit(v)
-	w.CommitFit()
-	return w.Bytes()
-}
-
-// FIXME: check this, untested, might be broken
-func (c *central) handleReadBlob(b []byte) []byte {
-	h := binary.LittleEndian.Uint16(b)
-	offset := binary.LittleEndian.Uint16(b[2:])
-	a, ok := c.attrs.At(h)
-	if !ok {
-		return attErrorRsp(attOpReadBlobReq, h, attEcodeInvalidHandle)
-	}
-	if a.props&CharRead == 0 {
-		return attErrorRsp(attOpReadBlobReq, h, attEcodeReadNotPerm)
-	}
-	if a.secure&CharRead != 0 && c.security > securityLow {
-		return attErrorRsp(attOpReadBlobReq, h, attEcodeAuthentication)
-	}
-	v := a.value
-	if v == nil {
-		req := &ReadRequest{
-			Request: Request{Central: c},
-			Cap:     int(c.mtu - 1),
-			Offset:  int(offset),
-		}
-		rsp := newResponseWriter(int(c.mtu - 1))
-		if c, ok := a.pvt.(*Characteristic); ok {
-			c.rhandler.ServeRead(rsp, req)
-		} else if d, ok := a.pvt.(*Descriptor); ok {
-			d.rhandler.ServeRead(rsp, req)
-		}
-		v = rsp.bytes()
-		offset = 0 // the server has already adjusted for the offset
-	}
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpReadBlobRsp)
-	w.Chunk()
-	w.WriteFit(v)
-	if ok := w.ChunkSeek(offset); !ok {
-		return attErrorRsp(attOpReadBlobReq, h, attEcodeInvalidOffset)
-	}
-	w.CommitFit()
-	return w.Bytes()
-}
-
-func (c *central) handleReadByGroup(b []byte) []byte {
-	start, end := readHandleRange(b)
-	t := UUID{b[4:]}
-
-	// Only support the ATT ReadByGroupReq for GATT Primary Service Discovery.
-	// More specifically, the "Discover All Primary Services" sub-procedure.
-	if !t.Equal(attrPrimaryServiceUUID) {
-		return attErrorRsp(attOpReadByGroupReq, start, attEcodeUnsuppGrpType)
-	}
-
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpReadByGroupRsp)
-	uuidLen := -1
-	for _, a := range c.attrs.Subrange(start, end) {
-		if !a.typ.Equal(attrPrimaryServiceUUID) {
-			continue
-		}
-		if uuidLen == -1 {
-			uuidLen = len(a.value)
-			w.WriteByteFit(byte(uuidLen + 4))
-		}
-		if uuidLen != len(a.value) {
-			break
-		}
-		s := a.pvt.(*Service)
-		w.Chunk()
-		w.WriteUint16Fit(s.h)
-		w.WriteUint16Fit(s.endh)
-		w.WriteFit(a.value)
-		if ok := w.Commit(); !ok {
-			break
-		}
-	}
-	if uuidLen == -1 {
-		return attErrorRsp(attOpReadByGroupReq, start, attEcodeAttrNotFound)
-	}
-	return w.Bytes()
-}
-
-func (c *central) handleWrite(reqType byte, b []byte) []byte {
-	h := binary.LittleEndian.Uint16(b[:2])
-	value := b[2:]
-
-	a, ok := c.attrs.At(h)
-	if !ok {
-		return attErrorRsp(reqType, h, attEcodeInvalidHandle)
-	}
-
-	noRsp := reqType == attOpWriteCmd
-	charFlag := CharWrite
-	if noRsp {
-		charFlag = CharWriteNR
-	}
-	if a.props&charFlag == 0 {
-		return attErrorRsp(reqType, h, attEcodeWriteNotPerm)
-	}
-	if a.secure&charFlag == 0 && c.security > securityLow {
-		return attErrorRsp(reqType, h, attEcodeAuthentication)
-	}
-
-	// Props of Service and Characteristic declration are read only.
-	// So we only need deal with writable descriptors here.
-	// (Characteristic's value is implemented with descriptor)
-	if !a.typ.Equal(attrClientCharacteristicConfigUUID) {
-		// Regular write, not CCC
-		r := Request{Central: c}
-		if c, ok := a.pvt.(*Characteristic); ok {
-			c.whandler.ServeWrite(r, value)
-		} else if d, ok := a.pvt.(*Characteristic); ok {
-			d.whandler.ServeWrite(r, value)
-		}
-		if noRsp {
-			return nil
-		} else {
-			return []byte{attOpWriteRsp}
-		}
-	}
-
-	// CCC/descriptor write
-	if len(value) != 2 {
-		return attErrorRsp(reqType, h, attEcodeInvalAttrValueLen)
-	}
-	ccc := binary.LittleEndian.Uint16(value)
-	// char := a.pvt.(*Descriptor).char
-	if ccc&(gattCCCNotifyFlag|gattCCCIndicateFlag) != 0 {
-		c.startNotify(&a, int(c.mtu-3))
-	} else {
-		c.stopNotify(&a)
-	}
-	if noRsp {
-		return nil
-	}
-	return []byte{attOpWriteRsp}
-}
-
-func (c *central) sendNotification(a *attr, data []byte) (int, error) {
-	w := newL2capWriter(c.mtu)
-	w.WriteByteFit(attOpHandleNotify)
-	w.WriteUint16Fit(a.pvt.(*Descriptor).char.vh)
-	w.WriteFit(data)
-	return c.l2conn.Write(w.Bytes())
-}
-
-func readHandleRange(b []byte) (start, end uint16) {
-	return binary.LittleEndian.Uint16(b), binary.LittleEndian.Uint16(b[2:])
-}
-
-func (c *central) startNotify(a *attr, maxlen int) {
-	c.notifiersmu.Lock()
-	defer c.notifiersmu.Unlock()
-	if _, found := c.notifiers[a.h]; found {
-		return
-	}
-	char := a.pvt.(*Descriptor).char
-	n := newNotifier(c, a, maxlen)
-	c.notifiers[a.h] = n
-	go char.nhandler.ServeNotify(Request{Central: c}, n)
-}
-
-func (c *central) stopNotify(a *attr) {
-	c.notifiersmu.Lock()
-	defer c.notifiersmu.Unlock()
-	// char := a.pvt.(*Characteristic)
-	if n, found := c.notifiers[a.h]; found {
-		n.stop()
-		delete(c.notifiers, a.h)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/common.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/common.go b/newtmgr/vendor/github.com/runtimeinc/gatt/common.go
deleted file mode 100644
index 4fa2389..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/common.go
+++ /dev/null
@@ -1,399 +0,0 @@
-package gatt
-
-// Supported statuses for GATT characteristic read/write operations.
-// These correspond to att constants in the BLE spec
-const (
-	StatusSuccess         = 0
-	StatusInvalidOffset   = 1
-	StatusUnexpectedError = 2
-)
-
-// A Request is the context for a request from a connected central device.
-// TODO: Replace this with more general context, such as:
-// http://godoc.org/golang.org/x/net/context
-type Request struct {
-	Central Central
-}
-
-// A ReadRequest is a characteristic read request from a connected device.
-type ReadRequest struct {
-	Request
-	Cap    int // maximum allowed reply length
-	Offset int // request value offset
-}
-
-type Property int
-
-// Characteristic property flags (spec 3.3.3.1)
-const (
-	CharBroadcast   Property = 0x01 // may be brocasted
-	CharRead        Property = 0x02 // may be read
-	CharWriteNR     Property = 0x04 // may be written to, with no reply
-	CharWrite       Property = 0x08 // may be written to, with a reply
-	CharNotify      Property = 0x10 // supports notifications
-	CharIndicate    Property = 0x20 // supports Indications
-	CharSignedWrite Property = 0x40 // supports signed write
-	CharExtended    Property = 0x80 // supports extended properties
-)
-
-func (p Property) String() (result string) {
-	if (p & CharBroadcast) != 0 {
-		result += "broadcast "
-	}
-	if (p & CharRead) != 0 {
-		result += "read "
-	}
-	if (p & CharWriteNR) != 0 {
-		result += "writeWithoutResponse "
-	}
-	if (p & CharWrite) != 0 {
-		result += "write "
-	}
-	if (p & CharNotify) != 0 {
-		result += "notify "
-	}
-	if (p & CharIndicate) != 0 {
-		result += "indicate "
-	}
-	if (p & CharSignedWrite) != 0 {
-		result += "authenticateSignedWrites "
-	}
-	if (p & CharExtended) != 0 {
-		result += "extendedProperties "
-	}
-	return
-}
-
-// A Service is a BLE service.
-type Service struct {
-	uuid  UUID
-	chars []*Characteristic
-
-	h    uint16
-	endh uint16
-}
-
-// NewService creates and initialize a new Service using u as it's UUID.
-func NewService(u UUID) *Service {
-	return &Service{uuid: u}
-}
-
-// AddCharacteristic adds a characteristic to a service.
-// AddCharacteristic panics if the service already contains another
-// characteristic with the same UUID.
-func (s *Service) AddCharacteristic(u UUID) *Characteristic {
-	for _, c := range s.chars {
-		if c.uuid.Equal(u) {
-			panic("service already contains a characteristic with uuid " + u.String())
-		}
-	}
-	c := &Characteristic{uuid: u, svc: s}
-	s.chars = append(s.chars, c)
-	return c
-}
-
-// UUID returns the UUID of the service.
-func (s *Service) UUID() UUID { return s.uuid }
-
-// Name returns the specificatin name of the service according to its UUID.
-// If the UUID is not assigne, Name returns an empty string.
-func (s *Service) Name() string {
-	return knownServices[s.uuid.String()].Name
-}
-
-// Handle returns the Handle of the service.
-func (s *Service) Handle() uint16 { return s.h }
-
-// EndHandle returns the End Handle of the service.
-func (s *Service) EndHandle() uint16 { return s.endh }
-
-// SetHandle sets the Handle of the service.
-func (s *Service) SetHandle(h uint16) { s.h = h }
-
-// SetEndHandle sets the End Handle of the service.
-func (s *Service) SetEndHandle(endh uint16) { s.endh = endh }
-
-// SetCharacteristics sets the Characteristics of the service.
-func (s *Service) SetCharacteristics(chars []*Characteristic) { s.chars = chars }
-
-// Characteristic returns the contained characteristic of this service.
-func (s *Service) Characteristics() []*Characteristic { return s.chars }
-
-// A Characteristic is a BLE characteristic.
-type Characteristic struct {
-	uuid   UUID
-	props  Property // enabled properties
-	secure Property // security enabled properties
-	svc    *Service
-	cccd   *Descriptor
-	descs  []*Descriptor
-
-	value []byte
-
-	// All the following fields are only used in peripheral/server implementation.
-	rhandler ReadHandler
-	whandler WriteHandler
-	nhandler NotifyHandler
-
-	h    uint16
-	vh   uint16
-	endh uint16
-}
-
-// NewCharacteristic creates and returns a Characteristic.
-func NewCharacteristic(u UUID, s *Service, props Property, h uint16, vh uint16) *Characteristic {
-	c := &Characteristic{
-		uuid:  u,
-		svc:   s,
-		props: props,
-		h:     h,
-		vh:    vh,
-	}
-
-	return c
-}
-
-// Handle returns the Handle of the characteristic.
-func (c *Characteristic) Handle() uint16 { return c.h }
-
-// VHandle returns the Value Handle of the characteristic.
-func (c *Characteristic) VHandle() uint16 { return c.vh }
-
-// EndHandle returns the End Handle of the characteristic.
-func (c *Characteristic) EndHandle() uint16 { return c.endh }
-
-// Descriptor returns the Descriptor of the characteristic.
-func (c *Characteristic) Descriptor() *Descriptor { return c.cccd }
-
-// SetHandle sets the Handle of the characteristic.
-func (c *Characteristic) SetHandle(h uint16) { c.h = h }
-
-// SetVHandle sets the Value Handle of the characteristic.
-func (c *Characteristic) SetVHandle(vh uint16) { c.vh = vh }
-
-// SetEndHandle sets the End Handle of the characteristic.
-func (c *Characteristic) SetEndHandle(endh uint16) { c.endh = endh }
-
-// SetDescriptor sets the Descriptor of the characteristic.
-func (c *Characteristic) SetDescriptor(cccd *Descriptor) { c.cccd = cccd }
-
-// SetDescriptors sets the list of Descriptor of the characteristic.
-func (c *Characteristic) SetDescriptors(descs []*Descriptor) { c.descs = descs }
-
-// UUID returns the UUID of the characteristic.
-func (c *Characteristic) UUID() UUID {
-	return c.uuid
-}
-
-// Name returns the specificatin name of the characteristic.
-// If the UUID is not assigned, Name returns empty string.
-func (c *Characteristic) Name() string {
-	return knownCharacteristics[c.uuid.String()].Name
-}
-
-// Service returns the containing service of this characteristic.
-func (c *Characteristic) Service() *Service {
-	return c.svc
-}
-
-// Properties returns the properties of this characteristic.
-func (c *Characteristic) Properties() Property {
-	return c.props
-}
-
-// Descriptors returns the contained descriptors of this characteristic.
-func (c *Characteristic) Descriptors() []*Descriptor {
-	return c.descs
-}
-
-// AddDescriptor adds a descriptor to a characteristic.
-// AddDescriptor panics if the characteristic already contains another
-// descriptor with the same UUID.
-func (c *Characteristic) AddDescriptor(u UUID) *Descriptor {
-	for _, d := range c.descs {
-		if d.uuid.Equal(u) {
-			panic("service already contains a characteristic with uuid " + u.String())
-		}
-	}
-	d := &Descriptor{uuid: u, char: c}
-	c.descs = append(c.descs, d)
-	return d
-}
-
-// SetValue makes the characteristic support read requests, and returns a
-// static value. SetValue must be called before the containing service is
-// added to a server.
-// SetValue panics if the characteristic has been configured with a ReadHandler.
-func (c *Characteristic) SetValue(b []byte) {
-	if c.rhandler != nil {
-		panic("charactristic has been configured with a read handler")
-	}
-	c.props |= CharRead
-	// c.secure |= CharRead
-	c.value = make([]byte, len(b))
-	copy(c.value, b)
-}
-
-// HandleRead makes the characteristic support read requests, and routes read
-// requests to h. HandleRead must be called before the containing service is
-// added to a server.
-// HandleRead panics if the characteristic has been configured with a static value.
-func (c *Characteristic) HandleRead(h ReadHandler) {
-	if c.value != nil {
-		panic("charactristic has been configured with a static value")
-	}
-	c.props |= CharRead
-	// c.secure |= CharRead
-	c.rhandler = h
-}
-
-// HandleReadFunc calls HandleRead(ReadHandlerFunc(f)).
-func (c *Characteristic) HandleReadFunc(f func(rsp ResponseWriter, req *ReadRequest)) {
-	c.HandleRead(ReadHandlerFunc(f))
-}
-
-// HandleWrite makes the characteristic support write and write-no-response
-// requests, and routes write requests to h.
-// The WriteHandler does not differentiate between write and write-no-response
-// requests; it is handled automatically.
-// HandleWrite must be called before the containing service is added to a server.
-func (c *Characteristic) HandleWrite(h WriteHandler) {
-	c.props |= CharWrite | CharWriteNR
-	// c.secure |= CharWrite | CharWriteNR
-	c.whandler = h
-}
-
-// HandleWriteFunc calls HandleWrite(WriteHandlerFunc(f)).
-func (c *Characteristic) HandleWriteFunc(f func(r Request, data []byte) (status byte)) {
-	c.HandleWrite(WriteHandlerFunc(f))
-}
-
-// HandleNotify makes the characteristic support notify requests, and routes
-// notification requests to h. HandleNotify must be called before the
-// containing service is added to a server.
-func (c *Characteristic) HandleNotify(h NotifyHandler) {
-	if c.cccd != nil {
-		return
-	}
-	p := CharNotify | CharIndicate
-	c.props |= p
-	c.nhandler = h
-
-	// add ccc (client characteristic configuration) descriptor
-	secure := Property(0)
-	// If the characteristic requested secure notifications,
-	// then set ccc security to r/w.
-	if c.secure&p != 0 {
-		secure = CharRead | CharWrite
-	}
-	cd := &Descriptor{
-		uuid:   attrClientCharacteristicConfigUUID,
-		props:  CharRead | CharWrite | CharWriteNR,
-		secure: secure,
-		// FIXME: currently, we always return 0, which is inaccurate.
-		// Each connection should have it's own copy of this value.
-		value: []byte{0x00, 0x00},
-		char:  c,
-	}
-	c.cccd = cd
-	c.descs = append(c.descs, cd)
-}
-
-// HandleNotifyFunc calls HandleNotify(NotifyHandlerFunc(f)).
-func (c *Characteristic) HandleNotifyFunc(f func(r Request, n Notifier)) {
-	c.HandleNotify(NotifyHandlerFunc(f))
-}
-
-// TODO
-// func (c *Characteristic) SubscribedCentrals() []Central{
-// }
-
-// Descriptor is a BLE descriptor
-type Descriptor struct {
-	uuid   UUID
-	char   *Characteristic
-	props  Property // enabled properties
-	secure Property // security enabled properties
-
-	h     uint16
-	value []byte
-
-	rhandler ReadHandler
-	whandler WriteHandler
-}
-
-// Handle returns the Handle of the descriptor.
-func (d *Descriptor) Handle() uint16 { return d.h }
-
-// SetHandle sets the Handle of the descriptor.
-func (d *Descriptor) SetHandle(h uint16) { d.h = h }
-
-// NewDescriptor creates and returns a Descriptor.
-func NewDescriptor(u UUID, h uint16, char *Characteristic) *Descriptor {
-	cd := &Descriptor{
-		uuid: u,
-		h:    h,
-		char: char,
-	}
-	return cd
-}
-
-// UUID returns the UUID of the descriptor.
-func (d *Descriptor) UUID() UUID {
-	return d.uuid
-}
-
-// Name returns the specificatin name of the descriptor.
-// If the UUID is not assigned, returns an empty string.
-func (d *Descriptor) Name() string {
-	return knownDescriptors[d.uuid.String()].Name
-}
-
-// Characteristic returns the containing characteristic of the descriptor.
-func (d *Descriptor) Characteristic() *Characteristic {
-	return d.char
-}
-
-// SetValue makes the descriptor support read requests, and returns a static value.
-// SetValue must be called before the containing service is added to a server.
-// SetValue panics if the descriptor has already configured with a ReadHandler.
-func (d *Descriptor) SetValue(b []byte) {
-	if d.rhandler != nil {
-		panic("descriptor has been configured with a read handler")
-	}
-	d.props |= CharRead
-	// d.secure |= CharRead
-	d.value = make([]byte, len(b))
-	copy(d.value, b)
-}
-
-// HandleRead makes the descriptor support read requests, and routes read requests to h.
-// HandleRead must be called before the containing service is added to a server.
-// HandleRead panics if the descriptor has been configured with a static value.
-func (d *Descriptor) HandleRead(h ReadHandler) {
-	if d.value != nil {
-		panic("descriptor has been configured with a static value")
-	}
-	d.props |= CharRead
-	// d.secure |= CharRead
-	d.rhandler = h
-}
-
-// HandleReadFunc calls HandleRead(ReadHandlerFunc(f)).
-func (d *Descriptor) HandleReadFunc(f func(rsp ResponseWriter, req *ReadRequest)) {
-	d.HandleRead(ReadHandlerFunc(f))
-}
-
-// HandleWrite makes the descriptor support write and write-no-response requests, and routes write requests to h.
-// The WriteHandler does not differentiate between write and write-no-response requests; it is handled automatically.
-// HandleWrite must be called before the containing service is added to a server.
-func (d *Descriptor) HandleWrite(h WriteHandler) {
-	d.props |= CharWrite | CharWriteNR
-	// d.secure |= CharWrite | CharWriteNR
-	d.whandler = h
-}
-
-// HandleWriteFunc calls HandleWrite(WriteHandlerFunc(f)).
-func (d *Descriptor) HandleWriteFunc(f func(r Request, data []byte) (status byte)) {
-	d.HandleWrite(WriteHandlerFunc(f))
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/const.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/const.go b/newtmgr/vendor/github.com/runtimeinc/gatt/const.go
deleted file mode 100644
index 4a04b04..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/const.go
+++ /dev/null
@@ -1,153 +0,0 @@
-package gatt
-
-// This file includes constants from the BLE spec.
-
-var (
-	attrGAPUUID  = UUID16(0x1800)
-	attrGATTUUID = UUID16(0x1801)
-
-	attrPrimaryServiceUUID   = UUID16(0x2800)
-	attrSecondaryServiceUUID = UUID16(0x2801)
-	attrIncludeUUID          = UUID16(0x2802)
-	attrCharacteristicUUID   = UUID16(0x2803)
-
-	attrClientCharacteristicConfigUUID = UUID16(0x2902)
-	attrServerCharacteristicConfigUUID = UUID16(0x2903)
-
-	attrDeviceNameUUID        = UUID16(0x2A00)
-	attrAppearanceUUID        = UUID16(0x2A01)
-	attrPeripheralPrivacyUUID = UUID16(0x2A02)
-	attrReconnectionAddrUUID  = UUID16(0x2A03)
-	attrPeferredParamsUUID    = UUID16(0x2A04)
-	attrServiceChangedUUID    = UUID16(0x2A05)
-)
-
-const (
-	gattCCCNotifyFlag   = 0x0001
-	gattCCCIndicateFlag = 0x0002
-)
-
-const (
-	attOpError              = 0x01
-	attOpMtuReq             = 0x02
-	attOpMtuRsp             = 0x03
-	attOpFindInfoReq        = 0x04
-	attOpFindInfoRsp        = 0x05
-	attOpFindByTypeValueReq = 0x06
-	attOpFindByTypeValueRsp = 0x07
-	attOpReadByTypeReq      = 0x08
-	attOpReadByTypeRsp      = 0x09
-	attOpReadReq            = 0x0a
-	attOpReadRsp            = 0x0b
-	attOpReadBlobReq        = 0x0c
-	attOpReadBlobRsp        = 0x0d
-	attOpReadMultiReq       = 0x0e
-	attOpReadMultiRsp       = 0x0f
-	attOpReadByGroupReq     = 0x10
-	attOpReadByGroupRsp     = 0x11
-	attOpWriteReq           = 0x12
-	attOpWriteRsp           = 0x13
-	attOpWriteCmd           = 0x52
-	attOpPrepWriteReq       = 0x16
-	attOpPrepWriteRsp       = 0x17
-	attOpExecWriteReq       = 0x18
-	attOpExecWriteRsp       = 0x19
-	attOpHandleNotify       = 0x1b
-	attOpHandleInd          = 0x1d
-	attOpHandleCnf          = 0x1e
-	attOpSignedWriteCmd     = 0xd2
-)
-
-type attEcode byte
-
-const (
-	attEcodeSuccess           attEcode = 0x00 // Success
-	attEcodeInvalidHandle     attEcode = 0x01 // The attribute handle given was not valid on this server.
-	attEcodeReadNotPerm       attEcode = 0x02 // The attribute cannot be read.
-	attEcodeWriteNotPerm      attEcode = 0x03 // The attribute cannot be written.
-	attEcodeInvalidPDU        attEcode = 0x04 // The attribute PDU was invalid.
-	attEcodeAuthentication    attEcode = 0x05 // The attribute requires authentication before it can be read or written.
-	attEcodeReqNotSupp        attEcode = 0x06 // Attribute server does not support the request received from the client.
-	attEcodeInvalidOffset     attEcode = 0x07 // Offset specified was past the end of the attribute.
-	attEcodeAuthorization     attEcode = 0x08 // The attribute requires authorization before it can be read or written.
-	attEcodePrepQueueFull     attEcode = 0x09 // Too many prepare writes have been queued.
-	attEcodeAttrNotFound      attEcode = 0x0a // No attribute found within the given attribute handle range.
-	attEcodeAttrNotLong       attEcode = 0x0b // The attribute cannot be read or written using the Read Blob Request.
-	attEcodeInsuffEncrKeySize attEcode = 0x0c // The Encryption Key Size used for encrypting this link is insufficient.
-	attEcodeInvalAttrValueLen attEcode = 0x0d // The attribute value length is invalid for the operation.
-	attEcodeUnlikely          attEcode = 0x0e // The attribute request that was requested has encountered an error that was unlikely, and therefore could not be completed as requested.
-	attEcodeInsuffEnc         attEcode = 0x0f // The attribute requires encryption before it can be read or written.
-	attEcodeUnsuppGrpType     attEcode = 0x10 // The attribute type is not a supported grouping attribute as defined by a higher layer specification.
-	attEcodeInsuffResources   attEcode = 0x11 // Insufficient Resources to complete the request.
-)
-
-func (a attEcode) Error() string {
-	switch i := int(a); {
-	case i < 0x11:
-		return attEcodeName[a]
-	case i >= 0x12 && i <= 0x7F: // Reserved for future use
-		return "reserved error code"
-	case i >= 0x80 && i <= 0x9F: // Application Error, defined by higher level
-		return "reserved error code"
-	case i >= 0xA0 && i <= 0xDF: // Reserved for future use
-		return "reserved error code"
-	case i >= 0xE0 && i <= 0xFF: // Common profile and service error codes
-		return "profile or service error"
-	default: // can't happen, just make compiler happy
-		return "unkown error"
-	}
-}
-
-var attEcodeName = map[attEcode]string{
-	attEcodeSuccess:           "success",
-	attEcodeInvalidHandle:     "invalid handle",
-	attEcodeReadNotPerm:       "read not permitted",
-	attEcodeWriteNotPerm:      "write not permitted",
-	attEcodeInvalidPDU:        "invalid PDU",
-	attEcodeAuthentication:    "insufficient authentication",
-	attEcodeReqNotSupp:        "request not supported",
-	attEcodeInvalidOffset:     "invalid offset",
-	attEcodeAuthorization:     "insufficient authorization",
-	attEcodePrepQueueFull:     "prepare queue full",
-	attEcodeAttrNotFound:      "attribute not found",
-	attEcodeAttrNotLong:       "attribute not long",
-	attEcodeInsuffEncrKeySize: "insufficient encryption key size",
-	attEcodeInvalAttrValueLen: "invalid attribute value length",
-	attEcodeUnlikely:          "unlikely error",
-	attEcodeInsuffEnc:         "insufficient encryption",
-	attEcodeUnsuppGrpType:     "unsupported group type",
-	attEcodeInsuffResources:   "insufficient resources",
-}
-
-func attErrorRsp(op byte, h uint16, s attEcode) []byte {
-	return attErr{opcode: op, attr: h, status: s}.Marshal()
-}
-
-// attRspFor maps from att request
-// codes to att response codes.
-var attRspFor = map[byte]byte{
-	attOpMtuReq:             attOpMtuRsp,
-	attOpFindInfoReq:        attOpFindInfoRsp,
-	attOpFindByTypeValueReq: attOpFindByTypeValueRsp,
-	attOpReadByTypeReq:      attOpReadByTypeRsp,
-	attOpReadReq:            attOpReadRsp,
-	attOpReadBlobReq:        attOpReadBlobRsp,
-	attOpReadMultiReq:       attOpReadMultiRsp,
-	attOpReadByGroupReq:     attOpReadByGroupRsp,
-	attOpWriteReq:           attOpWriteRsp,
-	attOpPrepWriteReq:       attOpPrepWriteRsp,
-	attOpExecWriteReq:       attOpExecWriteRsp,
-}
-
-type attErr struct {
-	opcode uint8
-	attr   uint16
-	status attEcode
-}
-
-// TODO: Reformulate in a way that lets the caller avoid allocs.
-// Accept a []byte? Write directly to an io.Writer?
-func (e attErr) Marshal() []byte {
-	// little-endian encoding for attr
-	return []byte{attOpError, e.opcode, byte(e.attr), byte(e.attr >> 8), byte(e.status)}
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/device.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/device.go b/newtmgr/vendor/github.com/runtimeinc/gatt/device.go
deleted file mode 100644
index eba96cf..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/device.go
+++ /dev/null
@@ -1,161 +0,0 @@
-package gatt
-
-import "errors"
-
-var notImplemented = errors.New("not implemented")
-
-type State int
-
-const (
-	StateUnknown      State = 0
-	StateResetting    State = 1
-	StateUnsupported  State = 2
-	StateUnauthorized State = 3
-	StatePoweredOff   State = 4
-	StatePoweredOn    State = 5
-)
-
-func (s State) String() string {
-	str := []string{
-		"Unknown",
-		"Resetting",
-		"Unsupported",
-		"Unauthorized",
-		"PoweredOff",
-		"PoweredOn",
-	}
-	return str[int(s)]
-}
-
-// Device defines the interface for a BLE device.
-// Since an interface can't define fields(properties). To implement the
-// callback support for cerntain events, deviceHandler is defined and
-// implementation of Device on different platforms should embed it in
-// order to keep have keep compatible in API level.
-// Package users can use the Handler to set these handlers.
-type Device interface {
-	Init(stateChanged func(Device, State)) error
-
-	// Advertise advertise AdvPacket
-	Advertise(a *AdvPacket) error
-
-	// AdvertiseNameAndServices advertises device name, and specified service UUIDs.
-	// It tres to fit the UUIDs in the advertising packet as much as possible.
-	// If name doesn't fit in the advertising packet, it will be put in scan response.
-	AdvertiseNameAndServices(name string, ss []UUID) error
-
-	// AdvertiseIBeaconData advertise iBeacon with given manufacturer data.
-	AdvertiseIBeaconData(b []byte) error
-
-	// AdvertisingIbeacon advertises iBeacon with specified parameters.
-	AdvertiseIBeacon(u UUID, major, minor uint16, pwr int8) error
-
-	// StopAdvertising stops advertising.
-	StopAdvertising() error
-
-	// RemoveAllServices removes all services that are currently in the database.
-	RemoveAllServices() error
-
-	// Add Service add a service to database.
-	AddService(s *Service) error
-
-	// SetServices set the specified service to the database.
-	// It removes all currently added services, if any.
-	SetServices(ss []*Service) error
-
-	// Scan discovers surounding remote peripherals that have the Service UUID specified in ss.
-	// If ss is set to nil, all devices scanned are reported.
-	// dup specifies weather duplicated advertisement should be reported or not.
-	// When a remote peripheral is discovered, the PeripheralDiscovered Handler is called.
-	Scan(ss []UUID, dup bool)
-
-	// StopScanning stops scanning.
-	StopScanning()
-
-	// Connect connects to a remote peripheral.
-	Connect(p Peripheral)
-
-	// CancelConnection disconnects a remote peripheral.
-	CancelConnection(p Peripheral)
-
-	// Handle registers the specified handlers.
-	Handle(h ...Handler)
-
-	// Stop HCI Connection
-        Stop() error
-
-	// Option sets the options specified.
-	Option(o ...Option) error
-}
-
-// deviceHandler is the handlers(callbacks) of the Device.
-type deviceHandler struct {
-	// stateChanged is called when the device states changes.
-	stateChanged func(d Device, s State)
-
-	// connect is called when a remote central device connects to the device.
-	centralConnected func(c Central)
-
-	// disconnect is called when a remote central device disconnects to the device.
-	centralDisconnected func(c Central)
-
-	// peripheralDiscovered is called when a remote peripheral device is found during scan procedure.
-	peripheralDiscovered func(p Peripheral, a *Advertisement, rssi int)
-
-	// peripheralConnected is called when a remote peripheral is conneted.
-	peripheralConnected func(p Peripheral, err error)
-
-	// peripheralConnected is called when a remote peripheral is disconneted.
-	peripheralDisconnected func(p Peripheral, err error)
-}
-
-// A Handler is a self-referential function, which registers the options specified.
-// See http://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html for more discussion.
-type Handler func(Device)
-
-// Handle registers the specified handlers.
-func (d *device) Handle(hh ...Handler) {
-	for _, h := range hh {
-		h(d)
-	}
-}
-
-// CentralConnected returns a Handler, which sets the specified function to be called when a device connects to the server.
-func CentralConnected(f func(Central)) Handler {
-	return func(d Device) { d.(*device).centralConnected = f }
-}
-
-// CentralDisconnected returns a Handler, which sets the specified function to be called when a device disconnects from the server.
-func CentralDisconnected(f func(Central)) Handler {
-	return func(d Device) { d.(*device).centralDisconnected = f }
-}
-
-// PeripheralDiscovered returns a Handler, which sets the specified function to be called when a remote peripheral device is found during scan procedure.
-func PeripheralDiscovered(f func(Peripheral, *Advertisement, int)) Handler {
-	return func(d Device) { d.(*device).peripheralDiscovered = f }
-}
-
-// PeripheralConnected returns a Handler, which sets the specified function to be called when a remote peripheral device connects.
-func PeripheralConnected(f func(Peripheral, error)) Handler {
-	return func(d Device) { d.(*device).peripheralConnected = f }
-}
-
-// PeripheralDisconnected returns a Handler, which sets the specified function to be called when a remote peripheral device disconnects.
-func PeripheralDisconnected(f func(Peripheral, error)) Handler {
-	return func(d Device) { d.(*device).peripheralDisconnected = f }
-}
-
-// An Option is a self-referential function, which sets the option specified.
-// Most Options are platform-specific, which gives more fine-grained control over the device at a cost of losing portibility.
-// See http://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html for more discussion.
-type Option func(Device) error
-
-// Option sets the options specified.
-// Some options can only be set before the device is initialized; they are best used with NewDevice instead of Option.
-func (d *device) Option(opts ...Option) error {
-	var err error
-	for _, opt := range opts {
-		err = opt(d)
-	}
-	return err
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/device_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/device_darwin.go b/newtmgr/vendor/github.com/runtimeinc/gatt/device_darwin.go
deleted file mode 100644
index 5401057..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/device_darwin.go
+++ /dev/null
@@ -1,513 +0,0 @@
-package gatt
-
-import (
-	"bytes"
-	"encoding/binary"
-	"errors"
-	"fmt"
-	"log"
-	"sync"
-	"time"
-
-	"github.com/runtimeinc/gatt/xpc"
-)
-
-const (
-	peripheralDiscovered   = 37
-	peripheralConnected    = 38
-	peripheralDisconnected = 40
-	// below constants for Yosemite
-	rssiRead                   = 55
-	includedServicesDiscovered = 63
-	serviceDiscovered          = 56
-	characteristicsDiscovered  = 64
-	characteristicRead         = 71
-	characteristicWritten      = 72
-	notificationValueSet       = 74
-	descriptorsDiscovered      = 76
-	descriptorRead             = 79
-	descriptorWritten          = 80
-)
-
-type device struct {
-	deviceHandler
-
-	conn xpc.XPC
-
-	role int // 1: peripheralManager (server), 0: centralManager (client)
-
-	reqc chan message
-	rspc chan message
-
-	// Only used in client/centralManager implementation
-	plist   map[string]*peripheral
-	plistmu *sync.Mutex
-
-	// Only used in server/peripheralManager implementation
-
-	attrN int
-	attrs map[int]*attr
-
-	subscribers map[string]*central
-}
-
-func NewDevice(opts ...Option) (Device, error) {
-	d := &device{
-		reqc:    make(chan message),
-		rspc:    make(chan message),
-		plist:   map[string]*peripheral{},
-		plistmu: &sync.Mutex{},
-
-		attrN: 1,
-		attrs: make(map[int]*attr),
-
-		subscribers: make(map[string]*central),
-	}
-	d.Option(opts...)
-	d.conn = xpc.XpcConnect("com.apple.blued", d)
-	return d, nil
-}
-
-func (d *device) Init(f func(Device, State)) error {
-	go d.loop()
-	rsp := d.sendReq(1, xpc.Dict{
-		"kCBMsgArgName":    fmt.Sprintf("gopher-%v", time.Now().Unix()),
-		"kCBMsgArgOptions": xpc.Dict{"kCBInitOptionShowPowerAlert": 1},
-		"kCBMsgArgType":    d.role,
-	})
-	d.stateChanged = f
-	go d.stateChanged(d, State(rsp.MustGetInt("kCBMsgArgState")))
-	return nil
-}
-
-func (d *device) Advertise(a *AdvPacket) error {
-	rsp := d.sendReq(8, xpc.Dict{
-		"kCBAdvDataAppleMfgData": a.b, // not a.Bytes(). should be slice
-	})
-
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return errors.New("FIXME: Advertise error")
-	}
-	return nil
-}
-
-func (d *device) AdvertiseNameAndServices(name string, ss []UUID) error {
-	us := uuidSlice(ss)
-	rsp := d.sendReq(8, xpc.Dict{
-		"kCBAdvDataLocalName":    name,
-		"kCBAdvDataServiceUUIDs": us},
-	)
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return errors.New("FIXME: Advertise error")
-	}
-	return nil
-}
-
-func (d *device) AdvertiseIBeaconData(data []byte) error {
-	var utsname xpc.Utsname
-	xpc.Uname(&utsname)
-
-	var rsp xpc.Dict
-
-	if utsname.Release >= "14." {
-		l := len(data)
-		buf := bytes.NewBuffer([]byte{byte(l + 5), 0xFF, 0x4C, 0x00, 0x02, byte(l)})
-		buf.Write(data)
-		rsp = d.sendReq(8, xpc.Dict{"kCBAdvDataAppleMfgData": buf.Bytes()})
-	} else {
-		rsp = d.sendReq(8, xpc.Dict{"kCBAdvDataAppleBeaconKey": data})
-	}
-
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return errors.New("FIXME: Advertise error")
-	}
-
-	return nil
-}
-
-func (d *device) AdvertiseIBeacon(u UUID, major, minor uint16, pwr int8) error {
-	b := make([]byte, 21)
-	copy(b, reverse(u.b))                     // Big endian
-	binary.BigEndian.PutUint16(b[16:], major) // Big endian
-	binary.BigEndian.PutUint16(b[18:], minor) // Big endian
-	b[20] = uint8(pwr)                        // Measured Tx Power
-	return d.AdvertiseIBeaconData(b)
-}
-
-func (d *device) StopAdvertising() error {
-	rsp := d.sendReq(9, nil)
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return errors.New("FIXME: Stop Advertise error")
-	}
-	return nil
-}
-
-func (d *device) RemoveAllServices() error {
-	d.sendCmd(12, nil)
-	return nil
-}
-
-func (d *device) AddService(s *Service) error {
-	if s.uuid.Equal(attrGAPUUID) || s.uuid.Equal(attrGATTUUID) {
-		// skip GATT and GAP services
-		return nil
-	}
-
-	xs := xpc.Dict{
-		"kCBMsgArgAttributeID":     d.attrN,
-		"kCBMsgArgAttributeIDs":    []int{},
-		"kCBMsgArgCharacteristics": nil,
-		"kCBMsgArgType":            1, // 1 => primary, 0 => excluded
-		"kCBMsgArgUUID":            reverse(s.uuid.b),
-	}
-	d.attrN++
-
-	xcs := xpc.Array{}
-	for _, c := range s.Characteristics() {
-		props := 0
-		perm := 0
-		if c.props&CharRead != 0 {
-			props |= 0x02
-			if CharRead&c.secure != 0 {
-				perm |= 0x04
-			} else {
-				perm |= 0x01
-			}
-		}
-		if c.props&CharWriteNR != 0 {
-			props |= 0x04
-			if c.secure&CharWriteNR != 0 {
-				perm |= 0x08
-			} else {
-				perm |= 0x02
-			}
-		}
-		if c.props&CharWrite != 0 {
-			props |= 0x08
-			if c.secure&CharWrite != 0 {
-				perm |= 0x08
-			} else {
-				perm |= 0x02
-			}
-		}
-		if c.props&CharNotify != 0 {
-			if c.secure&CharNotify != 0 {
-				props |= 0x100
-			} else {
-				props |= 0x10
-			}
-		}
-		if c.props&CharIndicate != 0 {
-			if c.secure&CharIndicate != 0 {
-				props |= 0x200
-			} else {
-				props |= 0x20
-			}
-		}
-
-		xc := xpc.Dict{
-			"kCBMsgArgAttributeID":              d.attrN,
-			"kCBMsgArgUUID":                     reverse(c.uuid.b),
-			"kCBMsgArgAttributePermissions":     perm,
-			"kCBMsgArgCharacteristicProperties": props,
-			"kCBMsgArgData":                     c.value,
-		}
-		d.attrs[d.attrN] = &attr{h: uint16(d.attrN), value: c.value, pvt: c}
-		d.attrN++
-
-		xds := xpc.Array{}
-		for _, d := range c.Descriptors() {
-			if d.uuid.Equal(attrClientCharacteristicConfigUUID) {
-				// skip CCCD
-				continue
-			}
-			xd := xpc.Dict{
-				"kCBMsgArgData": d.value,
-				"kCBMsgArgUUID": reverse(d.uuid.b),
-			}
-			xds = append(xds, xd)
-		}
-		xc["kCBMsgArgDescriptors"] = xds
-		xcs = append(xcs, xc)
-	}
-	xs["kCBMsgArgCharacteristics"] = xcs
-
-	rsp := d.sendReq(10, xs)
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return errors.New("FIXME: Add Srvice error")
-	}
-	return nil
-}
-
-func (d *device) SetServices(ss []*Service) error {
-	d.RemoveAllServices()
-	for _, s := range ss {
-		d.AddService(s)
-	}
-	return nil
-}
-
-func (d *device) Scan(ss []UUID, dup bool) {
-	args := xpc.Dict{
-		"kCBMsgArgUUIDs": uuidSlice(ss),
-		"kCBMsgArgOptions": xpc.Dict{
-			"kCBScanOptionAllowDuplicates": map[bool]int{true: 1, false: 0}[dup],
-		},
-	}
-	d.sendCmd(29, args)
-}
-
-func (d *device) StopScanning() {
-	d.sendCmd(30, nil)
-}
-
-func (d *device) Connect(p Peripheral) {
-	pp := p.(*peripheral)
-	d.plist[pp.id.String()] = pp
-	d.sendCmd(31,
-		xpc.Dict{
-			"kCBMsgArgDeviceUUID": pp.id,
-			"kCBMsgArgOptions": xpc.Dict{
-				"kCBConnectOptionNotifyOnDisconnection": 1,
-			},
-		})
-}
-
-func (d *device) respondToRequest(id int, args xpc.Dict) {
-
-	switch id {
-	case 19: // ReadRequest
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		t := args.MustGetInt("kCBMsgArgTransactionID")
-		a := args.MustGetInt("kCBMsgArgAttributeID")
-		o := args.MustGetInt("kCBMsgArgOffset")
-
-		attr := d.attrs[a]
-		v := attr.value
-		if v == nil {
-			c := newCentral(d, u)
-			req := &ReadRequest{
-				Request: Request{Central: c},
-				Cap:     int(c.mtu - 1),
-				Offset:  o,
-			}
-			rsp := newResponseWriter(int(c.mtu - 1))
-			if c, ok := attr.pvt.(*Characteristic); ok {
-				c.rhandler.ServeRead(rsp, req)
-				v = rsp.bytes()
-			}
-		}
-
-		d.sendCmd(13, xpc.Dict{
-			"kCBMsgArgAttributeID":   a,
-			"kCBMsgArgData":          v,
-			"kCBMsgArgTransactionID": t,
-			"kCBMsgArgResult":        0,
-		})
-
-	case 20: // WriteRequest
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		t := args.MustGetInt("kCBMsgArgTransactionID")
-		a := 0
-		noRsp := false
-		xxws := args.MustGetArray("kCBMsgArgATTWrites")
-		for _, xxw := range xxws {
-			xw := xxw.(xpc.Dict)
-			if a == 0 {
-				a = xw.MustGetInt("kCBMsgArgAttributeID")
-			}
-			o := xw.MustGetInt("kCBMsgArgOffset")
-			i := xw.MustGetInt("kCBMsgArgIgnoreResponse")
-			b := xw.MustGetBytes("kCBMsgArgData")
-			_ = o
-			attr := d.attrs[a]
-			c := newCentral(d, u)
-			r := Request{Central: c}
-			attr.pvt.(*Characteristic).whandler.ServeWrite(r, b)
-			if i == 1 {
-				noRsp = true
-			}
-
-		}
-		if noRsp {
-			break
-		}
-		d.sendCmd(13, xpc.Dict{
-			"kCBMsgArgAttributeID":   a,
-			"kCBMsgArgData":          nil,
-			"kCBMsgArgTransactionID": t,
-			"kCBMsgArgResult":        0,
-		})
-
-	case 21: // subscribed
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		a := args.MustGetInt("kCBMsgArgAttributeID")
-		attr := d.attrs[a]
-		c := newCentral(d, u)
-		d.subscribers[u.String()] = c
-		c.startNotify(attr, c.mtu)
-
-	case 22: // unubscribed
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		a := args.MustGetInt("kCBMsgArgAttributeID")
-		attr := d.attrs[a]
-		if c := d.subscribers[u.String()]; c != nil {
-			c.stopNotify(attr)
-		}
-
-	case 23: // notificationSent
-	}
-}
-
-/*
- * OSX GATT library currently doesn't work for Mynewt, so adding this stub to keep
- * it buildable for OSX.
- */
-func (d *device) Stop() error {
-	return nil
-}
-
-func (d *device) CancelConnection(p Peripheral) {
-	d.sendCmd(32, xpc.Dict{"kCBMsgArgDeviceUUID": p.(*peripheral).id})
-}
-
-// process device events and asynchronous errors
-// (implements XpcEventHandler)
-func (d *device) HandleXpcEvent(event xpc.Dict, err error) {
-	if err != nil {
-		log.Println("error:", err)
-		return
-	}
-
-	id := event.MustGetInt("kCBMsgId")
-	args := event.MustGetDict("kCBMsgArgs")
-	//log.Printf(">> %d, %v", id, args)
-
-	switch id {
-	case // device event
-		6,  // StateChanged
-		16, // AdvertisingStarted
-		17, // AdvertisingStopped
-		18: // ServiceAdded
-		d.rspc <- message{id: id, args: args}
-
-	case
-		19, // ReadRequest
-		20, // WriteRequest
-		21, // Subscribe
-		22, // Unubscribe
-		23: // Confirmation
-		d.respondToRequest(id, args)
-
-	case peripheralDiscovered:
-		xa := args.MustGetDict("kCBMsgArgAdvertisementData")
-		if len(xa) == 0 {
-			return
-		}
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		a := &Advertisement{
-			LocalName:        xa.GetString("kCBAdvDataLocalName", args.GetString("kCBMsgArgName", "")),
-			TxPowerLevel:     xa.GetInt("kCBAdvDataTxPowerLevel", 0),
-			ManufacturerData: xa.GetBytes("kCBAdvDataManufacturerData", nil),
-		}
-
-		rssi := args.MustGetInt("kCBMsgArgRssi")
-
-		if xu, ok := xa["kCBAdvDataServiceUUIDs"]; ok {
-			for _, xs := range xu.(xpc.Array) {
-				s := UUID{reverse(xs.([]byte))}
-				a.Services = append(a.Services, s)
-			}
-		}
-		if xsds, ok := xa["kCBAdvDataServiceData"]; ok {
-			xsd := xsds.(xpc.Array)
-			for i := 0; i < len(xsd); i += 2 {
-				sd := ServiceData{
-					UUID: UUID{xsd[i].([]byte)},
-					Data: xsd[i+1].([]byte),
-				}
-				a.ServiceData = append(a.ServiceData, sd)
-			}
-		}
-		if d.peripheralDiscovered != nil {
-			go d.peripheralDiscovered(&peripheral{id: xpc.UUID(u.b), d: d}, a, rssi)
-		}
-
-	case peripheralConnected:
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		p := &peripheral{
-			id:    xpc.UUID(u.b),
-			d:     d,
-			reqc:  make(chan message),
-			rspc:  make(chan message),
-			quitc: make(chan struct{}),
-			sub:   newSubscriber(),
-		}
-		d.plistmu.Lock()
-		d.plist[u.String()] = p
-		d.plistmu.Unlock()
-		go p.loop()
-
-		if d.peripheralConnected != nil {
-			go d.peripheralConnected(p, nil)
-		}
-
-	case peripheralDisconnected:
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		d.plistmu.Lock()
-		p := d.plist[u.String()]
-		delete(d.plist, u.String())
-		d.plistmu.Unlock()
-		if d.peripheralDisconnected != nil {
-			d.peripheralDisconnected(p, nil) // TODO: Get Result as error?
-		}
-		close(p.quitc)
-
-	case // Peripheral events
-		rssiRead,
-		serviceDiscovered,
-		includedServicesDiscovered,
-		characteristicsDiscovered,
-		characteristicRead,
-		characteristicWritten,
-		notificationValueSet,
-		descriptorsDiscovered,
-		descriptorRead,
-		descriptorWritten:
-
-		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
-		d.plistmu.Lock()
-		p := d.plist[u.String()]
-		d.plistmu.Unlock()
-		p.rspc <- message{id: id, args: args}
-
-	default:
-		log.Printf("Unhandled event: %#v", event)
-	}
-}
-
-func (d *device) sendReq(id int, args xpc.Dict) xpc.Dict {
-	m := message{id: id, args: args, rspc: make(chan xpc.Dict)}
-	d.reqc <- m
-	return <-m.rspc
-}
-
-func (d *device) sendCmd(id int, args xpc.Dict) {
-	d.reqc <- message{id: id, args: args}
-}
-
-func (d *device) loop() {
-	for req := range d.reqc {
-		d.sendCBMsg(req.id, req.args)
-		if req.rspc == nil {
-			continue
-		}
-		m := <-d.rspc
-		req.rspc <- m.args
-	}
-}
-
-func (d *device) sendCBMsg(id int, args xpc.Dict) {
-	// log.Printf("<< %d, %v", id, args)
-	d.conn.Send(xpc.Dict{"kCBMsgId": id, "kCBMsgArgs": args}, false)
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/device_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/device_linux.go b/newtmgr/vendor/github.com/runtimeinc/gatt/device_linux.go
deleted file mode 100644
index d723e40..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/device_linux.go
+++ /dev/null
@@ -1,240 +0,0 @@
-package gatt
-
-import (
-	"encoding/binary"
-	"net"
-
-	"github.com/runtimeinc/gatt/linux"
-	"github.com/runtimeinc/gatt/linux/cmd"
-)
-
-type device struct {
-	deviceHandler
-
-	hci   *linux.HCI
-	state State
-
-	// All the following fields are only used peripheralManager (server) implementation.
-	svcs  []*Service
-	attrs *attrRange
-
-	devID   int
-	chkLE   bool
-	maxConn int
-
-	advData   *cmd.LESetAdvertisingData
-	scanResp  *cmd.LESetScanResponseData
-	advParam  *cmd.LESetAdvertisingParameters
-	scanParam *cmd.LESetScanParameters
-}
-
-func NewDevice(opts ...Option) (Device, error) {
-	d := &device{
-		maxConn: 1,    // Support 1 connection at a time.
-		devID:   -1,   // Find an available HCI device.
-		chkLE:   true, // Check if the device supports LE.
-
-		advParam: &cmd.LESetAdvertisingParameters{
-			AdvertisingIntervalMin:  0x800,     // [0x0800]: 0.625 ms * 0x0800 = 1280.0 ms
-			AdvertisingIntervalMax:  0x800,     // [0x0800]: 0.625 ms * 0x0800 = 1280.0 ms
-			AdvertisingType:         0x00,      // [0x00]: ADV_IND, 0x01: DIRECT(HIGH), 0x02: SCAN, 0x03: NONCONN, 0x04: DIRECT(LOW)
-			OwnAddressType:          0x00,      // [0x00]: public, 0x01: random
-			DirectAddressType:       0x00,      // [0x00]: public, 0x01: random
-			DirectAddress:           [6]byte{}, // Public or Random Address of the device to be connected
-			AdvertisingChannelMap:   0x7,       // [0x07] 0x01: ch37, 0x2: ch38, 0x4: ch39
-			AdvertisingFilterPolicy: 0x00,
-		},
-		scanParam: &cmd.LESetScanParameters{
-			LEScanType:           0x01,   // [0x00]: passive, 0x01: active
-			LEScanInterval:       0x0010, // [0x10]: 0.625ms * 16
-			LEScanWindow:         0x0010, // [0x10]: 0.625ms * 16
-			OwnAddressType:       0x00,   // [0x00]: public, 0x01: random
-			ScanningFilterPolicy: 0x00,   // [0x00]: accept all, 0x01: ignore non-white-listed.
-		},
-	}
-
-	d.Option(opts...)
-	h, err := linux.NewHCI(d.devID, d.chkLE, d.maxConn)
-	if err != nil {
-		return nil, err
-	}
-
-	d.hci = h
-	return d, nil
-}
-
-func (d *device) Init(f func(Device, State)) error {
-	d.hci.AcceptMasterHandler = func(pd *linux.PlatData) {
-		a := pd.Address
-		c := newCentral(d.attrs, net.HardwareAddr([]byte{a[5], a[4], a[3], a[2], a[1], a[0]}), pd.Conn)
-		if d.centralConnected != nil {
-			d.centralConnected(c)
-		}
-		c.loop()
-		if d.centralDisconnected != nil {
-			d.centralDisconnected(c)
-		}
-	}
-	d.hci.AcceptSlaveHandler = func(pd *linux.PlatData) {
-		p := &peripheral{
-			d:     d,
-			pd:    pd,
-			l2c:   pd.Conn,
-			reqc:  make(chan message),
-			quitc: make(chan struct{}),
-			sub:   newSubscriber(),
-		}
-		if d.peripheralConnected != nil {
-			go d.peripheralConnected(p, nil)
-		}
-		p.loop()
-		if d.peripheralDisconnected != nil {
-			d.peripheralDisconnected(p, nil)
-		}
-	}
-	d.hci.AdvertisementHandler = func(pd *linux.PlatData) {
-		a := &Advertisement{}
-		a.unmarshall(pd.Data)
-		a.Connectable = pd.Connectable
-	        a.Address = pd.Address
-		a.AddressType = pd.AddressType
-		p := &peripheral{pd: pd, d: d}
-		if d.peripheralDiscovered != nil {
-			pd.Name = a.LocalName
-			d.peripheralDiscovered(p, a, int(pd.RSSI))
-		}
-	}
-	d.state = StatePoweredOn
-	d.stateChanged = f
-	go d.stateChanged(d, d.state)
-	return nil
-}
-
-func (d *device) Stop() error {
-	d.state = StatePoweredOff
-	defer d.stateChanged(d, d.state)
-	return d.hci.Close()
-}
-
-func (d *device) AddService(s *Service) error {
-	d.svcs = append(d.svcs, s)
-	d.attrs = generateAttributes(d.svcs, uint16(1)) // ble attrs start at 1
-	return nil
-}
-
-func (d *device) RemoveAllServices() error {
-	d.svcs = nil
-	d.attrs = nil
-	return nil
-}
-
-func (d *device) SetServices(s []*Service) error {
-	d.RemoveAllServices()
-	d.svcs = append(d.svcs, s...)
-	d.attrs = generateAttributes(d.svcs, uint16(1)) // ble attrs start at 1
-	return nil
-}
-
-func (d *device) Advertise(a *AdvPacket) error {
-	d.advData = &cmd.LESetAdvertisingData{
-		AdvertisingDataLength: uint8(a.Len()),
-		AdvertisingData:       a.Bytes(),
-	}
-
-	if err := d.update(); err != nil {
-		return err
-	}
-
-	return d.hci.SetAdvertiseEnable(true)
-}
-
-func (d *device) AdvertiseNameAndServices(name string, uu []UUID) error {
-	a := &AdvPacket{}
-	a.AppendFlags(flagGeneralDiscoverable | flagLEOnly)
-	a.AppendUUIDFit(uu)
-
-	if len(a.b)+len(name)+2 < MaxEIRPacketLength {
-		a.AppendName(name)
-		d.scanResp = nil
-	} else {
-		a := &AdvPacket{}
-		a.AppendName(name)
-		d.scanResp = &cmd.LESetScanResponseData{
-			ScanResponseDataLength: uint8(a.Len()),
-			ScanResponseData:       a.Bytes(),
-		}
-	}
-
-	return d.Advertise(a)
-}
-
-func (d *device) AdvertiseIBeaconData(b []byte) error {
-	a := &AdvPacket{}
-	a.AppendFlags(flagGeneralDiscoverable | flagLEOnly)
-	a.AppendManufacturerData(0x004C, b)
-	d.advData = &cmd.LESetAdvertisingData{
-		AdvertisingDataLength: uint8(a.Len()),
-		AdvertisingData:       a.Bytes(),
-	}
-
-	return d.Advertise(a)
-}
-
-func (d *device) AdvertiseIBeacon(u UUID, major, minor uint16, pwr int8) error {
-	b := make([]byte, 23)
-	b[0] = 0x02                               // Data type: iBeacon
-	b[1] = 0x15                               // Data length: 21 bytes
-	copy(b[2:], reverse(u.b))                 // Big endian
-	binary.BigEndian.PutUint16(b[18:], major) // Big endian
-	binary.BigEndian.PutUint16(b[20:], minor) // Big endian
-	b[22] = uint8(pwr)                        // Measured Tx Power
-	return d.AdvertiseIBeaconData(b)
-}
-
-func (d *device) StopAdvertising() error {
-	return d.hci.SetAdvertiseEnable(false)
-}
-
-func (d *device) Scan(ss []UUID, dup bool) {
-	// TODO: filter
-	d.hci.SetScanEnable(true, dup)
-}
-
-func (d *device) StopScanning() {
-	d.hci.SetScanEnable(false, true)
-}
-
-func (d *device) Connect(p Peripheral) {
-	d.hci.Connect(p.(*peripheral).pd)
-}
-
-func (d *device) CancelConnection(p Peripheral) {
-	d.hci.CancelConnection(p.(*peripheral).pd)
-}
-
-func (d *device) SendHCIRawCommand(c cmd.CmdParam) ([]byte, error) {
-	return d.hci.SendRawCommand(c)
-}
-
-// Flush pending advertising settings to the device.
-func (d *device) update() error {
-	if d.advParam != nil {
-		if err := d.hci.SendCmdWithAdvOff(d.advParam); err != nil {
-			return err
-		}
-		d.advParam = nil
-	}
-	if d.scanResp != nil {
-		if err := d.hci.SendCmdWithAdvOff(d.scanResp); err != nil {
-			return err
-		}
-		d.scanResp = nil
-	}
-	if d.advData != nil {
-		if err := d.hci.SendCmdWithAdvOff(d.advData); err != nil {
-			return err
-		}
-		d.advData = nil
-	}
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/doc.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/doc.go b/newtmgr/vendor/github.com/runtimeinc/gatt/doc.go
deleted file mode 100644
index c34a3e9..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/doc.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// Package gatt provides a Bluetooth Low Energy gatt implementation.
-//
-// Gatt (Generic Attribute Profile) is the protocol used to write
-// BLE peripherals (servers) and centrals (clients).
-//
-// STATUS
-//
-// This package is a work in progress. The API will change.
-//
-// As a peripheral, you can create services, characteristics, and descriptors,
-// advertise, accept connections, and handle requests.
-// As a central, you can scan, connect, discover services, and make requests.
-//
-// SETUP
-//
-// gatt supports both Linux and OS X.
-//
-// On Linux:
-// To gain complete and exclusive control of the HCI device, gatt uses
-// HCI_CHANNEL_USER (introduced in Linux v3.14) instead of HCI_CHANNEL_RAW.
-// Those who must use an older kernel may patch in these relevant commits
-// from Marcel Holtmann:
-//
-//     Bluetooth: Introduce new HCI socket channel for user operation
-//     Bluetooth: Introduce user channel flag for HCI devices
-//     Bluetooth: Refactor raw socket filter into more readable code
-//
-// Note that because gatt uses HCI_CHANNEL_USER, once gatt has opened the
-// device no other program may access it.
-//
-// Before starting a gatt program, make sure that your BLE device is down:
-//
-//     sudo hciconfig
-//     sudo hciconfig hci0 down  # or whatever hci device you want to use
-//
-// If you have BlueZ 5.14+ (or aren't sure), stop the built-in
-// bluetooth server, which interferes with gatt, e.g.:
-//
-//     sudo service bluetooth stop
-//
-// Because gatt programs administer network devices, they must
-// either be run as root, or be granted appropriate capabilities:
-//
-//     sudo <executable>
-//     # OR
-//     sudo setcap 'cap_net_raw,cap_net_admin=eip' <executable>
-//     <executable>
-//
-// USAGE
-//
-//     # Start a simple server.
-//     sudo go run example/server.go
-//
-//     # Discover surrounding peripherals.
-//     sudo go run example/discoverer.go
-//
-//     # Connect to and explorer a peripheral device.
-//     sudo go run example/explorer.go <peripheral ID>
-//
-// See the server.go, discoverer.go, and explorer.go in the examples/
-// directory for writing server or client programs that run on Linux
-// and OS X.
-//
-// Users, especially on Linux platforms, seeking finer-grained control
-// over the devices can see the examples/server_lnx.go for the usage
-// of Option, which are platform specific.
-//
-// See the rest of the docs for other options and finer-grained control.
-//
-// Note that some BLE central devices, particularly iOS, may aggressively
-// cache results from previous connections. If you change your services or
-// characteristics, you may need to reboot the other device to pick up the
-// changes. This is a common source of confusion and apparent bugs. For an
-// OS X central, see http://stackoverflow.com/questions/20553957.
-//
-//
-// REFERENCES
-//
-// gatt started life as a port of bleno, to which it is indebted:
-// https://github.com/sandeepmistry/bleno. If you are having
-// problems with gatt, particularly around installation, issues
-// filed with bleno might also be helpful references.
-//
-// To try out your GATT server, it is useful to experiment with a
-// generic BLE client. LightBlue is a good choice. It is available
-// free for both iOS and OS X.
-//
-package gatt

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/known_uuid.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/known_uuid.go b/newtmgr/vendor/github.com/runtimeinc/gatt/known_uuid.go
deleted file mode 100644
index 2146af5..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/known_uuid.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package gatt
-
-// A dictionary of known service names and type (keyed by service uuid)
-var knownServices = map[string]struct{ Name, Type string }{
-	"1800": {Name: "Generic Access", Type: "org.bluetooth.service.generic_access"},
-	"1801": {Name: "Generic Attribute", Type: "org.bluetooth.service.generic_attribute"},
-	"1802": {Name: "Immediate Alert", Type: "org.bluetooth.service.immediate_alert"},
-	"1803": {Name: "Link Loss", Type: "org.bluetooth.service.link_loss"},
-	"1804": {Name: "Tx Power", Type: "org.bluetooth.service.tx_power"},
-	"1805": {Name: "Current Time Service", Type: "org.bluetooth.service.current_time"},
-	"1806": {Name: "Reference Time Update Service", Type: "org.bluetooth.service.reference_time_update"},
-	"1807": {Name: "Next DST Change Service", Type: "org.bluetooth.service.next_dst_change"},
-	"1808": {Name: "Glucose", Type: "org.bluetooth.service.glucose"},
-	"1809": {Name: "Health Thermometer", Type: "org.bluetooth.service.health_thermometer"},
-	"180a": {Name: "Device Information", Type: "org.bluetooth.service.device_information"},
-	"180d": {Name: "Heart Rate", Type: "org.bluetooth.service.heart_rate"},
-	"180e": {Name: "Phone Alert Status Service", Type: "org.bluetooth.service.phone_alert_service"},
-	"180f": {Name: "Battery Service", Type: "org.bluetooth.service.battery_service"},
-	"1810": {Name: "Blood Pressure", Type: "org.bluetooth.service.blood_pressuer"},
-	"1811": {Name: "Alert Notification Service", Type: "org.bluetooth.service.alert_notification"},
-	"1812": {Name: "Human Interface Device", Type: "org.bluetooth.service.human_interface_device"},
-	"1813": {Name: "Scan Parameters", Type: "org.bluetooth.service.scan_parameters"},
-	"1814": {Name: "Running Speed and Cadence", Type: "org.bluetooth.service.running_speed_and_cadence"},
-	"1815": {Name: "Cycling Speed and Cadence", Type: "org.bluetooth.service.cycling_speed_and_cadence"},
-}
-
-// A dictionary of known descriptor names and type (keyed by attribute uuid)
-var knownAttributes = map[string]struct{ Name, Type string }{
-	"2800": {Name: "Primary Service", Type: "org.bluetooth.attribute.gatt.primary_service_declaration"},
-	"2801": {Name: "Secondary Service", Type: "org.bluetooth.attribute.gatt.secondary_service_declaration"},
-	"2802": {Name: "Include", Type: "org.bluetooth.attribute.gatt.include_declaration"},
-	"2803": {Name: "Characteristic", Type: "org.bluetooth.attribute.gatt.characteristic_declaration"},
-}
-
-// A dictionary of known descriptor names and type (keyed by descriptor uuid)
-var knownDescriptors = map[string]struct{ Name, Type string }{
-	"2900": {Name: "Characteristic Extended Properties", Type: "org.bluetooth.descriptor.gatt.characteristic_extended_properties"},
-	"2901": {Name: "Characteristic User Description", Type: "org.bluetooth.descriptor.gatt.characteristic_user_description"},
-	"2902": {Name: "Client Characteristic Configuration", Type: "org.bluetooth.descriptor.gatt.client_characteristic_configuration"},
-	"2903": {Name: "Server Characteristic Configuration", Type: "org.bluetooth.descriptor.gatt.server_characteristic_configuration"},
-	"2904": {Name: "Characteristic Presentation Format", Type: "org.bluetooth.descriptor.gatt.characteristic_presentation_format"},
-	"2905": {Name: "Characteristic Aggregate Format", Type: "org.bluetooth.descriptor.gatt.characteristic_aggregate_format"},
-	"2906": {Name: "Valid Range", Type: "org.bluetooth.descriptor.valid_range"},
-	"2907": {Name: "External Report Reference", Type: "org.bluetooth.descriptor.external_report_reference"},
-	"2908": {Name: "Report Reference", Type: "org.bluetooth.descriptor.report_reference"},
-}
-
-// A dictionary of known characteristic names and type (keyed by characteristic uuid)
-var knownCharacteristics = map[string]struct{ Name, Type string }{
-	"2a00": {Name: "Device Name", Type: "org.bluetooth.characteristic.gap.device_name"},
-	"2a01": {Name: "Appearance", Type: "org.bluetooth.characteristic.gap.appearance"},
-	"2a02": {Name: "Peripheral Privacy Flag", Type: "org.bluetooth.characteristic.gap.peripheral_privacy_flag"},
-	"2a03": {Name: "Reconnection Address", Type: "org.bluetooth.characteristic.gap.reconnection_address"},
-	"2a04": {Name: "Peripheral Preferred Connection Parameters", Type: "org.bluetooth.characteristic.gap.peripheral_preferred_connection_parameters"},
-	"2a05": {Name: "Service Changed", Type: "org.bluetooth.characteristic.gatt.service_changed"},
-	"2a06": {Name: "Alert Level", Type: "org.bluetooth.characteristic.alert_level"},
-	"2a07": {Name: "Tx Power Level", Type: "org.bluetooth.characteristic.tx_power_level"},
-	"2a08": {Name: "Date Time", Type: "org.bluetooth.characteristic.date_time"},
-	"2a09": {Name: "Day of Week", Type: "org.bluetooth.characteristic.day_of_week"},
-	"2a0a": {Name: "Day Date Time", Type: "org.bluetooth.characteristic.day_date_time"},
-	"2a0c": {Name: "Exact Time 256", Type: "org.bluetooth.characteristic.exact_time_256"},
-	"2a0d": {Name: "DST Offset", Type: "org.bluetooth.characteristic.dst_offset"},
-	"2a0e": {Name: "Time Zone", Type: "org.bluetooth.characteristic.time_zone"},
-	"2a0f": {Name: "Local Time Information", Type: "org.bluetooth.characteristic.local_time_information"},
-	"2a11": {Name: "Time with DST", Type: "org.bluetooth.characteristic.time_with_dst"},
-	"2a12": {Name: "Time Accuracy", Type: "org.bluetooth.characteristic.time_accuracy"},
-	"2a13": {Name: "Time Source", Type: "org.bluetooth.characteristic.time_source"},
-	"2a14": {Name: "Reference Time Information", Type: "org.bluetooth.characteristic.reference_time_information"},
-	"2a16": {Name: "Time Update Control Point", Type: "org.bluetooth.characteristic.time_update_control_point"},
-	"2a17": {Name: "Time Update State", Type: "org.bluetooth.characteristic.time_update_state"},
-	"2a18": {Name: "Glucose Measurement", Type: "org.bluetooth.characteristic.glucose_measurement"},
-	"2a19": {Name: "Battery Level", Type: "org.bluetooth.characteristic.battery_level"},
-	"2a1c": {Name: "Temperature Measurement", Type: "org.bluetooth.characteristic.temperature_measurement"},
-	"2a1d": {Name: "Temperature Type", Type: "org.bluetooth.characteristic.temperature_type"},
-	"2a1e": {Name: "Intermediate Temperature", Type: "org.bluetooth.characteristic.intermediate_temperature"},
-	"2a21": {Name: "Measurement Interval", Type: "org.bluetooth.characteristic.measurement_interval"},
-	"2a22": {Name: "Boot Keyboard Input Report", Type: "org.bluetooth.characteristic.boot_keyboard_input_report"},
-	"2a23": {Name: "System ID", Type: "org.bluetooth.characteristic.system_id"},
-	"2a24": {Name: "Model Number String", Type: "org.bluetooth.characteristic.model_number_string"},
-	"2a25": {Name: "Serial Number String", Type: "org.bluetooth.characteristic.serial_number_string"},
-	"2a26": {Name: "Firmware Revision String", Type: "org.bluetooth.characteristic.firmware_revision_string"},
-	"2a27": {Name: "Hardware Revision String", Type: "org.bluetooth.characteristic.hardware_revision_string"},
-	"2a28": {Name: "Software Revision String", Type: "org.bluetooth.characteristic.software_revision_string"},
-	"2a29": {Name: "Manufacturer Name String", Type: "org.bluetooth.characteristic.manufacturer_name_string"},
-	"2a2a": {Name: "IEEE 11073-20601 Regulatory Certification Data List", Type: "org.bluetooth.characteristic.ieee_11073-20601_regulatory_certification_data_list"},
-	"2a2b": {Name: "Current Time", Type: "org.bluetooth.characteristic.current_time"},
-	"2a31": {Name: "Scan Refresh", Type: "org.bluetooth.characteristic.scan_refresh"},
-	"2a32": {Name: "Boot Keyboard Output Report", Type: "org.bluetooth.characteristic.boot_keyboard_output_report"},
-	"2a33": {Name: "Boot Mouse Input Report", Type: "org.bluetooth.characteristic.boot_mouse_input_report"},
-	"2a34": {Name: "Glucose Measurement Context", Type: "org.bluetooth.characteristic.glucose_measurement_context"},
-	"2a35": {Name: "Blood Pressure Measurement", Type: "org.bluetooth.characteristic.blood_pressure_measurement"},
-	"2a36": {Name: "Intermediate Cuff Pressure", Type: "org.bluetooth.characteristic.intermediate_blood_pressure"},
-	"2a37": {Name: "Heart Rate Measurement", Type: "org.bluetooth.characteristic.heart_rate_measurement"},
-	"2a38": {Name: "Body Sensor Location", Type: "org.bluetooth.characteristic.body_sensor_location"},
-	"2a39": {Name: "Heart Rate Control Point", Type: "org.bluetooth.characteristic.heart_rate_control_point"},
-	"2a3f": {Name: "Alert Status", Type: "org.bluetooth.characteristic.alert_status"},
-	"2a40": {Name: "Ringer Control Point", Type: "org.bluetooth.characteristic.ringer_control_point"},
-	"2a41": {Name: "Ringer Setting", Type: "org.bluetooth.characteristic.ringer_setting"},
-	"2a42": {Name: "Alert Category ID Bit Mask", Type: "org.bluetooth.characteristic.alert_category_id_bit_mask"},
-	"2a43": {Name: "Alert Category ID", Type: "org.bluetooth.characteristic.alert_category_id"},
-	"2a44": {Name: "Alert Notification Control Point", Type: "org.bluetooth.characteristic.alert_notification_control_point"},
-	"2a45": {Name: "Unread Alert Status", Type: "org.bluetooth.characteristic.unread_alert_status"},
-	"2a46": {Name: "New Alert", Type: "org.bluetooth.characteristic.new_alert"},
-	"2a47": {Name: "Supported New Alert Category", Type: "org.bluetooth.characteristic.supported_new_alert_category"},
-	"2a48": {Name: "Supported Unread Alert Category", Type: "org.bluetooth.characteristic.supported_unread_alert_category"},
-	"2a49": {Name: "Blood Pressure Feature", Type: "org.bluetooth.characteristic.blood_pressure_feature"},
-	"2a4a": {Name: "HID Information", Type: "org.bluetooth.characteristic.hid_information"},
-	"2a4b": {Name: "Report Map", Type: "org.bluetooth.characteristic.report_map"},
-	"2a4c": {Name: "HID Control Point", Type: "org.bluetooth.characteristic.hid_control_point"},
-	"2a4d": {Name: "Report", Type: "org.bluetooth.characteristic.report"},
-	"2a4e": {Name: "Protocol Mode", Type: "org.bluetooth.characteristic.protocol_mode"},
-	"2a4f": {Name: "Scan Interval Window", Type: "org.bluetooth.characteristic.scan_interval_window"},
-	"2a50": {Name: "PnP ID", Type: "org.bluetooth.characteristic.pnp_id"},
-	"2a51": {Name: "Glucose Feature", Type: "org.bluetooth.characteristic.glucose_feature"},
-	"2a52": {Name: "Record Access Control Point", Type: "org.bluetooth.characteristic.record_access_control_point"},
-	"2a53": {Name: "RSC Measurement", Type: "org.bluetooth.characteristic.rsc_measurement"},
-	"2a54": {Name: "RSC Feature", Type: "org.bluetooth.characteristic.rsc_feature"},
-	"2a55": {Name: "SC Control Point", Type: "org.bluetooth.characteristic.sc_control_point"},
-	"2a5b": {Name: "CSC Measurement", Type: "org.bluetooth.characteristic.csc_measurement"},
-	"2a5c": {Name: "CSC Feature", Type: "org.bluetooth.characteristic.csc_feature"},
-	"2a5d": {Name: "Sensor Location", Type: "org.bluetooth.characteristic.sensor_location"},
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/l2cap_writer_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/l2cap_writer_linux.go b/newtmgr/vendor/github.com/runtimeinc/gatt/l2cap_writer_linux.go
deleted file mode 100644
index f5cecaf..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/l2cap_writer_linux.go
+++ /dev/null
@@ -1,156 +0,0 @@
-package gatt
-
-import "encoding/binary"
-
-// l2capWriter helps create l2cap responses.
-// It is not meant to be used with large writes.
-// TODO: benchmark the number of allocs here.
-// Reduce by letting WriteByteFit, WriteUint16Fit, etc.
-// extend b/chunk and write into it directly.
-type l2capWriter struct {
-	mtu     int
-	b       []byte
-	chunk   []byte
-	chunked bool
-}
-
-func newL2capWriter(mtu uint16) *l2capWriter {
-	return &l2capWriter{mtu: int(mtu), b: make([]byte, 0, mtu)}
-}
-
-// Chunk starts writing a new chunk. This chunk
-// is not committed until Commit is called.
-// Chunk panics if another chunk has already been
-// started and not committed.
-func (w *l2capWriter) Chunk() {
-	if w.chunked {
-		panic("l2capWriter: chunk called twice without committing")
-	}
-	w.chunked = true
-	if w.chunk == nil {
-		w.chunk = make([]byte, 0, w.mtu)
-	}
-}
-
-// Commit writes the current chunk and reports whether the
-// write succeeded. The write succeeds iff there is enough room.
-// Commit panics if no chunk has been started.
-func (w *l2capWriter) Commit() bool {
-	if !w.chunked {
-		panic("l2capWriter: commit without starting a chunk")
-	}
-	var success bool
-	if len(w.b)+len(w.chunk) <= w.mtu {
-		success = true
-		w.b = append(w.b, w.chunk...)
-	}
-	w.chunk = w.chunk[:0]
-	w.chunked = false
-	return success
-}
-
-// CommitFit writes as much of the current chunk as possible,
-// truncating as needed.
-// CommitFit panics if no chunk has been started.
-func (w *l2capWriter) CommitFit() {
-	if !w.chunked {
-		panic("l2capWriter: CommitFit without starting a chunk")
-	}
-	writeable := w.mtu - len(w.b)
-	if writeable > len(w.chunk) {
-		writeable = len(w.chunk)
-	}
-	w.b = append(w.b, w.chunk[:writeable]...)
-	w.chunk = w.chunk[:0]
-	w.chunked = false
-}
-
-// WriteByteFit writes b.
-// It reports whether the write succeeded,
-// using the criteria of WriteFit.
-func (w *l2capWriter) WriteByteFit(b byte) bool {
-	return w.WriteFit([]byte{b})
-}
-
-// WriteUint16Fit writes v using BLE (LittleEndian) encoding.
-// It reports whether the write succeeded, using the
-// criteria of WriteFit.
-func (w *l2capWriter) WriteUint16Fit(v uint16) bool {
-	b := make([]byte, 2)
-	binary.LittleEndian.PutUint16(b, v)
-	return w.WriteFit(b)
-}
-
-// WriteUUIDFit writes uuid using BLE (reversed) encoding.
-// It reports whether the write succeeded, using the
-// criteria of WriteFit.
-func (w *l2capWriter) WriteUUIDFit(u UUID) bool {
-	return w.WriteFit(u.b)
-}
-
-// Writeable returns the number of bytes from b
-// that would be written if pad bytes were written,
-// then as much of b as fits were written. When
-// writing to a chunk, any amount of bytes may be
-// written.
-func (w *l2capWriter) Writeable(pad int, b []byte) int {
-	if w.chunked {
-		return len(b)
-	}
-	avail := w.mtu - len(w.b) - pad
-	if avail > len(b) {
-		return len(b)
-	}
-	if avail < 0 {
-		return 0
-	}
-	return avail
-}
-
-// WriteFit writes as much of b as fits.
-// It reports whether the write succeeded without
-// truncation. A write succeeds without truncation
-// iff a chunk write is in progress or the entire
-// contents were written (without exceeding the mtu).
-func (w *l2capWriter) WriteFit(b []byte) bool {
-	if w.chunked {
-		w.chunk = append(w.chunk, b...)
-		return true
-	}
-	avail := w.mtu - len(w.b)
-	if avail >= len(b) {
-		w.b = append(w.b, b...)
-		return true
-	}
-	w.b = append(w.b, b[:avail]...)
-	return false
-}
-
-// ChunkSeek discards the first offset bytes from the
-// current chunk. It reports whether there were at least
-// offset bytes available to discard.
-// It panics if a chunked write is not in progress.
-func (w *l2capWriter) ChunkSeek(offset uint16) bool {
-	if !w.chunked {
-		panic("l2capWriter: ChunkSeek requested without chunked write in progress")
-	}
-	if len(w.chunk) < int(offset) {
-		w.chunk = w.chunk[:0]
-		return false
-	}
-	w.chunk = w.chunk[offset:]
-	return true
-}
-
-// Bytes returns the written bytes.
-// It will panic if a chunked write
-// is in progress.
-// It is meant to be used when writing
-// is completed. It does not return a copy.
-// Don't abuse this, it's not worth it.
-func (w *l2capWriter) Bytes() []byte {
-	if w.chunked {
-		panic("l2capWriter: Bytes requested while chunked write in progress")
-	}
-	return w.b
-}


[6/7] incubator-mynewt-newt git commit: MYNEWT-653 Use runtimeco gatt fork.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/doc.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/doc.go b/newtmgr/vendor/github.com/runtimeco/gatt/doc.go
new file mode 100644
index 0000000..c34a3e9
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/doc.go
@@ -0,0 +1,88 @@
+// Package gatt provides a Bluetooth Low Energy gatt implementation.
+//
+// Gatt (Generic Attribute Profile) is the protocol used to write
+// BLE peripherals (servers) and centrals (clients).
+//
+// STATUS
+//
+// This package is a work in progress. The API will change.
+//
+// As a peripheral, you can create services, characteristics, and descriptors,
+// advertise, accept connections, and handle requests.
+// As a central, you can scan, connect, discover services, and make requests.
+//
+// SETUP
+//
+// gatt supports both Linux and OS X.
+//
+// On Linux:
+// To gain complete and exclusive control of the HCI device, gatt uses
+// HCI_CHANNEL_USER (introduced in Linux v3.14) instead of HCI_CHANNEL_RAW.
+// Those who must use an older kernel may patch in these relevant commits
+// from Marcel Holtmann:
+//
+//     Bluetooth: Introduce new HCI socket channel for user operation
+//     Bluetooth: Introduce user channel flag for HCI devices
+//     Bluetooth: Refactor raw socket filter into more readable code
+//
+// Note that because gatt uses HCI_CHANNEL_USER, once gatt has opened the
+// device no other program may access it.
+//
+// Before starting a gatt program, make sure that your BLE device is down:
+//
+//     sudo hciconfig
+//     sudo hciconfig hci0 down  # or whatever hci device you want to use
+//
+// If you have BlueZ 5.14+ (or aren't sure), stop the built-in
+// bluetooth server, which interferes with gatt, e.g.:
+//
+//     sudo service bluetooth stop
+//
+// Because gatt programs administer network devices, they must
+// either be run as root, or be granted appropriate capabilities:
+//
+//     sudo <executable>
+//     # OR
+//     sudo setcap 'cap_net_raw,cap_net_admin=eip' <executable>
+//     <executable>
+//
+// USAGE
+//
+//     # Start a simple server.
+//     sudo go run example/server.go
+//
+//     # Discover surrounding peripherals.
+//     sudo go run example/discoverer.go
+//
+//     # Connect to and explorer a peripheral device.
+//     sudo go run example/explorer.go <peripheral ID>
+//
+// See the server.go, discoverer.go, and explorer.go in the examples/
+// directory for writing server or client programs that run on Linux
+// and OS X.
+//
+// Users, especially on Linux platforms, seeking finer-grained control
+// over the devices can see the examples/server_lnx.go for the usage
+// of Option, which are platform specific.
+//
+// See the rest of the docs for other options and finer-grained control.
+//
+// Note that some BLE central devices, particularly iOS, may aggressively
+// cache results from previous connections. If you change your services or
+// characteristics, you may need to reboot the other device to pick up the
+// changes. This is a common source of confusion and apparent bugs. For an
+// OS X central, see http://stackoverflow.com/questions/20553957.
+//
+//
+// REFERENCES
+//
+// gatt started life as a port of bleno, to which it is indebted:
+// https://github.com/sandeepmistry/bleno. If you are having
+// problems with gatt, particularly around installation, issues
+// filed with bleno might also be helpful references.
+//
+// To try out your GATT server, it is useful to experiment with a
+// generic BLE client. LightBlue is a good choice. It is available
+// free for both iOS and OS X.
+//
+package gatt

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/known_uuid.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/known_uuid.go b/newtmgr/vendor/github.com/runtimeco/gatt/known_uuid.go
new file mode 100644
index 0000000..2146af5
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/known_uuid.go
@@ -0,0 +1,122 @@
+package gatt
+
+// A dictionary of known service names and type (keyed by service uuid)
+var knownServices = map[string]struct{ Name, Type string }{
+	"1800": {Name: "Generic Access", Type: "org.bluetooth.service.generic_access"},
+	"1801": {Name: "Generic Attribute", Type: "org.bluetooth.service.generic_attribute"},
+	"1802": {Name: "Immediate Alert", Type: "org.bluetooth.service.immediate_alert"},
+	"1803": {Name: "Link Loss", Type: "org.bluetooth.service.link_loss"},
+	"1804": {Name: "Tx Power", Type: "org.bluetooth.service.tx_power"},
+	"1805": {Name: "Current Time Service", Type: "org.bluetooth.service.current_time"},
+	"1806": {Name: "Reference Time Update Service", Type: "org.bluetooth.service.reference_time_update"},
+	"1807": {Name: "Next DST Change Service", Type: "org.bluetooth.service.next_dst_change"},
+	"1808": {Name: "Glucose", Type: "org.bluetooth.service.glucose"},
+	"1809": {Name: "Health Thermometer", Type: "org.bluetooth.service.health_thermometer"},
+	"180a": {Name: "Device Information", Type: "org.bluetooth.service.device_information"},
+	"180d": {Name: "Heart Rate", Type: "org.bluetooth.service.heart_rate"},
+	"180e": {Name: "Phone Alert Status Service", Type: "org.bluetooth.service.phone_alert_service"},
+	"180f": {Name: "Battery Service", Type: "org.bluetooth.service.battery_service"},
+	"1810": {Name: "Blood Pressure", Type: "org.bluetooth.service.blood_pressuer"},
+	"1811": {Name: "Alert Notification Service", Type: "org.bluetooth.service.alert_notification"},
+	"1812": {Name: "Human Interface Device", Type: "org.bluetooth.service.human_interface_device"},
+	"1813": {Name: "Scan Parameters", Type: "org.bluetooth.service.scan_parameters"},
+	"1814": {Name: "Running Speed and Cadence", Type: "org.bluetooth.service.running_speed_and_cadence"},
+	"1815": {Name: "Cycling Speed and Cadence", Type: "org.bluetooth.service.cycling_speed_and_cadence"},
+}
+
+// A dictionary of known descriptor names and type (keyed by attribute uuid)
+var knownAttributes = map[string]struct{ Name, Type string }{
+	"2800": {Name: "Primary Service", Type: "org.bluetooth.attribute.gatt.primary_service_declaration"},
+	"2801": {Name: "Secondary Service", Type: "org.bluetooth.attribute.gatt.secondary_service_declaration"},
+	"2802": {Name: "Include", Type: "org.bluetooth.attribute.gatt.include_declaration"},
+	"2803": {Name: "Characteristic", Type: "org.bluetooth.attribute.gatt.characteristic_declaration"},
+}
+
+// A dictionary of known descriptor names and type (keyed by descriptor uuid)
+var knownDescriptors = map[string]struct{ Name, Type string }{
+	"2900": {Name: "Characteristic Extended Properties", Type: "org.bluetooth.descriptor.gatt.characteristic_extended_properties"},
+	"2901": {Name: "Characteristic User Description", Type: "org.bluetooth.descriptor.gatt.characteristic_user_description"},
+	"2902": {Name: "Client Characteristic Configuration", Type: "org.bluetooth.descriptor.gatt.client_characteristic_configuration"},
+	"2903": {Name: "Server Characteristic Configuration", Type: "org.bluetooth.descriptor.gatt.server_characteristic_configuration"},
+	"2904": {Name: "Characteristic Presentation Format", Type: "org.bluetooth.descriptor.gatt.characteristic_presentation_format"},
+	"2905": {Name: "Characteristic Aggregate Format", Type: "org.bluetooth.descriptor.gatt.characteristic_aggregate_format"},
+	"2906": {Name: "Valid Range", Type: "org.bluetooth.descriptor.valid_range"},
+	"2907": {Name: "External Report Reference", Type: "org.bluetooth.descriptor.external_report_reference"},
+	"2908": {Name: "Report Reference", Type: "org.bluetooth.descriptor.report_reference"},
+}
+
+// A dictionary of known characteristic names and type (keyed by characteristic uuid)
+var knownCharacteristics = map[string]struct{ Name, Type string }{
+	"2a00": {Name: "Device Name", Type: "org.bluetooth.characteristic.gap.device_name"},
+	"2a01": {Name: "Appearance", Type: "org.bluetooth.characteristic.gap.appearance"},
+	"2a02": {Name: "Peripheral Privacy Flag", Type: "org.bluetooth.characteristic.gap.peripheral_privacy_flag"},
+	"2a03": {Name: "Reconnection Address", Type: "org.bluetooth.characteristic.gap.reconnection_address"},
+	"2a04": {Name: "Peripheral Preferred Connection Parameters", Type: "org.bluetooth.characteristic.gap.peripheral_preferred_connection_parameters"},
+	"2a05": {Name: "Service Changed", Type: "org.bluetooth.characteristic.gatt.service_changed"},
+	"2a06": {Name: "Alert Level", Type: "org.bluetooth.characteristic.alert_level"},
+	"2a07": {Name: "Tx Power Level", Type: "org.bluetooth.characteristic.tx_power_level"},
+	"2a08": {Name: "Date Time", Type: "org.bluetooth.characteristic.date_time"},
+	"2a09": {Name: "Day of Week", Type: "org.bluetooth.characteristic.day_of_week"},
+	"2a0a": {Name: "Day Date Time", Type: "org.bluetooth.characteristic.day_date_time"},
+	"2a0c": {Name: "Exact Time 256", Type: "org.bluetooth.characteristic.exact_time_256"},
+	"2a0d": {Name: "DST Offset", Type: "org.bluetooth.characteristic.dst_offset"},
+	"2a0e": {Name: "Time Zone", Type: "org.bluetooth.characteristic.time_zone"},
+	"2a0f": {Name: "Local Time Information", Type: "org.bluetooth.characteristic.local_time_information"},
+	"2a11": {Name: "Time with DST", Type: "org.bluetooth.characteristic.time_with_dst"},
+	"2a12": {Name: "Time Accuracy", Type: "org.bluetooth.characteristic.time_accuracy"},
+	"2a13": {Name: "Time Source", Type: "org.bluetooth.characteristic.time_source"},
+	"2a14": {Name: "Reference Time Information", Type: "org.bluetooth.characteristic.reference_time_information"},
+	"2a16": {Name: "Time Update Control Point", Type: "org.bluetooth.characteristic.time_update_control_point"},
+	"2a17": {Name: "Time Update State", Type: "org.bluetooth.characteristic.time_update_state"},
+	"2a18": {Name: "Glucose Measurement", Type: "org.bluetooth.characteristic.glucose_measurement"},
+	"2a19": {Name: "Battery Level", Type: "org.bluetooth.characteristic.battery_level"},
+	"2a1c": {Name: "Temperature Measurement", Type: "org.bluetooth.characteristic.temperature_measurement"},
+	"2a1d": {Name: "Temperature Type", Type: "org.bluetooth.characteristic.temperature_type"},
+	"2a1e": {Name: "Intermediate Temperature", Type: "org.bluetooth.characteristic.intermediate_temperature"},
+	"2a21": {Name: "Measurement Interval", Type: "org.bluetooth.characteristic.measurement_interval"},
+	"2a22": {Name: "Boot Keyboard Input Report", Type: "org.bluetooth.characteristic.boot_keyboard_input_report"},
+	"2a23": {Name: "System ID", Type: "org.bluetooth.characteristic.system_id"},
+	"2a24": {Name: "Model Number String", Type: "org.bluetooth.characteristic.model_number_string"},
+	"2a25": {Name: "Serial Number String", Type: "org.bluetooth.characteristic.serial_number_string"},
+	"2a26": {Name: "Firmware Revision String", Type: "org.bluetooth.characteristic.firmware_revision_string"},
+	"2a27": {Name: "Hardware Revision String", Type: "org.bluetooth.characteristic.hardware_revision_string"},
+	"2a28": {Name: "Software Revision String", Type: "org.bluetooth.characteristic.software_revision_string"},
+	"2a29": {Name: "Manufacturer Name String", Type: "org.bluetooth.characteristic.manufacturer_name_string"},
+	"2a2a": {Name: "IEEE 11073-20601 Regulatory Certification Data List", Type: "org.bluetooth.characteristic.ieee_11073-20601_regulatory_certification_data_list"},
+	"2a2b": {Name: "Current Time", Type: "org.bluetooth.characteristic.current_time"},
+	"2a31": {Name: "Scan Refresh", Type: "org.bluetooth.characteristic.scan_refresh"},
+	"2a32": {Name: "Boot Keyboard Output Report", Type: "org.bluetooth.characteristic.boot_keyboard_output_report"},
+	"2a33": {Name: "Boot Mouse Input Report", Type: "org.bluetooth.characteristic.boot_mouse_input_report"},
+	"2a34": {Name: "Glucose Measurement Context", Type: "org.bluetooth.characteristic.glucose_measurement_context"},
+	"2a35": {Name: "Blood Pressure Measurement", Type: "org.bluetooth.characteristic.blood_pressure_measurement"},
+	"2a36": {Name: "Intermediate Cuff Pressure", Type: "org.bluetooth.characteristic.intermediate_blood_pressure"},
+	"2a37": {Name: "Heart Rate Measurement", Type: "org.bluetooth.characteristic.heart_rate_measurement"},
+	"2a38": {Name: "Body Sensor Location", Type: "org.bluetooth.characteristic.body_sensor_location"},
+	"2a39": {Name: "Heart Rate Control Point", Type: "org.bluetooth.characteristic.heart_rate_control_point"},
+	"2a3f": {Name: "Alert Status", Type: "org.bluetooth.characteristic.alert_status"},
+	"2a40": {Name: "Ringer Control Point", Type: "org.bluetooth.characteristic.ringer_control_point"},
+	"2a41": {Name: "Ringer Setting", Type: "org.bluetooth.characteristic.ringer_setting"},
+	"2a42": {Name: "Alert Category ID Bit Mask", Type: "org.bluetooth.characteristic.alert_category_id_bit_mask"},
+	"2a43": {Name: "Alert Category ID", Type: "org.bluetooth.characteristic.alert_category_id"},
+	"2a44": {Name: "Alert Notification Control Point", Type: "org.bluetooth.characteristic.alert_notification_control_point"},
+	"2a45": {Name: "Unread Alert Status", Type: "org.bluetooth.characteristic.unread_alert_status"},
+	"2a46": {Name: "New Alert", Type: "org.bluetooth.characteristic.new_alert"},
+	"2a47": {Name: "Supported New Alert Category", Type: "org.bluetooth.characteristic.supported_new_alert_category"},
+	"2a48": {Name: "Supported Unread Alert Category", Type: "org.bluetooth.characteristic.supported_unread_alert_category"},
+	"2a49": {Name: "Blood Pressure Feature", Type: "org.bluetooth.characteristic.blood_pressure_feature"},
+	"2a4a": {Name: "HID Information", Type: "org.bluetooth.characteristic.hid_information"},
+	"2a4b": {Name: "Report Map", Type: "org.bluetooth.characteristic.report_map"},
+	"2a4c": {Name: "HID Control Point", Type: "org.bluetooth.characteristic.hid_control_point"},
+	"2a4d": {Name: "Report", Type: "org.bluetooth.characteristic.report"},
+	"2a4e": {Name: "Protocol Mode", Type: "org.bluetooth.characteristic.protocol_mode"},
+	"2a4f": {Name: "Scan Interval Window", Type: "org.bluetooth.characteristic.scan_interval_window"},
+	"2a50": {Name: "PnP ID", Type: "org.bluetooth.characteristic.pnp_id"},
+	"2a51": {Name: "Glucose Feature", Type: "org.bluetooth.characteristic.glucose_feature"},
+	"2a52": {Name: "Record Access Control Point", Type: "org.bluetooth.characteristic.record_access_control_point"},
+	"2a53": {Name: "RSC Measurement", Type: "org.bluetooth.characteristic.rsc_measurement"},
+	"2a54": {Name: "RSC Feature", Type: "org.bluetooth.characteristic.rsc_feature"},
+	"2a55": {Name: "SC Control Point", Type: "org.bluetooth.characteristic.sc_control_point"},
+	"2a5b": {Name: "CSC Measurement", Type: "org.bluetooth.characteristic.csc_measurement"},
+	"2a5c": {Name: "CSC Feature", Type: "org.bluetooth.characteristic.csc_feature"},
+	"2a5d": {Name: "Sensor Location", Type: "org.bluetooth.characteristic.sensor_location"},
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/l2cap_writer_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/l2cap_writer_linux.go b/newtmgr/vendor/github.com/runtimeco/gatt/l2cap_writer_linux.go
new file mode 100644
index 0000000..f5cecaf
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/l2cap_writer_linux.go
@@ -0,0 +1,156 @@
+package gatt
+
+import "encoding/binary"
+
+// l2capWriter helps create l2cap responses.
+// It is not meant to be used with large writes.
+// TODO: benchmark the number of allocs here.
+// Reduce by letting WriteByteFit, WriteUint16Fit, etc.
+// extend b/chunk and write into it directly.
+type l2capWriter struct {
+	mtu     int
+	b       []byte
+	chunk   []byte
+	chunked bool
+}
+
+func newL2capWriter(mtu uint16) *l2capWriter {
+	return &l2capWriter{mtu: int(mtu), b: make([]byte, 0, mtu)}
+}
+
+// Chunk starts writing a new chunk. This chunk
+// is not committed until Commit is called.
+// Chunk panics if another chunk has already been
+// started and not committed.
+func (w *l2capWriter) Chunk() {
+	if w.chunked {
+		panic("l2capWriter: chunk called twice without committing")
+	}
+	w.chunked = true
+	if w.chunk == nil {
+		w.chunk = make([]byte, 0, w.mtu)
+	}
+}
+
+// Commit writes the current chunk and reports whether the
+// write succeeded. The write succeeds iff there is enough room.
+// Commit panics if no chunk has been started.
+func (w *l2capWriter) Commit() bool {
+	if !w.chunked {
+		panic("l2capWriter: commit without starting a chunk")
+	}
+	var success bool
+	if len(w.b)+len(w.chunk) <= w.mtu {
+		success = true
+		w.b = append(w.b, w.chunk...)
+	}
+	w.chunk = w.chunk[:0]
+	w.chunked = false
+	return success
+}
+
+// CommitFit writes as much of the current chunk as possible,
+// truncating as needed.
+// CommitFit panics if no chunk has been started.
+func (w *l2capWriter) CommitFit() {
+	if !w.chunked {
+		panic("l2capWriter: CommitFit without starting a chunk")
+	}
+	writeable := w.mtu - len(w.b)
+	if writeable > len(w.chunk) {
+		writeable = len(w.chunk)
+	}
+	w.b = append(w.b, w.chunk[:writeable]...)
+	w.chunk = w.chunk[:0]
+	w.chunked = false
+}
+
+// WriteByteFit writes b.
+// It reports whether the write succeeded,
+// using the criteria of WriteFit.
+func (w *l2capWriter) WriteByteFit(b byte) bool {
+	return w.WriteFit([]byte{b})
+}
+
+// WriteUint16Fit writes v using BLE (LittleEndian) encoding.
+// It reports whether the write succeeded, using the
+// criteria of WriteFit.
+func (w *l2capWriter) WriteUint16Fit(v uint16) bool {
+	b := make([]byte, 2)
+	binary.LittleEndian.PutUint16(b, v)
+	return w.WriteFit(b)
+}
+
+// WriteUUIDFit writes uuid using BLE (reversed) encoding.
+// It reports whether the write succeeded, using the
+// criteria of WriteFit.
+func (w *l2capWriter) WriteUUIDFit(u UUID) bool {
+	return w.WriteFit(u.b)
+}
+
+// Writeable returns the number of bytes from b
+// that would be written if pad bytes were written,
+// then as much of b as fits were written. When
+// writing to a chunk, any amount of bytes may be
+// written.
+func (w *l2capWriter) Writeable(pad int, b []byte) int {
+	if w.chunked {
+		return len(b)
+	}
+	avail := w.mtu - len(w.b) - pad
+	if avail > len(b) {
+		return len(b)
+	}
+	if avail < 0 {
+		return 0
+	}
+	return avail
+}
+
+// WriteFit writes as much of b as fits.
+// It reports whether the write succeeded without
+// truncation. A write succeeds without truncation
+// iff a chunk write is in progress or the entire
+// contents were written (without exceeding the mtu).
+func (w *l2capWriter) WriteFit(b []byte) bool {
+	if w.chunked {
+		w.chunk = append(w.chunk, b...)
+		return true
+	}
+	avail := w.mtu - len(w.b)
+	if avail >= len(b) {
+		w.b = append(w.b, b...)
+		return true
+	}
+	w.b = append(w.b, b[:avail]...)
+	return false
+}
+
+// ChunkSeek discards the first offset bytes from the
+// current chunk. It reports whether there were at least
+// offset bytes available to discard.
+// It panics if a chunked write is not in progress.
+func (w *l2capWriter) ChunkSeek(offset uint16) bool {
+	if !w.chunked {
+		panic("l2capWriter: ChunkSeek requested without chunked write in progress")
+	}
+	if len(w.chunk) < int(offset) {
+		w.chunk = w.chunk[:0]
+		return false
+	}
+	w.chunk = w.chunk[offset:]
+	return true
+}
+
+// Bytes returns the written bytes.
+// It will panic if a chunked write
+// is in progress.
+// It is meant to be used when writing
+// is completed. It does not return a copy.
+// Don't abuse this, it's not worth it.
+func (w *l2capWriter) Bytes() []byte {
+	if w.chunked {
+		panic("l2capWriter: Bytes requested while chunked write in progress")
+	}
+	return w.b
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/cmd/cmd.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/cmd/cmd.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/cmd/cmd.go
new file mode 100644
index 0000000..7052502
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/cmd/cmd.go
@@ -0,0 +1,995 @@
+package cmd
+
+import (
+	"bytes"
+	"errors"
+	"fmt"
+	"io"
+	"log"
+
+	"github.com/runtimeco/gatt/linux/evt"
+	"github.com/runtimeco/gatt/linux/util"
+)
+
+type CmdParam interface {
+	Marshal([]byte)
+	Opcode() int
+	Len() int
+}
+
+func NewCmd(d io.Writer) *Cmd {
+	c := &Cmd{
+		dev:     d,
+		sent:    []*cmdPkt{},
+		compc:   make(chan evt.CommandCompleteEP),
+		statusc: make(chan evt.CommandStatusEP),
+	}
+	go c.processCmdEvents()
+	return c
+}
+
+type cmdPkt struct {
+	op   int
+	cp   CmdParam
+	done chan []byte
+}
+
+func (c cmdPkt) Marshal() []byte {
+	b := make([]byte, 1+2+1+c.cp.Len())
+	b[0] = byte(0x1) // typCommandPkt
+	b[1] = byte(c.op)
+	b[2] = byte(c.op >> 8)
+	b[3] = byte(c.cp.Len())
+	c.cp.Marshal(b[4:])
+	return b
+}
+
+type Cmd struct {
+	dev     io.Writer
+	sent    []*cmdPkt
+	compc   chan evt.CommandCompleteEP
+	statusc chan evt.CommandStatusEP
+}
+
+func (c Cmd) trace(fmt string, v ...interface{}) {}
+
+func (c *Cmd) HandleComplete(b []byte) error {
+	var e evt.CommandCompleteEP
+	if err := e.Unmarshal(b); err != nil {
+		return err
+	}
+	c.compc <- e
+	return nil
+}
+
+func (c *Cmd) HandleStatus(b []byte) error {
+	var e evt.CommandStatusEP
+	if err := e.Unmarshal(b); err != nil {
+		return err
+	}
+	c.statusc <- e
+	return nil
+}
+
+func (c *Cmd) Send(cp CmdParam) ([]byte, error) {
+	op := cp.Opcode()
+	p := &cmdPkt{op: op, cp: cp, done: make(chan []byte)}
+	raw := p.Marshal()
+
+	c.sent = append(c.sent, p)
+	if n, err := c.dev.Write(raw); err != nil {
+		return nil, err
+	} else if n != len(raw) {
+		return nil, errors.New("Failed to send whole Cmd pkt to HCI socket")
+	}
+	return <-p.done, nil
+}
+
+func (c *Cmd) SendAndCheckResp(cp CmdParam, exp []byte) error {
+	rsp, err := c.Send(cp)
+	if err != nil {
+		return err
+	}
+	// Don't care about the response
+	if len(exp) == 0 {
+		return nil
+	}
+	// Check the if status is one of the expected value
+	if !bytes.Contains(exp, rsp[0:1]) {
+		return fmt.Errorf("HCI command: '0x%04x' return 0x%02X, expect: [%X] ", cp.Opcode(), rsp[0], exp)
+	}
+	return nil
+}
+
+func (c *Cmd) processCmdEvents() {
+	for {
+		select {
+		case status := <-c.statusc:
+			found := false
+			for i, p := range c.sent {
+				if uint16(p.op) == status.CommandOpcode {
+					found = true
+					c.sent = append(c.sent[:i], c.sent[i+1:]...)
+					close(p.done)
+					break
+				}
+			}
+			if !found {
+				log.Printf("Can't find the cmdPkt for this CommandStatusEP: %v", status)
+			}
+		case comp := <-c.compc:
+			found := false
+			for i, p := range c.sent {
+				if uint16(p.op) == comp.CommandOPCode {
+					found = true
+					c.sent = append(c.sent[:i], c.sent[i+1:]...)
+					p.done <- comp.ReturnParameters
+					break
+				}
+			}
+			if !found {
+				log.Printf("Can't find the cmdPkt for this CommandCompleteEP: %v", comp)
+			}
+		}
+	}
+}
+
+const (
+	linkCtl     = 0x01
+	linkPolicy  = 0x02
+	hostCtl     = 0x03
+	infoParam   = 0x04
+	statusParam = 0x05
+	testingCmd  = 0X3E
+	leCtl       = 0x08
+	vendorCmd   = 0X3F
+)
+
+const (
+	opInquiry                = linkCtl<<10 | 0x0001 // Inquiry
+	opInquiryCancel          = linkCtl<<10 | 0x0002 // Inquiry Cancel
+	opPeriodicInquiry        = linkCtl<<10 | 0x0003 // Periodic Inquiry Mode
+	opExitPeriodicInquiry    = linkCtl<<10 | 0x0004 // Exit Periodic Inquiry Mode
+	opCreateConn             = linkCtl<<10 | 0x0005 // Create Connection
+	opDisconnect             = linkCtl<<10 | 0x0006 // Disconnect
+	opCreateConnCancel       = linkCtl<<10 | 0x0008 // Create Connection Cancel
+	opAcceptConnReq          = linkCtl<<10 | 0x0009 // Accept Connection Request
+	opRejectConnReq          = linkCtl<<10 | 0x000A // Reject Connection Request
+	opLinkKeyReply           = linkCtl<<10 | 0x000B // Link Key Request Reply
+	opLinkKeyNegReply        = linkCtl<<10 | 0x000C // Link Key Request Negative Reply
+	opPinCodeReply           = linkCtl<<10 | 0x000D // PIN Code Request Reply
+	opPinCodeNegReply        = linkCtl<<10 | 0x000E // PIN Code Request Negative Reply
+	opSetConnPtype           = linkCtl<<10 | 0x000F // Change Connection Packet Type
+	opAuthRequested          = linkCtl<<10 | 0x0011 // Authentication Request
+	opSetConnEncrypt         = linkCtl<<10 | 0x0013 // Set Connection Encryption
+	opChangeConnLinkKey      = linkCtl<<10 | 0x0015 // Change Connection Link Key
+	opMasterLinkKey          = linkCtl<<10 | 0x0017 // Master Link Key
+	opRemoteNameReq          = linkCtl<<10 | 0x0019 // Remote Name Request
+	opRemoteNameReqCancel    = linkCtl<<10 | 0x001A // Remote Name Request Cancel
+	opReadRemoteFeatures     = linkCtl<<10 | 0x001B // Read Remote Supported Features
+	opReadRemoteExtFeatures  = linkCtl<<10 | 0x001C // Read Remote Extended Features
+	opReadRemoteVersion      = linkCtl<<10 | 0x001D // Read Remote Version Information
+	opReadClockOffset        = linkCtl<<10 | 0x001F // Read Clock Offset
+	opReadLMPHandle          = linkCtl<<10 | 0x0020 // Read LMP Handle
+	opSetupSyncConn          = linkCtl<<10 | 0x0028 // Setup Synchronous Connection
+	opAcceptSyncConnReq      = linkCtl<<10 | 0x0029 // Aceept Synchronous Connection
+	opRejectSyncConnReq      = linkCtl<<10 | 0x002A // Recject Synchronous Connection
+	opIOCapabilityReply      = linkCtl<<10 | 0x002B // IO Capability Request Reply
+	opUserConfirmReply       = linkCtl<<10 | 0x002C // User Confirmation Request Reply
+	opUserConfirmNegReply    = linkCtl<<10 | 0x002D // User Confirmation Negative Reply
+	opUserPasskeyReply       = linkCtl<<10 | 0x002E // User Passkey Request Reply
+	opUserPasskeyNegReply    = linkCtl<<10 | 0x002F // User Passkey Request Negative Reply
+	opRemoteOOBDataReply     = linkCtl<<10 | 0x0030 // Remote OOB Data Request Reply
+	opRemoteOOBDataNegReply  = linkCtl<<10 | 0x0033 // Remote OOB Data Request Negative Reply
+	opIOCapabilityNegReply   = linkCtl<<10 | 0x0034 // IO Capability Request Negative Reply
+	opCreatePhysicalLink     = linkCtl<<10 | 0x0035 // Create Physical Link
+	opAcceptPhysicalLink     = linkCtl<<10 | 0x0036 // Accept Physical Link
+	opDisconnectPhysicalLink = linkCtl<<10 | 0x0037 // Disconnect Physical Link
+	opCreateLogicalLink      = linkCtl<<10 | 0x0038 // Create Logical Link
+	opAcceptLogicalLink      = linkCtl<<10 | 0x0039 // Accept Logical Link
+	opDisconnectLogicalLink  = linkCtl<<10 | 0x003A // Disconnect Logical Link
+	opLogicalLinkCancel      = linkCtl<<10 | 0x003B // Logical Link Cancel
+	opFlowSpecModify         = linkCtl<<10 | 0x003C // Flow Spec Modify
+)
+
+const (
+	opHoldMode               = linkPolicy<<10 | 0x0001 // Hold Mode
+	opSniffMode              = linkPolicy<<10 | 0x0003 // Sniff Mode
+	opExitSniffMode          = linkPolicy<<10 | 0x0004 // Exit Sniff Mode
+	opParkMode               = linkPolicy<<10 | 0x0005 // Park State
+	opExitParkMode           = linkPolicy<<10 | 0x0006 // Exit Park State
+	opQoSSetup               = linkPolicy<<10 | 0x0007 // QoS Setup
+	opRoleDiscovery          = linkPolicy<<10 | 0x0009 // Role Discovery
+	opSwitchRole             = linkPolicy<<10 | 0x000B // Switch Role
+	opReadLinkPolicy         = linkPolicy<<10 | 0x000C // Read Link Policy Settings
+	opWriteLinkPolicy        = linkPolicy<<10 | 0x000D // Write Link Policy Settings
+	opReadDefaultLinkPolicy  = linkPolicy<<10 | 0x000E // Read Default Link Policy Settings
+	opWriteDefaultLinkPolicy = linkPolicy<<10 | 0x000F // Write Default Link Policy Settings
+	opFlowSpecification      = linkPolicy<<10 | 0x0010 // Flow Specification
+	opSniffSubrating         = linkPolicy<<10 | 0x0011 // Sniff Subrating
+)
+
+const (
+	opSetEventMask                      = hostCtl<<10 | 0x0001 // Set Event Mask
+	opReset                             = hostCtl<<10 | 0x0003 // Reset
+	opSetEventFlt                       = hostCtl<<10 | 0x0005 // Set Event Filter
+	opFlush                             = hostCtl<<10 | 0x0008 // Flush
+	opReadPinType                       = hostCtl<<10 | 0x0009 // Read PIN Type
+	opWritePinType                      = hostCtl<<10 | 0x000A // Write PIN Type
+	opCreateNewUnitKey                  = hostCtl<<10 | 0x000B // Create New Unit Key
+	opReadStoredLinkKey                 = hostCtl<<10 | 0x000D // Read Stored Link Key
+	opWriteStoredLinkKey                = hostCtl<<10 | 0x0011 // Write Stored Link Key
+	opDeleteStoredLinkKey               = hostCtl<<10 | 0x0012 // Delete Stored Link Key
+	opWriteLocalName                    = hostCtl<<10 | 0x0013 // Write Local Name
+	opReadLocalName                     = hostCtl<<10 | 0x0014 // Read Local Name
+	opReadConnAcceptTimeout             = hostCtl<<10 | 0x0015 // Read Connection Accept Timeout
+	opWriteConnAcceptTimeout            = hostCtl<<10 | 0x0016 // Write Connection Accept Timeout
+	opReadPageTimeout                   = hostCtl<<10 | 0x0017 // Read Page Timeout
+	opWritePageTimeout                  = hostCtl<<10 | 0x0018 // Write Page Timeout
+	opReadScanEnable                    = hostCtl<<10 | 0x0019 // Read Scan Enable
+	opWriteScanEnable                   = hostCtl<<10 | 0x001A // Write Scan Enable
+	opReadPageActivity                  = hostCtl<<10 | 0x001B // Read Page Scan Activity
+	opWritePageActivity                 = hostCtl<<10 | 0x001C // Write Page Scan Activity
+	opReadInqActivity                   = hostCtl<<10 | 0x001D // Read Inquiry Scan Activity
+	opWriteInqActivity                  = hostCtl<<10 | 0x001E // Write Inquiry Scan Activity
+	opReadAuthEnable                    = hostCtl<<10 | 0x001F // Read Authentication Enable
+	opWriteAuthEnable                   = hostCtl<<10 | 0x0020 // Write Authentication Enable
+	opReadEncryptMode                   = hostCtl<<10 | 0x0021
+	opWriteEncryptMode                  = hostCtl<<10 | 0x0022
+	opReadClassOfDev                    = hostCtl<<10 | 0x0023 // Read Class of Device
+	opWriteClassOfDevice                = hostCtl<<10 | 0x0024 // Write Class of Device
+	opReadVoiceSetting                  = hostCtl<<10 | 0x0025 // Read Voice Setting
+	opWriteVoiceSetting                 = hostCtl<<10 | 0x0026 // Write Voice Setting
+	opReadAutomaticFlushTimeout         = hostCtl<<10 | 0x0027 // Read Automatic Flush Timeout
+	opWriteAutomaticFlushTimeout        = hostCtl<<10 | 0x0028 // Write Automatic Flush Timeout
+	opReadNumBroadcastRetrans           = hostCtl<<10 | 0x0029 // Read Num Broadcast Retransmissions
+	opWriteNumBroadcastRetrans          = hostCtl<<10 | 0x002A // Write Num Broadcast Retransmissions
+	opReadHoldModeActivity              = hostCtl<<10 | 0x002B // Read Hold Mode Activity
+	opWriteHoldModeActivity             = hostCtl<<10 | 0x002C // Write Hold Mode Activity
+	opReadTransmitPowerLevel            = hostCtl<<10 | 0x002D // Read Transmit Power Level
+	opReadSyncFlowEnable                = hostCtl<<10 | 0x002E // Read Synchronous Flow Control
+	opWriteSyncFlowEnable               = hostCtl<<10 | 0x002F // Write Synchronous Flow Control
+	opSetControllerToHostFC             = hostCtl<<10 | 0x0031 // Set Controller To Host Flow Control
+	opHostBufferSize                    = hostCtl<<10 | 0x0033 // Host Buffer Size
+	opHostNumCompPkts                   = hostCtl<<10 | 0x0035 // Host Number Of Completed Packets
+	opReadLinkSupervisionTimeout        = hostCtl<<10 | 0x0036 // Read Link Supervision Timeout
+	opWriteLinkSupervisionTimeout       = hostCtl<<10 | 0x0037 // Write Link Supervision Timeout
+	opReadNumSupportedIAC               = hostCtl<<10 | 0x0038 // Read Number Of Supported IAC
+	opReadCurrentIACLAP                 = hostCtl<<10 | 0x0039 // Read Current IAC LAP
+	opWriteCurrentIACLAP                = hostCtl<<10 | 0x003A // Write Current IAC LAP
+	opReadPageScanPeriodMode            = hostCtl<<10 | 0x003B
+	opWritePageScanPeriodMode           = hostCtl<<10 | 0x003C
+	opReadPageScanMode                  = hostCtl<<10 | 0x003D
+	opWritePageScanMode                 = hostCtl<<10 | 0x003E
+	opSetAFHClassification              = hostCtl<<10 | 0x003F // Set AFH Host Channel Classification
+	opReadInquiryScanType               = hostCtl<<10 | 0x0042 // Read Inquiry Scan Type
+	opWriteInquiryScanType              = hostCtl<<10 | 0x0043 // Write Inquiry Scan Type
+	opReadInquiryMode                   = hostCtl<<10 | 0x0044 // Read Inquiry Mode
+	opWriteInquiryMode                  = hostCtl<<10 | 0x0045 // Write Inquiry Mode
+	opReadPageScanType                  = hostCtl<<10 | 0x0046 // Read Page Scan Type
+	opWritePageScanType                 = hostCtl<<10 | 0x0047 // Write Page Scan Type
+	opReadAFHMode                       = hostCtl<<10 | 0x0048 // Read AFH Channel Assessment Mode
+	opWriteAFHMode                      = hostCtl<<10 | 0x0049 // Write AFH Channel Assesment Mode
+	opReadExtInquiryResponse            = hostCtl<<10 | 0x0051 // Read Extended Inquiry Response
+	opWriteExtInquiryResponse           = hostCtl<<10 | 0x0052 // Write Extended Inquiry Response
+	opRefreshEncryptionKey              = hostCtl<<10 | 0x0053 // Refresh Encryption Key
+	opReadSimplePairingMode             = hostCtl<<10 | 0x0055 // Read Simple Pairing Mode
+	opWriteSimplePairingMode            = hostCtl<<10 | 0x0056 // Write Simple Pairing Mode
+	opReadLocalOobData                  = hostCtl<<10 | 0x0057 // Read Local OOB Data
+	opReadInqResponseTransmitPowerLevel = hostCtl<<10 | 0x0058 // Read Inquiry Response Transmit Power Level
+	opWriteInquiryTransmitPowerLevel    = hostCtl<<10 | 0x0059 // Write Inquiry Response Transmit Power Level
+	opReadDefaultErrorDataReporting     = hostCtl<<10 | 0x005A // Read Default Erroneous Data Reporting
+	opWriteDefaultErrorDataReporting    = hostCtl<<10 | 0x005B // Write Default Erroneous Data Reporting
+	opEnhancedFlush                     = hostCtl<<10 | 0x005F // Enhanced Flush
+	opSendKeypressNotify                = hostCtl<<10 | 0x0060 // send Keypress Notification
+	opReadLogicalLinkAcceptTimeout      = hostCtl<<10 | 0x0061 // Read Logical Link Accept Timeout
+	opWriteLogicalLinkAcceptTimeout     = hostCtl<<10 | 0x0062 // Write Logical Link Accept Timeout
+	opSetEventMaskPage2                 = hostCtl<<10 | 0x0063 // Set Event Mask Page 2
+	opReadLocationData                  = hostCtl<<10 | 0x0064 // Read Location Data
+	opWriteLocationData                 = hostCtl<<10 | 0x0065 // Write Location Data
+	opReadFlowControlMode               = hostCtl<<10 | 0x0066 // Read Flow Control Mode
+	opWriteFlowControlMode              = hostCtl<<10 | 0x0067 // Write Flow Control Mode
+	opReadEnhancedTransmitpowerLevel    = hostCtl<<10 | 0x0068 // Read Enhanced Transmit Power Level
+	opReadBestEffortFlushTimeout        = hostCtl<<10 | 0x0069 // Read Best Effort Flush Timeout
+	opWriteBestEffortFlushTimeout       = hostCtl<<10 | 0x006A // Write Best Effort Flush Timeout
+	opReadLEHostSupported               = hostCtl<<10 | 0x006C // Read LE Host Supported
+	opWriteLEHostSupported              = hostCtl<<10 | 0x006D // Write LE Host Supported
+)
+const (
+	opReadLocalVersionInformation = infoParam<<10 | 0x0001 // Read Local Version Information
+	opReadLocalSupportedCommands  = infoParam<<10 | 0x0002 // Read Local Supported Commands
+	opReadLocalSupportedFeatures  = infoParam<<10 | 0x0003 // Read Local Supported Features
+	opReadLocalExtendedFeatures   = infoParam<<10 | 0x0004 // Read Local Extended Features
+	opReadBufferSize              = infoParam<<10 | 0x0005 // Read Buffer Size
+	opReadBDADDR                  = infoParam<<10 | 0x0009 // Read BD_ADDR
+	opReadDataBlockSize           = infoParam<<10 | 0x000A // Read Data Block Size
+	opReadLocalSupportedCodecs    = infoParam<<10 | 0x000B // Read Local Supported Codecs
+)
+const (
+	opLESetEventMask                      = leCtl<<10 | 0x0001 // LE Set Event Mask
+	opLEReadBufferSize                    = leCtl<<10 | 0x0002 // LE Read Buffer Size
+	opLEReadLocalSupportedFeatures        = leCtl<<10 | 0x0003 // LE Read Local Supported Features
+	opLESetRandomAddress                  = leCtl<<10 | 0x0005 // LE Set Random Address
+	opLESetAdvertisingParameters          = leCtl<<10 | 0x0006 // LE Set Advertising Parameters
+	opLEReadAdvertisingChannelTxPower     = leCtl<<10 | 0x0007 // LE Read Advertising Channel Tx Power
+	opLESetAdvertisingData                = leCtl<<10 | 0x0008 // LE Set Advertising Data
+	opLESetScanResponseData               = leCtl<<10 | 0x0009 // LE Set Scan Response Data
+	opLESetAdvertiseEnable                = leCtl<<10 | 0x000a // LE Set Advertising Enable
+	opLESetScanParameters                 = leCtl<<10 | 0x000b // LE Set Scan Parameters
+	opLESetScanEnable                     = leCtl<<10 | 0x000c // LE Set Scan Enable
+	opLECreateConn                        = leCtl<<10 | 0x000d // LE Create Connection
+	opLECreateConnCancel                  = leCtl<<10 | 0x000e // LE Create Connection Cancel
+	opLEReadWhiteListSize                 = leCtl<<10 | 0x000f // LE Read White List Size
+	opLEClearWhiteList                    = leCtl<<10 | 0x0010 // LE Clear White List
+	opLEAddDeviceToWhiteList              = leCtl<<10 | 0x0011 // LE Add Device To White List
+	opLERemoveDeviceFromWhiteList         = leCtl<<10 | 0x0012 // LE Remove Device From White List
+	opLEConnUpdate                        = leCtl<<10 | 0x0013 // LE Connection Update
+	opLESetHostChannelClassification      = leCtl<<10 | 0x0014 // LE Set Host Channel Classification
+	opLEReadChannelMap                    = leCtl<<10 | 0x0015 // LE Read Channel Map
+	opLEReadRemoteUsedFeatures            = leCtl<<10 | 0x0016 // LE Read Remote Used Features
+	opLEEncrypt                           = leCtl<<10 | 0x0017 // LE Encrypt
+	opLERand                              = leCtl<<10 | 0x0018 // LE Rand
+	opLEStartEncryption                   = leCtl<<10 | 0x0019 // LE Star Encryption
+	opLELTKReply                          = leCtl<<10 | 0x001a // LE Long Term Key Request Reply
+	opLELTKNegReply                       = leCtl<<10 | 0x001b // LE Long Term Key Request Negative Reply
+	opLEReadSupportedStates               = leCtl<<10 | 0x001c // LE Read Supported States
+	opLEReceiverTest                      = leCtl<<10 | 0x001d // LE Reciever Test
+	opLETransmitterTest                   = leCtl<<10 | 0x001e // LE Transmitter Test
+	opLETestEnd                           = leCtl<<10 | 0x001f // LE Test End
+	opLERemoteConnectionParameterReply    = leCtl<<10 | 0x0020 // LE Remote Connection Parameter Request Reply
+	opLERemoteConnectionParameterNegReply = leCtl<<10 | 0x0021 // LE Remote Connection Parameter Request Negative Reply
+)
+
+var o = util.Order
+
+// Link Control Commands
+
+// Disconnect (0x0006)
+type Disconnect struct {
+	ConnectionHandle uint16
+	Reason           uint8
+}
+
+func (c Disconnect) Opcode() int { return opDisconnect }
+func (c Disconnect) Len() int    { return 3 }
+func (c Disconnect) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.ConnectionHandle)
+	b[2] = c.Reason
+}
+
+// No Return Parameters, Check for Disconnection Complete Event
+type DisconnectRP struct{}
+
+// Link Policy Commands
+
+// Write Default Link Policy
+type WriteDefaultLinkPolicy struct{ DefaultLinkPolicySettings uint16 }
+
+func (c WriteDefaultLinkPolicy) Opcode() int      { return opWriteDefaultLinkPolicy }
+func (c WriteDefaultLinkPolicy) Len() int         { return 2 }
+func (c WriteDefaultLinkPolicy) Marshal(b []byte) { o.PutUint16(b, c.DefaultLinkPolicySettings) }
+
+type WriteDefaultLinkPolicyRP struct{ Status uint8 }
+
+// Host Control Commands
+
+// Set Event Mask (0x0001)
+type SetEventMask struct{ EventMask uint64 }
+
+func (c SetEventMask) Opcode() int      { return opSetEventMask }
+func (c SetEventMask) Len() int         { return 8 }
+func (c SetEventMask) Marshal(b []byte) { o.PutUint64(b, c.EventMask) }
+
+type SetEventMaskRP struct{ Status uint8 }
+
+// Reset (0x0002)
+type Reset struct{}
+
+func (c Reset) Opcode() int      { return opReset }
+func (c Reset) Len() int         { return 0 }
+func (c Reset) Marshal(b []byte) {}
+
+type ResetRP struct{ Status uint8 }
+
+// Set Event Filter (0x0003)
+// FIXME: This structures are overloading.
+// Both Marshal() and Len() are just placeholder.
+// Need more effort for decoding.
+// type SetEventFlt struct {
+// 	FilterType          uint8
+// 	FilterConditionType uint8
+// 	Condition           uint8
+// }
+
+// func (c SetEventFlt) Opcode() int   { return opSetEventFlt }
+// func (c SetEventFlt) Len() int         { return 0 }
+// func (c SetEventFlt) Marshal(b []byte) {}
+
+type SetEventFltRP struct{ Status uint8 }
+
+// Flush (0x0008)
+type Flush struct{ ConnectionHandle uint16 }
+
+func (c Flush) Opcode() int      { return opFlush }
+func (c Flush) Len() int         { return 2 }
+func (c Flush) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
+
+type flushRP struct{ status uint8 }
+
+// Write Page Timeout (0x0018)
+type WritePageTimeout struct{ PageTimeout uint16 }
+
+func (c WritePageTimeout) Opcode() int      { return opWritePageTimeout }
+func (c WritePageTimeout) Len() int         { return 2 }
+func (c WritePageTimeout) Marshal(b []byte) { o.PutUint16(b, c.PageTimeout) }
+
+type WritePageTimeoutRP struct{}
+
+// Write Class of Device (0x0024)
+type WriteClassOfDevice struct{ ClassOfDevice [3]byte }
+
+func (c WriteClassOfDevice) Opcode() int      { return opWriteClassOfDevice }
+func (c WriteClassOfDevice) Len() int         { return 3 }
+func (c WriteClassOfDevice) Marshal(b []byte) { copy(b, c.ClassOfDevice[:]) }
+
+type WriteClassOfDevRP struct{ status uint8 }
+
+// Write Host Buffer Size (0x0033)
+type HostBufferSize struct {
+	HostACLDataPacketLength            uint16
+	HostSynchronousDataPacketLength    uint8
+	HostTotalNumACLDataPackets         uint16
+	HostTotalNumSynchronousDataPackets uint16
+}
+
+func (c HostBufferSize) Opcode() int { return opHostBufferSize }
+func (c HostBufferSize) Len() int    { return 7 }
+func (c HostBufferSize) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.HostACLDataPacketLength)
+	o.PutUint8(b[2:], c.HostSynchronousDataPacketLength)
+	o.PutUint16(b[3:], c.HostTotalNumACLDataPackets)
+	o.PutUint16(b[5:], c.HostTotalNumSynchronousDataPackets)
+}
+
+type HostBufferSizeRP struct{ Status uint8 }
+
+// Write Inquiry Scan Type (0x0043)
+type WriteInquiryScanType struct{ ScanType uint8 }
+
+func (c WriteInquiryScanType) Opcode() int      { return opWriteInquiryScanType }
+func (c WriteInquiryScanType) Len() int         { return 1 }
+func (c WriteInquiryScanType) Marshal(b []byte) { b[0] = c.ScanType }
+
+type WriteInquiryScanTypeRP struct{ Status uint8 }
+
+// Write Inquiry Mode (0x0045)
+type WriteInquiryMode struct {
+	InquiryMode uint8
+}
+
+func (c WriteInquiryMode) Opcode() int      { return opWriteInquiryMode }
+func (c WriteInquiryMode) Len() int         { return 1 }
+func (c WriteInquiryMode) Marshal(b []byte) { b[0] = c.InquiryMode }
+
+type WriteInquiryModeRP struct{ Status uint8 }
+
+// Write Page Scan Type (0x0046)
+type WritePageScanType struct{ PageScanType uint8 }
+
+func (c WritePageScanType) Opcode() int      { return opWritePageScanType }
+func (c WritePageScanType) Len() int         { return 1 }
+func (c WritePageScanType) Marshal(b []byte) { b[0] = c.PageScanType }
+
+type WritePageScanTypeRP struct{ Status uint8 }
+
+// Write Simple Pairing Mode (0x0056)
+type WriteSimplePairingMode struct{ SimplePairingMode uint8 }
+
+func (c WriteSimplePairingMode) Opcode() int      { return opWriteSimplePairingMode }
+func (c WriteSimplePairingMode) Len() int         { return 1 }
+func (c WriteSimplePairingMode) Marshal(b []byte) { b[0] = c.SimplePairingMode }
+
+type WriteSimplePairingModeRP struct{}
+
+// Set Event Mask Page 2 (0x0063)
+type SetEventMaskPage2 struct{ EventMaskPage2 uint64 }
+
+func (c SetEventMaskPage2) Opcode() int      { return opSetEventMaskPage2 }
+func (c SetEventMaskPage2) Len() int         { return 8 }
+func (c SetEventMaskPage2) Marshal(b []byte) { o.PutUint64(b, c.EventMaskPage2) }
+
+type SetEventMaskPage2RP struct{ Status uint8 }
+
+// Write LE Host Supported (0x006D)
+type WriteLEHostSupported struct {
+	LESupportedHost    uint8
+	SimultaneousLEHost uint8
+}
+
+func (c WriteLEHostSupported) Opcode() int      { return opWriteLEHostSupported }
+func (c WriteLEHostSupported) Len() int         { return 2 }
+func (c WriteLEHostSupported) Marshal(b []byte) { b[0], b[1] = c.LESupportedHost, c.SimultaneousLEHost }
+
+type WriteLeHostSupportedRP struct{ Status uint8 }
+
+// LE Controller Commands
+
+// LE Set Event Mask (0x0001)
+type LESetEventMask struct{ LEEventMask uint64 }
+
+func (c LESetEventMask) Opcode() int      { return opLESetEventMask }
+func (c LESetEventMask) Len() int         { return 8 }
+func (c LESetEventMask) Marshal(b []byte) { o.PutUint64(b, c.LEEventMask) }
+
+type LESetEventMaskRP struct{ Status uint8 }
+
+// LE Read Buffer Size (0x0002)
+type LEReadBufferSize struct{}
+
+func (c LEReadBufferSize) Opcode() int      { return opLEReadBufferSize }
+func (c LEReadBufferSize) Len() int         { return 1 }
+func (c LEReadBufferSize) Marshal(b []byte) {}
+
+type LEReadBufferSizeRP struct {
+	Status                     uint8
+	HCLEACLDataPacketLength    uint16
+	HCTotalNumLEACLDataPackets uint8
+}
+
+// LE Read Local Supported Features (0x0003)
+type LEReadLocalSupportedFeatures struct{}
+
+func (c LEReadLocalSupportedFeatures) Opcode() int      { return opLEReadLocalSupportedFeatures }
+func (c LEReadLocalSupportedFeatures) Len() int         { return 0 }
+func (c LEReadLocalSupportedFeatures) Marshal(b []byte) {}
+
+type LEReadLocalSupportedFeaturesRP struct {
+	Status     uint8
+	LEFeatures uint64
+}
+
+// LE Set Random Address (0x0005)
+type LESetRandomAddress struct{ RandomAddress [6]byte }
+
+func (c LESetRandomAddress) Opcode() int      { return opLESetRandomAddress }
+func (c LESetRandomAddress) Len() int         { return 6 }
+func (c LESetRandomAddress) Marshal(b []byte) { o.PutMAC(b, c.RandomAddress) }
+
+type LESetRandomAddressRP struct{ Status uint8 }
+
+// LE Set Advertising Parameters (0x0006)
+type LESetAdvertisingParameters struct {
+	AdvertisingIntervalMin  uint16
+	AdvertisingIntervalMax  uint16
+	AdvertisingType         uint8
+	OwnAddressType          uint8
+	DirectAddressType       uint8
+	DirectAddress           [6]byte
+	AdvertisingChannelMap   uint8
+	AdvertisingFilterPolicy uint8
+}
+
+func (c LESetAdvertisingParameters) Opcode() int { return opLESetAdvertisingParameters }
+func (c LESetAdvertisingParameters) Len() int    { return 15 }
+func (c LESetAdvertisingParameters) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.AdvertisingIntervalMin)
+	o.PutUint16(b[2:], c.AdvertisingIntervalMax)
+	o.PutUint8(b[4:], c.AdvertisingType)
+	o.PutUint8(b[5:], c.OwnAddressType)
+	o.PutUint8(b[6:], c.DirectAddressType)
+	o.PutMAC(b[7:], c.DirectAddress)
+	o.PutUint8(b[13:], c.AdvertisingChannelMap)
+	o.PutUint8(b[14:], c.AdvertisingFilterPolicy)
+}
+
+type LESetAdvertisingParametersRP struct{ Status uint8 }
+
+// LE Read Advertising Channel Tx Power (0x0007)
+type LEReadAdvertisingChannelTxPower struct{}
+
+func (c LEReadAdvertisingChannelTxPower) Opcode() int      { return opLEReadAdvertisingChannelTxPower }
+func (c LEReadAdvertisingChannelTxPower) Len() int         { return 0 }
+func (c LEReadAdvertisingChannelTxPower) Marshal(b []byte) {}
+
+type LEReadAdvertisingChannelTxPowerRP struct {
+	Status             uint8
+	TransmitPowerLevel uint8
+}
+
+// LE Set Advertising Data (0x0008)
+type LESetAdvertisingData struct {
+	AdvertisingDataLength uint8
+	AdvertisingData       [31]byte
+}
+
+func (c LESetAdvertisingData) Opcode() int { return opLESetAdvertisingData }
+func (c LESetAdvertisingData) Len() int    { return 32 }
+func (c LESetAdvertisingData) Marshal(b []byte) {
+	b[0] = c.AdvertisingDataLength
+	copy(b[1:], c.AdvertisingData[:c.AdvertisingDataLength])
+}
+
+type LESetAdvertisingDataRP struct{ Status uint8 }
+
+// LE Set Scan Response Data (0x0009)
+type LESetScanResponseData struct {
+	ScanResponseDataLength uint8
+	ScanResponseData       [31]byte
+}
+
+func (c LESetScanResponseData) Opcode() int { return opLESetScanResponseData }
+func (c LESetScanResponseData) Len() int    { return 32 }
+func (c LESetScanResponseData) Marshal(b []byte) {
+	b[0] = c.ScanResponseDataLength
+	copy(b[1:], c.ScanResponseData[:c.ScanResponseDataLength])
+}
+
+type LESetScanResponseDataRP struct{ Status uint8 }
+
+// LE Set Advertising Enable (0x000A)
+type LESetAdvertiseEnable struct{ AdvertisingEnable uint8 }
+
+func (c LESetAdvertiseEnable) Opcode() int      { return opLESetAdvertiseEnable }
+func (c LESetAdvertiseEnable) Len() int         { return 1 }
+func (c LESetAdvertiseEnable) Marshal(b []byte) { b[0] = c.AdvertisingEnable }
+
+type LESetAdvertiseEnableRP struct{ Status uint8 }
+
+// LE Set Scan Parameters (0x000B)
+type LESetScanParameters struct {
+	LEScanType           uint8
+	LEScanInterval       uint16
+	LEScanWindow         uint16
+	OwnAddressType       uint8
+	ScanningFilterPolicy uint8
+}
+
+func (c LESetScanParameters) Opcode() int { return opLESetScanParameters }
+func (c LESetScanParameters) Len() int    { return 7 }
+func (c LESetScanParameters) Marshal(b []byte) {
+	o.PutUint8(b[0:], c.LEScanType)
+	o.PutUint16(b[1:], c.LEScanInterval)
+	o.PutUint16(b[3:], c.LEScanWindow)
+	o.PutUint8(b[5:], c.OwnAddressType)
+	o.PutUint8(b[6:], c.ScanningFilterPolicy)
+}
+
+type LESetScanParametersRP struct{ Status uint8 }
+
+// LE Set Scan Enable (0x000C)
+type LESetScanEnable struct {
+	LEScanEnable     uint8
+	FilterDuplicates uint8
+}
+
+func (c LESetScanEnable) Opcode() int      { return opLESetScanEnable }
+func (c LESetScanEnable) Len() int         { return 2 }
+func (c LESetScanEnable) Marshal(b []byte) { b[0], b[1] = c.LEScanEnable, c.FilterDuplicates }
+
+type LESetScanEnableRP struct{ Status uint8 }
+
+// LE Create Connection (0x000D)
+type LECreateConn struct {
+	LEScanInterval        uint16
+	LEScanWindow          uint16
+	InitiatorFilterPolicy uint8
+	PeerAddressType       uint8
+	PeerAddress           [6]byte
+	OwnAddressType        uint8
+	ConnIntervalMin       uint16
+	ConnIntervalMax       uint16
+	ConnLatency           uint16
+	SupervisionTimeout    uint16
+	MinimumCELength       uint16
+	MaximumCELength       uint16
+}
+
+func (c LECreateConn) Opcode() int { return opLECreateConn }
+func (c LECreateConn) Len() int    { return 25 }
+func (c LECreateConn) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.LEScanInterval)
+	o.PutUint16(b[2:], c.LEScanWindow)
+	o.PutUint8(b[4:], c.InitiatorFilterPolicy)
+	o.PutUint8(b[5:], c.PeerAddressType)
+	o.PutMAC(b[6:], c.PeerAddress)
+	o.PutUint8(b[12:], c.OwnAddressType)
+	o.PutUint16(b[13:], c.ConnIntervalMin)
+	o.PutUint16(b[15:], c.ConnIntervalMax)
+	o.PutUint16(b[17:], c.ConnLatency)
+	o.PutUint16(b[19:], c.SupervisionTimeout)
+	o.PutUint16(b[21:], c.MinimumCELength)
+	o.PutUint16(b[23:], c.MaximumCELength)
+}
+
+type LECreateConnRP struct{}
+
+// LE Create Connection Cancel (0x000E)
+type LECreateConnCancel struct{}
+
+func (c LECreateConnCancel) Opcode() int      { return opLECreateConnCancel }
+func (c LECreateConnCancel) Len() int         { return 0 }
+func (c LECreateConnCancel) Marshal(b []byte) {}
+
+type LECreateConnCancelRP struct{ Status uint8 }
+
+// LE Read White List Size (0x000F)
+type LEReadWhiteListSize struct{}
+
+func (c LEReadWhiteListSize) Opcode() int      { return opLEReadWhiteListSize }
+func (c LEReadWhiteListSize) Len() int         { return 0 }
+func (c LEReadWhiteListSize) Marshal(b []byte) {}
+
+type LEReadWhiteListSizeRP struct {
+	Status        uint8
+	WhiteListSize uint8
+}
+
+// LE Clear White List (0x0010)
+type LEClearWhiteList struct{}
+
+func (c LEClearWhiteList) Opcode() int      { return opLEClearWhiteList }
+func (c LEClearWhiteList) Len() int         { return 0 }
+func (c LEClearWhiteList) Marshal(b []byte) {}
+
+type LEClearWhiteListRP struct{ Status uint8 }
+
+// LE Add Device To White List (0x0011)
+type LEAddDeviceToWhiteList struct {
+	AddressType uint8
+	Address     [6]byte
+}
+
+func (c LEAddDeviceToWhiteList) Opcode() int { return opLEAddDeviceToWhiteList }
+func (c LEAddDeviceToWhiteList) Len() int    { return 7 }
+func (c LEAddDeviceToWhiteList) Marshal(b []byte) {
+	b[0] = c.AddressType
+	o.PutMAC(b[1:], c.Address)
+}
+
+type LEAddDeviceToWhiteListRP struct{ Status uint8 }
+
+// LE Remove Device From White List (0x0012)
+type LERemoveDeviceFromWhiteList struct {
+	AddressType uint8
+	Address     [6]byte
+}
+
+func (c LERemoveDeviceFromWhiteList) Opcode() int { return opLERemoveDeviceFromWhiteList }
+func (c LERemoveDeviceFromWhiteList) Len() int    { return 7 }
+func (c LERemoveDeviceFromWhiteList) Marshal(b []byte) {
+	b[0] = c.AddressType
+	o.PutMAC(b[1:], c.Address)
+}
+
+type LERemoveDeviceFromWhiteListRP struct{ Status uint8 }
+
+// LE Connection Update (0x0013)
+type LEConnUpdate struct {
+	ConnectionHandle   uint16
+	ConnIntervalMin    uint16
+	ConnIntervalMax    uint16
+	ConnLatency        uint16
+	SupervisionTimeout uint16
+	MinimumCELength    uint16
+	MaximumCELength    uint16
+}
+
+func (c LEConnUpdate) Opcode() int { return opLEConnUpdate }
+func (c LEConnUpdate) Len() int    { return 14 }
+func (c LEConnUpdate) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.ConnectionHandle)
+	o.PutUint16(b[2:], c.ConnIntervalMin)
+	o.PutUint16(b[4:], c.ConnIntervalMax)
+	o.PutUint16(b[6:], c.ConnLatency)
+	o.PutUint16(b[8:], c.SupervisionTimeout)
+	o.PutUint16(b[10:], c.MinimumCELength)
+	o.PutUint16(b[12:], c.MaximumCELength)
+}
+
+type LEConnUpdateRP struct{}
+
+// LE Set Host Channel Classification (0x0014)
+type LESetHostChannelClassification struct{ ChannelMap [5]byte }
+
+func (c LESetHostChannelClassification) Opcode() int      { return opLESetHostChannelClassification }
+func (c LESetHostChannelClassification) Len() int         { return 5 }
+func (c LESetHostChannelClassification) Marshal(b []byte) { copy(b, c.ChannelMap[:]) }
+
+type LESetHostChannelClassificationRP struct{ Status uint8 }
+
+// LE Read Channel Map (0x0015)
+type LEReadChannelMap struct{ ConnectionHandle uint16 }
+
+func (c LEReadChannelMap) Opcode() int      { return opLEReadChannelMap }
+func (c LEReadChannelMap) Len() int         { return 2 }
+func (c LEReadChannelMap) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
+
+type LEReadChannelMapRP struct {
+	Status           uint8
+	ConnectionHandle uint16
+	ChannelMap       [5]byte
+}
+
+// LE Read Remote Used Features (0x0016)
+type LEReadRemoteUsedFeatures struct{ ConnectionHandle uint16 }
+
+func (c LEReadRemoteUsedFeatures) Opcode() int      { return opLEReadRemoteUsedFeatures }
+func (c LEReadRemoteUsedFeatures) Len() int         { return 8 }
+func (c LEReadRemoteUsedFeatures) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
+
+type LEReadRemoteUsedFeaturesRP struct{}
+
+// LE Encrypt (0x0017)
+type LEEncrypt struct {
+	Key           [16]byte
+	PlaintextData [16]byte
+}
+
+func (c LEEncrypt) Opcode() int { return opLEEncrypt }
+func (c LEEncrypt) Len() int    { return 32 }
+func (c LEEncrypt) Marshal(b []byte) {
+	copy(b[0:], c.Key[:])
+	copy(b[16:], c.PlaintextData[:])
+}
+
+type LEEncryptRP struct {
+	Stauts        uint8
+	EncryptedData [16]byte
+}
+
+// LE Rand (0x0018)
+type LERand struct{}
+
+func (c LERand) Opcode() int      { return opLERand }
+func (c LERand) Len() int         { return 0 }
+func (c LERand) Marshal(b []byte) {}
+
+type LERandRP struct {
+	Status       uint8
+	RandomNumber uint64
+}
+
+// LE Start Encryption (0x0019)
+type LEStartEncryption struct {
+	ConnectionHandle     uint16
+	RandomNumber         uint64
+	EncryptedDiversifier uint16
+	LongTermKey          [16]byte
+}
+
+func (c LEStartEncryption) Opcode() int { return opLEStartEncryption }
+func (c LEStartEncryption) Len() int    { return 28 }
+func (c LEStartEncryption) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.ConnectionHandle)
+	o.PutUint64(b[2:], c.RandomNumber)
+	o.PutUint16(b[10:], c.EncryptedDiversifier)
+	copy(b[12:], c.LongTermKey[:])
+}
+
+type LEStartEncryptionRP struct{}
+
+// LE Long Term Key Reply (0x001A)
+type LELTKReply struct {
+	ConnectionHandle uint16
+	LongTermKey      [16]byte
+}
+
+func (c LELTKReply) Opcode() int { return opLELTKReply }
+func (c LELTKReply) Len() int    { return 18 }
+func (c LELTKReply) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.ConnectionHandle)
+	copy(b[2:], c.LongTermKey[:])
+}
+
+type LELTKReplyRP struct {
+	Status           uint8
+	ConnectionHandle uint16
+}
+
+// LE Long Term Key  Negative Reply (0x001B)
+type LELTKNegReply struct{ ConnectionHandle uint16 }
+
+func (c LELTKNegReply) Opcode() int      { return opLELTKNegReply }
+func (c LELTKNegReply) Len() int         { return 2 }
+func (c LELTKNegReply) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
+
+type LELTKNegReplyRP struct {
+	Status           uint8
+	ConnectionHandle uint16
+}
+
+// LE Read Supported States (0x001C)
+type LEReadSupportedStates struct{}
+
+func (c LEReadSupportedStates) Opcode() int      { return opLEReadSupportedStates }
+func (c LEReadSupportedStates) Len() int         { return 0 }
+func (c LEReadSupportedStates) Marshal(b []byte) {}
+
+type LEReadSupportedStatesRP struct {
+	Status   uint8
+	LEStates [8]byte
+}
+
+// LE Reciever Test (0x001D)
+type LEReceiverTest struct{ RxChannel uint8 }
+
+func (c LEReceiverTest) Opcode() int      { return opLEReceiverTest }
+func (c LEReceiverTest) Len() int         { return 1 }
+func (c LEReceiverTest) Marshal(b []byte) { b[0] = c.RxChannel }
+
+type LEReceiverTestRP struct{ Status uint8 }
+
+// LE Transmitter Test (0x001E)
+type LETransmitterTest struct {
+	TxChannel        uint8
+	LengthOfTestData uint8
+	PacketPayload    uint8
+}
+
+func (c LETransmitterTest) Opcode() int { return opLETransmitterTest }
+func (c LETransmitterTest) Len() int    { return 3 }
+func (c LETransmitterTest) Marshal(b []byte) {
+	b[0], b[1], b[2] = c.TxChannel, c.LengthOfTestData, c.PacketPayload
+}
+
+type LETransmitterTestRP struct{ Status uint8 }
+
+// LE Test End (0x001F)
+type LETestEnd struct{}
+
+func (c LETestEnd) Opcode() int      { return opLETestEnd }
+func (c LETestEnd) Len() int         { return 0 }
+func (c LETestEnd) Marshal(b []byte) {}
+
+type LETestEndRP struct {
+	Status          uint8
+	NumberOfPackets uint16
+}
+
+// LE Remote Connection Parameters Reply (0x0020)
+type LERemoteConnectionParameterReply struct {
+	ConnectionHandle uint16
+	IntervalMin      uint16
+	IntervalMax      uint16
+	Latency          uint16
+	Timeout          uint16
+	MinimumCELength  uint16
+	MaximumCELength  uint16
+}
+
+func (c LERemoteConnectionParameterReply) Opcode() int { return opLERemoteConnectionParameterReply }
+func (c LERemoteConnectionParameterReply) Len() int    { return 14 }
+func (c LERemoteConnectionParameterReply) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.ConnectionHandle)
+	o.PutUint16(b[2:], c.IntervalMin)
+	o.PutUint16(b[4:], c.IntervalMax)
+	o.PutUint16(b[6:], c.Latency)
+	o.PutUint16(b[8:], c.Timeout)
+	o.PutUint16(b[10:], c.MinimumCELength)
+	o.PutUint16(b[12:], c.MaximumCELength)
+}
+
+type LERemoteConnectionParameterReplyRP struct {
+	Status           uint8
+	ConnectionHandle uint16
+}
+
+// LE Remote Connection Parameters Negative Reply (0x0021)
+type LERemoteConnectionParameterNegReply struct {
+	ConnectionHandle uint16
+	Reason           uint8
+}
+
+func (c LERemoteConnectionParameterNegReply) Opcode() int {
+	return opLERemoteConnectionParameterNegReply
+}
+func (c LERemoteConnectionParameterNegReply) Len() int { return 3 }
+func (c LERemoteConnectionParameterNegReply) Marshal(b []byte) {
+	o.PutUint16(b[0:], c.ConnectionHandle)
+	b[2] = c.Reason
+}
+
+type LERemoteConnectionParameterNegReplyRP struct {
+	Status           uint8
+	ConnectionHandle uint16
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/const.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/const.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/const.go
new file mode 100644
index 0000000..8c0a140
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/const.go
@@ -0,0 +1,21 @@
+package linux
+
+type packetType uint8
+
+// HCI Packet types
+const (
+	typCommandPkt packetType = 0X01
+	typACLDataPkt            = 0X02
+	typSCODataPkt            = 0X03
+	typEventPkt              = 0X04
+	typVendorPkt             = 0XFF
+)
+
+// Event Type
+const (
+	advInd        = 0x00 // Connectable undirected advertising (ADV_IND).
+	advDirectInd  = 0x01 // Connectable directed advertising (ADV_DIRECT_IND)
+	advScanInd    = 0x02 // Scannable undirected advertising (ADV_SCAN_IND)
+	advNonconnInd = 0x03 // Non connectable undirected advertising (ADV_NONCONN_IND)
+	scanRsp       = 0x04 // Scan Response (SCAN_RSP)
+)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/device.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/device.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/device.go
new file mode 100644
index 0000000..402c5eb
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/device.go
@@ -0,0 +1,109 @@
+package linux
+
+import (
+	"errors"
+	"log"
+	"sync"
+	"syscall"
+	"unsafe"
+
+	"github.com/runtimeco/gatt/linux/gioctl"
+	"github.com/runtimeco/gatt/linux/socket"
+)
+
+type device struct {
+	fd   int
+	dev  int
+	name string
+	rmu  *sync.Mutex
+	wmu  *sync.Mutex
+}
+
+func newDevice(n int, chk bool) (*device, error) {
+	fd, err := socket.Socket(socket.AF_BLUETOOTH, syscall.SOCK_RAW, socket.BTPROTO_HCI)
+	if err != nil {
+		return nil, err
+	}
+	if n != -1 {
+		return newSocket(fd, n, chk)
+	}
+
+	req := devListRequest{devNum: hciMaxDevices}
+	if err := gioctl.Ioctl(uintptr(fd), hciGetDeviceList, uintptr(unsafe.Pointer(&req))); err != nil {
+		return nil, err
+	}
+	for i := 0; i < int(req.devNum); i++ {
+		d, err := newSocket(fd, i, chk)
+		if err == nil {
+			log.Printf("dev: %s opened", d.name)
+			return d, err
+		}
+	}
+	return nil, errors.New("no supported devices available")
+}
+
+func newSocket(fd, n int, chk bool) (*device, error) {
+	i := hciDevInfo{id: uint16(n)}
+	if err := gioctl.Ioctl(uintptr(fd), hciGetDeviceInfo, uintptr(unsafe.Pointer(&i))); err != nil {
+		return nil, err
+	}
+	name := string(i.name[:])
+	// Check the feature list returned feature list.
+	if chk && i.features[4]&0x40 == 0 {
+		err := errors.New("does not support LE")
+		log.Printf("dev: %s %s", name, err)
+		return nil, err
+	}
+	log.Printf("dev: %s up", name)
+	if err := gioctl.Ioctl(uintptr(fd), hciUpDevice, uintptr(n)); err != nil {
+		if err != syscall.EALREADY {
+			return nil, err
+		}
+		log.Printf("dev: %s reset", name)
+		if err := gioctl.Ioctl(uintptr(fd), hciResetDevice, uintptr(n)); err != nil {
+			return nil, err
+		}
+	}
+	log.Printf("dev: %s down", name)
+	if err := gioctl.Ioctl(uintptr(fd), hciDownDevice, uintptr(n)); err != nil {
+		return nil, err
+	}
+
+	// Attempt to use the linux 3.14 feature, if this fails with EINVAL fall back to raw access
+	// on older kernels.
+	sa := socket.SockaddrHCI{Dev: n, Channel: socket.HCI_CHANNEL_USER}
+	if err := socket.Bind(fd, &sa); err != nil {
+		if err != syscall.EINVAL {
+			return nil, err
+		}
+		log.Printf("dev: %s can't bind to hci user channel, err: %s.", name, err)
+		sa := socket.SockaddrHCI{Dev: n, Channel: socket.HCI_CHANNEL_RAW}
+		if err := socket.Bind(fd, &sa); err != nil {
+			log.Printf("dev: %s can't bind to hci raw channel, err: %s.", name, err)
+			return nil, err
+		}
+	}
+	return &device{
+		fd:   fd,
+		dev:  n,
+		name: name,
+		rmu:  &sync.Mutex{},
+		wmu:  &sync.Mutex{},
+	}, nil
+}
+
+func (d device) Read(b []byte) (int, error) {
+	d.rmu.Lock()
+	defer d.rmu.Unlock()
+	return syscall.Read(d.fd, b)
+}
+
+func (d device) Write(b []byte) (int, error) {
+	d.wmu.Lock()
+	defer d.wmu.Unlock()
+	return syscall.Write(d.fd, b)
+}
+
+func (d device) Close() error {
+	return syscall.Close(d.fd)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/devices.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/devices.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/devices.go
new file mode 100644
index 0000000..1c9c13c
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/devices.go
@@ -0,0 +1,58 @@
+package linux
+
+import "github.com/runtimeco/gatt/linux/gioctl"
+
+const (
+	ioctlSize     = uintptr(4)
+	hciMaxDevices = 16
+	typHCI        = 72 // 'H'
+)
+
+var (
+	hciUpDevice      = gioctl.IoW(typHCI, 201, ioctlSize) // HCIDEVUP
+	hciDownDevice    = gioctl.IoW(typHCI, 202, ioctlSize) // HCIDEVDOWN
+	hciResetDevice   = gioctl.IoW(typHCI, 203, ioctlSize) // HCIDEVRESET
+	hciGetDeviceList = gioctl.IoR(typHCI, 210, ioctlSize) // HCIGETDEVLIST
+	hciGetDeviceInfo = gioctl.IoR(typHCI, 211, ioctlSize) // HCIGETDEVINFO
+)
+
+type devRequest struct {
+	id  uint16
+	opt uint32
+}
+
+type devListRequest struct {
+	devNum     uint16
+	devRequest [hciMaxDevices]devRequest
+}
+
+type hciDevInfo struct {
+	id         uint16
+	name       [8]byte
+	bdaddr     [6]byte
+	flags      uint32
+	devType    uint8
+	features   [8]uint8
+	pktType    uint32
+	linkPolicy uint32
+	linkMode   uint32
+	aclMtu     uint16
+	aclPkts    uint16
+	scoMtu     uint16
+	scoPkts    uint16
+
+	stats hciDevStats
+}
+
+type hciDevStats struct {
+	errRx  uint32
+	errTx  uint32
+	cmdTx  uint32
+	evtRx  uint32
+	aclTx  uint32
+	aclRx  uint32
+	scoTx  uint32
+	scoRx  uint32
+	byteRx uint32
+	byteTx uint32
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/doc.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/doc.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/doc.go
new file mode 100644
index 0000000..c41c53e
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/doc.go
@@ -0,0 +1,5 @@
+// Package linux provides linux-specific support for gatt.
+//
+// This package is work in progress. We expect the APIs to change significantly before stabilizing.
+
+package linux

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/evt/evt.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/evt/evt.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/evt/evt.go
new file mode 100644
index 0000000..2981e51
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/evt/evt.go
@@ -0,0 +1,382 @@
+package evt
+
+import (
+	"bytes"
+	"encoding/binary"
+	"errors"
+
+	"github.com/runtimeco/gatt/linux/util"
+)
+
+type EventHandler interface {
+	HandleEvent([]byte) error
+}
+
+type HandlerFunc func(b []byte) error
+
+func (f HandlerFunc) HandleEvent(b []byte) error {
+	return f(b)
+}
+
+type Evt struct {
+	evtHandlers map[int]EventHandler
+}
+
+func NewEvt() *Evt {
+	return &Evt{
+		evtHandlers: map[int]EventHandler{},
+	}
+}
+
+func (e *Evt) HandleEvent(c int, h EventHandler) {
+	e.evtHandlers[c] = h
+}
+
+func (e *Evt) Dispatch(b []byte) error {
+	h := &EventHeader{}
+	if err := h.Unmarshal(b); err != nil {
+		return err
+	}
+	b = b[2:] // Skip Event Header (uint8 + uint8)
+	if f, found := e.evtHandlers[h.code]; found {
+		e.trace("> HCI Event: %s (0x%02X) plen %d: [ % X ])\n", h.code, uint8(h.code), h.plen, b)
+		return f.HandleEvent(b)
+	}
+	e.trace("> HCI Event: no handler for %s (0x%02X)\n", h.code, uint8(h.code))
+	return nil
+}
+
+func (e *Evt) trace(fmt string, v ...interface{}) {}
+
+const (
+	InquiryComplete                              = 0x01 // Inquiry Complete
+	InquiryResult                                = 0x02 // Inquiry Result
+	ConnectionComplete                           = 0x03 // Connection Complete
+	ConnectionRequest                            = 0x04 // Connection Request
+	DisconnectionComplete                        = 0x05 // Disconnection Complete
+	AuthenticationComplete                       = 0x06 // Authentication
+	RemoteNameReqComplete                        = 0x07 // Remote Name Request Complete
+	EncryptionChange                             = 0x08 // Encryption Change
+	ChangeConnectionLinkKeyComplete              = 0x09 // Change Conection Link Key Complete
+	MasterLinkKeyComplete                        = 0x0A // Master Link Keye Complete
+	ReadRemoteSupportedFeaturesComplete          = 0x0B // Read Remote Supported Features Complete
+	ReadRemoteVersionInformationComplete         = 0x0C // Read Remote Version Information Complete
+	QoSSetupComplete                             = 0x0D // QoSSetupComplete
+	CommandComplete                              = 0x0E // Command Complete
+	CommandStatus                                = 0x0F // Command status
+	HardwareError                                = 0x10 // Hardware Error
+	FlushOccurred                                = 0x11 // Flush Occured
+	RoleChange                                   = 0x12 // Role Change
+	NumberOfCompletedPkts                        = 0x13 // Number Of Completed Packets
+	ModeChange                                   = 0x14 // Mode Change
+	ReturnLinkKeys                               = 0x15 // Return Link Keys
+	PinCodeRequest                               = 0x16 // PIN Code Request
+	LinkKeyRequest                               = 0x17 // Link Key Request
+	LinkKeyNotification                          = 0x18 // Link Key Notification
+	LoopbackCommand                              = 0x19 // Loopback Command
+	DataBufferOverflow                           = 0x1A // Data Buffer Overflow
+	MaxSlotsChange                               = 0x1B // Max Slots Change
+	ReadClockOffsetComplete                      = 0x1C // Read Clock Offset Complete
+	ConnectionPtypeChanged                       = 0x1D // Connection Packet Type Changed
+	QoSViolation                                 = 0x1E // QoS Violation
+	PageScanRepetitionModeChange                 = 0x20 // Page Scan Repetition Mode Change
+	FlowSpecificationComplete                    = 0x21 // Flow Specification
+	InquiryResultWithRssi                        = 0x22 // Inquery Result with RSSI
+	ReadRemoteExtendedFeaturesComplete           = 0x23 // Read Remote Extended Features Complete
+	SyncConnectionComplete                       = 0x2C // Synchronous Connection Complete
+	SyncConnectionChanged                        = 0x2D // Synchronous Connection Changed
+	SniffSubrating                               = 0x2E // Sniff Subrating
+	ExtendedInquiryResult                        = 0x2F // Extended Inquiry Result
+	EncryptionKeyRefreshComplete                 = 0x30 // Encryption Key Refresh Complete
+	IOCapabilityRequest                          = 0x31 // IO Capability Request
+	IOCapabilityResponse                         = 0x32 // IO Capability Changed
+	UserConfirmationRequest                      = 0x33 // User Confirmation Request
+	UserPasskeyRequest                           = 0x34 // User Passkey Request
+	RemoteOOBDataRequest                         = 0x35 // Remote OOB Data
+	SimplePairingComplete                        = 0x36 // Simple Pairing Complete
+	LinkSupervisionTimeoutChanged                = 0x38 // Link Supervision Timeout Changed
+	EnhancedFlushComplete                        = 0x39 // Enhanced Flush Complete
+	UserPasskeyNotify                            = 0x3B // User Passkey Notification
+	KeypressNotify                               = 0x3C // Keypass Notification
+	RemoteHostFeaturesNotify                     = 0x3D // Remote Host Supported Features Notification
+	LEMeta                                       = 0x3E // LE Meta
+	PhysicalLinkComplete                         = 0x40 // Physical Link Complete
+	ChannelSelected                              = 0x41 // Channel Selected
+	DisconnectionPhysicalLinkComplete            = 0x42 // Disconnection Physical Link Complete
+	PhysicalLinkLossEarlyWarning                 = 0x43 // Physical Link Loss Early Warning
+	PhysicalLinkRecovery                         = 0x44 // Physical Link Recovery
+	LogicalLinkComplete                          = 0x45 // Logical Link Complete
+	DisconnectionLogicalLinkComplete             = 0x46 // Disconnection Logical Link Complete
+	FlowSpecModifyComplete                       = 0x47 // Flow Spec Modify Complete
+	NumberOfCompletedBlocks                      = 0x48 // Number Of Completed Data Blocks
+	AMPStartTest                                 = 0x49 // AMP Start Test
+	AMPTestEnd                                   = 0x4A // AMP Test End
+	AMPReceiverReport                            = 0x4b // AMP Receiver Report
+	AMPStatusChange                              = 0x4D // AMP status Change
+	TriggeredClockCapture                        = 0x4e // Triggered Clock Capture
+	SynchronizationTrainComplete                 = 0x4F // Synchronization Train Complete
+	SynchronizationTrainReceived                 = 0x50 // Synchronization Train Received
+	ConnectionlessSlaveBroadcastReceive          = 0x51 // Connectionless Slave Broadcast Receive
+	ConnectionlessSlaveBroadcastTimeout          = 0x52 // Connectionless Slave Broadcast Timeout
+	TruncatedPageComplete                        = 0x53 // Truncated Page Complete
+	SlavePageResponseTimeout                     = 0x54 // Slave Page Response Timeout
+	ConnectionlessSlaveBroadcastChannelMapChange = 0x55 // Connectionless Slave Broadcast Channel Map Change
+	InquiryResponseNotification                  = 0x56 // Inquiry Response Notification
+	AuthenticatedPayloadTimeoutExpired           = 0x57 // Authenticated Payload Timeout Expired
+)
+
+type LEEventCode int
+
+const (
+	LEConnectionComplete               LEEventCode = 0x01 // LE Connection Complete
+	LEAdvertisingReport                            = 0x02 // LE Advertising Report
+	LEConnectionUpdateComplete                     = 0x03 // LE Connection Update Complete
+	LEReadRemoteUsedFeaturesComplete               = 0x04 // LE Read Remote Used Features Complete
+	LELTKRequest                                   = 0x05 // LE LTK Request
+	LERemoteConnectionParameterRequest             = 0x06 // LE Remote Connection Parameter Request
+)
+
+type EventHeader struct {
+	code int
+	plen uint8
+}
+
+func (h *EventHeader) Unmarshal(b []byte) error {
+	if len(b) < 2 {
+		return errors.New("malformed header")
+	}
+	h.code = int(b[0])
+	h.plen = b[1]
+	if uint8(len(b)) != 2+h.plen {
+		return errors.New("wrong length")
+	}
+	return nil
+}
+
+var o = util.Order
+
+// Event Parameters
+
+type InquiryCompleteEP struct {
+	Status uint8
+}
+
+type InquiryResultEP struct {
+	NumResponses           uint8
+	BDAddr                 [][6]byte
+	PageScanRepetitionMode []uint8
+	Reserved1              []byte
+	Reserved2              []byte
+	ClassOfDevice          [][3]byte
+	ClockOffset            []uint16
+}
+
+type ConnectionCompleteEP struct {
+	Status            uint8
+	ConnectionHandle  uint16
+	BDAddr            [6]byte
+	LinkType          uint8
+	EncryptionEnabled uint8
+}
+
+type ConnectionRequestEP struct {
+	BDAddr        [6]byte
+	ClassofDevice [3]byte
+	LinkType      uint8
+}
+
+type DisconnectionCompleteEP struct {
+	Status           uint8
+	ConnectionHandle uint16
+	Reason           uint8
+}
+
+func (e *DisconnectionCompleteEP) Unmarshal(b []byte) error {
+	buf := bytes.NewBuffer(b)
+	binary.Read(buf, binary.LittleEndian, &e.Status)
+	binary.Read(buf, binary.LittleEndian, &e.ConnectionHandle)
+	return binary.Read(buf, binary.LittleEndian, &e.Reason)
+}
+
+type CommandCompleteEP struct {
+	NumHCICommandPackets uint8
+	CommandOPCode        uint16
+	ReturnParameters     []byte
+}
+
+func (e *CommandCompleteEP) Unmarshal(b []byte) error {
+	buf := bytes.NewBuffer(b)
+	if err := binary.Read(buf, binary.LittleEndian, &e.NumHCICommandPackets); err != nil {
+		return err
+	}
+	if err := binary.Read(buf, binary.LittleEndian, &e.CommandOPCode); err != nil {
+		return err
+	}
+	e.ReturnParameters = buf.Bytes()
+	return nil
+}
+
+type CommandStatusEP struct {
+	Status               uint8
+	NumHCICommandPackets uint8
+	CommandOpcode        uint16
+}
+
+func (e *CommandStatusEP) Unmarshal(b []byte) error {
+	buf := bytes.NewBuffer(b)
+	binary.Read(buf, binary.LittleEndian, &e.Status)
+	binary.Read(buf, binary.LittleEndian, &e.NumHCICommandPackets)
+	return binary.Read(buf, binary.LittleEndian, &e.CommandOpcode)
+}
+
+type NumOfCompletedPkt struct {
+	ConnectionHandle   uint16
+	NumOfCompletedPkts uint16
+}
+
+type NumberOfCompletedPktsEP struct {
+	NumberOfHandles uint8
+	Packets         []NumOfCompletedPkt
+}
+
+func (e *NumberOfCompletedPktsEP) Unmarshal(b []byte) error {
+	e.NumberOfHandles = b[0]
+	n := int(e.NumberOfHandles)
+	buf := bytes.NewBuffer(b[1:])
+	e.Packets = make([]NumOfCompletedPkt, n)
+	for i := 0; i < n; i++ {
+		binary.Read(buf, binary.LittleEndian, &e.Packets[i].ConnectionHandle)
+		binary.Read(buf, binary.LittleEndian, &e.Packets[i].NumOfCompletedPkts)
+
+		e.Packets[i].ConnectionHandle &= 0xfff
+	}
+	return nil
+}
+
+// LE Meta Subevents
+type LEConnectionCompleteEP struct {
+	SubeventCode        uint8
+	Status              uint8
+	ConnectionHandle    uint16
+	Role                uint8
+	PeerAddressType     uint8
+	PeerAddress         [6]byte
+	ConnInterval        uint16
+	ConnLatency         uint16
+	SupervisionTimeout  uint16
+	MasterClockAccuracy uint8
+}
+
+func (e *LEConnectionCompleteEP) Unmarshal(b []byte) error {
+	e.SubeventCode = o.Uint8(b[0:])
+	e.Status = o.Uint8(b[1:])
+	e.ConnectionHandle = o.Uint16(b[2:])
+	e.Role = o.Uint8(b[4:])
+	e.PeerAddressType = o.Uint8(b[5:])
+	e.PeerAddress = o.MAC(b[6:])
+	e.ConnInterval = o.Uint16(b[12:])
+	e.ConnLatency = o.Uint16(b[14:])
+	e.SupervisionTimeout = o.Uint16(b[16:])
+	e.MasterClockAccuracy = o.Uint8(b[17:])
+	return nil
+}
+
+type LEAdvertisingReportEP struct {
+	SubeventCode uint8
+	NumReports   uint8
+	EventType    []uint8
+	AddressType  []uint8
+	Address      [][6]byte
+	Length       []uint8
+	Data         [][]byte
+	RSSI         []int8
+}
+
+func (e *LEAdvertisingReportEP) Unmarshal(b []byte) error {
+	e.SubeventCode = o.Uint8(b)
+	b = b[1:]
+	e.NumReports = o.Uint8(b)
+	b = b[1:]
+	n := int(e.NumReports)
+	e.EventType = make([]uint8, n)
+	e.AddressType = make([]uint8, n)
+	e.Address = make([][6]byte, n)
+	e.Length = make([]uint8, n)
+	e.Data = make([][]byte, n)
+	e.RSSI = make([]int8, n)
+
+	for i := 0; i < n; i++ {
+		e.EventType[i] = o.Uint8(b)
+		b = b[1:]
+	}
+	for i := 0; i < n; i++ {
+		e.AddressType[i] = o.Uint8(b)
+		b = b[1:]
+	}
+	for i := 0; i < n; i++ {
+		e.Address[i] = o.MAC(b)
+		b = b[6:]
+	}
+	for i := 0; i < n; i++ {
+		e.Length[i] = o.Uint8(b)
+		b = b[1:]
+	}
+	for i := 0; i < n; i++ {
+		e.Data[i] = make([]byte, e.Length[i])
+		copy(e.Data[i], b)
+		b = b[e.Length[i]:]
+	}
+	for i := 0; i < n; i++ {
+		e.RSSI[i] = o.Int8(b)
+		b = b[1:]
+	}
+	return nil
+}
+
+type LEConnectionUpdateCompleteEP struct {
+	SubeventCode       uint8
+	Status             uint8
+	ConnectionHandle   uint16
+	ConnInterval       uint16
+	ConnLatency        uint16
+	SupervisionTimeout uint16
+}
+
+func (e *LEConnectionUpdateCompleteEP) Unmarshal(b []byte) error {
+	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
+}
+
+type LEReadRemoteUsedFeaturesCompleteEP struct {
+	SubeventCode     uint8
+	Status           uint8
+	ConnectionHandle uint16
+	LEFeatures       uint64
+}
+
+func (e *LEReadRemoteUsedFeaturesCompleteEP) Unmarshal(b []byte) error {
+	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
+}
+
+type LELTKRequestEP struct {
+	SubeventCode          uint8
+	ConnectionHandle      uint16
+	RandomNumber          uint64
+	EncryptionDiversifier uint16
+}
+
+func (e *LELTKRequestEP) Unmarshal(b []byte) error {
+	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
+}
+
+type LERemoteConnectionParameterRequestEP struct {
+	SubeventCode     uint8
+	ConnectionHandle uint16
+	IntervalMin      uint16
+	IntervalMax      uint16
+	Latency          uint16
+	Timeout          uint16
+}
+
+func (e *LERemoteConnectionParameterRequestEP) Unmarshal(b []byte) error {
+	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/LICENSE.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/LICENSE.md b/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/LICENSE.md
new file mode 100644
index 0000000..1e1b7cd
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/LICENSE.md
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Mark Wolfe
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/README.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/README.md b/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/README.md
new file mode 100644
index 0000000..837fa03
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/README.md
@@ -0,0 +1,12 @@
+# gioctl [![GoDoc](https://img.shields.io/badge/godoc-Reference-brightgreen.svg?style=flat)](http://godoc.org/github.com/wolfeidau/gioctl)
+
+Simple library which provides golang versions of the ioctl macros in linux.
+
+# References
+
+* https://github.com/luismesas/goPi started with the IOCTL stuff from this project initally.
+* http://www.circlemud.org/jelson/software/fusd/docs/node31.html good information on IOCTL macros.
+
+# License
+
+This code is Copyright (c) 2014 Mark Wolfe and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/ioctl.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/ioctl.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/ioctl.go
new file mode 100644
index 0000000..0097459
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/gioctl/ioctl.go
@@ -0,0 +1,57 @@
+package gioctl
+
+import "syscall"
+
+const (
+	typeBits      = 8
+	numberBits    = 8
+	sizeBits      = 14
+	directionBits = 2
+
+	typeMask      = (1 << typeBits) - 1
+	numberMask    = (1 << numberBits) - 1
+	sizeMask      = (1 << sizeBits) - 1
+	directionMask = (1 << directionBits) - 1
+
+	directionNone  = 0
+	directionWrite = 1
+	directionRead  = 2
+
+	numberShift    = 0
+	typeShift      = numberShift + numberBits
+	sizeShift      = typeShift + typeBits
+	directionShift = sizeShift + sizeBits
+)
+
+func ioc(dir, t, nr, size uintptr) uintptr {
+	return (dir << directionShift) | (t << typeShift) | (nr << numberShift) | (size << sizeShift)
+}
+
+// Io used for a simple ioctl that sends nothing but the type and number, and receives back nothing but an (integer) retval.
+func Io(t, nr uintptr) uintptr {
+	return ioc(directionNone, t, nr, 0)
+}
+
+// IoR used for an ioctl that reads data from the device driver. The driver will be allowed to return sizeof(data_type) bytes to the user.
+func IoR(t, nr, size uintptr) uintptr {
+	return ioc(directionRead, t, nr, size)
+}
+
+// IoW used for an ioctl that writes data to the device driver.
+func IoW(t, nr, size uintptr) uintptr {
+	return ioc(directionWrite, t, nr, size)
+}
+
+// IoRW  a combination of IoR and IoW. That is, data is both written to the driver and then read back from the driver by the client.
+func IoRW(t, nr, size uintptr) uintptr {
+	return ioc(directionRead|directionWrite, t, nr, size)
+}
+
+// Ioctl simplified ioct call
+func Ioctl(fd, op, arg uintptr) error {
+	_, _, ep := syscall.Syscall(syscall.SYS_IOCTL, fd, op, arg)
+	if ep != 0 {
+		return syscall.Errno(ep)
+	}
+	return nil
+}


[5/7] incubator-mynewt-newt git commit: MYNEWT-653 Use runtimeco gatt fork.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/hci.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/hci.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/hci.go
new file mode 100644
index 0000000..967680d
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/hci.go
@@ -0,0 +1,400 @@
+package linux
+
+import (
+	"fmt"
+	"io"
+	"log"
+	"sync"
+
+	"github.com/runtimeco/gatt/linux/cmd"
+	"github.com/runtimeco/gatt/linux/evt"
+)
+
+type HCI struct {
+	AcceptMasterHandler  func(pd *PlatData)
+	AcceptSlaveHandler   func(pd *PlatData)
+	AdvertisementHandler func(pd *PlatData)
+
+	d io.ReadWriteCloser
+	c *cmd.Cmd
+	e *evt.Evt
+
+	plist   map[bdaddr]*PlatData
+	plistmu *sync.Mutex
+
+	bufCnt  chan struct{}
+	bufSize int
+
+	maxConn int
+	connsmu *sync.Mutex
+	conns   map[uint16]*conn
+
+	adv   bool
+	advmu *sync.Mutex
+}
+
+type bdaddr [6]byte
+
+type PlatData struct {
+	Name        string
+	AddressType uint8
+	Address     [6]byte
+	Data        []byte
+	Connectable bool
+	RSSI        int8
+
+	Conn io.ReadWriteCloser
+}
+
+func NewHCI(devID int, chk bool, maxConn int) (*HCI, error) {
+	d, err := newDevice(devID, chk)
+	if err != nil {
+		return nil, err
+	}
+	c := cmd.NewCmd(d)
+	e := evt.NewEvt()
+
+	h := &HCI{
+		d: d,
+		c: c,
+		e: e,
+
+		plist:   make(map[bdaddr]*PlatData),
+		plistmu: &sync.Mutex{},
+
+		bufCnt:  make(chan struct{}, 15-1),
+		bufSize: 27,
+
+		maxConn: maxConn,
+		connsmu: &sync.Mutex{},
+		conns:   map[uint16]*conn{},
+
+		advmu: &sync.Mutex{},
+	}
+
+	e.HandleEvent(evt.LEMeta, evt.HandlerFunc(h.handleLEMeta))
+	e.HandleEvent(evt.DisconnectionComplete, evt.HandlerFunc(h.handleDisconnectionComplete))
+	e.HandleEvent(evt.NumberOfCompletedPkts, evt.HandlerFunc(h.handleNumberOfCompletedPkts))
+	e.HandleEvent(evt.CommandComplete, evt.HandlerFunc(c.HandleComplete))
+	e.HandleEvent(evt.CommandStatus, evt.HandlerFunc(c.HandleStatus))
+
+	go h.mainLoop()
+	h.resetDevice()
+	return h, nil
+}
+
+func (h *HCI) Close() error {
+	for _, c := range h.conns {
+		c.Close()
+	}
+	return h.d.Close()
+}
+
+func (h *HCI) SetAdvertiseEnable(en bool) error {
+	h.advmu.Lock()
+	h.adv = en
+	h.advmu.Unlock()
+	return h.setAdvertiseEnable(en)
+}
+
+func (h *HCI) setAdvertiseEnable(en bool) error {
+	h.advmu.Lock()
+	defer h.advmu.Unlock()
+	if en && h.adv && (len(h.conns) == h.maxConn) {
+		return nil
+	}
+	return h.c.SendAndCheckResp(
+		cmd.LESetAdvertiseEnable{
+			AdvertisingEnable: btoi(en),
+		}, []byte{0x00})
+}
+
+func (h *HCI) SendCmdWithAdvOff(c cmd.CmdParam) error {
+	h.setAdvertiseEnable(false)
+	err := h.c.SendAndCheckResp(c, nil)
+	if h.adv {
+		h.setAdvertiseEnable(true)
+	}
+	return err
+}
+
+func (h *HCI) SetScanEnable(en bool, dup bool) error {
+	return h.c.SendAndCheckResp(
+		cmd.LESetScanEnable{
+			LEScanEnable:     btoi(en),
+			FilterDuplicates: btoi(!dup),
+		}, []byte{0x00})
+}
+
+func (h *HCI) Connect(pd *PlatData) error {
+	h.c.Send(
+		cmd.LECreateConn{
+			LEScanInterval:        0x0004,         // N x 0.625ms
+			LEScanWindow:          0x0004,         // N x 0.625ms
+			InitiatorFilterPolicy: 0x00,           // white list not used
+			PeerAddressType:       pd.AddressType, // public or random
+			PeerAddress:           pd.Address,     //
+			OwnAddressType:        0x00,           // public
+			ConnIntervalMin:       6,         // N x 0.125ms
+			ConnIntervalMax:       7,         // N x 0.125ms
+			ConnLatency:           0x0000,         //
+			SupervisionTimeout:    0x00100,         // N x 10ms
+			MinimumCELength:       0x0000,         // N x 0.625ms
+			MaximumCELength:       0x0000,         // N x 0.625ms
+		})
+	return nil
+}
+
+func (h *HCI) CancelConnection(pd *PlatData) error {
+	return pd.Conn.Close()
+}
+
+func (h *HCI) SendRawCommand(c cmd.CmdParam) ([]byte, error) {
+	return h.c.Send(c)
+}
+
+func btoi(b bool) uint8 {
+	if b {
+		return 1
+	}
+	return 0
+}
+
+func (h *HCI) mainLoop() {
+	b := make([]byte, 4096)
+	for {
+		n, err := h.d.Read(b)
+		if err != nil {
+			return
+		}
+		if n == 0 {
+			return
+		}
+		p := make([]byte, n)
+		copy(p, b)
+		h.handlePacket(p)
+	}
+}
+
+func (h *HCI) handlePacket(b []byte) {
+	t, b := packetType(b[0]), b[1:]
+	var err error
+	switch t {
+	case typCommandPkt:
+		op := uint16(b[0]) | uint16(b[1])<<8
+		log.Printf("unmanaged cmd: opcode (%04x) [ % X ]\n", op, b)
+	case typACLDataPkt:
+		err = h.handleL2CAP(b)
+	case typSCODataPkt:
+		err = fmt.Errorf("SCO packet not supported")
+	case typEventPkt:
+		go func() {
+			err := h.e.Dispatch(b)
+			if err != nil {
+				log.Printf("hci: %s, [ % X]", err, b)
+			}
+		}()
+	case typVendorPkt:
+		err = fmt.Errorf("Vendor packet not supported")
+	default:
+		log.Fatalf("Unknown event: 0x%02X [ % X ]\n", t, b)
+	}
+	if err != nil {
+		log.Printf("hci: %s, [ % X]", err, b)
+	}
+}
+
+func (h *HCI) resetDevice() error {
+	seq := []cmd.CmdParam{
+		cmd.Reset{},
+		cmd.SetEventMask{EventMask: 0x3dbff807fffbffff},
+		cmd.LESetEventMask{LEEventMask: 0x000000000000001F},
+		cmd.WriteSimplePairingMode{SimplePairingMode: 1},
+		cmd.WriteLEHostSupported{LESupportedHost: 1, SimultaneousLEHost: 0},
+		cmd.WriteInquiryMode{InquiryMode: 2},
+		cmd.WritePageScanType{PageScanType: 1},
+		cmd.WriteInquiryScanType{ScanType: 1},
+		cmd.WriteClassOfDevice{ClassOfDevice: [3]byte{0x40, 0x02, 0x04}},
+		cmd.WritePageTimeout{PageTimeout: 0x2000},
+		cmd.WriteDefaultLinkPolicy{DefaultLinkPolicySettings: 0x5},
+		cmd.HostBufferSize{
+			HostACLDataPacketLength:            0x1000,
+			HostSynchronousDataPacketLength:    0xff,
+			HostTotalNumACLDataPackets:         0x0014,
+			HostTotalNumSynchronousDataPackets: 0x000a},
+		cmd.LESetScanParameters{
+			LEScanType:           0x01,   // [0x00]: passive, 0x01: active
+			LEScanInterval:       0x0010, // [0x10]: 0.625ms * 16
+			LEScanWindow:         0x0010, // [0x10]: 0.625ms * 16
+			OwnAddressType:       0x00,   // [0x00]: public, 0x01: random
+			ScanningFilterPolicy: 0x00,   // [0x00]: accept all, 0x01: ignore non-white-listed.
+		},
+	}
+	for _, s := range seq {
+		if err := h.c.SendAndCheckResp(s, []byte{0x00}); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+func (h *HCI) handleAdvertisement(b []byte) {
+	// If no one is interested, don't bother.
+	if h.AdvertisementHandler == nil {
+		return
+	}
+	ep := &evt.LEAdvertisingReportEP{}
+	if err := ep.Unmarshal(b); err != nil {
+		return
+	}
+	for i := 0; i < int(ep.NumReports); i++ {
+		addr := bdaddr(ep.Address[i])
+		et := ep.EventType[i]
+		connectable := et == advInd || et == advDirectInd
+		scannable := et == advInd || et == advScanInd
+
+		if et == scanRsp {
+			h.plistmu.Lock()
+			pd, ok := h.plist[addr]
+			h.plistmu.Unlock()
+			if ok {
+				pd.Data = append(pd.Data, ep.Data[i]...)
+				h.AdvertisementHandler(pd)
+			}
+			continue
+		}
+
+		pd := &PlatData{
+			AddressType: ep.AddressType[i],
+			Address:     ep.Address[i],
+			Data:        ep.Data[i],
+			Connectable: connectable,
+			RSSI:        ep.RSSI[i],
+		}
+		h.plistmu.Lock()
+		h.plist[addr] = pd
+		h.plistmu.Unlock()
+		if scannable {
+			continue
+		}
+		h.AdvertisementHandler(pd)
+	}
+}
+
+func (h *HCI) handleNumberOfCompletedPkts(b []byte) error {
+	ep := &evt.NumberOfCompletedPktsEP{}
+	if err := ep.Unmarshal(b); err != nil {
+		return err
+	}
+	for _, r := range ep.Packets {
+		for i := 0; i < int(r.NumOfCompletedPkts); i++ {
+			<-h.bufCnt
+		}
+	}
+	return nil
+}
+
+func (h *HCI) handleConnection(b []byte) {
+	ep := &evt.LEConnectionCompleteEP{}
+	if err := ep.Unmarshal(b); err != nil {
+		return // FIXME
+	}
+	hh := ep.ConnectionHandle
+	c := newConn(h, hh)
+	h.connsmu.Lock()
+	h.conns[hh] = c
+	h.connsmu.Unlock()
+	h.setAdvertiseEnable(true)
+
+	// FIXME: sloppiness. This call should be called by the package user once we
+	// flesh out the support of l2cap signaling packets (CID:0x0001,0x0005)
+	if ep.ConnLatency != 0 || ep.ConnInterval > 0x18 {
+		c.updateConnection()
+	}
+
+	// master connection
+	if ep.Role == 0x01 {
+		pd := &PlatData{
+			Address: ep.PeerAddress,
+			Conn:    c,
+		}
+		h.AcceptMasterHandler(pd)
+		return
+	}
+	h.plistmu.Lock()
+	pd := h.plist[ep.PeerAddress]
+	h.plistmu.Unlock()
+	pd.Conn = c
+	h.AcceptSlaveHandler(pd)
+}
+
+func (h *HCI) handleDisconnectionComplete(b []byte) error {
+	ep := &evt.DisconnectionCompleteEP{}
+	if err := ep.Unmarshal(b); err != nil {
+		return err
+	}
+	hh := ep.ConnectionHandle
+	h.connsmu.Lock()
+	defer h.connsmu.Unlock()
+	c, found := h.conns[hh]
+	if !found {
+		// should not happen, just be cautious for now.
+		log.Printf("l2conn: disconnecting a disconnected 0x%04X connection", hh)
+		return nil
+	}
+	delete(h.conns, hh)
+	close(c.aclc)
+	h.setAdvertiseEnable(true)
+	return nil
+}
+
+func (h *HCI) handleLEMeta(b []byte) error {
+	code := evt.LEEventCode(b[0])
+	switch code {
+	case evt.LEConnectionComplete:
+		go h.handleConnection(b)
+	case evt.LEConnectionUpdateComplete:
+		// anything to do here?
+	case evt.LEAdvertisingReport:
+		go h.handleAdvertisement(b)
+	// case evt.LEReadRemoteUsedFeaturesComplete:
+	// case evt.LELTKRequest:
+	// case evt.LERemoteConnectionParameterRequest:
+	default:
+		return fmt.Errorf("Unhandled LE event: %s, [ % X ]", code, b)
+	}
+	return nil
+}
+
+func (h *HCI) handleL2CAP(b []byte) error {
+        a := &aclData{}
+	if err := a.unmarshal(b); err != nil {
+		return err
+	}
+	h.connsmu.Lock()
+	defer h.connsmu.Unlock()
+	c, found := h.conns[a.attr]
+
+        if a.flags != 0x002 {
+	    if !found {
+		    // should not happen, just be cautious for now.
+		    log.Printf("l2conn: got data for disconnected handle: 0x%04x", a.attr)
+		    return nil
+	        if len(a.b) < 4 {
+		    log.Printf("l2conn: l2cap packet is too short/corrupt, length is %d", len(a.b))
+		    return nil
+	        }
+	        cid := uint16(a.b[2]) | (uint16(a.b[3]) << 8)
+	        if cid == 5 {
+		    c.handleSignal(a)
+		    return nil
+	        }
+            }
+        }
+	c.aclc <- a
+	return nil
+}
+
+func (h *HCI) trace(fmt string, v ...interface{}) {
+	log.Printf(fmt, v)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/l2cap.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/l2cap.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/l2cap.go
new file mode 100644
index 0000000..daca82f
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/l2cap.go
@@ -0,0 +1,174 @@
+package linux
+
+import (
+	"fmt"
+	"io"
+	"log"
+
+	"github.com/runtimeco/gatt/linux/cmd"
+)
+
+type aclData struct {
+	attr  uint16
+	flags uint8
+	dlen  uint16
+	b     []byte
+}
+
+func (a *aclData) unmarshal(b []byte) error {
+	if len(b) < 4 {
+		return fmt.Errorf("malformed acl packet")
+	}
+	attr := uint16(b[0]) | (uint16(b[1]&0x0f) << 8)
+	flags := b[1] >> 4
+	dlen := uint16(b[2]) | (uint16(b[3]) << 8)
+	if len(b) != 4+int(dlen) {
+		return fmt.Errorf("malformed acl packet")
+	}
+
+	*a = aclData{attr: attr, flags: flags, dlen: dlen, b: b[4:]}
+	return nil
+}
+
+type conn struct {
+	hci  *HCI
+	attr uint16
+	aclc chan *aclData
+}
+
+func newConn(hci *HCI, hh uint16) *conn {
+	return &conn{
+		hci:  hci,
+		attr: hh,
+		aclc: make(chan *aclData),
+	}
+}
+
+func (c *conn) updateConnection() (int, error) {
+	b := []byte{
+		0x12,       // Code (Connection Param Update)
+		0x02,       // ID
+		0x08, 0x00, // DataLength
+		0x08, 0x00, // IntervalMin
+		0x18, 0x00, // IntervalMax
+		0x00, 0x00, // SlaveLatency
+		0xC8, 0x00} // TimeoutMultiplier
+	return c.write(0x05, b)
+}
+
+// write writes the l2cap payload to the controller.
+// It first prepend the l2cap header (4-bytes), and diassemble the payload
+// if it is larger than the HCI LE buffer size that the conntroller can support.
+func (c *conn) write(cid int, b []byte) (int, error) {
+	flag := uint8(0) // ACL data continuation flag
+	tlen := len(b)   // Total length of the l2cap payload
+
+	// log.Printf("W: [ % X ]", b)
+	w := append(
+		[]byte{
+			0,    // packet type
+			0, 0, // attr
+			0, 0, // dlen
+			uint8(tlen), uint8(tlen >> 8), // l2cap header
+			uint8(cid), uint8(cid >> 8), // l2cap header
+		}, b...)
+
+	n := 4 + tlen // l2cap header + l2cap payload
+	for n > 0 {
+		dlen := n
+		if dlen > c.hci.bufSize {
+			dlen = c.hci.bufSize
+		}
+		w[0] = 0x02 // packetTypeACL
+		w[1] = uint8(c.attr)
+		w[2] = uint8(c.attr>>8) | flag
+		w[3] = uint8(dlen)
+		w[4] = uint8(dlen >> 8)
+
+		// make sure we don't send more buffers than the controller can handdle
+		c.hci.bufCnt <- struct{}{}
+
+		c.hci.d.Write(w[:5+dlen])
+		w = w[dlen:] // advance the pointer to the next segment, if any.
+		flag = 0x10  // the rest of iterations attr continued segments, if any.
+		n -= dlen
+	}
+
+	return len(b), nil
+}
+
+func (c *conn) Read(b []byte) (int, error) {
+	a, ok := <-c.aclc
+	if !ok {
+		return 0, io.EOF
+	}
+	tlen := int(uint16(a.b[0]) | uint16(a.b[1])<<8)
+	if tlen > len(b) {
+		return 0, io.ErrShortBuffer
+	}
+	d := a.b[4:] // skip l2cap header
+	copy(b, d)
+	n := len(d)
+
+	// Keep receiving and reassemble continued l2cap segments
+	for n != tlen {
+		if a, ok = <-c.aclc; !ok || (a.flags&0x1) == 0 {
+			return n, io.ErrUnexpectedEOF
+		}
+		copy(b[n:], a.b)
+		n += len(a.b)
+	}
+	// log.Printf("R: [ % X ]", b[:n])
+	return n, nil
+}
+
+func (c *conn) Write(b []byte) (int, error) {
+	return c.write(0x04, b)
+}
+
+// Close disconnects the connection by sending HCI disconnect command to the device.
+func (c *conn) Close() error {
+	h := c.hci
+	hh := c.attr
+	h.connsmu.Lock()
+	defer h.connsmu.Unlock()
+	_, found := h.conns[hh]
+	if !found {
+		// log.Printf("l2conn: 0x%04x already disconnected", hh)
+		return nil
+	}
+	if err, _ := h.c.Send(cmd.Disconnect{ConnectionHandle: hh, Reason: 0x13}); err != nil {
+		return fmt.Errorf("l2conn: failed to disconnect, %s", err)
+	}
+	return nil
+}
+
+// Signal Packets
+// 0x00 Reserved								Any
+// 0x01 Command reject							0x0001 and 0x0005
+// 0x02 Connection request						0x0001
+// 0x03 Connection response 					0x0001
+// 0x04 Configure request						0x0001
+// 0x05 Configure response						0x0001
+// 0x06 Disconnection request					0x0001 and 0x0005
+// 0x07 Disconnection response					0x0001 and 0x0005
+// 0x08 Echo request							0x0001
+// 0x09 Echo response							0x0001
+// 0x0A Information request						0x0001
+// 0x0B Information response					0x0001
+// 0x0C Create Channel request					0x0001
+// 0x0D Create Channel response					0x0001
+// 0x0E Move Channel request					0x0001
+// 0x0F Move Channel response					0x0001
+// 0x10 Move Channel Confirmation				0x0001
+// 0x11 Move Channel Confirmation response		0x0001
+// 0x12 Connection Parameter Update request		0x0005
+// 0x13 Connection Parameter Update response	0x0005
+// 0x14 LE Credit Based Connection request		0x0005
+// 0x15 LE Credit Based Connection response		0x0005
+// 0x16 LE Flow Control Credit					0x0005
+func (c *conn) handleSignal(a *aclData) error {
+	log.Printf("ignore l2cap signal:[ % X ]", a.b)
+	// FIXME: handle LE signaling channel (CID: 5)
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm.s
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm.s b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm.s
new file mode 100644
index 0000000..d4ca868
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm.s
@@ -0,0 +1,8 @@
+// Copyright 2014 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "textflag.h"
+
+TEXT �use(SB),NOSPLIT,$0
+	RET

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm_linux_386.s
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm_linux_386.s b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm_linux_386.s
new file mode 100644
index 0000000..5d3ad9a
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/asm_linux_386.s
@@ -0,0 +1,33 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "textflag.h"
+
+//
+// System calls for 386, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT	�Syscall(SB),NOSPLIT,$0-28
+	JMP	syscall�Syscall(SB)
+
+TEXT	�Syscall6(SB),NOSPLIT,$0-40
+	JMP	syscall�Syscall6(SB)
+
+TEXT �RawSyscall(SB),NOSPLIT,$0-28
+	JMP	syscall�RawSyscall(SB)
+
+TEXT	�RawSyscall6(SB),NOSPLIT,$0-40
+	JMP	syscall�RawSyscall6(SB)
+
+TEXT �socketcall(SB),NOSPLIT,$0-36
+	JMP	syscall�socketcall(SB)
+
+TEXT �rawsocketcall(SB),NOSPLIT,$0-36
+	JMP	syscall�rawsocketcall(SB)
+
+TEXT �seek(SB),NOSPLIT,$0-28
+	JMP	syscall�seek(SB)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket.go
new file mode 100644
index 0000000..ffc49a6
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket.go
@@ -0,0 +1,121 @@
+// Package socket implements a minimal set of function of the HCI Socket,
+// which is not yet supported by the Go standard library. Most of the code
+// follow suit the existing code in the standard library. Once it gets
+// supported officially, we can get rid of this package entirely.
+
+package socket
+
+import (
+	"errors"
+	"syscall"
+	"time"
+	"unsafe"
+)
+
+// Bluetooth Protocols
+const (
+	BTPROTO_L2CAP  = 0
+	BTPROTO_HCI    = 1
+	BTPROTO_SCO    = 2
+	BTPROTO_RFCOMM = 3
+	BTPROTO_BNEP   = 4
+	BTPROTO_CMTP   = 5
+	BTPROTO_HIDP   = 6
+	BTPROTO_AVDTP  = 7
+)
+
+const (
+	HCI_CHANNEL_RAW     = 0
+	HCI_CHANNEL_USER    = 1
+	HCI_CHANNEL_MONITOR = 2
+	HCI_CHANNEL_CONTROL = 3
+)
+
+var (
+	ErrSocketOpenFailed  = errors.New("unable to open bluetooth socket to device")
+	ErrSocketBindTimeout = errors.New("timeout occured binding to bluetooth device")
+)
+
+type _Socklen uint32
+
+type Sockaddr interface {
+	sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
+}
+
+type rawSockaddrHCI struct {
+	Family  uint16
+	Dev     uint16
+	Channel uint16
+}
+
+type SockaddrHCI struct {
+	Dev     int
+	Channel uint16
+	raw     rawSockaddrHCI
+}
+
+const sizeofSockaddrHCI = unsafe.Sizeof(rawSockaddrHCI{})
+
+func (sa *SockaddrHCI) sockaddr() (unsafe.Pointer, _Socklen, error) {
+	if sa.Dev < 0 || sa.Dev > 0xFFFF {
+		return nil, 0, syscall.EINVAL
+	}
+	if sa.Channel < 0 || sa.Channel > 0xFFFF {
+		return nil, 0, syscall.EINVAL
+	}
+	sa.raw.Family = AF_BLUETOOTH
+	sa.raw.Dev = uint16(sa.Dev)
+	sa.raw.Channel = sa.Channel
+	return unsafe.Pointer(&sa.raw), _Socklen(sizeofSockaddrHCI), nil
+}
+
+func Socket(domain, typ, proto int) (int, error) {
+	for i := 0; i < 5; i++ {
+		if fd, err := syscall.Socket(domain, typ, proto); err == nil || err != syscall.EBUSY {
+			return fd, err
+		}
+		time.Sleep(time.Second)
+	}
+	return 0, ErrSocketOpenFailed
+}
+
+func Bind(fd int, sa Sockaddr) (err error) {
+	ptr, n, err := sa.sockaddr()
+	if err != nil {
+		return err
+	}
+	for i := 0; i < 5; i++ {
+		if err = bind(fd, ptr, n); err == nil || err != syscall.EBUSY {
+			return err
+		}
+		time.Sleep(time.Second)
+	}
+	return ErrSocketBindTimeout
+}
+
+// Socket Level
+const (
+	SOL_HCI    = 0
+	SOL_L2CAP  = 6
+	SOL_SCO    = 17
+	SOL_RFCOMM = 18
+
+	SOL_BLUETOOTH = 274
+)
+
+// HCI Socket options
+const (
+	HCI_DATA_DIR   = 1
+	HCI_FILTER     = 2
+	HCI_TIME_STAMP = 3
+)
+
+type HCIFilter struct {
+	TypeMask  uint32
+	EventMask [2]uint32
+	opcode    uint16
+}
+
+func SetsockoptFilter(fd int, f *HCIFilter) (err error) {
+	return setsockopt(fd, SOL_HCI, HCI_FILTER, unsafe.Pointer(f), unsafe.Sizeof(*f))
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_common.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_common.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_common.go
new file mode 100644
index 0000000..b01ceeb
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_common.go
@@ -0,0 +1,24 @@
+// +build !386
+
+package socket
+
+import (
+	"syscall"
+	"unsafe"
+)
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+	_, _, e1 := syscall.Syscall(syscall.SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+	if e1 != 0 {
+		err = e1
+	}
+	return
+}
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+	_, _, e1 := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+	if e1 != 0 {
+		err = e1
+	}
+	return
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_darwin.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_darwin.go
new file mode 100644
index 0000000..abb96a5
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_darwin.go
@@ -0,0 +1,6 @@
+// +build darwin
+
+package socket
+
+// For compile time compatibility
+const AF_BLUETOOTH = 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux.go
new file mode 100644
index 0000000..4793915
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux.go
@@ -0,0 +1,7 @@
+// +build linux
+
+package socket
+
+import "syscall"
+
+const AF_BLUETOOTH = syscall.AF_BLUETOOTH

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux_386.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux_386.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux_386.go
new file mode 100644
index 0000000..05ca65c
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/socket/socket_linux_386.go
@@ -0,0 +1,31 @@
+// +build linux,386
+
+package socket
+
+import (
+	"syscall"
+	"unsafe"
+)
+
+const (
+	BIND         = 2
+	SETSOCKETOPT = 14
+)
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+	_, e1 := socketcall(BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
+	if e1 != 0 {
+		err = e1
+	}
+	return
+}
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+	_, e1 := socketcall(SETSOCKETOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0)
+	if e1 != 0 {
+		err = e1
+	}
+	return
+}
+
+func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/linux/util/util.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/linux/util/util.go b/newtmgr/vendor/github.com/runtimeco/gatt/linux/util/util.go
new file mode 100644
index 0000000..4933008
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/linux/util/util.go
@@ -0,0 +1,16 @@
+package util
+
+import "encoding/binary"
+
+type order struct{ binary.ByteOrder }
+
+var Order = order{binary.LittleEndian}
+
+func (o order) Int8(b []byte) int8   { return int8(b[0]) }
+func (o order) Uint8(b []byte) uint8 { return b[0] }
+func (o order) MAC(b []byte) [6]byte { return [6]byte{b[5], b[4], b[3], b[2], b[1], b[0]} }
+
+func (o order) PutUint8(b []byte, v uint8) { b[0] = v }
+func (o order) PutMAC(b []byte, m [6]byte) {
+	b[0], b[1], b[2], b[3], b[4], b[5] = m[5], m[4], m[3], m[2], m[1], m[0]
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/option_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/option_darwin.go b/newtmgr/vendor/github.com/runtimeco/gatt/option_darwin.go
new file mode 100644
index 0000000..617db21
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/option_darwin.go
@@ -0,0 +1,15 @@
+package gatt
+
+const (
+	CentralManager    = 0 // Client functions (default)
+	PeripheralManager = 1 // Server functions
+)
+
+// MacDeviceRole specify the XPC connection type to connect blued.
+// THis option can only be used with NewDevice on OS X implementation.
+func MacDeviceRole(r int) Option {
+	return func(d Device) error {
+		d.(*device).role = r
+		return nil
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/option_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/option_linux.go b/newtmgr/vendor/github.com/runtimeco/gatt/option_linux.go
new file mode 100644
index 0000000..bf2360c
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/option_linux.go
@@ -0,0 +1,87 @@
+package gatt
+
+import (
+	"errors"
+	"io"
+
+	"github.com/runtimeco/gatt/linux/cmd"
+)
+
+// LnxDeviceID specifies which HCI device to use.
+// If n is set to -1, all the available HCI devices will be probed.
+// If chk is set to true, LnxDeviceID checks the LE support in the feature list of the HCI device.
+// This is to filter devices that does not support LE. In case some LE driver that doesn't correctly
+// set the LE support in its feature list, user can turn off the check.
+// This option can only be used with NewDevice on Linux implementation.
+func LnxDeviceID(n int, chk bool) Option {
+	return func(d Device) error {
+		d.(*device).devID = n
+		d.(*device).chkLE = chk
+		return nil
+	}
+}
+
+// LnxMaxConnections is an optional parameter.
+// If set, it overrides the default max connections supported.
+// This option can only be used with NewDevice on Linux implementation.
+func LnxMaxConnections(n int) Option {
+	return func(d Device) error {
+		d.(*device).maxConn = n
+		return nil
+	}
+}
+
+// LnxSetAdvertisingEnable sets the advertising data to the HCI device.
+// This option can be used with Option on Linux implementation.
+func LnxSetAdvertisingEnable(en bool) Option {
+	return func(d Device) error {
+		dd := d.(*device)
+		if dd == nil {
+			return errors.New("device is not initialized")
+		}
+		if err := dd.update(); err != nil {
+			return err
+		}
+		return dd.hci.SetAdvertiseEnable(en)
+	}
+}
+
+// LnxSetAdvertisingData sets the advertising data to the HCI device.
+// This option can be used with NewDevice or Option on Linux implementation.
+func LnxSetAdvertisingData(c *cmd.LESetAdvertisingData) Option {
+	return func(d Device) error {
+		d.(*device).advData = c
+		return nil
+	}
+}
+
+// LnxSetScanResponseData sets the scan response data to the HXI device.
+// This option can be used with NewDevice or Option on Linux implementation.
+func LnxSetScanResponseData(c *cmd.LESetScanResponseData) Option {
+	return func(d Device) error {
+		d.(*device).scanResp = c
+		return nil
+	}
+}
+
+// LnxSetAdvertisingParameters sets the advertising parameters to the HCI device.
+// This option can be used with NewDevice or Option on Linux implementation.
+func LnxSetAdvertisingParameters(c *cmd.LESetAdvertisingParameters) Option {
+	return func(d Device) error {
+		d.(*device).advParam = c
+		return nil
+	}
+}
+
+// LnxSendHCIRawCommand sends a raw command to the HCI device
+// This option can be used with NewDevice or Option on Linux implementation.
+func LnxSendHCIRawCommand(c cmd.CmdParam, rsp io.Writer) Option {
+	return func(d Device) error {
+		b, err := d.(*device).SendHCIRawCommand(c)
+		if rsp == nil {
+			return err
+		}
+		rsp.Write(b)
+		return err
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/peripheral.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/peripheral.go b/newtmgr/vendor/github.com/runtimeco/gatt/peripheral.go
new file mode 100644
index 0000000..36ad578
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/peripheral.go
@@ -0,0 +1,102 @@
+package gatt
+
+import (
+	"errors"
+	"sync"
+)
+
+// Peripheral is the interface that represent a remote peripheral device.
+type Peripheral interface {
+	// Device returns the underlying device.
+	Device() Device
+
+	// ID is the platform specific unique ID of the remote peripheral, e.g. MAC for Linux, Peripheral UUID for MacOS.
+	ID() string
+
+	// Name returns the name of the remote peripheral.
+	// This can be the advertised name, if exists, or the GAP device name, which takes priority
+	Name() string
+
+	// Services returnns the services of the remote peripheral which has been discovered.
+	Services() []*Service
+
+	// DiscoverServices discover the specified services of the remote peripheral.
+	// If the specified services is set to nil, all the available services of the remote peripheral are returned.
+	DiscoverServices(s []UUID) ([]*Service, error)
+
+	// DiscoverIncludedServices discovers the specified included services of a service.
+	// If the specified services is set to nil, all the included services of the service are returned.
+	DiscoverIncludedServices(ss []UUID, s *Service) ([]*Service, error)
+
+	// DiscoverCharacteristics discovers the specified characteristics of a service.
+	// If the specified characterstics is set to nil, all the characteristic of the service are returned.
+	DiscoverCharacteristics(c []UUID, s *Service) ([]*Characteristic, error)
+
+	// DiscoverDescriptors discovers the descriptors of a characteristic.
+	// If the specified descriptors is set to nil, all the descriptors of the characteristic are returned.
+	DiscoverDescriptors(d []UUID, c *Characteristic) ([]*Descriptor, error)
+
+	// ReadCharacteristic retrieves the value of a specified characteristic.
+	ReadCharacteristic(c *Characteristic) ([]byte, error)
+
+	// ReadLongCharacteristic retrieves the value of a specified characteristic that is longer than the
+	// MTU.
+	ReadLongCharacteristic(c *Characteristic) ([]byte, error)
+
+	// ReadDescriptor retrieves the value of a specified characteristic descriptor.
+	ReadDescriptor(d *Descriptor) ([]byte, error)
+
+	// WriteCharacteristic writes the value of a characteristic.
+	WriteCharacteristic(c *Characteristic, b []byte, noRsp bool) error
+
+	// WriteDescriptor writes the value of a characteristic descriptor.
+	WriteDescriptor(d *Descriptor, b []byte) error
+
+	// SetNotifyValue sets notifications for the value of a specified characteristic.
+	SetNotifyValue(c *Characteristic, f func(*Characteristic, []byte, error)) error
+
+	// SetIndicateValue sets indications for the value of a specified characteristic.
+	SetIndicateValue(c *Characteristic, f func(*Characteristic, []byte, error)) error
+
+	// ReadRSSI retrieves the current RSSI value for the remote peripheral.
+	ReadRSSI() int
+
+	// SetMTU sets the mtu for the remote peripheral.
+	SetMTU(mtu uint16) error
+}
+
+type subscriber struct {
+	sub map[uint16]subscribefn
+	mu  *sync.Mutex
+}
+
+type subscribefn func([]byte, error)
+
+func newSubscriber() *subscriber {
+	return &subscriber{
+		sub: make(map[uint16]subscribefn),
+		mu:  &sync.Mutex{},
+	}
+}
+
+func (s *subscriber) subscribe(h uint16, f subscribefn) {
+	s.mu.Lock()
+	s.sub[h] = f
+	s.mu.Unlock()
+}
+
+func (s *subscriber) unsubscribe(h uint16) {
+	s.mu.Lock()
+	delete(s.sub, h)
+	s.mu.Unlock()
+}
+
+func (s *subscriber) fn(h uint16) subscribefn {
+	s.mu.Lock()
+	defer s.mu.Unlock()
+	return s.sub[h]
+}
+
+var (
+	ErrInvalidLength = errors.New("invalid length")
+)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_darwin.go b/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_darwin.go
new file mode 100644
index 0000000..9174e61
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_darwin.go
@@ -0,0 +1,277 @@
+package gatt
+
+import (
+	"errors"
+	"log"
+
+	"github.com/runtimeco/gatt/xpc"
+)
+
+type peripheral struct {
+	// NameChanged is called whenever the peripheral GAP Device name has changed.
+	NameChanged func(Peripheral)
+
+	// ServicesModified is called when one or more service of a peripheral have changed.
+	// A list of invalid service is provided in the parameter.
+	ServicesModified func(Peripheral, []*Service)
+
+	d    *device
+	svcs []*Service
+
+	sub *subscriber
+
+	id   xpc.UUID
+	name string
+
+	reqc  chan message
+	rspc  chan message
+	quitc chan struct{}
+}
+
+func NewPeripheral(u UUID) Peripheral { return &peripheral{id: xpc.UUID(u.b)} }
+
+func (p *peripheral) Device() Device       { return p.d }
+func (p *peripheral) ID() string           { return p.id.String() }
+func (p *peripheral) Name() string         { return p.name }
+func (p *peripheral) Services() []*Service { return p.svcs }
+
+func (p *peripheral) DiscoverServices(ss []UUID) ([]*Service, error) {
+	rsp := p.sendReq(45, xpc.Dict{
+		"kCBMsgArgDeviceUUID": p.id,
+		"kCBMsgArgUUIDs":      uuidSlice(ss),
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return nil, attEcode(res)
+	}
+	svcs := []*Service{}
+	for _, xss := range rsp["kCBMsgArgServices"].(xpc.Array) {
+		xs := xss.(xpc.Dict)
+		u := MustParseUUID(xs.MustGetHexBytes("kCBMsgArgUUID"))
+		h := uint16(xs.MustGetInt("kCBMsgArgServiceStartHandle"))
+		endh := uint16(xs.MustGetInt("kCBMsgArgServiceEndHandle"))
+		svcs = append(svcs, &Service{uuid: u, h: h, endh: endh})
+	}
+	p.svcs = svcs
+	return svcs, nil
+}
+
+func (p *peripheral) DiscoverIncludedServices(ss []UUID, s *Service) ([]*Service, error) {
+	rsp := p.sendReq(60, xpc.Dict{
+		"kCBMsgArgDeviceUUID":         p.id,
+		"kCBMsgArgServiceStartHandle": s.h,
+		"kCBMsgArgServiceEndHandle":   s.endh,
+		"kCBMsgArgUUIDs":              uuidSlice(ss),
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return nil, attEcode(res)
+	}
+	// TODO
+	return nil, notImplemented
+}
+
+func (p *peripheral) DiscoverCharacteristics(cs []UUID, s *Service) ([]*Characteristic, error) {
+	rsp := p.sendReq(62, xpc.Dict{
+		"kCBMsgArgDeviceUUID":         p.id,
+		"kCBMsgArgServiceStartHandle": s.h,
+		"kCBMsgArgServiceEndHandle":   s.endh,
+		"kCBMsgArgUUIDs":              uuidSlice(cs),
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return nil, attEcode(res)
+	}
+	for _, xcs := range rsp.MustGetArray("kCBMsgArgCharacteristics") {
+		xc := xcs.(xpc.Dict)
+		u := MustParseUUID(xc.MustGetHexBytes("kCBMsgArgUUID"))
+		ch := uint16(xc.MustGetInt("kCBMsgArgCharacteristicHandle"))
+		vh := uint16(xc.MustGetInt("kCBMsgArgCharacteristicValueHandle"))
+		props := Property(xc.MustGetInt("kCBMsgArgCharacteristicProperties"))
+		c := &Characteristic{uuid: u, svc: s, props: props, h: ch, vh: vh}
+		s.chars = append(s.chars, c)
+	}
+	return s.chars, nil
+}
+
+func (p *peripheral) DiscoverDescriptors(ds []UUID, c *Characteristic) ([]*Descriptor, error) {
+	rsp := p.sendReq(70, xpc.Dict{
+		"kCBMsgArgDeviceUUID":                p.id,
+		"kCBMsgArgCharacteristicHandle":      c.h,
+		"kCBMsgArgCharacteristicValueHandle": c.vh,
+		"kCBMsgArgUUIDs":                     uuidSlice(ds),
+	})
+	for _, xds := range rsp.MustGetArray("kCBMsgArgDescriptors") {
+		xd := xds.(xpc.Dict)
+		u := MustParseUUID(xd.MustGetHexBytes("kCBMsgArgUUID"))
+		h := uint16(xd.MustGetInt("kCBMsgArgDescriptorHandle"))
+		d := &Descriptor{uuid: u, char: c, h: h}
+		c.descs = append(c.descs, d)
+	}
+	return c.descs, nil
+}
+
+func (p *peripheral) ReadCharacteristic(c *Characteristic) ([]byte, error) {
+	rsp := p.sendReq(65, xpc.Dict{
+		"kCBMsgArgDeviceUUID":                p.id,
+		"kCBMsgArgCharacteristicHandle":      c.h,
+		"kCBMsgArgCharacteristicValueHandle": c.vh,
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return nil, attEcode(res)
+	}
+	b := rsp.MustGetBytes("kCBMsgArgData")
+	return b, nil
+}
+
+func (p *peripheral) ReadLongCharacteristic(c *Characteristic) ([]byte, error) {
+	return nil, errors.New("Not implemented")
+}
+
+func (p *peripheral) WriteCharacteristic(c *Characteristic, b []byte, noRsp bool) error {
+	args := xpc.Dict{
+		"kCBMsgArgDeviceUUID":                p.id,
+		"kCBMsgArgCharacteristicHandle":      c.h,
+		"kCBMsgArgCharacteristicValueHandle": c.vh,
+		"kCBMsgArgData":                      b,
+		"kCBMsgArgType":                      map[bool]int{false: 0, true: 1}[noRsp],
+	}
+	if noRsp {
+		p.sendCmd(66, args)
+		return nil
+	}
+	rsp := p.sendReq(65, args)
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return attEcode(res)
+	}
+	return nil
+}
+
+func (p *peripheral) ReadDescriptor(d *Descriptor) ([]byte, error) {
+	rsp := p.sendReq(77, xpc.Dict{
+		"kCBMsgArgDeviceUUID":       p.id,
+		"kCBMsgArgDescriptorHandle": d.h,
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return nil, attEcode(res)
+	}
+	b := rsp.MustGetBytes("kCBMsgArgData")
+	return b, nil
+}
+
+func (p *peripheral) WriteDescriptor(d *Descriptor, b []byte) error {
+	rsp := p.sendReq(78, xpc.Dict{
+		"kCBMsgArgDeviceUUID":       p.id,
+		"kCBMsgArgDescriptorHandle": d.h,
+		"kCBMsgArgData":             b,
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return attEcode(res)
+	}
+	return nil
+}
+
+func (p *peripheral) SetNotifyValue(c *Characteristic, f func(*Characteristic, []byte, error)) error {
+	set := 1
+	if f == nil {
+		set = 0
+	}
+	// To avoid race condition, registeration is handled before requesting the server.
+	if f != nil {
+		// Note: when notified, core bluetooth reports characteristic handle, not value's handle.
+		p.sub.subscribe(c.h, func(b []byte, err error) { f(c, b, err) })
+	}
+	rsp := p.sendReq(68, xpc.Dict{
+		"kCBMsgArgDeviceUUID":                p.id,
+		"kCBMsgArgCharacteristicHandle":      c.h,
+		"kCBMsgArgCharacteristicValueHandle": c.vh,
+		"kCBMsgArgState":                     set,
+	})
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return attEcode(res)
+	}
+	// To avoid race condition, unregisteration is handled after server responses.
+	if f == nil {
+		p.sub.unsubscribe(c.h)
+	}
+	return nil
+}
+
+func (p *peripheral) SetIndicateValue(c *Characteristic,
+	f func(*Characteristic, []byte, error)) error {
+	// TODO: Implement set indications logic for darwin (https://github.com/runtimeco/gatt/issues/32)
+	return nil
+}
+
+func (p *peripheral) ReadRSSI() int {
+	rsp := p.sendReq(43, xpc.Dict{"kCBMsgArgDeviceUUID": p.id})
+	return rsp.MustGetInt("kCBMsgArgData")
+}
+
+func (p *peripheral) SetMTU(mtu uint16) error {
+	return errors.New("Not implemented")
+}
+
+func uuidSlice(uu []UUID) [][]byte {
+	us := [][]byte{}
+	for _, u := range uu {
+		us = append(us, reverse(u.b))
+	}
+	return us
+}
+
+type message struct {
+	id   int
+	args xpc.Dict
+	rspc chan xpc.Dict
+}
+
+func (p *peripheral) sendCmd(id int, args xpc.Dict) {
+	p.reqc <- message{id: id, args: args}
+}
+
+func (p *peripheral) sendReq(id int, args xpc.Dict) xpc.Dict {
+	m := message{id: id, args: args, rspc: make(chan xpc.Dict)}
+	p.reqc <- m
+	return <-m.rspc
+}
+
+func (p *peripheral) loop() {
+	rspc := make(chan message)
+
+	go func() {
+		for {
+			select {
+			case req := <-p.reqc:
+				p.d.sendCBMsg(req.id, req.args)
+				if req.rspc == nil {
+					break
+				}
+				m := <-rspc
+				req.rspc <- m.args
+			case <-p.quitc:
+				return
+			}
+		}
+	}()
+
+	for {
+		select {
+		case rsp := <-p.rspc:
+			// Notification
+			if rsp.id == 71 && rsp.args.GetInt("kCBMsgArgIsNotification", 0) != 0 {
+				// While we're notified with the value's handle, blued reports the characteristic handle.
+				ch := uint16(rsp.args.MustGetInt("kCBMsgArgCharacteristicHandle"))
+				b := rsp.args.MustGetBytes("kCBMsgArgData")
+				f := p.sub.fn(ch)
+				if f == nil {
+					log.Printf("notified by unsubscribed handle")
+					// FIXME: should terminate the connection?
+				} else {
+					go f(b, nil)
+				}
+				break
+			}
+			rspc <- rsp
+		case <-p.quitc:
+			return
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_linux.go b/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_linux.go
new file mode 100644
index 0000000..43ec067
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/peripheral_linux.go
@@ -0,0 +1,448 @@
+package gatt
+
+import (
+	"bytes"
+	"encoding/binary"
+	"fmt"
+	"io"
+	"log"
+	"net"
+	"strings"
+
+	"github.com/runtimeco/gatt/linux"
+)
+
+type peripheral struct {
+	// NameChanged is called whenever the peripheral GAP device name has changed.
+	NameChanged func(*peripheral)
+
+	// ServicedModified is called when one or more service of a peripheral have changed.
+	// A list of invalid service is provided in the parameter.
+	ServicesModified func(*peripheral, []*Service)
+
+	d    *device
+	svcs []*Service
+
+	sub *subscriber
+
+	mtu uint16
+	l2c io.ReadWriteCloser
+
+	reqc  chan message
+	quitc chan struct{}
+
+	pd *linux.PlatData // platform specific data
+}
+
+func (p *peripheral) Device() Device       { return p.d }
+func (p *peripheral) ID() string           { return strings.ToUpper(net.HardwareAddr(p.pd.Address[:]).String()) }
+func (p *peripheral) Name() string         { return p.pd.Name }
+func (p *peripheral) Services() []*Service { return p.svcs }
+
+func finish(op byte, h uint16, b []byte) bool {
+	done := b[0] == attOpError && b[1] == op && b[2] == byte(h) && b[3] == byte(h>>8)
+	e := attEcode(b[4])
+	if e != attEcodeAttrNotFound {
+		// log.Printf("unexpected protocol error: %s", e)
+		// FIXME: terminate the connection
+	}
+	return done
+}
+
+func (p *peripheral) DiscoverServices(s []UUID) ([]*Service, error) {
+	// TODO: implement the UUID filters
+	// p.pd.Conn.Write([]byte{0x02, 0x87, 0x00}) // MTU
+	done := false
+	start := uint16(0x0001)
+	for !done {
+		op := byte(attOpReadByGroupReq)
+		b := make([]byte, 7)
+		b[0] = op
+		binary.LittleEndian.PutUint16(b[1:3], start)
+		binary.LittleEndian.PutUint16(b[3:5], 0xFFFF)
+		binary.LittleEndian.PutUint16(b[5:7], 0x2800)
+
+		b = p.sendReq(op, b)
+		if finish(op, start, b) {
+			break
+		}
+		b = b[1:]
+		l, b := int(b[0]), b[1:]
+		switch {
+		case l == 6 && (len(b)%6 == 0):
+		case l == 20 && (len(b)%20 == 0):
+		default:
+			return nil, ErrInvalidLength
+		}
+
+		for len(b) != 0 {
+			h := binary.LittleEndian.Uint16(b[:2])
+			endh := binary.LittleEndian.Uint16(b[2:4])
+			s := &Service{
+				uuid: UUID{b[4:l]},
+				h:    h,
+				endh: endh,
+			}
+			p.svcs = append(p.svcs, s)
+			b = b[l:]
+			done = endh == 0xFFFF
+			start = endh + 1
+		}
+	}
+	return p.svcs, nil
+}
+
+func (p *peripheral) DiscoverIncludedServices(ss []UUID, s *Service) ([]*Service, error) {
+	// TODO
+	return nil, nil
+}
+
+func (p *peripheral) DiscoverCharacteristics(cs []UUID, s *Service) ([]*Characteristic, error) {
+	// TODO: implement the UUID filters
+	done := false
+	start := s.h
+	var prev *Characteristic
+	for !done {
+		op := byte(attOpReadByTypeReq)
+		b := make([]byte, 7)
+		b[0] = op
+		binary.LittleEndian.PutUint16(b[1:3], start)
+		binary.LittleEndian.PutUint16(b[3:5], s.endh)
+		binary.LittleEndian.PutUint16(b[5:7], 0x2803)
+
+		b = p.sendReq(op, b)
+		if finish(op, start, b) {
+			break
+		}
+		b = b[1:]
+
+		l, b := int(b[0]), b[1:]
+		switch {
+		case l == 7 && (len(b)%7 == 0):
+		case l == 21 && (len(b)%21 == 0):
+		default:
+			return nil, ErrInvalidLength
+		}
+
+		for len(b) != 0 {
+			h := binary.LittleEndian.Uint16(b[:2])
+			props := Property(b[2])
+			vh := binary.LittleEndian.Uint16(b[3:5])
+			u := UUID{b[5:l]}
+			s := searchService(p.svcs, h, vh)
+			if s == nil {
+				log.Printf("Can't find service range that contains 0x%04X - 0x%04X", h, vh)
+				return nil, fmt.Errorf("Can't find service range that contains 0x%04X - 0x%04X", h, vh)
+			}
+			c := &Characteristic{
+				uuid:  u,
+				svc:   s,
+				props: props,
+				h:     h,
+				vh:    vh,
+			}
+			s.chars = append(s.chars, c)
+			b = b[l:]
+			done = vh == s.endh
+			start = vh + 1
+			if prev != nil {
+				prev.endh = c.h - 1
+			}
+			prev = c
+		}
+	}
+	if len(s.chars) > 1 {
+		s.chars[len(s.chars)-1].endh = s.endh
+	}
+	return s.chars, nil
+}
+
+func (p *peripheral) DiscoverDescriptors(ds []UUID, c *Characteristic) ([]*Descriptor, error) {
+	// TODO: implement the UUID filters
+	done := false
+	start := c.vh + 1
+	for !done {
+		if c.endh == 0 {
+			c.endh = c.svc.endh
+		}
+		op := byte(attOpFindInfoReq)
+		b := make([]byte, 5)
+		b[0] = op
+		binary.LittleEndian.PutUint16(b[1:3], start)
+		binary.LittleEndian.PutUint16(b[3:5], c.endh)
+
+		b = p.sendReq(op, b)
+		if finish(attOpFindInfoReq, start, b) {
+			break
+		}
+		b = b[1:]
+
+		var l int
+		f, b := int(b[0]), b[1:]
+		switch {
+		case f == 1 && (len(b)%4 == 0):
+			l = 4
+		case f == 2 && (len(b)%18 == 0):
+			l = 18
+		default:
+			return nil, ErrInvalidLength
+		}
+
+		for len(b) != 0 {
+			h := binary.LittleEndian.Uint16(b[:2])
+			u := UUID{b[2:l]}
+			d := &Descriptor{uuid: u, h: h, char: c}
+			c.descs = append(c.descs, d)
+			if u.Equal(attrClientCharacteristicConfigUUID) {
+				c.cccd = d
+			}
+			b = b[l:]
+			done = h == c.endh
+			start = h + 1
+		}
+	}
+	return c.descs, nil
+}
+
+func (p *peripheral) ReadCharacteristic(c *Characteristic) ([]byte, error) {
+	b := make([]byte, 3)
+	op := byte(attOpReadReq)
+	b[0] = op
+	binary.LittleEndian.PutUint16(b[1:3], c.vh)
+
+	b = p.sendReq(op, b)
+	b = b[1:]
+	return b, nil
+}
+
+func (p *peripheral) ReadLongCharacteristic(c *Characteristic) ([]byte, error) {
+	// The spec says that a read blob request should fail if the characteristic
+	// is smaller than mtu - 1.  To simplify the API, the first read is done
+	// with a regular read request.  If the buffer received is equal to mtu -1,
+	// then we read the rest of the data using read blob.
+	firstRead, err := p.ReadCharacteristic(c)
+	if err != nil {
+		return nil, err
+	}
+	if len(firstRead) < int(p.mtu)-1 {
+		return firstRead, nil
+	}
+
+	var buf bytes.Buffer
+	buf.Write(firstRead)
+	off := uint16(len(firstRead))
+	for {
+		b := make([]byte, 5)
+		op := byte(attOpReadBlobReq)
+		b[0] = op
+		binary.LittleEndian.PutUint16(b[1:3], c.vh)
+		binary.LittleEndian.PutUint16(b[3:5], off)
+
+		b = p.sendReq(op, b)
+		b = b[1:]
+		if len(b) == 0 {
+			break
+		}
+		buf.Write(b)
+		off += uint16(len(b))
+		if len(b) < int(p.mtu)-1 {
+			break
+		}
+	}
+	return buf.Bytes(), nil
+}
+
+func (p *peripheral) WriteCharacteristic(c *Characteristic, value []byte, noRsp bool) error {
+	b := make([]byte, 3+len(value))
+	op := byte(attOpWriteReq)
+	b[0] = op
+	if noRsp {
+		b[0] = attOpWriteCmd
+	}
+	binary.LittleEndian.PutUint16(b[1:3], c.vh)
+	copy(b[3:], value)
+
+	if noRsp {
+		p.sendCmd(op, b)
+		return nil
+	}
+	b = p.sendReq(op, b)
+	// TODO: error handling
+	b = b[1:]
+	return nil
+}
+
+func (p *peripheral) ReadDescriptor(d *Descriptor) ([]byte, error) {
+	b := make([]byte, 3)
+	op := byte(attOpReadReq)
+	b[0] = op
+	binary.LittleEndian.PutUint16(b[1:3], d.h)
+
+	b = p.sendReq(op, b)
+	b = b[1:]
+	// TODO: error handling
+	return b, nil
+}
+
+func (p *peripheral) WriteDescriptor(d *Descriptor, value []byte) error {
+	b := make([]byte, 3+len(value))
+	op := byte(attOpWriteReq)
+	b[0] = op
+	binary.LittleEndian.PutUint16(b[1:3], d.h)
+	copy(b[3:], value)
+
+	b = p.sendReq(op, b)
+	b = b[1:]
+	// TODO: error handling
+	return nil
+}
+
+func (p *peripheral) setNotifyValue(c *Characteristic, flag uint16,
+	f func(*Characteristic, []byte, error)) error {
+/*
+	if c.cccd == nil {
+		return errors.New("no cccd") // FIXME
+	}
+	ccc := uint16(0)
+	if f != nil {
+		ccc = flag
+*/
+		p.sub.subscribe(c.vh, func(b []byte, err error) { f(c, b, err) })
+/*
+	}
+	b := make([]byte, 5)
+	op := byte(attOpWriteReq)
+	b[0] = op
+	binary.LittleEndian.PutUint16(b[1:3], c.cccd.h)
+	binary.LittleEndian.PutUint16(b[3:5], ccc)
+
+	b = p.sendReq(op, b)
+	b = b[1:]
+	// TODO: error handling
+	if f == nil {
+		p.sub.unsubscribe(c.vh)
+	}
+*/
+	return nil
+}
+
+func (p *peripheral) SetNotifyValue(c *Characteristic,
+	f func(*Characteristic, []byte, error)) error {
+	return p.setNotifyValue(c, gattCCCNotifyFlag, f)
+}
+
+func (p *peripheral) SetIndicateValue(c *Characteristic,
+	f func(*Characteristic, []byte, error)) error {
+	return p.setNotifyValue(c, gattCCCIndicateFlag, f)
+}
+
+func (p *peripheral) ReadRSSI() int {
+	// TODO: implement
+	return -1
+}
+
+func searchService(ss []*Service, start, end uint16) *Service {
+	for _, s := range ss {
+		if s.h < start && s.endh >= end {
+			return s
+		}
+	}
+	return nil
+}
+
+// TODO: unifiy the message with OS X pots and refactor
+type message struct {
+	op   byte
+	b    []byte
+	rspc chan []byte
+}
+
+func (p *peripheral) sendCmd(op byte, b []byte) {
+	p.reqc <- message{op: op, b: b}
+}
+
+func (p *peripheral) sendReq(op byte, b []byte) []byte {
+	m := message{op: op, b: b, rspc: make(chan []byte)}
+	p.reqc <- m
+	return <-m.rspc
+}
+
+func (p *peripheral) loop() {
+	// Serialize the request.
+	rspc := make(chan []byte)
+
+	// Dequeue request loop
+	go func() {
+		for {
+			select {
+			case req := <-p.reqc:
+				p.l2c.Write(req.b)
+				if req.rspc == nil {
+					break
+				}
+				r := <-rspc
+				switch reqOp, rspOp := req.b[0], r[0]; {
+				case rspOp == attRspFor[reqOp]:
+				case rspOp == attOpError && r[1] == reqOp:
+				default:
+					log.Printf("Request 0x%02x got a mismatched response: 0x%02x", reqOp, rspOp)
+					// FIXME: terminate the connection?
+				}
+				req.rspc <- r
+			case <-p.quitc:
+				return
+			}
+		}
+	}()
+
+	// L2CAP implementations shall support a minimum MTU size of 48 bytes.
+	// The default value is 672 bytes
+	buf := make([]byte, 672)
+
+	// Handling response or notification/indication
+	for {
+		n, err := p.l2c.Read(buf)
+		if n == 0 || err != nil {
+			close(p.quitc)
+			return
+		}
+
+		b := make([]byte, n)
+		copy(b, buf)
+
+		if (b[0] != attOpHandleNotify) && (b[0] != attOpHandleInd) {
+			rspc <- b
+			continue
+		}
+
+		h := binary.LittleEndian.Uint16(b[1:3])
+		f := p.sub.fn(h)
+		if f == nil {
+			log.Printf("notified by unsubscribed handle")
+			// FIXME: terminate the connection?
+		} else {
+			go f(b[3:], nil)
+		}
+
+		if b[0] == attOpHandleInd {
+			// write aknowledgement for indication
+			p.l2c.Write([]byte{attOpHandleCnf})
+		}
+
+	}
+}
+
+func (p *peripheral) SetMTU(mtu uint16) error {
+	b := make([]byte, 3)
+	op := byte(attOpMtuReq)
+	b[0] = op
+	binary.LittleEndian.PutUint16(b[1:3], uint16(mtu))
+
+	b = p.sendReq(op, b)
+	serverMTU := binary.LittleEndian.Uint16(b[1:3])
+	if serverMTU < mtu {
+		mtu = serverMTU
+	}
+	p.mtu = mtu
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/readme.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/readme.md b/newtmgr/vendor/github.com/runtimeco/gatt/readme.md
new file mode 100644
index 0000000..ea3a957
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/readme.md
@@ -0,0 +1,115 @@
+# Package gatt provides a Bluetooth Low Energy GATT implementation.
+
+Gatt (Generic Attribute Profile) is the protocol used to write BLE peripherals (servers) and centrals (clients).
+
+As a peripheral, you can create services, characteristics, and descriptors,
+advertise, accept connections, and handle requests.
+
+As a central, you can scan, connect, discover services, and make requests.
+
+## SETUP
+
+### gatt supports both Linux and OS X.
+
+### On Linux:
+To gain complete and exclusive control of the HCI device, gatt uses
+HCI_CHANNEL_USER (introduced in Linux v3.14) instead of HCI_CHANNEL_RAW.
+Those who must use an older kernel may patch in these relevant commits
+from Marcel Holtmann:
+
+    Bluetooth: Introduce new HCI socket channel for user operation
+    Bluetooth: Introduce user channel flag for HCI devices
+    Bluetooth: Refactor raw socket filter into more readable code
+
+Note that because gatt uses HCI_CHANNEL_USER, once gatt has opened the
+device no other program may access it.
+
+Before starting a gatt program, make sure that your BLE device is down:
+
+    sudo hciconfig
+    sudo hciconfig hci0 down  # or whatever hci device you want to use
+
+If you have BlueZ 5.14+ (or aren't sure), stop the built-in
+bluetooth server, which interferes with gatt, e.g.:
+
+    sudo service bluetooth stop
+
+Because gatt programs administer network devices, they must
+either be run as root, or be granted appropriate capabilities:
+
+    sudo <executable>
+    # OR
+    sudo setcap 'cap_net_raw,cap_net_admin=eip' <executable>
+    <executable>
+
+## Usage
+Please see [godoc.org](http://godoc.org/github.com/paypal/gatt) for documentation.
+
+## Examples
+
+### Build and run the examples on a native environment (Linux or OS X)
+
+Go is a compiled language, which means to run the examples you need to build them first.
+
+    # Build the sample server.
+    go build examples/server.go
+    # Start the sample server.
+    sudo ./server
+
+Alternatively, you can use "go run" to build and run the examples in a single step:
+
+    # Build and run the sample server.
+    sudo go run examples/server.go
+
+Discoverer and explorer demonstrates central (client) functions:
+
+    # Discover surrounding peripherals.
+    sudo go run examples/discoverer.go
+
+    # Connect to and explorer a peripheral device.
+    sudo go run examples/explorer.go <peripheral ID>
+
+### Cross-compile and deploy to a target device
+
+    # Build and run the server example on a ARMv5 target device.
+    GOARCH=arm GOARM=5 GOOS=linux go build examples/server.go
+    cp server <target device>
+    # Start the server on the target device
+    sudo ./server
+
+See the server.go, discoverer.go, and explorer.go in the examples/
+directory for writing server or client programs that run on Linux
+and OS X.
+
+Users, especially on Linux platforms, seeking finer-grained control
+over the devices can see the examples/server_lnx.go for the usage
+of Option, which are platform specific.
+
+See the rest of the docs for other options and finer-grained control.
+
+## Note
+Note that some BLE central devices, particularly iOS, may aggressively
+cache results from previous connections. If you change your services or
+characteristics, you may need to reboot the other device to pick up the
+changes. This is a common source of confusion and apparent bugs. For an
+OS X central, see http://stackoverflow.com/questions/20553957.
+
+## Known Issues
+
+Currently OS X vesion  does not support subscribing to indications. 
+Please check [#32](https://github.com/paypal/gatt/issues/32) for the status of this issue.
+
+## REFERENCES
+
+gatt started life as a port of bleno, to which it is indebted:
+https://github.com/sandeepmistry/bleno. If you are having
+problems with gatt, particularly around installation, issues
+filed with bleno might also be helpful references.
+
+To try out your GATT server, it is useful to experiment with a
+generic BLE client. LightBlue is a good choice. It is available
+free for both iOS and OS X.
+
+gatt is similar to [bleno](https://github.com/sandeepmistry/bleno) and [noble](https://github.com/sandeepmistry/noble), which offer BLE GATT implementations for node.js.
+
+Gatt is released under a [BSD-style license](./LICENSE.md).

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/uuid.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/uuid.go b/newtmgr/vendor/github.com/runtimeco/gatt/uuid.go
new file mode 100644
index 0000000..393e548
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/uuid.go
@@ -0,0 +1,86 @@
+package gatt
+
+import (
+	"bytes"
+	"encoding/binary"
+	"encoding/hex"
+	"fmt"
+	"strings"
+)
+
+// A UUID is a BLE UUID.
+type UUID struct {
+	// Hide the bytes, so that we can enforce that they have length 2 or 16,
+	// and that they are immutable. This simplifies the code and API.
+	b []byte
+}
+
+// UUID16 converts a uint16 (such as 0x1800) to a UUID.
+func UUID16(i uint16) UUID {
+	b := make([]byte, 2)
+	binary.LittleEndian.PutUint16(b, i)
+	return UUID{b}
+}
+
+// ParseUUID parses a standard-format UUID string, such
+// as "1800" or "34DA3AD1-7110-41A1-B1EF-4430F509CDE7".
+func ParseUUID(s string) (UUID, error) {
+	s = strings.Replace(s, "-", "", -1)
+	b, err := hex.DecodeString(s)
+	if err != nil {
+		return UUID{}, err
+	}
+	if err := lenErr(len(b)); err != nil {
+		return UUID{}, err
+	}
+	return UUID{reverse(b)}, nil
+}
+
+// MustParseUUID parses a standard-format UUID string,
+// like ParseUUID, but panics in case of error.
+func MustParseUUID(s string) UUID {
+	u, err := ParseUUID(s)
+	if err != nil {
+		panic(err)
+	}
+	return u
+}
+
+// lenErr returns an error if n is an invalid UUID length.
+func lenErr(n int) error {
+	switch n {
+	case 2, 16:
+		return nil
+	}
+	return fmt.Errorf("UUIDs must have length 2 or 16, got %d", n)
+}
+
+// Len returns the length of the UUID, in bytes.
+// BLE UUIDs are either 2 or 16 bytes.
+func (u UUID) Len() int {
+	return len(u.b)
+}
+
+// String hex-encodes a UUID.
+func (u UUID) String() string {
+	return fmt.Sprintf("%x", reverse(u.b))
+}
+
+// Equal returns a boolean reporting whether v represent the same UUID as u.
+func (u UUID) Equal(v UUID) bool {
+	return bytes.Equal(u.b, v.b)
+}
+
+// reverse returns a reversed copy of u.
+func reverse(u []byte) []byte {
+	// Special-case 16 bit UUIDS for speed.
+	l := len(u)
+	if l == 2 {
+		return []byte{u[1], u[0]}
+	}
+	b := make([]byte, l)
+	for i := 0; i < l/2+1; i++ {
+		b[i], b[l-i-1] = u[l-i-1], u[i]
+	}
+	return b
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/LICENSE
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/LICENSE b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/LICENSE
new file mode 100644
index 0000000..766a0a5
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) {{{year}}} {{{fullname}}}
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/doc.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/doc.go b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/doc.go
new file mode 100644
index 0000000..d292249
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/doc.go
@@ -0,0 +1,8 @@
+// Package xpc provides minimal OS X XPC support required for gatt
+//
+// This is adapted from [goble], by Raffaele Sena.
+//
+//     http://godoc.org/github.com/raff/goble
+//     https://github.com/raff/goble
+
+package xpc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_darwin.go b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_darwin.go
new file mode 100644
index 0000000..2a85a99
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_darwin.go
@@ -0,0 +1,350 @@
+package xpc
+
+/*
+#include "xpc_wrapper_darwin.h"
+#include "sys/utsname.h"
+*/
+import "C"
+
+import (
+	"errors"
+	"fmt"
+	"log"
+	r "reflect"
+	"unsafe"
+)
+
+type XPC struct {
+	conn C.xpc_connection_t
+}
+
+func (x *XPC) Send(msg interface{}, verbose bool) {
+	// verbose == true converts the type from bool to C._Bool
+	C.XpcSendMessage(x.conn, goToXpc(msg), true, verbose == true)
+}
+
+//
+// minimal XPC support required for BLE
+//
+
+// a dictionary of things
+type Dict map[string]interface{}
+
+func (d Dict) Contains(k string) bool {
+	_, ok := d[k]
+	return ok
+}
+
+func (d Dict) MustGetDict(k string) Dict {
+	return d[k].(Dict)
+}
+
+func (d Dict) MustGetArray(k string) Array {
+	return d[k].(Array)
+}
+
+func (d Dict) MustGetBytes(k string) []byte {
+	return d[k].([]byte)
+}
+
+func (d Dict) MustGetHexBytes(k string) string {
+	return fmt.Sprintf("%x", d[k].([]byte))
+}
+
+func (d Dict) MustGetInt(k string) int {
+	return int(d[k].(int64))
+}
+
+func (d Dict) MustGetUUID(k string) []byte {
+	u := d[k].(UUID)
+	return u[:]
+}
+
+func (d Dict) GetString(k, defv string) string {
+	if v := d[k]; v != nil {
+		//log.Printf("GetString %s %#v\n", k, v)
+		return v.(string)
+	} else {
+		//log.Printf("GetString %s default %#v\n", k, defv)
+		return defv
+	}
+}
+
+func (d Dict) GetBytes(k string, defv []byte) []byte {
+	if v := d[k]; v != nil {
+		//log.Printf("GetBytes %s %#v\n", k, v)
+		return v.([]byte)
+	} else {
+		//log.Printf("GetBytes %s default %#v\n", k, defv)
+		return defv
+	}
+}
+
+func (d Dict) GetInt(k string, defv int) int {
+	if v := d[k]; v != nil {
+		//log.Printf("GetString %s %#v\n", k, v)
+		return int(v.(int64))
+	} else {
+		//log.Printf("GetString %s default %#v\n", k, defv)
+		return defv
+	}
+}
+
+func (d Dict) GetUUID(k string) UUID {
+	return GetUUID(d[k])
+}
+
+// an array of things
+type Array []interface{}
+
+func (a Array) GetUUID(k int) UUID {
+	return GetUUID(a[k])
+}
+
+// a UUID
+type UUID []byte
+
+func MakeUUID(s string) UUID {
+	var sl []byte
+	fmt.Sscanf(s, "%32x", &sl)
+
+	var uuid [16]byte
+	copy(uuid[:], sl)
+	return UUID(uuid[:])
+}
+
+func (uuid UUID) String() string {
+	return fmt.Sprintf("%x", []byte(uuid))
+}
+
+func GetUUID(v interface{}) UUID {
+	if v == nil {
+		return UUID{}
+	}
+
+	if uuid, ok := v.(UUID); ok {
+		return uuid
+	}
+
+	if bytes, ok := v.([]byte); ok {
+		uuid := UUID{}
+
+		for i, b := range bytes {
+			uuid[i] = b
+		}
+
+		return uuid
+	}
+
+	if bytes, ok := v.([]uint8); ok {
+		uuid := UUID{}
+
+		for i, b := range bytes {
+			uuid[i] = b
+		}
+
+		return uuid
+	}
+
+	log.Fatalf("invalid type for UUID: %#v", v)
+	return UUID{}
+}
+
+var (
+	CONNECTION_INVALID     = errors.New("connection invalid")
+	CONNECTION_INTERRUPTED = errors.New("connection interrupted")
+	CONNECTION_TERMINATED  = errors.New("connection terminated")
+
+	TYPE_OF_UUID  = r.TypeOf(UUID{})
+	TYPE_OF_BYTES = r.TypeOf([]byte{})
+)
+
+type XpcEventHandler interface {
+	HandleXpcEvent(event Dict, err error)
+}
+
+func XpcConnect(service string, eh XpcEventHandler) XPC {
+	cservice := C.CString(service)
+	defer C.free(unsafe.Pointer(cservice))
+	return XPC{conn: C.XpcConnect(cservice, unsafe.Pointer(&eh))}
+}
+
+//export handleXpcEvent
+func handleXpcEvent(event C.xpc_object_t, p unsafe.Pointer) {
+	//log.Printf("handleXpcEvent %#v %#v\n", event, p)
+
+	t := C.xpc_get_type(event)
+	eh := *((*XpcEventHandler)(p))
+
+	if t == C.TYPE_ERROR {
+		if event == C.ERROR_CONNECTION_INVALID {
+			// The client process on the other end of the connection has either
+			// crashed or cancelled the connection. After receiving this error,
+			// the connection is in an invalid state, and you do not need to
+			// call xpc_connection_cancel(). Just tear down any associated state
+			// here.
+			//log.Println("connection invalid")
+			eh.HandleXpcEvent(nil, CONNECTION_INVALID)
+		} else if event == C.ERROR_CONNECTION_INTERRUPTED {
+			//log.Println("connection interrupted")
+			eh.HandleXpcEvent(nil, CONNECTION_INTERRUPTED)
+		} else if event == C.ERROR_CONNECTION_TERMINATED {
+			// Handle per-connection termination cleanup.
+			//log.Println("connection terminated")
+			eh.HandleXpcEvent(nil, CONNECTION_TERMINATED)
+		} else {
+			//log.Println("got some error", event)
+			eh.HandleXpcEvent(nil, fmt.Errorf("%v", event))
+		}
+	} else {
+		eh.HandleXpcEvent(xpcToGo(event).(Dict), nil)
+	}
+}
+
+// goToXpc converts a go object to an xpc object
+func goToXpc(o interface{}) C.xpc_object_t {
+	return valueToXpc(r.ValueOf(o))
+}
+
+// valueToXpc converts a go Value to an xpc object
+//
+// note that not all the types are supported, but only the subset required for Blued
+func valueToXpc(val r.Value) C.xpc_object_t {
+	if !val.IsValid() {
+		return nil
+	}
+
+	var xv C.xpc_object_t
+
+	switch val.Kind() {
+	case r.Int, r.Int8, r.Int16, r.Int32, r.Int64:
+		xv = C.xpc_int64_create(C.int64_t(val.Int()))
+
+	case r.Uint, r.Uint8, r.Uint16, r.Uint32:
+		xv = C.xpc_int64_create(C.int64_t(val.Uint()))
+
+	case r.String:
+		xv = C.xpc_string_create(C.CString(val.String()))
+
+	case r.Map:
+		xv = C.xpc_dictionary_create(nil, nil, 0)
+		for _, k := range val.MapKeys() {
+			v := valueToXpc(val.MapIndex(k))
+			C.xpc_dictionary_set_value(xv, C.CString(k.String()), v)
+			if v != nil {
+				C.xpc_release(v)
+			}
+		}
+
+	case r.Array, r.Slice:
+		if val.Type() == TYPE_OF_UUID {
+			// array of bytes
+			var uuid [16]byte
+			r.Copy(r.ValueOf(uuid[:]), val)
+			xv = C.xpc_uuid_create(C.ptr_to_uuid(unsafe.Pointer(&uuid[0])))
+		} else if val.Type() == TYPE_OF_BYTES {
+			// slice of bytes
+			xv = C.xpc_data_create(unsafe.Pointer(val.Pointer()), C.size_t(val.Len()))
+		} else {
+			xv = C.xpc_array_create(nil, 0)
+			l := val.Len()
+
+			for i := 0; i < l; i++ {
+				v := valueToXpc(val.Index(i))
+				C.xpc_array_append_value(xv, v)
+				if v != nil {
+					C.xpc_release(v)
+				}
+			}
+		}
+
+	case r.Interface, r.Ptr:
+		xv = valueToXpc(val.Elem())
+
+	default:
+		log.Fatalf("unsupported %#v", val.String())
+	}
+
+	return xv
+}
+
+//export arraySet
+func arraySet(u unsafe.Pointer, i C.int, v C.xpc_object_t) {
+	a := *(*Array)(u)
+	a[i] = xpcToGo(v)
+}
+
+//export dictSet
+func dictSet(u unsafe.Pointer, k *C.char, v C.xpc_object_t) {
+	d := *(*Dict)(u)
+	d[C.GoString(k)] = xpcToGo(v)
+}
+
+// xpcToGo converts an xpc object to a go object
+//
+// note that not all the types are supported, but only the subset required for Blued
+func xpcToGo(v C.xpc_object_t) interface{} {
+	t := C.xpc_get_type(v)
+
+	switch t {
+	case C.TYPE_ARRAY:
+		a := make(Array, C.int(C.xpc_array_get_count(v)))
+		C.XpcArrayApply(unsafe.Pointer(&a), v)
+		return a
+
+	case C.TYPE_DATA:
+		return C.GoBytes(C.xpc_data_get_bytes_ptr(v), C.int(C.xpc_data_get_length(v)))
+
+	case C.TYPE_DICT:
+		d := make(Dict)
+		C.XpcDictApply(unsafe.Pointer(&d), v)
+		return d
+
+	case C.TYPE_INT64:
+		return int64(C.xpc_int64_get_value(v))
+
+	case C.TYPE_STRING:
+		return C.GoString(C.xpc_string_get_string_ptr(v))
+
+	case C.TYPE_UUID:
+		a := [16]byte{}
+		C.XpcUUIDGetBytes(unsafe.Pointer(&a), v)
+		return UUID(a[:])
+
+	default:
+		log.Fatalf("unexpected type %#v, value %#v", t, v)
+	}
+
+	return nil
+}
+
+// xpc_release is needed by tests, since they can't use CGO
+func xpc_release(xv C.xpc_object_t) {
+	C.xpc_release(xv)
+}
+
+// this is used to check the OS version
+
+type Utsname struct {
+	Sysname  string
+	Nodename string
+	Release  string
+	Version  string
+	Machine  string
+}
+
+func Uname(utsname *Utsname) error {
+	var cstruct C.struct_utsname
+	if err := C.uname(&cstruct); err != 0 {
+		return errors.New("utsname error")
+	}
+
+	// XXX: this may crash if any value is exactly 256 characters (no 0 terminator)
+	utsname.Sysname = C.GoString(&cstruct.sysname[0])
+	utsname.Nodename = C.GoString(&cstruct.nodename[0])
+	utsname.Release = C.GoString(&cstruct.release[0])
+	utsname.Version = C.GoString(&cstruct.version[0])
+	utsname.Machine = C.GoString(&cstruct.machine[0])
+
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.c
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.c b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.c
new file mode 100644
index 0000000..7bcb83d
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.c
@@ -0,0 +1,85 @@
+#include <dispatch/dispatch.h>
+#include <xpc/xpc.h>
+#include <xpc/connection.h>
+#include <Block.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "_cgo_export.h"
+
+//
+// types and errors are implemented as macros
+// create some real objects to make them accessible to Go
+//
+xpc_type_t TYPE_ERROR = XPC_TYPE_ERROR;
+
+xpc_type_t TYPE_ARRAY = XPC_TYPE_ARRAY;
+xpc_type_t TYPE_DATA = XPC_TYPE_DATA;
+xpc_type_t TYPE_DICT = XPC_TYPE_DICTIONARY;
+xpc_type_t TYPE_INT64 = XPC_TYPE_INT64;
+xpc_type_t TYPE_STRING = XPC_TYPE_STRING;
+xpc_type_t TYPE_UUID = XPC_TYPE_UUID;
+
+xpc_object_t ERROR_CONNECTION_INVALID = (xpc_object_t) XPC_ERROR_CONNECTION_INVALID;
+xpc_object_t ERROR_CONNECTION_INTERRUPTED = (xpc_object_t) XPC_ERROR_CONNECTION_INTERRUPTED;
+xpc_object_t ERROR_CONNECTION_TERMINATED = (xpc_object_t) XPC_ERROR_TERMINATION_IMMINENT;
+
+const ptr_to_uuid_t ptr_to_uuid(void *p) { return (ptr_to_uuid_t)p; }
+
+
+//
+// connect to XPC service
+//
+xpc_connection_t XpcConnect(char *service, void *ctx) {
+    dispatch_queue_t queue = dispatch_queue_create(service, 0);
+    xpc_connection_t conn = xpc_connection_create_mach_service(service, queue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);
+
+    // making a local copy, that should be made "persistent" with the following Block_copy
+    GoInterface ictx = *((GoInterface*)ctx);
+
+    xpc_connection_set_event_handler(conn,
+        Block_copy(^(xpc_object_t event) {
+            handleXpcEvent(event, (void *)&ictx);
+        })
+    );
+
+    xpc_connection_resume(conn);
+    return conn;
+}
+
+void XpcSendMessage(xpc_connection_t conn, xpc_object_t message, bool release, bool reportDelivery) {
+    xpc_connection_send_message(conn,  message);
+    xpc_connection_send_barrier(conn, ^{
+        // Block is invoked on connection's target queue
+        // when 'message' has been sent.
+        if (reportDelivery) { // maybe this could be a callback
+            puts("message delivered");
+        }
+    });
+    if (release) {
+        xpc_release(message);
+    }
+}
+
+void XpcArrayApply(void *v, xpc_object_t arr) {
+  xpc_array_apply(arr, ^bool(size_t index, xpc_object_t value) {
+    arraySet(v, index, value);
+    return true;
+  });
+}
+
+void XpcDictApply(void *v, xpc_object_t dict) {
+  xpc_dictionary_apply(dict, ^bool(const char *key, xpc_object_t value) {
+    dictSet(v, (char *)key, value);
+    return true;
+  });
+}
+
+void XpcUUIDGetBytes(void *v, xpc_object_t uuid) {
+   const uint8_t *src = xpc_uuid_get_bytes(uuid);
+   uint8_t *dest = (uint8_t *)v;
+
+   for (int i=0; i < sizeof(uuid_t); i++) {
+     dest[i] = src[i];
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.h
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.h b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.h
new file mode 100644
index 0000000..e2cfb5c
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/xpc/xpc_wrapper_darwin.h
@@ -0,0 +1,32 @@
+#ifndef _XPC_WRAPPER_H_
+#define _XPC_WRAPPER_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <xpc/xpc.h>
+
+extern xpc_type_t TYPE_ERROR;
+
+extern xpc_type_t TYPE_ARRAY;
+extern xpc_type_t TYPE_DATA;
+extern xpc_type_t TYPE_DICT;
+extern xpc_type_t TYPE_INT64;
+extern xpc_type_t TYPE_STRING;
+extern xpc_type_t TYPE_UUID;
+
+extern xpc_object_t ERROR_CONNECTION_INVALID;
+extern xpc_object_t ERROR_CONNECTION_INTERRUPTED;
+extern xpc_object_t ERROR_CONNECTION_TERMINATED;
+
+extern xpc_connection_t XpcConnect(char *, void *);
+extern void XpcSendMessage(xpc_connection_t, xpc_object_t, bool, bool);
+extern void XpcArrayApply(void *, xpc_object_t);
+extern void XpcDictApply(void *, xpc_object_t);
+extern void XpcUUIDGetBytes(void *, xpc_object_t);
+
+// the input type for xpc_uuid_create should be uuid_t but CGO instists on unsigned char *
+// typedef uuid_t * ptr_to_uuid_t;
+typedef unsigned char * ptr_to_uuid_t;
+extern const ptr_to_uuid_t ptr_to_uuid(void *p);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/.gitignore
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/.gitignore b/newtmgr/vendor/github.com/runtimeinc/gatt/.gitignore
deleted file mode 100644
index 7ab0687..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-c.out
-c/*-ble
-sample

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/LICENSE.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/LICENSE.md b/newtmgr/vendor/github.com/runtimeinc/gatt/LICENSE.md
deleted file mode 100644
index 51c07a6..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/LICENSE.md
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2014 PayPal Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-   * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-   * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-   * Neither the name of PayPal Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/adv.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/adv.go b/newtmgr/vendor/github.com/runtimeinc/gatt/adv.go
deleted file mode 100644
index 3b8a747..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/adv.go
+++ /dev/null
@@ -1,234 +0,0 @@
-package gatt
-
-import (
-	"errors"
-	"log"
-)
-
-// MaxEIRPacketLength is the maximum allowed AdvertisingPacket
-// and ScanResponsePacket length.
-const MaxEIRPacketLength = 31
-
-// ErrEIRPacketTooLong is the error returned when an AdvertisingPacket
-// or ScanResponsePacket is too long.
-var ErrEIRPacketTooLong = errors.New("max packet length is 31")
-
-// Advertising data field types
-const (
-	typeFlags             = 0x01 // Flags
-	typeSomeUUID16        = 0x02 // Incomplete List of 16-bit Service Class UUIDs
-	typeAllUUID16         = 0x03 // Complete List of 16-bit Service Class UUIDs
-	typeSomeUUID32        = 0x04 // Incomplete List of 32-bit Service Class UUIDs
-	typeAllUUID32         = 0x05 // Complete List of 32-bit Service Class UUIDs
-	typeSomeUUID128       = 0x06 // Incomplete List of 128-bit Service Class UUIDs
-	typeAllUUID128        = 0x07 // Complete List of 128-bit Service Class UUIDs
-	typeShortName         = 0x08 // Shortened Local Name
-	typeCompleteName      = 0x09 // Complete Local Name
-	typeTxPower           = 0x0A // Tx Power Level
-	typeClassOfDevice     = 0x0D // Class of Device
-	typeSimplePairingC192 = 0x0E // Simple Pairing Hash C-192
-	typeSimplePairingR192 = 0x0F // Simple Pairing Randomizer R-192
-	typeSecManagerTK      = 0x10 // Security Manager TK Value
-	typeSecManagerOOB     = 0x11 // Security Manager Out of Band Flags
-	typeSlaveConnInt      = 0x12 // Slave Connection Interval Range
-	typeServiceSol16      = 0x14 // List of 16-bit Service Solicitation UUIDs
-	typeServiceSol128     = 0x15 // List of 128-bit Service Solicitation UUIDs
-	typeServiceData16     = 0x16 // Service Data - 16-bit UUID
-	typePubTargetAddr     = 0x17 // Public Target Address
-	typeRandTargetAddr    = 0x18 // Random Target Address
-	typeAppearance        = 0x19 // Appearance
-	typeAdvInterval       = 0x1A // Advertising Interval
-	typeLEDeviceAddr      = 0x1B // LE Bluetooth Device Address
-	typeLERole            = 0x1C // LE Role
-	typeServiceSol32      = 0x1F // List of 32-bit Service Solicitation UUIDs
-	typeServiceData32     = 0x20 // Service Data - 32-bit UUID
-	typeServiceData128    = 0x21 // Service Data - 128-bit UUID
-	typeLESecConfirm      = 0x22 // LE Secure Connections Confirmation Value
-	typeLESecRandom       = 0x23 // LE Secure Connections Random Value
-	typeManufacturerData  = 0xFF // Manufacturer Specific Data
-)
-
-// Advertising type flags
-const (
-	flagLimitedDiscoverable = 0x01 // LE Limited Discoverable Mode
-	flagGeneralDiscoverable = 0x02 // LE General Discoverable Mode
-	flagLEOnly              = 0x04 // BR/EDR Not Supported. Bit 37 of LMP Feature Mask Definitions (Page 0)
-	flagBothController      = 0x08 // Simultaneous LE and BR/EDR to Same Device Capable (Controller).
-	flagBothHost            = 0x10 // Simultaneous LE and BR/EDR to Same Device Capable (Host).
-)
-
-// FIXME: check the unmarshalling of this data structure.
-type ServiceData struct {
-	UUID UUID
-	Data []byte
-}
-
-// This is borrowed from core bluetooth.
-// Embedded/Linux folks might be interested in more details.
-type Advertisement struct {
-	LocalName        string
-	ManufacturerData []byte
-	ServiceData      []ServiceData
-	Services         []UUID
-	OverflowService  []UUID
-	TxPowerLevel     int
-	Connectable      bool
-	SolicitedService []UUID
-	AddressType uint8
-	Address     [6]byte
-}
-
-// This is only used in Linux port.
-func (a *Advertisement) unmarshall(b []byte) error {
-
-	// Utility function for creating a list of uuids.
-	uuidList := func(u []UUID, d []byte, w int) []UUID {
-		for len(d) > 0 {
-			u = append(u, UUID{d[:w]})
-			d = d[w:]
-		}
-		return u
-	}
-
-	for len(b) > 0 {
-		if len(b) < 2 {
-			return errors.New("invalid advertise data")
-		}
-		l, t := b[0], b[1]
-		if len(b) < int(1+l) {
-			return errors.New("invalid advertise data")
-		}
-		d := b[2 : 1+l]
-		switch t {
-		case typeFlags:
-			// TODO: should we do anything about the discoverability here?
-		case typeSomeUUID16:
-			a.Services = uuidList(a.Services, d, 2)
-		case typeAllUUID16:
-			a.Services = uuidList(a.Services, d, 2)
-		case typeSomeUUID32:
-			a.Services = uuidList(a.Services, d, 4)
-		case typeAllUUID32:
-			a.Services = uuidList(a.Services, d, 4)
-		case typeSomeUUID128:
-			a.Services = uuidList(a.Services, d, 16)
-		case typeAllUUID128:
-			a.Services = uuidList(a.Services, d, 16)
-		case typeShortName:
-			a.LocalName = string(d)
-		case typeCompleteName:
-			a.LocalName = string(d)
-		case typeTxPower:
-			a.TxPowerLevel = int(d[0])
-		case typeServiceSol16:
-			a.SolicitedService = uuidList(a.SolicitedService, d, 2)
-		case typeServiceSol128:
-			a.SolicitedService = uuidList(a.SolicitedService, d, 16)
-		case typeServiceSol32:
-			a.SolicitedService = uuidList(a.SolicitedService, d, 4)
-		case typeManufacturerData:
-			a.ManufacturerData = make([]byte, len(d))
-			copy(a.ManufacturerData, d)
-		// case typeServiceData16,
-		// case typeServiceData32,
-		// case typeServiceData128:
-		default:
-			log.Printf("DATA: [ % X ]", d)
-		}
-		b = b[1+l:]
-	}
-	return nil
-}
-
-// AdvPacket is an utility to help crafting advertisment or scan response data.
-type AdvPacket struct {
-	b []byte
-}
-
-// Bytes returns an 31-byte array, which contains up to 31 bytes of the packet.
-func (a *AdvPacket) Bytes() [31]byte {
-	b := [31]byte{}
-	copy(b[:], a.b)
-	return b
-}
-
-// Len returns the length of the packets with a maximum of 31.
-func (a *AdvPacket) Len() int {
-	if len(a.b) > 31 {
-		return 31
-	}
-	return len(a.b)
-}
-
-// AppendField appends a BLE advertising packet field.
-// TODO: refuse to append field if it'd make the packet too long.
-func (a *AdvPacket) AppendField(typ byte, b []byte) *AdvPacket {
-	// A field consists of len, typ, b.
-	// Len is 1 byte for typ plus len(b).
-	if len(a.b)+2+len(b) > MaxEIRPacketLength {
-		b = b[:MaxEIRPacketLength-len(a.b)-2]
-	}
-	a.b = append(a.b, byte(len(b)+1))
-	a.b = append(a.b, typ)
-	a.b = append(a.b, b...)
-	return a
-}
-
-// AppendFlags appends a flag field to the packet.
-func (a *AdvPacket) AppendFlags(f byte) *AdvPacket {
-	return a.AppendField(typeFlags, []byte{f})
-}
-
-// AppendFlags appends a name field to the packet.
-// If the name fits in the space, it will be append as a complete name field, otherwise a short name field.
-func (a *AdvPacket) AppendName(n string) *AdvPacket {
-	typ := byte(typeCompleteName)
-	if len(a.b)+2+len(n) > MaxEIRPacketLength {
-		typ = byte(typeShortName)
-	}
-	return a.AppendField(typ, []byte(n))
-}
-
-// AppendManufacturerData appends a manufacturer data field to the packet.
-func (a *AdvPacket) AppendManufacturerData(id uint16, b []byte) *AdvPacket {
-	d := append([]byte{uint8(id), uint8(id >> 8)}, b...)
-	return a.AppendField(typeManufacturerData, d)
-}
-
-// AppendUUIDFit appends a BLE advertised service UUID
-// packet field if it fits in the packet, and reports whether the UUID fit.
-func (a *AdvPacket) AppendUUIDFit(uu []UUID) bool {
-	// Iterate all UUIDs to see if they fit in the packet or not.
-	fit, l := true, len(a.b)
-	for _, u := range uu {
-		if u.Equal(attrGAPUUID) || u.Equal(attrGATTUUID) {
-			continue
-		}
-		l += 2 + u.Len()
-		if l > MaxEIRPacketLength {
-			fit = false
-			break
-		}
-	}
-
-	// Append the UUIDs until they no longer fit.
-	for _, u := range uu {
-		if u.Equal(attrGAPUUID) || u.Equal(attrGATTUUID) {
-			continue
-		}
-		if len(a.b)+2+u.Len() > MaxEIRPacketLength {
-			break
-		}
-		switch l = u.Len(); {
-		case l == 2 && fit:
-			a.AppendField(typeAllUUID16, u.b)
-		case l == 16 && fit:
-			a.AppendField(typeAllUUID128, u.b)
-		case l == 2 && !fit:
-			a.AppendField(typeSomeUUID16, u.b)
-		case l == 16 && !fit:
-			a.AppendField(typeSomeUUID128, u.b)
-		}
-	}
-	return fit
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/attr.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/attr.go b/newtmgr/vendor/github.com/runtimeinc/gatt/attr.go
deleted file mode 100644
index d1ae09d..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/attr.go
+++ /dev/null
@@ -1,160 +0,0 @@
-package gatt
-
-import "log"
-
-// attr is a BLE attribute. It is not exported;
-// managing attributes is an implementation detail.
-type attr struct {
-	h      uint16   // attribute handle
-	typ    UUID     // attribute type in UUID
-	props  Property // attripute property
-	secure Property // attribute secure (implementation specific usage)
-	value  []byte   // attribute value
-
-	pvt interface{} // point to the corresponsing Serveice/Characteristic/Descriptor
-}
-
-// A attrRange is a contiguous range of attributes.
-type attrRange struct {
-	aa   []attr
-	base uint16 // handle for first attr in aa
-}
-
-const (
-	tooSmall = -1
-	tooLarge = -2
-)
-
-// idx returns the index into aa corresponding to attr a.
-// If h is too small, idx returns tooSmall (-1).
-// If h is too large, idx returns tooLarge (-2).
-func (r *attrRange) idx(h int) int {
-	if h < int(r.base) {
-		return tooSmall
-	}
-	if int(h) >= int(r.base)+len(r.aa) {
-		return tooLarge
-	}
-	return h - int(r.base)
-}
-
-// At returns attr a.
-func (r *attrRange) At(h uint16) (a attr, ok bool) {
-	i := r.idx(int(h))
-	if i < 0 {
-		return attr{}, false
-	}
-	return r.aa[i], true
-}
-
-// Subrange returns attributes in range [start, end]; it may
-// return an empty slice. Subrange does not panic for
-// out-of-range start or end.
-func (r *attrRange) Subrange(start, end uint16) []attr {
-	startidx := r.idx(int(start))
-	switch startidx {
-	case tooSmall:
-		startidx = 0
-	case tooLarge:
-		return []attr{}
-	}
-
-	endidx := r.idx(int(end) + 1) // [start, end] includes its upper bound!
-	switch endidx {
-	case tooSmall:
-		return []attr{}
-	case tooLarge:
-		endidx = len(r.aa)
-	}
-	return r.aa[startidx:endidx]
-}
-
-func dumpAttributes(aa []attr) {
-	log.Printf("Generating attribute table:")
-	log.Printf("handle\ttype\tprops\tsecure\tpvt\tvalue")
-	for _, a := range aa {
-		log.Printf("0x%04X\t0x%s\t0x%02X\t0x%02x\t%T\t[ % X ]",
-			a.h, a.typ, int(a.props), int(a.secure), a.pvt, a.value)
-	}
-}
-
-func generateAttributes(ss []*Service, base uint16) *attrRange {
-	var aa []attr
-	h := base
-	last := len(ss) - 1
-	for i, s := range ss {
-		var a []attr
-		h, a = generateServiceAttributes(s, h, i == last)
-		aa = append(aa, a...)
-	}
-	dumpAttributes(aa)
-	return &attrRange{aa: aa, base: base}
-}
-
-func generateServiceAttributes(s *Service, h uint16, last bool) (uint16, []attr) {
-	s.h = h
-	// endh set later
-	a := attr{
-		h:     h,
-		typ:   attrPrimaryServiceUUID,
-		value: s.uuid.b,
-		props: CharRead,
-		pvt:   s,
-	}
-	aa := []attr{a}
-	h++
-
-	for _, c := range s.Characteristics() {
-		var a []attr
-		h, a = generateCharAttributes(c, h)
-		aa = append(aa, a...)
-	}
-
-	s.endh = h - 1
-	if last {
-		h = 0xFFFF
-		s.endh = h
-	}
-
-	return h, aa
-}
-
-func generateCharAttributes(c *Characteristic, h uint16) (uint16, []attr) {
-	c.h = h
-	c.vh = h + 1
-	ca := attr{
-		h:     c.h,
-		typ:   attrCharacteristicUUID,
-		value: append([]byte{byte(c.props), byte(c.vh), byte((c.vh) >> 8)}, c.uuid.b...),
-		props: c.props,
-		pvt:   c,
-	}
-	va := attr{
-		h:     c.vh,
-		typ:   c.uuid,
-		value: c.value,
-		props: c.props,
-		pvt:   c,
-	}
-	h += 2
-
-	aa := []attr{ca, va}
-	for _, d := range c.descs {
-		aa = append(aa, generateDescAttributes(d, h))
-		h++
-	}
-
-	return h, aa
-}
-
-func generateDescAttributes(d *Descriptor, h uint16) attr {
-	d.h = h
-	a := attr{
-		h:     h,
-		typ:   d.uuid,
-		value: d.value,
-		props: d.props,
-		pvt:   d,
-	}
-	return a
-}



[7/7] incubator-mynewt-newt git commit: MYNEWT-653 Use runtimeco gatt fork.

Posted by cc...@apache.org.
MYNEWT-653 Use runtimeco gatt fork.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/abf65d3a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/abf65d3a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/abf65d3a

Branch: refs/heads/develop
Commit: abf65d3a748ee8b1078ecd13adef096fb863e413
Parents: 671a154
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Mar 2 19:12:27 2017 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Mar 2 19:18:41 2017 -0800

----------------------------------------------------------------------
 newtmgr/Godeps/Godeps.json                      |  32 +-
 .../vendor/github.com/runtimeco/gatt/.gitignore |   3 +
 .../vendor/github.com/runtimeco/gatt/LICENSE.md |  27 +
 newtmgr/vendor/github.com/runtimeco/gatt/adv.go | 234 +++++
 .../vendor/github.com/runtimeco/gatt/attr.go    | 160 +++
 .../vendor/github.com/runtimeco/gatt/central.go | 152 +++
 .../github.com/runtimeco/gatt/central_darwin.go |  70 ++
 .../github.com/runtimeco/gatt/central_linux.go  | 446 +++++++++
 .../vendor/github.com/runtimeco/gatt/common.go  | 399 ++++++++
 .../vendor/github.com/runtimeco/gatt/const.go   | 153 +++
 .../vendor/github.com/runtimeco/gatt/device.go  | 161 +++
 .../github.com/runtimeco/gatt/device_darwin.go  | 513 ++++++++++
 .../github.com/runtimeco/gatt/device_linux.go   | 240 +++++
 newtmgr/vendor/github.com/runtimeco/gatt/doc.go |  88 ++
 .../github.com/runtimeco/gatt/known_uuid.go     | 122 +++
 .../runtimeco/gatt/l2cap_writer_linux.go        | 156 +++
 .../github.com/runtimeco/gatt/linux/cmd/cmd.go  | 995 +++++++++++++++++++
 .../github.com/runtimeco/gatt/linux/const.go    |  21 +
 .../github.com/runtimeco/gatt/linux/device.go   | 109 ++
 .../github.com/runtimeco/gatt/linux/devices.go  |  58 ++
 .../github.com/runtimeco/gatt/linux/doc.go      |   5 +
 .../github.com/runtimeco/gatt/linux/evt/evt.go  | 382 +++++++
 .../runtimeco/gatt/linux/gioctl/LICENSE.md      |  22 +
 .../runtimeco/gatt/linux/gioctl/README.md       |  12 +
 .../runtimeco/gatt/linux/gioctl/ioctl.go        |  57 ++
 .../github.com/runtimeco/gatt/linux/hci.go      | 400 ++++++++
 .../github.com/runtimeco/gatt/linux/l2cap.go    | 174 ++++
 .../runtimeco/gatt/linux/socket/asm.s           |   8 +
 .../runtimeco/gatt/linux/socket/asm_linux_386.s |  33 +
 .../runtimeco/gatt/linux/socket/socket.go       | 121 +++
 .../gatt/linux/socket/socket_common.go          |  24 +
 .../gatt/linux/socket/socket_darwin.go          |   6 +
 .../runtimeco/gatt/linux/socket/socket_linux.go |   7 +
 .../gatt/linux/socket/socket_linux_386.go       |  31 +
 .../runtimeco/gatt/linux/util/util.go           |  16 +
 .../github.com/runtimeco/gatt/option_darwin.go  |  15 +
 .../github.com/runtimeco/gatt/option_linux.go   |  87 ++
 .../github.com/runtimeco/gatt/peripheral.go     | 102 ++
 .../runtimeco/gatt/peripheral_darwin.go         | 277 ++++++
 .../runtimeco/gatt/peripheral_linux.go          | 448 +++++++++
 .../vendor/github.com/runtimeco/gatt/readme.md  | 115 +++
 .../vendor/github.com/runtimeco/gatt/uuid.go    |  86 ++
 .../github.com/runtimeco/gatt/xpc/LICENSE       |  21 +
 .../vendor/github.com/runtimeco/gatt/xpc/doc.go |   8 +
 .../github.com/runtimeco/gatt/xpc/xpc_darwin.go | 350 +++++++
 .../runtimeco/gatt/xpc/xpc_wrapper_darwin.c     |  85 ++
 .../runtimeco/gatt/xpc/xpc_wrapper_darwin.h     |  32 +
 .../github.com/runtimeinc/gatt/.gitignore       |   3 -
 .../github.com/runtimeinc/gatt/LICENSE.md       |  27 -
 .../vendor/github.com/runtimeinc/gatt/adv.go    | 234 -----
 .../vendor/github.com/runtimeinc/gatt/attr.go   | 160 ---
 .../github.com/runtimeinc/gatt/central.go       | 152 ---
 .../runtimeinc/gatt/central_darwin.go           |  70 --
 .../github.com/runtimeinc/gatt/central_linux.go | 446 ---------
 .../vendor/github.com/runtimeinc/gatt/common.go | 399 --------
 .../vendor/github.com/runtimeinc/gatt/const.go  | 153 ---
 .../vendor/github.com/runtimeinc/gatt/device.go | 161 ---
 .../github.com/runtimeinc/gatt/device_darwin.go | 513 ----------
 .../github.com/runtimeinc/gatt/device_linux.go  | 240 -----
 .../vendor/github.com/runtimeinc/gatt/doc.go    |  88 --
 .../github.com/runtimeinc/gatt/known_uuid.go    | 122 ---
 .../runtimeinc/gatt/l2cap_writer_linux.go       | 156 ---
 .../github.com/runtimeinc/gatt/linux/cmd/cmd.go | 995 -------------------
 .../github.com/runtimeinc/gatt/linux/const.go   |  21 -
 .../github.com/runtimeinc/gatt/linux/device.go  | 109 --
 .../github.com/runtimeinc/gatt/linux/devices.go |  58 --
 .../github.com/runtimeinc/gatt/linux/doc.go     |   5 -
 .../github.com/runtimeinc/gatt/linux/evt/evt.go | 382 -------
 .../runtimeinc/gatt/linux/gioctl/LICENSE.md     |  22 -
 .../runtimeinc/gatt/linux/gioctl/README.md      |  12 -
 .../runtimeinc/gatt/linux/gioctl/ioctl.go       |  57 --
 .../github.com/runtimeinc/gatt/linux/hci.go     | 400 --------
 .../github.com/runtimeinc/gatt/linux/l2cap.go   | 174 ----
 .../runtimeinc/gatt/linux/socket/asm.s          |   8 -
 .../gatt/linux/socket/asm_linux_386.s           |  33 -
 .../runtimeinc/gatt/linux/socket/socket.go      | 121 ---
 .../gatt/linux/socket/socket_common.go          |  24 -
 .../gatt/linux/socket/socket_darwin.go          |   6 -
 .../gatt/linux/socket/socket_linux.go           |   7 -
 .../gatt/linux/socket/socket_linux_386.go       |  31 -
 .../runtimeinc/gatt/linux/util/util.go          |  16 -
 .../github.com/runtimeinc/gatt/option_darwin.go |  15 -
 .../github.com/runtimeinc/gatt/option_linux.go  |  87 --
 .../github.com/runtimeinc/gatt/peripheral.go    | 102 --
 .../runtimeinc/gatt/peripheral_darwin.go        | 277 ------
 .../runtimeinc/gatt/peripheral_linux.go         | 448 ---------
 .../vendor/github.com/runtimeinc/gatt/readme.md | 115 ---
 .../vendor/github.com/runtimeinc/gatt/uuid.go   |  86 --
 .../github.com/runtimeinc/gatt/xpc/LICENSE      |  21 -
 .../github.com/runtimeinc/gatt/xpc/doc.go       |   8 -
 .../runtimeinc/gatt/xpc/xpc_darwin.go           | 350 -------
 .../runtimeinc/gatt/xpc/xpc_wrapper_darwin.c    |  85 --
 .../runtimeinc/gatt/xpc/xpc_wrapper_darwin.h    |  32 -
 93 files changed, 7061 insertions(+), 7033 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/Godeps/Godeps.json
----------------------------------------------------------------------
diff --git a/newtmgr/Godeps/Godeps.json b/newtmgr/Godeps/Godeps.json
index b2571e8..b486ebe 100644
--- a/newtmgr/Godeps/Godeps.json
+++ b/newtmgr/Godeps/Godeps.json
@@ -38,8 +38,8 @@
 			"Rev": "f3009df150dadf309fdee4a54ed65c124afad715"
 		},
 		{
-			"ImportPath": "github.com/runtimeinc/gatt",
-			"Rev": "a8b4c64987af1491ef629e5ec45d3fc47df29eb9"
+			"ImportPath": "github.com/runtimeco/gatt",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
 		},
 		{
 			"ImportPath": "github.com/runtimeinc/gatt/linux",
@@ -116,6 +116,34 @@
 			"ImportPath": "mynewt.apache.org/newt/yaml",
 			"Comment": "pre_sterly_refactor-137-gfcecea4",
 			"Rev": "fcecea4b13ab467168e936a51ef01695833644d8"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/linux",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/linux/cmd",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/xpc",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/linux/evt",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/linux/gioctl",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/linux/socket",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+		},
+		{
+			"ImportPath": "github.com/runtimeco/gatt/linux/util",
+			"Rev": "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
 		}
 	]
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/.gitignore
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/.gitignore b/newtmgr/vendor/github.com/runtimeco/gatt/.gitignore
new file mode 100644
index 0000000..7ab0687
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/.gitignore
@@ -0,0 +1,3 @@
+c.out
+c/*-ble
+sample

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/LICENSE.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/LICENSE.md b/newtmgr/vendor/github.com/runtimeco/gatt/LICENSE.md
new file mode 100644
index 0000000..51c07a6
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/LICENSE.md
@@ -0,0 +1,27 @@
+Copyright (c) 2014 PayPal Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+   * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+   * Neither the name of PayPal Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/adv.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/adv.go b/newtmgr/vendor/github.com/runtimeco/gatt/adv.go
new file mode 100644
index 0000000..3b8a747
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/adv.go
@@ -0,0 +1,234 @@
+package gatt
+
+import (
+	"errors"
+	"log"
+)
+
+// MaxEIRPacketLength is the maximum allowed AdvertisingPacket
+// and ScanResponsePacket length.
+const MaxEIRPacketLength = 31
+
+// ErrEIRPacketTooLong is the error returned when an AdvertisingPacket
+// or ScanResponsePacket is too long.
+var ErrEIRPacketTooLong = errors.New("max packet length is 31")
+
+// Advertising data field types
+const (
+	typeFlags             = 0x01 // Flags
+	typeSomeUUID16        = 0x02 // Incomplete List of 16-bit Service Class UUIDs
+	typeAllUUID16         = 0x03 // Complete List of 16-bit Service Class UUIDs
+	typeSomeUUID32        = 0x04 // Incomplete List of 32-bit Service Class UUIDs
+	typeAllUUID32         = 0x05 // Complete List of 32-bit Service Class UUIDs
+	typeSomeUUID128       = 0x06 // Incomplete List of 128-bit Service Class UUIDs
+	typeAllUUID128        = 0x07 // Complete List of 128-bit Service Class UUIDs
+	typeShortName         = 0x08 // Shortened Local Name
+	typeCompleteName      = 0x09 // Complete Local Name
+	typeTxPower           = 0x0A // Tx Power Level
+	typeClassOfDevice     = 0x0D // Class of Device
+	typeSimplePairingC192 = 0x0E // Simple Pairing Hash C-192
+	typeSimplePairingR192 = 0x0F // Simple Pairing Randomizer R-192
+	typeSecManagerTK      = 0x10 // Security Manager TK Value
+	typeSecManagerOOB     = 0x11 // Security Manager Out of Band Flags
+	typeSlaveConnInt      = 0x12 // Slave Connection Interval Range
+	typeServiceSol16      = 0x14 // List of 16-bit Service Solicitation UUIDs
+	typeServiceSol128     = 0x15 // List of 128-bit Service Solicitation UUIDs
+	typeServiceData16     = 0x16 // Service Data - 16-bit UUID
+	typePubTargetAddr     = 0x17 // Public Target Address
+	typeRandTargetAddr    = 0x18 // Random Target Address
+	typeAppearance        = 0x19 // Appearance
+	typeAdvInterval       = 0x1A // Advertising Interval
+	typeLEDeviceAddr      = 0x1B // LE Bluetooth Device Address
+	typeLERole            = 0x1C // LE Role
+	typeServiceSol32      = 0x1F // List of 32-bit Service Solicitation UUIDs
+	typeServiceData32     = 0x20 // Service Data - 32-bit UUID
+	typeServiceData128    = 0x21 // Service Data - 128-bit UUID
+	typeLESecConfirm      = 0x22 // LE Secure Connections Confirmation Value
+	typeLESecRandom       = 0x23 // LE Secure Connections Random Value
+	typeManufacturerData  = 0xFF // Manufacturer Specific Data
+)
+
+// Advertising type flags
+const (
+	flagLimitedDiscoverable = 0x01 // LE Limited Discoverable Mode
+	flagGeneralDiscoverable = 0x02 // LE General Discoverable Mode
+	flagLEOnly              = 0x04 // BR/EDR Not Supported. Bit 37 of LMP Feature Mask Definitions (Page 0)
+	flagBothController      = 0x08 // Simultaneous LE and BR/EDR to Same Device Capable (Controller).
+	flagBothHost            = 0x10 // Simultaneous LE and BR/EDR to Same Device Capable (Host).
+)
+
+// FIXME: check the unmarshalling of this data structure.
+type ServiceData struct {
+	UUID UUID
+	Data []byte
+}
+
+// This is borrowed from core bluetooth.
+// Embedded/Linux folks might be interested in more details.
+type Advertisement struct {
+	LocalName        string
+	ManufacturerData []byte
+	ServiceData      []ServiceData
+	Services         []UUID
+	OverflowService  []UUID
+	TxPowerLevel     int
+	Connectable      bool
+	SolicitedService []UUID
+	AddressType uint8
+	Address     [6]byte
+}
+
+// This is only used in Linux port.
+func (a *Advertisement) unmarshall(b []byte) error {
+
+	// Utility function for creating a list of uuids.
+	uuidList := func(u []UUID, d []byte, w int) []UUID {
+		for len(d) > 0 {
+			u = append(u, UUID{d[:w]})
+			d = d[w:]
+		}
+		return u
+	}
+
+	for len(b) > 0 {
+		if len(b) < 2 {
+			return errors.New("invalid advertise data")
+		}
+		l, t := b[0], b[1]
+		if len(b) < int(1+l) {
+			return errors.New("invalid advertise data")
+		}
+		d := b[2 : 1+l]
+		switch t {
+		case typeFlags:
+			// TODO: should we do anything about the discoverability here?
+		case typeSomeUUID16:
+			a.Services = uuidList(a.Services, d, 2)
+		case typeAllUUID16:
+			a.Services = uuidList(a.Services, d, 2)
+		case typeSomeUUID32:
+			a.Services = uuidList(a.Services, d, 4)
+		case typeAllUUID32:
+			a.Services = uuidList(a.Services, d, 4)
+		case typeSomeUUID128:
+			a.Services = uuidList(a.Services, d, 16)
+		case typeAllUUID128:
+			a.Services = uuidList(a.Services, d, 16)
+		case typeShortName:
+			a.LocalName = string(d)
+		case typeCompleteName:
+			a.LocalName = string(d)
+		case typeTxPower:
+			a.TxPowerLevel = int(d[0])
+		case typeServiceSol16:
+			a.SolicitedService = uuidList(a.SolicitedService, d, 2)
+		case typeServiceSol128:
+			a.SolicitedService = uuidList(a.SolicitedService, d, 16)
+		case typeServiceSol32:
+			a.SolicitedService = uuidList(a.SolicitedService, d, 4)
+		case typeManufacturerData:
+			a.ManufacturerData = make([]byte, len(d))
+			copy(a.ManufacturerData, d)
+		// case typeServiceData16,
+		// case typeServiceData32,
+		// case typeServiceData128:
+		default:
+			log.Printf("DATA: [ % X ]", d)
+		}
+		b = b[1+l:]
+	}
+	return nil
+}
+
+// AdvPacket is an utility to help crafting advertisment or scan response data.
+type AdvPacket struct {
+	b []byte
+}
+
+// Bytes returns an 31-byte array, which contains up to 31 bytes of the packet.
+func (a *AdvPacket) Bytes() [31]byte {
+	b := [31]byte{}
+	copy(b[:], a.b)
+	return b
+}
+
+// Len returns the length of the packets with a maximum of 31.
+func (a *AdvPacket) Len() int {
+	if len(a.b) > 31 {
+		return 31
+	}
+	return len(a.b)
+}
+
+// AppendField appends a BLE advertising packet field.
+// TODO: refuse to append field if it'd make the packet too long.
+func (a *AdvPacket) AppendField(typ byte, b []byte) *AdvPacket {
+	// A field consists of len, typ, b.
+	// Len is 1 byte for typ plus len(b).
+	if len(a.b)+2+len(b) > MaxEIRPacketLength {
+		b = b[:MaxEIRPacketLength-len(a.b)-2]
+	}
+	a.b = append(a.b, byte(len(b)+1))
+	a.b = append(a.b, typ)
+	a.b = append(a.b, b...)
+	return a
+}
+
+// AppendFlags appends a flag field to the packet.
+func (a *AdvPacket) AppendFlags(f byte) *AdvPacket {
+	return a.AppendField(typeFlags, []byte{f})
+}
+
+// AppendFlags appends a name field to the packet.
+// If the name fits in the space, it will be append as a complete name field, otherwise a short name field.
+func (a *AdvPacket) AppendName(n string) *AdvPacket {
+	typ := byte(typeCompleteName)
+	if len(a.b)+2+len(n) > MaxEIRPacketLength {
+		typ = byte(typeShortName)
+	}
+	return a.AppendField(typ, []byte(n))
+}
+
+// AppendManufacturerData appends a manufacturer data field to the packet.
+func (a *AdvPacket) AppendManufacturerData(id uint16, b []byte) *AdvPacket {
+	d := append([]byte{uint8(id), uint8(id >> 8)}, b...)
+	return a.AppendField(typeManufacturerData, d)
+}
+
+// AppendUUIDFit appends a BLE advertised service UUID
+// packet field if it fits in the packet, and reports whether the UUID fit.
+func (a *AdvPacket) AppendUUIDFit(uu []UUID) bool {
+	// Iterate all UUIDs to see if they fit in the packet or not.
+	fit, l := true, len(a.b)
+	for _, u := range uu {
+		if u.Equal(attrGAPUUID) || u.Equal(attrGATTUUID) {
+			continue
+		}
+		l += 2 + u.Len()
+		if l > MaxEIRPacketLength {
+			fit = false
+			break
+		}
+	}
+
+	// Append the UUIDs until they no longer fit.
+	for _, u := range uu {
+		if u.Equal(attrGAPUUID) || u.Equal(attrGATTUUID) {
+			continue
+		}
+		if len(a.b)+2+u.Len() > MaxEIRPacketLength {
+			break
+		}
+		switch l = u.Len(); {
+		case l == 2 && fit:
+			a.AppendField(typeAllUUID16, u.b)
+		case l == 16 && fit:
+			a.AppendField(typeAllUUID128, u.b)
+		case l == 2 && !fit:
+			a.AppendField(typeSomeUUID16, u.b)
+		case l == 16 && !fit:
+			a.AppendField(typeSomeUUID128, u.b)
+		}
+	}
+	return fit
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/attr.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/attr.go b/newtmgr/vendor/github.com/runtimeco/gatt/attr.go
new file mode 100644
index 0000000..d1ae09d
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/attr.go
@@ -0,0 +1,160 @@
+package gatt
+
+import "log"
+
+// attr is a BLE attribute. It is not exported;
+// managing attributes is an implementation detail.
+type attr struct {
+	h      uint16   // attribute handle
+	typ    UUID     // attribute type in UUID
+	props  Property // attripute property
+	secure Property // attribute secure (implementation specific usage)
+	value  []byte   // attribute value
+
+	pvt interface{} // point to the corresponsing Serveice/Characteristic/Descriptor
+}
+
+// A attrRange is a contiguous range of attributes.
+type attrRange struct {
+	aa   []attr
+	base uint16 // handle for first attr in aa
+}
+
+const (
+	tooSmall = -1
+	tooLarge = -2
+)
+
+// idx returns the index into aa corresponding to attr a.
+// If h is too small, idx returns tooSmall (-1).
+// If h is too large, idx returns tooLarge (-2).
+func (r *attrRange) idx(h int) int {
+	if h < int(r.base) {
+		return tooSmall
+	}
+	if int(h) >= int(r.base)+len(r.aa) {
+		return tooLarge
+	}
+	return h - int(r.base)
+}
+
+// At returns attr a.
+func (r *attrRange) At(h uint16) (a attr, ok bool) {
+	i := r.idx(int(h))
+	if i < 0 {
+		return attr{}, false
+	}
+	return r.aa[i], true
+}
+
+// Subrange returns attributes in range [start, end]; it may
+// return an empty slice. Subrange does not panic for
+// out-of-range start or end.
+func (r *attrRange) Subrange(start, end uint16) []attr {
+	startidx := r.idx(int(start))
+	switch startidx {
+	case tooSmall:
+		startidx = 0
+	case tooLarge:
+		return []attr{}
+	}
+
+	endidx := r.idx(int(end) + 1) // [start, end] includes its upper bound!
+	switch endidx {
+	case tooSmall:
+		return []attr{}
+	case tooLarge:
+		endidx = len(r.aa)
+	}
+	return r.aa[startidx:endidx]
+}
+
+func dumpAttributes(aa []attr) {
+	log.Printf("Generating attribute table:")
+	log.Printf("handle\ttype\tprops\tsecure\tpvt\tvalue")
+	for _, a := range aa {
+		log.Printf("0x%04X\t0x%s\t0x%02X\t0x%02x\t%T\t[ % X ]",
+			a.h, a.typ, int(a.props), int(a.secure), a.pvt, a.value)
+	}
+}
+
+func generateAttributes(ss []*Service, base uint16) *attrRange {
+	var aa []attr
+	h := base
+	last := len(ss) - 1
+	for i, s := range ss {
+		var a []attr
+		h, a = generateServiceAttributes(s, h, i == last)
+		aa = append(aa, a...)
+	}
+	dumpAttributes(aa)
+	return &attrRange{aa: aa, base: base}
+}
+
+func generateServiceAttributes(s *Service, h uint16, last bool) (uint16, []attr) {
+	s.h = h
+	// endh set later
+	a := attr{
+		h:     h,
+		typ:   attrPrimaryServiceUUID,
+		value: s.uuid.b,
+		props: CharRead,
+		pvt:   s,
+	}
+	aa := []attr{a}
+	h++
+
+	for _, c := range s.Characteristics() {
+		var a []attr
+		h, a = generateCharAttributes(c, h)
+		aa = append(aa, a...)
+	}
+
+	s.endh = h - 1
+	if last {
+		h = 0xFFFF
+		s.endh = h
+	}
+
+	return h, aa
+}
+
+func generateCharAttributes(c *Characteristic, h uint16) (uint16, []attr) {
+	c.h = h
+	c.vh = h + 1
+	ca := attr{
+		h:     c.h,
+		typ:   attrCharacteristicUUID,
+		value: append([]byte{byte(c.props), byte(c.vh), byte((c.vh) >> 8)}, c.uuid.b...),
+		props: c.props,
+		pvt:   c,
+	}
+	va := attr{
+		h:     c.vh,
+		typ:   c.uuid,
+		value: c.value,
+		props: c.props,
+		pvt:   c,
+	}
+	h += 2
+
+	aa := []attr{ca, va}
+	for _, d := range c.descs {
+		aa = append(aa, generateDescAttributes(d, h))
+		h++
+	}
+
+	return h, aa
+}
+
+func generateDescAttributes(d *Descriptor, h uint16) attr {
+	d.h = h
+	a := attr{
+		h:     h,
+		typ:   d.uuid,
+		value: d.value,
+		props: d.props,
+		pvt:   d,
+	}
+	return a
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/central.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/central.go b/newtmgr/vendor/github.com/runtimeco/gatt/central.go
new file mode 100644
index 0000000..55bd2c1
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/central.go
@@ -0,0 +1,152 @@
+package gatt
+
+import (
+	"bytes"
+	"errors"
+	"fmt"
+	"sync"
+)
+
+// Central is the interface that represent a remote central device.
+type Central interface {
+	ID() string   // ID returns platform specific ID of the remote central device.
+	Close() error // Close disconnects the connection.
+	MTU() int     // MTU returns the current connection mtu.
+}
+
+type ResponseWriter interface {
+	// Write writes data to return as the characteristic value.
+	Write([]byte) (int, error)
+
+	// SetStatus reports the result of the read operation. See the Status* constants.
+	SetStatus(byte)
+}
+
+// responseWriter is the default implementation of ResponseWriter.
+type responseWriter struct {
+	capacity int
+	buf      *bytes.Buffer
+	status   byte
+}
+
+func newResponseWriter(c int) *responseWriter {
+	return &responseWriter{
+		capacity: c,
+		buf:      new(bytes.Buffer),
+		status:   StatusSuccess,
+	}
+}
+
+func (w *responseWriter) Write(b []byte) (int, error) {
+	if avail := w.capacity - w.buf.Len(); avail < len(b) {
+		return 0, fmt.Errorf("requested write %d bytes, %d available", len(b), avail)
+	}
+	return w.buf.Write(b)
+}
+
+func (w *responseWriter) SetStatus(status byte) { w.status = status }
+func (w *responseWriter) bytes() []byte         { return w.buf.Bytes() }
+
+// A ReadHandler handles GATT read requests.
+type ReadHandler interface {
+	ServeRead(resp ResponseWriter, req *ReadRequest)
+}
+
+// ReadHandlerFunc is an adapter to allow the use of
+// ordinary functions as ReadHandlers. If f is a function
+// with the appropriate signature, ReadHandlerFunc(f) is a
+// ReadHandler that calls f.
+type ReadHandlerFunc func(resp ResponseWriter, req *ReadRequest)
+
+// ServeRead returns f(r, maxlen, offset).
+func (f ReadHandlerFunc) ServeRead(resp ResponseWriter, req *ReadRequest) {
+	f(resp, req)
+}
+
+// A WriteHandler handles GATT write requests.
+// Write and WriteNR requests are presented identically;
+// the server will ensure that a response is sent if appropriate.
+type WriteHandler interface {
+	ServeWrite(r Request, data []byte) (status byte)
+}
+
+// WriteHandlerFunc is an adapter to allow the use of
+// ordinary functions as WriteHandlers. If f is a function
+// with the appropriate signature, WriteHandlerFunc(f) is a
+// WriteHandler that calls f.
+type WriteHandlerFunc func(r Request, data []byte) byte
+
+// ServeWrite returns f(r, data).
+func (f WriteHandlerFunc) ServeWrite(r Request, data []byte) byte {
+	return f(r, data)
+}
+
+// A NotifyHandler handles GATT notification requests.
+// Notifications can be sent using the provided notifier.
+type NotifyHandler interface {
+	ServeNotify(r Request, n Notifier)
+}
+
+// NotifyHandlerFunc is an adapter to allow the use of
+// ordinary functions as NotifyHandlers. If f is a function
+// with the appropriate signature, NotifyHandlerFunc(f) is a
+// NotifyHandler that calls f.
+type NotifyHandlerFunc func(r Request, n Notifier)
+
+// ServeNotify calls f(r, n).
+func (f NotifyHandlerFunc) ServeNotify(r Request, n Notifier) {
+	f(r, n)
+}
+
+// A Notifier provides a means for a GATT server to send
+// notifications about value changes to a connected device.
+// Notifiers are provided by NotifyHandlers.
+type Notifier interface {
+	// Write sends data to the central.
+	Write(data []byte) (int, error)
+
+	// Done reports whether the central has requested not to
+	// receive any more notifications with this notifier.
+	Done() bool
+
+	// Cap returns the maximum number of bytes that may be sent
+	// in a single notification.
+	Cap() int
+}
+
+type notifier struct {
+	central *central
+	a       *attr
+	maxlen  int
+	donemu  sync.RWMutex
+	done    bool
+}
+
+func newNotifier(c *central, a *attr, maxlen int) *notifier {
+	return &notifier{central: c, a: a, maxlen: maxlen}
+}
+
+func (n *notifier) Write(b []byte) (int, error) {
+	n.donemu.RLock()
+	defer n.donemu.RUnlock()
+	if n.done {
+		return 0, errors.New("central stopped notifications")
+	}
+	return n.central.sendNotification(n.a, b)
+}
+
+func (n *notifier) Cap() int {
+	return n.maxlen
+}
+
+func (n *notifier) Done() bool {
+	n.donemu.RLock()
+	defer n.donemu.RUnlock()
+	return n.done
+}
+
+func (n *notifier) stop() {
+	n.donemu.Lock()
+	n.done = true
+	n.donemu.Unlock()
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/central_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/central_darwin.go b/newtmgr/vendor/github.com/runtimeco/gatt/central_darwin.go
new file mode 100644
index 0000000..47faa2e
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/central_darwin.go
@@ -0,0 +1,70 @@
+package gatt
+
+import (
+	"sync"
+
+	"github.com/runtimeco/gatt/xpc"
+)
+
+type central struct {
+	dev         *device
+	uuid        UUID
+	mtu         int
+	notifiers   map[uint16]*notifier
+	notifiersmu *sync.Mutex
+}
+
+func newCentral(d *device, u UUID) *central {
+	return &central{
+		dev:         d,
+		mtu:         23,
+		uuid:        u,
+		notifiers:   make(map[uint16]*notifier),
+		notifiersmu: &sync.Mutex{},
+	}
+}
+
+func (c *central) ID() string   { return c.uuid.String() }
+func (c *central) Close() error { return nil }
+func (c *central) MTU() int     { return c.mtu }
+
+func (c *central) sendNotification(a *attr, b []byte) (int, error) {
+	data := make([]byte, len(b))
+	copy(data, b) // have to make a copy, why?
+	c.dev.sendCmd(15, xpc.Dict{
+		// "kCBMsgArgUUIDs": [][]byte{reverse(c.uuid.b)}, // connection interrupted
+		// "kCBMsgArgUUIDs": [][]byte{c.uuid.b}, // connection interrupted
+		// "kCBMsgArgUUIDs": []xpc.UUID{xpc.UUID(reverse(c.uuid.b))},
+		// "kCBMsgArgUUIDs": []xpc.UUID{xpc.UUID(c.uuid.b)},
+		// "kCBMsgArgUUIDs": reverse(c.uuid.b),
+		//
+		// FIXME: Sigh... tried to targeting the central, but couldn't get work.
+		// So, broadcast to all subscribed centrals. Either of the following works.
+		// "kCBMsgArgUUIDs": []xpc.UUID{},
+		"kCBMsgArgUUIDs":       [][]byte{},
+		"kCBMsgArgAttributeID": a.h,
+		"kCBMsgArgData":        data,
+	})
+	return len(b), nil
+}
+
+func (c *central) startNotify(a *attr, maxlen int) {
+	c.notifiersmu.Lock()
+	defer c.notifiersmu.Unlock()
+	if _, found := c.notifiers[a.h]; found {
+		return
+	}
+	n := newNotifier(c, a, maxlen)
+	c.notifiers[a.h] = n
+	char := a.pvt.(*Characteristic)
+	go char.nhandler.ServeNotify(Request{Central: c}, n)
+}
+
+func (c *central) stopNotify(a *attr) {
+	c.notifiersmu.Lock()
+	defer c.notifiersmu.Unlock()
+	if n, found := c.notifiers[a.h]; found {
+		n.stop()
+		delete(c.notifiers, a.h)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/central_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/central_linux.go b/newtmgr/vendor/github.com/runtimeco/gatt/central_linux.go
new file mode 100644
index 0000000..3ae6994
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/central_linux.go
@@ -0,0 +1,446 @@
+package gatt
+
+import (
+	"encoding/binary"
+	"io"
+	"net"
+	"sync"
+)
+
+type security int
+
+const (
+	securityLow = iota
+	securityMed
+	securityHigh
+)
+
+type central struct {
+	attrs       *attrRange
+	mtu         uint16
+	addr        net.HardwareAddr
+	security    security
+	l2conn      io.ReadWriteCloser
+	notifiers   map[uint16]*notifier
+	notifiersmu *sync.Mutex
+}
+
+func newCentral(a *attrRange, addr net.HardwareAddr, l2conn io.ReadWriteCloser) *central {
+	return &central{
+		attrs:       a,
+		mtu:         23,
+		addr:        addr,
+		security:    securityLow,
+		l2conn:      l2conn,
+		notifiers:   make(map[uint16]*notifier),
+		notifiersmu: &sync.Mutex{},
+	}
+}
+
+func (c *central) ID() string {
+	return c.addr.String()
+}
+
+func (c *central) Close() error {
+	c.notifiersmu.Lock()
+	defer c.notifiersmu.Unlock()
+	for _, n := range c.notifiers {
+		n.stop()
+	}
+	return c.l2conn.Close()
+}
+
+func (c *central) MTU() int {
+	return int(c.mtu)
+}
+
+func (c *central) loop() {
+	for {
+		// L2CAP implementations shall support a minimum MTU size of 48 bytes.
+		// The default value is 672 bytes
+		b := make([]byte, 672)
+		n, err := c.l2conn.Read(b)
+		if n == 0 || err != nil {
+			c.Close()
+			break
+		}
+		if rsp := c.handleReq(b[:n]); rsp != nil {
+			c.l2conn.Write(rsp)
+		}
+	}
+}
+
+// handleReq dispatches a raw request from the central shim
+// to an appropriate handler, based on its type.
+// It panics if len(b) == 0.
+func (c *central) handleReq(b []byte) []byte {
+	var resp []byte
+	switch reqType, req := b[0], b[1:]; reqType {
+	case attOpMtuReq:
+		resp = c.handleMTU(req)
+	case attOpFindInfoReq:
+		resp = c.handleFindInfo(req)
+	case attOpFindByTypeValueReq:
+		resp = c.handleFindByTypeValue(req)
+	case attOpReadByTypeReq:
+		resp = c.handleReadByType(req)
+	case attOpReadReq:
+		resp = c.handleRead(req)
+	case attOpReadBlobReq:
+		resp = c.handleReadBlob(req)
+	case attOpReadByGroupReq:
+		resp = c.handleReadByGroup(req)
+	case attOpWriteReq, attOpWriteCmd:
+		resp = c.handleWrite(reqType, req)
+	case attOpReadMultiReq, attOpPrepWriteReq, attOpExecWriteReq, attOpSignedWriteCmd:
+		fallthrough
+	default:
+		resp = attErrorRsp(reqType, 0x0000, attEcodeReqNotSupp)
+	}
+	return resp
+}
+
+func (c *central) handleMTU(b []byte) []byte {
+	c.mtu = binary.LittleEndian.Uint16(b[:2])
+	if c.mtu < 23 {
+		c.mtu = 23
+	}
+	if c.mtu >= 256 {
+		c.mtu = 256
+	}
+	return []byte{attOpMtuRsp, uint8(c.mtu), uint8(c.mtu >> 8)}
+}
+
+// REQ: FindInfoReq(0x04), StartHandle, EndHandle
+// RSP: FindInfoRsp(0x05), UUIDFormat, Handle, UUID, Handle, UUID, ...
+func (c *central) handleFindInfo(b []byte) []byte {
+	start, end := readHandleRange(b[:4])
+
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpFindInfoRsp)
+
+	uuidLen := -1
+	for _, a := range c.attrs.Subrange(start, end) {
+		if uuidLen == -1 {
+			uuidLen = a.typ.Len()
+			if uuidLen == 2 {
+				w.WriteByteFit(0x01) // TODO: constants for 16bit vs 128bit uuid magic numbers here
+			} else {
+				w.WriteByteFit(0x02)
+			}
+		}
+		if a.typ.Len() != uuidLen {
+			break
+		}
+		w.Chunk()
+		w.WriteUint16Fit(a.h)
+		w.WriteUUIDFit(a.typ)
+		if ok := w.Commit(); !ok {
+			break
+		}
+	}
+
+	if uuidLen == -1 {
+		return attErrorRsp(attOpFindInfoReq, start, attEcodeAttrNotFound)
+	}
+	return w.Bytes()
+}
+
+// REQ: FindByTypeValueReq(0x06), StartHandle, EndHandle, Type(UUID), Value
+// RSP: FindByTypeValueRsp(0x07), AttrHandle, GroupEndHandle, AttrHandle, GroupEndHandle, ...
+func (c *central) handleFindByTypeValue(b []byte) []byte {
+	start, end := readHandleRange(b[:4])
+	t := UUID{b[4:6]}
+	u := UUID{b[6:]}
+
+	// Only support the ATT ReadByGroupReq for GATT Primary Service Discovery.
+	// More sepcifically, the "Discover Primary Services By Service UUID" sub-procedure
+	if !t.Equal(attrPrimaryServiceUUID) {
+		return attErrorRsp(attOpFindByTypeValueReq, start, attEcodeAttrNotFound)
+	}
+
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpFindByTypeValueRsp)
+
+	var wrote bool
+	for _, a := range c.attrs.Subrange(start, end) {
+		if !a.typ.Equal(attrPrimaryServiceUUID) {
+			continue
+		}
+		if !(UUID{a.value}.Equal(u)) {
+			continue
+		}
+		s := a.pvt.(*Service)
+		w.Chunk()
+		w.WriteUint16Fit(s.h)
+		w.WriteUint16Fit(s.endh)
+		if ok := w.Commit(); !ok {
+			break
+		}
+		wrote = true
+	}
+	if !wrote {
+		return attErrorRsp(attOpFindByTypeValueReq, start, attEcodeAttrNotFound)
+	}
+
+	return w.Bytes()
+}
+
+// REQ: ReadByType(0x08), StartHandle, EndHandle, Type(UUID)
+// RSP: ReadByType(0x09), LenOfEachDataField, DataField, DataField, ...
+func (c *central) handleReadByType(b []byte) []byte {
+	start, end := readHandleRange(b[:4])
+	t := UUID{b[4:]}
+
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpReadByTypeRsp)
+	uuidLen := -1
+	for _, a := range c.attrs.Subrange(start, end) {
+		if !a.typ.Equal(t) {
+			continue
+		}
+		if (a.secure&CharRead) != 0 && c.security > securityLow {
+			return attErrorRsp(attOpReadByTypeReq, start, attEcodeAuthentication)
+		}
+		v := a.value
+		if v == nil {
+			rsp := newResponseWriter(int(c.mtu - 1))
+			req := &ReadRequest{
+				Request: Request{Central: c},
+				Cap:     int(c.mtu - 1),
+				Offset:  0,
+			}
+			if c, ok := a.pvt.(*Characteristic); ok {
+				c.rhandler.ServeRead(rsp, req)
+			} else if d, ok := a.pvt.(*Descriptor); ok {
+				d.rhandler.ServeRead(rsp, req)
+			}
+			v = rsp.bytes()
+		}
+		if uuidLen == -1 {
+			uuidLen = len(v)
+			w.WriteByteFit(byte(uuidLen) + 2)
+		}
+		if len(v) != uuidLen {
+			break
+		}
+		w.Chunk()
+		w.WriteUint16Fit(a.h)
+		w.WriteFit(v)
+		if ok := w.Commit(); !ok {
+			break
+		}
+	}
+	if uuidLen == -1 {
+		return attErrorRsp(attOpReadByTypeReq, start, attEcodeAttrNotFound)
+	}
+	return w.Bytes()
+}
+
+// REQ: ReadReq(0x0A), Handle
+// RSP: ReadRsp(0x0B), Value
+func (c *central) handleRead(b []byte) []byte {
+	h := binary.LittleEndian.Uint16(b)
+	a, ok := c.attrs.At(h)
+	if !ok {
+		return attErrorRsp(attOpReadReq, h, attEcodeInvalidHandle)
+	}
+	if a.props&CharRead == 0 {
+		return attErrorRsp(attOpReadReq, h, attEcodeReadNotPerm)
+	}
+	if a.secure&CharRead != 0 && c.security > securityLow {
+		return attErrorRsp(attOpReadReq, h, attEcodeAuthentication)
+	}
+	v := a.value
+	if v == nil {
+		req := &ReadRequest{
+			Request: Request{Central: c},
+			Cap:     int(c.mtu - 1),
+			Offset:  0,
+		}
+		rsp := newResponseWriter(int(c.mtu - 1))
+		if c, ok := a.pvt.(*Characteristic); ok {
+			c.rhandler.ServeRead(rsp, req)
+		} else if d, ok := a.pvt.(*Descriptor); ok {
+			d.rhandler.ServeRead(rsp, req)
+		}
+		v = rsp.bytes()
+	}
+
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpReadRsp)
+	w.Chunk()
+	w.WriteFit(v)
+	w.CommitFit()
+	return w.Bytes()
+}
+
+// FIXME: check this, untested, might be broken
+func (c *central) handleReadBlob(b []byte) []byte {
+	h := binary.LittleEndian.Uint16(b)
+	offset := binary.LittleEndian.Uint16(b[2:])
+	a, ok := c.attrs.At(h)
+	if !ok {
+		return attErrorRsp(attOpReadBlobReq, h, attEcodeInvalidHandle)
+	}
+	if a.props&CharRead == 0 {
+		return attErrorRsp(attOpReadBlobReq, h, attEcodeReadNotPerm)
+	}
+	if a.secure&CharRead != 0 && c.security > securityLow {
+		return attErrorRsp(attOpReadBlobReq, h, attEcodeAuthentication)
+	}
+	v := a.value
+	if v == nil {
+		req := &ReadRequest{
+			Request: Request{Central: c},
+			Cap:     int(c.mtu - 1),
+			Offset:  int(offset),
+		}
+		rsp := newResponseWriter(int(c.mtu - 1))
+		if c, ok := a.pvt.(*Characteristic); ok {
+			c.rhandler.ServeRead(rsp, req)
+		} else if d, ok := a.pvt.(*Descriptor); ok {
+			d.rhandler.ServeRead(rsp, req)
+		}
+		v = rsp.bytes()
+		offset = 0 // the server has already adjusted for the offset
+	}
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpReadBlobRsp)
+	w.Chunk()
+	w.WriteFit(v)
+	if ok := w.ChunkSeek(offset); !ok {
+		return attErrorRsp(attOpReadBlobReq, h, attEcodeInvalidOffset)
+	}
+	w.CommitFit()
+	return w.Bytes()
+}
+
+func (c *central) handleReadByGroup(b []byte) []byte {
+	start, end := readHandleRange(b)
+	t := UUID{b[4:]}
+
+	// Only support the ATT ReadByGroupReq for GATT Primary Service Discovery.
+	// More specifically, the "Discover All Primary Services" sub-procedure.
+	if !t.Equal(attrPrimaryServiceUUID) {
+		return attErrorRsp(attOpReadByGroupReq, start, attEcodeUnsuppGrpType)
+	}
+
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpReadByGroupRsp)
+	uuidLen := -1
+	for _, a := range c.attrs.Subrange(start, end) {
+		if !a.typ.Equal(attrPrimaryServiceUUID) {
+			continue
+		}
+		if uuidLen == -1 {
+			uuidLen = len(a.value)
+			w.WriteByteFit(byte(uuidLen + 4))
+		}
+		if uuidLen != len(a.value) {
+			break
+		}
+		s := a.pvt.(*Service)
+		w.Chunk()
+		w.WriteUint16Fit(s.h)
+		w.WriteUint16Fit(s.endh)
+		w.WriteFit(a.value)
+		if ok := w.Commit(); !ok {
+			break
+		}
+	}
+	if uuidLen == -1 {
+		return attErrorRsp(attOpReadByGroupReq, start, attEcodeAttrNotFound)
+	}
+	return w.Bytes()
+}
+
+func (c *central) handleWrite(reqType byte, b []byte) []byte {
+	h := binary.LittleEndian.Uint16(b[:2])
+	value := b[2:]
+
+	a, ok := c.attrs.At(h)
+	if !ok {
+		return attErrorRsp(reqType, h, attEcodeInvalidHandle)
+	}
+
+	noRsp := reqType == attOpWriteCmd
+	charFlag := CharWrite
+	if noRsp {
+		charFlag = CharWriteNR
+	}
+	if a.props&charFlag == 0 {
+		return attErrorRsp(reqType, h, attEcodeWriteNotPerm)
+	}
+	if a.secure&charFlag == 0 && c.security > securityLow {
+		return attErrorRsp(reqType, h, attEcodeAuthentication)
+	}
+
+	// Props of Service and Characteristic declration are read only.
+	// So we only need deal with writable descriptors here.
+	// (Characteristic's value is implemented with descriptor)
+	if !a.typ.Equal(attrClientCharacteristicConfigUUID) {
+		// Regular write, not CCC
+		r := Request{Central: c}
+		if c, ok := a.pvt.(*Characteristic); ok {
+			c.whandler.ServeWrite(r, value)
+		} else if d, ok := a.pvt.(*Characteristic); ok {
+			d.whandler.ServeWrite(r, value)
+		}
+		if noRsp {
+			return nil
+		} else {
+			return []byte{attOpWriteRsp}
+		}
+	}
+
+	// CCC/descriptor write
+	if len(value) != 2 {
+		return attErrorRsp(reqType, h, attEcodeInvalAttrValueLen)
+	}
+	ccc := binary.LittleEndian.Uint16(value)
+	// char := a.pvt.(*Descriptor).char
+	if ccc&(gattCCCNotifyFlag|gattCCCIndicateFlag) != 0 {
+		c.startNotify(&a, int(c.mtu-3))
+	} else {
+		c.stopNotify(&a)
+	}
+	if noRsp {
+		return nil
+	}
+	return []byte{attOpWriteRsp}
+}
+
+func (c *central) sendNotification(a *attr, data []byte) (int, error) {
+	w := newL2capWriter(c.mtu)
+	w.WriteByteFit(attOpHandleNotify)
+	w.WriteUint16Fit(a.pvt.(*Descriptor).char.vh)
+	w.WriteFit(data)
+	return c.l2conn.Write(w.Bytes())
+}
+
+func readHandleRange(b []byte) (start, end uint16) {
+	return binary.LittleEndian.Uint16(b), binary.LittleEndian.Uint16(b[2:])
+}
+
+func (c *central) startNotify(a *attr, maxlen int) {
+	c.notifiersmu.Lock()
+	defer c.notifiersmu.Unlock()
+	if _, found := c.notifiers[a.h]; found {
+		return
+	}
+	char := a.pvt.(*Descriptor).char
+	n := newNotifier(c, a, maxlen)
+	c.notifiers[a.h] = n
+	go char.nhandler.ServeNotify(Request{Central: c}, n)
+}
+
+func (c *central) stopNotify(a *attr) {
+	c.notifiersmu.Lock()
+	defer c.notifiersmu.Unlock()
+	// char := a.pvt.(*Characteristic)
+	if n, found := c.notifiers[a.h]; found {
+		n.stop()
+		delete(c.notifiers, a.h)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/common.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/common.go b/newtmgr/vendor/github.com/runtimeco/gatt/common.go
new file mode 100644
index 0000000..4fa2389
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/common.go
@@ -0,0 +1,399 @@
+package gatt
+
+// Supported statuses for GATT characteristic read/write operations.
+// These correspond to att constants in the BLE spec
+const (
+	StatusSuccess         = 0
+	StatusInvalidOffset   = 1
+	StatusUnexpectedError = 2
+)
+
+// A Request is the context for a request from a connected central device.
+// TODO: Replace this with more general context, such as:
+// http://godoc.org/golang.org/x/net/context
+type Request struct {
+	Central Central
+}
+
+// A ReadRequest is a characteristic read request from a connected device.
+type ReadRequest struct {
+	Request
+	Cap    int // maximum allowed reply length
+	Offset int // request value offset
+}
+
+type Property int
+
+// Characteristic property flags (spec 3.3.3.1)
+const (
+	CharBroadcast   Property = 0x01 // may be brocasted
+	CharRead        Property = 0x02 // may be read
+	CharWriteNR     Property = 0x04 // may be written to, with no reply
+	CharWrite       Property = 0x08 // may be written to, with a reply
+	CharNotify      Property = 0x10 // supports notifications
+	CharIndicate    Property = 0x20 // supports Indications
+	CharSignedWrite Property = 0x40 // supports signed write
+	CharExtended    Property = 0x80 // supports extended properties
+)
+
+func (p Property) String() (result string) {
+	if (p & CharBroadcast) != 0 {
+		result += "broadcast "
+	}
+	if (p & CharRead) != 0 {
+		result += "read "
+	}
+	if (p & CharWriteNR) != 0 {
+		result += "writeWithoutResponse "
+	}
+	if (p & CharWrite) != 0 {
+		result += "write "
+	}
+	if (p & CharNotify) != 0 {
+		result += "notify "
+	}
+	if (p & CharIndicate) != 0 {
+		result += "indicate "
+	}
+	if (p & CharSignedWrite) != 0 {
+		result += "authenticateSignedWrites "
+	}
+	if (p & CharExtended) != 0 {
+		result += "extendedProperties "
+	}
+	return
+}
+
+// A Service is a BLE service.
+type Service struct {
+	uuid  UUID
+	chars []*Characteristic
+
+	h    uint16
+	endh uint16
+}
+
+// NewService creates and initialize a new Service using u as it's UUID.
+func NewService(u UUID) *Service {
+	return &Service{uuid: u}
+}
+
+// AddCharacteristic adds a characteristic to a service.
+// AddCharacteristic panics if the service already contains another
+// characteristic with the same UUID.
+func (s *Service) AddCharacteristic(u UUID) *Characteristic {
+	for _, c := range s.chars {
+		if c.uuid.Equal(u) {
+			panic("service already contains a characteristic with uuid " + u.String())
+		}
+	}
+	c := &Characteristic{uuid: u, svc: s}
+	s.chars = append(s.chars, c)
+	return c
+}
+
+// UUID returns the UUID of the service.
+func (s *Service) UUID() UUID { return s.uuid }
+
+// Name returns the specificatin name of the service according to its UUID.
+// If the UUID is not assigne, Name returns an empty string.
+func (s *Service) Name() string {
+	return knownServices[s.uuid.String()].Name
+}
+
+// Handle returns the Handle of the service.
+func (s *Service) Handle() uint16 { return s.h }
+
+// EndHandle returns the End Handle of the service.
+func (s *Service) EndHandle() uint16 { return s.endh }
+
+// SetHandle sets the Handle of the service.
+func (s *Service) SetHandle(h uint16) { s.h = h }
+
+// SetEndHandle sets the End Handle of the service.
+func (s *Service) SetEndHandle(endh uint16) { s.endh = endh }
+
+// SetCharacteristics sets the Characteristics of the service.
+func (s *Service) SetCharacteristics(chars []*Characteristic) { s.chars = chars }
+
+// Characteristic returns the contained characteristic of this service.
+func (s *Service) Characteristics() []*Characteristic { return s.chars }
+
+// A Characteristic is a BLE characteristic.
+type Characteristic struct {
+	uuid   UUID
+	props  Property // enabled properties
+	secure Property // security enabled properties
+	svc    *Service
+	cccd   *Descriptor
+	descs  []*Descriptor
+
+	value []byte
+
+	// All the following fields are only used in peripheral/server implementation.
+	rhandler ReadHandler
+	whandler WriteHandler
+	nhandler NotifyHandler
+
+	h    uint16
+	vh   uint16
+	endh uint16
+}
+
+// NewCharacteristic creates and returns a Characteristic.
+func NewCharacteristic(u UUID, s *Service, props Property, h uint16, vh uint16) *Characteristic {
+	c := &Characteristic{
+		uuid:  u,
+		svc:   s,
+		props: props,
+		h:     h,
+		vh:    vh,
+	}
+
+	return c
+}
+
+// Handle returns the Handle of the characteristic.
+func (c *Characteristic) Handle() uint16 { return c.h }
+
+// VHandle returns the Value Handle of the characteristic.
+func (c *Characteristic) VHandle() uint16 { return c.vh }
+
+// EndHandle returns the End Handle of the characteristic.
+func (c *Characteristic) EndHandle() uint16 { return c.endh }
+
+// Descriptor returns the Descriptor of the characteristic.
+func (c *Characteristic) Descriptor() *Descriptor { return c.cccd }
+
+// SetHandle sets the Handle of the characteristic.
+func (c *Characteristic) SetHandle(h uint16) { c.h = h }
+
+// SetVHandle sets the Value Handle of the characteristic.
+func (c *Characteristic) SetVHandle(vh uint16) { c.vh = vh }
+
+// SetEndHandle sets the End Handle of the characteristic.
+func (c *Characteristic) SetEndHandle(endh uint16) { c.endh = endh }
+
+// SetDescriptor sets the Descriptor of the characteristic.
+func (c *Characteristic) SetDescriptor(cccd *Descriptor) { c.cccd = cccd }
+
+// SetDescriptors sets the list of Descriptor of the characteristic.
+func (c *Characteristic) SetDescriptors(descs []*Descriptor) { c.descs = descs }
+
+// UUID returns the UUID of the characteristic.
+func (c *Characteristic) UUID() UUID {
+	return c.uuid
+}
+
+// Name returns the specificatin name of the characteristic.
+// If the UUID is not assigned, Name returns empty string.
+func (c *Characteristic) Name() string {
+	return knownCharacteristics[c.uuid.String()].Name
+}
+
+// Service returns the containing service of this characteristic.
+func (c *Characteristic) Service() *Service {
+	return c.svc
+}
+
+// Properties returns the properties of this characteristic.
+func (c *Characteristic) Properties() Property {
+	return c.props
+}
+
+// Descriptors returns the contained descriptors of this characteristic.
+func (c *Characteristic) Descriptors() []*Descriptor {
+	return c.descs
+}
+
+// AddDescriptor adds a descriptor to a characteristic.
+// AddDescriptor panics if the characteristic already contains another
+// descriptor with the same UUID.
+func (c *Characteristic) AddDescriptor(u UUID) *Descriptor {
+	for _, d := range c.descs {
+		if d.uuid.Equal(u) {
+			panic("service already contains a characteristic with uuid " + u.String())
+		}
+	}
+	d := &Descriptor{uuid: u, char: c}
+	c.descs = append(c.descs, d)
+	return d
+}
+
+// SetValue makes the characteristic support read requests, and returns a
+// static value. SetValue must be called before the containing service is
+// added to a server.
+// SetValue panics if the characteristic has been configured with a ReadHandler.
+func (c *Characteristic) SetValue(b []byte) {
+	if c.rhandler != nil {
+		panic("charactristic has been configured with a read handler")
+	}
+	c.props |= CharRead
+	// c.secure |= CharRead
+	c.value = make([]byte, len(b))
+	copy(c.value, b)
+}
+
+// HandleRead makes the characteristic support read requests, and routes read
+// requests to h. HandleRead must be called before the containing service is
+// added to a server.
+// HandleRead panics if the characteristic has been configured with a static value.
+func (c *Characteristic) HandleRead(h ReadHandler) {
+	if c.value != nil {
+		panic("charactristic has been configured with a static value")
+	}
+	c.props |= CharRead
+	// c.secure |= CharRead
+	c.rhandler = h
+}
+
+// HandleReadFunc calls HandleRead(ReadHandlerFunc(f)).
+func (c *Characteristic) HandleReadFunc(f func(rsp ResponseWriter, req *ReadRequest)) {
+	c.HandleRead(ReadHandlerFunc(f))
+}
+
+// HandleWrite makes the characteristic support write and write-no-response
+// requests, and routes write requests to h.
+// The WriteHandler does not differentiate between write and write-no-response
+// requests; it is handled automatically.
+// HandleWrite must be called before the containing service is added to a server.
+func (c *Characteristic) HandleWrite(h WriteHandler) {
+	c.props |= CharWrite | CharWriteNR
+	// c.secure |= CharWrite | CharWriteNR
+	c.whandler = h
+}
+
+// HandleWriteFunc calls HandleWrite(WriteHandlerFunc(f)).
+func (c *Characteristic) HandleWriteFunc(f func(r Request, data []byte) (status byte)) {
+	c.HandleWrite(WriteHandlerFunc(f))
+}
+
+// HandleNotify makes the characteristic support notify requests, and routes
+// notification requests to h. HandleNotify must be called before the
+// containing service is added to a server.
+func (c *Characteristic) HandleNotify(h NotifyHandler) {
+	if c.cccd != nil {
+		return
+	}
+	p := CharNotify | CharIndicate
+	c.props |= p
+	c.nhandler = h
+
+	// add ccc (client characteristic configuration) descriptor
+	secure := Property(0)
+	// If the characteristic requested secure notifications,
+	// then set ccc security to r/w.
+	if c.secure&p != 0 {
+		secure = CharRead | CharWrite
+	}
+	cd := &Descriptor{
+		uuid:   attrClientCharacteristicConfigUUID,
+		props:  CharRead | CharWrite | CharWriteNR,
+		secure: secure,
+		// FIXME: currently, we always return 0, which is inaccurate.
+		// Each connection should have it's own copy of this value.
+		value: []byte{0x00, 0x00},
+		char:  c,
+	}
+	c.cccd = cd
+	c.descs = append(c.descs, cd)
+}
+
+// HandleNotifyFunc calls HandleNotify(NotifyHandlerFunc(f)).
+func (c *Characteristic) HandleNotifyFunc(f func(r Request, n Notifier)) {
+	c.HandleNotify(NotifyHandlerFunc(f))
+}
+
+// TODO
+// func (c *Characteristic) SubscribedCentrals() []Central{
+// }
+
+// Descriptor is a BLE descriptor
+type Descriptor struct {
+	uuid   UUID
+	char   *Characteristic
+	props  Property // enabled properties
+	secure Property // security enabled properties
+
+	h     uint16
+	value []byte
+
+	rhandler ReadHandler
+	whandler WriteHandler
+}
+
+// Handle returns the Handle of the descriptor.
+func (d *Descriptor) Handle() uint16 { return d.h }
+
+// SetHandle sets the Handle of the descriptor.
+func (d *Descriptor) SetHandle(h uint16) { d.h = h }
+
+// NewDescriptor creates and returns a Descriptor.
+func NewDescriptor(u UUID, h uint16, char *Characteristic) *Descriptor {
+	cd := &Descriptor{
+		uuid: u,
+		h:    h,
+		char: char,
+	}
+	return cd
+}
+
+// UUID returns the UUID of the descriptor.
+func (d *Descriptor) UUID() UUID {
+	return d.uuid
+}
+
+// Name returns the specificatin name of the descriptor.
+// If the UUID is not assigned, returns an empty string.
+func (d *Descriptor) Name() string {
+	return knownDescriptors[d.uuid.String()].Name
+}
+
+// Characteristic returns the containing characteristic of the descriptor.
+func (d *Descriptor) Characteristic() *Characteristic {
+	return d.char
+}
+
+// SetValue makes the descriptor support read requests, and returns a static value.
+// SetValue must be called before the containing service is added to a server.
+// SetValue panics if the descriptor has already configured with a ReadHandler.
+func (d *Descriptor) SetValue(b []byte) {
+	if d.rhandler != nil {
+		panic("descriptor has been configured with a read handler")
+	}
+	d.props |= CharRead
+	// d.secure |= CharRead
+	d.value = make([]byte, len(b))
+	copy(d.value, b)
+}
+
+// HandleRead makes the descriptor support read requests, and routes read requests to h.
+// HandleRead must be called before the containing service is added to a server.
+// HandleRead panics if the descriptor has been configured with a static value.
+func (d *Descriptor) HandleRead(h ReadHandler) {
+	if d.value != nil {
+		panic("descriptor has been configured with a static value")
+	}
+	d.props |= CharRead
+	// d.secure |= CharRead
+	d.rhandler = h
+}
+
+// HandleReadFunc calls HandleRead(ReadHandlerFunc(f)).
+func (d *Descriptor) HandleReadFunc(f func(rsp ResponseWriter, req *ReadRequest)) {
+	d.HandleRead(ReadHandlerFunc(f))
+}
+
+// HandleWrite makes the descriptor support write and write-no-response requests, and routes write requests to h.
+// The WriteHandler does not differentiate between write and write-no-response requests; it is handled automatically.
+// HandleWrite must be called before the containing service is added to a server.
+func (d *Descriptor) HandleWrite(h WriteHandler) {
+	d.props |= CharWrite | CharWriteNR
+	// d.secure |= CharWrite | CharWriteNR
+	d.whandler = h
+}
+
+// HandleWriteFunc calls HandleWrite(WriteHandlerFunc(f)).
+func (d *Descriptor) HandleWriteFunc(f func(r Request, data []byte) (status byte)) {
+	d.HandleWrite(WriteHandlerFunc(f))
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/const.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/const.go b/newtmgr/vendor/github.com/runtimeco/gatt/const.go
new file mode 100644
index 0000000..4a04b04
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/const.go
@@ -0,0 +1,153 @@
+package gatt
+
+// This file includes constants from the BLE spec.
+
+var (
+	attrGAPUUID  = UUID16(0x1800)
+	attrGATTUUID = UUID16(0x1801)
+
+	attrPrimaryServiceUUID   = UUID16(0x2800)
+	attrSecondaryServiceUUID = UUID16(0x2801)
+	attrIncludeUUID          = UUID16(0x2802)
+	attrCharacteristicUUID   = UUID16(0x2803)
+
+	attrClientCharacteristicConfigUUID = UUID16(0x2902)
+	attrServerCharacteristicConfigUUID = UUID16(0x2903)
+
+	attrDeviceNameUUID        = UUID16(0x2A00)
+	attrAppearanceUUID        = UUID16(0x2A01)
+	attrPeripheralPrivacyUUID = UUID16(0x2A02)
+	attrReconnectionAddrUUID  = UUID16(0x2A03)
+	attrPeferredParamsUUID    = UUID16(0x2A04)
+	attrServiceChangedUUID    = UUID16(0x2A05)
+)
+
+const (
+	gattCCCNotifyFlag   = 0x0001
+	gattCCCIndicateFlag = 0x0002
+)
+
+const (
+	attOpError              = 0x01
+	attOpMtuReq             = 0x02
+	attOpMtuRsp             = 0x03
+	attOpFindInfoReq        = 0x04
+	attOpFindInfoRsp        = 0x05
+	attOpFindByTypeValueReq = 0x06
+	attOpFindByTypeValueRsp = 0x07
+	attOpReadByTypeReq      = 0x08
+	attOpReadByTypeRsp      = 0x09
+	attOpReadReq            = 0x0a
+	attOpReadRsp            = 0x0b
+	attOpReadBlobReq        = 0x0c
+	attOpReadBlobRsp        = 0x0d
+	attOpReadMultiReq       = 0x0e
+	attOpReadMultiRsp       = 0x0f
+	attOpReadByGroupReq     = 0x10
+	attOpReadByGroupRsp     = 0x11
+	attOpWriteReq           = 0x12
+	attOpWriteRsp           = 0x13
+	attOpWriteCmd           = 0x52
+	attOpPrepWriteReq       = 0x16
+	attOpPrepWriteRsp       = 0x17
+	attOpExecWriteReq       = 0x18
+	attOpExecWriteRsp       = 0x19
+	attOpHandleNotify       = 0x1b
+	attOpHandleInd          = 0x1d
+	attOpHandleCnf          = 0x1e
+	attOpSignedWriteCmd     = 0xd2
+)
+
+type attEcode byte
+
+const (
+	attEcodeSuccess           attEcode = 0x00 // Success
+	attEcodeInvalidHandle     attEcode = 0x01 // The attribute handle given was not valid on this server.
+	attEcodeReadNotPerm       attEcode = 0x02 // The attribute cannot be read.
+	attEcodeWriteNotPerm      attEcode = 0x03 // The attribute cannot be written.
+	attEcodeInvalidPDU        attEcode = 0x04 // The attribute PDU was invalid.
+	attEcodeAuthentication    attEcode = 0x05 // The attribute requires authentication before it can be read or written.
+	attEcodeReqNotSupp        attEcode = 0x06 // Attribute server does not support the request received from the client.
+	attEcodeInvalidOffset     attEcode = 0x07 // Offset specified was past the end of the attribute.
+	attEcodeAuthorization     attEcode = 0x08 // The attribute requires authorization before it can be read or written.
+	attEcodePrepQueueFull     attEcode = 0x09 // Too many prepare writes have been queued.
+	attEcodeAttrNotFound      attEcode = 0x0a // No attribute found within the given attribute handle range.
+	attEcodeAttrNotLong       attEcode = 0x0b // The attribute cannot be read or written using the Read Blob Request.
+	attEcodeInsuffEncrKeySize attEcode = 0x0c // The Encryption Key Size used for encrypting this link is insufficient.
+	attEcodeInvalAttrValueLen attEcode = 0x0d // The attribute value length is invalid for the operation.
+	attEcodeUnlikely          attEcode = 0x0e // The attribute request that was requested has encountered an error that was unlikely, and therefore could not be completed as requested.
+	attEcodeInsuffEnc         attEcode = 0x0f // The attribute requires encryption before it can be read or written.
+	attEcodeUnsuppGrpType     attEcode = 0x10 // The attribute type is not a supported grouping attribute as defined by a higher layer specification.
+	attEcodeInsuffResources   attEcode = 0x11 // Insufficient Resources to complete the request.
+)
+
+func (a attEcode) Error() string {
+	switch i := int(a); {
+	case i < 0x11:
+		return attEcodeName[a]
+	case i >= 0x12 && i <= 0x7F: // Reserved for future use
+		return "reserved error code"
+	case i >= 0x80 && i <= 0x9F: // Application Error, defined by higher level
+		return "reserved error code"
+	case i >= 0xA0 && i <= 0xDF: // Reserved for future use
+		return "reserved error code"
+	case i >= 0xE0 && i <= 0xFF: // Common profile and service error codes
+		return "profile or service error"
+	default: // can't happen, just make compiler happy
+		return "unkown error"
+	}
+}
+
+var attEcodeName = map[attEcode]string{
+	attEcodeSuccess:           "success",
+	attEcodeInvalidHandle:     "invalid handle",
+	attEcodeReadNotPerm:       "read not permitted",
+	attEcodeWriteNotPerm:      "write not permitted",
+	attEcodeInvalidPDU:        "invalid PDU",
+	attEcodeAuthentication:    "insufficient authentication",
+	attEcodeReqNotSupp:        "request not supported",
+	attEcodeInvalidOffset:     "invalid offset",
+	attEcodeAuthorization:     "insufficient authorization",
+	attEcodePrepQueueFull:     "prepare queue full",
+	attEcodeAttrNotFound:      "attribute not found",
+	attEcodeAttrNotLong:       "attribute not long",
+	attEcodeInsuffEncrKeySize: "insufficient encryption key size",
+	attEcodeInvalAttrValueLen: "invalid attribute value length",
+	attEcodeUnlikely:          "unlikely error",
+	attEcodeInsuffEnc:         "insufficient encryption",
+	attEcodeUnsuppGrpType:     "unsupported group type",
+	attEcodeInsuffResources:   "insufficient resources",
+}
+
+func attErrorRsp(op byte, h uint16, s attEcode) []byte {
+	return attErr{opcode: op, attr: h, status: s}.Marshal()
+}
+
+// attRspFor maps from att request
+// codes to att response codes.
+var attRspFor = map[byte]byte{
+	attOpMtuReq:             attOpMtuRsp,
+	attOpFindInfoReq:        attOpFindInfoRsp,
+	attOpFindByTypeValueReq: attOpFindByTypeValueRsp,
+	attOpReadByTypeReq:      attOpReadByTypeRsp,
+	attOpReadReq:            attOpReadRsp,
+	attOpReadBlobReq:        attOpReadBlobRsp,
+	attOpReadMultiReq:       attOpReadMultiRsp,
+	attOpReadByGroupReq:     attOpReadByGroupRsp,
+	attOpWriteReq:           attOpWriteRsp,
+	attOpPrepWriteReq:       attOpPrepWriteRsp,
+	attOpExecWriteReq:       attOpExecWriteRsp,
+}
+
+type attErr struct {
+	opcode uint8
+	attr   uint16
+	status attEcode
+}
+
+// TODO: Reformulate in a way that lets the caller avoid allocs.
+// Accept a []byte? Write directly to an io.Writer?
+func (e attErr) Marshal() []byte {
+	// little-endian encoding for attr
+	return []byte{attOpError, e.opcode, byte(e.attr), byte(e.attr >> 8), byte(e.status)}
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/device.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/device.go b/newtmgr/vendor/github.com/runtimeco/gatt/device.go
new file mode 100644
index 0000000..eba96cf
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/device.go
@@ -0,0 +1,161 @@
+package gatt
+
+import "errors"
+
+var notImplemented = errors.New("not implemented")
+
+type State int
+
+const (
+	StateUnknown      State = 0
+	StateResetting    State = 1
+	StateUnsupported  State = 2
+	StateUnauthorized State = 3
+	StatePoweredOff   State = 4
+	StatePoweredOn    State = 5
+)
+
+func (s State) String() string {
+	str := []string{
+		"Unknown",
+		"Resetting",
+		"Unsupported",
+		"Unauthorized",
+		"PoweredOff",
+		"PoweredOn",
+	}
+	return str[int(s)]
+}
+
+// Device defines the interface for a BLE device.
+// Since an interface can't define fields(properties). To implement the
+// callback support for cerntain events, deviceHandler is defined and
+// implementation of Device on different platforms should embed it in
+// order to keep have keep compatible in API level.
+// Package users can use the Handler to set these handlers.
+type Device interface {
+	Init(stateChanged func(Device, State)) error
+
+	// Advertise advertise AdvPacket
+	Advertise(a *AdvPacket) error
+
+	// AdvertiseNameAndServices advertises device name, and specified service UUIDs.
+	// It tres to fit the UUIDs in the advertising packet as much as possible.
+	// If name doesn't fit in the advertising packet, it will be put in scan response.
+	AdvertiseNameAndServices(name string, ss []UUID) error
+
+	// AdvertiseIBeaconData advertise iBeacon with given manufacturer data.
+	AdvertiseIBeaconData(b []byte) error
+
+	// AdvertisingIbeacon advertises iBeacon with specified parameters.
+	AdvertiseIBeacon(u UUID, major, minor uint16, pwr int8) error
+
+	// StopAdvertising stops advertising.
+	StopAdvertising() error
+
+	// RemoveAllServices removes all services that are currently in the database.
+	RemoveAllServices() error
+
+	// Add Service add a service to database.
+	AddService(s *Service) error
+
+	// SetServices set the specified service to the database.
+	// It removes all currently added services, if any.
+	SetServices(ss []*Service) error
+
+	// Scan discovers surounding remote peripherals that have the Service UUID specified in ss.
+	// If ss is set to nil, all devices scanned are reported.
+	// dup specifies weather duplicated advertisement should be reported or not.
+	// When a remote peripheral is discovered, the PeripheralDiscovered Handler is called.
+	Scan(ss []UUID, dup bool)
+
+	// StopScanning stops scanning.
+	StopScanning()
+
+	// Connect connects to a remote peripheral.
+	Connect(p Peripheral)
+
+	// CancelConnection disconnects a remote peripheral.
+	CancelConnection(p Peripheral)
+
+	// Handle registers the specified handlers.
+	Handle(h ...Handler)
+
+	// Stop HCI Connection
+        Stop() error
+
+	// Option sets the options specified.
+	Option(o ...Option) error
+}
+
+// deviceHandler is the handlers(callbacks) of the Device.
+type deviceHandler struct {
+	// stateChanged is called when the device states changes.
+	stateChanged func(d Device, s State)
+
+	// connect is called when a remote central device connects to the device.
+	centralConnected func(c Central)
+
+	// disconnect is called when a remote central device disconnects to the device.
+	centralDisconnected func(c Central)
+
+	// peripheralDiscovered is called when a remote peripheral device is found during scan procedure.
+	peripheralDiscovered func(p Peripheral, a *Advertisement, rssi int)
+
+	// peripheralConnected is called when a remote peripheral is conneted.
+	peripheralConnected func(p Peripheral, err error)
+
+	// peripheralConnected is called when a remote peripheral is disconneted.
+	peripheralDisconnected func(p Peripheral, err error)
+}
+
+// A Handler is a self-referential function, which registers the options specified.
+// See http://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html for more discussion.
+type Handler func(Device)
+
+// Handle registers the specified handlers.
+func (d *device) Handle(hh ...Handler) {
+	for _, h := range hh {
+		h(d)
+	}
+}
+
+// CentralConnected returns a Handler, which sets the specified function to be called when a device connects to the server.
+func CentralConnected(f func(Central)) Handler {
+	return func(d Device) { d.(*device).centralConnected = f }
+}
+
+// CentralDisconnected returns a Handler, which sets the specified function to be called when a device disconnects from the server.
+func CentralDisconnected(f func(Central)) Handler {
+	return func(d Device) { d.(*device).centralDisconnected = f }
+}
+
+// PeripheralDiscovered returns a Handler, which sets the specified function to be called when a remote peripheral device is found during scan procedure.
+func PeripheralDiscovered(f func(Peripheral, *Advertisement, int)) Handler {
+	return func(d Device) { d.(*device).peripheralDiscovered = f }
+}
+
+// PeripheralConnected returns a Handler, which sets the specified function to be called when a remote peripheral device connects.
+func PeripheralConnected(f func(Peripheral, error)) Handler {
+	return func(d Device) { d.(*device).peripheralConnected = f }
+}
+
+// PeripheralDisconnected returns a Handler, which sets the specified function to be called when a remote peripheral device disconnects.
+func PeripheralDisconnected(f func(Peripheral, error)) Handler {
+	return func(d Device) { d.(*device).peripheralDisconnected = f }
+}
+
+// An Option is a self-referential function, which sets the option specified.
+// Most Options are platform-specific, which gives more fine-grained control over the device at a cost of losing portibility.
+// See http://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html for more discussion.
+type Option func(Device) error
+
+// Option sets the options specified.
+// Some options can only be set before the device is initialized; they are best used with NewDevice instead of Option.
+func (d *device) Option(opts ...Option) error {
+	var err error
+	for _, opt := range opts {
+		err = opt(d)
+	}
+	return err
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/device_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/device_darwin.go b/newtmgr/vendor/github.com/runtimeco/gatt/device_darwin.go
new file mode 100644
index 0000000..acf4431
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/device_darwin.go
@@ -0,0 +1,513 @@
+package gatt
+
+import (
+	"bytes"
+	"encoding/binary"
+	"errors"
+	"fmt"
+	"log"
+	"sync"
+	"time"
+
+	"github.com/runtimeco/gatt/xpc"
+)
+
+const (
+	peripheralDiscovered   = 37
+	peripheralConnected    = 38
+	peripheralDisconnected = 40
+	// below constants for Yosemite
+	rssiRead                   = 55
+	includedServicesDiscovered = 63
+	serviceDiscovered          = 56
+	characteristicsDiscovered  = 64
+	characteristicRead         = 71
+	characteristicWritten      = 72
+	notificationValueSet       = 74
+	descriptorsDiscovered      = 76
+	descriptorRead             = 79
+	descriptorWritten          = 80
+)
+
+type device struct {
+	deviceHandler
+
+	conn xpc.XPC
+
+	role int // 1: peripheralManager (server), 0: centralManager (client)
+
+	reqc chan message
+	rspc chan message
+
+	// Only used in client/centralManager implementation
+	plist   map[string]*peripheral
+	plistmu *sync.Mutex
+
+	// Only used in server/peripheralManager implementation
+
+	attrN int
+	attrs map[int]*attr
+
+	subscribers map[string]*central
+}
+
+func NewDevice(opts ...Option) (Device, error) {
+	d := &device{
+		reqc:    make(chan message),
+		rspc:    make(chan message),
+		plist:   map[string]*peripheral{},
+		plistmu: &sync.Mutex{},
+
+		attrN: 1,
+		attrs: make(map[int]*attr),
+
+		subscribers: make(map[string]*central),
+	}
+	d.Option(opts...)
+	d.conn = xpc.XpcConnect("com.apple.blued", d)
+	return d, nil
+}
+
+func (d *device) Init(f func(Device, State)) error {
+	go d.loop()
+	rsp := d.sendReq(1, xpc.Dict{
+		"kCBMsgArgName":    fmt.Sprintf("gopher-%v", time.Now().Unix()),
+		"kCBMsgArgOptions": xpc.Dict{"kCBInitOptionShowPowerAlert": 1},
+		"kCBMsgArgType":    d.role,
+	})
+	d.stateChanged = f
+	go d.stateChanged(d, State(rsp.MustGetInt("kCBMsgArgState")))
+	return nil
+}
+
+func (d *device) Advertise(a *AdvPacket) error {
+	rsp := d.sendReq(8, xpc.Dict{
+		"kCBAdvDataAppleMfgData": a.b, // not a.Bytes(). should be slice
+	})
+
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return errors.New("FIXME: Advertise error")
+	}
+	return nil
+}
+
+func (d *device) AdvertiseNameAndServices(name string, ss []UUID) error {
+	us := uuidSlice(ss)
+	rsp := d.sendReq(8, xpc.Dict{
+		"kCBAdvDataLocalName":    name,
+		"kCBAdvDataServiceUUIDs": us},
+	)
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return errors.New("FIXME: Advertise error")
+	}
+	return nil
+}
+
+func (d *device) AdvertiseIBeaconData(data []byte) error {
+	var utsname xpc.Utsname
+	xpc.Uname(&utsname)
+
+	var rsp xpc.Dict
+
+	if utsname.Release >= "14." {
+		l := len(data)
+		buf := bytes.NewBuffer([]byte{byte(l + 5), 0xFF, 0x4C, 0x00, 0x02, byte(l)})
+		buf.Write(data)
+		rsp = d.sendReq(8, xpc.Dict{"kCBAdvDataAppleMfgData": buf.Bytes()})
+	} else {
+		rsp = d.sendReq(8, xpc.Dict{"kCBAdvDataAppleBeaconKey": data})
+	}
+
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return errors.New("FIXME: Advertise error")
+	}
+
+	return nil
+}
+
+func (d *device) AdvertiseIBeacon(u UUID, major, minor uint16, pwr int8) error {
+	b := make([]byte, 21)
+	copy(b, reverse(u.b))                     // Big endian
+	binary.BigEndian.PutUint16(b[16:], major) // Big endian
+	binary.BigEndian.PutUint16(b[18:], minor) // Big endian
+	b[20] = uint8(pwr)                        // Measured Tx Power
+	return d.AdvertiseIBeaconData(b)
+}
+
+func (d *device) StopAdvertising() error {
+	rsp := d.sendReq(9, nil)
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return errors.New("FIXME: Stop Advertise error")
+	}
+	return nil
+}
+
+func (d *device) RemoveAllServices() error {
+	d.sendCmd(12, nil)
+	return nil
+}
+
+func (d *device) AddService(s *Service) error {
+	if s.uuid.Equal(attrGAPUUID) || s.uuid.Equal(attrGATTUUID) {
+		// skip GATT and GAP services
+		return nil
+	}
+
+	xs := xpc.Dict{
+		"kCBMsgArgAttributeID":     d.attrN,
+		"kCBMsgArgAttributeIDs":    []int{},
+		"kCBMsgArgCharacteristics": nil,
+		"kCBMsgArgType":            1, // 1 => primary, 0 => excluded
+		"kCBMsgArgUUID":            reverse(s.uuid.b),
+	}
+	d.attrN++
+
+	xcs := xpc.Array{}
+	for _, c := range s.Characteristics() {
+		props := 0
+		perm := 0
+		if c.props&CharRead != 0 {
+			props |= 0x02
+			if CharRead&c.secure != 0 {
+				perm |= 0x04
+			} else {
+				perm |= 0x01
+			}
+		}
+		if c.props&CharWriteNR != 0 {
+			props |= 0x04
+			if c.secure&CharWriteNR != 0 {
+				perm |= 0x08
+			} else {
+				perm |= 0x02
+			}
+		}
+		if c.props&CharWrite != 0 {
+			props |= 0x08
+			if c.secure&CharWrite != 0 {
+				perm |= 0x08
+			} else {
+				perm |= 0x02
+			}
+		}
+		if c.props&CharNotify != 0 {
+			if c.secure&CharNotify != 0 {
+				props |= 0x100
+			} else {
+				props |= 0x10
+			}
+		}
+		if c.props&CharIndicate != 0 {
+			if c.secure&CharIndicate != 0 {
+				props |= 0x200
+			} else {
+				props |= 0x20
+			}
+		}
+
+		xc := xpc.Dict{
+			"kCBMsgArgAttributeID":              d.attrN,
+			"kCBMsgArgUUID":                     reverse(c.uuid.b),
+			"kCBMsgArgAttributePermissions":     perm,
+			"kCBMsgArgCharacteristicProperties": props,
+			"kCBMsgArgData":                     c.value,
+		}
+		d.attrs[d.attrN] = &attr{h: uint16(d.attrN), value: c.value, pvt: c}
+		d.attrN++
+
+		xds := xpc.Array{}
+		for _, d := range c.Descriptors() {
+			if d.uuid.Equal(attrClientCharacteristicConfigUUID) {
+				// skip CCCD
+				continue
+			}
+			xd := xpc.Dict{
+				"kCBMsgArgData": d.value,
+				"kCBMsgArgUUID": reverse(d.uuid.b),
+			}
+			xds = append(xds, xd)
+		}
+		xc["kCBMsgArgDescriptors"] = xds
+		xcs = append(xcs, xc)
+	}
+	xs["kCBMsgArgCharacteristics"] = xcs
+
+	rsp := d.sendReq(10, xs)
+	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
+		return errors.New("FIXME: Add Srvice error")
+	}
+	return nil
+}
+
+func (d *device) SetServices(ss []*Service) error {
+	d.RemoveAllServices()
+	for _, s := range ss {
+		d.AddService(s)
+	}
+	return nil
+}
+
+func (d *device) Scan(ss []UUID, dup bool) {
+	args := xpc.Dict{
+		"kCBMsgArgUUIDs": uuidSlice(ss),
+		"kCBMsgArgOptions": xpc.Dict{
+			"kCBScanOptionAllowDuplicates": map[bool]int{true: 1, false: 0}[dup],
+		},
+	}
+	d.sendCmd(29, args)
+}
+
+func (d *device) StopScanning() {
+	d.sendCmd(30, nil)
+}
+
+func (d *device) Connect(p Peripheral) {
+	pp := p.(*peripheral)
+	d.plist[pp.id.String()] = pp
+	d.sendCmd(31,
+		xpc.Dict{
+			"kCBMsgArgDeviceUUID": pp.id,
+			"kCBMsgArgOptions": xpc.Dict{
+				"kCBConnectOptionNotifyOnDisconnection": 1,
+			},
+		})
+}
+
+func (d *device) respondToRequest(id int, args xpc.Dict) {
+
+	switch id {
+	case 19: // ReadRequest
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		t := args.MustGetInt("kCBMsgArgTransactionID")
+		a := args.MustGetInt("kCBMsgArgAttributeID")
+		o := args.MustGetInt("kCBMsgArgOffset")
+
+		attr := d.attrs[a]
+		v := attr.value
+		if v == nil {
+			c := newCentral(d, u)
+			req := &ReadRequest{
+				Request: Request{Central: c},
+				Cap:     int(c.mtu - 1),
+				Offset:  o,
+			}
+			rsp := newResponseWriter(int(c.mtu - 1))
+			if c, ok := attr.pvt.(*Characteristic); ok {
+				c.rhandler.ServeRead(rsp, req)
+				v = rsp.bytes()
+			}
+		}
+
+		d.sendCmd(13, xpc.Dict{
+			"kCBMsgArgAttributeID":   a,
+			"kCBMsgArgData":          v,
+			"kCBMsgArgTransactionID": t,
+			"kCBMsgArgResult":        0,
+		})
+
+	case 20: // WriteRequest
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		t := args.MustGetInt("kCBMsgArgTransactionID")
+		a := 0
+		noRsp := false
+		xxws := args.MustGetArray("kCBMsgArgATTWrites")
+		for _, xxw := range xxws {
+			xw := xxw.(xpc.Dict)
+			if a == 0 {
+				a = xw.MustGetInt("kCBMsgArgAttributeID")
+			}
+			o := xw.MustGetInt("kCBMsgArgOffset")
+			i := xw.MustGetInt("kCBMsgArgIgnoreResponse")
+			b := xw.MustGetBytes("kCBMsgArgData")
+			_ = o
+			attr := d.attrs[a]
+			c := newCentral(d, u)
+			r := Request{Central: c}
+			attr.pvt.(*Characteristic).whandler.ServeWrite(r, b)
+			if i == 1 {
+				noRsp = true
+			}
+
+		}
+		if noRsp {
+			break
+		}
+		d.sendCmd(13, xpc.Dict{
+			"kCBMsgArgAttributeID":   a,
+			"kCBMsgArgData":          nil,
+			"kCBMsgArgTransactionID": t,
+			"kCBMsgArgResult":        0,
+		})
+
+	case 21: // subscribed
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		a := args.MustGetInt("kCBMsgArgAttributeID")
+		attr := d.attrs[a]
+		c := newCentral(d, u)
+		d.subscribers[u.String()] = c
+		c.startNotify(attr, c.mtu)
+
+	case 22: // unubscribed
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		a := args.MustGetInt("kCBMsgArgAttributeID")
+		attr := d.attrs[a]
+		if c := d.subscribers[u.String()]; c != nil {
+			c.stopNotify(attr)
+		}
+
+	case 23: // notificationSent
+	}
+}
+
+/*
+ * OSX GATT library currently doesn't work for Mynewt, so adding this stub to keep
+ * it buildable for OSX.
+ */
+func (d *device) Stop() error {
+	return nil
+}
+
+func (d *device) CancelConnection(p Peripheral) {
+	d.sendCmd(32, xpc.Dict{"kCBMsgArgDeviceUUID": p.(*peripheral).id})
+}
+
+// process device events and asynchronous errors
+// (implements XpcEventHandler)
+func (d *device) HandleXpcEvent(event xpc.Dict, err error) {
+	if err != nil {
+		log.Println("error:", err)
+		return
+	}
+
+	id := event.MustGetInt("kCBMsgId")
+	args := event.MustGetDict("kCBMsgArgs")
+	//log.Printf(">> %d, %v", id, args)
+
+	switch id {
+	case // device event
+		6,  // StateChanged
+		16, // AdvertisingStarted
+		17, // AdvertisingStopped
+		18: // ServiceAdded
+		d.rspc <- message{id: id, args: args}
+
+	case
+		19, // ReadRequest
+		20, // WriteRequest
+		21, // Subscribe
+		22, // Unubscribe
+		23: // Confirmation
+		d.respondToRequest(id, args)
+
+	case peripheralDiscovered:
+		xa := args.MustGetDict("kCBMsgArgAdvertisementData")
+		if len(xa) == 0 {
+			return
+		}
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		a := &Advertisement{
+			LocalName:        xa.GetString("kCBAdvDataLocalName", args.GetString("kCBMsgArgName", "")),
+			TxPowerLevel:     xa.GetInt("kCBAdvDataTxPowerLevel", 0),
+			ManufacturerData: xa.GetBytes("kCBAdvDataManufacturerData", nil),
+		}
+
+		rssi := args.MustGetInt("kCBMsgArgRssi")
+
+		if xu, ok := xa["kCBAdvDataServiceUUIDs"]; ok {
+			for _, xs := range xu.(xpc.Array) {
+				s := UUID{reverse(xs.([]byte))}
+				a.Services = append(a.Services, s)
+			}
+		}
+		if xsds, ok := xa["kCBAdvDataServiceData"]; ok {
+			xsd := xsds.(xpc.Array)
+			for i := 0; i < len(xsd); i += 2 {
+				sd := ServiceData{
+					UUID: UUID{xsd[i].([]byte)},
+					Data: xsd[i+1].([]byte),
+				}
+				a.ServiceData = append(a.ServiceData, sd)
+			}
+		}
+		if d.peripheralDiscovered != nil {
+			go d.peripheralDiscovered(&peripheral{id: xpc.UUID(u.b), d: d}, a, rssi)
+		}
+
+	case peripheralConnected:
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		p := &peripheral{
+			id:    xpc.UUID(u.b),
+			d:     d,
+			reqc:  make(chan message),
+			rspc:  make(chan message),
+			quitc: make(chan struct{}),
+			sub:   newSubscriber(),
+		}
+		d.plistmu.Lock()
+		d.plist[u.String()] = p
+		d.plistmu.Unlock()
+		go p.loop()
+
+		if d.peripheralConnected != nil {
+			go d.peripheralConnected(p, nil)
+		}
+
+	case peripheralDisconnected:
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		d.plistmu.Lock()
+		p := d.plist[u.String()]
+		delete(d.plist, u.String())
+		d.plistmu.Unlock()
+		if d.peripheralDisconnected != nil {
+			d.peripheralDisconnected(p, nil) // TODO: Get Result as error?
+		}
+		close(p.quitc)
+
+	case // Peripheral events
+		rssiRead,
+		serviceDiscovered,
+		includedServicesDiscovered,
+		characteristicsDiscovered,
+		characteristicRead,
+		characteristicWritten,
+		notificationValueSet,
+		descriptorsDiscovered,
+		descriptorRead,
+		descriptorWritten:
+
+		u := UUID{args.MustGetUUID("kCBMsgArgDeviceUUID")}
+		d.plistmu.Lock()
+		p := d.plist[u.String()]
+		d.plistmu.Unlock()
+		p.rspc <- message{id: id, args: args}
+
+	default:
+		log.Printf("Unhandled event: %#v", event)
+	}
+}
+
+func (d *device) sendReq(id int, args xpc.Dict) xpc.Dict {
+	m := message{id: id, args: args, rspc: make(chan xpc.Dict)}
+	d.reqc <- m
+	return <-m.rspc
+}
+
+func (d *device) sendCmd(id int, args xpc.Dict) {
+	d.reqc <- message{id: id, args: args}
+}
+
+func (d *device) loop() {
+	for req := range d.reqc {
+		d.sendCBMsg(req.id, req.args)
+		if req.rspc == nil {
+			continue
+		}
+		m := <-d.rspc
+		req.rspc <- m.args
+	}
+}
+
+func (d *device) sendCBMsg(id int, args xpc.Dict) {
+	// log.Printf("<< %d, %v", id, args)
+	d.conn.Send(xpc.Dict{"kCBMsgId": id, "kCBMsgArgs": args}, false)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeco/gatt/device_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeco/gatt/device_linux.go b/newtmgr/vendor/github.com/runtimeco/gatt/device_linux.go
new file mode 100644
index 0000000..4c989e1
--- /dev/null
+++ b/newtmgr/vendor/github.com/runtimeco/gatt/device_linux.go
@@ -0,0 +1,240 @@
+package gatt
+
+import (
+	"encoding/binary"
+	"net"
+
+	"github.com/runtimeco/gatt/linux"
+	"github.com/runtimeco/gatt/linux/cmd"
+)
+
+type device struct {
+	deviceHandler
+
+	hci   *linux.HCI
+	state State
+
+	// All the following fields are only used peripheralManager (server) implementation.
+	svcs  []*Service
+	attrs *attrRange
+
+	devID   int
+	chkLE   bool
+	maxConn int
+
+	advData   *cmd.LESetAdvertisingData
+	scanResp  *cmd.LESetScanResponseData
+	advParam  *cmd.LESetAdvertisingParameters
+	scanParam *cmd.LESetScanParameters
+}
+
+func NewDevice(opts ...Option) (Device, error) {
+	d := &device{
+		maxConn: 1,    // Support 1 connection at a time.
+		devID:   -1,   // Find an available HCI device.
+		chkLE:   true, // Check if the device supports LE.
+
+		advParam: &cmd.LESetAdvertisingParameters{
+			AdvertisingIntervalMin:  0x800,     // [0x0800]: 0.625 ms * 0x0800 = 1280.0 ms
+			AdvertisingIntervalMax:  0x800,     // [0x0800]: 0.625 ms * 0x0800 = 1280.0 ms
+			AdvertisingType:         0x00,      // [0x00]: ADV_IND, 0x01: DIRECT(HIGH), 0x02: SCAN, 0x03: NONCONN, 0x04: DIRECT(LOW)
+			OwnAddressType:          0x00,      // [0x00]: public, 0x01: random
+			DirectAddressType:       0x00,      // [0x00]: public, 0x01: random
+			DirectAddress:           [6]byte{}, // Public or Random Address of the device to be connected
+			AdvertisingChannelMap:   0x7,       // [0x07] 0x01: ch37, 0x2: ch38, 0x4: ch39
+			AdvertisingFilterPolicy: 0x00,
+		},
+		scanParam: &cmd.LESetScanParameters{
+			LEScanType:           0x01,   // [0x00]: passive, 0x01: active
+			LEScanInterval:       0x0010, // [0x10]: 0.625ms * 16
+			LEScanWindow:         0x0010, // [0x10]: 0.625ms * 16
+			OwnAddressType:       0x00,   // [0x00]: public, 0x01: random
+			ScanningFilterPolicy: 0x00,   // [0x00]: accept all, 0x01: ignore non-white-listed.
+		},
+	}
+
+	d.Option(opts...)
+	h, err := linux.NewHCI(d.devID, d.chkLE, d.maxConn)
+	if err != nil {
+		return nil, err
+	}
+
+	d.hci = h
+	return d, nil
+}
+
+func (d *device) Init(f func(Device, State)) error {
+	d.hci.AcceptMasterHandler = func(pd *linux.PlatData) {
+		a := pd.Address
+		c := newCentral(d.attrs, net.HardwareAddr([]byte{a[5], a[4], a[3], a[2], a[1], a[0]}), pd.Conn)
+		if d.centralConnected != nil {
+			d.centralConnected(c)
+		}
+		c.loop()
+		if d.centralDisconnected != nil {
+			d.centralDisconnected(c)
+		}
+	}
+	d.hci.AcceptSlaveHandler = func(pd *linux.PlatData) {
+		p := &peripheral{
+			d:     d,
+			pd:    pd,
+			l2c:   pd.Conn,
+			reqc:  make(chan message),
+			quitc: make(chan struct{}),
+			sub:   newSubscriber(),
+		}
+		if d.peripheralConnected != nil {
+			go d.peripheralConnected(p, nil)
+		}
+		p.loop()
+		if d.peripheralDisconnected != nil {
+			d.peripheralDisconnected(p, nil)
+		}
+	}
+	d.hci.AdvertisementHandler = func(pd *linux.PlatData) {
+		a := &Advertisement{}
+		a.unmarshall(pd.Data)
+		a.Connectable = pd.Connectable
+	        a.Address = pd.Address
+		a.AddressType = pd.AddressType
+		p := &peripheral{pd: pd, d: d}
+		if d.peripheralDiscovered != nil {
+			pd.Name = a.LocalName
+			d.peripheralDiscovered(p, a, int(pd.RSSI))
+		}
+	}
+	d.state = StatePoweredOn
+	d.stateChanged = f
+	go d.stateChanged(d, d.state)
+	return nil
+}
+
+func (d *device) Stop() error {
+	d.state = StatePoweredOff
+	defer d.stateChanged(d, d.state)
+	return d.hci.Close()
+}
+
+func (d *device) AddService(s *Service) error {
+	d.svcs = append(d.svcs, s)
+	d.attrs = generateAttributes(d.svcs, uint16(1)) // ble attrs start at 1
+	return nil
+}
+
+func (d *device) RemoveAllServices() error {
+	d.svcs = nil
+	d.attrs = nil
+	return nil
+}
+
+func (d *device) SetServices(s []*Service) error {
+	d.RemoveAllServices()
+	d.svcs = append(d.svcs, s...)
+	d.attrs = generateAttributes(d.svcs, uint16(1)) // ble attrs start at 1
+	return nil
+}
+
+func (d *device) Advertise(a *AdvPacket) error {
+	d.advData = &cmd.LESetAdvertisingData{
+		AdvertisingDataLength: uint8(a.Len()),
+		AdvertisingData:       a.Bytes(),
+	}
+
+	if err := d.update(); err != nil {
+		return err
+	}
+
+	return d.hci.SetAdvertiseEnable(true)
+}
+
+func (d *device) AdvertiseNameAndServices(name string, uu []UUID) error {
+	a := &AdvPacket{}
+	a.AppendFlags(flagGeneralDiscoverable | flagLEOnly)
+	a.AppendUUIDFit(uu)
+
+	if len(a.b)+len(name)+2 < MaxEIRPacketLength {
+		a.AppendName(name)
+		d.scanResp = nil
+	} else {
+		a := &AdvPacket{}
+		a.AppendName(name)
+		d.scanResp = &cmd.LESetScanResponseData{
+			ScanResponseDataLength: uint8(a.Len()),
+			ScanResponseData:       a.Bytes(),
+		}
+	}
+
+	return d.Advertise(a)
+}
+
+func (d *device) AdvertiseIBeaconData(b []byte) error {
+	a := &AdvPacket{}
+	a.AppendFlags(flagGeneralDiscoverable | flagLEOnly)
+	a.AppendManufacturerData(0x004C, b)
+	d.advData = &cmd.LESetAdvertisingData{
+		AdvertisingDataLength: uint8(a.Len()),
+		AdvertisingData:       a.Bytes(),
+	}
+
+	return d.Advertise(a)
+}
+
+func (d *device) AdvertiseIBeacon(u UUID, major, minor uint16, pwr int8) error {
+	b := make([]byte, 23)
+	b[0] = 0x02                               // Data type: iBeacon
+	b[1] = 0x15                               // Data length: 21 bytes
+	copy(b[2:], reverse(u.b))                 // Big endian
+	binary.BigEndian.PutUint16(b[18:], major) // Big endian
+	binary.BigEndian.PutUint16(b[20:], minor) // Big endian
+	b[22] = uint8(pwr)                        // Measured Tx Power
+	return d.AdvertiseIBeaconData(b)
+}
+
+func (d *device) StopAdvertising() error {
+	return d.hci.SetAdvertiseEnable(false)
+}
+
+func (d *device) Scan(ss []UUID, dup bool) {
+	// TODO: filter
+	d.hci.SetScanEnable(true, dup)
+}
+
+func (d *device) StopScanning() {
+	d.hci.SetScanEnable(false, true)
+}
+
+func (d *device) Connect(p Peripheral) {
+	d.hci.Connect(p.(*peripheral).pd)
+}
+
+func (d *device) CancelConnection(p Peripheral) {
+	d.hci.CancelConnection(p.(*peripheral).pd)
+}
+
+func (d *device) SendHCIRawCommand(c cmd.CmdParam) ([]byte, error) {
+	return d.hci.SendRawCommand(c)
+}
+
+// Flush pending advertising settings to the device.
+func (d *device) update() error {
+	if d.advParam != nil {
+		if err := d.hci.SendCmdWithAdvOff(d.advParam); err != nil {
+			return err
+		}
+		d.advParam = nil
+	}
+	if d.scanResp != nil {
+		if err := d.hci.SendCmdWithAdvOff(d.scanResp); err != nil {
+			return err
+		}
+		d.scanResp = nil
+	}
+	if d.advData != nil {
+		if err := d.hci.SendCmdWithAdvOff(d.advData); err != nil {
+			return err
+		}
+		d.advData = nil
+	}
+	return nil
+}


[2/7] incubator-mynewt-newt git commit: MYNEWT-653 Use runtimeco gatt fork.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/util/util.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/util/util.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/util/util.go
deleted file mode 100644
index 4933008..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/util/util.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package util
-
-import "encoding/binary"
-
-type order struct{ binary.ByteOrder }
-
-var Order = order{binary.LittleEndian}
-
-func (o order) Int8(b []byte) int8   { return int8(b[0]) }
-func (o order) Uint8(b []byte) uint8 { return b[0] }
-func (o order) MAC(b []byte) [6]byte { return [6]byte{b[5], b[4], b[3], b[2], b[1], b[0]} }
-
-func (o order) PutUint8(b []byte, v uint8) { b[0] = v }
-func (o order) PutMAC(b []byte, m [6]byte) {
-	b[0], b[1], b[2], b[3], b[4], b[5] = m[5], m[4], m[3], m[2], m[1], m[0]
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/option_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/option_darwin.go b/newtmgr/vendor/github.com/runtimeinc/gatt/option_darwin.go
deleted file mode 100644
index 617db21..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/option_darwin.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package gatt
-
-const (
-	CentralManager    = 0 // Client functions (default)
-	PeripheralManager = 1 // Server functions
-)
-
-// MacDeviceRole specify the XPC connection type to connect blued.
-// THis option can only be used with NewDevice on OS X implementation.
-func MacDeviceRole(r int) Option {
-	return func(d Device) error {
-		d.(*device).role = r
-		return nil
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/option_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/option_linux.go b/newtmgr/vendor/github.com/runtimeinc/gatt/option_linux.go
deleted file mode 100644
index fe8065b..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/option_linux.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package gatt
-
-import (
-	"errors"
-	"io"
-
-	"github.com/runtimeinc/gatt/linux/cmd"
-)
-
-// LnxDeviceID specifies which HCI device to use.
-// If n is set to -1, all the available HCI devices will be probed.
-// If chk is set to true, LnxDeviceID checks the LE support in the feature list of the HCI device.
-// This is to filter devices that does not support LE. In case some LE driver that doesn't correctly
-// set the LE support in its feature list, user can turn off the check.
-// This option can only be used with NewDevice on Linux implementation.
-func LnxDeviceID(n int, chk bool) Option {
-	return func(d Device) error {
-		d.(*device).devID = n
-		d.(*device).chkLE = chk
-		return nil
-	}
-}
-
-// LnxMaxConnections is an optional parameter.
-// If set, it overrides the default max connections supported.
-// This option can only be used with NewDevice on Linux implementation.
-func LnxMaxConnections(n int) Option {
-	return func(d Device) error {
-		d.(*device).maxConn = n
-		return nil
-	}
-}
-
-// LnxSetAdvertisingEnable sets the advertising data to the HCI device.
-// This option can be used with Option on Linux implementation.
-func LnxSetAdvertisingEnable(en bool) Option {
-	return func(d Device) error {
-		dd := d.(*device)
-		if dd == nil {
-			return errors.New("device is not initialized")
-		}
-		if err := dd.update(); err != nil {
-			return err
-		}
-		return dd.hci.SetAdvertiseEnable(en)
-	}
-}
-
-// LnxSetAdvertisingData sets the advertising data to the HCI device.
-// This option can be used with NewDevice or Option on Linux implementation.
-func LnxSetAdvertisingData(c *cmd.LESetAdvertisingData) Option {
-	return func(d Device) error {
-		d.(*device).advData = c
-		return nil
-	}
-}
-
-// LnxSetScanResponseData sets the scan response data to the HXI device.
-// This option can be used with NewDevice or Option on Linux implementation.
-func LnxSetScanResponseData(c *cmd.LESetScanResponseData) Option {
-	return func(d Device) error {
-		d.(*device).scanResp = c
-		return nil
-	}
-}
-
-// LnxSetAdvertisingParameters sets the advertising parameters to the HCI device.
-// This option can be used with NewDevice or Option on Linux implementation.
-func LnxSetAdvertisingParameters(c *cmd.LESetAdvertisingParameters) Option {
-	return func(d Device) error {
-		d.(*device).advParam = c
-		return nil
-	}
-}
-
-// LnxSendHCIRawCommand sends a raw command to the HCI device
-// This option can be used with NewDevice or Option on Linux implementation.
-func LnxSendHCIRawCommand(c cmd.CmdParam, rsp io.Writer) Option {
-	return func(d Device) error {
-		b, err := d.(*device).SendHCIRawCommand(c)
-		if rsp == nil {
-			return err
-		}
-		rsp.Write(b)
-		return err
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral.go b/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral.go
deleted file mode 100644
index 36ad578..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral.go
+++ /dev/null
@@ -1,102 +0,0 @@
-package gatt
-
-import (
-	"errors"
-	"sync"
-)
-
-// Peripheral is the interface that represent a remote peripheral device.
-type Peripheral interface {
-	// Device returns the underlying device.
-	Device() Device
-
-	// ID is the platform specific unique ID of the remote peripheral, e.g. MAC for Linux, Peripheral UUID for MacOS.
-	ID() string
-
-	// Name returns the name of the remote peripheral.
-	// This can be the advertised name, if exists, or the GAP device name, which takes priority
-	Name() string
-
-	// Services returnns the services of the remote peripheral which has been discovered.
-	Services() []*Service
-
-	// DiscoverServices discover the specified services of the remote peripheral.
-	// If the specified services is set to nil, all the available services of the remote peripheral are returned.
-	DiscoverServices(s []UUID) ([]*Service, error)
-
-	// DiscoverIncludedServices discovers the specified included services of a service.
-	// If the specified services is set to nil, all the included services of the service are returned.
-	DiscoverIncludedServices(ss []UUID, s *Service) ([]*Service, error)
-
-	// DiscoverCharacteristics discovers the specified characteristics of a service.
-	// If the specified characterstics is set to nil, all the characteristic of the service are returned.
-	DiscoverCharacteristics(c []UUID, s *Service) ([]*Characteristic, error)
-
-	// DiscoverDescriptors discovers the descriptors of a characteristic.
-	// If the specified descriptors is set to nil, all the descriptors of the characteristic are returned.
-	DiscoverDescriptors(d []UUID, c *Characteristic) ([]*Descriptor, error)
-
-	// ReadCharacteristic retrieves the value of a specified characteristic.
-	ReadCharacteristic(c *Characteristic) ([]byte, error)
-
-	// ReadLongCharacteristic retrieves the value of a specified characteristic that is longer than the
-	// MTU.
-	ReadLongCharacteristic(c *Characteristic) ([]byte, error)
-
-	// ReadDescriptor retrieves the value of a specified characteristic descriptor.
-	ReadDescriptor(d *Descriptor) ([]byte, error)
-
-	// WriteCharacteristic writes the value of a characteristic.
-	WriteCharacteristic(c *Characteristic, b []byte, noRsp bool) error
-
-	// WriteDescriptor writes the value of a characteristic descriptor.
-	WriteDescriptor(d *Descriptor, b []byte) error
-
-	// SetNotifyValue sets notifications for the value of a specified characteristic.
-	SetNotifyValue(c *Characteristic, f func(*Characteristic, []byte, error)) error
-
-	// SetIndicateValue sets indications for the value of a specified characteristic.
-	SetIndicateValue(c *Characteristic, f func(*Characteristic, []byte, error)) error
-
-	// ReadRSSI retrieves the current RSSI value for the remote peripheral.
-	ReadRSSI() int
-
-	// SetMTU sets the mtu for the remote peripheral.
-	SetMTU(mtu uint16) error
-}
-
-type subscriber struct {
-	sub map[uint16]subscribefn
-	mu  *sync.Mutex
-}
-
-type subscribefn func([]byte, error)
-
-func newSubscriber() *subscriber {
-	return &subscriber{
-		sub: make(map[uint16]subscribefn),
-		mu:  &sync.Mutex{},
-	}
-}
-
-func (s *subscriber) subscribe(h uint16, f subscribefn) {
-	s.mu.Lock()
-	s.sub[h] = f
-	s.mu.Unlock()
-}
-
-func (s *subscriber) unsubscribe(h uint16) {
-	s.mu.Lock()
-	delete(s.sub, h)
-	s.mu.Unlock()
-}
-
-func (s *subscriber) fn(h uint16) subscribefn {
-	s.mu.Lock()
-	defer s.mu.Unlock()
-	return s.sub[h]
-}
-
-var (
-	ErrInvalidLength = errors.New("invalid length")
-)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_darwin.go b/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_darwin.go
deleted file mode 100644
index 69f9b36..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_darwin.go
+++ /dev/null
@@ -1,277 +0,0 @@
-package gatt
-
-import (
-	"errors"
-	"log"
-
-	"github.com/runtimeinc/gatt/xpc"
-)
-
-type peripheral struct {
-	// NameChanged is called whenever the peripheral GAP Device name has changed.
-	NameChanged func(Peripheral)
-
-	// ServicesModified is called when one or more service of a peripheral have changed.
-	// A list of invalid service is provided in the parameter.
-	ServicesModified func(Peripheral, []*Service)
-
-	d    *device
-	svcs []*Service
-
-	sub *subscriber
-
-	id   xpc.UUID
-	name string
-
-	reqc  chan message
-	rspc  chan message
-	quitc chan struct{}
-}
-
-func NewPeripheral(u UUID) Peripheral { return &peripheral{id: xpc.UUID(u.b)} }
-
-func (p *peripheral) Device() Device       { return p.d }
-func (p *peripheral) ID() string           { return p.id.String() }
-func (p *peripheral) Name() string         { return p.name }
-func (p *peripheral) Services() []*Service { return p.svcs }
-
-func (p *peripheral) DiscoverServices(ss []UUID) ([]*Service, error) {
-	rsp := p.sendReq(45, xpc.Dict{
-		"kCBMsgArgDeviceUUID": p.id,
-		"kCBMsgArgUUIDs":      uuidSlice(ss),
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return nil, attEcode(res)
-	}
-	svcs := []*Service{}
-	for _, xss := range rsp["kCBMsgArgServices"].(xpc.Array) {
-		xs := xss.(xpc.Dict)
-		u := MustParseUUID(xs.MustGetHexBytes("kCBMsgArgUUID"))
-		h := uint16(xs.MustGetInt("kCBMsgArgServiceStartHandle"))
-		endh := uint16(xs.MustGetInt("kCBMsgArgServiceEndHandle"))
-		svcs = append(svcs, &Service{uuid: u, h: h, endh: endh})
-	}
-	p.svcs = svcs
-	return svcs, nil
-}
-
-func (p *peripheral) DiscoverIncludedServices(ss []UUID, s *Service) ([]*Service, error) {
-	rsp := p.sendReq(60, xpc.Dict{
-		"kCBMsgArgDeviceUUID":         p.id,
-		"kCBMsgArgServiceStartHandle": s.h,
-		"kCBMsgArgServiceEndHandle":   s.endh,
-		"kCBMsgArgUUIDs":              uuidSlice(ss),
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return nil, attEcode(res)
-	}
-	// TODO
-	return nil, notImplemented
-}
-
-func (p *peripheral) DiscoverCharacteristics(cs []UUID, s *Service) ([]*Characteristic, error) {
-	rsp := p.sendReq(62, xpc.Dict{
-		"kCBMsgArgDeviceUUID":         p.id,
-		"kCBMsgArgServiceStartHandle": s.h,
-		"kCBMsgArgServiceEndHandle":   s.endh,
-		"kCBMsgArgUUIDs":              uuidSlice(cs),
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return nil, attEcode(res)
-	}
-	for _, xcs := range rsp.MustGetArray("kCBMsgArgCharacteristics") {
-		xc := xcs.(xpc.Dict)
-		u := MustParseUUID(xc.MustGetHexBytes("kCBMsgArgUUID"))
-		ch := uint16(xc.MustGetInt("kCBMsgArgCharacteristicHandle"))
-		vh := uint16(xc.MustGetInt("kCBMsgArgCharacteristicValueHandle"))
-		props := Property(xc.MustGetInt("kCBMsgArgCharacteristicProperties"))
-		c := &Characteristic{uuid: u, svc: s, props: props, h: ch, vh: vh}
-		s.chars = append(s.chars, c)
-	}
-	return s.chars, nil
-}
-
-func (p *peripheral) DiscoverDescriptors(ds []UUID, c *Characteristic) ([]*Descriptor, error) {
-	rsp := p.sendReq(70, xpc.Dict{
-		"kCBMsgArgDeviceUUID":                p.id,
-		"kCBMsgArgCharacteristicHandle":      c.h,
-		"kCBMsgArgCharacteristicValueHandle": c.vh,
-		"kCBMsgArgUUIDs":                     uuidSlice(ds),
-	})
-	for _, xds := range rsp.MustGetArray("kCBMsgArgDescriptors") {
-		xd := xds.(xpc.Dict)
-		u := MustParseUUID(xd.MustGetHexBytes("kCBMsgArgUUID"))
-		h := uint16(xd.MustGetInt("kCBMsgArgDescriptorHandle"))
-		d := &Descriptor{uuid: u, char: c, h: h}
-		c.descs = append(c.descs, d)
-	}
-	return c.descs, nil
-}
-
-func (p *peripheral) ReadCharacteristic(c *Characteristic) ([]byte, error) {
-	rsp := p.sendReq(65, xpc.Dict{
-		"kCBMsgArgDeviceUUID":                p.id,
-		"kCBMsgArgCharacteristicHandle":      c.h,
-		"kCBMsgArgCharacteristicValueHandle": c.vh,
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return nil, attEcode(res)
-	}
-	b := rsp.MustGetBytes("kCBMsgArgData")
-	return b, nil
-}
-
-func (p *peripheral) ReadLongCharacteristic(c *Characteristic) ([]byte, error) {
-	return nil, errors.New("Not implemented")
-}
-
-func (p *peripheral) WriteCharacteristic(c *Characteristic, b []byte, noRsp bool) error {
-	args := xpc.Dict{
-		"kCBMsgArgDeviceUUID":                p.id,
-		"kCBMsgArgCharacteristicHandle":      c.h,
-		"kCBMsgArgCharacteristicValueHandle": c.vh,
-		"kCBMsgArgData":                      b,
-		"kCBMsgArgType":                      map[bool]int{false: 0, true: 1}[noRsp],
-	}
-	if noRsp {
-		p.sendCmd(66, args)
-		return nil
-	}
-	rsp := p.sendReq(65, args)
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return attEcode(res)
-	}
-	return nil
-}
-
-func (p *peripheral) ReadDescriptor(d *Descriptor) ([]byte, error) {
-	rsp := p.sendReq(77, xpc.Dict{
-		"kCBMsgArgDeviceUUID":       p.id,
-		"kCBMsgArgDescriptorHandle": d.h,
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return nil, attEcode(res)
-	}
-	b := rsp.MustGetBytes("kCBMsgArgData")
-	return b, nil
-}
-
-func (p *peripheral) WriteDescriptor(d *Descriptor, b []byte) error {
-	rsp := p.sendReq(78, xpc.Dict{
-		"kCBMsgArgDeviceUUID":       p.id,
-		"kCBMsgArgDescriptorHandle": d.h,
-		"kCBMsgArgData":             b,
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return attEcode(res)
-	}
-	return nil
-}
-
-func (p *peripheral) SetNotifyValue(c *Characteristic, f func(*Characteristic, []byte, error)) error {
-	set := 1
-	if f == nil {
-		set = 0
-	}
-	// To avoid race condition, registeration is handled before requesting the server.
-	if f != nil {
-		// Note: when notified, core bluetooth reports characteristic handle, not value's handle.
-		p.sub.subscribe(c.h, func(b []byte, err error) { f(c, b, err) })
-	}
-	rsp := p.sendReq(68, xpc.Dict{
-		"kCBMsgArgDeviceUUID":                p.id,
-		"kCBMsgArgCharacteristicHandle":      c.h,
-		"kCBMsgArgCharacteristicValueHandle": c.vh,
-		"kCBMsgArgState":                     set,
-	})
-	if res := rsp.MustGetInt("kCBMsgArgResult"); res != 0 {
-		return attEcode(res)
-	}
-	// To avoid race condition, unregisteration is handled after server responses.
-	if f == nil {
-		p.sub.unsubscribe(c.h)
-	}
-	return nil
-}
-
-func (p *peripheral) SetIndicateValue(c *Characteristic,
-	f func(*Characteristic, []byte, error)) error {
-	// TODO: Implement set indications logic for darwin (https://github.com/runtimeinc/gatt/issues/32)
-	return nil
-}
-
-func (p *peripheral) ReadRSSI() int {
-	rsp := p.sendReq(43, xpc.Dict{"kCBMsgArgDeviceUUID": p.id})
-	return rsp.MustGetInt("kCBMsgArgData")
-}
-
-func (p *peripheral) SetMTU(mtu uint16) error {
-	return errors.New("Not implemented")
-}
-
-func uuidSlice(uu []UUID) [][]byte {
-	us := [][]byte{}
-	for _, u := range uu {
-		us = append(us, reverse(u.b))
-	}
-	return us
-}
-
-type message struct {
-	id   int
-	args xpc.Dict
-	rspc chan xpc.Dict
-}
-
-func (p *peripheral) sendCmd(id int, args xpc.Dict) {
-	p.reqc <- message{id: id, args: args}
-}
-
-func (p *peripheral) sendReq(id int, args xpc.Dict) xpc.Dict {
-	m := message{id: id, args: args, rspc: make(chan xpc.Dict)}
-	p.reqc <- m
-	return <-m.rspc
-}
-
-func (p *peripheral) loop() {
-	rspc := make(chan message)
-
-	go func() {
-		for {
-			select {
-			case req := <-p.reqc:
-				p.d.sendCBMsg(req.id, req.args)
-				if req.rspc == nil {
-					break
-				}
-				m := <-rspc
-				req.rspc <- m.args
-			case <-p.quitc:
-				return
-			}
-		}
-	}()
-
-	for {
-		select {
-		case rsp := <-p.rspc:
-			// Notification
-			if rsp.id == 71 && rsp.args.GetInt("kCBMsgArgIsNotification", 0) != 0 {
-				// While we're notified with the value's handle, blued reports the characteristic handle.
-				ch := uint16(rsp.args.MustGetInt("kCBMsgArgCharacteristicHandle"))
-				b := rsp.args.MustGetBytes("kCBMsgArgData")
-				f := p.sub.fn(ch)
-				if f == nil {
-					log.Printf("notified by unsubscribed handle")
-					// FIXME: should terminate the connection?
-				} else {
-					go f(b, nil)
-				}
-				break
-			}
-			rspc <- rsp
-		case <-p.quitc:
-			return
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_linux.go b/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_linux.go
deleted file mode 100644
index a8a819c..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/peripheral_linux.go
+++ /dev/null
@@ -1,448 +0,0 @@
-package gatt
-
-import (
-	"bytes"
-	"encoding/binary"
-	"fmt"
-	"io"
-	"log"
-	"net"
-	"strings"
-
-	"github.com/runtimeinc/gatt/linux"
-)
-
-type peripheral struct {
-	// NameChanged is called whenever the peripheral GAP device name has changed.
-	NameChanged func(*peripheral)
-
-	// ServicedModified is called when one or more service of a peripheral have changed.
-	// A list of invalid service is provided in the parameter.
-	ServicesModified func(*peripheral, []*Service)
-
-	d    *device
-	svcs []*Service
-
-	sub *subscriber
-
-	mtu uint16
-	l2c io.ReadWriteCloser
-
-	reqc  chan message
-	quitc chan struct{}
-
-	pd *linux.PlatData // platform specific data
-}
-
-func (p *peripheral) Device() Device       { return p.d }
-func (p *peripheral) ID() string           { return strings.ToUpper(net.HardwareAddr(p.pd.Address[:]).String()) }
-func (p *peripheral) Name() string         { return p.pd.Name }
-func (p *peripheral) Services() []*Service { return p.svcs }
-
-func finish(op byte, h uint16, b []byte) bool {
-	done := b[0] == attOpError && b[1] == op && b[2] == byte(h) && b[3] == byte(h>>8)
-	e := attEcode(b[4])
-	if e != attEcodeAttrNotFound {
-		// log.Printf("unexpected protocol error: %s", e)
-		// FIXME: terminate the connection
-	}
-	return done
-}
-
-func (p *peripheral) DiscoverServices(s []UUID) ([]*Service, error) {
-	// TODO: implement the UUID filters
-	// p.pd.Conn.Write([]byte{0x02, 0x87, 0x00}) // MTU
-	done := false
-	start := uint16(0x0001)
-	for !done {
-		op := byte(attOpReadByGroupReq)
-		b := make([]byte, 7)
-		b[0] = op
-		binary.LittleEndian.PutUint16(b[1:3], start)
-		binary.LittleEndian.PutUint16(b[3:5], 0xFFFF)
-		binary.LittleEndian.PutUint16(b[5:7], 0x2800)
-
-		b = p.sendReq(op, b)
-		if finish(op, start, b) {
-			break
-		}
-		b = b[1:]
-		l, b := int(b[0]), b[1:]
-		switch {
-		case l == 6 && (len(b)%6 == 0):
-		case l == 20 && (len(b)%20 == 0):
-		default:
-			return nil, ErrInvalidLength
-		}
-
-		for len(b) != 0 {
-			h := binary.LittleEndian.Uint16(b[:2])
-			endh := binary.LittleEndian.Uint16(b[2:4])
-			s := &Service{
-				uuid: UUID{b[4:l]},
-				h:    h,
-				endh: endh,
-			}
-			p.svcs = append(p.svcs, s)
-			b = b[l:]
-			done = endh == 0xFFFF
-			start = endh + 1
-		}
-	}
-	return p.svcs, nil
-}
-
-func (p *peripheral) DiscoverIncludedServices(ss []UUID, s *Service) ([]*Service, error) {
-	// TODO
-	return nil, nil
-}
-
-func (p *peripheral) DiscoverCharacteristics(cs []UUID, s *Service) ([]*Characteristic, error) {
-	// TODO: implement the UUID filters
-	done := false
-	start := s.h
-	var prev *Characteristic
-	for !done {
-		op := byte(attOpReadByTypeReq)
-		b := make([]byte, 7)
-		b[0] = op
-		binary.LittleEndian.PutUint16(b[1:3], start)
-		binary.LittleEndian.PutUint16(b[3:5], s.endh)
-		binary.LittleEndian.PutUint16(b[5:7], 0x2803)
-
-		b = p.sendReq(op, b)
-		if finish(op, start, b) {
-			break
-		}
-		b = b[1:]
-
-		l, b := int(b[0]), b[1:]
-		switch {
-		case l == 7 && (len(b)%7 == 0):
-		case l == 21 && (len(b)%21 == 0):
-		default:
-			return nil, ErrInvalidLength
-		}
-
-		for len(b) != 0 {
-			h := binary.LittleEndian.Uint16(b[:2])
-			props := Property(b[2])
-			vh := binary.LittleEndian.Uint16(b[3:5])
-			u := UUID{b[5:l]}
-			s := searchService(p.svcs, h, vh)
-			if s == nil {
-				log.Printf("Can't find service range that contains 0x%04X - 0x%04X", h, vh)
-				return nil, fmt.Errorf("Can't find service range that contains 0x%04X - 0x%04X", h, vh)
-			}
-			c := &Characteristic{
-				uuid:  u,
-				svc:   s,
-				props: props,
-				h:     h,
-				vh:    vh,
-			}
-			s.chars = append(s.chars, c)
-			b = b[l:]
-			done = vh == s.endh
-			start = vh + 1
-			if prev != nil {
-				prev.endh = c.h - 1
-			}
-			prev = c
-		}
-	}
-	if len(s.chars) > 1 {
-		s.chars[len(s.chars)-1].endh = s.endh
-	}
-	return s.chars, nil
-}
-
-func (p *peripheral) DiscoverDescriptors(ds []UUID, c *Characteristic) ([]*Descriptor, error) {
-	// TODO: implement the UUID filters
-	done := false
-	start := c.vh + 1
-	for !done {
-		if c.endh == 0 {
-			c.endh = c.svc.endh
-		}
-		op := byte(attOpFindInfoReq)
-		b := make([]byte, 5)
-		b[0] = op
-		binary.LittleEndian.PutUint16(b[1:3], start)
-		binary.LittleEndian.PutUint16(b[3:5], c.endh)
-
-		b = p.sendReq(op, b)
-		if finish(attOpFindInfoReq, start, b) {
-			break
-		}
-		b = b[1:]
-
-		var l int
-		f, b := int(b[0]), b[1:]
-		switch {
-		case f == 1 && (len(b)%4 == 0):
-			l = 4
-		case f == 2 && (len(b)%18 == 0):
-			l = 18
-		default:
-			return nil, ErrInvalidLength
-		}
-
-		for len(b) != 0 {
-			h := binary.LittleEndian.Uint16(b[:2])
-			u := UUID{b[2:l]}
-			d := &Descriptor{uuid: u, h: h, char: c}
-			c.descs = append(c.descs, d)
-			if u.Equal(attrClientCharacteristicConfigUUID) {
-				c.cccd = d
-			}
-			b = b[l:]
-			done = h == c.endh
-			start = h + 1
-		}
-	}
-	return c.descs, nil
-}
-
-func (p *peripheral) ReadCharacteristic(c *Characteristic) ([]byte, error) {
-	b := make([]byte, 3)
-	op := byte(attOpReadReq)
-	b[0] = op
-	binary.LittleEndian.PutUint16(b[1:3], c.vh)
-
-	b = p.sendReq(op, b)
-	b = b[1:]
-	return b, nil
-}
-
-func (p *peripheral) ReadLongCharacteristic(c *Characteristic) ([]byte, error) {
-	// The spec says that a read blob request should fail if the characteristic
-	// is smaller than mtu - 1.  To simplify the API, the first read is done
-	// with a regular read request.  If the buffer received is equal to mtu -1,
-	// then we read the rest of the data using read blob.
-	firstRead, err := p.ReadCharacteristic(c)
-	if err != nil {
-		return nil, err
-	}
-	if len(firstRead) < int(p.mtu)-1 {
-		return firstRead, nil
-	}
-
-	var buf bytes.Buffer
-	buf.Write(firstRead)
-	off := uint16(len(firstRead))
-	for {
-		b := make([]byte, 5)
-		op := byte(attOpReadBlobReq)
-		b[0] = op
-		binary.LittleEndian.PutUint16(b[1:3], c.vh)
-		binary.LittleEndian.PutUint16(b[3:5], off)
-
-		b = p.sendReq(op, b)
-		b = b[1:]
-		if len(b) == 0 {
-			break
-		}
-		buf.Write(b)
-		off += uint16(len(b))
-		if len(b) < int(p.mtu)-1 {
-			break
-		}
-	}
-	return buf.Bytes(), nil
-}
-
-func (p *peripheral) WriteCharacteristic(c *Characteristic, value []byte, noRsp bool) error {
-	b := make([]byte, 3+len(value))
-	op := byte(attOpWriteReq)
-	b[0] = op
-	if noRsp {
-		b[0] = attOpWriteCmd
-	}
-	binary.LittleEndian.PutUint16(b[1:3], c.vh)
-	copy(b[3:], value)
-
-	if noRsp {
-		p.sendCmd(op, b)
-		return nil
-	}
-	b = p.sendReq(op, b)
-	// TODO: error handling
-	b = b[1:]
-	return nil
-}
-
-func (p *peripheral) ReadDescriptor(d *Descriptor) ([]byte, error) {
-	b := make([]byte, 3)
-	op := byte(attOpReadReq)
-	b[0] = op
-	binary.LittleEndian.PutUint16(b[1:3], d.h)
-
-	b = p.sendReq(op, b)
-	b = b[1:]
-	// TODO: error handling
-	return b, nil
-}
-
-func (p *peripheral) WriteDescriptor(d *Descriptor, value []byte) error {
-	b := make([]byte, 3+len(value))
-	op := byte(attOpWriteReq)
-	b[0] = op
-	binary.LittleEndian.PutUint16(b[1:3], d.h)
-	copy(b[3:], value)
-
-	b = p.sendReq(op, b)
-	b = b[1:]
-	// TODO: error handling
-	return nil
-}
-
-func (p *peripheral) setNotifyValue(c *Characteristic, flag uint16,
-	f func(*Characteristic, []byte, error)) error {
-/*
-	if c.cccd == nil {
-		return errors.New("no cccd") // FIXME
-	}
-	ccc := uint16(0)
-	if f != nil {
-		ccc = flag
-*/
-		p.sub.subscribe(c.vh, func(b []byte, err error) { f(c, b, err) })
-/*
-	}
-	b := make([]byte, 5)
-	op := byte(attOpWriteReq)
-	b[0] = op
-	binary.LittleEndian.PutUint16(b[1:3], c.cccd.h)
-	binary.LittleEndian.PutUint16(b[3:5], ccc)
-
-	b = p.sendReq(op, b)
-	b = b[1:]
-	// TODO: error handling
-	if f == nil {
-		p.sub.unsubscribe(c.vh)
-	}
-*/
-	return nil
-}
-
-func (p *peripheral) SetNotifyValue(c *Characteristic,
-	f func(*Characteristic, []byte, error)) error {
-	return p.setNotifyValue(c, gattCCCNotifyFlag, f)
-}
-
-func (p *peripheral) SetIndicateValue(c *Characteristic,
-	f func(*Characteristic, []byte, error)) error {
-	return p.setNotifyValue(c, gattCCCIndicateFlag, f)
-}
-
-func (p *peripheral) ReadRSSI() int {
-	// TODO: implement
-	return -1
-}
-
-func searchService(ss []*Service, start, end uint16) *Service {
-	for _, s := range ss {
-		if s.h < start && s.endh >= end {
-			return s
-		}
-	}
-	return nil
-}
-
-// TODO: unifiy the message with OS X pots and refactor
-type message struct {
-	op   byte
-	b    []byte
-	rspc chan []byte
-}
-
-func (p *peripheral) sendCmd(op byte, b []byte) {
-	p.reqc <- message{op: op, b: b}
-}
-
-func (p *peripheral) sendReq(op byte, b []byte) []byte {
-	m := message{op: op, b: b, rspc: make(chan []byte)}
-	p.reqc <- m
-	return <-m.rspc
-}
-
-func (p *peripheral) loop() {
-	// Serialize the request.
-	rspc := make(chan []byte)
-
-	// Dequeue request loop
-	go func() {
-		for {
-			select {
-			case req := <-p.reqc:
-				p.l2c.Write(req.b)
-				if req.rspc == nil {
-					break
-				}
-				r := <-rspc
-				switch reqOp, rspOp := req.b[0], r[0]; {
-				case rspOp == attRspFor[reqOp]:
-				case rspOp == attOpError && r[1] == reqOp:
-				default:
-					log.Printf("Request 0x%02x got a mismatched response: 0x%02x", reqOp, rspOp)
-					// FIXME: terminate the connection?
-				}
-				req.rspc <- r
-			case <-p.quitc:
-				return
-			}
-		}
-	}()
-
-	// L2CAP implementations shall support a minimum MTU size of 48 bytes.
-	// The default value is 672 bytes
-	buf := make([]byte, 672)
-
-	// Handling response or notification/indication
-	for {
-		n, err := p.l2c.Read(buf)
-		if n == 0 || err != nil {
-			close(p.quitc)
-			return
-		}
-
-		b := make([]byte, n)
-		copy(b, buf)
-
-		if (b[0] != attOpHandleNotify) && (b[0] != attOpHandleInd) {
-			rspc <- b
-			continue
-		}
-
-		h := binary.LittleEndian.Uint16(b[1:3])
-		f := p.sub.fn(h)
-		if f == nil {
-			log.Printf("notified by unsubscribed handle")
-			// FIXME: terminate the connection?
-		} else {
-			go f(b[3:], nil)
-		}
-
-		if b[0] == attOpHandleInd {
-			// write aknowledgement for indication
-			p.l2c.Write([]byte{attOpHandleCnf})
-		}
-
-	}
-}
-
-func (p *peripheral) SetMTU(mtu uint16) error {
-	b := make([]byte, 3)
-	op := byte(attOpMtuReq)
-	b[0] = op
-	binary.LittleEndian.PutUint16(b[1:3], uint16(mtu))
-
-	b = p.sendReq(op, b)
-	serverMTU := binary.LittleEndian.Uint16(b[1:3])
-	if serverMTU < mtu {
-		mtu = serverMTU
-	}
-	p.mtu = mtu
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/readme.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/readme.md b/newtmgr/vendor/github.com/runtimeinc/gatt/readme.md
deleted file mode 100644
index ea3a957..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/readme.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# Package gatt provides a Bluetooth Low Energy GATT implementation.
-
-Gatt (Generic Attribute Profile) is the protocol used to write BLE peripherals (servers) and centrals (clients).
-
-As a peripheral, you can create services, characteristics, and descriptors,
-advertise, accept connections, and handle requests.
-
-As a central, you can scan, connect, discover services, and make requests.
-
-## SETUP
-
-### gatt supports both Linux and OS X.
-
-### On Linux:
-To gain complete and exclusive control of the HCI device, gatt uses
-HCI_CHANNEL_USER (introduced in Linux v3.14) instead of HCI_CHANNEL_RAW.
-Those who must use an older kernel may patch in these relevant commits
-from Marcel Holtmann:
-
-    Bluetooth: Introduce new HCI socket channel for user operation
-    Bluetooth: Introduce user channel flag for HCI devices
-    Bluetooth: Refactor raw socket filter into more readable code
-
-Note that because gatt uses HCI_CHANNEL_USER, once gatt has opened the
-device no other program may access it.
-
-Before starting a gatt program, make sure that your BLE device is down:
-
-    sudo hciconfig
-    sudo hciconfig hci0 down  # or whatever hci device you want to use
-
-If you have BlueZ 5.14+ (or aren't sure), stop the built-in
-bluetooth server, which interferes with gatt, e.g.:
-
-    sudo service bluetooth stop
-
-Because gatt programs administer network devices, they must
-either be run as root, or be granted appropriate capabilities:
-
-    sudo <executable>
-    # OR
-    sudo setcap 'cap_net_raw,cap_net_admin=eip' <executable>
-    <executable>
-
-## Usage
-Please see [godoc.org](http://godoc.org/github.com/paypal/gatt) for documentation.
-
-## Examples
-
-### Build and run the examples on a native environment (Linux or OS X)
-
-Go is a compiled language, which means to run the examples you need to build them first.
-
-    # Build the sample server.
-    go build examples/server.go
-    # Start the sample server.
-    sudo ./server
-
-Alternatively, you can use "go run" to build and run the examples in a single step:
-
-    # Build and run the sample server.
-    sudo go run examples/server.go
-
-Discoverer and explorer demonstrates central (client) functions:
-
-    # Discover surrounding peripherals.
-    sudo go run examples/discoverer.go
-
-    # Connect to and explorer a peripheral device.
-    sudo go run examples/explorer.go <peripheral ID>
-
-### Cross-compile and deploy to a target device
-
-    # Build and run the server example on a ARMv5 target device.
-    GOARCH=arm GOARM=5 GOOS=linux go build examples/server.go
-    cp server <target device>
-    # Start the server on the target device
-    sudo ./server
-
-See the server.go, discoverer.go, and explorer.go in the examples/
-directory for writing server or client programs that run on Linux
-and OS X.
-
-Users, especially on Linux platforms, seeking finer-grained control
-over the devices can see the examples/server_lnx.go for the usage
-of Option, which are platform specific.
-
-See the rest of the docs for other options and finer-grained control.
-
-## Note
-Note that some BLE central devices, particularly iOS, may aggressively
-cache results from previous connections. If you change your services or
-characteristics, you may need to reboot the other device to pick up the
-changes. This is a common source of confusion and apparent bugs. For an
-OS X central, see http://stackoverflow.com/questions/20553957.
-
-## Known Issues
-
-Currently OS X vesion  does not support subscribing to indications. 
-Please check [#32](https://github.com/paypal/gatt/issues/32) for the status of this issue.
-
-## REFERENCES
-
-gatt started life as a port of bleno, to which it is indebted:
-https://github.com/sandeepmistry/bleno. If you are having
-problems with gatt, particularly around installation, issues
-filed with bleno might also be helpful references.
-
-To try out your GATT server, it is useful to experiment with a
-generic BLE client. LightBlue is a good choice. It is available
-free for both iOS and OS X.
-
-gatt is similar to [bleno](https://github.com/sandeepmistry/bleno) and [noble](https://github.com/sandeepmistry/noble), which offer BLE GATT implementations for node.js.
-
-Gatt is released under a [BSD-style license](./LICENSE.md).

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/uuid.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/uuid.go b/newtmgr/vendor/github.com/runtimeinc/gatt/uuid.go
deleted file mode 100644
index 393e548..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/uuid.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package gatt
-
-import (
-	"bytes"
-	"encoding/binary"
-	"encoding/hex"
-	"fmt"
-	"strings"
-)
-
-// A UUID is a BLE UUID.
-type UUID struct {
-	// Hide the bytes, so that we can enforce that they have length 2 or 16,
-	// and that they are immutable. This simplifies the code and API.
-	b []byte
-}
-
-// UUID16 converts a uint16 (such as 0x1800) to a UUID.
-func UUID16(i uint16) UUID {
-	b := make([]byte, 2)
-	binary.LittleEndian.PutUint16(b, i)
-	return UUID{b}
-}
-
-// ParseUUID parses a standard-format UUID string, such
-// as "1800" or "34DA3AD1-7110-41A1-B1EF-4430F509CDE7".
-func ParseUUID(s string) (UUID, error) {
-	s = strings.Replace(s, "-", "", -1)
-	b, err := hex.DecodeString(s)
-	if err != nil {
-		return UUID{}, err
-	}
-	if err := lenErr(len(b)); err != nil {
-		return UUID{}, err
-	}
-	return UUID{reverse(b)}, nil
-}
-
-// MustParseUUID parses a standard-format UUID string,
-// like ParseUUID, but panics in case of error.
-func MustParseUUID(s string) UUID {
-	u, err := ParseUUID(s)
-	if err != nil {
-		panic(err)
-	}
-	return u
-}
-
-// lenErr returns an error if n is an invalid UUID length.
-func lenErr(n int) error {
-	switch n {
-	case 2, 16:
-		return nil
-	}
-	return fmt.Errorf("UUIDs must have length 2 or 16, got %d", n)
-}
-
-// Len returns the length of the UUID, in bytes.
-// BLE UUIDs are either 2 or 16 bytes.
-func (u UUID) Len() int {
-	return len(u.b)
-}
-
-// String hex-encodes a UUID.
-func (u UUID) String() string {
-	return fmt.Sprintf("%x", reverse(u.b))
-}
-
-// Equal returns a boolean reporting whether v represent the same UUID as u.
-func (u UUID) Equal(v UUID) bool {
-	return bytes.Equal(u.b, v.b)
-}
-
-// reverse returns a reversed copy of u.
-func reverse(u []byte) []byte {
-	// Special-case 16 bit UUIDS for speed.
-	l := len(u)
-	if l == 2 {
-		return []byte{u[1], u[0]}
-	}
-	b := make([]byte, l)
-	for i := 0; i < l/2+1; i++ {
-		b[i], b[l-i-1] = u[l-i-1], u[i]
-	}
-	return b
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/LICENSE
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/LICENSE b/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/LICENSE
deleted file mode 100644
index 766a0a5..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) {{{year}}} {{{fullname}}}
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/doc.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/doc.go b/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/doc.go
deleted file mode 100644
index d292249..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/doc.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Package xpc provides minimal OS X XPC support required for gatt
-//
-// This is adapted from [goble], by Raffaele Sena.
-//
-//     http://godoc.org/github.com/raff/goble
-//     https://github.com/raff/goble
-
-package xpc

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_darwin.go b/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_darwin.go
deleted file mode 100644
index 2a85a99..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_darwin.go
+++ /dev/null
@@ -1,350 +0,0 @@
-package xpc
-
-/*
-#include "xpc_wrapper_darwin.h"
-#include "sys/utsname.h"
-*/
-import "C"
-
-import (
-	"errors"
-	"fmt"
-	"log"
-	r "reflect"
-	"unsafe"
-)
-
-type XPC struct {
-	conn C.xpc_connection_t
-}
-
-func (x *XPC) Send(msg interface{}, verbose bool) {
-	// verbose == true converts the type from bool to C._Bool
-	C.XpcSendMessage(x.conn, goToXpc(msg), true, verbose == true)
-}
-
-//
-// minimal XPC support required for BLE
-//
-
-// a dictionary of things
-type Dict map[string]interface{}
-
-func (d Dict) Contains(k string) bool {
-	_, ok := d[k]
-	return ok
-}
-
-func (d Dict) MustGetDict(k string) Dict {
-	return d[k].(Dict)
-}
-
-func (d Dict) MustGetArray(k string) Array {
-	return d[k].(Array)
-}
-
-func (d Dict) MustGetBytes(k string) []byte {
-	return d[k].([]byte)
-}
-
-func (d Dict) MustGetHexBytes(k string) string {
-	return fmt.Sprintf("%x", d[k].([]byte))
-}
-
-func (d Dict) MustGetInt(k string) int {
-	return int(d[k].(int64))
-}
-
-func (d Dict) MustGetUUID(k string) []byte {
-	u := d[k].(UUID)
-	return u[:]
-}
-
-func (d Dict) GetString(k, defv string) string {
-	if v := d[k]; v != nil {
-		//log.Printf("GetString %s %#v\n", k, v)
-		return v.(string)
-	} else {
-		//log.Printf("GetString %s default %#v\n", k, defv)
-		return defv
-	}
-}
-
-func (d Dict) GetBytes(k string, defv []byte) []byte {
-	if v := d[k]; v != nil {
-		//log.Printf("GetBytes %s %#v\n", k, v)
-		return v.([]byte)
-	} else {
-		//log.Printf("GetBytes %s default %#v\n", k, defv)
-		return defv
-	}
-}
-
-func (d Dict) GetInt(k string, defv int) int {
-	if v := d[k]; v != nil {
-		//log.Printf("GetString %s %#v\n", k, v)
-		return int(v.(int64))
-	} else {
-		//log.Printf("GetString %s default %#v\n", k, defv)
-		return defv
-	}
-}
-
-func (d Dict) GetUUID(k string) UUID {
-	return GetUUID(d[k])
-}
-
-// an array of things
-type Array []interface{}
-
-func (a Array) GetUUID(k int) UUID {
-	return GetUUID(a[k])
-}
-
-// a UUID
-type UUID []byte
-
-func MakeUUID(s string) UUID {
-	var sl []byte
-	fmt.Sscanf(s, "%32x", &sl)
-
-	var uuid [16]byte
-	copy(uuid[:], sl)
-	return UUID(uuid[:])
-}
-
-func (uuid UUID) String() string {
-	return fmt.Sprintf("%x", []byte(uuid))
-}
-
-func GetUUID(v interface{}) UUID {
-	if v == nil {
-		return UUID{}
-	}
-
-	if uuid, ok := v.(UUID); ok {
-		return uuid
-	}
-
-	if bytes, ok := v.([]byte); ok {
-		uuid := UUID{}
-
-		for i, b := range bytes {
-			uuid[i] = b
-		}
-
-		return uuid
-	}
-
-	if bytes, ok := v.([]uint8); ok {
-		uuid := UUID{}
-
-		for i, b := range bytes {
-			uuid[i] = b
-		}
-
-		return uuid
-	}
-
-	log.Fatalf("invalid type for UUID: %#v", v)
-	return UUID{}
-}
-
-var (
-	CONNECTION_INVALID     = errors.New("connection invalid")
-	CONNECTION_INTERRUPTED = errors.New("connection interrupted")
-	CONNECTION_TERMINATED  = errors.New("connection terminated")
-
-	TYPE_OF_UUID  = r.TypeOf(UUID{})
-	TYPE_OF_BYTES = r.TypeOf([]byte{})
-)
-
-type XpcEventHandler interface {
-	HandleXpcEvent(event Dict, err error)
-}
-
-func XpcConnect(service string, eh XpcEventHandler) XPC {
-	cservice := C.CString(service)
-	defer C.free(unsafe.Pointer(cservice))
-	return XPC{conn: C.XpcConnect(cservice, unsafe.Pointer(&eh))}
-}
-
-//export handleXpcEvent
-func handleXpcEvent(event C.xpc_object_t, p unsafe.Pointer) {
-	//log.Printf("handleXpcEvent %#v %#v\n", event, p)
-
-	t := C.xpc_get_type(event)
-	eh := *((*XpcEventHandler)(p))
-
-	if t == C.TYPE_ERROR {
-		if event == C.ERROR_CONNECTION_INVALID {
-			// The client process on the other end of the connection has either
-			// crashed or cancelled the connection. After receiving this error,
-			// the connection is in an invalid state, and you do not need to
-			// call xpc_connection_cancel(). Just tear down any associated state
-			// here.
-			//log.Println("connection invalid")
-			eh.HandleXpcEvent(nil, CONNECTION_INVALID)
-		} else if event == C.ERROR_CONNECTION_INTERRUPTED {
-			//log.Println("connection interrupted")
-			eh.HandleXpcEvent(nil, CONNECTION_INTERRUPTED)
-		} else if event == C.ERROR_CONNECTION_TERMINATED {
-			// Handle per-connection termination cleanup.
-			//log.Println("connection terminated")
-			eh.HandleXpcEvent(nil, CONNECTION_TERMINATED)
-		} else {
-			//log.Println("got some error", event)
-			eh.HandleXpcEvent(nil, fmt.Errorf("%v", event))
-		}
-	} else {
-		eh.HandleXpcEvent(xpcToGo(event).(Dict), nil)
-	}
-}
-
-// goToXpc converts a go object to an xpc object
-func goToXpc(o interface{}) C.xpc_object_t {
-	return valueToXpc(r.ValueOf(o))
-}
-
-// valueToXpc converts a go Value to an xpc object
-//
-// note that not all the types are supported, but only the subset required for Blued
-func valueToXpc(val r.Value) C.xpc_object_t {
-	if !val.IsValid() {
-		return nil
-	}
-
-	var xv C.xpc_object_t
-
-	switch val.Kind() {
-	case r.Int, r.Int8, r.Int16, r.Int32, r.Int64:
-		xv = C.xpc_int64_create(C.int64_t(val.Int()))
-
-	case r.Uint, r.Uint8, r.Uint16, r.Uint32:
-		xv = C.xpc_int64_create(C.int64_t(val.Uint()))
-
-	case r.String:
-		xv = C.xpc_string_create(C.CString(val.String()))
-
-	case r.Map:
-		xv = C.xpc_dictionary_create(nil, nil, 0)
-		for _, k := range val.MapKeys() {
-			v := valueToXpc(val.MapIndex(k))
-			C.xpc_dictionary_set_value(xv, C.CString(k.String()), v)
-			if v != nil {
-				C.xpc_release(v)
-			}
-		}
-
-	case r.Array, r.Slice:
-		if val.Type() == TYPE_OF_UUID {
-			// array of bytes
-			var uuid [16]byte
-			r.Copy(r.ValueOf(uuid[:]), val)
-			xv = C.xpc_uuid_create(C.ptr_to_uuid(unsafe.Pointer(&uuid[0])))
-		} else if val.Type() == TYPE_OF_BYTES {
-			// slice of bytes
-			xv = C.xpc_data_create(unsafe.Pointer(val.Pointer()), C.size_t(val.Len()))
-		} else {
-			xv = C.xpc_array_create(nil, 0)
-			l := val.Len()
-
-			for i := 0; i < l; i++ {
-				v := valueToXpc(val.Index(i))
-				C.xpc_array_append_value(xv, v)
-				if v != nil {
-					C.xpc_release(v)
-				}
-			}
-		}
-
-	case r.Interface, r.Ptr:
-		xv = valueToXpc(val.Elem())
-
-	default:
-		log.Fatalf("unsupported %#v", val.String())
-	}
-
-	return xv
-}
-
-//export arraySet
-func arraySet(u unsafe.Pointer, i C.int, v C.xpc_object_t) {
-	a := *(*Array)(u)
-	a[i] = xpcToGo(v)
-}
-
-//export dictSet
-func dictSet(u unsafe.Pointer, k *C.char, v C.xpc_object_t) {
-	d := *(*Dict)(u)
-	d[C.GoString(k)] = xpcToGo(v)
-}
-
-// xpcToGo converts an xpc object to a go object
-//
-// note that not all the types are supported, but only the subset required for Blued
-func xpcToGo(v C.xpc_object_t) interface{} {
-	t := C.xpc_get_type(v)
-
-	switch t {
-	case C.TYPE_ARRAY:
-		a := make(Array, C.int(C.xpc_array_get_count(v)))
-		C.XpcArrayApply(unsafe.Pointer(&a), v)
-		return a
-
-	case C.TYPE_DATA:
-		return C.GoBytes(C.xpc_data_get_bytes_ptr(v), C.int(C.xpc_data_get_length(v)))
-
-	case C.TYPE_DICT:
-		d := make(Dict)
-		C.XpcDictApply(unsafe.Pointer(&d), v)
-		return d
-
-	case C.TYPE_INT64:
-		return int64(C.xpc_int64_get_value(v))
-
-	case C.TYPE_STRING:
-		return C.GoString(C.xpc_string_get_string_ptr(v))
-
-	case C.TYPE_UUID:
-		a := [16]byte{}
-		C.XpcUUIDGetBytes(unsafe.Pointer(&a), v)
-		return UUID(a[:])
-
-	default:
-		log.Fatalf("unexpected type %#v, value %#v", t, v)
-	}
-
-	return nil
-}
-
-// xpc_release is needed by tests, since they can't use CGO
-func xpc_release(xv C.xpc_object_t) {
-	C.xpc_release(xv)
-}
-
-// this is used to check the OS version
-
-type Utsname struct {
-	Sysname  string
-	Nodename string
-	Release  string
-	Version  string
-	Machine  string
-}
-
-func Uname(utsname *Utsname) error {
-	var cstruct C.struct_utsname
-	if err := C.uname(&cstruct); err != 0 {
-		return errors.New("utsname error")
-	}
-
-	// XXX: this may crash if any value is exactly 256 characters (no 0 terminator)
-	utsname.Sysname = C.GoString(&cstruct.sysname[0])
-	utsname.Nodename = C.GoString(&cstruct.nodename[0])
-	utsname.Release = C.GoString(&cstruct.release[0])
-	utsname.Version = C.GoString(&cstruct.version[0])
-	utsname.Machine = C.GoString(&cstruct.machine[0])
-
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.c
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.c b/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.c
deleted file mode 100644
index 7bcb83d..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <dispatch/dispatch.h>
-#include <xpc/xpc.h>
-#include <xpc/connection.h>
-#include <Block.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "_cgo_export.h"
-
-//
-// types and errors are implemented as macros
-// create some real objects to make them accessible to Go
-//
-xpc_type_t TYPE_ERROR = XPC_TYPE_ERROR;
-
-xpc_type_t TYPE_ARRAY = XPC_TYPE_ARRAY;
-xpc_type_t TYPE_DATA = XPC_TYPE_DATA;
-xpc_type_t TYPE_DICT = XPC_TYPE_DICTIONARY;
-xpc_type_t TYPE_INT64 = XPC_TYPE_INT64;
-xpc_type_t TYPE_STRING = XPC_TYPE_STRING;
-xpc_type_t TYPE_UUID = XPC_TYPE_UUID;
-
-xpc_object_t ERROR_CONNECTION_INVALID = (xpc_object_t) XPC_ERROR_CONNECTION_INVALID;
-xpc_object_t ERROR_CONNECTION_INTERRUPTED = (xpc_object_t) XPC_ERROR_CONNECTION_INTERRUPTED;
-xpc_object_t ERROR_CONNECTION_TERMINATED = (xpc_object_t) XPC_ERROR_TERMINATION_IMMINENT;
-
-const ptr_to_uuid_t ptr_to_uuid(void *p) { return (ptr_to_uuid_t)p; }
-
-
-//
-// connect to XPC service
-//
-xpc_connection_t XpcConnect(char *service, void *ctx) {
-    dispatch_queue_t queue = dispatch_queue_create(service, 0);
-    xpc_connection_t conn = xpc_connection_create_mach_service(service, queue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);
-
-    // making a local copy, that should be made "persistent" with the following Block_copy
-    GoInterface ictx = *((GoInterface*)ctx);
-
-    xpc_connection_set_event_handler(conn,
-        Block_copy(^(xpc_object_t event) {
-            handleXpcEvent(event, (void *)&ictx);
-        })
-    );
-
-    xpc_connection_resume(conn);
-    return conn;
-}
-
-void XpcSendMessage(xpc_connection_t conn, xpc_object_t message, bool release, bool reportDelivery) {
-    xpc_connection_send_message(conn,  message);
-    xpc_connection_send_barrier(conn, ^{
-        // Block is invoked on connection's target queue
-        // when 'message' has been sent.
-        if (reportDelivery) { // maybe this could be a callback
-            puts("message delivered");
-        }
-    });
-    if (release) {
-        xpc_release(message);
-    }
-}
-
-void XpcArrayApply(void *v, xpc_object_t arr) {
-  xpc_array_apply(arr, ^bool(size_t index, xpc_object_t value) {
-    arraySet(v, index, value);
-    return true;
-  });
-}
-
-void XpcDictApply(void *v, xpc_object_t dict) {
-  xpc_dictionary_apply(dict, ^bool(const char *key, xpc_object_t value) {
-    dictSet(v, (char *)key, value);
-    return true;
-  });
-}
-
-void XpcUUIDGetBytes(void *v, xpc_object_t uuid) {
-   const uint8_t *src = xpc_uuid_get_bytes(uuid);
-   uint8_t *dest = (uint8_t *)v;
-
-   for (int i=0; i < sizeof(uuid_t); i++) {
-     dest[i] = src[i];
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.h
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.h b/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.h
deleted file mode 100644
index e2cfb5c..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/xpc/xpc_wrapper_darwin.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _XPC_WRAPPER_H_
-#define _XPC_WRAPPER_H_
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <xpc/xpc.h>
-
-extern xpc_type_t TYPE_ERROR;
-
-extern xpc_type_t TYPE_ARRAY;
-extern xpc_type_t TYPE_DATA;
-extern xpc_type_t TYPE_DICT;
-extern xpc_type_t TYPE_INT64;
-extern xpc_type_t TYPE_STRING;
-extern xpc_type_t TYPE_UUID;
-
-extern xpc_object_t ERROR_CONNECTION_INVALID;
-extern xpc_object_t ERROR_CONNECTION_INTERRUPTED;
-extern xpc_object_t ERROR_CONNECTION_TERMINATED;
-
-extern xpc_connection_t XpcConnect(char *, void *);
-extern void XpcSendMessage(xpc_connection_t, xpc_object_t, bool, bool);
-extern void XpcArrayApply(void *, xpc_object_t);
-extern void XpcDictApply(void *, xpc_object_t);
-extern void XpcUUIDGetBytes(void *, xpc_object_t);
-
-// the input type for xpc_uuid_create should be uuid_t but CGO instists on unsigned char *
-// typedef uuid_t * ptr_to_uuid_t;
-typedef unsigned char * ptr_to_uuid_t;
-extern const ptr_to_uuid_t ptr_to_uuid(void *p);
-
-#endif


[3/7] incubator-mynewt-newt git commit: MYNEWT-653 Use runtimeco gatt fork.

Posted by cc...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/cmd/cmd.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/cmd/cmd.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/cmd/cmd.go
deleted file mode 100644
index 937f802..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/cmd/cmd.go
+++ /dev/null
@@ -1,995 +0,0 @@
-package cmd
-
-import (
-	"bytes"
-	"errors"
-	"fmt"
-	"io"
-	"log"
-
-	"github.com/runtimeinc/gatt/linux/evt"
-	"github.com/runtimeinc/gatt/linux/util"
-)
-
-type CmdParam interface {
-	Marshal([]byte)
-	Opcode() int
-	Len() int
-}
-
-func NewCmd(d io.Writer) *Cmd {
-	c := &Cmd{
-		dev:     d,
-		sent:    []*cmdPkt{},
-		compc:   make(chan evt.CommandCompleteEP),
-		statusc: make(chan evt.CommandStatusEP),
-	}
-	go c.processCmdEvents()
-	return c
-}
-
-type cmdPkt struct {
-	op   int
-	cp   CmdParam
-	done chan []byte
-}
-
-func (c cmdPkt) Marshal() []byte {
-	b := make([]byte, 1+2+1+c.cp.Len())
-	b[0] = byte(0x1) // typCommandPkt
-	b[1] = byte(c.op)
-	b[2] = byte(c.op >> 8)
-	b[3] = byte(c.cp.Len())
-	c.cp.Marshal(b[4:])
-	return b
-}
-
-type Cmd struct {
-	dev     io.Writer
-	sent    []*cmdPkt
-	compc   chan evt.CommandCompleteEP
-	statusc chan evt.CommandStatusEP
-}
-
-func (c Cmd) trace(fmt string, v ...interface{}) {}
-
-func (c *Cmd) HandleComplete(b []byte) error {
-	var e evt.CommandCompleteEP
-	if err := e.Unmarshal(b); err != nil {
-		return err
-	}
-	c.compc <- e
-	return nil
-}
-
-func (c *Cmd) HandleStatus(b []byte) error {
-	var e evt.CommandStatusEP
-	if err := e.Unmarshal(b); err != nil {
-		return err
-	}
-	c.statusc <- e
-	return nil
-}
-
-func (c *Cmd) Send(cp CmdParam) ([]byte, error) {
-	op := cp.Opcode()
-	p := &cmdPkt{op: op, cp: cp, done: make(chan []byte)}
-	raw := p.Marshal()
-
-	c.sent = append(c.sent, p)
-	if n, err := c.dev.Write(raw); err != nil {
-		return nil, err
-	} else if n != len(raw) {
-		return nil, errors.New("Failed to send whole Cmd pkt to HCI socket")
-	}
-	return <-p.done, nil
-}
-
-func (c *Cmd) SendAndCheckResp(cp CmdParam, exp []byte) error {
-	rsp, err := c.Send(cp)
-	if err != nil {
-		return err
-	}
-	// Don't care about the response
-	if len(exp) == 0 {
-		return nil
-	}
-	// Check the if status is one of the expected value
-	if !bytes.Contains(exp, rsp[0:1]) {
-		return fmt.Errorf("HCI command: '0x%04x' return 0x%02X, expect: [%X] ", cp.Opcode(), rsp[0], exp)
-	}
-	return nil
-}
-
-func (c *Cmd) processCmdEvents() {
-	for {
-		select {
-		case status := <-c.statusc:
-			found := false
-			for i, p := range c.sent {
-				if uint16(p.op) == status.CommandOpcode {
-					found = true
-					c.sent = append(c.sent[:i], c.sent[i+1:]...)
-					close(p.done)
-					break
-				}
-			}
-			if !found {
-				log.Printf("Can't find the cmdPkt for this CommandStatusEP: %v", status)
-			}
-		case comp := <-c.compc:
-			found := false
-			for i, p := range c.sent {
-				if uint16(p.op) == comp.CommandOPCode {
-					found = true
-					c.sent = append(c.sent[:i], c.sent[i+1:]...)
-					p.done <- comp.ReturnParameters
-					break
-				}
-			}
-			if !found {
-				log.Printf("Can't find the cmdPkt for this CommandCompleteEP: %v", comp)
-			}
-		}
-	}
-}
-
-const (
-	linkCtl     = 0x01
-	linkPolicy  = 0x02
-	hostCtl     = 0x03
-	infoParam   = 0x04
-	statusParam = 0x05
-	testingCmd  = 0X3E
-	leCtl       = 0x08
-	vendorCmd   = 0X3F
-)
-
-const (
-	opInquiry                = linkCtl<<10 | 0x0001 // Inquiry
-	opInquiryCancel          = linkCtl<<10 | 0x0002 // Inquiry Cancel
-	opPeriodicInquiry        = linkCtl<<10 | 0x0003 // Periodic Inquiry Mode
-	opExitPeriodicInquiry    = linkCtl<<10 | 0x0004 // Exit Periodic Inquiry Mode
-	opCreateConn             = linkCtl<<10 | 0x0005 // Create Connection
-	opDisconnect             = linkCtl<<10 | 0x0006 // Disconnect
-	opCreateConnCancel       = linkCtl<<10 | 0x0008 // Create Connection Cancel
-	opAcceptConnReq          = linkCtl<<10 | 0x0009 // Accept Connection Request
-	opRejectConnReq          = linkCtl<<10 | 0x000A // Reject Connection Request
-	opLinkKeyReply           = linkCtl<<10 | 0x000B // Link Key Request Reply
-	opLinkKeyNegReply        = linkCtl<<10 | 0x000C // Link Key Request Negative Reply
-	opPinCodeReply           = linkCtl<<10 | 0x000D // PIN Code Request Reply
-	opPinCodeNegReply        = linkCtl<<10 | 0x000E // PIN Code Request Negative Reply
-	opSetConnPtype           = linkCtl<<10 | 0x000F // Change Connection Packet Type
-	opAuthRequested          = linkCtl<<10 | 0x0011 // Authentication Request
-	opSetConnEncrypt         = linkCtl<<10 | 0x0013 // Set Connection Encryption
-	opChangeConnLinkKey      = linkCtl<<10 | 0x0015 // Change Connection Link Key
-	opMasterLinkKey          = linkCtl<<10 | 0x0017 // Master Link Key
-	opRemoteNameReq          = linkCtl<<10 | 0x0019 // Remote Name Request
-	opRemoteNameReqCancel    = linkCtl<<10 | 0x001A // Remote Name Request Cancel
-	opReadRemoteFeatures     = linkCtl<<10 | 0x001B // Read Remote Supported Features
-	opReadRemoteExtFeatures  = linkCtl<<10 | 0x001C // Read Remote Extended Features
-	opReadRemoteVersion      = linkCtl<<10 | 0x001D // Read Remote Version Information
-	opReadClockOffset        = linkCtl<<10 | 0x001F // Read Clock Offset
-	opReadLMPHandle          = linkCtl<<10 | 0x0020 // Read LMP Handle
-	opSetupSyncConn          = linkCtl<<10 | 0x0028 // Setup Synchronous Connection
-	opAcceptSyncConnReq      = linkCtl<<10 | 0x0029 // Aceept Synchronous Connection
-	opRejectSyncConnReq      = linkCtl<<10 | 0x002A // Recject Synchronous Connection
-	opIOCapabilityReply      = linkCtl<<10 | 0x002B // IO Capability Request Reply
-	opUserConfirmReply       = linkCtl<<10 | 0x002C // User Confirmation Request Reply
-	opUserConfirmNegReply    = linkCtl<<10 | 0x002D // User Confirmation Negative Reply
-	opUserPasskeyReply       = linkCtl<<10 | 0x002E // User Passkey Request Reply
-	opUserPasskeyNegReply    = linkCtl<<10 | 0x002F // User Passkey Request Negative Reply
-	opRemoteOOBDataReply     = linkCtl<<10 | 0x0030 // Remote OOB Data Request Reply
-	opRemoteOOBDataNegReply  = linkCtl<<10 | 0x0033 // Remote OOB Data Request Negative Reply
-	opIOCapabilityNegReply   = linkCtl<<10 | 0x0034 // IO Capability Request Negative Reply
-	opCreatePhysicalLink     = linkCtl<<10 | 0x0035 // Create Physical Link
-	opAcceptPhysicalLink     = linkCtl<<10 | 0x0036 // Accept Physical Link
-	opDisconnectPhysicalLink = linkCtl<<10 | 0x0037 // Disconnect Physical Link
-	opCreateLogicalLink      = linkCtl<<10 | 0x0038 // Create Logical Link
-	opAcceptLogicalLink      = linkCtl<<10 | 0x0039 // Accept Logical Link
-	opDisconnectLogicalLink  = linkCtl<<10 | 0x003A // Disconnect Logical Link
-	opLogicalLinkCancel      = linkCtl<<10 | 0x003B // Logical Link Cancel
-	opFlowSpecModify         = linkCtl<<10 | 0x003C // Flow Spec Modify
-)
-
-const (
-	opHoldMode               = linkPolicy<<10 | 0x0001 // Hold Mode
-	opSniffMode              = linkPolicy<<10 | 0x0003 // Sniff Mode
-	opExitSniffMode          = linkPolicy<<10 | 0x0004 // Exit Sniff Mode
-	opParkMode               = linkPolicy<<10 | 0x0005 // Park State
-	opExitParkMode           = linkPolicy<<10 | 0x0006 // Exit Park State
-	opQoSSetup               = linkPolicy<<10 | 0x0007 // QoS Setup
-	opRoleDiscovery          = linkPolicy<<10 | 0x0009 // Role Discovery
-	opSwitchRole             = linkPolicy<<10 | 0x000B // Switch Role
-	opReadLinkPolicy         = linkPolicy<<10 | 0x000C // Read Link Policy Settings
-	opWriteLinkPolicy        = linkPolicy<<10 | 0x000D // Write Link Policy Settings
-	opReadDefaultLinkPolicy  = linkPolicy<<10 | 0x000E // Read Default Link Policy Settings
-	opWriteDefaultLinkPolicy = linkPolicy<<10 | 0x000F // Write Default Link Policy Settings
-	opFlowSpecification      = linkPolicy<<10 | 0x0010 // Flow Specification
-	opSniffSubrating         = linkPolicy<<10 | 0x0011 // Sniff Subrating
-)
-
-const (
-	opSetEventMask                      = hostCtl<<10 | 0x0001 // Set Event Mask
-	opReset                             = hostCtl<<10 | 0x0003 // Reset
-	opSetEventFlt                       = hostCtl<<10 | 0x0005 // Set Event Filter
-	opFlush                             = hostCtl<<10 | 0x0008 // Flush
-	opReadPinType                       = hostCtl<<10 | 0x0009 // Read PIN Type
-	opWritePinType                      = hostCtl<<10 | 0x000A // Write PIN Type
-	opCreateNewUnitKey                  = hostCtl<<10 | 0x000B // Create New Unit Key
-	opReadStoredLinkKey                 = hostCtl<<10 | 0x000D // Read Stored Link Key
-	opWriteStoredLinkKey                = hostCtl<<10 | 0x0011 // Write Stored Link Key
-	opDeleteStoredLinkKey               = hostCtl<<10 | 0x0012 // Delete Stored Link Key
-	opWriteLocalName                    = hostCtl<<10 | 0x0013 // Write Local Name
-	opReadLocalName                     = hostCtl<<10 | 0x0014 // Read Local Name
-	opReadConnAcceptTimeout             = hostCtl<<10 | 0x0015 // Read Connection Accept Timeout
-	opWriteConnAcceptTimeout            = hostCtl<<10 | 0x0016 // Write Connection Accept Timeout
-	opReadPageTimeout                   = hostCtl<<10 | 0x0017 // Read Page Timeout
-	opWritePageTimeout                  = hostCtl<<10 | 0x0018 // Write Page Timeout
-	opReadScanEnable                    = hostCtl<<10 | 0x0019 // Read Scan Enable
-	opWriteScanEnable                   = hostCtl<<10 | 0x001A // Write Scan Enable
-	opReadPageActivity                  = hostCtl<<10 | 0x001B // Read Page Scan Activity
-	opWritePageActivity                 = hostCtl<<10 | 0x001C // Write Page Scan Activity
-	opReadInqActivity                   = hostCtl<<10 | 0x001D // Read Inquiry Scan Activity
-	opWriteInqActivity                  = hostCtl<<10 | 0x001E // Write Inquiry Scan Activity
-	opReadAuthEnable                    = hostCtl<<10 | 0x001F // Read Authentication Enable
-	opWriteAuthEnable                   = hostCtl<<10 | 0x0020 // Write Authentication Enable
-	opReadEncryptMode                   = hostCtl<<10 | 0x0021
-	opWriteEncryptMode                  = hostCtl<<10 | 0x0022
-	opReadClassOfDev                    = hostCtl<<10 | 0x0023 // Read Class of Device
-	opWriteClassOfDevice                = hostCtl<<10 | 0x0024 // Write Class of Device
-	opReadVoiceSetting                  = hostCtl<<10 | 0x0025 // Read Voice Setting
-	opWriteVoiceSetting                 = hostCtl<<10 | 0x0026 // Write Voice Setting
-	opReadAutomaticFlushTimeout         = hostCtl<<10 | 0x0027 // Read Automatic Flush Timeout
-	opWriteAutomaticFlushTimeout        = hostCtl<<10 | 0x0028 // Write Automatic Flush Timeout
-	opReadNumBroadcastRetrans           = hostCtl<<10 | 0x0029 // Read Num Broadcast Retransmissions
-	opWriteNumBroadcastRetrans          = hostCtl<<10 | 0x002A // Write Num Broadcast Retransmissions
-	opReadHoldModeActivity              = hostCtl<<10 | 0x002B // Read Hold Mode Activity
-	opWriteHoldModeActivity             = hostCtl<<10 | 0x002C // Write Hold Mode Activity
-	opReadTransmitPowerLevel            = hostCtl<<10 | 0x002D // Read Transmit Power Level
-	opReadSyncFlowEnable                = hostCtl<<10 | 0x002E // Read Synchronous Flow Control
-	opWriteSyncFlowEnable               = hostCtl<<10 | 0x002F // Write Synchronous Flow Control
-	opSetControllerToHostFC             = hostCtl<<10 | 0x0031 // Set Controller To Host Flow Control
-	opHostBufferSize                    = hostCtl<<10 | 0x0033 // Host Buffer Size
-	opHostNumCompPkts                   = hostCtl<<10 | 0x0035 // Host Number Of Completed Packets
-	opReadLinkSupervisionTimeout        = hostCtl<<10 | 0x0036 // Read Link Supervision Timeout
-	opWriteLinkSupervisionTimeout       = hostCtl<<10 | 0x0037 // Write Link Supervision Timeout
-	opReadNumSupportedIAC               = hostCtl<<10 | 0x0038 // Read Number Of Supported IAC
-	opReadCurrentIACLAP                 = hostCtl<<10 | 0x0039 // Read Current IAC LAP
-	opWriteCurrentIACLAP                = hostCtl<<10 | 0x003A // Write Current IAC LAP
-	opReadPageScanPeriodMode            = hostCtl<<10 | 0x003B
-	opWritePageScanPeriodMode           = hostCtl<<10 | 0x003C
-	opReadPageScanMode                  = hostCtl<<10 | 0x003D
-	opWritePageScanMode                 = hostCtl<<10 | 0x003E
-	opSetAFHClassification              = hostCtl<<10 | 0x003F // Set AFH Host Channel Classification
-	opReadInquiryScanType               = hostCtl<<10 | 0x0042 // Read Inquiry Scan Type
-	opWriteInquiryScanType              = hostCtl<<10 | 0x0043 // Write Inquiry Scan Type
-	opReadInquiryMode                   = hostCtl<<10 | 0x0044 // Read Inquiry Mode
-	opWriteInquiryMode                  = hostCtl<<10 | 0x0045 // Write Inquiry Mode
-	opReadPageScanType                  = hostCtl<<10 | 0x0046 // Read Page Scan Type
-	opWritePageScanType                 = hostCtl<<10 | 0x0047 // Write Page Scan Type
-	opReadAFHMode                       = hostCtl<<10 | 0x0048 // Read AFH Channel Assessment Mode
-	opWriteAFHMode                      = hostCtl<<10 | 0x0049 // Write AFH Channel Assesment Mode
-	opReadExtInquiryResponse            = hostCtl<<10 | 0x0051 // Read Extended Inquiry Response
-	opWriteExtInquiryResponse           = hostCtl<<10 | 0x0052 // Write Extended Inquiry Response
-	opRefreshEncryptionKey              = hostCtl<<10 | 0x0053 // Refresh Encryption Key
-	opReadSimplePairingMode             = hostCtl<<10 | 0x0055 // Read Simple Pairing Mode
-	opWriteSimplePairingMode            = hostCtl<<10 | 0x0056 // Write Simple Pairing Mode
-	opReadLocalOobData                  = hostCtl<<10 | 0x0057 // Read Local OOB Data
-	opReadInqResponseTransmitPowerLevel = hostCtl<<10 | 0x0058 // Read Inquiry Response Transmit Power Level
-	opWriteInquiryTransmitPowerLevel    = hostCtl<<10 | 0x0059 // Write Inquiry Response Transmit Power Level
-	opReadDefaultErrorDataReporting     = hostCtl<<10 | 0x005A // Read Default Erroneous Data Reporting
-	opWriteDefaultErrorDataReporting    = hostCtl<<10 | 0x005B // Write Default Erroneous Data Reporting
-	opEnhancedFlush                     = hostCtl<<10 | 0x005F // Enhanced Flush
-	opSendKeypressNotify                = hostCtl<<10 | 0x0060 // send Keypress Notification
-	opReadLogicalLinkAcceptTimeout      = hostCtl<<10 | 0x0061 // Read Logical Link Accept Timeout
-	opWriteLogicalLinkAcceptTimeout     = hostCtl<<10 | 0x0062 // Write Logical Link Accept Timeout
-	opSetEventMaskPage2                 = hostCtl<<10 | 0x0063 // Set Event Mask Page 2
-	opReadLocationData                  = hostCtl<<10 | 0x0064 // Read Location Data
-	opWriteLocationData                 = hostCtl<<10 | 0x0065 // Write Location Data
-	opReadFlowControlMode               = hostCtl<<10 | 0x0066 // Read Flow Control Mode
-	opWriteFlowControlMode              = hostCtl<<10 | 0x0067 // Write Flow Control Mode
-	opReadEnhancedTransmitpowerLevel    = hostCtl<<10 | 0x0068 // Read Enhanced Transmit Power Level
-	opReadBestEffortFlushTimeout        = hostCtl<<10 | 0x0069 // Read Best Effort Flush Timeout
-	opWriteBestEffortFlushTimeout       = hostCtl<<10 | 0x006A // Write Best Effort Flush Timeout
-	opReadLEHostSupported               = hostCtl<<10 | 0x006C // Read LE Host Supported
-	opWriteLEHostSupported              = hostCtl<<10 | 0x006D // Write LE Host Supported
-)
-const (
-	opReadLocalVersionInformation = infoParam<<10 | 0x0001 // Read Local Version Information
-	opReadLocalSupportedCommands  = infoParam<<10 | 0x0002 // Read Local Supported Commands
-	opReadLocalSupportedFeatures  = infoParam<<10 | 0x0003 // Read Local Supported Features
-	opReadLocalExtendedFeatures   = infoParam<<10 | 0x0004 // Read Local Extended Features
-	opReadBufferSize              = infoParam<<10 | 0x0005 // Read Buffer Size
-	opReadBDADDR                  = infoParam<<10 | 0x0009 // Read BD_ADDR
-	opReadDataBlockSize           = infoParam<<10 | 0x000A // Read Data Block Size
-	opReadLocalSupportedCodecs    = infoParam<<10 | 0x000B // Read Local Supported Codecs
-)
-const (
-	opLESetEventMask                      = leCtl<<10 | 0x0001 // LE Set Event Mask
-	opLEReadBufferSize                    = leCtl<<10 | 0x0002 // LE Read Buffer Size
-	opLEReadLocalSupportedFeatures        = leCtl<<10 | 0x0003 // LE Read Local Supported Features
-	opLESetRandomAddress                  = leCtl<<10 | 0x0005 // LE Set Random Address
-	opLESetAdvertisingParameters          = leCtl<<10 | 0x0006 // LE Set Advertising Parameters
-	opLEReadAdvertisingChannelTxPower     = leCtl<<10 | 0x0007 // LE Read Advertising Channel Tx Power
-	opLESetAdvertisingData                = leCtl<<10 | 0x0008 // LE Set Advertising Data
-	opLESetScanResponseData               = leCtl<<10 | 0x0009 // LE Set Scan Response Data
-	opLESetAdvertiseEnable                = leCtl<<10 | 0x000a // LE Set Advertising Enable
-	opLESetScanParameters                 = leCtl<<10 | 0x000b // LE Set Scan Parameters
-	opLESetScanEnable                     = leCtl<<10 | 0x000c // LE Set Scan Enable
-	opLECreateConn                        = leCtl<<10 | 0x000d // LE Create Connection
-	opLECreateConnCancel                  = leCtl<<10 | 0x000e // LE Create Connection Cancel
-	opLEReadWhiteListSize                 = leCtl<<10 | 0x000f // LE Read White List Size
-	opLEClearWhiteList                    = leCtl<<10 | 0x0010 // LE Clear White List
-	opLEAddDeviceToWhiteList              = leCtl<<10 | 0x0011 // LE Add Device To White List
-	opLERemoveDeviceFromWhiteList         = leCtl<<10 | 0x0012 // LE Remove Device From White List
-	opLEConnUpdate                        = leCtl<<10 | 0x0013 // LE Connection Update
-	opLESetHostChannelClassification      = leCtl<<10 | 0x0014 // LE Set Host Channel Classification
-	opLEReadChannelMap                    = leCtl<<10 | 0x0015 // LE Read Channel Map
-	opLEReadRemoteUsedFeatures            = leCtl<<10 | 0x0016 // LE Read Remote Used Features
-	opLEEncrypt                           = leCtl<<10 | 0x0017 // LE Encrypt
-	opLERand                              = leCtl<<10 | 0x0018 // LE Rand
-	opLEStartEncryption                   = leCtl<<10 | 0x0019 // LE Star Encryption
-	opLELTKReply                          = leCtl<<10 | 0x001a // LE Long Term Key Request Reply
-	opLELTKNegReply                       = leCtl<<10 | 0x001b // LE Long Term Key Request Negative Reply
-	opLEReadSupportedStates               = leCtl<<10 | 0x001c // LE Read Supported States
-	opLEReceiverTest                      = leCtl<<10 | 0x001d // LE Reciever Test
-	opLETransmitterTest                   = leCtl<<10 | 0x001e // LE Transmitter Test
-	opLETestEnd                           = leCtl<<10 | 0x001f // LE Test End
-	opLERemoteConnectionParameterReply    = leCtl<<10 | 0x0020 // LE Remote Connection Parameter Request Reply
-	opLERemoteConnectionParameterNegReply = leCtl<<10 | 0x0021 // LE Remote Connection Parameter Request Negative Reply
-)
-
-var o = util.Order
-
-// Link Control Commands
-
-// Disconnect (0x0006)
-type Disconnect struct {
-	ConnectionHandle uint16
-	Reason           uint8
-}
-
-func (c Disconnect) Opcode() int { return opDisconnect }
-func (c Disconnect) Len() int    { return 3 }
-func (c Disconnect) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.ConnectionHandle)
-	b[2] = c.Reason
-}
-
-// No Return Parameters, Check for Disconnection Complete Event
-type DisconnectRP struct{}
-
-// Link Policy Commands
-
-// Write Default Link Policy
-type WriteDefaultLinkPolicy struct{ DefaultLinkPolicySettings uint16 }
-
-func (c WriteDefaultLinkPolicy) Opcode() int      { return opWriteDefaultLinkPolicy }
-func (c WriteDefaultLinkPolicy) Len() int         { return 2 }
-func (c WriteDefaultLinkPolicy) Marshal(b []byte) { o.PutUint16(b, c.DefaultLinkPolicySettings) }
-
-type WriteDefaultLinkPolicyRP struct{ Status uint8 }
-
-// Host Control Commands
-
-// Set Event Mask (0x0001)
-type SetEventMask struct{ EventMask uint64 }
-
-func (c SetEventMask) Opcode() int      { return opSetEventMask }
-func (c SetEventMask) Len() int         { return 8 }
-func (c SetEventMask) Marshal(b []byte) { o.PutUint64(b, c.EventMask) }
-
-type SetEventMaskRP struct{ Status uint8 }
-
-// Reset (0x0002)
-type Reset struct{}
-
-func (c Reset) Opcode() int      { return opReset }
-func (c Reset) Len() int         { return 0 }
-func (c Reset) Marshal(b []byte) {}
-
-type ResetRP struct{ Status uint8 }
-
-// Set Event Filter (0x0003)
-// FIXME: This structures are overloading.
-// Both Marshal() and Len() are just placeholder.
-// Need more effort for decoding.
-// type SetEventFlt struct {
-// 	FilterType          uint8
-// 	FilterConditionType uint8
-// 	Condition           uint8
-// }
-
-// func (c SetEventFlt) Opcode() int   { return opSetEventFlt }
-// func (c SetEventFlt) Len() int         { return 0 }
-// func (c SetEventFlt) Marshal(b []byte) {}
-
-type SetEventFltRP struct{ Status uint8 }
-
-// Flush (0x0008)
-type Flush struct{ ConnectionHandle uint16 }
-
-func (c Flush) Opcode() int      { return opFlush }
-func (c Flush) Len() int         { return 2 }
-func (c Flush) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
-
-type flushRP struct{ status uint8 }
-
-// Write Page Timeout (0x0018)
-type WritePageTimeout struct{ PageTimeout uint16 }
-
-func (c WritePageTimeout) Opcode() int      { return opWritePageTimeout }
-func (c WritePageTimeout) Len() int         { return 2 }
-func (c WritePageTimeout) Marshal(b []byte) { o.PutUint16(b, c.PageTimeout) }
-
-type WritePageTimeoutRP struct{}
-
-// Write Class of Device (0x0024)
-type WriteClassOfDevice struct{ ClassOfDevice [3]byte }
-
-func (c WriteClassOfDevice) Opcode() int      { return opWriteClassOfDevice }
-func (c WriteClassOfDevice) Len() int         { return 3 }
-func (c WriteClassOfDevice) Marshal(b []byte) { copy(b, c.ClassOfDevice[:]) }
-
-type WriteClassOfDevRP struct{ status uint8 }
-
-// Write Host Buffer Size (0x0033)
-type HostBufferSize struct {
-	HostACLDataPacketLength            uint16
-	HostSynchronousDataPacketLength    uint8
-	HostTotalNumACLDataPackets         uint16
-	HostTotalNumSynchronousDataPackets uint16
-}
-
-func (c HostBufferSize) Opcode() int { return opHostBufferSize }
-func (c HostBufferSize) Len() int    { return 7 }
-func (c HostBufferSize) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.HostACLDataPacketLength)
-	o.PutUint8(b[2:], c.HostSynchronousDataPacketLength)
-	o.PutUint16(b[3:], c.HostTotalNumACLDataPackets)
-	o.PutUint16(b[5:], c.HostTotalNumSynchronousDataPackets)
-}
-
-type HostBufferSizeRP struct{ Status uint8 }
-
-// Write Inquiry Scan Type (0x0043)
-type WriteInquiryScanType struct{ ScanType uint8 }
-
-func (c WriteInquiryScanType) Opcode() int      { return opWriteInquiryScanType }
-func (c WriteInquiryScanType) Len() int         { return 1 }
-func (c WriteInquiryScanType) Marshal(b []byte) { b[0] = c.ScanType }
-
-type WriteInquiryScanTypeRP struct{ Status uint8 }
-
-// Write Inquiry Mode (0x0045)
-type WriteInquiryMode struct {
-	InquiryMode uint8
-}
-
-func (c WriteInquiryMode) Opcode() int      { return opWriteInquiryMode }
-func (c WriteInquiryMode) Len() int         { return 1 }
-func (c WriteInquiryMode) Marshal(b []byte) { b[0] = c.InquiryMode }
-
-type WriteInquiryModeRP struct{ Status uint8 }
-
-// Write Page Scan Type (0x0046)
-type WritePageScanType struct{ PageScanType uint8 }
-
-func (c WritePageScanType) Opcode() int      { return opWritePageScanType }
-func (c WritePageScanType) Len() int         { return 1 }
-func (c WritePageScanType) Marshal(b []byte) { b[0] = c.PageScanType }
-
-type WritePageScanTypeRP struct{ Status uint8 }
-
-// Write Simple Pairing Mode (0x0056)
-type WriteSimplePairingMode struct{ SimplePairingMode uint8 }
-
-func (c WriteSimplePairingMode) Opcode() int      { return opWriteSimplePairingMode }
-func (c WriteSimplePairingMode) Len() int         { return 1 }
-func (c WriteSimplePairingMode) Marshal(b []byte) { b[0] = c.SimplePairingMode }
-
-type WriteSimplePairingModeRP struct{}
-
-// Set Event Mask Page 2 (0x0063)
-type SetEventMaskPage2 struct{ EventMaskPage2 uint64 }
-
-func (c SetEventMaskPage2) Opcode() int      { return opSetEventMaskPage2 }
-func (c SetEventMaskPage2) Len() int         { return 8 }
-func (c SetEventMaskPage2) Marshal(b []byte) { o.PutUint64(b, c.EventMaskPage2) }
-
-type SetEventMaskPage2RP struct{ Status uint8 }
-
-// Write LE Host Supported (0x006D)
-type WriteLEHostSupported struct {
-	LESupportedHost    uint8
-	SimultaneousLEHost uint8
-}
-
-func (c WriteLEHostSupported) Opcode() int      { return opWriteLEHostSupported }
-func (c WriteLEHostSupported) Len() int         { return 2 }
-func (c WriteLEHostSupported) Marshal(b []byte) { b[0], b[1] = c.LESupportedHost, c.SimultaneousLEHost }
-
-type WriteLeHostSupportedRP struct{ Status uint8 }
-
-// LE Controller Commands
-
-// LE Set Event Mask (0x0001)
-type LESetEventMask struct{ LEEventMask uint64 }
-
-func (c LESetEventMask) Opcode() int      { return opLESetEventMask }
-func (c LESetEventMask) Len() int         { return 8 }
-func (c LESetEventMask) Marshal(b []byte) { o.PutUint64(b, c.LEEventMask) }
-
-type LESetEventMaskRP struct{ Status uint8 }
-
-// LE Read Buffer Size (0x0002)
-type LEReadBufferSize struct{}
-
-func (c LEReadBufferSize) Opcode() int      { return opLEReadBufferSize }
-func (c LEReadBufferSize) Len() int         { return 1 }
-func (c LEReadBufferSize) Marshal(b []byte) {}
-
-type LEReadBufferSizeRP struct {
-	Status                     uint8
-	HCLEACLDataPacketLength    uint16
-	HCTotalNumLEACLDataPackets uint8
-}
-
-// LE Read Local Supported Features (0x0003)
-type LEReadLocalSupportedFeatures struct{}
-
-func (c LEReadLocalSupportedFeatures) Opcode() int      { return opLEReadLocalSupportedFeatures }
-func (c LEReadLocalSupportedFeatures) Len() int         { return 0 }
-func (c LEReadLocalSupportedFeatures) Marshal(b []byte) {}
-
-type LEReadLocalSupportedFeaturesRP struct {
-	Status     uint8
-	LEFeatures uint64
-}
-
-// LE Set Random Address (0x0005)
-type LESetRandomAddress struct{ RandomAddress [6]byte }
-
-func (c LESetRandomAddress) Opcode() int      { return opLESetRandomAddress }
-func (c LESetRandomAddress) Len() int         { return 6 }
-func (c LESetRandomAddress) Marshal(b []byte) { o.PutMAC(b, c.RandomAddress) }
-
-type LESetRandomAddressRP struct{ Status uint8 }
-
-// LE Set Advertising Parameters (0x0006)
-type LESetAdvertisingParameters struct {
-	AdvertisingIntervalMin  uint16
-	AdvertisingIntervalMax  uint16
-	AdvertisingType         uint8
-	OwnAddressType          uint8
-	DirectAddressType       uint8
-	DirectAddress           [6]byte
-	AdvertisingChannelMap   uint8
-	AdvertisingFilterPolicy uint8
-}
-
-func (c LESetAdvertisingParameters) Opcode() int { return opLESetAdvertisingParameters }
-func (c LESetAdvertisingParameters) Len() int    { return 15 }
-func (c LESetAdvertisingParameters) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.AdvertisingIntervalMin)
-	o.PutUint16(b[2:], c.AdvertisingIntervalMax)
-	o.PutUint8(b[4:], c.AdvertisingType)
-	o.PutUint8(b[5:], c.OwnAddressType)
-	o.PutUint8(b[6:], c.DirectAddressType)
-	o.PutMAC(b[7:], c.DirectAddress)
-	o.PutUint8(b[13:], c.AdvertisingChannelMap)
-	o.PutUint8(b[14:], c.AdvertisingFilterPolicy)
-}
-
-type LESetAdvertisingParametersRP struct{ Status uint8 }
-
-// LE Read Advertising Channel Tx Power (0x0007)
-type LEReadAdvertisingChannelTxPower struct{}
-
-func (c LEReadAdvertisingChannelTxPower) Opcode() int      { return opLEReadAdvertisingChannelTxPower }
-func (c LEReadAdvertisingChannelTxPower) Len() int         { return 0 }
-func (c LEReadAdvertisingChannelTxPower) Marshal(b []byte) {}
-
-type LEReadAdvertisingChannelTxPowerRP struct {
-	Status             uint8
-	TransmitPowerLevel uint8
-}
-
-// LE Set Advertising Data (0x0008)
-type LESetAdvertisingData struct {
-	AdvertisingDataLength uint8
-	AdvertisingData       [31]byte
-}
-
-func (c LESetAdvertisingData) Opcode() int { return opLESetAdvertisingData }
-func (c LESetAdvertisingData) Len() int    { return 32 }
-func (c LESetAdvertisingData) Marshal(b []byte) {
-	b[0] = c.AdvertisingDataLength
-	copy(b[1:], c.AdvertisingData[:c.AdvertisingDataLength])
-}
-
-type LESetAdvertisingDataRP struct{ Status uint8 }
-
-// LE Set Scan Response Data (0x0009)
-type LESetScanResponseData struct {
-	ScanResponseDataLength uint8
-	ScanResponseData       [31]byte
-}
-
-func (c LESetScanResponseData) Opcode() int { return opLESetScanResponseData }
-func (c LESetScanResponseData) Len() int    { return 32 }
-func (c LESetScanResponseData) Marshal(b []byte) {
-	b[0] = c.ScanResponseDataLength
-	copy(b[1:], c.ScanResponseData[:c.ScanResponseDataLength])
-}
-
-type LESetScanResponseDataRP struct{ Status uint8 }
-
-// LE Set Advertising Enable (0x000A)
-type LESetAdvertiseEnable struct{ AdvertisingEnable uint8 }
-
-func (c LESetAdvertiseEnable) Opcode() int      { return opLESetAdvertiseEnable }
-func (c LESetAdvertiseEnable) Len() int         { return 1 }
-func (c LESetAdvertiseEnable) Marshal(b []byte) { b[0] = c.AdvertisingEnable }
-
-type LESetAdvertiseEnableRP struct{ Status uint8 }
-
-// LE Set Scan Parameters (0x000B)
-type LESetScanParameters struct {
-	LEScanType           uint8
-	LEScanInterval       uint16
-	LEScanWindow         uint16
-	OwnAddressType       uint8
-	ScanningFilterPolicy uint8
-}
-
-func (c LESetScanParameters) Opcode() int { return opLESetScanParameters }
-func (c LESetScanParameters) Len() int    { return 7 }
-func (c LESetScanParameters) Marshal(b []byte) {
-	o.PutUint8(b[0:], c.LEScanType)
-	o.PutUint16(b[1:], c.LEScanInterval)
-	o.PutUint16(b[3:], c.LEScanWindow)
-	o.PutUint8(b[5:], c.OwnAddressType)
-	o.PutUint8(b[6:], c.ScanningFilterPolicy)
-}
-
-type LESetScanParametersRP struct{ Status uint8 }
-
-// LE Set Scan Enable (0x000C)
-type LESetScanEnable struct {
-	LEScanEnable     uint8
-	FilterDuplicates uint8
-}
-
-func (c LESetScanEnable) Opcode() int      { return opLESetScanEnable }
-func (c LESetScanEnable) Len() int         { return 2 }
-func (c LESetScanEnable) Marshal(b []byte) { b[0], b[1] = c.LEScanEnable, c.FilterDuplicates }
-
-type LESetScanEnableRP struct{ Status uint8 }
-
-// LE Create Connection (0x000D)
-type LECreateConn struct {
-	LEScanInterval        uint16
-	LEScanWindow          uint16
-	InitiatorFilterPolicy uint8
-	PeerAddressType       uint8
-	PeerAddress           [6]byte
-	OwnAddressType        uint8
-	ConnIntervalMin       uint16
-	ConnIntervalMax       uint16
-	ConnLatency           uint16
-	SupervisionTimeout    uint16
-	MinimumCELength       uint16
-	MaximumCELength       uint16
-}
-
-func (c LECreateConn) Opcode() int { return opLECreateConn }
-func (c LECreateConn) Len() int    { return 25 }
-func (c LECreateConn) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.LEScanInterval)
-	o.PutUint16(b[2:], c.LEScanWindow)
-	o.PutUint8(b[4:], c.InitiatorFilterPolicy)
-	o.PutUint8(b[5:], c.PeerAddressType)
-	o.PutMAC(b[6:], c.PeerAddress)
-	o.PutUint8(b[12:], c.OwnAddressType)
-	o.PutUint16(b[13:], c.ConnIntervalMin)
-	o.PutUint16(b[15:], c.ConnIntervalMax)
-	o.PutUint16(b[17:], c.ConnLatency)
-	o.PutUint16(b[19:], c.SupervisionTimeout)
-	o.PutUint16(b[21:], c.MinimumCELength)
-	o.PutUint16(b[23:], c.MaximumCELength)
-}
-
-type LECreateConnRP struct{}
-
-// LE Create Connection Cancel (0x000E)
-type LECreateConnCancel struct{}
-
-func (c LECreateConnCancel) Opcode() int      { return opLECreateConnCancel }
-func (c LECreateConnCancel) Len() int         { return 0 }
-func (c LECreateConnCancel) Marshal(b []byte) {}
-
-type LECreateConnCancelRP struct{ Status uint8 }
-
-// LE Read White List Size (0x000F)
-type LEReadWhiteListSize struct{}
-
-func (c LEReadWhiteListSize) Opcode() int      { return opLEReadWhiteListSize }
-func (c LEReadWhiteListSize) Len() int         { return 0 }
-func (c LEReadWhiteListSize) Marshal(b []byte) {}
-
-type LEReadWhiteListSizeRP struct {
-	Status        uint8
-	WhiteListSize uint8
-}
-
-// LE Clear White List (0x0010)
-type LEClearWhiteList struct{}
-
-func (c LEClearWhiteList) Opcode() int      { return opLEClearWhiteList }
-func (c LEClearWhiteList) Len() int         { return 0 }
-func (c LEClearWhiteList) Marshal(b []byte) {}
-
-type LEClearWhiteListRP struct{ Status uint8 }
-
-// LE Add Device To White List (0x0011)
-type LEAddDeviceToWhiteList struct {
-	AddressType uint8
-	Address     [6]byte
-}
-
-func (c LEAddDeviceToWhiteList) Opcode() int { return opLEAddDeviceToWhiteList }
-func (c LEAddDeviceToWhiteList) Len() int    { return 7 }
-func (c LEAddDeviceToWhiteList) Marshal(b []byte) {
-	b[0] = c.AddressType
-	o.PutMAC(b[1:], c.Address)
-}
-
-type LEAddDeviceToWhiteListRP struct{ Status uint8 }
-
-// LE Remove Device From White List (0x0012)
-type LERemoveDeviceFromWhiteList struct {
-	AddressType uint8
-	Address     [6]byte
-}
-
-func (c LERemoveDeviceFromWhiteList) Opcode() int { return opLERemoveDeviceFromWhiteList }
-func (c LERemoveDeviceFromWhiteList) Len() int    { return 7 }
-func (c LERemoveDeviceFromWhiteList) Marshal(b []byte) {
-	b[0] = c.AddressType
-	o.PutMAC(b[1:], c.Address)
-}
-
-type LERemoveDeviceFromWhiteListRP struct{ Status uint8 }
-
-// LE Connection Update (0x0013)
-type LEConnUpdate struct {
-	ConnectionHandle   uint16
-	ConnIntervalMin    uint16
-	ConnIntervalMax    uint16
-	ConnLatency        uint16
-	SupervisionTimeout uint16
-	MinimumCELength    uint16
-	MaximumCELength    uint16
-}
-
-func (c LEConnUpdate) Opcode() int { return opLEConnUpdate }
-func (c LEConnUpdate) Len() int    { return 14 }
-func (c LEConnUpdate) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.ConnectionHandle)
-	o.PutUint16(b[2:], c.ConnIntervalMin)
-	o.PutUint16(b[4:], c.ConnIntervalMax)
-	o.PutUint16(b[6:], c.ConnLatency)
-	o.PutUint16(b[8:], c.SupervisionTimeout)
-	o.PutUint16(b[10:], c.MinimumCELength)
-	o.PutUint16(b[12:], c.MaximumCELength)
-}
-
-type LEConnUpdateRP struct{}
-
-// LE Set Host Channel Classification (0x0014)
-type LESetHostChannelClassification struct{ ChannelMap [5]byte }
-
-func (c LESetHostChannelClassification) Opcode() int      { return opLESetHostChannelClassification }
-func (c LESetHostChannelClassification) Len() int         { return 5 }
-func (c LESetHostChannelClassification) Marshal(b []byte) { copy(b, c.ChannelMap[:]) }
-
-type LESetHostChannelClassificationRP struct{ Status uint8 }
-
-// LE Read Channel Map (0x0015)
-type LEReadChannelMap struct{ ConnectionHandle uint16 }
-
-func (c LEReadChannelMap) Opcode() int      { return opLEReadChannelMap }
-func (c LEReadChannelMap) Len() int         { return 2 }
-func (c LEReadChannelMap) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
-
-type LEReadChannelMapRP struct {
-	Status           uint8
-	ConnectionHandle uint16
-	ChannelMap       [5]byte
-}
-
-// LE Read Remote Used Features (0x0016)
-type LEReadRemoteUsedFeatures struct{ ConnectionHandle uint16 }
-
-func (c LEReadRemoteUsedFeatures) Opcode() int      { return opLEReadRemoteUsedFeatures }
-func (c LEReadRemoteUsedFeatures) Len() int         { return 8 }
-func (c LEReadRemoteUsedFeatures) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
-
-type LEReadRemoteUsedFeaturesRP struct{}
-
-// LE Encrypt (0x0017)
-type LEEncrypt struct {
-	Key           [16]byte
-	PlaintextData [16]byte
-}
-
-func (c LEEncrypt) Opcode() int { return opLEEncrypt }
-func (c LEEncrypt) Len() int    { return 32 }
-func (c LEEncrypt) Marshal(b []byte) {
-	copy(b[0:], c.Key[:])
-	copy(b[16:], c.PlaintextData[:])
-}
-
-type LEEncryptRP struct {
-	Stauts        uint8
-	EncryptedData [16]byte
-}
-
-// LE Rand (0x0018)
-type LERand struct{}
-
-func (c LERand) Opcode() int      { return opLERand }
-func (c LERand) Len() int         { return 0 }
-func (c LERand) Marshal(b []byte) {}
-
-type LERandRP struct {
-	Status       uint8
-	RandomNumber uint64
-}
-
-// LE Start Encryption (0x0019)
-type LEStartEncryption struct {
-	ConnectionHandle     uint16
-	RandomNumber         uint64
-	EncryptedDiversifier uint16
-	LongTermKey          [16]byte
-}
-
-func (c LEStartEncryption) Opcode() int { return opLEStartEncryption }
-func (c LEStartEncryption) Len() int    { return 28 }
-func (c LEStartEncryption) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.ConnectionHandle)
-	o.PutUint64(b[2:], c.RandomNumber)
-	o.PutUint16(b[10:], c.EncryptedDiversifier)
-	copy(b[12:], c.LongTermKey[:])
-}
-
-type LEStartEncryptionRP struct{}
-
-// LE Long Term Key Reply (0x001A)
-type LELTKReply struct {
-	ConnectionHandle uint16
-	LongTermKey      [16]byte
-}
-
-func (c LELTKReply) Opcode() int { return opLELTKReply }
-func (c LELTKReply) Len() int    { return 18 }
-func (c LELTKReply) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.ConnectionHandle)
-	copy(b[2:], c.LongTermKey[:])
-}
-
-type LELTKReplyRP struct {
-	Status           uint8
-	ConnectionHandle uint16
-}
-
-// LE Long Term Key  Negative Reply (0x001B)
-type LELTKNegReply struct{ ConnectionHandle uint16 }
-
-func (c LELTKNegReply) Opcode() int      { return opLELTKNegReply }
-func (c LELTKNegReply) Len() int         { return 2 }
-func (c LELTKNegReply) Marshal(b []byte) { o.PutUint16(b, c.ConnectionHandle) }
-
-type LELTKNegReplyRP struct {
-	Status           uint8
-	ConnectionHandle uint16
-}
-
-// LE Read Supported States (0x001C)
-type LEReadSupportedStates struct{}
-
-func (c LEReadSupportedStates) Opcode() int      { return opLEReadSupportedStates }
-func (c LEReadSupportedStates) Len() int         { return 0 }
-func (c LEReadSupportedStates) Marshal(b []byte) {}
-
-type LEReadSupportedStatesRP struct {
-	Status   uint8
-	LEStates [8]byte
-}
-
-// LE Reciever Test (0x001D)
-type LEReceiverTest struct{ RxChannel uint8 }
-
-func (c LEReceiverTest) Opcode() int      { return opLEReceiverTest }
-func (c LEReceiverTest) Len() int         { return 1 }
-func (c LEReceiverTest) Marshal(b []byte) { b[0] = c.RxChannel }
-
-type LEReceiverTestRP struct{ Status uint8 }
-
-// LE Transmitter Test (0x001E)
-type LETransmitterTest struct {
-	TxChannel        uint8
-	LengthOfTestData uint8
-	PacketPayload    uint8
-}
-
-func (c LETransmitterTest) Opcode() int { return opLETransmitterTest }
-func (c LETransmitterTest) Len() int    { return 3 }
-func (c LETransmitterTest) Marshal(b []byte) {
-	b[0], b[1], b[2] = c.TxChannel, c.LengthOfTestData, c.PacketPayload
-}
-
-type LETransmitterTestRP struct{ Status uint8 }
-
-// LE Test End (0x001F)
-type LETestEnd struct{}
-
-func (c LETestEnd) Opcode() int      { return opLETestEnd }
-func (c LETestEnd) Len() int         { return 0 }
-func (c LETestEnd) Marshal(b []byte) {}
-
-type LETestEndRP struct {
-	Status          uint8
-	NumberOfPackets uint16
-}
-
-// LE Remote Connection Parameters Reply (0x0020)
-type LERemoteConnectionParameterReply struct {
-	ConnectionHandle uint16
-	IntervalMin      uint16
-	IntervalMax      uint16
-	Latency          uint16
-	Timeout          uint16
-	MinimumCELength  uint16
-	MaximumCELength  uint16
-}
-
-func (c LERemoteConnectionParameterReply) Opcode() int { return opLERemoteConnectionParameterReply }
-func (c LERemoteConnectionParameterReply) Len() int    { return 14 }
-func (c LERemoteConnectionParameterReply) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.ConnectionHandle)
-	o.PutUint16(b[2:], c.IntervalMin)
-	o.PutUint16(b[4:], c.IntervalMax)
-	o.PutUint16(b[6:], c.Latency)
-	o.PutUint16(b[8:], c.Timeout)
-	o.PutUint16(b[10:], c.MinimumCELength)
-	o.PutUint16(b[12:], c.MaximumCELength)
-}
-
-type LERemoteConnectionParameterReplyRP struct {
-	Status           uint8
-	ConnectionHandle uint16
-}
-
-// LE Remote Connection Parameters Negative Reply (0x0021)
-type LERemoteConnectionParameterNegReply struct {
-	ConnectionHandle uint16
-	Reason           uint8
-}
-
-func (c LERemoteConnectionParameterNegReply) Opcode() int {
-	return opLERemoteConnectionParameterNegReply
-}
-func (c LERemoteConnectionParameterNegReply) Len() int { return 3 }
-func (c LERemoteConnectionParameterNegReply) Marshal(b []byte) {
-	o.PutUint16(b[0:], c.ConnectionHandle)
-	b[2] = c.Reason
-}
-
-type LERemoteConnectionParameterNegReplyRP struct {
-	Status           uint8
-	ConnectionHandle uint16
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/const.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/const.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/const.go
deleted file mode 100644
index 8c0a140..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/const.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package linux
-
-type packetType uint8
-
-// HCI Packet types
-const (
-	typCommandPkt packetType = 0X01
-	typACLDataPkt            = 0X02
-	typSCODataPkt            = 0X03
-	typEventPkt              = 0X04
-	typVendorPkt             = 0XFF
-)
-
-// Event Type
-const (
-	advInd        = 0x00 // Connectable undirected advertising (ADV_IND).
-	advDirectInd  = 0x01 // Connectable directed advertising (ADV_DIRECT_IND)
-	advScanInd    = 0x02 // Scannable undirected advertising (ADV_SCAN_IND)
-	advNonconnInd = 0x03 // Non connectable undirected advertising (ADV_NONCONN_IND)
-	scanRsp       = 0x04 // Scan Response (SCAN_RSP)
-)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/device.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/device.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/device.go
deleted file mode 100644
index ef55268..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/device.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package linux
-
-import (
-	"errors"
-	"log"
-	"sync"
-	"syscall"
-	"unsafe"
-
-	"github.com/runtimeinc/gatt/linux/gioctl"
-	"github.com/runtimeinc/gatt/linux/socket"
-)
-
-type device struct {
-	fd   int
-	dev  int
-	name string
-	rmu  *sync.Mutex
-	wmu  *sync.Mutex
-}
-
-func newDevice(n int, chk bool) (*device, error) {
-	fd, err := socket.Socket(socket.AF_BLUETOOTH, syscall.SOCK_RAW, socket.BTPROTO_HCI)
-	if err != nil {
-		return nil, err
-	}
-	if n != -1 {
-		return newSocket(fd, n, chk)
-	}
-
-	req := devListRequest{devNum: hciMaxDevices}
-	if err := gioctl.Ioctl(uintptr(fd), hciGetDeviceList, uintptr(unsafe.Pointer(&req))); err != nil {
-		return nil, err
-	}
-	for i := 0; i < int(req.devNum); i++ {
-		d, err := newSocket(fd, i, chk)
-		if err == nil {
-			log.Printf("dev: %s opened", d.name)
-			return d, err
-		}
-	}
-	return nil, errors.New("no supported devices available")
-}
-
-func newSocket(fd, n int, chk bool) (*device, error) {
-	i := hciDevInfo{id: uint16(n)}
-	if err := gioctl.Ioctl(uintptr(fd), hciGetDeviceInfo, uintptr(unsafe.Pointer(&i))); err != nil {
-		return nil, err
-	}
-	name := string(i.name[:])
-	// Check the feature list returned feature list.
-	if chk && i.features[4]&0x40 == 0 {
-		err := errors.New("does not support LE")
-		log.Printf("dev: %s %s", name, err)
-		return nil, err
-	}
-	log.Printf("dev: %s up", name)
-	if err := gioctl.Ioctl(uintptr(fd), hciUpDevice, uintptr(n)); err != nil {
-		if err != syscall.EALREADY {
-			return nil, err
-		}
-		log.Printf("dev: %s reset", name)
-		if err := gioctl.Ioctl(uintptr(fd), hciResetDevice, uintptr(n)); err != nil {
-			return nil, err
-		}
-	}
-	log.Printf("dev: %s down", name)
-	if err := gioctl.Ioctl(uintptr(fd), hciDownDevice, uintptr(n)); err != nil {
-		return nil, err
-	}
-
-	// Attempt to use the linux 3.14 feature, if this fails with EINVAL fall back to raw access
-	// on older kernels.
-	sa := socket.SockaddrHCI{Dev: n, Channel: socket.HCI_CHANNEL_USER}
-	if err := socket.Bind(fd, &sa); err != nil {
-		if err != syscall.EINVAL {
-			return nil, err
-		}
-		log.Printf("dev: %s can't bind to hci user channel, err: %s.", name, err)
-		sa := socket.SockaddrHCI{Dev: n, Channel: socket.HCI_CHANNEL_RAW}
-		if err := socket.Bind(fd, &sa); err != nil {
-			log.Printf("dev: %s can't bind to hci raw channel, err: %s.", name, err)
-			return nil, err
-		}
-	}
-	return &device{
-		fd:   fd,
-		dev:  n,
-		name: name,
-		rmu:  &sync.Mutex{},
-		wmu:  &sync.Mutex{},
-	}, nil
-}
-
-func (d device) Read(b []byte) (int, error) {
-	d.rmu.Lock()
-	defer d.rmu.Unlock()
-	return syscall.Read(d.fd, b)
-}
-
-func (d device) Write(b []byte) (int, error) {
-	d.wmu.Lock()
-	defer d.wmu.Unlock()
-	return syscall.Write(d.fd, b)
-}
-
-func (d device) Close() error {
-	return syscall.Close(d.fd)
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/devices.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/devices.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/devices.go
deleted file mode 100644
index 7c5336f..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/devices.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package linux
-
-import "github.com/runtimeinc/gatt/linux/gioctl"
-
-const (
-	ioctlSize     = uintptr(4)
-	hciMaxDevices = 16
-	typHCI        = 72 // 'H'
-)
-
-var (
-	hciUpDevice      = gioctl.IoW(typHCI, 201, ioctlSize) // HCIDEVUP
-	hciDownDevice    = gioctl.IoW(typHCI, 202, ioctlSize) // HCIDEVDOWN
-	hciResetDevice   = gioctl.IoW(typHCI, 203, ioctlSize) // HCIDEVRESET
-	hciGetDeviceList = gioctl.IoR(typHCI, 210, ioctlSize) // HCIGETDEVLIST
-	hciGetDeviceInfo = gioctl.IoR(typHCI, 211, ioctlSize) // HCIGETDEVINFO
-)
-
-type devRequest struct {
-	id  uint16
-	opt uint32
-}
-
-type devListRequest struct {
-	devNum     uint16
-	devRequest [hciMaxDevices]devRequest
-}
-
-type hciDevInfo struct {
-	id         uint16
-	name       [8]byte
-	bdaddr     [6]byte
-	flags      uint32
-	devType    uint8
-	features   [8]uint8
-	pktType    uint32
-	linkPolicy uint32
-	linkMode   uint32
-	aclMtu     uint16
-	aclPkts    uint16
-	scoMtu     uint16
-	scoPkts    uint16
-
-	stats hciDevStats
-}
-
-type hciDevStats struct {
-	errRx  uint32
-	errTx  uint32
-	cmdTx  uint32
-	evtRx  uint32
-	aclTx  uint32
-	aclRx  uint32
-	scoTx  uint32
-	scoRx  uint32
-	byteRx uint32
-	byteTx uint32
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/doc.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/doc.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/doc.go
deleted file mode 100644
index c41c53e..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/doc.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Package linux provides linux-specific support for gatt.
-//
-// This package is work in progress. We expect the APIs to change significantly before stabilizing.
-
-package linux

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/evt/evt.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/evt/evt.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/evt/evt.go
deleted file mode 100644
index 2461a30..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/evt/evt.go
+++ /dev/null
@@ -1,382 +0,0 @@
-package evt
-
-import (
-	"bytes"
-	"encoding/binary"
-	"errors"
-
-	"github.com/runtimeinc/gatt/linux/util"
-)
-
-type EventHandler interface {
-	HandleEvent([]byte) error
-}
-
-type HandlerFunc func(b []byte) error
-
-func (f HandlerFunc) HandleEvent(b []byte) error {
-	return f(b)
-}
-
-type Evt struct {
-	evtHandlers map[int]EventHandler
-}
-
-func NewEvt() *Evt {
-	return &Evt{
-		evtHandlers: map[int]EventHandler{},
-	}
-}
-
-func (e *Evt) HandleEvent(c int, h EventHandler) {
-	e.evtHandlers[c] = h
-}
-
-func (e *Evt) Dispatch(b []byte) error {
-	h := &EventHeader{}
-	if err := h.Unmarshal(b); err != nil {
-		return err
-	}
-	b = b[2:] // Skip Event Header (uint8 + uint8)
-	if f, found := e.evtHandlers[h.code]; found {
-		e.trace("> HCI Event: %s (0x%02X) plen %d: [ % X ])\n", h.code, uint8(h.code), h.plen, b)
-		return f.HandleEvent(b)
-	}
-	e.trace("> HCI Event: no handler for %s (0x%02X)\n", h.code, uint8(h.code))
-	return nil
-}
-
-func (e *Evt) trace(fmt string, v ...interface{}) {}
-
-const (
-	InquiryComplete                              = 0x01 // Inquiry Complete
-	InquiryResult                                = 0x02 // Inquiry Result
-	ConnectionComplete                           = 0x03 // Connection Complete
-	ConnectionRequest                            = 0x04 // Connection Request
-	DisconnectionComplete                        = 0x05 // Disconnection Complete
-	AuthenticationComplete                       = 0x06 // Authentication
-	RemoteNameReqComplete                        = 0x07 // Remote Name Request Complete
-	EncryptionChange                             = 0x08 // Encryption Change
-	ChangeConnectionLinkKeyComplete              = 0x09 // Change Conection Link Key Complete
-	MasterLinkKeyComplete                        = 0x0A // Master Link Keye Complete
-	ReadRemoteSupportedFeaturesComplete          = 0x0B // Read Remote Supported Features Complete
-	ReadRemoteVersionInformationComplete         = 0x0C // Read Remote Version Information Complete
-	QoSSetupComplete                             = 0x0D // QoSSetupComplete
-	CommandComplete                              = 0x0E // Command Complete
-	CommandStatus                                = 0x0F // Command status
-	HardwareError                                = 0x10 // Hardware Error
-	FlushOccurred                                = 0x11 // Flush Occured
-	RoleChange                                   = 0x12 // Role Change
-	NumberOfCompletedPkts                        = 0x13 // Number Of Completed Packets
-	ModeChange                                   = 0x14 // Mode Change
-	ReturnLinkKeys                               = 0x15 // Return Link Keys
-	PinCodeRequest                               = 0x16 // PIN Code Request
-	LinkKeyRequest                               = 0x17 // Link Key Request
-	LinkKeyNotification                          = 0x18 // Link Key Notification
-	LoopbackCommand                              = 0x19 // Loopback Command
-	DataBufferOverflow                           = 0x1A // Data Buffer Overflow
-	MaxSlotsChange                               = 0x1B // Max Slots Change
-	ReadClockOffsetComplete                      = 0x1C // Read Clock Offset Complete
-	ConnectionPtypeChanged                       = 0x1D // Connection Packet Type Changed
-	QoSViolation                                 = 0x1E // QoS Violation
-	PageScanRepetitionModeChange                 = 0x20 // Page Scan Repetition Mode Change
-	FlowSpecificationComplete                    = 0x21 // Flow Specification
-	InquiryResultWithRssi                        = 0x22 // Inquery Result with RSSI
-	ReadRemoteExtendedFeaturesComplete           = 0x23 // Read Remote Extended Features Complete
-	SyncConnectionComplete                       = 0x2C // Synchronous Connection Complete
-	SyncConnectionChanged                        = 0x2D // Synchronous Connection Changed
-	SniffSubrating                               = 0x2E // Sniff Subrating
-	ExtendedInquiryResult                        = 0x2F // Extended Inquiry Result
-	EncryptionKeyRefreshComplete                 = 0x30 // Encryption Key Refresh Complete
-	IOCapabilityRequest                          = 0x31 // IO Capability Request
-	IOCapabilityResponse                         = 0x32 // IO Capability Changed
-	UserConfirmationRequest                      = 0x33 // User Confirmation Request
-	UserPasskeyRequest                           = 0x34 // User Passkey Request
-	RemoteOOBDataRequest                         = 0x35 // Remote OOB Data
-	SimplePairingComplete                        = 0x36 // Simple Pairing Complete
-	LinkSupervisionTimeoutChanged                = 0x38 // Link Supervision Timeout Changed
-	EnhancedFlushComplete                        = 0x39 // Enhanced Flush Complete
-	UserPasskeyNotify                            = 0x3B // User Passkey Notification
-	KeypressNotify                               = 0x3C // Keypass Notification
-	RemoteHostFeaturesNotify                     = 0x3D // Remote Host Supported Features Notification
-	LEMeta                                       = 0x3E // LE Meta
-	PhysicalLinkComplete                         = 0x40 // Physical Link Complete
-	ChannelSelected                              = 0x41 // Channel Selected
-	DisconnectionPhysicalLinkComplete            = 0x42 // Disconnection Physical Link Complete
-	PhysicalLinkLossEarlyWarning                 = 0x43 // Physical Link Loss Early Warning
-	PhysicalLinkRecovery                         = 0x44 // Physical Link Recovery
-	LogicalLinkComplete                          = 0x45 // Logical Link Complete
-	DisconnectionLogicalLinkComplete             = 0x46 // Disconnection Logical Link Complete
-	FlowSpecModifyComplete                       = 0x47 // Flow Spec Modify Complete
-	NumberOfCompletedBlocks                      = 0x48 // Number Of Completed Data Blocks
-	AMPStartTest                                 = 0x49 // AMP Start Test
-	AMPTestEnd                                   = 0x4A // AMP Test End
-	AMPReceiverReport                            = 0x4b // AMP Receiver Report
-	AMPStatusChange                              = 0x4D // AMP status Change
-	TriggeredClockCapture                        = 0x4e // Triggered Clock Capture
-	SynchronizationTrainComplete                 = 0x4F // Synchronization Train Complete
-	SynchronizationTrainReceived                 = 0x50 // Synchronization Train Received
-	ConnectionlessSlaveBroadcastReceive          = 0x51 // Connectionless Slave Broadcast Receive
-	ConnectionlessSlaveBroadcastTimeout          = 0x52 // Connectionless Slave Broadcast Timeout
-	TruncatedPageComplete                        = 0x53 // Truncated Page Complete
-	SlavePageResponseTimeout                     = 0x54 // Slave Page Response Timeout
-	ConnectionlessSlaveBroadcastChannelMapChange = 0x55 // Connectionless Slave Broadcast Channel Map Change
-	InquiryResponseNotification                  = 0x56 // Inquiry Response Notification
-	AuthenticatedPayloadTimeoutExpired           = 0x57 // Authenticated Payload Timeout Expired
-)
-
-type LEEventCode int
-
-const (
-	LEConnectionComplete               LEEventCode = 0x01 // LE Connection Complete
-	LEAdvertisingReport                            = 0x02 // LE Advertising Report
-	LEConnectionUpdateComplete                     = 0x03 // LE Connection Update Complete
-	LEReadRemoteUsedFeaturesComplete               = 0x04 // LE Read Remote Used Features Complete
-	LELTKRequest                                   = 0x05 // LE LTK Request
-	LERemoteConnectionParameterRequest             = 0x06 // LE Remote Connection Parameter Request
-)
-
-type EventHeader struct {
-	code int
-	plen uint8
-}
-
-func (h *EventHeader) Unmarshal(b []byte) error {
-	if len(b) < 2 {
-		return errors.New("malformed header")
-	}
-	h.code = int(b[0])
-	h.plen = b[1]
-	if uint8(len(b)) != 2+h.plen {
-		return errors.New("wrong length")
-	}
-	return nil
-}
-
-var o = util.Order
-
-// Event Parameters
-
-type InquiryCompleteEP struct {
-	Status uint8
-}
-
-type InquiryResultEP struct {
-	NumResponses           uint8
-	BDAddr                 [][6]byte
-	PageScanRepetitionMode []uint8
-	Reserved1              []byte
-	Reserved2              []byte
-	ClassOfDevice          [][3]byte
-	ClockOffset            []uint16
-}
-
-type ConnectionCompleteEP struct {
-	Status            uint8
-	ConnectionHandle  uint16
-	BDAddr            [6]byte
-	LinkType          uint8
-	EncryptionEnabled uint8
-}
-
-type ConnectionRequestEP struct {
-	BDAddr        [6]byte
-	ClassofDevice [3]byte
-	LinkType      uint8
-}
-
-type DisconnectionCompleteEP struct {
-	Status           uint8
-	ConnectionHandle uint16
-	Reason           uint8
-}
-
-func (e *DisconnectionCompleteEP) Unmarshal(b []byte) error {
-	buf := bytes.NewBuffer(b)
-	binary.Read(buf, binary.LittleEndian, &e.Status)
-	binary.Read(buf, binary.LittleEndian, &e.ConnectionHandle)
-	return binary.Read(buf, binary.LittleEndian, &e.Reason)
-}
-
-type CommandCompleteEP struct {
-	NumHCICommandPackets uint8
-	CommandOPCode        uint16
-	ReturnParameters     []byte
-}
-
-func (e *CommandCompleteEP) Unmarshal(b []byte) error {
-	buf := bytes.NewBuffer(b)
-	if err := binary.Read(buf, binary.LittleEndian, &e.NumHCICommandPackets); err != nil {
-		return err
-	}
-	if err := binary.Read(buf, binary.LittleEndian, &e.CommandOPCode); err != nil {
-		return err
-	}
-	e.ReturnParameters = buf.Bytes()
-	return nil
-}
-
-type CommandStatusEP struct {
-	Status               uint8
-	NumHCICommandPackets uint8
-	CommandOpcode        uint16
-}
-
-func (e *CommandStatusEP) Unmarshal(b []byte) error {
-	buf := bytes.NewBuffer(b)
-	binary.Read(buf, binary.LittleEndian, &e.Status)
-	binary.Read(buf, binary.LittleEndian, &e.NumHCICommandPackets)
-	return binary.Read(buf, binary.LittleEndian, &e.CommandOpcode)
-}
-
-type NumOfCompletedPkt struct {
-	ConnectionHandle   uint16
-	NumOfCompletedPkts uint16
-}
-
-type NumberOfCompletedPktsEP struct {
-	NumberOfHandles uint8
-	Packets         []NumOfCompletedPkt
-}
-
-func (e *NumberOfCompletedPktsEP) Unmarshal(b []byte) error {
-	e.NumberOfHandles = b[0]
-	n := int(e.NumberOfHandles)
-	buf := bytes.NewBuffer(b[1:])
-	e.Packets = make([]NumOfCompletedPkt, n)
-	for i := 0; i < n; i++ {
-		binary.Read(buf, binary.LittleEndian, &e.Packets[i].ConnectionHandle)
-		binary.Read(buf, binary.LittleEndian, &e.Packets[i].NumOfCompletedPkts)
-
-		e.Packets[i].ConnectionHandle &= 0xfff
-	}
-	return nil
-}
-
-// LE Meta Subevents
-type LEConnectionCompleteEP struct {
-	SubeventCode        uint8
-	Status              uint8
-	ConnectionHandle    uint16
-	Role                uint8
-	PeerAddressType     uint8
-	PeerAddress         [6]byte
-	ConnInterval        uint16
-	ConnLatency         uint16
-	SupervisionTimeout  uint16
-	MasterClockAccuracy uint8
-}
-
-func (e *LEConnectionCompleteEP) Unmarshal(b []byte) error {
-	e.SubeventCode = o.Uint8(b[0:])
-	e.Status = o.Uint8(b[1:])
-	e.ConnectionHandle = o.Uint16(b[2:])
-	e.Role = o.Uint8(b[4:])
-	e.PeerAddressType = o.Uint8(b[5:])
-	e.PeerAddress = o.MAC(b[6:])
-	e.ConnInterval = o.Uint16(b[12:])
-	e.ConnLatency = o.Uint16(b[14:])
-	e.SupervisionTimeout = o.Uint16(b[16:])
-	e.MasterClockAccuracy = o.Uint8(b[17:])
-	return nil
-}
-
-type LEAdvertisingReportEP struct {
-	SubeventCode uint8
-	NumReports   uint8
-	EventType    []uint8
-	AddressType  []uint8
-	Address      [][6]byte
-	Length       []uint8
-	Data         [][]byte
-	RSSI         []int8
-}
-
-func (e *LEAdvertisingReportEP) Unmarshal(b []byte) error {
-	e.SubeventCode = o.Uint8(b)
-	b = b[1:]
-	e.NumReports = o.Uint8(b)
-	b = b[1:]
-	n := int(e.NumReports)
-	e.EventType = make([]uint8, n)
-	e.AddressType = make([]uint8, n)
-	e.Address = make([][6]byte, n)
-	e.Length = make([]uint8, n)
-	e.Data = make([][]byte, n)
-	e.RSSI = make([]int8, n)
-
-	for i := 0; i < n; i++ {
-		e.EventType[i] = o.Uint8(b)
-		b = b[1:]
-	}
-	for i := 0; i < n; i++ {
-		e.AddressType[i] = o.Uint8(b)
-		b = b[1:]
-	}
-	for i := 0; i < n; i++ {
-		e.Address[i] = o.MAC(b)
-		b = b[6:]
-	}
-	for i := 0; i < n; i++ {
-		e.Length[i] = o.Uint8(b)
-		b = b[1:]
-	}
-	for i := 0; i < n; i++ {
-		e.Data[i] = make([]byte, e.Length[i])
-		copy(e.Data[i], b)
-		b = b[e.Length[i]:]
-	}
-	for i := 0; i < n; i++ {
-		e.RSSI[i] = o.Int8(b)
-		b = b[1:]
-	}
-	return nil
-}
-
-type LEConnectionUpdateCompleteEP struct {
-	SubeventCode       uint8
-	Status             uint8
-	ConnectionHandle   uint16
-	ConnInterval       uint16
-	ConnLatency        uint16
-	SupervisionTimeout uint16
-}
-
-func (e *LEConnectionUpdateCompleteEP) Unmarshal(b []byte) error {
-	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
-}
-
-type LEReadRemoteUsedFeaturesCompleteEP struct {
-	SubeventCode     uint8
-	Status           uint8
-	ConnectionHandle uint16
-	LEFeatures       uint64
-}
-
-func (e *LEReadRemoteUsedFeaturesCompleteEP) Unmarshal(b []byte) error {
-	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
-}
-
-type LELTKRequestEP struct {
-	SubeventCode          uint8
-	ConnectionHandle      uint16
-	RandomNumber          uint64
-	EncryptionDiversifier uint16
-}
-
-func (e *LELTKRequestEP) Unmarshal(b []byte) error {
-	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
-}
-
-type LERemoteConnectionParameterRequestEP struct {
-	SubeventCode     uint8
-	ConnectionHandle uint16
-	IntervalMin      uint16
-	IntervalMax      uint16
-	Latency          uint16
-	Timeout          uint16
-}
-
-func (e *LERemoteConnectionParameterRequestEP) Unmarshal(b []byte) error {
-	return binary.Read(bytes.NewBuffer(b), binary.LittleEndian, e)
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/LICENSE.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/LICENSE.md b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/LICENSE.md
deleted file mode 100644
index 1e1b7cd..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/LICENSE.md
+++ /dev/null
@@ -1,22 +0,0 @@
-Copyright (c) 2012 Mark Wolfe
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/README.md
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/README.md b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/README.md
deleted file mode 100644
index 837fa03..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# gioctl [![GoDoc](https://img.shields.io/badge/godoc-Reference-brightgreen.svg?style=flat)](http://godoc.org/github.com/wolfeidau/gioctl)
-
-Simple library which provides golang versions of the ioctl macros in linux.
-
-# References
-
-* https://github.com/luismesas/goPi started with the IOCTL stuff from this project initally.
-* http://www.circlemud.org/jelson/software/fusd/docs/node31.html good information on IOCTL macros.
-
-# License
-
-This code is Copyright (c) 2014 Mark Wolfe and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/ioctl.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/ioctl.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/ioctl.go
deleted file mode 100644
index 0097459..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/gioctl/ioctl.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package gioctl
-
-import "syscall"
-
-const (
-	typeBits      = 8
-	numberBits    = 8
-	sizeBits      = 14
-	directionBits = 2
-
-	typeMask      = (1 << typeBits) - 1
-	numberMask    = (1 << numberBits) - 1
-	sizeMask      = (1 << sizeBits) - 1
-	directionMask = (1 << directionBits) - 1
-
-	directionNone  = 0
-	directionWrite = 1
-	directionRead  = 2
-
-	numberShift    = 0
-	typeShift      = numberShift + numberBits
-	sizeShift      = typeShift + typeBits
-	directionShift = sizeShift + sizeBits
-)
-
-func ioc(dir, t, nr, size uintptr) uintptr {
-	return (dir << directionShift) | (t << typeShift) | (nr << numberShift) | (size << sizeShift)
-}
-
-// Io used for a simple ioctl that sends nothing but the type and number, and receives back nothing but an (integer) retval.
-func Io(t, nr uintptr) uintptr {
-	return ioc(directionNone, t, nr, 0)
-}
-
-// IoR used for an ioctl that reads data from the device driver. The driver will be allowed to return sizeof(data_type) bytes to the user.
-func IoR(t, nr, size uintptr) uintptr {
-	return ioc(directionRead, t, nr, size)
-}
-
-// IoW used for an ioctl that writes data to the device driver.
-func IoW(t, nr, size uintptr) uintptr {
-	return ioc(directionWrite, t, nr, size)
-}
-
-// IoRW  a combination of IoR and IoW. That is, data is both written to the driver and then read back from the driver by the client.
-func IoRW(t, nr, size uintptr) uintptr {
-	return ioc(directionRead|directionWrite, t, nr, size)
-}
-
-// Ioctl simplified ioct call
-func Ioctl(fd, op, arg uintptr) error {
-	_, _, ep := syscall.Syscall(syscall.SYS_IOCTL, fd, op, arg)
-	if ep != 0 {
-		return syscall.Errno(ep)
-	}
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/hci.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/hci.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/hci.go
deleted file mode 100644
index c41d0bf..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/hci.go
+++ /dev/null
@@ -1,400 +0,0 @@
-package linux
-
-import (
-	"fmt"
-	"io"
-	"log"
-	"sync"
-
-	"github.com/runtimeinc/gatt/linux/cmd"
-	"github.com/runtimeinc/gatt/linux/evt"
-)
-
-type HCI struct {
-	AcceptMasterHandler  func(pd *PlatData)
-	AcceptSlaveHandler   func(pd *PlatData)
-	AdvertisementHandler func(pd *PlatData)
-
-	d io.ReadWriteCloser
-	c *cmd.Cmd
-	e *evt.Evt
-
-	plist   map[bdaddr]*PlatData
-	plistmu *sync.Mutex
-
-	bufCnt  chan struct{}
-	bufSize int
-
-	maxConn int
-	connsmu *sync.Mutex
-	conns   map[uint16]*conn
-
-	adv   bool
-	advmu *sync.Mutex
-}
-
-type bdaddr [6]byte
-
-type PlatData struct {
-	Name        string
-	AddressType uint8
-	Address     [6]byte
-	Data        []byte
-	Connectable bool
-	RSSI        int8
-
-	Conn io.ReadWriteCloser
-}
-
-func NewHCI(devID int, chk bool, maxConn int) (*HCI, error) {
-	d, err := newDevice(devID, chk)
-	if err != nil {
-		return nil, err
-	}
-	c := cmd.NewCmd(d)
-	e := evt.NewEvt()
-
-	h := &HCI{
-		d: d,
-		c: c,
-		e: e,
-
-		plist:   make(map[bdaddr]*PlatData),
-		plistmu: &sync.Mutex{},
-
-		bufCnt:  make(chan struct{}, 15-1),
-		bufSize: 27,
-
-		maxConn: maxConn,
-		connsmu: &sync.Mutex{},
-		conns:   map[uint16]*conn{},
-
-		advmu: &sync.Mutex{},
-	}
-
-	e.HandleEvent(evt.LEMeta, evt.HandlerFunc(h.handleLEMeta))
-	e.HandleEvent(evt.DisconnectionComplete, evt.HandlerFunc(h.handleDisconnectionComplete))
-	e.HandleEvent(evt.NumberOfCompletedPkts, evt.HandlerFunc(h.handleNumberOfCompletedPkts))
-	e.HandleEvent(evt.CommandComplete, evt.HandlerFunc(c.HandleComplete))
-	e.HandleEvent(evt.CommandStatus, evt.HandlerFunc(c.HandleStatus))
-
-	go h.mainLoop()
-	h.resetDevice()
-	return h, nil
-}
-
-func (h *HCI) Close() error {
-	for _, c := range h.conns {
-		c.Close()
-	}
-	return h.d.Close()
-}
-
-func (h *HCI) SetAdvertiseEnable(en bool) error {
-	h.advmu.Lock()
-	h.adv = en
-	h.advmu.Unlock()
-	return h.setAdvertiseEnable(en)
-}
-
-func (h *HCI) setAdvertiseEnable(en bool) error {
-	h.advmu.Lock()
-	defer h.advmu.Unlock()
-	if en && h.adv && (len(h.conns) == h.maxConn) {
-		return nil
-	}
-	return h.c.SendAndCheckResp(
-		cmd.LESetAdvertiseEnable{
-			AdvertisingEnable: btoi(en),
-		}, []byte{0x00})
-}
-
-func (h *HCI) SendCmdWithAdvOff(c cmd.CmdParam) error {
-	h.setAdvertiseEnable(false)
-	err := h.c.SendAndCheckResp(c, nil)
-	if h.adv {
-		h.setAdvertiseEnable(true)
-	}
-	return err
-}
-
-func (h *HCI) SetScanEnable(en bool, dup bool) error {
-	return h.c.SendAndCheckResp(
-		cmd.LESetScanEnable{
-			LEScanEnable:     btoi(en),
-			FilterDuplicates: btoi(!dup),
-		}, []byte{0x00})
-}
-
-func (h *HCI) Connect(pd *PlatData) error {
-	h.c.Send(
-		cmd.LECreateConn{
-			LEScanInterval:        0x0004,         // N x 0.625ms
-			LEScanWindow:          0x0004,         // N x 0.625ms
-			InitiatorFilterPolicy: 0x00,           // white list not used
-			PeerAddressType:       pd.AddressType, // public or random
-			PeerAddress:           pd.Address,     //
-			OwnAddressType:        0x00,           // public
-			ConnIntervalMin:       6,         // N x 0.125ms
-			ConnIntervalMax:       7,         // N x 0.125ms
-			ConnLatency:           0x0000,         //
-			SupervisionTimeout:    0x00100,         // N x 10ms
-			MinimumCELength:       0x0000,         // N x 0.625ms
-			MaximumCELength:       0x0000,         // N x 0.625ms
-		})
-	return nil
-}
-
-func (h *HCI) CancelConnection(pd *PlatData) error {
-	return pd.Conn.Close()
-}
-
-func (h *HCI) SendRawCommand(c cmd.CmdParam) ([]byte, error) {
-	return h.c.Send(c)
-}
-
-func btoi(b bool) uint8 {
-	if b {
-		return 1
-	}
-	return 0
-}
-
-func (h *HCI) mainLoop() {
-	b := make([]byte, 4096)
-	for {
-		n, err := h.d.Read(b)
-		if err != nil {
-			return
-		}
-		if n == 0 {
-			return
-		}
-		p := make([]byte, n)
-		copy(p, b)
-		h.handlePacket(p)
-	}
-}
-
-func (h *HCI) handlePacket(b []byte) {
-	t, b := packetType(b[0]), b[1:]
-	var err error
-	switch t {
-	case typCommandPkt:
-		op := uint16(b[0]) | uint16(b[1])<<8
-		log.Printf("unmanaged cmd: opcode (%04x) [ % X ]\n", op, b)
-	case typACLDataPkt:
-		err = h.handleL2CAP(b)
-	case typSCODataPkt:
-		err = fmt.Errorf("SCO packet not supported")
-	case typEventPkt:
-		go func() {
-			err := h.e.Dispatch(b)
-			if err != nil {
-				log.Printf("hci: %s, [ % X]", err, b)
-			}
-		}()
-	case typVendorPkt:
-		err = fmt.Errorf("Vendor packet not supported")
-	default:
-		log.Fatalf("Unknown event: 0x%02X [ % X ]\n", t, b)
-	}
-	if err != nil {
-		log.Printf("hci: %s, [ % X]", err, b)
-	}
-}
-
-func (h *HCI) resetDevice() error {
-	seq := []cmd.CmdParam{
-		cmd.Reset{},
-		cmd.SetEventMask{EventMask: 0x3dbff807fffbffff},
-		cmd.LESetEventMask{LEEventMask: 0x000000000000001F},
-		cmd.WriteSimplePairingMode{SimplePairingMode: 1},
-		cmd.WriteLEHostSupported{LESupportedHost: 1, SimultaneousLEHost: 0},
-		cmd.WriteInquiryMode{InquiryMode: 2},
-		cmd.WritePageScanType{PageScanType: 1},
-		cmd.WriteInquiryScanType{ScanType: 1},
-		cmd.WriteClassOfDevice{ClassOfDevice: [3]byte{0x40, 0x02, 0x04}},
-		cmd.WritePageTimeout{PageTimeout: 0x2000},
-		cmd.WriteDefaultLinkPolicy{DefaultLinkPolicySettings: 0x5},
-		cmd.HostBufferSize{
-			HostACLDataPacketLength:            0x1000,
-			HostSynchronousDataPacketLength:    0xff,
-			HostTotalNumACLDataPackets:         0x0014,
-			HostTotalNumSynchronousDataPackets: 0x000a},
-		cmd.LESetScanParameters{
-			LEScanType:           0x01,   // [0x00]: passive, 0x01: active
-			LEScanInterval:       0x0010, // [0x10]: 0.625ms * 16
-			LEScanWindow:         0x0010, // [0x10]: 0.625ms * 16
-			OwnAddressType:       0x00,   // [0x00]: public, 0x01: random
-			ScanningFilterPolicy: 0x00,   // [0x00]: accept all, 0x01: ignore non-white-listed.
-		},
-	}
-	for _, s := range seq {
-		if err := h.c.SendAndCheckResp(s, []byte{0x00}); err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func (h *HCI) handleAdvertisement(b []byte) {
-	// If no one is interested, don't bother.
-	if h.AdvertisementHandler == nil {
-		return
-	}
-	ep := &evt.LEAdvertisingReportEP{}
-	if err := ep.Unmarshal(b); err != nil {
-		return
-	}
-	for i := 0; i < int(ep.NumReports); i++ {
-		addr := bdaddr(ep.Address[i])
-		et := ep.EventType[i]
-		connectable := et == advInd || et == advDirectInd
-		scannable := et == advInd || et == advScanInd
-
-		if et == scanRsp {
-			h.plistmu.Lock()
-			pd, ok := h.plist[addr]
-			h.plistmu.Unlock()
-			if ok {
-				pd.Data = append(pd.Data, ep.Data[i]...)
-				h.AdvertisementHandler(pd)
-			}
-			continue
-		}
-
-		pd := &PlatData{
-			AddressType: ep.AddressType[i],
-			Address:     ep.Address[i],
-			Data:        ep.Data[i],
-			Connectable: connectable,
-			RSSI:        ep.RSSI[i],
-		}
-		h.plistmu.Lock()
-		h.plist[addr] = pd
-		h.plistmu.Unlock()
-		if scannable {
-			continue
-		}
-		h.AdvertisementHandler(pd)
-	}
-}
-
-func (h *HCI) handleNumberOfCompletedPkts(b []byte) error {
-	ep := &evt.NumberOfCompletedPktsEP{}
-	if err := ep.Unmarshal(b); err != nil {
-		return err
-	}
-	for _, r := range ep.Packets {
-		for i := 0; i < int(r.NumOfCompletedPkts); i++ {
-			<-h.bufCnt
-		}
-	}
-	return nil
-}
-
-func (h *HCI) handleConnection(b []byte) {
-	ep := &evt.LEConnectionCompleteEP{}
-	if err := ep.Unmarshal(b); err != nil {
-		return // FIXME
-	}
-	hh := ep.ConnectionHandle
-	c := newConn(h, hh)
-	h.connsmu.Lock()
-	h.conns[hh] = c
-	h.connsmu.Unlock()
-	h.setAdvertiseEnable(true)
-
-	// FIXME: sloppiness. This call should be called by the package user once we
-	// flesh out the support of l2cap signaling packets (CID:0x0001,0x0005)
-	if ep.ConnLatency != 0 || ep.ConnInterval > 0x18 {
-		c.updateConnection()
-	}
-
-	// master connection
-	if ep.Role == 0x01 {
-		pd := &PlatData{
-			Address: ep.PeerAddress,
-			Conn:    c,
-		}
-		h.AcceptMasterHandler(pd)
-		return
-	}
-	h.plistmu.Lock()
-	pd := h.plist[ep.PeerAddress]
-	h.plistmu.Unlock()
-	pd.Conn = c
-	h.AcceptSlaveHandler(pd)
-}
-
-func (h *HCI) handleDisconnectionComplete(b []byte) error {
-	ep := &evt.DisconnectionCompleteEP{}
-	if err := ep.Unmarshal(b); err != nil {
-		return err
-	}
-	hh := ep.ConnectionHandle
-	h.connsmu.Lock()
-	defer h.connsmu.Unlock()
-	c, found := h.conns[hh]
-	if !found {
-		// should not happen, just be cautious for now.
-		log.Printf("l2conn: disconnecting a disconnected 0x%04X connection", hh)
-		return nil
-	}
-	delete(h.conns, hh)
-	close(c.aclc)
-	h.setAdvertiseEnable(true)
-	return nil
-}
-
-func (h *HCI) handleLEMeta(b []byte) error {
-	code := evt.LEEventCode(b[0])
-	switch code {
-	case evt.LEConnectionComplete:
-		go h.handleConnection(b)
-	case evt.LEConnectionUpdateComplete:
-		// anything to do here?
-	case evt.LEAdvertisingReport:
-		go h.handleAdvertisement(b)
-	// case evt.LEReadRemoteUsedFeaturesComplete:
-	// case evt.LELTKRequest:
-	// case evt.LERemoteConnectionParameterRequest:
-	default:
-		return fmt.Errorf("Unhandled LE event: %s, [ % X ]", code, b)
-	}
-	return nil
-}
-
-func (h *HCI) handleL2CAP(b []byte) error {
-        a := &aclData{}
-	if err := a.unmarshal(b); err != nil {
-		return err
-	}
-	h.connsmu.Lock()
-	defer h.connsmu.Unlock()
-	c, found := h.conns[a.attr]
-
-        if a.flags != 0x002 {
-	    if !found {
-		    // should not happen, just be cautious for now.
-		    log.Printf("l2conn: got data for disconnected handle: 0x%04x", a.attr)
-		    return nil
-	        if len(a.b) < 4 {
-		    log.Printf("l2conn: l2cap packet is too short/corrupt, length is %d", len(a.b))
-		    return nil
-	        }
-	        cid := uint16(a.b[2]) | (uint16(a.b[3]) << 8)
-	        if cid == 5 {
-		    c.handleSignal(a)
-		    return nil
-	        }
-            }
-        }
-	c.aclc <- a
-	return nil
-}
-
-func (h *HCI) trace(fmt string, v ...interface{}) {
-	log.Printf(fmt, v)
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/l2cap.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/l2cap.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/l2cap.go
deleted file mode 100644
index 19c2968..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/l2cap.go
+++ /dev/null
@@ -1,174 +0,0 @@
-package linux
-
-import (
-	"fmt"
-	"io"
-	"log"
-
-	"github.com/runtimeinc/gatt/linux/cmd"
-)
-
-type aclData struct {
-	attr  uint16
-	flags uint8
-	dlen  uint16
-	b     []byte
-}
-
-func (a *aclData) unmarshal(b []byte) error {
-	if len(b) < 4 {
-		return fmt.Errorf("malformed acl packet")
-	}
-	attr := uint16(b[0]) | (uint16(b[1]&0x0f) << 8)
-	flags := b[1] >> 4
-	dlen := uint16(b[2]) | (uint16(b[3]) << 8)
-	if len(b) != 4+int(dlen) {
-		return fmt.Errorf("malformed acl packet")
-	}
-
-	*a = aclData{attr: attr, flags: flags, dlen: dlen, b: b[4:]}
-	return nil
-}
-
-type conn struct {
-	hci  *HCI
-	attr uint16
-	aclc chan *aclData
-}
-
-func newConn(hci *HCI, hh uint16) *conn {
-	return &conn{
-		hci:  hci,
-		attr: hh,
-		aclc: make(chan *aclData),
-	}
-}
-
-func (c *conn) updateConnection() (int, error) {
-	b := []byte{
-		0x12,       // Code (Connection Param Update)
-		0x02,       // ID
-		0x08, 0x00, // DataLength
-		0x08, 0x00, // IntervalMin
-		0x18, 0x00, // IntervalMax
-		0x00, 0x00, // SlaveLatency
-		0xC8, 0x00} // TimeoutMultiplier
-	return c.write(0x05, b)
-}
-
-// write writes the l2cap payload to the controller.
-// It first prepend the l2cap header (4-bytes), and diassemble the payload
-// if it is larger than the HCI LE buffer size that the conntroller can support.
-func (c *conn) write(cid int, b []byte) (int, error) {
-	flag := uint8(0) // ACL data continuation flag
-	tlen := len(b)   // Total length of the l2cap payload
-
-	// log.Printf("W: [ % X ]", b)
-	w := append(
-		[]byte{
-			0,    // packet type
-			0, 0, // attr
-			0, 0, // dlen
-			uint8(tlen), uint8(tlen >> 8), // l2cap header
-			uint8(cid), uint8(cid >> 8), // l2cap header
-		}, b...)
-
-	n := 4 + tlen // l2cap header + l2cap payload
-	for n > 0 {
-		dlen := n
-		if dlen > c.hci.bufSize {
-			dlen = c.hci.bufSize
-		}
-		w[0] = 0x02 // packetTypeACL
-		w[1] = uint8(c.attr)
-		w[2] = uint8(c.attr>>8) | flag
-		w[3] = uint8(dlen)
-		w[4] = uint8(dlen >> 8)
-
-		// make sure we don't send more buffers than the controller can handdle
-		c.hci.bufCnt <- struct{}{}
-
-		c.hci.d.Write(w[:5+dlen])
-		w = w[dlen:] // advance the pointer to the next segment, if any.
-		flag = 0x10  // the rest of iterations attr continued segments, if any.
-		n -= dlen
-	}
-
-	return len(b), nil
-}
-
-func (c *conn) Read(b []byte) (int, error) {
-	a, ok := <-c.aclc
-	if !ok {
-		return 0, io.EOF
-	}
-	tlen := int(uint16(a.b[0]) | uint16(a.b[1])<<8)
-	if tlen > len(b) {
-		return 0, io.ErrShortBuffer
-	}
-	d := a.b[4:] // skip l2cap header
-	copy(b, d)
-	n := len(d)
-
-	// Keep receiving and reassemble continued l2cap segments
-	for n != tlen {
-		if a, ok = <-c.aclc; !ok || (a.flags&0x1) == 0 {
-			return n, io.ErrUnexpectedEOF
-		}
-		copy(b[n:], a.b)
-		n += len(a.b)
-	}
-	// log.Printf("R: [ % X ]", b[:n])
-	return n, nil
-}
-
-func (c *conn) Write(b []byte) (int, error) {
-	return c.write(0x04, b)
-}
-
-// Close disconnects the connection by sending HCI disconnect command to the device.
-func (c *conn) Close() error {
-	h := c.hci
-	hh := c.attr
-	h.connsmu.Lock()
-	defer h.connsmu.Unlock()
-	_, found := h.conns[hh]
-	if !found {
-		// log.Printf("l2conn: 0x%04x already disconnected", hh)
-		return nil
-	}
-	if err, _ := h.c.Send(cmd.Disconnect{ConnectionHandle: hh, Reason: 0x13}); err != nil {
-		return fmt.Errorf("l2conn: failed to disconnect, %s", err)
-	}
-	return nil
-}
-
-// Signal Packets
-// 0x00 Reserved								Any
-// 0x01 Command reject							0x0001 and 0x0005
-// 0x02 Connection request						0x0001
-// 0x03 Connection response 					0x0001
-// 0x04 Configure request						0x0001
-// 0x05 Configure response						0x0001
-// 0x06 Disconnection request					0x0001 and 0x0005
-// 0x07 Disconnection response					0x0001 and 0x0005
-// 0x08 Echo request							0x0001
-// 0x09 Echo response							0x0001
-// 0x0A Information request						0x0001
-// 0x0B Information response					0x0001
-// 0x0C Create Channel request					0x0001
-// 0x0D Create Channel response					0x0001
-// 0x0E Move Channel request					0x0001
-// 0x0F Move Channel response					0x0001
-// 0x10 Move Channel Confirmation				0x0001
-// 0x11 Move Channel Confirmation response		0x0001
-// 0x12 Connection Parameter Update request		0x0005
-// 0x13 Connection Parameter Update response	0x0005
-// 0x14 LE Credit Based Connection request		0x0005
-// 0x15 LE Credit Based Connection response		0x0005
-// 0x16 LE Flow Control Credit					0x0005
-func (c *conn) handleSignal(a *aclData) error {
-	log.Printf("ignore l2cap signal:[ % X ]", a.b)
-	// FIXME: handle LE signaling channel (CID: 5)
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm.s
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm.s b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm.s
deleted file mode 100644
index d4ca868..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm.s
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2014 The Go Authors.  All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "textflag.h"
-
-TEXT �use(SB),NOSPLIT,$0
-	RET

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm_linux_386.s
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm_linux_386.s b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm_linux_386.s
deleted file mode 100644
index 5d3ad9a..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/asm_linux_386.s
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "textflag.h"
-
-//
-// System calls for 386, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT	�Syscall(SB),NOSPLIT,$0-28
-	JMP	syscall�Syscall(SB)
-
-TEXT	�Syscall6(SB),NOSPLIT,$0-40
-	JMP	syscall�Syscall6(SB)
-
-TEXT �RawSyscall(SB),NOSPLIT,$0-28
-	JMP	syscall�RawSyscall(SB)
-
-TEXT	�RawSyscall6(SB),NOSPLIT,$0-40
-	JMP	syscall�RawSyscall6(SB)
-
-TEXT �socketcall(SB),NOSPLIT,$0-36
-	JMP	syscall�socketcall(SB)
-
-TEXT �rawsocketcall(SB),NOSPLIT,$0-36
-	JMP	syscall�rawsocketcall(SB)
-
-TEXT �seek(SB),NOSPLIT,$0-28
-	JMP	syscall�seek(SB)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket.go
deleted file mode 100644
index ffc49a6..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket.go
+++ /dev/null
@@ -1,121 +0,0 @@
-// Package socket implements a minimal set of function of the HCI Socket,
-// which is not yet supported by the Go standard library. Most of the code
-// follow suit the existing code in the standard library. Once it gets
-// supported officially, we can get rid of this package entirely.
-
-package socket
-
-import (
-	"errors"
-	"syscall"
-	"time"
-	"unsafe"
-)
-
-// Bluetooth Protocols
-const (
-	BTPROTO_L2CAP  = 0
-	BTPROTO_HCI    = 1
-	BTPROTO_SCO    = 2
-	BTPROTO_RFCOMM = 3
-	BTPROTO_BNEP   = 4
-	BTPROTO_CMTP   = 5
-	BTPROTO_HIDP   = 6
-	BTPROTO_AVDTP  = 7
-)
-
-const (
-	HCI_CHANNEL_RAW     = 0
-	HCI_CHANNEL_USER    = 1
-	HCI_CHANNEL_MONITOR = 2
-	HCI_CHANNEL_CONTROL = 3
-)
-
-var (
-	ErrSocketOpenFailed  = errors.New("unable to open bluetooth socket to device")
-	ErrSocketBindTimeout = errors.New("timeout occured binding to bluetooth device")
-)
-
-type _Socklen uint32
-
-type Sockaddr interface {
-	sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
-}
-
-type rawSockaddrHCI struct {
-	Family  uint16
-	Dev     uint16
-	Channel uint16
-}
-
-type SockaddrHCI struct {
-	Dev     int
-	Channel uint16
-	raw     rawSockaddrHCI
-}
-
-const sizeofSockaddrHCI = unsafe.Sizeof(rawSockaddrHCI{})
-
-func (sa *SockaddrHCI) sockaddr() (unsafe.Pointer, _Socklen, error) {
-	if sa.Dev < 0 || sa.Dev > 0xFFFF {
-		return nil, 0, syscall.EINVAL
-	}
-	if sa.Channel < 0 || sa.Channel > 0xFFFF {
-		return nil, 0, syscall.EINVAL
-	}
-	sa.raw.Family = AF_BLUETOOTH
-	sa.raw.Dev = uint16(sa.Dev)
-	sa.raw.Channel = sa.Channel
-	return unsafe.Pointer(&sa.raw), _Socklen(sizeofSockaddrHCI), nil
-}
-
-func Socket(domain, typ, proto int) (int, error) {
-	for i := 0; i < 5; i++ {
-		if fd, err := syscall.Socket(domain, typ, proto); err == nil || err != syscall.EBUSY {
-			return fd, err
-		}
-		time.Sleep(time.Second)
-	}
-	return 0, ErrSocketOpenFailed
-}
-
-func Bind(fd int, sa Sockaddr) (err error) {
-	ptr, n, err := sa.sockaddr()
-	if err != nil {
-		return err
-	}
-	for i := 0; i < 5; i++ {
-		if err = bind(fd, ptr, n); err == nil || err != syscall.EBUSY {
-			return err
-		}
-		time.Sleep(time.Second)
-	}
-	return ErrSocketBindTimeout
-}
-
-// Socket Level
-const (
-	SOL_HCI    = 0
-	SOL_L2CAP  = 6
-	SOL_SCO    = 17
-	SOL_RFCOMM = 18
-
-	SOL_BLUETOOTH = 274
-)
-
-// HCI Socket options
-const (
-	HCI_DATA_DIR   = 1
-	HCI_FILTER     = 2
-	HCI_TIME_STAMP = 3
-)
-
-type HCIFilter struct {
-	TypeMask  uint32
-	EventMask [2]uint32
-	opcode    uint16
-}
-
-func SetsockoptFilter(fd int, f *HCIFilter) (err error) {
-	return setsockopt(fd, SOL_HCI, HCI_FILTER, unsafe.Pointer(f), unsafe.Sizeof(*f))
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_common.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_common.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_common.go
deleted file mode 100644
index b01ceeb..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_common.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// +build !386
-
-package socket
-
-import (
-	"syscall"
-	"unsafe"
-)
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
-	_, _, e1 := syscall.Syscall(syscall.SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
-	if e1 != 0 {
-		err = e1
-	}
-	return
-}
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
-	_, _, e1 := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
-	if e1 != 0 {
-		err = e1
-	}
-	return
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_darwin.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_darwin.go
deleted file mode 100644
index abb96a5..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_darwin.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// +build darwin
-
-package socket
-
-// For compile time compatibility
-const AF_BLUETOOTH = 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux.go
deleted file mode 100644
index 4793915..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build linux
-
-package socket
-
-import "syscall"
-
-const AF_BLUETOOTH = syscall.AF_BLUETOOTH

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/abf65d3a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux_386.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux_386.go b/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux_386.go
deleted file mode 100644
index 05ca65c..0000000
--- a/newtmgr/vendor/github.com/runtimeinc/gatt/linux/socket/socket_linux_386.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// +build linux,386
-
-package socket
-
-import (
-	"syscall"
-	"unsafe"
-)
-
-const (
-	BIND         = 2
-	SETSOCKETOPT = 14
-)
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
-	_, e1 := socketcall(BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
-	if e1 != 0 {
-		err = e1
-	}
-	return
-}
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
-	_, e1 := socketcall(SETSOCKETOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0)
-	if e1 != 0 {
-		err = e1
-	}
-	return
-}
-
-func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)