updated uxplay-beacon python files

This commit is contained in:
F. Duncanh
2026-03-19 03:51:53 -04:00
parent 3d71c13136
commit 3b0b0dfe23
5 changed files with 205 additions and 149 deletions

View File

@@ -76,11 +76,16 @@ def start_beacon():
setup_beacon(ipv4_str, port, advmin, advmax, index)
advertised_port = beacon_on()
beacon_is_running = advertised_port is not None
if not beacon_is_running:
print(f'second attempt to start beacon:')
count = 1
while not beacon_is_running:
print(f'Failed attempt {count} to start beacon:')
advertised_port = beacon_on()
beacon_is_running = advertised_port is not None
count += 1
if count > 5:
print(f'Giving up, check Bluetooth adapter')
raise SystemExit(1)
def stop_beacon():
global beacon_is_running
global advertised_port
@@ -498,6 +503,14 @@ if __name__ == '__main__':
advminmax = f'[advmin:advmax]={advmin}:{advmax}'
if ble_type == bluez:
indx = f'index {index}'
test = None
if ble_type == winrt or ble_type == bluez:
# initial test to see if Bluetooth is available
setup_beacon(ipv4_str, 1, advmin, advmax, index)
test = beacon_on()
beacon_off()
if test is not None:
print(f"test passed")
print(f'AirPlay Service-Discovery Bluetooth LE beacon: BLE file {path} {advminmax} {indx}')
print(f'Advertising IP address {ipv4_str}')
print(f'(Press Ctrl+C to exit)')