https://github.com/lecodeurdudimanche/php-bluetooth
A package to manage bluetooth connexions on Linux using PHP, relying on the BlueZ stack
https://github.com/lecodeurdudimanche/php-bluetooth
bluetooth linux php
Last synced: about 1 year ago
JSON representation
A package to manage bluetooth connexions on Linux using PHP, relying on the BlueZ stack
- Host: GitHub
- URL: https://github.com/lecodeurdudimanche/php-bluetooth
- Owner: LeCodeurDuDimanche
- License: mit
- Created: 2020-07-03T16:35:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-28T22:39:42.000Z (over 5 years ago)
- Last Synced: 2025-04-11T18:02:09.537Z (about 1 year ago)
- Topics: bluetooth, linux, php
- Language: PHP
- Homepage:
- Size: 65.4 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: License.md
Awesome Lists containing this project
README
# PHP Bluetooth
## A package to manage bluetooth connexions on Linux using PHP
This package relies on the Bluez stack, using the `bluetoothctl` tool.
*This package is in early development stage*
## Requirements
This library relies on the BlueZ stack, so you need to install `bluez` and `bluez-tools` packages. \
PHP version >= 7.2
## Installation
```
composer require lecodeurdudimanche\php-bluetooth
```
## Basic usage
The `Manager` class is the entry point of this library. \
To launch the `Manager` and set the bluetooth adapter in a discoverable state and to accept paring :
```php
use lecodeurdudimanche\PHPBluetooth\Manager;
$manager = new Manager($discoverable, $pairable);
```
Next you can manage the bluetooth connextion through the `Manager`, keep in mind that all commands (but not all methods) are asynchronous :
```php
use lecodeurdudimanche\PHPBluetooth\Device;
$manager->scanDevices(); //Initiate device scan
$manager->setPairable(false);
$manager->pairDevice(new Device($mac));
$manager->updateBluetoothInfo();
$data = $manager->getBluetoothInfo();
foreach($data->getAvailableDevices() as $device)
{
if (! $device->paired)
$manager->blockDevice($device);
}
// Other methods are available, see Manager class
```
## TODO
- Add detection of discoverable and pairable status at startup
- Add support to exclude unscanned paired devices from scanned devices list
- Add detection of trusted and blocked devices
- Add I/O exception handling
## License
MIT License