Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Bluetooth UI button send commands
-
Hi Jon B,
Thanks for the reply. Yes, I still didn't get that working either. Maybe I need to change the name of the button in my.ui... -
Post what you are trying... What errors are you getting.
-
It says "object hs no attribute," referencing the button. I created a separate UI and I am trying to work that in too. The error only happens after I press the word that says "button", after it appears on the screen.
-
Look, we can't help you unless you post the code you are using, along with a full traceback (print traceback).
-
Btw, in the last code you posted, you don't present your ui until after you press the X... So that may be party of your issue!
-
Hi, sorry about that. Here is a screen shot. Not a lot of time to post code with my kiddos running around so I grab a few minutes here and there when I can.
Print trace back line 38.
def a(self,sender): c=self.characteristic ``` Error says, Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/DEE1AA35-7934-4C6D-85F7-C62F8C4760BD/Pythonista3/Documents/ui test.py", line 38, in a c=self.characteristic AttributeError: 'MyCentralManagerDelegateView' object has no attribute 'characteristic' Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/DEE1AA35-7934-4C6D-85F7-C62F8C4760BD/Pythonista3/Documents/ui test.py", line 38, in a c=self.characteristic AttributeError: 'MyCentralManagerDelegateView' object has no attribute 'characteristic'
-
you need to make sure you have
self.characteristic=c
in did_discover_characteristic.
-
Hmm...I checked and it does say that. What isn't working?
-
Open the code. Press the share button, then choose share to gist. Then paste the link back here.
-
This is the entire code. Thanks for the help.
import cb import ui class MyCentralManagerDelegateView (ui.View): def __init__(self): self.peripheral = None self.charactetistic= None self.b=ui.Button(title='button') self.add_subview(self.b) self.b.action=self.a self.frame=(0,0,320,570) def did_discover_peripheral(self, p): if p.name == 'Bluno' and not self.peripheral: print ('Discovered ')+ p.name self.peripheral = p cb.connect_peripheral(self.peripheral) def did_connect_peripheral(self, p): print ('Connected Peripheral ') + p.name print ('Looking for Service FFE0') p.discover_services() def did_discover_services(self, p, error): for s in p.services: if s.uuid == 'DFB0': print ('Found Service ') + s.uuid print ('Looking for Characteristic FFE1') p.discover_characteristics(s) def did_discover_characteristics(self, s, error): for c in s.characteristics: if c.uuid == 'DFB1': print ('Found Characteristic') + c.uuid self.characteristic=c print ('Writing H') def a(self,sender): c=self.characteristic self.peripheral.write_characteristic_value(c, 'H', False) def close(self): cb.reset() v=MyCentralManagerDelegateView() cb.set_central_delegate( v) print ('Looking for HM-10-BLE module') cb.scan_for_peripherals() v.present('sheet')```
-
This post is deleted!