You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/06 21:17:13 UTC

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

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
+}