Conditional Networking
-
The Open5X Voron(i) machine is running a Mini 5+ wifi and in order to make it easy to connect to at MRRF (and other shows) I want it booting in access point mode. In all other situations though i want it to connect to a configured network (i.e. home network, or my phone).
I though it would be a good idea to add a switch that if depressed on startup, put it in access point mode, other wise it would boot into normal wifi mode.
The code for this in config.g is simple enough:
; Network ;create a GPIO input pin to allow for start up network setup choice. ;If the input is triggered boot into access point mode, other wise boot into normal mode M950 J1 C"!io0.in" M552 S0 ;turn off wifi config before selecting another one G4 S1 if(sensors.gpIn[1].value==1) M552 S2 else M552 S1 ; enable network and acquire dynamic address via DHCP
What I realised as I was doing this is that I don't even need to add a switch. The Voron(i) has a nozzle contact probe used for calibration, so I set this so that if the nozzle was touching the contact plate on startup it booted into access point mode, otherwise normal mode.
Final code:
; Network ; Create a GPIO input pin using the nozzle contact probe to allow for start up network setup choice. ;If the nozzle in in contact with the trigger plate ;then boot into access point mode, other wise boot into normal mode M950 J1 C"!io0.in" M552 S0 ;turn off wifi config before selecting another one G4 S1 if(sensors.gpIn[1].value==1) M552 S2 else M552 S1; enable network and acquire dynamic address via DHCP G4 P500 M950 J1 C"nil" ;free up the pin so it can be used for the z probe later. G4 P500