legoino icon indicating copy to clipboard operation
legoino copied to clipboard

Make connection flow easier

Open corneliusmunz opened this issue 3 years ago • 1 comments

With more devices handled in an Arduino sketch the connection flow and the boilerplate code becomes more and more complicated. In this issue i want to discuss the requirements of a more easy way of the connection procedure. Initial thoughts came from @falk12 written in the following thread of another issue: https://github.com/corneliusmunz/legoino/issues/34#issuecomment-722257005

Main Goals:

  • Single Setup command where the hub with attached devices, callbacks could be defined
  • If defined in the setup, the ports will be activated for updates automatically if a device is connected
  • Support of use and array multiple hub instances
  • Get rid of the isConnecting / connectHub methods and do this internally in the library

corneliusmunz avatar Nov 11 '20 16:11 corneliusmunz

Hello

Here are some ideas to describe a hub. This might be done via a class or a structure. Some properties might be

  • useMacAddress optional:MacAdress of an existing device
  • Device-Type (list of allowed Hubs)
  • Port A-device (list of allowed devices)
  • Port A-callback (list of used callbacks)
  • .

They have to be coded(defined) by user and all used in a new "Conncet" routine, icluding init/isConnected/delay() and so on. Perhaps you add that as an additional routine (for backward compatibility)?

Other values might be filled automatically

  • status
  • hubButton
  • battery_Voltage
  • Device-Type
  • Port A Device-type attached
  • Port B device-type attached

And so on.

More values should be added if necessary

It could be useful to store other values like “hubButton”, as you can’t ask for the state within the program. (or is this still possible with the V 1.0.2 ?)

So the callback would have to store “true” and “false” when executed.

Another idea would be to have a byte per port to save the status:

1 no device attached 2 wrong device 3 correct device 4 port ready 5 callback running (?)

we could use this as an interface to any kind of display to show what is the status of the complete hub.

For my little project I choose a structure to do that. First as I am not that familiar with classes, second to use a loop code to stop all motors on all ports and shutdown all hubs when pressing on button.

Question: isn’t there a lot of overhead when reporting hubProperties, because the battery_Voltage changes rapidly, as well of rotations? Can you turn off notifications? Is this useful?

falk12 avatar Nov 12 '20 17:11 falk12