Python windows 10 bluetooth

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Bluetooth Python extension module

License

pybluez/pybluez

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

deprecate widcom and add linux wheels

Git stats

Files

Failed to load latest commit information.

README.md

The PyBluez module allows Python code to access the host machine’s Bluetooth resources.

This project is not under active development. Contributions are strongly desired to resolve compatibility problems on newer systems, address bugs, and improve platform support for various features.

# simple inquiry example import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names=True) print("Found <> devices.".format(len(nearby_devices))) for addr, name in nearby_devices: print(" <> - <>".format(addr, name))
# bluetooth low energy scan from bluetooth.ble import DiscoveryService service = DiscoveryService() devices = service.discover(2) for address, name in devices.items(): print("name: <>, address: <>".format(name, address))

GNU/Linux and Windows XP examples:

Читайте также:  Блютуз гарнитура своими руками

  • examples/simple/inquiry.py — Detecting nearby Bluetooth devices
  • examples/simple/sdp-browse.py — Browsing SDP services on a Bluetooth device.
  • examples/simple/rfcomm-server.py — establishing an RFCOMM connection.
  • examples/simple/rfcomm-client.py — establishing an RFCOMM connection.
  • examples/advanced/read-local-bdaddr.py — provides the local Bluetooth device address.

GNU/Linux experimental BLE support:

Please file bugs to the issue tracker. Questions can be asked on the mailing list hosted on Google Groups, but unfortunately it is not very active.

PyBluez is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

PyBluez is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PyBluez; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

About

Bluetooth Python extension module

Источник

Русские Блоги

Модуль связи Python Bluetooth Pybluez исследования заметки

Установить Bluetooth модуль связи Pybluez

Установка pybluez под Windows

Примечание. Средой разработки этой статьи является Windows10 + Python3.7.3.

Причина этой проблемы заключается в том, что соответствующий SDK не установлен в системе Windows, и нет папки Microsoft SDK.

Загрузите адрес установочного файла Windows7: https://www.microsoft.com/en-us/download/details.aspx?id=8279

Перед установкой SDK соответствующей системы лучше всего удалить распространяемый Visual C ++ 2010 и .NET.Framework в системе перед установкой соответствующего SDK.

По-прежнему возникает ошибка при повторной установке pybluez, проверьте каталог установки и следуйте директории setup.py MS_SDK = r’Microsoft SDKs \ Windows \ v6.0A ‘

Читайте также:  Msi ноутбук bluetooth драйвер

Windows7 необходимо вручную изменить папку v7.1 в Microsoft SDKs до v6.0A

Windows10 необходимо вручную изменить папку v10.0A в Microsoft SDK для v7.0A

После завершения установите новый распространяемый Visual C ++ 2010 и .NET.Framework

После того, как Windows10 выполнит описанные выше шаги, все еще будут возникать следующие проблемы:

Самый простой способ решить эту проблему — это установить среду компиляции C ++ с программным обеспечением выше Visual Studio2017 и установить его снова, чтобы добиться успеха.

Установка pybluez под Linux

Перед установкой модуля pybluez установите libbluetooth-dev, иначе будет сообщено об ошибке.

Использование Bluetooth модуля связи Pybluez

Выберите объект связи Bluetooth

Найти партнеров по общению по понятным именам

import bluetooth target_name = "My Device" target_address = None nearby_devices = bluetooth.discover_devices() for bdaddr in nearby_devices: if target_name == bluetooth.lookup_name( bdaddr ): target_address = bdaddr break if target_address is not None: print("found target bluetooth device with address ", target_address) else: print("could not find target bluetooth device nearby")

Сервисное обслуживание запросов

import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names=True) for addr, name in nearby_devices: print(" %s - %s" % (addr, name)) services = bluetooth.find_service(address=addr) for svc in services: print("Service Name: %s" % svc["name"]) print(" Host: %s" % svc["host"]) print(" Description: %s" % svc["description"]) print(" Provided By: %s" % svc["provider"]) print(" Protocol: %s" % svc["protocol"]) print(" channel/PSM: %s" % svc["port"]) print(" svc classes: %s "% svc["service-classes"]) print(" profiles: %s "% svc["profiles"]) print(" service id: %s "% svc["service-id"]) print("")

Общайтесь через RFCOMM

Программирование связи Bluetooth способом, аналогичным модели программирования сокетов

import bluetooth server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) port = 1 server_sock.bind(("",port)) server_sock.listen(1) client_sock,address = server_sock.accept() print "Accepted connection from ",address data = client_sock.recv(1024) print "received [%s]" % data client_sock.close() server_sock.close()
import bluetooth bd_addr = "01:23:45:67:89:AB" port = 1 sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) sock.connect((bd_addr, port)) sock.send("hello!!") sock.close()

Общаться через L2CAP

Метод сокетов L2CAP почти эквивалентен методу сокетов RFCOMM, единственное отличие — метод L2CAP, и порт является нечетным портом между 0x1001 и 0x8FFF. Соединение по умолчанию может передавать надежные сообщения размером 672 байта.

import bluetooth server_sock=bluetooth.BluetoothSocket( bluetooth.L2CAP ) port = 0x1001 server_sock.bind(("",port)) server_sock.listen(1) client_sock,address = server_sock.accept() print "Accepted connection from ",address data = client_sock.recv(1024) print "received [%s]" % data client_sock.close() server_sock.close()
import bluetooth sock=bluetooth.BluetoothSocket(bluetooth.L2CAP) bd_addr = "01:23:45:67:89:AB" port = 0x1001 sock.connect((bd_addr, port)) sock.send("hello!!") sock.close()
l2cap_sock = bluetooth.BluetoothSocket( bluetooth.L2CAP ) . . # connect the socket . bluetooth.set_l2cap_mtu( l2cap_sock, 65535 )

Источник

Читайте также:  Можно ли отремонтировать блютуз наушники беспроводные

1. Installing PyBluez¶

PyBluez can be installed on GNU/Linux, Windows and macOS systems and is compatible with Python 2.7 and 3.

Before you install PyBluez please install the dependencies required for your system as described in the sections below.

Installing PyBluez using pip

Open a terminal (command prompt on Windows) and enter

(there are also binaries for Windows platform on PyPI or here — Unofficial Windows Binaries for Python Extension Packages)

For experimental Bluetooth Low Energy support (only for Linux platform — for additional dependencies please take look at: ble-dependencies)

Installing PyBluez from source

or download the latest version using the links below.

Extract the zip or tar and cd to the extracted file directory, then:

for Bluetooth Low Energy support (GNU/Linux only):

1.1. GNU/Linux Dependencies¶

  • Python 2.7 or more recent version
  • Python distutils (standard in most Python distros, separate package python-dev in Debian)
  • BlueZ libraries and header files

1.2. Windows Dependencies¶

PyBluez requires a C++ compiler installed on your system to build CPython modules.

  • Microsoft Visual C++ 14.0 standalone: Build Tools for Visual Studio 2017 (x86, x64, ARM, ARM64)
  • Microsoft Visual C++ 14.0 with Visual Studio 2017 (x86, x64, ARM, ARM64)
  • Microsoft Visual C++ 14.0 standalone: Visual C++ Build Tools 2015 (x86, x64, ARM)
  • Microsoft Visual C++ 14.0 with Visual Studio 2015 (x86, x64, ARM)

Windows 10 users need to download and install the Windows 10 SDK

1.3. macOS Dependencies¶

© Copyright 2004 — 2019, Albert Haung & contributors Revision adbbbdd7 .

Versions latest stable Downloads pdf html epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Источник

Оцените статью
Adblock
detector