mqtt

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfo

type ClientInfo struct {
	ID                string `json:"id"`
	RemoteAddr        string `json:"remote_addr"`
	SubscriptionCount int    `json:"subscription_count"`
}

ClientInfo represents a connected MQTT client

type MessageHook

type MessageHook struct {
	mqtt.HookBase
	// contains filtered or unexported fields
}

MessageHook implements the MQTT hook interface for message handling

func (*MessageHook) ID

func (h *MessageHook) ID() string

func (*MessageHook) OnPublished

func (h *MessageHook) OnPublished(cl *mqtt.Client, pk packets.Packet)

func (*MessageHook) Provides

func (h *MessageHook) Provides(b byte) bool

type Server

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

Server represents an MQTT broker with V2X charger simulation

func NewServer

func NewServer(id int, port int) *Server

NewServer creates a new MQTT server for V2X charger simulation

func (*Server) Address

func (s *Server) Address() string

Address returns the broker address

func (*Server) Category

func (s *Server) Category() device.Category

Category returns the device category

func (*Server) GenerateValues

func (s *Server) GenerateValues(simTime time.Time)

GenerateValues generates simulated values based on time

func (*Server) GetClients

func (s *Server) GetClients() []ClientInfo

GetClients returns a list of connected MQTT clients

func (*Server) GetLogs

func (s *Server) GetLogs(limit int) []device.LogEntry

GetLogs returns the operation logs

func (*Server) GetState

func (s *Server) GetState() map[string]interface{}

GetState returns the current charger state

func (*Server) Protocol

func (s *Server) Protocol() device.Protocol

Protocol returns the protocol type

func (*Server) SerialNumber

func (s *Server) SerialNumber() string

SerialNumber returns the serial number

func (*Server) SetPort

func (s *Server) SetPort(port int)

SetPort updates the server port (should be called while stopped)

func (*Server) SetSerialNumber

func (s *Server) SetSerialNumber(sn string)

SetSerialNumber sets the serial number

func (*Server) SetTargetPower

func (s *Server) SetTargetPower(power float64)

SetTargetPower sets the charging/discharging power Convention: negative power = charging, positive power = discharging

func (*Server) SetValue

func (s *Server) SetValue(key string, value interface{}) error

SetValue sets a charger state value

func (*Server) Start

func (s *Server) Start() error

Start starts the MQTT broker

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the MQTT broker

func (*Server) WakeUp

func (s *Server) WakeUp(wake bool)

WakeUp sends the wakeUp command to transition to CHARGE_LOOP

type V2XState

type V2XState struct {
	// Connection & identity
	Connected    bool   `json:"connected"`
	Version      string `json:"version"`
	SerialNumber string `json:"serialNumber"`

	// Session state
	SessionState   string `json:"sessionState"`
	ControlMode    string `json:"controlMode"`
	EVConnected    bool   `json:"evConnected"`
	ErrorState     bool   `json:"errorState"`
	ChargeProtocol string `json:"chargeProtocol"`
	ReplugRequired bool   `json:"replugRequired"`
	Sleep          bool   `json:"sleep"`

	// AC measurements
	PowerAc    float64 `json:"powerAc"`
	CurrentAc  float64 `json:"currentAc"`
	CurrentAc1 float64 `json:"currentAc1"`
	CurrentAc2 float64 `json:"currentAc2"`
	CurrentAc3 float64 `json:"currentAc3"`
	VoltageAc  float64 `json:"voltageAc"`
	VoltageAc1 float64 `json:"voltageAc1"`
	VoltageAc2 float64 `json:"voltageAc2"`
	VoltageAc3 float64 `json:"voltageAc3"`
	Frequency  float64 `json:"frequency"`

	// DC measurements
	PowerDc             float64 `json:"powerDc"`
	CurrentDc           float64 `json:"currentDc"`
	VoltageDc           float64 `json:"voltageDc"`
	InverterTemperature float64 `json:"inverterTemperature"`

	// Energy
	EnergyAc              float64 `json:"energyAc"`
	EnergyAcImport        float64 `json:"energyAcImport"`
	EnergyAcExport        float64 `json:"energyAcExport"`
	EnergyAcImportSession float64 `json:"energyAcImportSession"`
	EnergyAcExportSession float64 `json:"energyAcExportSession"`

	// Power limits
	ChargePowerMax    float64 `json:"chargePowerMax"`
	ChargePowerMin    float64 `json:"chargePowerMin"`
	DischargePowerMax float64 `json:"dischargePowerMax"`
	DischargePowerMin float64 `json:"dischargePowerMin"`

	// Vehicle state
	SoC                  float64 `json:"soc"`
	TargetEnergyRequest  float64 `json:"targetEnergyRequest"`
	RequestedTargetPower float64 `json:"requestedTargetPower"`

	// Control inputs (subscribed topics)
	TargetPower      float64 `json:"targetPower"`
	LimitChargePower float64 `json:"limitChargePower"`
}

V2XState holds the V2X charger state (matches Ambibox MQTT structure)

Jump to

Keyboard shortcuts

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