Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The pairing code is shown before it has reached the server #30

Open
ensonic opened this issue Jan 10, 2017 · 4 comments
Open

The pairing code is shown before it has reached the server #30

ensonic opened this issue Jan 10, 2017 · 4 comments

Comments

@ensonic
Copy link
Contributor

ensonic commented Jan 10, 2017

With the current code we show the pairing code in the UI and send a push-request with 'cmd=register' and the pairing code to the server. If the robot is on a slow network, the user can enter the code already and then gets this warning from the openroberta lab:

Check if your robot is switched on and connected to the server.

We can't wait for the request to reach the server, since this is a http-push api where, we intentionall fire requests and keep them waiting at the server side. There is no hook for getting notified when the request was sent.
https://docs.python.org/3/library/urllib.request.html#module-urllib.request

A better wait would be to:

  1. send the 'init' to the server without a token and receive the token from the server (small timeout)
  2. send 'register' with the received token to the server (long timeout)

This way we know that we have connected in 1) and can show the token. See OpenRoberta/robertalab#32

See also #28.

@ensonic
Copy link
Contributor Author

ensonic commented Apr 27, 2018

We have more options.

We can wait for an event from the connector thread before sending the 'connected' signal. The event is basically that we got a reply on the first push. So we change this code to

self.event = threading.Event()
# start connector thread
...
self.status('connected')
self.event.wait() # consider a timeout though
return self.thread.params['token']

and in the connector

self.service.event.set()

This works, but there is quite a pause in the UI before the pairing code is shown. Ideally we show a "connecting ..." message, since otherwise people can press connect multiple times.
(see ui code)

@lotu
Copy link

lotu commented May 22, 2018

One other possibility to show the code but have a waiting symbol (e.g. two arrows circling each other), until the robot knows the code has been received by the server, then change to a check mark or something.

For context when a middle student is unable to connect their robot it can be extremely discouraging because they did everything correctly but got a bad result and presume that something is wrong with them personally. It also consumes lots of teacher time troubleshooting non-working robots.

@ensonic
Copy link
Contributor Author

ensonic commented May 22, 2018

I totally understand, but I don't see how to fix this without UI changes and since those are in a different package, this is tricky. Adding the spinner does not make it easier. If I would have the 2nd signal to turn the spinner off, I could also defer showing the code :/

I'll see if I can introduce the signaling in one change and find a way for the UI to be changed to work with new and old signalling to support a transition period. Maybe I can provide an updated brickman for those who care (the 'jessie' version probably won't get a release otherwise).

@ensonic
Copy link
Contributor Author

ensonic commented Jun 19, 2018

ensonic added a commit to ensonic/brickman that referenced this issue Jun 26, 2018
We did send the code to the server and showed the code at the same time.
This will let the user enter the code before we managed to connect. Now
we show a "connecting..." message first and only show the code when we
conencted.
See OpenRoberta/robertalab-ev3dev#30
ensonic added a commit to ensonic/brickman that referenced this issue Jun 28, 2018
We did send the code to the server and showed the code at the same time.
This will let the user enter the code before we managed to connect. Now
we show a "connecting..." message first and only show the code when we
conencted.
See OpenRoberta/robertalab-ev3dev#30
dlech pushed a commit to ev3dev/brickman that referenced this issue Jul 1, 2018
We did send the code to the server and showed the code at the same time.
This will let the user enter the code before we managed to connect. Now
we show a "connecting..." message first and only show the code when we
conencted.
See OpenRoberta/robertalab-ev3dev#30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants