From 5df5e56ac271d4342852acb29f3fc7fb32211517 Mon Sep 17 00:00:00 2001 From: "F. Duncanh" Date: Sun, 2 Nov 2025 17:53:41 -0500 Subject: [PATCH] add uxplay-beacon.py for windows --- .../dbus/uxplay-beacon.1 | 2 +- Bluetooth_LE_beacon/dbus/uxplay-beacon.py | 26 ++++++++----- Bluetooth_LE_beacon/winrt/uxplay-beacon.1 | 39 +++++++++++++++++++ Bluetooth_LE_beacon/winrt/uxplay-beacon.py | 28 +++++++------ CMakeLists.txt | 12 +++++- 5 files changed, 83 insertions(+), 24 deletions(-) rename uxplay-beacon.1 => Bluetooth_LE_beacon/dbus/uxplay-beacon.1 (93%) create mode 100644 Bluetooth_LE_beacon/winrt/uxplay-beacon.1 diff --git a/uxplay-beacon.1 b/Bluetooth_LE_beacon/dbus/uxplay-beacon.1 similarity index 93% rename from uxplay-beacon.1 rename to Bluetooth_LE_beacon/dbus/uxplay-beacon.1 index edfa117..2655abf 100644 --- a/uxplay-beacon.1 +++ b/Bluetooth_LE_beacon/dbus/uxplay-beacon.1 @@ -5,7 +5,7 @@ uxplay-beacon.py \- Python (>= 3.6) script for a Bluetooth LE Service-Discovery .B uxplay-beacon.py [\fI\, -h, --help] + more options. .SH DESCRIPTION -UxPlay 1.72: Standalone Python Script for managing Bluetooth LE Service Discovery. +UxPlay 1.72: Standalone Python Script for Bluetooth LE Service Discovery (DBus). .SH OPTIONS .TP .B diff --git a/Bluetooth_LE_beacon/dbus/uxplay-beacon.py b/Bluetooth_LE_beacon/dbus/uxplay-beacon.py index 603cad2..9bb4deb 100644 --- a/Bluetooth_LE_beacon/dbus/uxplay-beacon.py +++ b/Bluetooth_LE_beacon/dbus/uxplay-beacon.py @@ -8,8 +8,8 @@ import gi try: from gi.repository import GLib -except ImportError: - print(f"ImportError: failed to import GLib") +except ImportError as e: + print(f"ImportError: {e}, failed to import GLib") import dbus @@ -196,6 +196,7 @@ import sys import psutil import struct import socket +import time # global variables beacon_is_running = False @@ -222,7 +223,10 @@ def stop_beacon(): global beacon_is_running beacon_off() beacon_is_running = False - + +def pid_is_running(pid): + return psutil.pid_exists(pid) + def check_process_name(pid, pname): try: process = psutil.Process(pid) @@ -260,10 +264,13 @@ def check_file_exists(file_path): port = struct.unpack('= 3.6) script for a Bluetooth LE Service-Discovery beacon. +.SH SYNOPSIS +.B uxplay-beacon.py +[\fI\, -h, --help] + more options. +.SH DESCRIPTION +UxPlay 1.72: Standalone Python Script for Bluetooth LE Service Discovery (Windows). +.SH OPTIONS +.TP +.B +\fB\--file\fR fn Specify alternate configuration file +.TP +\fB\--path\fR fn Specify non-default Bluetooth LE data file used by uxplay +.TP +\fB\--ipv4\fR ip Override automatically-obtained ipv4 address for contacting UxPlay +.TP +\fB \-h, --help\fR Show help text. +.SH +FILES +Options in beacon configuration file ~/.uxplay.beacon +.TP +are applied first (command-line options may modify them). Format: +.TP +one option per line, with initial "--"; lines beginning with "#" ignored. +.SH +AUTHORS +.TP +Various, see website or distribution. +.SH +COPYRIGHT +.TP +Various, see website or distribution. License: GPL v3+: +.TP +GNU GPL version 3 or later. (some parts LGPL v.2.1+ or MIT). +.SH +SEE ALSO +.TP +Website: diff --git a/Bluetooth_LE_beacon/winrt/uxplay-beacon.py b/Bluetooth_LE_beacon/winrt/uxplay-beacon.py index 8821511..464c95d 100755 --- a/Bluetooth_LE_beacon/winrt/uxplay-beacon.py +++ b/Bluetooth_LE_beacon/winrt/uxplay-beacon.py @@ -38,8 +38,10 @@ import asyncio publisher = None def on_status_changed(sender, args): + global publisher print(f"Publisher status change to: {args.status.name}") - + if args.status.name == "STOPPED": + publisher = None def create_airplay_service_discovery_advertisement_publisher(ipv4_str, port): assert port > 0 @@ -73,7 +75,7 @@ async def publish_advertisement(): def setup_beacon(ipv4_str, port): #index will be ignored - print(f"setup_beacon port {ipv4_str}:{port}") + print(f"setup_beacon for {ipv4_str}:{port}") create_airplay_service_discovery_advertisement_publisher(ipv4_str, port) def beacon_on(): @@ -89,8 +91,6 @@ def beacon_on(): def beacon_off(): global publisher publisher.stop() - print(f"Current Publisher Status: {publisher.status.name}") - publisher = None #==generic code (non-winrt) below here ============= @@ -100,6 +100,7 @@ import sys import psutil import struct import socket +import time # global variables beacon_is_running = False @@ -121,6 +122,9 @@ def stop_beacon(): beacon_off() beacon_is_running = False +def pid_is_running(pid): + return psutil.pid_exists(pid) + def check_process_name(pid, pname): try: process = psutil.Process(pid) @@ -158,10 +162,13 @@ def check_file_exists(file_path): port = struct.unpack('= (3,6): print("uxplay-beacon.py requires Python 3.6 or higher") diff --git a/CMakeLists.txt b/CMakeLists.txt index b1f8b63..4e50496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,10 +78,18 @@ install( FILES uxplay.service DESTINATION ${CMAKE_INSTALL_DOCDIR}/systemd ) if (DBUS_FOUND) install( FILES Bluetooth_LE_beacon/dbus/uxplay-beacon.py DESTINATION bin - PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) -install( FILES uxplay-beacon.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 ) + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) +install( FILES Bluetooth_LE_beacon/dbus/uxplay-beacon.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 ) endif() +if (WIN32) +install( FILES Bluetooth_LE_beacon/winrt/uxplay-beacon.py + DESTINATION bin + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) +install( FILES Bluetooth_LE_beacon/winrt/uxplay-beacon.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 ) +endif() + + # uninstall target if(NOT TARGET uninstall)