BleuIO

BleuIO

  • Get Started
  • Buy Now
  • Manual
  • AT Commands
  • Help

›Python library < v1.2.0

Manual

  • How it works
  • How to use
  • Verbose Mode
  • Known Issues
  • Troubleshooting

Firmware Updates

    BleuIO Pro (SSD025)

    • Firmware Updates
    • Release History

    BleuIO (SSD005)

    • Firmware Updates
    • Release History of BleuIO (SSD005)

AT-Commands

  • List of AT Commands

BleuIO Libraries

  • JavaScript Library
  • Python Library

Scripts & Tutorials

  • Python: iBeacon
  • Python: Eddystone Beacon
  • Python: Scan
  • Python: Scan and Store
  • Python: SPS Script
  • Python: File transfer Script
  • Python: Repeater Script
  • Javascript: Google chrome.serial Beacon
  • C# Console App Example
  • C# WFA Example

Script using libraries

    Python library > v1.2.0

    • Custom Services example using Python library
    • Eddystone example using Python library
    • IBeacon example using Python library
    • Scan example using Python library
    • Scan and store example using Python library

    Python library < v1.2.0

    • Eddystone example using Python library
    • IBeacon example using Python library
    • Scan example using Python library
    • Scan and store example using Python library
    • SPS example using Python library
    • Security Example using Python library

    JS library

    • Eddystone example using Javascript library
    • IBeacon example using Javascript library
    • Scan example using Javascript library
    • Security Example using Javascript library
    • Get Device Distance

Projects

    Arduino

    • Arduino Example

    Beaglebone

    • Beaglebone Example

    Raspberry Pi

    • Raspberry PI into Beacon
    • Raspberry PI home automation

    Raspberry PI Pico

    • BleuIO integration (Part1)
    • BleuIO integration (Part2)
    • BleuIO integration (Part3)

    Renesas RA4M2

    • Signal Strength Monitoring
    • Real-Time CO2 monitor
    • Monitoring Air Quality

    STM32 Nucleo-144

    • Nucleo-144 board example
    • Smart Bulb Example

    M5Stack's CoreMP135

    • M5Stack's CoreMP135 board example

Build Your Own Firmware

  • Build Your Own Firmware
  • Advertising Example

More

  • Links
Order Now

BleuIO

$19.99

Buy Now

Security Example using Python library

Introduction

In this tutorial, we're going to pair two BleuIO dongle securely using Python script.

Connect two dongle into your computer that has Python installed. One dongle will take on the Central role and the other will take on the Peripheral role and The example script will help pair two dongles using predefined passkey.

  • Update the script to set peripheral dongles mac address.
  • Your selected passkey.
  • Central and peripheral dongles mac address.
# (C) 2021 Smart Sensor Devices AB

import time

from bleuio_lib.bleuio_funcs import BleuIo


passkey = "123456"
peripheral_dongle_addr = (
    "[0]40:48:FD:E5:2D:B9"  # Enter your peripheral dongles mac address here
)
connect_with_passkey = False
connect_with_numeric_comparision = False
choice = "0"

print("Welcome to the security example!\r\n")

print(
    "Choose:\r\n1). For connection with passkey\r\n2). For connection with Numeric Comparision"
)
choice = input("\r\n>>")

if choice == "1":
    connect_with_passkey = True
elif choice == "2":
    connect_with_numeric_comparision = True
else:
    print("You must choose 1 or 2. Exiting script...")
    quit()


# Start
#Enter your Peripheral dongle com port
peripehral_dongle = BleuIo(port="COM6")
peripehral_dongle.start_daemon()

#Enter your Central dongle com port
central_dongle = BleuIo(port="COM5")
central_dongle.start_daemon()

central_status = central_dongle.ati()
for i in central_status:
    # Checks if dongle is in Peripheral
    # If it is it puts the dongle in Central Mode
    if i.__contains__("Peripheral"):
        setCentral = central_dongle.at_central()

peripehral_status = peripehral_dongle.ati()
for i in peripehral_status:
    # Checks if dongle is in Central
    # If it is it puts the dongle in Peripheral Mode to allow advertising
    if i.__contains__("Central"):
        setCentral = peripehral_dongle.at_peripheral()

if connect_with_passkey:
    print(peripehral_dongle.at_set_passkey(passkey))
    print(peripehral_dongle.at_gapiocap("0"))
    print(peripehral_dongle.at_sec_lvl("3"))
    print(peripehral_dongle.at_advstart())
    print(central_dongle.at_gapiocap("2"))
if connect_with_numeric_comparision:
    print(peripehral_dongle.at_gapiocap("1"))
    print(peripehral_dongle.at_sec_lvl("3"))
    print(peripehral_dongle.at_advstart())
    print(central_dongle.at_gapiocap("1"))
    print(central_dongle.at_numcompa("0"))

print("Waiting for connection...")
time.sleep(2)
connection = central_dongle.at_gapconnect(peripheral_dongle_addr, 5)
for y in connection:
    if "CONNECTED." in str(y):
        print("Connected!")

if connect_with_passkey:
    print(central_dongle.at_enter_passkey(passkey))
if connect_with_numeric_comparision:
    print(central_dongle.at_numcompa())

time.sleep(2)
print(central_dongle.at_sec_lvl())
print(peripehral_dongle.at_sec_lvl())

exit_msg = input("Press enter to exit.")
print(central_dongle.at_gapdisconnect())
print(peripehral_dongle.at_advstop())
central_dongle.stop_daemon()
peripehral_dongle.stop_daemon()
quit()

← SPS example using Python libraryEddystone example using Javascript library →
  • Introduction

Support Request

If you have any queries or technical questions, please don't hesitate to send us a message. We will reply within 24 hours.

Message Sent!

Docs
ManualAT CommandsHelp
Community
YouTubeLinkedInFacebook
More
BleuIOSmart Sensor DevicesGitHub
Sales & Support
support@bleuio.comsales@bleuio.com
Copyright © 2025 BleuIO. A product of Smart Sensor Devices