ble

package
v0.0.0-...-97dc920 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ATT_OPCODE_ERROR uint8 = iota
	ATT_OPCODE_MTU_REQUEST
	ATT_OPCODE_MTU_RESPONSE
	ATT_OPCODE_FIND_INFO_REQUEST
	ATT_OPCODE_FIND_INFO_RESPONSE
	ATT_OPCODE_FIND_BY_TYPE_VALUE_REQUEST
	ATT_OPCODE_FIND_BY_TYPE_VALUE_RESPONSE
	ATT_OPCODE_READ_BY_TYPE_REQUEST
	ATT_OPCODE_READ_BY_TYPE_RESPONSE
	ATT_OPCODE_READ_REQUEST
	ATT_OPCODE_READ_RESPONSE
	ATT_OPCODE_READ_BLOB_REQUEST
	ATT_OPCODE_READ_BLOB_RESPONSE
	ATT_OPCODE_READ_MULTIPLE_REQUEST
	ATT_OPCODE_READ_MULTIPLE_RESPONSE
	ATT_OPCODE_READ_BY_GROUP_TYPE_REQUEST
	ATT_OPCODE_READ_BY_GROUP_TYPE_RESPONSE
	ATT_OPCODE_WRITE_REQUEST
	ATT_OPCODE_WRITE_RESPONSE

	ATT_OPCODE_WRITE_COMMAND             = 0x52
	ATT_OPCODE_PREPARE_WRITE_REQUEST     = 0x16
	ATT_OPCODE_PREPARE_WRITE_RESPONSE    = 0x17
	ATT_OPCODE_EXECUTE_WRITE_REQUEST     = 0x18
	ATT_OPCODE_EXECUTE_WRITE_RESPONSE    = 0x19
	ATT_OPCODE_HANDLE_VALUE_NOTIFICATION = 0x1B
	ATT_OPCODE_HANDLE_VALUE_INDICATION   = 0x1D
	ATT_OPCODE_HANDLE_VALUE_CONFIRMATION = 0x1E
	ATT_OPCODE_SIGNED_WRITE_COMMAND      = 0xD2

	ATT_OPCODE_CONN_UPDATE = 0xF0
)
View Source
const (
	BTPROTO_L2CAP int = 0
	BTPROTO_HCI   int = 1
	BTPROTO_SCO   int = 2
	BTPROTO_RFCOM int = 3
	BTPROTO_BNEP  int = 4
	BTPROTO_CMTP  int = 5
	BTPROTO_HIDP  int = 6
	BTPROTO_AVDTP int = 7
)
View Source
const (
	SOL_HCI    int = 0
	SOL_L2CAP  int = 6
	SOL_SCO    int = 17
	SOL_RFCOMM int = 18
)
View Source
const (
	BDADDR_BREDR     uint8 = 0x00
	BDADDR_LE_PUBLIC uint8 = 0x01
	BDADDR_LE_RANDOM uint8 = 0x02
)
View Source
const (
	L2CAP_LM          int = 0x03
	L2CAP_LM_MASTER   int = 0x0001
	L2CAP_LM_AUTH     int = 0x0002
	L2CAP_LM_ENCRYPT  int = 0x0004
	L2CAP_LM_TRUSTED  int = 0x0008
	L2CAP_LM_RELIABLE int = 0x0010
	L2CAP_LM_SECURE   int = 0x0020
	L2CAP_LM_FIPS     int = 0x0040
)
View Source
const AF_BLUETOOTH int = 31
View Source
const (
	L2CAP_CONNINFO int = 0x02
)

Variables

View Source
var BLUETOOTH_BASE_UUID [12]byte = [12]byte{0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}
View Source
var Debug bool = false

Functions

func HCIConnUpdate

func HCIConnUpdate(fd *os.File, handle, min_interval, max_interval,
	latency, supervisor_timeout uint16) int

func NewBLE

func NewBLE(remoteAddr *L2Sockaddr, name string) (*os.File, error)

func NewHCI

func NewHCI(dev_id uint8) (*os.File, error)

Types

type AttPDU

type AttPDU interface {
	Msg() []byte
}

type ConnInfo

type ConnInfo struct {
	HCIHandle uint16
	DevClass  [3]uint8
}

func GetConnInfo

func GetConnInfo(fd *os.File) *ConnInfo

type DEV_ID

type DEV_ID [6]uint8

func Str2Ba

func Str2Ba(addrStr string) (DEV_ID, error)

type Device

type Device struct {
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(addr string, serverReqChan chan Request, fd io.ReadWriteCloser,
	ci *ConnInfo) *Device

func (*Device) Disconnect

func (this *Device) Disconnect()

func (*Device) Respond

func (this *Device) Respond(packet []byte)

func (*Device) Start

func (this *Device) Start()

func (*Device) StrHandles

func (device *Device) StrHandles() string

func (*Device) String

func (device *Device) String() string

func (*Device) Transaction

func (this *Device) Transaction(packet []byte, cb func([]byte, error))

func (*Device) WriteCmd

func (this *Device) WriteCmd(packet []byte)

type Error

type Error struct {
	// contains filtered or unexported fields
}

func NewError

func NewError(reqOpcode uint8, handle uint16, errCode uint8) *Error

func ParseError

func ParseError(msg []byte) (*Error, error)

func (*Error) ErrorCode

func (this *Error) ErrorCode() uint8

func (*Error) Handle

func (this *Error) Handle() uint16

func (*Error) Msg

func (this *Error) Msg() []byte

func (*Error) ReqOpcode

func (this *Error) ReqOpcode() uint8

type FindByTypeValueRequest

type FindByTypeValueRequest struct {
	// contains filtered or unexported fields
}

func ParseFindByTypeValueRequest

func ParseFindByTypeValueRequest(msg []byte) (*FindByTypeValueRequest, error)

func (*FindByTypeValueRequest) EndHandle

func (this *FindByTypeValueRequest) EndHandle() uint16

func (*FindByTypeValueRequest) StartHandle

func (this *FindByTypeValueRequest) StartHandle() uint16

func (*FindByTypeValueRequest) Type

func (this *FindByTypeValueRequest) Type() UUID

func (*FindByTypeValueRequest) Value

func (this *FindByTypeValueRequest) Value() []byte

type FindByTypeValueResponse

type FindByTypeValueResponse struct {
	// contains filtered or unexported fields
}

func NewFindByTypeValueResponse

func NewFindByTypeValueResponse(vals []*GroupValue) *FindByTypeValueResponse

type FindInfoByValueResponse

type FindInfoByValueResponse struct {
	// contains filtered or unexported fields
}

func NewFindInfoByValueResponse

func NewFindInfoByValueResponse(msg []byte) (*FindInfoByValueResponse, error)

func (*FindInfoByValueResponse) Msg

func (this *FindInfoByValueResponse) Msg() []byte

type FindInfoRequest

type FindInfoRequest struct {
	// contains filtered or unexported fields
}

func ParseFindInfoRequest

func ParseFindInfoRequest(msg []byte) (*FindInfoRequest, error)

func (*FindInfoRequest) EndHandle

func (this *FindInfoRequest) EndHandle() uint16

func (*FindInfoRequest) StartHandle

func (this *FindInfoRequest) StartHandle() uint16

type FindInfoResponse

type FindInfoResponse struct {
	// contains filtered or unexported fields
}

func NewFindInfoResponse

func NewFindInfoResponse(handles []HandleUUID) *FindInfoResponse

func ParseFindInfoResponse

func ParseFindInfoResponse(msg []byte) (*FindInfoResponse, error)

func (*FindInfoResponse) Format

func (this *FindInfoResponse) Format() uint8

func (*FindInfoResponse) InfoData

func (this *FindInfoResponse) InfoData() []*HandleInfo

func (*FindInfoResponse) Msg

func (this *FindInfoResponse) Msg() []byte

type GroupValue

type GroupValue struct {
	// contains filtered or unexported fields
}

func DiscoverServices

func DiscoverServices(f *Device) ([]*GroupValue, error)

type GroupValueLst

type GroupValueLst []*GroupValue

func (GroupValueLst) Len

func (this GroupValueLst) Len() int

func (GroupValueLst) Less

func (this GroupValueLst) Less(i, j int) bool

func (GroupValueLst) Swap

func (this GroupValueLst) Swap(i, j int)

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

type HandleInfo

type HandleInfo struct {
	// contains filtered or unexported fields
}

func DiscoverHandles

func DiscoverHandles(f *Device, startHandle uint16,
	endHandle uint16) ([]*HandleInfo, error)

type HandleUUID

type HandleUUID struct {
	// contains filtered or unexported fields
}

type HandleUUIDLst

type HandleUUIDLst []HandleUUID

func (HandleUUIDLst) Len

func (this HandleUUIDLst) Len() int

func (HandleUUIDLst) Less

func (this HandleUUIDLst) Less(i, j int) bool

func (HandleUUIDLst) Swap

func (this HandleUUIDLst) Swap(i, j int)

type HandleValue

type HandleValue struct {
	// contains filtered or unexported fields
}

func DiscoverCharacteristics

func DiscoverCharacteristics(f *Device, startHandle uint16,
	endHandle uint16) ([]*HandleValue, error)

type L2Sockaddr

type L2Sockaddr struct {
	// contains filtered or unexported fields
}

func NewL2Sockaddr

func NewL2Sockaddr(channel uint16, addr DEV_ID, addr_type uint8) *L2Sockaddr

type Manager

type Manager struct {
	Devices map[string]*Device
	// contains filtered or unexported fields
}

func NewManager

func NewManager(hciSock *os.File) *Manager

func (*Manager) AddDeviceForConn

func (this *Manager) AddDeviceForConn(addr string, nick string,
	f io.ReadWriteCloser, ci *ConnInfo) *Device

func (*Manager) ConnUpdate

func (this *Manager) ConnUpdate(device *Device, interval uint16) int

func (*Manager) ConnectTCP

func (this *Manager) ConnectTCP(addr string, nick string) error

func (*Manager) ConnectTo

func (this *Manager) ConnectTo(addrType uint8, addr string, nick string) error

func (*Manager) DisconnectFrom

func (this *Manager) DisconnectFrom(nick string) error

func (*Manager) RouteConnUpdate

func (this *Manager) RouteConnUpdate(req Request)

func (*Manager) RouteFindByTypeValue

func (this *Manager) RouteFindByTypeValue(req Request)

func (*Manager) RouteFindInfo

func (this *Manager) RouteFindInfo(req Request)

func (*Manager) RouteReadByType

func (this *Manager) RouteReadByType(req Request)

func (*Manager) RunRouter

func (this *Manager) RunRouter()

func (*Manager) Start

func (this *Manager) Start(nick string) error

func (*Manager) StartDevice

func (this *Manager) StartDevice(device *Device) error

func (*Manager) StartNoDiscover

func (this *Manager) StartNoDiscover(nick string) error

type ReadByGroupTypeResponse

type ReadByGroupTypeResponse struct {
	// contains filtered or unexported fields
}

func ParseReadByGroupTypeResponse

func ParseReadByGroupTypeResponse(msg []byte) (*ReadByGroupTypeResponse, error)

func (*ReadByGroupTypeResponse) DataList

func (this *ReadByGroupTypeResponse) DataList() []*GroupValue

func (*ReadByGroupTypeResponse) Length

func (this *ReadByGroupTypeResponse) Length() uint8

type ReadByTypeRequest

type ReadByTypeRequest struct {
	// contains filtered or unexported fields
}

func NewReadByTypeRequest

func NewReadByTypeRequest(startHandle, endHandle uint16, attType UUID) *ReadByTypeRequest

func ParseReadByTypeRequest

func ParseReadByTypeRequest(msg []byte) (*ReadByTypeRequest, error)

func (*ReadByTypeRequest) EndHandle

func (this *ReadByTypeRequest) EndHandle() uint16

func (*ReadByTypeRequest) StartHandle

func (this *ReadByTypeRequest) StartHandle() uint16

func (*ReadByTypeRequest) Type

func (this *ReadByTypeRequest) Type() UUID

type ReadByTypeResponse

type ReadByTypeResponse struct {
	// contains filtered or unexported fields
}

func NewReadByTypeResponse

func NewReadByTypeResponse(vals []*GroupValue) *ReadByTypeResponse

func ParseReadByTypeResponse

func ParseReadByTypeResponse(msg []byte) (*ReadByTypeResponse, error)

func (*ReadByTypeResponse) DataList

func (this *ReadByTypeResponse) DataList() []*HandleValue

func (*ReadByTypeResponse) Length

func (this *ReadByTypeResponse) Length() uint8

type Request

type Request struct {
	// contains filtered or unexported fields
}

type Response

type Response struct {
	// contains filtered or unexported fields
}

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

type UUID

type UUID [16]uint8
var GATT_CHARACTERISTIC_UUID UUID = [16]byte{0, 0, 0x3, 0x28, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}
var GATT_CLIENT_CONFIGURATION_UUID UUID = [16]byte{0, 0, 0x2, 0x29, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}
var GATT_PRIMARY_SERVICE_UUID UUID = [16]byte{0, 0, 0x0, 0x28, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL