Documentation
¶
Index ¶
Constants ¶
const DISCOVERY_PORT = 20054
const DISCOVERY_TIMEOUT = time.Second * 1
const REQUEST_TIMEOUT = time.Second * 3
Variables ¶
var ErrWaitForAuthOnDevice = errors.New("waiting for authorization on device")
Functions ¶
This section is empty.
Types ¶
type ConnectResponse ¶
type ConnectResponse struct { Token string `json:"token"` Readonly bool `json:"readonly"` Series string `json:"series"` Headtype uint `json:"headType"` HasEnclosure bool `json:"hasEnclosure"` }
ConnectResponse represents http response from snapmaker /connect api endpoint
type Device ¶
type Device struct { IP string `json:"ip"` Port uint `json:"port"` ConnectionData *ConnectResponse `json:"connectionData"` LatestStatus *StatusResponse Connected bool }
Device keeps current snapmaker device details
func DeviceFromJson ¶
Creates snapmaker device based on json file serialized earlier. Thanks to this authentication is not needed every time application connects to the device
func (*Device) Connect ¶
Connect - connects to snapmaker device. Saves response into Device structure
func (*Device) Disconnect ¶
Disconnect - breaks current connection with snapmaker device
func (*Device) ExecuteGCode ¶
ExecuteGCode - executes gcode on snapmaker device. Returns string with response and error if exists
func (*Device) Serialize ¶
Serialize - converts Device into json string. Thanks to this you can later connect to device without clicking yes on device display
func (*Device) Status ¶
func (d *Device) Status() (*StatusResponse, error)
Status gets current status of snapmaker device It returns StatusResponse struct It also saves StatusResponse struct into Device structure for easier access
type DeviceDescription ¶
type ModuleList ¶
type ModuleList struct { Enclosure bool `json:"enclosure"` RotaryModule bool `json:"rotaryModule"` EmergencyStopButton bool `json:"emergencyStopButton"` AirPurifier bool `json:"airPurifier"` }
ModuleList represents part of StatusResponse
type StatusResponse ¶
type StatusResponse struct { X float32 `json:"x"` Y float32 `json:"y"` Z float32 `json:"z"` Homed bool `json:"homed"` OffsetX float32 `json:"offsetX"` OffsetY float32 `json:"offsetY"` OffsetZ float32 `json:"offsetZ"` ToolHead string `json:"toolHead"` SpindleSpeed float32 `json:"spindleSpeed"` WorkSpeed float32 `json:"workSpeed"` PrintStatus string `json:"printStatus"` ModuleList ModuleList `json:"moduleList"` IsEnclosureDoorOpen bool `json:"isEnclosureDoorOpen"` DoorSwitchCount uint `json:"doorSwitchCount"` }
StatusResponse represents http response from snapmaker /status api
type WifiManager ¶
type WifiManager struct { Devices []DeviceDescription Client net.PacketConn }
func NewWifiManager ¶
func NewWifiManager() *WifiManager
func (*WifiManager) Close ¶
func (w *WifiManager) Close()
func (*WifiManager) DiscoverDevices ¶
func (w *WifiManager) DiscoverDevices(retries uint) error
DiscoverDevices - tries to discover snapmaker devices for specified number of times
func (*WifiManager) Init ¶
func (w *WifiManager) Init() error