Documentation ¶
Index ¶
- Constants
- func Base58ToU32(str string) (uint32, error)
- func BoolSliceToByteSlice(b []bool) []byte
- func ByteSliceToBoolSlice(b []byte) []bool
- func ByteSliceToFloat32Slice(slice []byte) []float32
- func ByteSliceToFloat64Slice(slice []byte) []float64
- func ByteSliceToInt16Slice(slice []byte) []int16
- func ByteSliceToInt32Slice(slice []byte) []int32
- func ByteSliceToInt64Slice(slice []byte) []int64
- func ByteSliceToInt8Slice(slice []byte) []int8
- func ByteSliceToRuneSlice(slice []byte) []rune
- func ByteSliceToString(slice []byte) string
- func ByteSliceToUint16Slice(slice []byte) []uint16
- func ByteSliceToUint32Slice(slice []byte) []uint32
- func ByteSliceToUint64Slice(slice []byte) []uint64
- func ByteSliceToUint8Slice(slice []byte) []uint8
- func Connect(addr string) (net.Conn, error)
- func FixedSliceToByteSlice(slice []interface{}) []byte
- func Int16SliceToByteSlice(slice []int16) []byte
- func Int8SliceToByteSlice(slice []int8) []byte
- func Min(left, right int64) int64
- func MinU(left, right uint64) uint64
- func ReqWithTimeout(packet []byte, reqTX chan<- Request) ([]byte, error)
- func RuneSliceToByteSlice(slice []rune) []byte
- func StringToByteSlice(str string, maxLen uint64) ([]byte, error)
- func Uint16SliceToByteSlice(slice []uint16) []byte
- func Uint64SliceToByteSlice(slice []uint64) []byte
- func Uint8SliceToByteSlice(slice []uint8) []byte
- type BrickletErrordeprecated
- type CallbackContainer
- type CallbackDeregistration
- type CallbackRegistration
- type ConnectCallbackContainer
- type ConnectCallbackRegistration
- type ConnectReason
- type ConnectionState
- type Device
- func (device *Device) DeregisterCallback(functionID uint8, registrationID uint64)
- func (device *Device) Get(functionID uint8, payload []byte) ([]byte, error)
- func (device *Device) GetAPIVersion() [3]uint8
- func (device *Device) GetHighLevel(lowLevelClosure func() (LowLevelResult, error), highLevelFunctionIdx uint8, ...) ([]byte, []byte, error)
- func (device *Device) GetResponseExpected(functionID uint8) (bool, error)
- func (device *Device) RegisterCallback(functionID uint8, fn func([]byte)) uint64
- func (device *Device) Set(functionID uint8, payload []byte) ([]byte, error)
- func (device *Device) SetHighLevel(lowLevelClosure func(uint64, uint64, []byte) (LowLevelWriteResult, error), ...) (LowLevelWriteResult, error)
- func (device *Device) SetResponseExpected(functionID uint8, responseExpected bool) error
- func (device *Device) SetResponseExpectedAll(responseExpected bool)
- type DeviceError
- type DisconnectCallbackContainer
- type DisconnectCallbackRegistration
- type DisconnectReason
- type EnumerationType
- type IPConCallbackDeregistration
- type IPConnection
- func (ipcon *IPConnection) Authenticate(secret string) error
- func (ipcon *IPConnection) Close()
- func (ipcon *IPConnection) Connect(addr string) error
- func (ipcon *IPConnection) DeregisterConnectCallback(registrationID uint64)
- func (ipcon *IPConnection) DeregisterDisconnectCallback(registrationID uint64)
- func (ipcon *IPConnection) DeregisterEnumerateCallback(registrationID uint64)
- func (ipcon *IPConnection) Disconnect()
- func (ipcon *IPConnection) Enumerate()
- func (ipcon *IPConnection) GetAutoReconnect() bool
- func (ipcon *IPConnection) GetConnectionState() ConnectionState
- func (ipcon *IPConnection) GetTimeout() time.Duration
- func (ipcon *IPConnection) RegisterConnectCallback(fn func(uint8)) uint64
- func (ipcon *IPConnection) RegisterDisconnectCallback(fn func(uint8)) uint64
- func (ipcon *IPConnection) RegisterEnumerateCallback(fn func([]byte)) uint64
- func (ipcon *IPConnection) SetAutoReconnect(autoReconnectEnabled bool)
- func (ipcon *IPConnection) SetTimeout(timeout time.Duration)
- type LowLevelResult
- type LowLevelWriteResult
- type PacketHeader
- type Request
- type ResponseExpectedFlag
- type TimeoutStruct
Constants ¶
View Source
const ChannelSize uint64 = 1 << 16
View Source
const PacketHeaderSeqNumOffset = 6
View Source
const PacketHeaderSize = 8
Variables ¶
This section is empty.
Functions ¶
func Base58ToU32 ¶
func BoolSliceToByteSlice ¶
func ByteSliceToBoolSlice ¶
func ByteSliceToFloat32Slice ¶
func ByteSliceToFloat64Slice ¶
func ByteSliceToInt16Slice ¶
func ByteSliceToInt32Slice ¶
func ByteSliceToInt64Slice ¶
func ByteSliceToInt8Slice ¶
func ByteSliceToRuneSlice ¶
func ByteSliceToString ¶
func ByteSliceToUint16Slice ¶
func ByteSliceToUint32Slice ¶
func ByteSliceToUint64Slice ¶
func ByteSliceToUint8Slice ¶
func FixedSliceToByteSlice ¶
func FixedSliceToByteSlice(slice []interface{}) []byte
func Int16SliceToByteSlice ¶
func Int8SliceToByteSlice ¶
func RuneSliceToByteSlice ¶
func Uint16SliceToByteSlice ¶
func Uint64SliceToByteSlice ¶
func Uint8SliceToByteSlice ¶
Types ¶
type BrickletError
deprecated
type BrickletError = DeviceError
Deprecated: BrickletError exists for historical compatibility. Use DeviceError instead.
type CallbackContainer ¶
type CallbackDeregistration ¶
type CallbackRegistration ¶
type ConnectReason ¶
type ConnectReason = uint8
const ( ConnectReasonRequest ConnectReason = iota ConnectReasonAutoReconnect )
type ConnectionState ¶
type ConnectionState = uint8
const ( ConnectionStateDisconnected ConnectionState = iota ConnectionStateConnected ConnectionStatePending )
type Device ¶
type Device struct { ResponseExpected [256]ResponseExpectedFlag UID string // contains filtered or unexported fields }
func (*Device) DeregisterCallback ¶
func (*Device) GetAPIVersion ¶
func (*Device) GetHighLevel ¶
func (*Device) GetResponseExpected ¶
func (*Device) RegisterCallback ¶
func (*Device) SetHighLevel ¶
func (*Device) SetResponseExpected ¶
func (*Device) SetResponseExpectedAll ¶
type DeviceError ¶
type DeviceError uint8
const ( //Deprecated: BrickletErrorSuccess exists for historical compatibility. Use DeviceErrorSuccess instead. BrickletErrorSuccess DeviceError = 0 //Deprecated: BrickletErrorInvalidParameter exists for historical compatibility. Use DeviceErrorInvalidParameter instead. BrickletErrorInvalidParameter DeviceError = 1 //Deprecated: BrickletErrorFunctionNotSupported exists for historical compatibility. Use DeviceErrorFunctionNotSupported instead. BrickletErrorFunctionNotSupported DeviceError = 2 //Deprecated: BrickletErrorUnknownError exists for historical compatibility. Use DeviceErrorUnknownError instead. BrickletErrorUnknownError DeviceError = 3 DeviceErrorSuccess DeviceError = 0 DeviceErrorInvalidParameter DeviceError = 1 DeviceErrorFunctionNotSupported DeviceError = 2 DeviceErrorUnknownError DeviceError = 3 )
func (DeviceError) Error ¶
func (e DeviceError) Error() string
type DisconnectReason ¶
type DisconnectReason = uint8
const ( DisconnectReasonRequest DisconnectReason = iota DisconnectReasonError DisconnectReasonShutdown )
type EnumerationType ¶
type EnumerationType = uint8
const ( EnumerationTypeAvailable EnumerationType = iota EnumerationTypeConnected EnumerationTypeDisconnected )
type IPConCallbackDeregistration ¶
type IPConCallbackDeregistration struct {
RegistrationID uint64
}
type IPConnection ¶
type IPConnection struct { Req chan Request CallbackReg chan CallbackRegistration CallbackDereg chan CallbackDeregistration // contains filtered or unexported fields }
func NewIPConnection ¶
func NewIPConnection() IPConnection
func (*IPConnection) Authenticate ¶
func (ipcon *IPConnection) Authenticate(secret string) error
func (*IPConnection) Close ¶
func (ipcon *IPConnection) Close()
func (*IPConnection) Connect ¶
func (ipcon *IPConnection) Connect(addr string) error
func (*IPConnection) DeregisterConnectCallback ¶
func (ipcon *IPConnection) DeregisterConnectCallback(registrationID uint64)
func (*IPConnection) DeregisterDisconnectCallback ¶
func (ipcon *IPConnection) DeregisterDisconnectCallback(registrationID uint64)
func (*IPConnection) DeregisterEnumerateCallback ¶
func (ipcon *IPConnection) DeregisterEnumerateCallback(registrationID uint64)
func (*IPConnection) Disconnect ¶
func (ipcon *IPConnection) Disconnect()
func (*IPConnection) Enumerate ¶
func (ipcon *IPConnection) Enumerate()
func (*IPConnection) GetAutoReconnect ¶
func (ipcon *IPConnection) GetAutoReconnect() bool
func (*IPConnection) GetConnectionState ¶
func (ipcon *IPConnection) GetConnectionState() ConnectionState
func (*IPConnection) GetTimeout ¶
func (ipcon *IPConnection) GetTimeout() time.Duration
func (*IPConnection) RegisterConnectCallback ¶
func (ipcon *IPConnection) RegisterConnectCallback(fn func(uint8)) uint64
func (*IPConnection) RegisterDisconnectCallback ¶
func (ipcon *IPConnection) RegisterDisconnectCallback(fn func(uint8)) uint64
func (*IPConnection) RegisterEnumerateCallback ¶
func (ipcon *IPConnection) RegisterEnumerateCallback(fn func([]byte)) uint64
func (*IPConnection) SetAutoReconnect ¶
func (ipcon *IPConnection) SetAutoReconnect(autoReconnectEnabled bool)
func (*IPConnection) SetTimeout ¶
func (ipcon *IPConnection) SetTimeout(timeout time.Duration)
type LowLevelResult ¶
type LowLevelWriteResult ¶
type PacketHeader ¶
type PacketHeader struct { UID uint32 Length uint8 FunctionID uint8 SequenceNumber uint8 ResponseExpected bool ErrorCode uint8 }
func (*PacketHeader) FillFromBytes ¶
func (header *PacketHeader) FillFromBytes(bytes []byte)
func (PacketHeader) ToLeBytes ¶
func (header PacketHeader) ToLeBytes() []byte
type ResponseExpectedFlag ¶
type ResponseExpectedFlag = uint8
const ( ResponseExpectedFlagInvalidFunctionID ResponseExpectedFlag = iota ResponseExpectedFlagFalse ResponseExpectedFlagTrue ResponseExpectedFlagAlwaysTrue )
type TimeoutStruct ¶
type TimeoutStruct struct {
// contains filtered or unexported fields
}
The IPConnection gets moved when returning from NewIPConnection(), so it only stores pointers to timeout and autoReconnect, as they are also shared to the socket thread. To ensure that the timeout is 64 bit aligned on 32 bit systems, allocate it in a separate struct.
Click to show internal directories.
Click to hide internal directories.