Open pdeboer1987 opened 7 years ago
Seems like the Class Attributes:
bgapi_rx_buffer = []
bgapi_rx_expected_length = 0
busy = False
packet_mode = False
debug = False
should be Instance variables in init, otherwise their definition is carried over to the next instance.
The events should be defined in init as well, because if you had two instances, that would be bad news. I tried doing this, but for some reason that breaks the BGAPIEvent property and it doesn't return an event handler anymore.
You're probably correct; this was some of the first complex Python code I ever wrote, and coming from C/C++, I didn't know the Pythonic way to differentiate between class variables and instance variables (or that I C-instance-like syntax would result in C-static-like behavior).
I'm not sure about the event properties; I'd have to dig into that. I'm currently pretty occupied with other projects and not likely to be able to investigate and fix this soon myself.
I made a branch. I'm not 100% sure it is correct.
Hi,
To start let me inform you the I'm using BGLib in Python 2.5. It was a straight forward conversion, so I don't expect a problem there.
The Issue:
I don't seem to be able to dispose of the BGLib object and run again. The result is that the first attempt will find a list of nearby devices. The second attempt will timeout and return an empty list having never serviced the ble_evt_gap_scan_response event.
Sorry about the formatting, I can't seem to find the way to show code correctly
import bglib,serial,time
gap_scan_response handler
def evt_find_device(sender, args):
print "evt_find_device" global devices
if name == 'main': timeout = 10