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 my_dongle.at_advdatai(user_input) print('iBeacon created with uuid: {}\n'.format(user_input)) # Start advertising my_dongle.at_advstart('0', '200', '3000', '0') print('Advertising..\n') user_input = input('Enter "STOP" to terminate script\n') print('Terminating script') my_dongle.at_advstop() my_dongle.stop_daemon()
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: time_out_counter = 0 i = 0 while not connected_to_central: # Get information from the dongle # to see if it's connected to the central status = my_dongle.at_gapstatus() # Checks for information about connection if '\\nConnected\\r' in str(status): print('\nConnected to central') while True: # Listen for a received message response = str(my_dongle.rx_buffer)
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(" ")