Comments (6)
Windows User must have a "[Bluegiga BLED112 Bluetooth Smart Dongle]"?
I'm already use Scratch 3.0 with Lego boost.
from pylgbst.
To check the connection possibility, you can just use
import logging
import time
from pylgbst import get_connection_auto
logging.basicConfig(level=logging.DEBUG)
conn = get_connection_auto()
conn.enable_notifications()
time.sleep(60) # wait 1 minute to gather info
That would give some more debugging information, might help understanding what does not work.
The requirement for BLED112 requirement is written for "the Windows version of pygatt
".
On Windows, different types of BLE hardware and different versions of libraries are known to have problems. It requires some experimentation and troubleshooting sometimes. I don't have any better solution for now.
from pylgbst.
Refer to https://github.com/rphuang/IotDevicesPy
There is the explanation with Install at windows
It works. & I try to check deeply for my thinking.
Anyway, Robot moving.
I will compare your code.
Thanks
Best Regards
from pylgbst.
Have got the same issue ((
`runfile('D:/Python/LEGO/pylgbst-master/examples/demo.py', wdir='D:/Python/LEGO/pylgbst-master/examples') 17636 INFO root Trying get_connection_bleak 17702 INFO comms-bleak Discovering devices... Press green button on Hub C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py:150: FutureWarning: The discover function will removed in a future version, use BleakScanner.discover instead. devices = await bleak.discover(timeout=1, **kwargs) 28317 WARNING hub Got only these devices: (None, None, None, None, None, None, None) Exception in thread Thread-6: Traceback (most recent call last): File "C:\Users\HUAWEI\anaconda3\lib\threading.py", line 980, in _bootstrap_inner self.run() File "C:\Users\HUAWEI\anaconda3\lib\threading.py", line 917, in run self._target(*self._args, **self._kwargs) File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 51, in self._connection_thread = threading.Thread(target=lambda: asyncio.run(self._bleak_thread())) File "C:\Users\HUAWEI\anaconda3\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\HUAWEI\anaconda3\lib\asyncio\base_events.py", line 647, in run_until_complete return future.result() File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 65, in _bleak_thread await bleak.connect(self.hub_mac, self.hub_name, **kwargs) File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 165, in connect raise ConnectionError('Device not found.') ConnectionError: Device not found.`
from pylgbst.
Tried to do this:
`from pylgbst.hub import MoveHub from pylgbst import get_connection_bleak conn = get_connection_bleak(hub_name='Move Hub') hub = MoveHub(conn) for device in hub.peripherals: print(device)`
The connection looks to established (blue constant LED on MoveHub), but MoveHub very quickly switched off.
`C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py:150: FutureWarning: The discover function will removed in a future version, use BleakScanner.discover instead. devices = await bleak.discover(timeout=1, **kwargs) Got only these devices: (None, None, None, None, None, None, None) Exception in thread Thread-6: Traceback (most recent call last): File "C:\Users\HUAWEI\anaconda3\lib\threading.py", line 980, in _bootstrap_inner self.run() File "C:\Users\HUAWEI\anaconda3\lib\threading.py", line 917, in run self._target(*self._args, **self._kwargs) File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 51, in self._connection_thread = threading.Thread(target=lambda: asyncio.run(self._bleak_thread())) File "C:\Users\HUAWEI\anaconda3\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\HUAWEI\anaconda3\lib\asyncio\base_events.py", line 647, in run_until_complete return future.result() File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 66, in _bleak_thread await bleak.set_notify_handler((self._safe_handler, self.resp_queue)) File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 215, in set_notify_handler await self._client.start_notify(MOVE_HUB_HW_UUID_CHAR, c) File "C:\Users\HUAWEI\anaconda3\lib\site-packages\bleak\__init__.py", line 649, in start_notify await self._backend.start_notify(characteristic, wrapped_callback, **kwargs) File "C:\Users\HUAWEI\anaconda3\lib\site-packages\bleak\backends\winrt\client.py", line 890, in start_notify await winrt_char.write_client_characteristic_configuration_descriptor_async( OSError: [WinError -2147467260] Operation aborted`
After that I have to restart python kernel as it hangs ((
from pylgbst.
The result of
import logging
import time
from pylgbst import get_connection_auto
logging.basicConfig(level=logging.DEBUG)
conn = get_connection_auto()
conn.enable_notifications()
time.sleep(60) # wait 1 minute to gather info
Connection seems to established:
INFO:root:Trying get_connection_bleak
DEBUG:asyncio:Using selector: SelectSelector
INFO:comms-bleak:Discovering devices... Press green button on Hub
C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py:150: FutureWarning: The discover function will removed in a future version, use BleakScanner.discover instead.
devices = await bleak.discover(timeout=1, **kwargs)
DEBUG:bleak.backends.winrt.scanner:Received 00:00:00:00:00:00: Move Hub.
DEBUG:bleak.backends.winrt.scanner:skipping callback, waiting for scan response
DEBUG:bleak.backends.winrt.scanner:Received 00:00:00:00:00:00: Move Hub.
DEBUG:bleak.backends.winrt.scanner:skipping callback, waiting for scan response
DEBUG:bleak.backends.winrt.scanner:Received 00:00:00:00:00:00: Move Hub.
DEBUG:bleak.backends.winrt.scanner:skipping callback, waiting for scan response
DEBUG:bleak.backends.winrt.scanner:Received 6F:F7:DE:81:9E:77: .
DEBUG:bleak.backends.winrt.scanner:skipping callback, waiting for scan response
DEBUG:bleak.backends.winrt.scanner:Received 00:16:53:AF:A1:FF: .
DEBUG:bleak.backends.winrt.scanner:skipping callback, waiting for scan response
DEBUG:bleak.backends.winrt.scanner:Received 00:16:53:AF:A1:FF: Move Hub.
DEBUG:bleak.backends.winrt.scanner:Received 00:16:53:AF:A1:FF: .
DEBUG:bleak.backends.winrt.scanner:Received 00:16:53:AF:A1:FF: Move Hub.
DEBUG:bleak.backends.winrt.scanner:1 devices found. Watcher status: 3.
DEBUG:comms-bleak:Devices: [BLEDevice(00:16:53:AF:A1:FF, Move Hub)]
DEBUG:comms-bleak:00:16:53:AF:A1:FF: Move Hub
DEBUG:comms:Checking device: Move Hub, MAC: 00:16:53:AF:A1:FF
INFO:comms:Found Move Hub at 00:16:53:AF:A1:FF
INFO:comms-bleak:Device matched: BLEDevice(00:16:53:AF:A1:FF, Move Hub)
DEBUG:bleak.backends.winrt.client:Connecting to BLE device @ 00:16:53:AF:A1:FF
DEBUG:bleak.backends.winrt.client:getting services (service_cache_mode=None, cache_mode=None)...
DEBUG:bleak.backends.winrt.client:session_status_changed_event_handler: id: <_bleak_winrt_Windows_Devices_Bluetooth.BluetoothDeviceId object at 0x000001EF8E932F90>, error: BluetoothError.SUCCESS, status: GattSessionStatus.ACTIVE
DEBUG:comms-bleak:Connection status: True
DEBUG:bleak.backends.winrt.client:session_status_changed_event_handler: id: <_bleak_winrt_Windows_Devices_Bluetooth.BluetoothDeviceId object at 0x000001EF8E932F10>, error: BluetoothError.SUCCESS, status: GattSessionStatus.CLOSED
DEBUG:bleak.backends.winrt.client:closing requester
DEBUG:bleak.backends.winrt.client:closing session
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Users\HUAWEI\anaconda3\lib\threading.py", line 980, in _bootstrap_inner
self.run()
File "C:\Users\HUAWEI\anaconda3\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 51, in <lambda>
self._connection_thread = threading.Thread(target=lambda: asyncio.run(self._bleak_thread()))
File "C:\Users\HUAWEI\anaconda3\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\HUAWEI\anaconda3\lib\asyncio\base_events.py", line 647, in run_until_complete
return future.result()
File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 66, in _bleak_thread
await bleak.set_notify_handler((self._safe_handler, self.resp_queue))
File "C:\Users\HUAWEI\anaconda3\lib\site-packages\pylgbst\comms\cbleak.py", line 215, in set_notify_handler
await self._client.start_notify(MOVE_HUB_HW_UUID_CHAR, c)
File "C:\Users\HUAWEI\anaconda3\lib\site-packages\bleak\__init__.py", line 649, in start_notify
await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
File "C:\Users\HUAWEI\anaconda3\lib\site-packages\bleak\backends\winrt\client.py", line 890, in start_notify
await winrt_char.write_client_characteristic_configuration_descriptor_async(
OSError: [WinError -2147467260] Operation aborted
from pylgbst.
Related Issues (20)
- Lego Train support HOT 2
- Lego Boost reconnection issue HOT 1
- LEDRGB: Current color can't be obtained/notified from the hub HOT 4
- Cannot connect to 88015 hub HOT 1
- Error on MacOS HOT 5
- 'MoveHub' object has no attribute 'connection' HOT 2
- Any plans for adding other hubs, maybe Mindstorms 515151? HOT 5
- [motors]Is there a way to ? HOT 1
- Technic Hub Port AB doesnt work HOT 16
- Connecting to WeDo SmartHub: no characteristic found HOT 7
- Cannot run a Lego tram HOT 25
- How to get Sound Files with Lego Boost app? HOT 1
- Calling hub methods from callback functions blocks further operations HOT 6
- Crashes from time to time calling bluepy function HOT 14
- How to control a DC (train) motor ? HOT 40
- Support for Powered Up Remote Handset (Lego 88010) HOT 6
- Is pylgbst thread-safe? HOT 2
- To bleak or not to bleak...? HOT 3
- AttributeError: 'NoneType' object has no attribute 'timed' HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylgbst.