howen

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type      string         `json:"type"`                // e.g., "80000", "80001", "80003", etc.
	Login     *LoginData     `json:"login,omitempty"`     // For action "80000"
	Subscribe *SubscribeData `json:"subscribe,omitempty"` // For action "80001"
	GPS       *GPSData       `json:"gps,omitempty"`       // For action "80003"
	Alarm     *AlarmData     `json:"alarm,omitempty"`     // For action "80004"
	Status    *StatusData    `json:"status,omitempty"`    // For action "80005"
}

Actionrepresents different types of actions, such as login, subscription, GPS data, alarm data, and status.

type ActionData

type ActionData struct {
	Action  string  `json:"action"`
	Payload Payload `json:"payload"`
}

type Alarm

type Alarm struct {
	VideoLost     string `json:"videoLost"`
	MotionDection string `json:"motionDection"`
	VideoMask     string `json:"videoMask"`
	Input         string `json:"input"`
	OverSpeed     string `json:"overSpeed"`
	LowSpeed      string `json:"lowSpeed"`
	Urgency       string `json:"urgency"`
}

Alarm holds alarm-related information.

type AlarmData

type AlarmData struct {
	AlarmType string `json:"alarm_type"`
	Severity  string `json:"severity"`
	Message   string `json:"message"`
}

AlarmData represents information about alarms.

type AlarmDetails

type AlarmDetails struct {
	AlarmID   string    `json:"alarmID"`  // Alarm unique identifier
	DeviceID  string    `json:"deviceID"` // Device identifier
	StartTime time.Time `json:"st"`       // Alarm start time
	EndTime   time.Time `json:"et"`       // Alarm end time
	Details   string    `json:"det"`      // Detailed alarm information
}

type AlarmMessage

type AlarmMessage struct {
	Action  string       `json:"action"`
	Payload AlarmPayload `json:"payload"`
}

AlarmMessage represents an alarm message.

func (*AlarmMessage) ToProtobufDeviceStatusAlarm

func (a *AlarmMessage) ToProtobufDeviceStatusAlarm() *types.DeviceStatus

type AlarmPayload

type AlarmPayload struct {
	Alarm       Alarm             `json:"alarm"`
	AlarmDetail string            `json:"alarmDetail"`
	AlarmID     string            `json:"alarmID"`
	Basic       Basic             `json:"basic"`
	Bluetooth   Bluetooth         `json:"bluetooth"`
	DeviceID    string            `json:"deviceID"`
	DeviceTemp  DeviceTemp        `json:"deviceTemp"`
	Driver      Driver            `json:"driver"`
	DTU         string            `json:"dtu"`
	EventType   string            `json:"eventType"`
	Fuel        map[string]string `json:"fuel"`
	GSensor     GSensor           `json:"gsensor"`
	IsLater     int               `json:"isLater"`
	Location    Location          `json:"location"`
	Load        Load              `json:"load"`
	Mileage     Mileage           `json:"mileage"`
	Module      Module            `json:"module"`
	Mobile      map[string]string `json:"mobile"`
	NodeID      string            `json:"nodeID"`
	OBD         []OBD             `json:"obd,omitempty"` // Array of OBD data
	Payload     PayloadDetail     `json:"payload"`
	Storage     []Storage         `json:"storage"`
	Temp        Temp              `json:"temp"`
	Voltage     Voltage           `json:"voltage"`

	Wifi map[string]string `json:"wifi"`
}

AlarmPayload represents payload data for alarms.

type Basic

type Basic struct {
	Key string `json:"key"`
}

Basic represents a basic key-value structure.

type Bluetooth

type Bluetooth struct {
	Connect string `json:"connect"`
}

Bluetooth represents Bluetooth connection status.

type Det

type Det struct {
	DT  string `json:"dt"`
	Cur string `json:"cur"`
	VT  string `json:"vt"`
}

Det represents detailed information within PayloadDetail.

type DevicePayload

type DevicePayload struct {
	GMT      string `json:"gmt"`
	Firmware string `json:"fw"`
	Ext      string `json:"ext"`
	MCU      string `json:"mcu"`
	HW       string `json:"hw"`
	IMEI     string `json:"imei"`
	UM       string `json:"um"`
	Dial     string `json:"dial"`
	ALG      string `json:"alg"`
}

DevicePayload holds details of a device's specifications and metadata.

type DeviceStatus

type DeviceStatus struct {
	Action  string        `json:"action"`
	Payload DevicePayload `json:"payload"`
}

DeviceStatus represents the status of a device.

type DeviceTemp

type DeviceTemp struct {
	CPU  string `json:"cpu"`
	Disk string `json:"disk"`
}

DeviceTemp holds information about device temperatures.

type Driver

type Driver struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Driver represents driver information.

type Extra

type Extra struct {
	FW string `json:"fw"`
}

Extra holds additional metadata.

type GPSData

type GPSData struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Speed     float64 `json:"speed"`
	Altitude  float64 `json:"altitude"`
}

GPSData holds GPS information.

type GPSPacket

type GPSPacket struct {
	Action  string  `json:"action"`
	Payload Payload `json:"payload"`
}

GPSPacket represents a GPS data packet.

func (*GPSPacket) ToProtobufDeviceStatusGPS

func (p *GPSPacket) ToProtobufDeviceStatusGPS() *types.DeviceStatus

type GSensor

type GSensor struct {
	X    string `json:"x"`
	Y    string `json:"y"`
	Z    string `json:"z"`
	Tilt string `json:"tilt"`
	Hit  string `json:"hit"`
}

GSensor holds G-sensor data.

type HOWENWS

type HOWENWS struct {
	DeviceType types.DeviceType
}

func (*HOWENWS) ConsumeConnection

func (p *HOWENWS) ConsumeConnection(conn *websocket.Conn, dataStore store.Store) error

func (*HOWENWS) ConsumeMessage

func (p *HOWENWS) ConsumeMessage(conn *websocket.Conn, dataStore store.Store) error

func (*HOWENWS) ConsumeStream

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

func (*HOWENWS) GetDeviceID

func (p *HOWENWS) GetDeviceID() string

func (*HOWENWS) GetDeviceType

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

func (*HOWENWS) GetProtocolType

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

func (*HOWENWS) Login

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

func (*HOWENWS) SendCommandToDevice

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

send command to device

func (*HOWENWS) SetDeviceType

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

type Load

type Load struct {
	Status string `json:"status"`
}

Load represents load status.

type Location

type Location struct {
	Mode       string `json:"mode"`
	DTU        string `json:"dtu"`
	Direct     string `json:"direct"`
	Satellites string `json:"satellites"`
	Speed      string `json:"speed"`
	Altitude   string `json:"altitude"`
	Precision  string `json:"precision"`
	Longitude  string `json:"longitude"`
	Latitude   string `json:"latitude"`
}

Location represents location-related data.

type LoginData

type LoginData struct {
	Username string `json:"username"`
	Token    string `json:"token"`
	PID      string `json:"pid"`
}

LoginData holds login information.

type LoginResponse

type LoginResponse struct {
	Msg    string `json:"msg"`
	Result string `json:"result"`
}

LoginResponse represents the response to a login action.

type Mileage

type Mileage struct {
	TodayDay string `json:"todayDay"`
	Total    string `json:"total"`
}

Mileage represents mileage information.

type Module

type Module struct {
	Mobile   string `json:"mobile"`
	Location string `json:"location"`
	Wifi     string `json:"wifi"`
	GSensor  string `json:"gsensor"`
	Record   string `json:"record"`
}

Module represents various module configurations.

type OBD

type OBD struct {
	TotalMil      int     `json:"totalMil"`      // Total mileage
	TotalFuel     int     `json:"totalFuel"`     // Total fuel consumed
	InstanFuel    float64 `json:"instanFuel"`    // Instantaneous fuel consumption
	Voltage       float64 `json:"voltage"`       // Vehicle voltage
	RPM           int     `json:"rpm"`           // Engine revolutions per minute
	Speed         float64 `json:"speed"`         // Vehicle speed in km/h
	AirShed       float64 `json:"airshed"`       // Air intake flow rate
	StressMpa     float64 `json:"stressMpa"`     // Air intake pressure in kPa
	CoolantsTemp  int     `json:"coolantsTemp"`  // Coolant temperature
	AirTemp       int     `json:"airTemp"`       // Air intake temperature
	MotorLimit    int     `json:"motorLimit"`    // Engine load in percentage
	Position      int     `json:"position"`      // Throttle position in percentage
	EFOA          int     `json:"efoa"`          // Fuel tank level in percentage
	VIN           string  `json:"vin"`           // Vehicle Identification Number
	Engine        int     `json:"engine"`        // Engine status (1: ON, 0: OFF)
	Idle          int     `json:"idle"`          // Idle status (1: Start, 0: End)
	EngineOnTime  string  `json:"engineOnTime"`  // Engine ON time
	EngineOffTime string  `json:"engineOffTime"` // Engine OFF time
	HC            int     `json:"hc"`            // Harsh cornering events
	HA            int     `json:"ha"`            // Harsh acceleration events
	HB            int     `json:"hb"`            // Harsh braking events
	LowBV         int     `json:"lowbv"`         // Battery low voltage (0: No, 1: Yes)
}

type Payload

type Payload struct {
	Alarm      Alarm             `json:"alarm"`
	Basic      Basic             `json:"basic"`
	Bluetooth  Bluetooth         `json:"bluetooth"`
	DeviceID   string            `json:"deviceID"`
	DeviceTemp DeviceTemp        `json:"deviceTemp"`
	Driver     Driver            `json:"driver"`
	DTU        string            `json:"dtu"`
	Ext        Extra             `json:"ext"`
	Fuel       map[string]string `json:"fuel"`
	GSensor    GSensor           `json:"gsensor"`
	Load       Load              `json:"load"`
	Location   Location          `json:"location"`
	Module     Module            `json:"module"`
	Mileage    Mileage           `json:"mileage"`
	Mobile     map[string]string `json:"mobile"`
	NodeID     string            `json:"nodeID"`
	OBD        []OBD             `json:"obd,omitempty"` // Array of OBD data
	Storage    []Storage         `json:"storage"`
	Temp       Temp              `json:"temp"`
	Voltage    Voltage           `json:"voltage"`
	Wifi       map[string]string `json:"wifi"`
}

Payload represents the main payload structure, holding different device details.

type PayloadDetail

type PayloadDetail struct {
	ST     string `json:"st"`
	Det    Det    `json:"det"`
	DTU    string `json:"dtu"`
	DrID   string `json:"drid"`
	DrName string `json:"drname"`
	SPDS   string `json:"spds"`
	UUID   string `json:"uuid"`
	EC     int    `json:"ec"`
	ET     string `json:"et"`
}

PayloadDetail holds detailed information within a payload.

type StatusData

type StatusData struct {
	Online bool   `json:"online"`
	Time   string `json:"time"` // Timestamp of status change
}

StatusData indicates the online/offline status and the time of status change.

type Storage

type Storage struct {
	Name   string `json:"name"`   // Name of the storage device (e.g., "sd1")
	Index  string `json:"index"`  // Index of the storage device (e.g., "0")
	Status string `json:"status"` // Status of the storage device (e.g., "1" for active)
	Total  string `json:"total"`  // Total capacity of the storage in MB or GB (e.g., "7523")
	Free   string `json:"free"`   // Free space available in MB or GB (e.g., "0")
}

type SubscribeData

type SubscribeData struct {
	Channel string `json:"channel"`
}

SubscribeData represents data for subscription actions.

type Temp

type Temp struct {
	InsideTemp      string `json:"insideTemp"`
	OutsideTemp     string `json:"outsideTemp"`
	EngineerTemp    string `json:"engineerTemp"`
	DeviceTemp      string `json:"deviceTemp"`
	InsideHumidity  string `json:"insideHumidity"`
	OutsideHumidity string `json:"outsideHumidity"`
}

Temp represents temperature data.

type Voltage

type Voltage struct {
	VCC string `json:"vcc"`
	Bat string `json:"bat"`
}

Voltage holds voltage data.

Jump to

Keyboard shortcuts

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