tr06

package
v0.0.0-...-c6ca42b Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartBitValue = 0x7979
	StopBitValue  = 0x0D0A
)
View Source
const (
	MSG_LoginData               MessageType = 0x01
	MSG_PositioningData                     = 0x12
	MSG_HeartbeatData                       = 0x13
	MSG_EG_HeartbeatData                    = 0x23
	MSG_StringInformation                   = 0x21
	MSG_AlarmData                           = 0x26
	MSG_LBSInformation                      = 0x28 // TODO: check if this is correct
	MSG_TimezoneInformation                 = 0x27
	MSG_GPS_PhoneNumber                     = 0x2a
	MSG_WifiInformation                     = 0x2c
	MSG_TransmissionInstruction             = 0x80
	MSG_Invalid                             = 0xff
)
View Source
const (
	AL_SOSDistress  AlarmType = 0x04 // 100 -> 0000 0100
	AL_LowBattery             = 0x03 // 011 -> 0000 0011
	AL_PowerFailure           = 0x02 // 010 -> 0000 0010
	AL_Vibration              = 0x01 // 001 -> 0000 0001
	AL_Normal                 = 0x00 // 000 -> 0000 0000
	AL_Invalid                = 0xff
)
View Source
const (
	VL_NoPower             BatteryLevel = 0x00
	VL_BatteryExtremelyLow              = 0x01
	VL_BatteryVeryLow                   = 0x02
	VL_BatteryLow                       = 0x03
	VL_BatteryMedium                    = 0x04
	VL_BatteryHigh                      = 0x05
	VL_BatteryFull                      = 0x06
	VL_Invalid                          = 0xff
)
View Source
const (
	ALV_Normal                       = 0x00
	ALV_SOS                          = 0x01
	ALV_PowerCut                     = 0x02
	ALV_Vibration                    = 0x03
	ALV_EnterFence                   = 0x04
	ALV_ExitFence                    = 0x05
	ALV_OverSpeed                    = 0x06
	ALV_Moving                       = 0x09
	ALV_EnterGPSDeadZone             = 0x0a
	ALV_ExitGPSDeadZone              = 0x0b
	ALV_PowerOn                      = 0x0c
	ALV_GPSFirstFixNotice            = 0x0d
	ALV_ExternalLowBattery           = 0x0e
	ALV_ExternalLowBatteryProtection = 0x0f
	ALV_SIMChange                    = 0x10
	ALV_PowerOff                     = 0x11
	ALV_AirplaneMode                 = 0x12
	ALV_Diassemble                   = 0x13
	ALV_Door                         = 0x14
	ALV_ShutdownLowPower             = 0x15
	ALV_Sound                        = 0x16
	ALV_InternalBatteryLow           = 0x17
	ALV_SleepMode                    = 0x20
	ALV_HarshAcceleration            = 0x29
	ALV_HarshBraking                 = 0x30
	ALV_SharpLeftTurn                = 0x2a
	ALV_SharpRightTurn               = 0x2b
	ALV_SharpCrash                   = 0x2c
	ALV_Pull                         = 0x32
	ALV_PressToUploadAlarmMessageBtn = 0x3e
	ALV_Fall                         = 0x23
	ALV_ACCOn                        = 0xee
	ALV_ACCOff                       = 0xff
)
View Source
const (
	LANG_Chinese = 0x01
	LANG_English = 0x02
	LANG_NoReply = 0x00
)
View Source
const (
	GSM_NoSignal            GSMSignalStrength = 0x00
	GSM_ExtremelyWeakSignal                   = 0x01
	GSM_WeakSignal                            = 0x02
	GSM_GoodSignal                            = 0x03
	GSM_StrongSignal                          = 0x04
	GSM_Invalid                               = 0xff
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlarmInformation

type AlarmInformation struct {
	GpsInformation    GPSInformation
	LBSInformation    LBSInformation
	StatusInformation StatusInformation
}

type AlarmType

type AlarmType uint8 // alarm type is 3 bit info, trying to encode it to 8 bit

type AlarmValue

type AlarmValue uint8

type BatteryLevel

type BatteryLevel uint8

type DoorStatusData

type DoorStatusData struct {
	DoorOpen bool
}

type ExternalPowerVoltageData

type ExternalPowerVoltageData struct {
	Voltage float32
}

type GPSCourse

type GPSCourse struct {
	IsRealtime     bool
	IsDifferential bool
	Positioned     bool
	Longitude      bool // 0 - east, 1 - west
	Latitude       bool // 1 - north, 0 - south
	Degree         uint16
}

type GPSDataUploadMode

type GPSDataUploadMode uint8

func (*GPSDataUploadMode) ToString

func (m *GPSDataUploadMode) ToString() string

type GPSInformation

type GPSInformation struct {
	Timestamp          time.Time
	GPSInfoLength      uint8
	NumberOfSatellites uint8
	Latitude           float32
	Longitude          float32
	Speed              uint8     // gpsSpeed
	Course             GPSCourse // course/heading - running direction of GPS
}

type GSMSignalStrength

type GSMSignalStrength uint8

type HeartbeatData

type HeartbeatData struct {
	TerminalInformation TerminalInformation
	BatteryLevel        BatteryLevel
	GSMSignalStrength   GSMSignalStrength
	ExtendedPortStatus  uint16 // 0x0001 Chinese, 0x0002 English
}

type InformationContent

type InformationContent struct {
	InformationType InformationType
	DataContent     uint16
}

type InformationTransmissionPacket

type InformationTransmissionPacket struct {
	StartBit                uint16
	PacketLength            uint16
	ProtocolNumber          byte
	InformationContent      InformationContent
	InformationSerialNumber uint16
	Crc                     uint16
	StopBits                uint16
}

type InformationType

type InformationType byte
const (
	ExternalPowerVoltage InformationType = 0x00
	TerminalStatusSync   InformationType = 0x04
	DoorStatus           InformationType = 0x05
)

type LBSInformation

type LBSInformation struct {
	MCC    uint16 // mobile country code
	MNC    uint8  // mobile network code
	LAC    uint16 // location area code
	CellID [3]byte
}

type Language

type Language uint8

type LoginData

type LoginData struct {
	TerminalID string
}

type MessageType

type MessageType byte

func (MessageType) String

func (mt MessageType) String() string

type Packet

type Packet struct {
	StartBit                uint16
	PacketLength            byte
	MessageType             MessageType
	Information             interface{}
	InformationSerialNumber uint16
	Crc                     uint16
	StopBits                uint16
}

func (*Packet) ToProtobufDeviceStatus

func (packet *Packet) ToProtobufDeviceStatus(imei string, deviceType types.DeviceType) *types.DeviceStatus

type PositioningInformation

type PositioningInformation struct {
	GpsInformation    GPSInformation
	LBSInfo           LBSInformation
	ACCHigh           bool
	DataReportingMode GPSDataUploadMode // for concox, but not for gt06
	GPSRealTime       bool              // 0x00 - realtime, 0x01 - re-upload
	MileageStatistics uint32
}

type ResponsePacket

type ResponsePacket struct {
	StartBit                uint16
	PacketLength            int8
	ProtocolNumber          int8
	InformationSerialNumber uint16
	Crc                     uint16
	StopBits                uint16
}

func (*ResponsePacket) ToBytes

func (r *ResponsePacket) ToBytes() []byte

type StatusInformation

type StatusInformation struct {
	TerminalInformation TerminalInformation
	BatteryLevel        BatteryLevel
	GSMSignalStrength   GSMSignalStrength
	Alarm               AlarmValue
	Language            Language
}

type TR06Protocol

type TR06Protocol struct {
	LoginInformation *LoginData
	DeviceType       types.DeviceType
}

func (*TR06Protocol) ConsumeStream

func (p *TR06Protocol) ConsumeStream(reader *bufio.Reader, writer io.Writer, dataStore store.Store) error

func (*TR06Protocol) GetDeviceID

func (p *TR06Protocol) GetDeviceID() string

func (*TR06Protocol) GetDeviceType

func (p *TR06Protocol) GetDeviceType() types.DeviceType

func (*TR06Protocol) GetProtocolType

func (p *TR06Protocol) GetProtocolType() types.DeviceProtocolType

func (*TR06Protocol) IsValidHeader

func (p *TR06Protocol) IsValidHeader(reader *bufio.Reader) bool

func (*TR06Protocol) Login

func (p *TR06Protocol) Login(reader *bufio.Reader) (ack []byte, byteToSkip int, e error)

func (*TR06Protocol) SendCommandToDevice

func (p *TR06Protocol) SendCommandToDevice(writer io.Writer, command string) error

send command to device

func (*TR06Protocol) SetDeviceType

func (p *TR06Protocol) SetDeviceType(t types.DeviceType)

type TerminalInformation

type TerminalInformation struct {
	OilElectricityConnected bool
	GPSSignalAvailable      bool
	AlarmType               AlarmType // concox has no alarm type, while gt06 does
	Charging                bool
	ACCHigh                 bool
	Armed                   bool
}

type TerminalStatusSyncData

type TerminalStatusSyncData struct {
	Status string
}

Jump to

Keyboard shortcuts

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