Broadening of cb module with implementation of more methods from CoreBluetooth?
I am a beginner in programming. Started with python. I want to use Pythonista to write code for an iOS/iPadOs app that uses RSSI of a BLE device. However readRSSI is not contained in the cb module in Pythonista. It would be great if this module was expanded to include more methods, functions, classes etc from the official Apple CoreBluetooth library. Does anyone have an alternative way that I can achieve reading the RSSI by using only Pythonista programming environment?
https://pyto.app has access to RSSI…https://github.com/ColdGrub1384/Pyto/search?q=rssi
@ccc Yes, but does Pyto have access to Bluetooth ? See its discord issue
@gsot96 perhaps could you use the standard Apple CoreBluetooth framework with
from objc_util import * load_framework('CoreBluetooth')
Édit: I don't know anything about Pythonista Bluetooth module but perhaps could you try
On a connected peripheral to check if readRSSI is an ObjectiveC method
Thank you for you replies!
Indeed, Pyto has access to the CoreBluetooth module but, for the time being, it cannot utilise the iPad’s (or iPhone’s) bluetooth functionality.
However, I modified a script for a BLE device scanner that I found on GitHub, in the Pyto environment, with a view to merely test if it is possible to write code and access the CoreBluetooth library (I knew that eventually, I wouldn’t be able to utilize my device’s BlueTooth functionality from within Pyto). But I am getting the error “CBCentralManager is not defined”, even though you can see from
print(dir(CoreBluetooth))that ‘CBCentralManager’ is actually a part of the CoreBluetooth library that I just imported.
screenshot on link
@gsot96 Ok, I insist but Pythonista has also access to CoreBluetooth framework...but noT in the cb module.
@cvp I tried using:
from objc_util import *
as you suggested. The question is (and don’t forget that I am very new in programming), how should I continue? The original CoreBluetooth framework is written in ObjC and in Swift. Hence, documentation is available for these two languages only.
How can I see the the classes and functions (in python language) that become available when using the “load_framework(‘CoreBluetooth’) line you suggested?
“print(dir(CoreBluetooth))” results in
NameError: name 'CoreBluetooth' is not defined
@gsot96 I can't test without BT devices, but something like
from objc_util import * #NSBundle.bundleWithPath_('/System/Library/Frameworks/CoreBluetooth.framework').load() load_framework('CoreBluetooth') CBCentralManager = ObjCClass('CBCentralManager').alloc() l = CBCentralManager.scanForPeripheralsWithServices_options_(None, None) print(l)
@cvp ok, I think I am starting to grab the idea. Thank you for your help. I’ll try my best for a couple of days and come back again with the/any(?) results.
@gsot96 good luck. I know there some guys in the forum who have some experience with BT.
I hope they are there and could help you much more than I can