mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-15 00:34:05 +09:00
updated uxplay-beacon python files
This commit is contained in:
@@ -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)')
|
||||
|
||||
Reference in New Issue
Block a user