rirze / mirobot-py

A Python interface library for WLkata's Mirobot
https://rirze.github.io/mirobot-py/
MIT License
24 stars 9 forks source link

Add option for a custom device connection #16

Open alxy opened 4 years ago

alxy commented 4 years ago

Currently, the device beeing used to comunicate with the mirobot is hardcoded and either serial or bluetooth: https://github.com/rirze/mirobot-py/blob/master/mirobot/base_mirobot.py#L87-L101

Would it be possible to pass a custom implementation of a device to the BaseMirobot class? I needed to do this because I want to connect your library to a simulation enviroment and thus need a custom device with additional there.

rirze commented 4 years ago

Sure, I'll add a "custom" else statement that allows passing in a class to the constructor. I'll try to have it done by today.

Just so you know, any class passed in as the device class needs to have certain elements implemented, which includes:

connect()
disconnect()
debug @property
is_connected @property
send(msg,
     disable_debug,
     terminator,
     wait,
     wait_idle)

If you're writing such a class, I'd check that it has these implemented. I'll try to make an abstract class that enforces these elements in the near future.