Library for using the bleuio dongle.
Project description
##Python library for BleuIo
Instructions
- Install the library by running:
pip install bleuio
- In the python file import:
from bleuio_lib.bleuio_funcs import BleuIo
- Initialise an object with BleuIo. You can leave the parameters empty for auto detection.
# Auto-Detect dongle
my_dongle = BleuIo()
# Specific COM port (Win) 'COMX'
my_dongle = BleuIo(port='COM7')
# Specific COM port (Linux) 'dev/tty.xxxxx...'
my_dongle = BleuIo(port='/dev/tty.123546877')
# Specific COM port (Mac) 'dev/cu.xxxx...'
my_dongle = BleuIo(port='/dev/cu.123546877')
- Start the deamon (background process handler) for rt and tx data.
my_dongle.start_daemon()
- Access all BleuIo AT-commands from my_dongle object.
- The functions return a string list.
- Don't forget that you can stop started scans with:
my_dongle.stop_scan()
and SPS streams with:
my_dongle.stop_sps()
Just remember that scans and streams will run indefinitely if not otherwise specified. They will not return data until stopped using .stop_scan() or stop_sps(). Once stopped you can collect the data from my_dongle.rx_scanning_results or my_dongle.rx_sps_results. You can get a live feed by listening to .rx_buffer().
Some examples can be found in bleuio_tests\test_bleuio_funcs.py
Functions
class BleuIo(object):
def __init__(self, port='auto', baud=57600, timeout=1, debug=False):
"""
Initiates the dongle. If port param is left as 'auto' it will auto-detect if bleuio dongle is connected. :param port: str
:param baud: int
:param timeout: int
:param debug: bool
"""
def start_daemon(self):
"""
Initiates a thread which manages all traffic received from serial
and dispatches it to the appropriate callback
"""
def stop_daemon(self):
"""
Stops the thread which is monitoring the serial port for incoming
traffic from the devices.
"""
def send_command(self, cmd):
"""
:param cmd: Data to be sent over serial. Can be used with the sps stream.
"""
async def stop_scan(self):
"""
Stops any type of scan.
:return: string[]
"""
async def stop_sps(self):
"""
Stops SPS Stream-mode.
:return: string[]
"""
def at(self):
"""
Basic AT-Command.
:return: string[]
"""
def ate(self, isOn):
"""
Turns Echo on/off. ATE0 off, ATE1 on.
:param isOn: (boolean) True=On, False=Off
:return: string[]
"""
def ati(self):
"""
Device information query.
:return: string[]
"""
def atr(self):
"""
Trigger platform reset.
:return: string[]
"""
def at_advdata(self, advdata=""):
"""
Sets or queries the advertising data.
:param: if left empty it will query what advdata is set
:param advdata: hex str format: xx:xx:xx:xx:xx.. (max 31 bytes)
:return: string[]
"""
def at_advdatai(self, advdata):
"""
Sets advertising data in a way that lets it be used as an iBeacon.
Format = (UUID)(MAJOR)(MINOR)(TX)
Example: at_advdatai(5f2dd896-b886-4549-ae01-e41acd7a354a0203010400)
:param: if left empty it will query what advdata is set
:param advdata: hex str
:return: string[]
"""
def at_advstart(self, conn_type="", intv_min="", intv_max="", timer=""):
"""
Starts advertising with default settings if no params.
With params: Starts advertising with <conn_type><intv_min><intv_max><timer>.
:param: Starts advertising with default settings.
:param conn_type: str
:param intv_min: str
:param intv_max: str
:param timer: str
:return: string[]
"""
def at_advstop(self):
"""
Stops advertising.
"""
def at_advresp(self, respData=""):
"""
Sets or queries scan response data. Data must be provided as hex string.
:param: if left empty it will query what advdata is set
:param respData: hex str format: xx:xx:xx:xx:xx.. (max 31 bytes)
:return: string[]
"""
def at_central(self):
"""
Sets the device Bluetooth role to central role.
:return: string[]
"""
def at_findscandata(self, scandata):
"""
Scans for all advertising/response data which contains the search params.
:param scandata: str
:return: string[]
"""
def at_gapconnect(self, addr):
"""
Initiates a connection with a specific slave device.
:param addr: hex str format: xx:xx:xx:xx:xx:xx
:return: string[]
"""
def at_gapdisconnect(self):
"""
Disconnects from a peer Bluetooth device.
:return: string[]
"""
def at_gapscan(self, timeout=0):
"""
Starts a Bluetooth device scan with or without timer set in seconds.
:param: if left empty it will scan indefinitely
:param timeout: int (time in seconds)
:return: string[]
"""
def at_gapstatus(self):
"""
Reports the Bluetooth role.
:return: string[]
"""
def at_gattcread(self, uuid):
"""
Read attribute of remote GATT server.
:param uuid: hex str format: xxxx
:return: string[]
"""
def at_gattcwrite(self, uuid, data):
"""
Write attribute to remote GATT server in ASCII.
:param uuid: hex str format: xxxx
:param data: str
:return: string[]
"""
def at_gattcwriteb(self, uuid, data):
"""
Write attribute to remote GATT server in Hex.
:param uuid: hex str format: xxxx
:param data: hex str format: xxxxxxxx..
:return: string[]
"""
def at_peripheral(self):
"""
Sets the device Bluetooth role to peripheral.
:return: string[]
"""
def at_scantarget(self, addr):
"""
Scan a target device. Displaying it's advertising and response data as it updates.
:param addr: hex str format: xx:xx:xx:xx:xx:xx
:return: string[]
"""
def at_spssend(self, data=""):
"""
Send a message or data via the SPS profile.
Without parameters it opens a stream for continiously sending data.
:param: if left empty it will open Streaming mode
:param data: str
:return: string[]
"""
def help(self):
"""
Shows all AT-Commands.
:return: string[]
"""
#Enjoy!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bleuio-1.0.3.tar.gz
(8.3 kB
view details)
Built Distribution
bleuio-1.0.3-py3-none-any.whl
(10.4 kB
view details)
File details
Details for the file bleuio-1.0.3.tar.gz
.
File metadata
- Download URL: bleuio-1.0.3.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91047a9c5eed759b27d8fd7732e38cef918017865d9643bd804a420825505b7d |
|
MD5 | 391c0582eaf32dbf3e774eb3260509e2 |
|
BLAKE2b-256 | f59323f204a7f0fdd63b51af9a44d2f80ec9ba8054354376f5b20a5f16ca3b6b |
File details
Details for the file bleuio-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: bleuio-1.0.3-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fc0311f2c526be57035da41a034bd694362b3f3045c32997440689930945a4a |
|
MD5 | 4a4115ae03ae7f41d973cad93d090615 |
|
BLAKE2b-256 | 08a5eb8a2c2cdf94c9a1b7899078cb2251e4898cda358ffb2469482f109ad880 |