Library for using the bleuio dongle.
Project description
##Python library for BleuIO 1.0.8
Supports BleuIO v.1.3.1
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.
"""
def stop_scan(self):
"""
Stops any type of scan.
:return: str list
"""
def stop_sps(self):
"""
Stops SPS Stream-mode.
:return: str list
"""
def at(self):
"""
Basic AT-Command.
:return:
"""
def ate(self, isOn):
"""
Turns Echo on/off. ATE0 off, ATE1 on.
:param isOn: (boolean) True=On, False=Off
:return:
"""
def ati(self):
"""
Device information query.
:return: str
"""
def atr(self):
"""
Trigger platform reset.
:return: str
"""
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_cancel_connect(self):
"""
While in Central Mode, cancels any ongoing connection attempts.
:return: string[]
"""
def at_central(self):
"""
Sets the device Bluetooth role to central role.
:return: string[]
"""
def at_enter_passkey(self, passkey):
"""
When faced with this message: BLE_EVT_GAP_PASSKEY_REQUEST use the AT+ENTERPASSKEY command to enter
the 6-digit passkey to continue the pairing request.
:param passkey: str: six-digit number string "XXXXXX"
: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, timeout=0):
"""
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_gapiocap(self, io_cap=""):
"""
Sets or queries what input and output capabilities the device has. Parameter is number between 0 to 4.
:param io_cap: str: number string "x"
:return: string[]
"""
def at_gappair(self, bonded=False):
"""
Starts a pairing (bonded=False) or bonding procedure (bonded=True).
:param bonded: boolean
: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_gapunpair(self, addr_to_unpair=""):
"""
Unpair paired devices if no parameters else unpair specific device. This will also remove the device bond data
from BLE storage.
Usable both when device is connected and when not.
:param addr_to_unpair: hex str format: [x]xx:xx:xx:xx:xx:xx
: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_get_services(self):
"""
Rediscovers a peripheral's services and characteristics.
:param addr: hex str format: "xx:xx:xx:xx:xx:xx"
:return: string[]
"""
def at_numcompa(self, auto_accept="2"):
"""
Used for accepting a numeric comparison authentication request (no params) or enabling/disabling auto-accepting
numeric comparisons. auto_accept="0" = off, auto_accept="1" = on.
:param auto_accept: str format: "0" or "1"
: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_sec_lvl(self, sec_lvl=""):
"""
Sets or queries (no params) what minimum security level will be used when connected to other devices.
:param sec_lvl: str: string number between 0 and 3
:return: string[]
"""
def at_setnoti(self, handle):
"""
Enable notification for selected characteristic.
:param handle: hex str format: "xxxx"
:return: string[]
"""
def at_set_passkey(self, passkey=""):
"""
Setting or quering set passkey (no params) for passkey authentication.
:param passkey: hex str format: "xxxxxx"
: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.8.tar.gz
(11.2 kB
view details)
Built Distribution
bleuio-1.0.8-py3-none-any.whl
(12.9 kB
view details)
File details
Details for the file bleuio-1.0.8.tar.gz
.
File metadata
- Download URL: bleuio-1.0.8.tar.gz
- Upload date:
- Size: 11.2 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 | 43a052e7cb492359a4c5c7795978efab246f6f237bdf4abf15bd435dbaf5ae2b |
|
MD5 | 5d032155a53431b32415232c80c6eafa |
|
BLAKE2b-256 | b18aede046d8f6021c19d7045e72c69548b24c9e948e54a8f26a6b80a88da993 |
File details
Details for the file bleuio-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: bleuio-1.0.8-py3-none-any.whl
- Upload date:
- Size: 12.9 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 | e819b472d9aa104f431eb909b54696e4c6e51d3a02cd25cb249b61a0b2f5fe48 |
|
MD5 | aa8d08b2efaf16e535f52c481cfcc275 |
|
BLAKE2b-256 | f816ea769b3e02abedb42133d9179555dd901c64c68fde191b33e4898fd6fe21 |