message

package
v0.0.0-...-d7543ea Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MESSAGE_TX_SYNC      = 0xA4
	MESSAGE_SYSTEM_RESET = 0x4A
	MESSAGE_STARTUP      = 0x6F
	MESSAGE_NETWORK_KEY  = 0x46
	ANTPLUS_NETWORK_KEY  = "\xB9\xA5\x21\xFB\xBD\x72\xC3\x45"
	OPEN_RX_SCAN_MODE    = 0x5B

	MESSAGE_CHANNEL_ASSIGN    = 0x42
	MESSAGE_CHANNEL_ID        = 0x51
	MESSAGE_CHANNEL_FREQUENCY = 0x45
	MESSAGE_CHANNEL_OPEN      = 0x4B
	MESSAGE_CHANNEL_CLOSE     = 0x4C

	MESSAGE_ENABLE_EXT_RX_MESSAGES = 0x66
	MESSAGE_LIB_CONFIG             = 0x6E

	// Extended message flags
	EXT_FLAG_CHANNEL_ID = 0x80
	EXT_FLAG_RSSI       = 0x40
	EXT_FLAG_TIMESTAMP  = 0x20

	CHANNEL_TYPE_TWOWAY_RECEIVE  = 0x00
	CHANNEL_TYPE_TWOWAY_TRANSMIT = 0x10
	CHANNEL_TYPE_SHARED_RECEIVE  = 0x20
	CHANNEL_TYPE_SHARED_TRANSMIT = 0x30
	CHANNEL_TYPE_ONEWAY_RECEIVE  = 0x40
	CHANNEL_TYPE_ONEWAY_TRANSMIT = 0x50
)
View Source
const (
	DEVICE_TYPE_SPEED_AND_CADENCE = 0x79
	DEVICE_TYPE_POWER             = 0x0B
)
View Source
const (
	MESSAGE_TYPE_BROADCAST = 0x4E
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AntBroadcastMessage

type AntBroadcastMessage AntPacket

func (AntBroadcastMessage) Channel

func (p AntBroadcastMessage) Channel() uint8

func (AntBroadcastMessage) Content

func (p AntBroadcastMessage) Content() []byte

func (AntBroadcastMessage) DeviceNumber

func (p AntBroadcastMessage) DeviceNumber() (num uint16)

func (AntBroadcastMessage) DeviceType

func (p AntBroadcastMessage) DeviceType() byte

func (AntBroadcastMessage) ExtendedContent

func (p AntBroadcastMessage) ExtendedContent() []byte

func (AntBroadcastMessage) ExtendedFlag

func (p AntBroadcastMessage) ExtendedFlag() byte

func (AntBroadcastMessage) RssiInfo

func (p AntBroadcastMessage) RssiInfo() Rssi

func (AntBroadcastMessage) RxTimestamp

func (p AntBroadcastMessage) RxTimestamp() (ts uint16)

func (AntBroadcastMessage) String

func (p AntBroadcastMessage) String() string

func (AntBroadcastMessage) TransmissionType

func (p AntBroadcastMessage) TransmissionType() byte

type AntPacket

type AntPacket []byte

func AssignChannelMessage

func AssignChannelMessage(channel uint8, typ byte) AntPacket

func CloseChannelMessage

func CloseChannelMessage(channel uint8) AntPacket

func EnableExtendedMessagesMessage

func EnableExtendedMessagesMessage(enable bool) AntPacket

func LibConfigMessage

func LibConfigMessage(rxTimestamp, rssi, channelId bool) AntPacket

func OpenChannelMessage

func OpenChannelMessage(channel uint8) AntPacket

func OpenRxScanModeMessage

func OpenRxScanModeMessage() AntPacket

func SetChannelIdMessage

func SetChannelIdMessage(channel uint8) AntPacket

func SetChannelRfFrequencyMessage

func SetChannelRfFrequencyMessage(channel uint8, freq uint16) AntPacket

func SetNetworkKeyMessage

func SetNetworkKeyMessage(channel uint8, key []byte) AntPacket

func SystemResetMessage

func SystemResetMessage() AntPacket

func (AntPacket) CalculateChecksum

func (p AntPacket) CalculateChecksum() (chk byte)

func (AntPacket) Class

func (p AntPacket) Class() byte

func (AntPacket) Data

func (p AntPacket) Data() []byte

func (AntPacket) RawHexString

func (p AntPacket) RawHexString() (s string)

func (AntPacket) RawString

func (p AntPacket) RawString() (s string)

func (AntPacket) String

func (p AntPacket) String() (s string)

func (AntPacket) Valid

func (p AntPacket) Valid() bool

type PowerMessage

type PowerMessage AntBroadcastMessage

func (PowerMessage) AccumulatedPower

func (m PowerMessage) AccumulatedPower() (num uint16)

Accumulated power is the running sum of the instantaneous power data and is incremented at each update of the update event count. (W)

func (PowerMessage) AveragePower

func (m PowerMessage) AveragePower(prev PowerMessage) float32

Under normal conditions with complete RF reception, average power equals instantaneous power. In conditions where packets are lost, average power accurately calculates power over the interval between the received messages. (W)

func (PowerMessage) DataPageNumber

func (m PowerMessage) DataPageNumber() uint8

The specifies the type of message sent by the power sensor Currently we only decode the standard Power-Only main data page (0x10)

func (PowerMessage) EventCount

func (m PowerMessage) EventCount() uint8

The update event count field is incremented each time the information in the message is updated. There are no invalid values for update event count.

func (PowerMessage) InstantaneousCadence

func (m PowerMessage) InstantaneousCadence() uint8

The instantaneous cadence field is used to transmit the pedaling cadence recorded from the power sensor. This field is an instantaneous value only; it does not accumulate between messages. (RPM)

func (PowerMessage) InstantaneousPower

func (m PowerMessage) InstantaneousPower() (num uint16)

Instantaneous power measurement (W)

func (PowerMessage) String

func (m PowerMessage) String() (s string)

type Rssi

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

func (Rssi) Value

func (r Rssi) Value() (v int8)

type SpeedAndCadenceMessage

type SpeedAndCadenceMessage AntBroadcastMessage

func (SpeedAndCadenceMessage) Cadence

func (m SpeedAndCadenceMessage) Cadence(prev SpeedAndCadenceMessage) (cadence float32, nochange bool)

Returns the cadence calculated from the previous message (0 if previous message is nil) The second parameter "nochange" indicates that the EventTime counter has not changed since the previous message, which means a complete rotation has not yet occurred. You should use this value to handle cases where the pedal stops: "coasting" (EventTime counter does not change) Cadence: (RPM)

func (SpeedAndCadenceMessage) CadenceEventTime

func (m SpeedAndCadenceMessage) CadenceEventTime() (num uint16)

Represents the time of the last valid bike cadence event (1/1024 sec)

func (SpeedAndCadenceMessage) CadenceEventTimeDiff

func (m SpeedAndCadenceMessage) CadenceEventTimeDiff(prev SpeedAndCadenceMessage) uint16

func (SpeedAndCadenceMessage) CadenceRevolutionCountDiff

func (m SpeedAndCadenceMessage) CadenceRevolutionCountDiff(prev SpeedAndCadenceMessage) uint16

func (SpeedAndCadenceMessage) CumulativeCadenceRevolutionCount

func (m SpeedAndCadenceMessage) CumulativeCadenceRevolutionCount() (num uint16)

Represents the total number of pedal revolutions

func (SpeedAndCadenceMessage) CumulativeSpeedRevolutionCount

func (m SpeedAndCadenceMessage) CumulativeSpeedRevolutionCount() (num uint16)

Represents the total number of wheel revolutions

func (SpeedAndCadenceMessage) Distance

func (m SpeedAndCadenceMessage) Distance(prev SpeedAndCadenceMessage, circumference float32) float32

Distance travelled since the last message: (m) circumference: Circumference of the wheel (m)

func (SpeedAndCadenceMessage) Speed

func (m SpeedAndCadenceMessage) Speed(prev SpeedAndCadenceMessage, circumference float32) (speed float32, nochange bool)

Speed: (m/s) circumference: Circumference of the wheel (m) The second parameter "nochange" indicates that the EventTime counter has not changed since the previous message, which means a complete rotation has not yet occurred. You should use this value to handle cases where the pedal stops: "coasting" (EventTime counter does not change)

func (SpeedAndCadenceMessage) SpeedEventTime

func (m SpeedAndCadenceMessage) SpeedEventTime() (num uint16)

Represents the time of the last valid bike speed event (1/1024 sec)

func (SpeedAndCadenceMessage) SpeedEventTimeDiff

func (m SpeedAndCadenceMessage) SpeedEventTimeDiff(prev SpeedAndCadenceMessage) uint16

func (SpeedAndCadenceMessage) String

func (m SpeedAndCadenceMessage) String() string

Jump to

Keyboard shortcuts

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