Robo3D / Robo-iOS-Beta

1 stars 0 forks source link

Unconnected printer can't be handled at all #20

Closed foosel closed 7 years ago

foosel commented 7 years ago

What I did

Configured the app for the OctoPrint instance of one of my printers. OctoPrint was currently not connected to the printer (serial connection offline, printer not "Operational" and actually fully powered down).

What I expected to happen

I expected to be able to get a connection to the OctoPrint instance, click on that to get the printer view, be able to connect to the printer there or at least see the video feed.

What happened instead

Printer in listing was stuck on "Not Found" with a "busy" throbber next to it. Clicking on it produced an error message that the app was unable to connect to the printer and to make sure that it is available.

Additional information

I did a tcpdump of what was going over the line at this point and noticed that the app was happily talking to the OctoPrint instance and querying printer status and job status from the corresponding APIs, ruling out any actual connectivity issues. The printer status returned a 409 since the printer was not connected - as documented in the API docs.

Possible solutions

IMHO the app at the very least should mirror that 409 to the user in the form of a message more to the likes of "please make sure your printer is online" or something like that, to differentiate it from a wrong API key or an offline OctoPrint instance or similar issues. Ideally it should be possible to connect to the printer from the app.

bryantjk commented 7 years ago

Moving this up to 1.0.5 as we need a little work on how the UI should handle disconnected printers and whether we will provide option for adjusting settings and connecting within the app.

AllenMcAfee commented 7 years ago

@bryantjk following up on this.. are we still needing a design decision on this or did we handle it last time we spoke?

After some thought on this I think we can approach the 409 return the same way we are handling it in RoboLCD - we arranged a popup to indicate the server was not connected to the mainboard with a button preconfigured to the correct connection settings. Since there is only ever 1 port and baud we are looking for on the R2 or C2, we can make this static in the RoboLCD app and allow a one-button connection.

For the iOS app, we can do a similar popup from the Printer Status window that will allow the user to:

  1. Set Baud rate per the Octoprint baud range "baudrates": [250000, 230400, 115200, 57600, 38400, 19200, 9600]
  2. Select the port preference: "ports": ["/dev/ttyACM0"] (most common port)
  3. Select autoconnect: "autoconnect": true

We should be able to pull this together from here: http://docs.octoprint.org/en/master/api/connection.html#get-connection-settings

This might also require us to add a new state to the printer status descriptions for Online/Not Connected or something more to the point. This would likely be the state for any printer returning any 400 client error code. This means:

@foosel will these change at all in 1.3.0? Also, do you think we should handle any 400 error with the popup solution above?

foosel commented 7 years ago

will these change at all in 1.3.0?

OctoPrint uses semantic versioning. As long as the major component doesn't change, stuff stays backwards compatible. So if you use the API as described, no problem. If you use undocumented functionality though, better get in touch.

do you think we should handle any 400 error with the popup solution above?

I guess you mean in case of a 400 returned on attempting to connect? Or in general? Usually a 400 should not arise in a well behaving API client. The only exception would be if the user first got the connection popup, then physically disconnected the printer again. But I don't know if you want to accomodate that in your UX.

Just to make sure (I'm not entirely positive that this is what you plan to do from the above description), you should definitely use the port and baudrate list from the API, at least if you want to stay compatible to all OctoPrint instances and not just those bundled with your own printers (which are pretty much guaranteed to only see one printer of which you should know the port and baudrate). A user might have had to configure an additional port or baudrate in order to connect to their printer, in which case ports might contain something like /dev/myCustomPrinterPort and baudrates might contain something like 123456.

bryantjk commented 7 years ago

I think I get all of this I just want to clarify how you're saying this will work:

From the Dashboard view, if a printer does not connect and a 409 error is returned, then launch a new view/popup that allows for easy correction of the connection settings. Correct?

Is this the only opportunity the user will have to adjust these settings? I think adding a button from the screen where the user edits printer name, IP Address, etc. to manually trigger this might be good.

AllenMcAfee commented 7 years ago

Tested this in 1.0.5 (2) and it seems to work as expected. Disconnect and connect statuses are updating correctly and the button handles both requests correctly.

Here are some issues I did find:

bryantjk commented 7 years ago

Turns out for those profile, port, and baud options I had an array I was just appending to each time you loaded the view. So the number of the profiles displayed matched the number of times the view had been loaded. Should be tighted up on the 1.0.9. version now.