pypavlok
Unofficial Python Bluetooth Pavlok API
Official Pavlok API makes requests to cloud service to send message to your tablet which will send Bluetooth command to your device. Maybe it works for tablet apps, but it is a quite clumsy way to zap people.
This package controls Pavlok directly with Bluetooth commands.
Requirements
Bluetooth 4 compatible adapter (Pavlok uses Bluetooth Low Energy)
Bluez
gattlib to interface gatttool
Python 2.7
Linux (I haven’t tested the code with anything else)
Installation
- Use pip:
pip install pypavlok
Be sure to install gattlib dependencies: boost-python, boost-thread and glib2
Usage
>>> from pypavlok import PyPavlok
>>> pavlok = PyPavlok() #If MAC address is not specified, it will be found using service discovery (requires root privileges)
>>> pavlok = PyPavlok('00:07:80:B5:9A:31', 'hci0') #Or pass MAC address (doesn't require special permissions)
>>> pavlok.battery_level
95
>>> pavlok.shock()
>>> pavlok.shock(level=50) #50% discharge
>>> pavlok.beep()
>>> pavlok.beep(count=3, duration_on=200, duration_off=100) #3 beeps by 0.2 sec with interval 0.1 sec
>>> pavlok.led()
>>> pavlok.led(led1=False, led2=True, count=5, duration_off=300) #Blink with red LEDs 5 times by 1 sec with interval 0.3 sec
>>> pavlok.vibrate()
>>> pavlok.firmware_revision
'2.4.28'
All action methods (shock, vibrate, led, beep) share common set of parameters:
level: discharge percents for shock(), tone for beep(), vibration speed for vibrate(), not used in led(). Default: 50
count: number of repetitions. Default: 1
duration_on: duration of action in milliseconds (<= 5 sec). Default: 1 sec
duration_off: if count > 0, set the interval between repetitions in milliseconds (<= 5 sec). Default: 1 sec
Checking your setup
Check if your bluetooth adapter is up:
$ sudo hciconfig
<device name> hci0: Type: BR/EDR Bus: USB
<device status> DOWN
If the status is down, run:
$ sudo hciconfig <device name> up
Search for BLE devices:
$ sudo hcitool lescan
LE Scan ...
<MAC address like xx:xx:xx:xx:xx:xx> Pavlok-xxxx
Ctrl-C
Try to connect to Pavlok with gatttool:
$ gatttool -b <MAC address> -I
[<MAC address>][LE]> connect
Attempting to connect to <MAC address>
Connection successful
[<MAC address>][LE]> primary
attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0008, end grp handle: 0x001a uuid: 0000180a-0000-1000-8000-00805f9b34fb
If you got to this point, everything should work
If you encounter problems with Pavlok, try pushing The Zap Button for about 15 seconds – it will blink, vibrate and reset
Metadata
Release files for pypavlok 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypavlok-0.4.tar.gz | 4.3 kB | Without provenance | Details for pypavlok-0.4.tar.gz |
Release files / pypavlok-0.4.tar.gz
| Download URL | pypavlok-0.4.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6024ae668262da4b7791d4f3c31db409dffcba78d15216318aaf325085cbf3b
|
|
BLAKE2b-256 checksum How to use checksums |
8b15584e7766fffc358e0587c15ba7511c6e76d78ae97d2a971af03d08a7503f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pypavlok 0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.