Fast Bluetooth LE discovery on Linux? - python

I’m looking to perform Bluetooth LE device discovery on Ubuntu 22.04, coding in Python 3.10.
I’ve got a prototype using the “pybluez” library, and it’s slow. Very slow compared to other solutions on the same machine.
When I run the “Bluetooth Settings” GUI. It’s at least 10x faster than my python prototype.
When I run “bluetoothctl” and “scan le” it’s also much faster than my prototype.
An interesting third case: I run bluetoothctl, and then open the Bluetooth Settings GUI. I can see the GUI’s scan results in the CLI. Very fast! I’m guessing they both use DBus messages, and the CLI decodes messages also received by the GUI.
Another guess - the GUI issues commands on DBus. The bluetoothctl CUI doesn’t report these, though.
I’m guessing that I could use the DBus Python library to do device discovery as the settings GUI does, if I could see what command messages it writes.
How can I log/inspect DBus messages being written by the “Bluetooth Settings” app? Is there an introspection tool for DBus?
I’ve read the bluez DBus API. It’s a bit thin. Are there other examples of apps using bluez via DBus to discover LE devices?

Related

Log in to Windows from a Python service?

I'm theory crafting a Python service which will manipulate domain joined machines into running tests as part of a suite. Details of requirements
We must be logged in as a domain user, and we must not have the automatic login enabled
We need to reboot machines a few times, so it's a requirement for this to be sustainable
I'm wondering if it's possible to, from a Python service, somehow convince Windows to log us in? Presumably a Python service runs in Session0, as does Microsoft's Hardware Certification Kit? If that's capable of doing it, Python should also be (so far as I can see).
Any suggestions most welcome, I've got a suspicion there's a cheeky Windows API call that does this, but can't seem to find it anywhere.
So I've found a way to do it from a Windows service (written in C++) and presumably the ctypes library will permit me to use it.
Simple as using LogonUser from Win32API so far as I can see. Yet to actually set up and test it but it does seem to be exactly what I need. The difficulty being that session0 can only be accessed once logged in or via some remote debugging, so getting something like this working is no easy feat.

Simple Python program to connect to a secure wifi network with user input credentials

My question I guess is: Is this possible without shelling out to command line and without 3rd party Python packages? I can't seem to find any native Python commands to manipulate or configure a wireless network connection. I know there are already built-in 'netsh wlan' commands in Windows 7, but would rather this all be in python. I am also confused by the logistics of this operation. With the netsh stuff, you still are required to have a wireless profile xml file specified in the command. My current image doesn't have any wireless profiles and I do not really understand the purpose of that if you are connecting to a brand new network. Why is this not automatically generated when you connect?
A little bit about the network
Network type: Infrastructure
Authentication: WPA2-Enterprise
Encryption: CCMP
The ultimate goal is to have a script that my users can just launch, put in their credentials, and never see the multiple Windows dialogues while doing so. I'm not asking for someone to write this for me. That's what I'm suppose to do. I just need to know if anyone has successfully done something like this in strictly Python or point me in the right direction. Thanks!
No. Python standard library doesn't ship with any functionality to control platform-specific functionality like wireless adapters. You have to invoke the tools shipped with the platform, find some 3rd party libraries that control this functionality, or write your own such libraries.

Implement A2DP sink on linux system using dbus-python api

I want to implement a custom A2DP sink on my linux system running the latest Ubuntu 12.04 with the latest bluez stack.
My Basic Requirements are:
Linux system to act as a receiver(like a bluetooth headset with automatic authentication with default key "0000" or "anything")
I want to use dbus-python API to communicate with bluez stack. I want to run my own algorithm to configure communication parameters in runtime, thats y i want to implement my own sink.
later i also want to implement HSP and HFP profiles for my linux system.
Basically, I want to run these profiles and test the external bluetooth module which is connected via usb with my linux system for various audio transmission configurations and evaluate the performance under different profiles for audio reception.
I know there must be open source code already available in the web. But i couldn't find one. Even if the code is written in C or JAVA it doesn't matter for me. I require it for my educational purpose and I cannot buy commercial codes. So, people with expertise kindly help me out in creating this test bed. Because, my main objective is to modify bluez stack in future and I dont want to waste time in creating the test bed.

Dial into FTP server (Data logger) using python (OS independent)

I have a few data loggers in the field. The manufacturer set them up as dial up ftp servers. I'm writing a python program that automagically downloads all the latest files from the server into a specified folder on my computer.
Which OS independent library do you recommend for dial up?
Do you have any suggestions, comments, or concerns that you can share?
Thanks
Why not use Python's built-in ftplib? Looks pretty straightforward, unless I'm missing something?
For using a modem with Python, this thread talks about using the pyserial module.
I've never used pyserial with a modem, but I have with a USB port and an arduino. It was pretty straight forward, so I'm sure with some research about modem communication you could do it pretty easily. PySerial doesn't come with python by default, but from their site,
[PySerial] provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono).
and earlier versions exist for MacOS and others.

Is there any "remote console" for twisted server?

I am developing a twisted server. I need to control the memory usage. It is not a good idea to modify code, insert some memory logging command and restart the server. I think it is better to use a "remote console", so that I can type heapy command and see the response from the server directly. All I need is a remote console, I can build one by myself, but I don't like to rebuild a wheel. My question is: is there already any remote console for twisted?
Thanks.
twisted.manhole.telnet uses the deprecated module twisted.protocols.telnet. It is recommended to use twisted.conch.manhole instead.
Here are some tutorials of how to use it:
Writing a client with Twisted.Conch -- twisted.conch documentation
Network programming with the Twisted framework, Part 4 -- IBM developerWorks
Twisted Network Programming Essentials - Chapter 10 -- Online book preview
Take a look at twisted.manhole

Categories