mjbrown / bgapi

A python package for communicating with BlueGiga modules through their proprietary API.
39 stars 25 forks source link

BlueGigaClient.connect() could be more versatile #25

Open eblot opened 7 years ago

eblot commented 7 years ago

It would be nice not to enforce a BLEScanResponse instance to connect to a remote device.

A duck typed tuple such as

ScanResp = namedtuple('ScanResp', 'sender, address_type')

used as

bgmac = bytes(reversed(unhexlify(macaddr.replace(':', '')))
bgc.connect(ScanResp(bgmac, gap_address_type['gap_address_type_public']))

can be used when no scan has been performed. It could be useful to allow connection without a former scan.

There is one left exception error message to modify:

raise BlueGigaModuleException("Connection attempt unsuccessful! (%s)" % target.get_sender_address())

with

raise BlueGigaModuleException("Connection attempt unsuccessful! (%s)" % target.sender)
netom commented 5 years ago

...or just allow to connect with any BLE address.