This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

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

Release History

Release History

0.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pypavlok-0.4.tar.gz (4.3 kB) Copy SHA256 Checksum SHA256 Source Jan 10, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting