pypsxwakebt 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FreeTHX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: pypsxwakebt
3
+ Version: 0.1.0
4
+ Summary: A Python library to wake PlayStation consoles via Bluetooth and extract MAC addresses via USB.
5
+ Home-page: https://github.com/FreeTHX/pypsxwakebt
6
+ Author: FreeTHX
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.7
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Provides-Extra: usb
20
+ Requires-Dist: pyusb; extra == "usb"
21
+ Dynamic: author
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: provides-extra
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ # pypsxwakebt
32
+
33
+ A Python library dedicated to PlayStation (PS3, PS4, PS5) Bluetooth operations and wake-up sequences.
34
+
35
+ ## 🏛️ Legacy Notice
36
+ This library is the official, modern successor to the previous **[pywakepsXonbt](https://github.com/FreeTHX/pywakepsXonbt)** and **[pywakeps4onbt](https://github.com/FreeTHX/pywakeps4onbt)** projects. It unifies, updates, and improves the functionality of these older repositories into a single, actively maintained package.
37
+
38
+ ## 🚀 Current Status: Beta (v0.1.0)
39
+
40
+ At this stage of development, the library provides a robust utility to extract Bluetooth MAC addresses from PlayStation controllers (DualShock 3, DualShock 4, DualSense) connected via USB.
41
+
42
+ *Future releases will integrate low-level Bluetooth HCI commands, MAC address spoofing, and complete wake-up sequences directly from Python.*
43
+
44
+ ## ⚙️ Installation
45
+
46
+ To install the library with the USB extraction dependencies, run:
47
+
48
+ ```bash
49
+ pip install pypsxwakebt[usb]
50
+ ```
51
+
52
+ ## ⚡ Quick Start
53
+
54
+ Extracting the console and controller MAC addresses via USB:
55
+
56
+ ```python
57
+ from pypsxwakebt.usb import extract_psx_bt_macs
58
+
59
+ # Ensure your controller is connected via USB before running
60
+ mac_data = extract_psx_bt_macs()
61
+
62
+ if mac_data:
63
+ print(f"Controller Type: {mac_data['controller_type']}")
64
+ print(f"Controller MAC: {mac_data['dsx_mac']}")
65
+ print(f"Console MAC: {mac_data['psx_mac']}")
66
+ else:
67
+ print("No supported Sony controller found on USB.")
68
+ ```
69
+
70
+ ## 🎮 Supported Devices
71
+
72
+ * DualShock 3 (PS3)
73
+ * DualShock 4 (PS4)
74
+ * DualSense & DualSense Edge (PS5)
75
+
76
+ ## 📄 License
77
+
78
+ This project is licensed under the MIT License.
@@ -0,0 +1,48 @@
1
+ # pypsxwakebt
2
+
3
+ A Python library dedicated to PlayStation (PS3, PS4, PS5) Bluetooth operations and wake-up sequences.
4
+
5
+ ## 🏛️ Legacy Notice
6
+ This library is the official, modern successor to the previous **[pywakepsXonbt](https://github.com/FreeTHX/pywakepsXonbt)** and **[pywakeps4onbt](https://github.com/FreeTHX/pywakeps4onbt)** projects. It unifies, updates, and improves the functionality of these older repositories into a single, actively maintained package.
7
+
8
+ ## 🚀 Current Status: Beta (v0.1.0)
9
+
10
+ At this stage of development, the library provides a robust utility to extract Bluetooth MAC addresses from PlayStation controllers (DualShock 3, DualShock 4, DualSense) connected via USB.
11
+
12
+ *Future releases will integrate low-level Bluetooth HCI commands, MAC address spoofing, and complete wake-up sequences directly from Python.*
13
+
14
+ ## ⚙️ Installation
15
+
16
+ To install the library with the USB extraction dependencies, run:
17
+
18
+ ```bash
19
+ pip install pypsxwakebt[usb]
20
+ ```
21
+
22
+ ## ⚡ Quick Start
23
+
24
+ Extracting the console and controller MAC addresses via USB:
25
+
26
+ ```python
27
+ from pypsxwakebt.usb import extract_psx_bt_macs
28
+
29
+ # Ensure your controller is connected via USB before running
30
+ mac_data = extract_psx_bt_macs()
31
+
32
+ if mac_data:
33
+ print(f"Controller Type: {mac_data['controller_type']}")
34
+ print(f"Controller MAC: {mac_data['dsx_mac']}")
35
+ print(f"Console MAC: {mac_data['psx_mac']}")
36
+ else:
37
+ print("No supported Sony controller found on USB.")
38
+ ```
39
+
40
+ ## 🎮 Supported Devices
41
+
42
+ * DualShock 3 (PS3)
43
+ * DualShock 4 (PS4)
44
+ * DualSense & DualSense Edge (PS5)
45
+
46
+ ## 📄 License
47
+
48
+ This project is licensed under the MIT License.
@@ -0,0 +1,8 @@
1
+ """
2
+ pypsxwakebt
3
+ A library to manage PlayStation wake-up sequences.
4
+ """
5
+
6
+ from .usb import extract_psx_bt_macs
7
+
8
+ __all__ = ["extract_psx_bt_macs"]
@@ -0,0 +1,33 @@
1
+ """
2
+ Constants for the pypsxwakebt library.
3
+ """
4
+
5
+ # USB Vendor ID for Sony Corporation
6
+ VENDOR_SONY = 0x054C
7
+
8
+ # USB Product IDs
9
+ PID_DUALSHOCK3 = 0x0268
10
+ PID_DUALSHOCK4_V1 = 0x05C4
11
+ PID_DUALSHOCK4_V2 = 0x09CC
12
+ PID_DUALSENSE = 0x0CE6
13
+ PID_DUALSENSE_EDGE = 0x0DF2
14
+
15
+ # Controller String Identifiers
16
+ CTRL_DUALSHOCK3 = "dualshock3"
17
+ CTRL_DUALSHOCK4 = "dualshock4"
18
+ CTRL_DUALSENSE = "dualsense"
19
+ CTRL_DUALSENSE_EDGE = "dualsense_edge"
20
+
21
+ # Result Dictionary Keys
22
+ KEY_DSX_MAC = "dsx_mac"
23
+ KEY_PSX_MAC = "psx_mac"
24
+ KEY_CTRL_TYPE = "controller_type"
25
+
26
+ # Device Mapping Table
27
+ SUPPORTED_DEVICES = {
28
+ PID_DUALSHOCK3: CTRL_DUALSHOCK3,
29
+ PID_DUALSHOCK4_V1: CTRL_DUALSHOCK4,
30
+ PID_DUALSHOCK4_V2: CTRL_DUALSHOCK4,
31
+ PID_DUALSENSE: CTRL_DUALSENSE,
32
+ PID_DUALSENSE_EDGE: CTRL_DUALSENSE_EDGE,
33
+ }
@@ -0,0 +1,95 @@
1
+ """
2
+ Module for extracting PlayStation MAC addresses via USB.
3
+ Requires the 'pyusb' package (install with: pip install pypsxwakebt[usb]).
4
+ """
5
+ import logging
6
+ from typing import Dict, Optional
7
+
8
+ from .const import (
9
+ VENDOR_SONY,
10
+ SUPPORTED_DEVICES,
11
+ CTRL_DUALSHOCK3,
12
+ CTRL_DUALSHOCK4,
13
+ CTRL_DUALSENSE,
14
+ CTRL_DUALSENSE_EDGE,
15
+ KEY_DSX_MAC,
16
+ KEY_PSX_MAC,
17
+ KEY_CTRL_TYPE,
18
+ )
19
+
20
+ _LOGGER = logging.getLogger(__name__)
21
+
22
+ def extract_psx_bt_macs() -> Optional[Dict[str, str]]:
23
+ """Scans for supported controllers and extracts MAC addresses."""
24
+ try:
25
+ import usb.core
26
+ import usb.util
27
+ except ImportError:
28
+ _LOGGER.error("The 'pyusb' library is required. Install it using: pip install pypsxwakebt[usb]")
29
+ return None
30
+
31
+ dev = None
32
+ controller_type = None
33
+
34
+ # Find the first connected supported Sony controller
35
+ for pid, name in SUPPORTED_DEVICES.items():
36
+ dev = usb.core.find(idVendor=VENDOR_SONY, idProduct=pid)
37
+ if dev is not None:
38
+ controller_type = name
39
+ break
40
+
41
+ if dev is None:
42
+ return None
43
+
44
+ # Detach kernel driver if necessary so pyusb can claim the interface
45
+ kernel_driver_detached = False
46
+ if dev.is_kernel_driver_active(0):
47
+ try:
48
+ dev.detach_kernel_driver(0)
49
+ kernel_driver_detached = True
50
+ except usb.core.USBError as err:
51
+ _LOGGER.error("Failed to detach kernel driver: %s", err)
52
+ return None
53
+
54
+ try:
55
+ dsx_mac = None
56
+ psx_mac = None
57
+
58
+ if controller_type == CTRL_DUALSHOCK3:
59
+ msg_ds = dev.ctrl_transfer(0xA1, 0x01, 0x03F2, 0, 17)
60
+ dsx_mac = ":".join(f"{x:02X}" for x in msg_ds[4:10])
61
+
62
+ msg_host = dev.ctrl_transfer(0xA1, 0x01, 0x03F5, 0, 8)
63
+ psx_mac = ":".join(f"{x:02X}" for x in msg_host[2:8])
64
+
65
+ elif controller_type == CTRL_DUALSHOCK4:
66
+ msg = dev.ctrl_transfer(0xA1, 0x01, 0x0312, 0, 16)
67
+ dsx_mac = ":".join(f"{x:02X}" for x in msg[1:7][::-1])
68
+ psx_mac = ":".join(f"{x:02X}" for x in msg[10:16][::-1])
69
+
70
+ elif controller_type in (CTRL_DUALSENSE, CTRL_DUALSENSE_EDGE):
71
+ msg = dev.ctrl_transfer(0xA1, 0x01, 0x0309, 0, 20)
72
+ dsx_mac = ":".join(f"{x:02X}" for x in msg[1:7][::-1])
73
+ psx_mac = ":".join(f"{x:02X}" for x in msg[10:16][::-1])
74
+
75
+ if dsx_mac and psx_mac:
76
+ return {
77
+ KEY_DSX_MAC: dsx_mac,
78
+ KEY_PSX_MAC: psx_mac,
79
+ KEY_CTRL_TYPE: controller_type
80
+ }
81
+
82
+ except Exception as err:
83
+ _LOGGER.error("Error reading USB Feature Report: %s", err)
84
+ return None
85
+
86
+ finally:
87
+ # Always clean up USB resources
88
+ usb.util.dispose_resources(dev)
89
+ if kernel_driver_detached:
90
+ try:
91
+ dev.attach_kernel_driver(0)
92
+ except usb.core.USBError:
93
+ pass
94
+
95
+ return None
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: pypsxwakebt
3
+ Version: 0.1.0
4
+ Summary: A Python library to wake PlayStation consoles via Bluetooth and extract MAC addresses via USB.
5
+ Home-page: https://github.com/FreeTHX/pypsxwakebt
6
+ Author: FreeTHX
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.7
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Provides-Extra: usb
20
+ Requires-Dist: pyusb; extra == "usb"
21
+ Dynamic: author
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: provides-extra
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ # pypsxwakebt
32
+
33
+ A Python library dedicated to PlayStation (PS3, PS4, PS5) Bluetooth operations and wake-up sequences.
34
+
35
+ ## 🏛️ Legacy Notice
36
+ This library is the official, modern successor to the previous **[pywakepsXonbt](https://github.com/FreeTHX/pywakepsXonbt)** and **[pywakeps4onbt](https://github.com/FreeTHX/pywakeps4onbt)** projects. It unifies, updates, and improves the functionality of these older repositories into a single, actively maintained package.
37
+
38
+ ## 🚀 Current Status: Beta (v0.1.0)
39
+
40
+ At this stage of development, the library provides a robust utility to extract Bluetooth MAC addresses from PlayStation controllers (DualShock 3, DualShock 4, DualSense) connected via USB.
41
+
42
+ *Future releases will integrate low-level Bluetooth HCI commands, MAC address spoofing, and complete wake-up sequences directly from Python.*
43
+
44
+ ## ⚙️ Installation
45
+
46
+ To install the library with the USB extraction dependencies, run:
47
+
48
+ ```bash
49
+ pip install pypsxwakebt[usb]
50
+ ```
51
+
52
+ ## ⚡ Quick Start
53
+
54
+ Extracting the console and controller MAC addresses via USB:
55
+
56
+ ```python
57
+ from pypsxwakebt.usb import extract_psx_bt_macs
58
+
59
+ # Ensure your controller is connected via USB before running
60
+ mac_data = extract_psx_bt_macs()
61
+
62
+ if mac_data:
63
+ print(f"Controller Type: {mac_data['controller_type']}")
64
+ print(f"Controller MAC: {mac_data['dsx_mac']}")
65
+ print(f"Console MAC: {mac_data['psx_mac']}")
66
+ else:
67
+ print("No supported Sony controller found on USB.")
68
+ ```
69
+
70
+ ## 🎮 Supported Devices
71
+
72
+ * DualShock 3 (PS3)
73
+ * DualShock 4 (PS4)
74
+ * DualSense & DualSense Edge (PS5)
75
+
76
+ ## 📄 License
77
+
78
+ This project is licensed under the MIT License.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ psxwakebt/__init__.py
5
+ psxwakebt/const.py
6
+ psxwakebt/usb.py
7
+ pypsxwakebt.egg-info/PKG-INFO
8
+ pypsxwakebt.egg-info/SOURCES.txt
9
+ pypsxwakebt.egg-info/dependency_links.txt
10
+ pypsxwakebt.egg-info/requires.txt
11
+ pypsxwakebt.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+
2
+ [usb]
3
+ pyusb
@@ -0,0 +1 @@
1
+ psxwakebt
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,33 @@
1
+ """
2
+ Setup configuration for the pypsxwakebt package.
3
+ """
4
+ from setuptools import setup, find_packages
5
+
6
+ setup(
7
+ name="pypsxwakebt",
8
+ version="0.1.0",
9
+ description="A Python library to wake PlayStation consoles via Bluetooth and extract MAC addresses via USB.",
10
+ long_description=open("README.md").read(),
11
+ long_description_content_type="text/markdown",
12
+ author="FreeTHX",
13
+ url="https://github.com/FreeTHX/pypsxwakebt",
14
+ packages=find_packages(),
15
+ classifiers=[
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.7",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Operating System :: OS Independent",
25
+ ],
26
+ # Base dependencies (empty for now, but you can add your Bluetooth libs here later)
27
+ install_requires=[],
28
+ # Optional dependencies (The "Extras" for Home Assistant)
29
+ extras_require={
30
+ "usb": ["pyusb"],
31
+ },
32
+ python_requires=">=3.7",
33
+ )