ready = input( "Press enter to connect to the repeater dongle. (This should be connected first)." ) print("Connecting...") reciever_dongle.at_gapconnect(mac_addr_to_repeater) time.sleep(5) while not connected: connected_status = reciever_dongle.ati() if "\r\nConnected" in connected_status[0]: connected = True break if "\r\nNot Connected" in connected_status[0]: reciever_dongle.at_gapconnect(mac_addr_to_repeater) time.sleep(5) print("Trying to connect...") time.sleep(2) print("Connected.") print("Waiting to recieve...") while 1: buffer = reciever_dongle.rx_buffer.decode("utf-8", "ignore") if "\r\nhandle_evt_gattc_notification:" in buffer: save_msg(buffer) time.sleep(0.5) except KeyboardInterrupt: reciever_dongle.at_cancel_connect() reciever_dongle.at_gapdisconnect() reciever_dongle.at_advstop() print("Shutting down script.")
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 = ""
print("Forwarding data to reciever:") print(msg_to_send) if not msg_to_send == "": repeter_dongle.at_spssend(msg_to_send) repeter_dongle.rx_state = "rx_waiting" except: print(" ") try: while 1: buffer = repeter_dongle.rx_buffer.decode("utf-8", "ignore") if "\r\nCONNECTED." in buffer: num_of_connected_devices = num_of_connected_devices + 1 print("A Dongle has connected!") repeter_dongle.at_advstart() repeter_dongle.rx_state = "rx_waiting" if "DISCONNECTED." in buffer: num_of_connected_devices = num_of_connected_devices - 1 connection_list = [] print("No Dongles connected.") if num_of_connected_devices > 1: if "\r\n[Received]:" in buffer: # print(buffer) send_msg(buffer) buffer = "" time.sleep(0.1) except KeyboardInterrupt: repeter_dongle.at_advstop() repeter_dongle.at_gapdisconnect() print("Shutting down script.")