4 Commits

Author SHA1 Message Date
Shin'ichiro Kawasaki
ed4df282b1 Merge pull request #39 from rcy/master-1
Update README.md to correct micro:bit hex file download link.
2023-08-15 11:28:26 +09:00
Ryan Yeske
00154f2b51 Update README.md
Remove version number

Upstream url changed on https://scratch.mit.edu/microbit
2023-08-05 17:08:21 -07:00
Shin'ichiro Kawasaki
dc2ee5a22f Tag version 0.2.8
Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
2023-07-02 21:52:08 +09:00
Shin'ichiro Kawasaki
caa344ecbb scratch_link.py: Support COMPLETE_LOCAL_NAME for 'namePrefix' filter
Current implementation of match() does filter matching for 'namePrefix'
keyword only for SHORT_LOCAL_NAME of the device. When the device does
not provide SHORT_LOCAL_NAME but provides COMPLETE_LOCAL_NAME, match()
for 'namePrefix' fails. For example, MicroBit More v2 [1] does not
provide the SHORT_LOCAL_NAME.

To support 'namePrefix' filter match with COMPLETE_LOCAL_NAME, add
support for it. While at it, replace the SHORT_LOCAL_NAME identifier
constant with the definition in btle.ScanEntry.

[1] https://lab.yengawa.com/project/microbit-more-v2/

Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
2023-07-02 21:52:08 +09:00
3 changed files with 20 additions and 12 deletions

View File

@@ -102,7 +102,7 @@ Installation
5. For micro:bit, install Scratch-link hex on your device.
* Download and unzip the [micro:bit Scratch Hex file](https://downloads.scratch.mit.edu/microbit/scratch-microbit-1.1.0.hex.zip).
* Download and unzip the [micro:bit Scratch Hex file](https://downloads.scratch.mit.edu/microbit/scratch-microbit.hex.zip).
* Flash the micro:bit over USB with the Scratch Hex File, you will see the
five character name of the micro:bit scroll across the screen such as
'zo9ev'.
@@ -170,6 +170,10 @@ Please file issues to [GitHub issue tracker](https://github.com/kawasaki/pyscrli
Releases
--------
Release 0.2.8
* Supported Microbit More v2
Release 0.2.7
* Supported Snap Firefox and Chromium

View File

@@ -18,7 +18,7 @@ import traceback
import argparse
# for BLESession (e.g. BBC micro:bit)
from bluepy.btle import Scanner, UUID, Peripheral, DefaultDelegate
from bluepy.btle import Scanner, UUID, Peripheral, DefaultDelegate, ScanEntry
from bluepy.btle import BTLEDisconnectError, BTLEManagementError
from pyscrlink import bluepy_helper_cap
@@ -292,15 +292,19 @@ class BLESession(Session):
logger.debug("match...")
return True
if 'namePrefix' in f:
# 0x08: Shortened Local Name
deviceName = dev.getValueText(0x08)
if not deviceName:
continue
logger.debug(f"Name of \"{deviceName}\" begins with: \"{f['namePrefix']}\"?")
if(deviceName.startswith(f['namePrefix'])):
logger.debug("Yes")
logger.debug(f"given namePrefix: {f['namePrefix']}")
deviceName = dev.getValueText(ScanEntry.SHORT_LOCAL_NAME)
if deviceName:
logger.debug(f"SHORT_LOCAL_NAME: {deviceName}")
if deviceName.startswith(f['namePrefix']):
logger.debug(f"match...")
return True
deviceName = dev.getValueText(ScanEntry.COMPLETE_LOCAL_NAME)
if deviceName:
logger.debug(f"COMPLETE_LOCAL_NAME: {deviceName}")
if deviceName.startswith(f['namePrefix']):
logger.debug(f"match...")
return True
logger.debug("No")
if 'name' in f or 'manufactureData' in f:
logger.error("name/manufactureData filters not implemented")
# TODO: implement other filters defined:

View File

@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="pyscrlink",
version="0.2.7",
version="0.2.8",
author="Shin'ichiro Kawasaki",
author_email='kawasaki@juno.dti.ne.jp',
description='Scratch-link for Linux with Python',