Documentation
¶
Overview ¶
Package wialonips implements the Wialon IPS communication protocol that was developed by Gurtam for use in personal and automotive GPS and GLONASS trackers which transfer data to a satellite monitoring server using the TCP or the UDP protocol.
The TCP connection must be maintained throughout the entire data transfer process. If the device disconnects immediately after sending the message, the server does not have time to send a response to the device, and traffic consumption increases. While using one TCP connection, you should transfer data from one device. Otherwise, the system registers only the data of the device whose ID is the first in the incoming data list. To save traffic, you can use the UDP protocol. However, it does not guarantee that the messages will be delivered.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrWialonIPSInvalidLoginMessage = errors.New("invalid login #L# message") ErrWialonIPSInvalidSDMessage = errors.New("invalid shortened data #SD# message") ErrWialonIPSInvalidDataMessage = errors.New("invalid data #D# message") ErrWialonIPSParseDateTime = errors.New("invalid date or time data") ErrWialonIPSParsePoint = errors.New("invalid coordinates data") ErrWialonIPSParseSCA = errors.New("invalid speed, course or altitude data") ErrWialonIPSParseSats = errors.New("invalid sats data") ErrWialonIPSParseHDOP = errors.New("invalid hdop data") ErrWialonIPSParseInOutput = errors.New("invalid input or output data") ErrWialonIPSParseADC = errors.New("invalid adc data") ErrWialonIPSParseAttribute = errors.New("invalid parameter data") ErrWialonIPSCRC16Validation = errors.New("CRC16 validation not passed") )
var (
ErrWialonIPSUnsupportedPacketType = errors.New("unsupported packet type")
)
Functions ¶
func MapErrToRespCode ¶
func MapErrToRespCode(p PacketType, err error) string
MapErrToRespCode maps errors to WialonIPS respond codes.
Types ¶
type BlackBoxMessage ¶
type BlackBoxMessage struct {
ShortenedMessages []ShortenedDataMessage
DataMessages []DataMessage
// contains filtered or unexported fields
}
BlackBoxMessage is a WialonIPS black box message.
func (*BlackBoxMessage) Decode ¶
func (bb *BlackBoxMessage) Decode(data []byte) error
Decode decodes a WialonIPS message. The black box packet is used to transmit messages for the past period. The maximum number of messages that can be transmitted in one packet is 5000. The packet looks as follows: #B#Date;Time;Lat1;Lat2;Lon1;Lon2;Speed;Course;Alt;Sats|Date;Time;Lat1;Lat 2;Lon1;Lon2;Speed;Course;Alt;Sats|Date ;Time;Lat1;Lat2;Lon1;Lon2;Speed; Course;Alt;Sats|CRC16\r\n.
func (*BlackBoxMessage) Response ¶
func (bb *BlackBoxMessage) Response() []byte
Response returns a WialonIPS response message.
type DataMessage ¶
type DataMessage struct {
ShortenedDataMessage
HDOP null.Float
Inputs null.Int // bit map.
Outputs null.Int // bit map.
ADC []null.Float
IButton null.String
Attributes protocol.Attributes
}
DataMessage is a WialonIPS data message. The packet contains additional data structures and looks as follows: #D#Date;Time;Lat1;Lat2;Lon1;Lon2;Speed;Course;Alt;Sats;HDOP;Inputs; Outputs;ADC;Ibutton;Params;CRC16\r\n Each parameter has the following structure: Name:Type:Value Examples of additional parameters: count1:1:564, fuel:2:45.8, hw:3:V4.5, SOS:1:1.
func (*DataMessage) Decode ¶
func (d *DataMessage) Decode(data []byte) error
Decode decodes a WialonIPS message.
func (*DataMessage) Response ¶
func (d *DataMessage) Response() []byte
Response returns a WialonIPS response message.
type LoginMessage ¶
type LoginMessage struct {
Password string
// contains filtered or unexported fields
}
LoginMessage is a WialonIPS login message. The packet is used for the device authorization on the server. Every TCP connection starts with sending this packet from the device to the server. Other data should be transferred only after the server confirms the successful authorization of the device. The login package looks as follows: #L#Protocol_version;IMEI;Password;CRC16\r\n.
func (*LoginMessage) Decode ¶
func (l *LoginMessage) Decode(data []byte) error
Decode decodes a WialonIPS message.
func (*LoginMessage) Response ¶
func (l *LoginMessage) Response() []byte
Response returns a WialonIPS response message.
type Message ¶
type Message interface {
Decode(data []byte) error
// Version returns version of Wialon IPS protocol. To avoid reflection use.
Version() Version
IMEI() string
Response() []byte
}
Message is the message of Wialon IPS protocol.
type Package ¶
type Package struct {
Type PacketType
Version Version
IMEI string // IMEI is the unique identifier of the device.
Message Message
}
Package is the package of Wialon IPS protocol. All data is received in text format as a packet which looks as follows: #PT#msgCRC\r\n.
func NewPackage ¶
NewPackage creates a new package of Wialon IPS protocol.
type PacketType ¶
type PacketType string
PacketType is the type of package of Wialon IPS.
const ( UnknownPacket PacketType = "" // Unknown packet type. Used for initializing PacketType. LoginPacket PacketType = "L" // Login packet. ShortenedDataPacket PacketType = "SD" // Shortened data packet. DataPacket PacketType = "D" // Data packet. BlackBoxPacket PacketType = "B" // Black box packet. PingPacket PacketType = "P" // Ping packet. )
type ShortenedDataMessage ¶
type ShortenedDataMessage struct {
RegisteredAt time.Time
Point generic.PointWGS84
// Speed is type of int according specs, but there is found it comes in float xxx.yyy thru retranslation.
Speed null.Float
Course null.Int
// Altitude is type of int according specs, but there is found it comes in float xxx.yyy thru retranslation.
Altitude null.Float
Sat null.Int
// contains filtered or unexported fields
}
ShortenedDataMessage is a WialonIPS shortened data message. The packet contains only navigation data and looks as follows: #SD#Date;Time;Lat1;Lat2;Lon1;Lon2;Speed;Course;Alt;Sats;CRC16\r\n.
func (*ShortenedDataMessage) Decode ¶
func (s *ShortenedDataMessage) Decode(data []byte) error
Decode decodes a WialonIPS message.
func (*ShortenedDataMessage) Response ¶
func (s *ShortenedDataMessage) Response() []byte
Response returns a WialonIPS response message.