Skip to main content

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


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.4.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

bleuio-1.0.4-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file bleuio-1.0.4.tar.gz.

File metadata

  • Download URL: bleuio-1.0.4.tar.gz
  • Upload date:
  • Size: 8.4 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

Hashes for bleuio-1.0.4.tar.gz
Algorithm Hash digest
SHA256 5acb5c9bc8d036218844205d03c58a81ee75618db13021a01b6a31eb38f142b8
MD5 33f5f5363d204f51739d964ccf00f5c8
BLAKE2b-256 562e5fc0ad579b262185046c8882f597eaf7ed428a641237733163e694e03a38

See more details on using hashes here.

File details

Details for the file bleuio-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: bleuio-1.0.4-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

Hashes for bleuio-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 363bb45af0ab6f8d5fa9b532c112588f759e2facd80a9337f977d48741d010cd
MD5 135929668bb68d65e1bcd533a16315b5
BLAKE2b-256 38d1c611e8cff104f107e033a2633de6f3019af6fb024528d8ba3b6f661d2d9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page