Skip to content

Commit

Permalink
BTSession: Pretend LEGO EV3 with LEGO Hub
Browse files Browse the repository at this point in the history
To try out LEGO Hub connection as LEGO EV3, tweak BTSession device
discovery code. When the device name has "LEGO Hub", prented its device
class (major/minor=8/4) as LEGO EV3's device class (major/minor=8/1).
This is a trial code for the GitHub issue #21.

Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
kawasaki committed Nov 14, 2021
1 parent 266bcc9 commit 18e0818
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyscrlink/scratch_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def device_discovered(self, address, device_class, rssi, name):
logger.debug(f"Found device {name} addr={address} class={device_class} rssi={rssi}")
major_class = (device_class & 0x1F00) >> 8
minor_class = (device_class & 0xFF) >> 2
if "LEGO Hub" in name:
minor_class = 1
logger.info(f"Pretend to be LEGO EV3 with LEGO Hub: class={major_class/minor_class}")
if major_class == self.major_class and minor_class == self.minor_class:
self.found_devices[address] = (name, device_class, rssi)

Expand Down

0 comments on commit 18e0818

Please sign in to comment.