Documentation ¶
Index ¶
- Constants
- Variables
- type CH9120
- type CH9121
- type CH9126
- type ControlPlane
- func (p *ControlPlane) Close() (err error)
- func (p *ControlPlane) Discovery() <-chan Module
- func (p *ControlPlane) Pull(ctx context.Context, product Product, address net.HardwareAddr) (module Module, err error)
- func (p *ControlPlane) Push(ctx context.Context, module Module) (parsed Module, err error)
- func (p *ControlPlane) Reset(ctx context.Context, product Product, address net.HardwareAddr) (module Module, err error)
- func (p *ControlPlane) SendDiscovery(product Product) (err error)
- type Kind
- type Module
- type ModuleOptions
- type NTPMode
- type NTPService
- type Product
- type UARTMode
- type UARTParity
- type UARTService
Constants ¶
View Source
const ( ProductCH9120 Product = "CH9120" ProductCH9121 Product = "CH9121" ProductCH9126 Product = "CH9126" KindPushRequest Kind = 0x01 KindPullRequest Kind = 0x02 KindResetRequest Kind = 0x03 KindDiscoveryRequest Kind = 0x04 KindPushResponse Kind = 0x81 KindPullResponse Kind = 0x82 KindResetResponse Kind = 0x83 KindDiscoveryResponse Kind = 0x84 TCPServer UARTMode = 0x00 TCPClient UARTMode = 0x01 UDPServer UARTMode = 0x02 UDPClient UARTMode = 0x03 ParityNone UARTParity = 0x00 ParityEven UARTParity = 0x01 ParityOdd UARTParity = 0x02 ParityMark UARTParity = 0x03 ParitySpace UARTParity = 0x04 NTPServer NTPMode = 0x00 NTPClient NTPMode = 0x01 )
Variables ¶
View Source
var ( ErrInvalidNetworkInterface = errors.New("ch912x: invalid network interface") ErrCH9120InvalidJSON = errors.New("ch912x: the JSON not is CH9120 configuration") ErrCH9121InvalidJSON = errors.New("ch912x: the JSON not is CH9121 configuration") ErrCH9126InvalidJSON = errors.New("ch912x: the JSON not is CH9126 configuration") ErrModuleKindWrong = errors.New("ch912x: the module kind wrong") ErrModuleMustMAC = errors.New("ch912x: the need to provide `ModuleMAC`") ErrTaskRunning = errors.New("ch912x: the previous task was not completed") ErrUnknownModuleType = errors.New("ch912x: unknown module type") )
Functions ¶
This section is empty.
Types ¶
type CH9120 ¶
type CH9120 struct { Kind Kind `json:"-"` Version string `json:"version,omitempty"` ModuleName string `json:"module_name,omitempty"` ModuleMAC net.HardwareAddr `json:"module_mac,omitempty"` ClientMAC net.HardwareAddr `json:"client_mac,omitempty"` ModuleOptions *ModuleOptions `json:"module_options,omitempty"` UART1 *UARTService `json:"uart_1,omitempty"` }
func (*CH9120) MarshalJSON ¶
func (*CH9120) UnmarshalJSON ¶
type CH9121 ¶
type CH9121 struct { Kind Kind `json:"-"` Version string `json:"version,omitempty"` ModuleName string `json:"module_name,omitempty"` ModuleMAC net.HardwareAddr `json:"module_mac,omitempty"` ClientMAC net.HardwareAddr `json:"client_mac,omitempty"` ModuleOptions *ModuleOptions `json:"module_options,omitempty"` UART1 *UARTService `json:"uart_1,omitempty"` UART2 *UARTService `json:"uart_2,omitempty"` }
func (*CH9121) MarshalJSON ¶
func (*CH9121) UnmarshalJSON ¶
type CH9126 ¶
type CH9126 struct { Kind Kind `json:"-"` Version string `json:"version,omitempty"` ModuleName string `json:"module_name,omitempty"` ModuleMAC net.HardwareAddr `json:"module_mac,omitempty"` ClientMAC net.HardwareAddr `json:"client_mac,omitempty"` ModuleOptions *ModuleOptions `json:"module_options,omitempty"` UART1 *UARTService `json:"uart_1,omitempty"` NTP *NTPService `json:"ntp,omitempty"` }
func (*CH9126) MarshalJSON ¶
func (*CH9126) UnmarshalJSON ¶
type ControlPlane ¶
type ControlPlane struct { Timeout time.Duration SendTimeout time.Duration // contains filtered or unexported fields }
func ListenCH912X ¶
func ListenCH912X(ifi *net.Interface) (plane *ControlPlane, err error)
func ListenCH912XByName ¶
func ListenCH912XByName(name string) (*ControlPlane, error)
func (*ControlPlane) Close ¶
func (p *ControlPlane) Close() (err error)
func (*ControlPlane) Discovery ¶
func (p *ControlPlane) Discovery() <-chan Module
func (*ControlPlane) Pull ¶
func (p *ControlPlane) Pull(ctx context.Context, product Product, address net.HardwareAddr) (module Module, err error)
func (*ControlPlane) Reset ¶
func (p *ControlPlane) Reset(ctx context.Context, product Product, address net.HardwareAddr) (module Module, err error)
func (*ControlPlane) SendDiscovery ¶
func (p *ControlPlane) SendDiscovery(product Product) (err error)
type Module ¶
type Module interface { io.ReaderFrom io.WriterTo // contains filtered or unexported methods }
type ModuleOptions ¶
type ModuleOptions struct { MAC net.HardwareAddr `json:"mac,omitempty"` IP net.IP `json:"ip,omitempty"` Mask net.IP `json:"mask,omitempty"` Gateway net.IP `json:"gateway,omitempty"` UseDHCP bool `json:"use_dhcp,omitempty"` SerialNegotiate bool `json:"serial_negotiate,omitempty"` EnabledMinorUART bool `json:"enabled_minor_uart,omitempty"` }
type NTPService ¶
type UARTParity ¶
type UARTParity byte
type UARTService ¶
type UARTService struct { Mode UARTMode `json:"mode"` ClientIP net.IP `json:"client_ip"` ClientPort uint16 `json:"client_port"` ClientDomain string `json:"client_domain"` UseDomain bool `json:"use_domain"` LocalPort uint16 `json:"local_port"` PacketSize uint16 `json:"packet_size"` PacketTimeout uint16 `json:"packet_timeout"` RandomClientPort bool `json:"random_client_port,omitempty"` CloseOnLost bool `json:"close_on_lost"` ClearOnReconnect bool `json:"clear_on_reconnect"` Baud uint32 `json:"baud"` DataBits uint8 `json:"data_bits"` StopBit uint8 `json:"stop_bit"` Parity UARTParity `json:"parity"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.