from bleuio_lib.bleuio_funcs import BleuIo import time my_dongle = BleuIo() my_dongle.start_daemon() print("\n\nConnected to Dongle.\n") print("\nWelcome to the iBeacon example!\n\n") success = "" while True: if not success: new_input = input( "Enter the iBeacon UUID (x) string with Major (j), " "Minor (n) and TX (t)\n" "Example: ebbaaf47-0e4f-4c65-8b08-dd07c98c41ca0000000000\n>> ") success = my_dongle.at_advdatai(new_input) time.sleep(0.1) if "OK" in str(success): advstart = my_dongle.at_advstart() print(advstart) if not input("Press any key to exit."): my_dongle.at_advstop() break else: print("Error, try again.") success = ""
from bleuio_lib.bleuio_funcs import BleuIo from serial import SerialException from time import sleep # This script will receive data from a central dongle # and echo it back to the central my_dongle = None connected_to_dongle = False connected_to_central = False message = '' while not connected_to_dongle: try: # Specify the COM PORT connected to the dongle my_dongle = BleuIo() # Start the deamon (background process handler) for RX and TX data. my_dongle.start_daemon() connected_to_dongle = True except SerialException: print('Dongle not found. Please connect your dongle') sleep(5) print('Connected to dongle\n\n' 'Welcome to the BleuIO SPS example!\n\n') # //TODO byt namn på de andra # Starts advertising so it can be detected my_dongle.at_advstart() try:
my_dongle = None connected_to_dongle = False connected_to_peripheral = False message = "" target_device_address = "" # This script will send data from a central dongle(my_dongle) # to a peripheral device(target_device_address) # which in turn will echo it back to the central # Target device needs to be set in peripheral role and be advertising while not connected_to_dongle: try: # Specify the COM PORT connected to the dongle my_dongle = BleuIo(port="COM3") # Start the deamon (background process handler) for RX and TX data. my_dongle.start_daemon() connected_to_dongle = True except SerialException: print("Dongle not found. Please connect your dongle") sleep(5) print( "Connected to dongle\n\n" "Welcome to the BleuIO SPS example!\n\n" ) # //TODO byt namn på de andra # Set the dongle in central role my_dongle.at_central()
import time from bleuio_lib.bleuio_funcs import BleuIo reciever_dongle_port = "COM74" # Change this to your dongle's COM port mac_addr_to_repeater = ( "[0]40:48:FD:E5:2D:74" # Change this to your repeater dongle's mac address ) buffer = "" connected = False connecting = "" reciever_dongle = BleuIo(port=reciever_dongle_port) reciever_dongle.start_daemon() print("Dongle found.") def save_msg(buffer): """ Parses incomming data string for just the data and prints it out. """ result = buffer result_array1 = result.split("\r\n") result_array = result_array1[2].split(" ") msg_to_save = str(result_array[0]) print("Recieved = " + msg_to_save) try:
from bleuio_lib.bleuio_funcs import BleuIo from time import sleep my_dongle = BleuIo() my_dongle.start_daemon() print("\nConnected to dongle\n\n" "Welcome to the Bluetooth device Scanning example!\n\n") # Set the dongle in central role my_dongle.at_central() user_input = input("Enter:\n" '"1" Continuous scan\n' '"2" Scan for a limited time\n' '"3" Scan a target device\n') if user_input == "1": # "Continuous scan" option # Start scanning for bluetooth devices my_dongle.at_gapscan() log = [] try: while True: # Fetch response from the dongle response = my_dongle.rx_scanning_results # Iterate the response for every device found for device in response: # Add and print the device if its not already found
import time from bleuio_lib.bleuio_funcs import BleuIo import random sender_dongle_port = "COM73" # Change this to your dongle's COM port mac_addr_to_repeater = ( "[0]40:48:FD:E5:2D:74" # Change this to your repeater dongle's mac address ) sender_dongle = BleuIo(port=sender_dongle_port) sender_dongle.start_daemon() connected = False data = "" buffer = "" def scan_and_get_results(): """ Starts a BLE scan for three seconds, looking for results including the 'FF' flag in the advertising data. Then it saves the results in a list and returns one of the results as a string. :return: string """ print("Scanning...") return_data = "" result_list = [] time.sleep(0.5) try: scanning = sender_dongle.at_findscandata("FF") if "SCANNING" in scanning[0]: time.sleep(4)
from bleuio_lib.bleuio_funcs import BleuIo from serial import SerialException from time import sleep # This script will receive data from a central dongle # and echo it back to the central my_dongle = None connected_to_dongle = False connected_to_central = False message = "" while not connected_to_dongle: try: # Specify the COM PORT connected to the dongle my_dongle = BleuIo(port="COM6") # Start the deamon (background process handler) for RX and TX data. my_dongle.start_daemon() connected_to_dongle = True except SerialException: print("Dongle not found. Please connect your dongle") sleep(5) print("Connected to dongle\n\n" "Welcome to the BleuIO SPS example!\n\n") # Starts advertising so it can be detected my_dongle.at_advstart() try: time_out_counter = 0
from bleuio_lib.bleuio_funcs import BleuIo # //FIXME går det att importera endast BleuIO? from serial import SerialException from time import sleep my_dongle = None connected = False while not connected: try: # Connect to dongle my_dongle = BleuIo() # Start the deamon (background process handler) for RX and TX data. my_dongle.start_daemon() connected = True except SerialException: print('Dongle not found. Please connect your dongle') sleep(5) print('\nConnected to dongle\n' 'Welcome to iBeacon example!\n') # Prompting user to enter a iBeacon UUID url to be broadcast user_input = input( 'Enter the iBeacon UUID (x) string with Major (j), ' 'Minor (n) and TX (t)\n' '(Example: ebbaaf47-0e4f-4c65-8b08-dd07c98c41ca0000000000):\n') while user_input.casefold() != 'stop': # Starts the beacon if the UUID matches the correct format # Sets the UUID as data to be advertised
import time from bleuio_lib.bleuio_funcs import BleuIo my_dongle = BleuIo() my_dongle.start_daemon() print("\n\nConnected to Dongle.\n") print("\nWelcome to the Eddystone example!\n\n") success = "" while True: if not success: new_input = input("Enter the Eddystone formatted url:\n" "Example: 0d:16:aa:fe:10:00:03:67:6f:6f:67:6c:65:07 " "(https://google.com)\n>> ") success = my_dongle.at_advdata("03:03:aa:fe " + new_input) time.sleep(0.1) if "OK" in str(success): advstart = my_dongle.at_advstart() print(advstart) if not input("Press any key to exit."): my_dongle.at_advstop() break else: print("Error, try again.") success = ""
import time from bleuio_lib.bleuio_funcs import BleuIo repeter_dongle_port = "COM38" # Change this to your dongle's COM port repeter_dongle = BleuIo(port=repeter_dongle_port) repeter_dongle.start_daemon() buffer = "" num_of_connected_devices = 0 connection_list = [] print("Dongle found.") repeter_dongle.at_dual() repeter_dongle.at_advstart() repeter_dongle.rx_state = "rx_waiting" print("Waiting for other dongles to connect...") def send_msg(buffer): """ Parses incomming data string for just the data and sends it forward via the Serial Port Service. """ try: result = buffer msg_to_send = "" result_array1 = result.split("\r\n") for line in result_array1: if "[Received]:" in line: msg_to_send = line.split(" ")
from datetime import datetime from bleuio_lib.bleuio_funcs import BleuIo # from serial import SerialException from time import sleep my_dongle = BleuIo() my_dongle.start_daemon() print("Connected to dongle\n\n" "Welcome to the Bluetooth device Scan and Store example!\n\n") # Set the dongle in central role my_dongle.at_central() user_input = input( "Enter something such as a Manufacturer Specific (MFS) ID to scan for " "and store in a file or just leave it blank to scan all:\n") # Scans with a specific id or all devices if none is provided my_dongle.at_findscandata(user_input) log = "" while user_input.casefold() != "stop": user_input = input('Enter "STOP" to stop scanning\n') # If the user stops the scan log reformat and log the response if user_input.casefold() == "stop": # Stop the scan