Documentation ¶
Index ¶
- Variables
- func EncodeMessage(msg Message) ([]byte, error)
- type CommandType
- type DeviceModel
- type Height
- type Message
- type MessageACK
- type MessageCommand
- type MessageDeviceInfo
- type MessageEndWorkout
- type MessageErrorCode
- type MessageHeartRate
- type MessageHeartRateType
- type MessageIncline
- type MessageLevel
- type MessageListener
- type MessageMaxIncline
- type MessageMaxLevel
- type MessageMaxSpeed
- type MessageProgram
- type MessageProgramGraphics
- type MessageRPM
- type MessageSetWorkoutMode
- type MessageSpeed
- type MessageTargetHeartRate
- type MessageType
- type MessageUserIncline
- type MessageUserLevel
- type MessageUserProfile
- type MessageWorkoutData
- type MessageWorkoutMode
- type MessageWorkoutTarget
- type Program
- type SexType
- type Speed
- type Treadmill
- func (t *Treadmill) AddListener(listener MessageListener)
- func (t *Treadmill) Close() error
- func (t *Treadmill) Connect(ctx context.Context) error
- func (t *Treadmill) GetDeviceInfo() (*MessageDeviceInfo, error)
- func (t *Treadmill) LevelUp() error
- func (t *Treadmill) SetMaxIncline(maxIncline byte) error
- func (t *Treadmill) SetProgram(program Program) error
- func (t *Treadmill) SetUserProfile(sex SexType, age byte, weight Weight, height Height) error
- func (t *Treadmill) SetWorkoutMode(mode WorkoutMode) error
- func (t *Treadmill) SetWorkoutTime(tm time.Duration) error
- func (t *Treadmill) Start() error
- func (t *Treadmill) WaitForResponse(ctx context.Context, msgType MessageType) (Message, error)
- type UnitsType
- type Weight
- type WorkoutMode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingCharacteristic = fmt.Errorf("missing expected characteristic") ErrMissingDescriptor = fmt.Errorf("missing expected descriptor") ErrMissingService = fmt.Errorf("missing expected service") ErrInvalidReadPayload = fmt.Errorf("unexpected data from device") ErrAckTimeout = fmt.Errorf("failed to get acknowledgement from device") )
View Source
var ErrInvalidMessage = fmt.Errorf("invalid message")
Functions ¶
func EncodeMessage ¶
Types ¶
type CommandType ¶
type CommandType byte
const ( CommandTypeStart CommandType = 0x01 CommandTypeLevelUp CommandType = 0x02 CommandTypeLevelDown CommandType = 0x03 CommandTypeStop CommandType = 0x06 )
func (CommandType) String ¶
func (ct CommandType) String() string
type DeviceModel ¶
type DeviceModel byte
const (
DeviceModelF80 DeviceModel = 146
)
func (DeviceModel) String ¶
func (dm DeviceModel) String() string
type Message ¶
type Message interface { MessageType() MessageType MarshalBinary() ([]byte, error) UnmarshalBinary([]byte) error ExpectedLength() int String() string }
func ParseMessage ¶
type MessageACK ¶
type MessageACK struct {
Acknowledged MessageType
}
func (*MessageACK) ExpectedLength ¶
func (ack *MessageACK) ExpectedLength() int
func (*MessageACK) MarshalBinary ¶
func (ack *MessageACK) MarshalBinary() ([]byte, error)
func (*MessageACK) MessageType ¶
func (ack *MessageACK) MessageType() MessageType
func (*MessageACK) String ¶
func (ack *MessageACK) String() string
func (*MessageACK) UnmarshalBinary ¶
func (ack *MessageACK) UnmarshalBinary(data []byte) error
type MessageCommand ¶
type MessageCommand struct {
Command CommandType
}
func (*MessageCommand) ExpectedLength ¶
func (e *MessageCommand) ExpectedLength() int
func (*MessageCommand) MarshalBinary ¶
func (e *MessageCommand) MarshalBinary() ([]byte, error)
func (*MessageCommand) MessageType ¶
func (e *MessageCommand) MessageType() MessageType
func (*MessageCommand) String ¶
func (e *MessageCommand) String() string
func (*MessageCommand) UnmarshalBinary ¶
func (e *MessageCommand) UnmarshalBinary(data []byte) error
type MessageDeviceInfo ¶
type MessageDeviceInfo struct { Model DeviceModel Version byte Units UnitsType MaxSpeed Speed MinSpeed Speed InclineMax byte UserSegment byte }
func (*MessageDeviceInfo) ExpectedLength ¶
func (di *MessageDeviceInfo) ExpectedLength() int
func (*MessageDeviceInfo) MarshalBinary ¶
func (di *MessageDeviceInfo) MarshalBinary() ([]byte, error)
func (*MessageDeviceInfo) MessageType ¶
func (di *MessageDeviceInfo) MessageType() MessageType
func (*MessageDeviceInfo) String ¶
func (di *MessageDeviceInfo) String() string
func (*MessageDeviceInfo) UnmarshalBinary ¶
func (di *MessageDeviceInfo) UnmarshalBinary(data []byte) error
type MessageEndWorkout ¶
type MessageEndWorkout struct { Seconds uint16 Distance uint16 Calories uint16 Speed Speed HeartRate byte Incline byte }
func (*MessageEndWorkout) ExpectedLength ¶
func (e *MessageEndWorkout) ExpectedLength() int
func (*MessageEndWorkout) MarshalBinary ¶
func (e *MessageEndWorkout) MarshalBinary() ([]byte, error)
func (*MessageEndWorkout) MessageType ¶
func (e *MessageEndWorkout) MessageType() MessageType
func (*MessageEndWorkout) String ¶
func (e *MessageEndWorkout) String() string
func (*MessageEndWorkout) UnmarshalBinary ¶
func (e *MessageEndWorkout) UnmarshalBinary(data []byte) error
type MessageErrorCode ¶
type MessageErrorCode struct {
Code byte
}
func (*MessageErrorCode) ExpectedLength ¶
func (e *MessageErrorCode) ExpectedLength() int
func (*MessageErrorCode) MarshalBinary ¶
func (e *MessageErrorCode) MarshalBinary() ([]byte, error)
func (*MessageErrorCode) MessageType ¶
func (e *MessageErrorCode) MessageType() MessageType
func (*MessageErrorCode) String ¶
func (e *MessageErrorCode) String() string
func (*MessageErrorCode) UnmarshalBinary ¶
func (e *MessageErrorCode) UnmarshalBinary(data []byte) error
type MessageHeartRate ¶
type MessageHeartRate struct {
HeartRate byte
}
func (*MessageHeartRate) ExpectedLength ¶
func (e *MessageHeartRate) ExpectedLength() int
func (*MessageHeartRate) MarshalBinary ¶
func (e *MessageHeartRate) MarshalBinary() ([]byte, error)
func (*MessageHeartRate) MessageType ¶
func (e *MessageHeartRate) MessageType() MessageType
func (*MessageHeartRate) String ¶
func (e *MessageHeartRate) String() string
func (*MessageHeartRate) UnmarshalBinary ¶
func (e *MessageHeartRate) UnmarshalBinary(data []byte) error
type MessageHeartRateType ¶
func (*MessageHeartRateType) ExpectedLength ¶
func (hr *MessageHeartRateType) ExpectedLength() int
func (*MessageHeartRateType) MarshalBinary ¶
func (hr *MessageHeartRateType) MarshalBinary() ([]byte, error)
func (*MessageHeartRateType) MessageType ¶
func (hr *MessageHeartRateType) MessageType() MessageType
func (*MessageHeartRateType) String ¶
func (hr *MessageHeartRateType) String() string
func (*MessageHeartRateType) UnmarshalBinary ¶
func (hr *MessageHeartRateType) UnmarshalBinary(data []byte) error
type MessageIncline ¶
type MessageIncline struct {
Incline byte
}
func (*MessageIncline) ExpectedLength ¶
func (e *MessageIncline) ExpectedLength() int
func (*MessageIncline) MarshalBinary ¶
func (e *MessageIncline) MarshalBinary() ([]byte, error)
func (*MessageIncline) MessageType ¶
func (e *MessageIncline) MessageType() MessageType
func (*MessageIncline) String ¶
func (e *MessageIncline) String() string
func (*MessageIncline) UnmarshalBinary ¶
func (e *MessageIncline) UnmarshalBinary(data []byte) error
type MessageLevel ¶
type MessageLevel struct {
Level byte
}
func (*MessageLevel) ExpectedLength ¶
func (e *MessageLevel) ExpectedLength() int
func (*MessageLevel) MarshalBinary ¶
func (e *MessageLevel) MarshalBinary() ([]byte, error)
func (*MessageLevel) MessageType ¶
func (e *MessageLevel) MessageType() MessageType
func (*MessageLevel) String ¶
func (e *MessageLevel) String() string
func (*MessageLevel) UnmarshalBinary ¶
func (e *MessageLevel) UnmarshalBinary(data []byte) error
type MessageListener ¶
type MessageMaxIncline ¶
type MessageMaxIncline struct {
MaxIncline byte
}
func (*MessageMaxIncline) ExpectedLength ¶
func (mi *MessageMaxIncline) ExpectedLength() int
func (*MessageMaxIncline) MarshalBinary ¶
func (mi *MessageMaxIncline) MarshalBinary() ([]byte, error)
func (*MessageMaxIncline) MessageType ¶
func (mi *MessageMaxIncline) MessageType() MessageType
func (*MessageMaxIncline) String ¶
func (mi *MessageMaxIncline) String() string
func (*MessageMaxIncline) UnmarshalBinary ¶
func (mi *MessageMaxIncline) UnmarshalBinary(data []byte) error
type MessageMaxLevel ¶
type MessageMaxLevel struct {
Level byte
}
func (*MessageMaxLevel) ExpectedLength ¶
func (e *MessageMaxLevel) ExpectedLength() int
func (*MessageMaxLevel) MarshalBinary ¶
func (e *MessageMaxLevel) MarshalBinary() ([]byte, error)
func (*MessageMaxLevel) MessageType ¶
func (e *MessageMaxLevel) MessageType() MessageType
func (*MessageMaxLevel) String ¶
func (e *MessageMaxLevel) String() string
func (*MessageMaxLevel) UnmarshalBinary ¶
func (e *MessageMaxLevel) UnmarshalBinary(data []byte) error
type MessageMaxSpeed ¶
type MessageMaxSpeed struct {
Speed Speed
}
func (*MessageMaxSpeed) ExpectedLength ¶
func (e *MessageMaxSpeed) ExpectedLength() int
func (*MessageMaxSpeed) MarshalBinary ¶
func (e *MessageMaxSpeed) MarshalBinary() ([]byte, error)
func (*MessageMaxSpeed) MessageType ¶
func (e *MessageMaxSpeed) MessageType() MessageType
func (*MessageMaxSpeed) String ¶
func (e *MessageMaxSpeed) String() string
func (*MessageMaxSpeed) UnmarshalBinary ¶
func (e *MessageMaxSpeed) UnmarshalBinary(data []byte) error
type MessageProgram ¶
type MessageProgram struct {
Program Program
}
func (*MessageProgram) ExpectedLength ¶
func (e *MessageProgram) ExpectedLength() int
func (*MessageProgram) MarshalBinary ¶
func (e *MessageProgram) MarshalBinary() ([]byte, error)
func (*MessageProgram) MessageType ¶
func (e *MessageProgram) MessageType() MessageType
func (*MessageProgram) String ¶
func (e *MessageProgram) String() string
func (*MessageProgram) UnmarshalBinary ¶
func (e *MessageProgram) UnmarshalBinary(data []byte) error
type MessageProgramGraphics ¶
type MessageProgramGraphics struct {
Graph [18]byte
}
func (*MessageProgramGraphics) ExpectedLength ¶
func (e *MessageProgramGraphics) ExpectedLength() int
func (*MessageProgramGraphics) MarshalBinary ¶
func (e *MessageProgramGraphics) MarshalBinary() ([]byte, error)
func (*MessageProgramGraphics) MessageType ¶
func (e *MessageProgramGraphics) MessageType() MessageType
func (*MessageProgramGraphics) String ¶
func (e *MessageProgramGraphics) String() string
func (*MessageProgramGraphics) UnmarshalBinary ¶
func (e *MessageProgramGraphics) UnmarshalBinary(data []byte) error
type MessageRPM ¶
type MessageRPM struct {
RPM byte
}
func (*MessageRPM) ExpectedLength ¶
func (e *MessageRPM) ExpectedLength() int
func (*MessageRPM) MarshalBinary ¶
func (e *MessageRPM) MarshalBinary() ([]byte, error)
func (*MessageRPM) MessageType ¶
func (e *MessageRPM) MessageType() MessageType
func (*MessageRPM) String ¶
func (e *MessageRPM) String() string
func (*MessageRPM) UnmarshalBinary ¶
func (e *MessageRPM) UnmarshalBinary(data []byte) error
type MessageSetWorkoutMode ¶
type MessageSetWorkoutMode struct {
Mode WorkoutMode
}
func (*MessageSetWorkoutMode) ExpectedLength ¶
func (wm *MessageSetWorkoutMode) ExpectedLength() int
func (*MessageSetWorkoutMode) MarshalBinary ¶
func (wm *MessageSetWorkoutMode) MarshalBinary() ([]byte, error)
func (*MessageSetWorkoutMode) MessageType ¶
func (wm *MessageSetWorkoutMode) MessageType() MessageType
func (*MessageSetWorkoutMode) String ¶
func (wm *MessageSetWorkoutMode) String() string
func (*MessageSetWorkoutMode) UnmarshalBinary ¶
func (wm *MessageSetWorkoutMode) UnmarshalBinary(data []byte) error
type MessageSpeed ¶
type MessageSpeed struct {
Speed Speed
}
func (*MessageSpeed) ExpectedLength ¶
func (e *MessageSpeed) ExpectedLength() int
func (*MessageSpeed) MarshalBinary ¶
func (e *MessageSpeed) MarshalBinary() ([]byte, error)
func (*MessageSpeed) MessageType ¶
func (e *MessageSpeed) MessageType() MessageType
func (*MessageSpeed) String ¶
func (e *MessageSpeed) String() string
func (*MessageSpeed) UnmarshalBinary ¶
func (e *MessageSpeed) UnmarshalBinary(data []byte) error
type MessageTargetHeartRate ¶
type MessageTargetHeartRate struct {
HeartRate byte
}
func (*MessageTargetHeartRate) ExpectedLength ¶
func (e *MessageTargetHeartRate) ExpectedLength() int
func (*MessageTargetHeartRate) MarshalBinary ¶
func (e *MessageTargetHeartRate) MarshalBinary() ([]byte, error)
func (*MessageTargetHeartRate) MessageType ¶
func (e *MessageTargetHeartRate) MessageType() MessageType
func (*MessageTargetHeartRate) String ¶
func (e *MessageTargetHeartRate) String() string
func (*MessageTargetHeartRate) UnmarshalBinary ¶
func (e *MessageTargetHeartRate) UnmarshalBinary(data []byte) error
type MessageType ¶
type MessageType byte
const ( MessageTypeACK MessageType = 0x00 MessageTypeSetWorkoutMode MessageType = 0x02 MessageTypeWorkoutMode MessageType = 0x03 MessageTypeWorkoutTarget MessageType = 0x04 MessageTypeWorkoutData MessageType = 0x06 MessageTypeUserProfile MessageType = 0x07 MessageTypeProgram MessageType = 0x08 MessageTypeHeartRateType MessageType = 0x09 MessageTypeErrorCode MessageType = 0x10 MessageTypeSpeed MessageType = 0x11 MessageTypeIncline MessageType = 0x12 MessageTypeLevel MessageType = 0x13 MessageTypeRPM MessageType = 0x14 MessageTypeHeartRate MessageType = 0x15 MessageTypeTargetHeartRate MessageType = 0x20 MessageTypeMaxSpeed MessageType = 0x21 MessageTypeMaxIncline MessageType = 0x22 MessageTypeMaxLevel MessageType = 0x23 MessageTypeUserIncline MessageType = 0x25 MessageTypeUserLevel MessageType = 0x27 MessageTypeEndWorkout MessageType = 0x32 MessageTypeProgramGraphics MessageType = 0x40 MessageTypeDeviceInfo MessageType = 0xf0 MessageTypeCommand MessageType = 0xf1 MessageTypeUnknown MessageType = 0xff )
func (MessageType) Create ¶
func (mt MessageType) Create() Message
func (MessageType) String ¶
func (mt MessageType) String() string
type MessageUserIncline ¶
type MessageUserIncline struct {
Incline byte
}
func (*MessageUserIncline) ExpectedLength ¶
func (e *MessageUserIncline) ExpectedLength() int
func (*MessageUserIncline) MarshalBinary ¶
func (e *MessageUserIncline) MarshalBinary() ([]byte, error)
func (*MessageUserIncline) MessageType ¶
func (e *MessageUserIncline) MessageType() MessageType
func (*MessageUserIncline) String ¶
func (e *MessageUserIncline) String() string
func (*MessageUserIncline) UnmarshalBinary ¶
func (e *MessageUserIncline) UnmarshalBinary(data []byte) error
type MessageUserLevel ¶
type MessageUserLevel struct {
Level byte
}
func (*MessageUserLevel) ExpectedLength ¶
func (e *MessageUserLevel) ExpectedLength() int
func (*MessageUserLevel) MarshalBinary ¶
func (e *MessageUserLevel) MarshalBinary() ([]byte, error)
func (*MessageUserLevel) MessageType ¶
func (e *MessageUserLevel) MessageType() MessageType
func (*MessageUserLevel) String ¶
func (e *MessageUserLevel) String() string
func (*MessageUserLevel) UnmarshalBinary ¶
func (e *MessageUserLevel) UnmarshalBinary(data []byte) error
type MessageUserProfile ¶
func (*MessageUserProfile) ExpectedLength ¶
func (p *MessageUserProfile) ExpectedLength() int
func (*MessageUserProfile) MarshalBinary ¶
func (p *MessageUserProfile) MarshalBinary() ([]byte, error)
func (*MessageUserProfile) MessageType ¶
func (p *MessageUserProfile) MessageType() MessageType
func (*MessageUserProfile) String ¶
func (p *MessageUserProfile) String() string
func (*MessageUserProfile) UnmarshalBinary ¶
func (p *MessageUserProfile) UnmarshalBinary(data []byte) error
type MessageWorkoutData ¶
type MessageWorkoutData struct { Minute byte Second byte Distance uint16 Calories uint16 HeartRate byte Speed Speed Incline byte HRType byte IntervalTime byte RecoveryTime byte ProgramRow byte ProgramColumn byte }
func (*MessageWorkoutData) ExpectedLength ¶
func (wd *MessageWorkoutData) ExpectedLength() int
func (*MessageWorkoutData) MarshalBinary ¶
func (wd *MessageWorkoutData) MarshalBinary() ([]byte, error)
func (*MessageWorkoutData) MessageType ¶
func (wd *MessageWorkoutData) MessageType() MessageType
func (*MessageWorkoutData) String ¶
func (wd *MessageWorkoutData) String() string
func (*MessageWorkoutData) UnmarshalBinary ¶
func (wd *MessageWorkoutData) UnmarshalBinary(data []byte) error
type MessageWorkoutMode ¶
type MessageWorkoutMode struct {
Mode WorkoutMode
}
func (*MessageWorkoutMode) ExpectedLength ¶
func (wm *MessageWorkoutMode) ExpectedLength() int
func (*MessageWorkoutMode) MarshalBinary ¶
func (wm *MessageWorkoutMode) MarshalBinary() ([]byte, error)
func (*MessageWorkoutMode) MessageType ¶
func (wm *MessageWorkoutMode) MessageType() MessageType
func (*MessageWorkoutMode) String ¶
func (wm *MessageWorkoutMode) String() string
func (*MessageWorkoutMode) UnmarshalBinary ¶
func (wm *MessageWorkoutMode) UnmarshalBinary(data []byte) error
type MessageWorkoutTarget ¶
func (*MessageWorkoutTarget) ExpectedLength ¶
func (wt *MessageWorkoutTarget) ExpectedLength() int
func (*MessageWorkoutTarget) MarshalBinary ¶
func (wt *MessageWorkoutTarget) MarshalBinary() ([]byte, error)
func (*MessageWorkoutTarget) MessageType ¶
func (wt *MessageWorkoutTarget) MessageType() MessageType
func (*MessageWorkoutTarget) String ¶
func (wt *MessageWorkoutTarget) String() string
func (*MessageWorkoutTarget) UnmarshalBinary ¶
func (wt *MessageWorkoutTarget) UnmarshalBinary(data []byte) error
type Program ¶
type Program uint16
const ( ProgramManual Program = 0x1001 //0x10 0x01 ProgramHill Program = 0x2002 //0x20 0x02 ProgramFatBurn Program = 0x2003 //0x20 0x03 ProgramCardio Program = 0x2004 //0x20 0x04 ProgramStrength Program = 0x2005 //0x20 0x05 ProgramInterval Program = 0x2006 //0x20 0x06 ProgramHR1 Program = 0x3009 //0x30 0x09 ProgramHR2 Program = 0x300a //0x30 0x0a ProgramUser1 Program = 0x3007 //0x30 0x07 ProgramUser2 Program = 0x3008 //0x30 0x08 ProgramFusion Program = 0x600c //0x60 0x0c )
type Treadmill ¶
type Treadmill struct {
// contains filtered or unexported fields
}
func (*Treadmill) AddListener ¶
func (t *Treadmill) AddListener(listener MessageListener)
func (*Treadmill) GetDeviceInfo ¶
func (t *Treadmill) GetDeviceInfo() (*MessageDeviceInfo, error)
func (*Treadmill) SetMaxIncline ¶
func (*Treadmill) SetProgram ¶
func (*Treadmill) SetUserProfile ¶
func (*Treadmill) SetWorkoutMode ¶
func (t *Treadmill) SetWorkoutMode(mode WorkoutMode) error
func (*Treadmill) WaitForResponse ¶
type WorkoutMode ¶
type WorkoutMode byte
const ( WorkoutModeIdle WorkoutMode = 0x01 WorkoutModeStart WorkoutMode = 0x02 WorkoutModeRunning WorkoutMode = 0x04 WorkoutModePause WorkoutMode = 0x06 WorkoutModeDone WorkoutMode = 0x07 )
func (WorkoutMode) String ¶
func (wm WorkoutMode) String() string
Click to show internal directories.
Click to hide internal directories.