kivy app to connect to raspberry pi with bluetooth sockets

  Рет қаралды 275

Альберт Иванов

Альберт Иванов

7 ай бұрын

there is information gap in internet how to create kivy app that connects using android bluetooth to raspberry pi bluetooth.
steps to repeat:
1. server-examples (should be started on raspberry).
git clone github.com/pybluez/pybluez
sudo apt install libbluetooth-dev
python setup.py install --user
There we see in pybluez/examples/simple - rfcomm-server.py
But as example dont work the working code should be looking like this:
#!/usr/bin/env python3
import bluetooth
server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
server_sock.bind(("", bluetooth.PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]
uuid = "00001101-0000-1000-8000-00805F9B34FB"
bluetooth.advertise_service(server_sock, "SampleServer", service_id=uuid,
service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS],
profiles=[bluetooth.SERIAL_PORT_PROFILE],
protocols=[bluetooth.OBEX_UUID]
)
print("Waiting for connection on RFCOMM channel", port)
client_sock, client_info = server_sock.accept()
print("Accepted connection from", client_info)
try:
while True:
data = client_sock.recv(1024)
if not data:
break
print("Received", data)
except OSError as e:
print(e)#pass
print("Disconnected.")
client_sock.close()
server_sock.close()
print("All done.")
*uuid could be whatever u want but it should be the same as in kivy app.
2. to build kivy app: buildozer,kivy,kivymd should be installed. could be installed by pip:
pip install buildozer,kivy,kivymd
they say NOT to install `em by pip but i did and nothing happened - everything works (i work on ubuntu).
u cant install everything to raspberry (kivy and kivymd will but buildozer fails and without it u wont build app. trust me here i tried on Bookworm).
3.after buildozer init on its dir (standard procedure to start working with it after install - buildozer init) it forms .spec file. this is something like config to future app.
at that dir you also need main file - main.py - that will be the app.
So in buildozer dir we have:
-buildozer.spec
-main.py
Copy-paste files provided to replace ONLY main.py:
main.py - drive.google.com/file/d/1U2uD...
buildozer.spec - drive.google.com/file/d/1qHXq...
because buildozer.spec usually platform specific and one shouldnt blind replace it. Try to replace and build. But if fails just take from there lines that not commented (by #).
4. Build kivy app. In dir with files above type in console:
buildozer android debug
This will make an .apk file that u can copy-paste that .apk to your android phone and install "by hands".
The end.

Пікірлер
Control Your Raspberry Pi Remotely Using Your Phone | RaspController
8:22
Kivy, the Raspberry Pi Touch Display, and GPIO
2:14
Matt Richardson
Рет қаралды 251 М.
MEU IRMÃO FICOU FAMOSO
00:52
Matheus Kriwat
Рет қаралды 45 МЛН
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 23 МЛН
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 16 МЛН
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 15 МЛН
edge-tpu-silva+picamera2 example
1:20
Альберт Иванов
Рет қаралды 45
Best FREE Deepfake Tools in 2024 - Easy to Use ✅
4:23
TechCM Ai
Рет қаралды 1,4 М.
Auto Run an Application on Raspberry Pi Raspbian Desktop
6:15
llamafile test with OmniFusion - вопросы llama на русском
4:22
Альберт Иванов
Рет қаралды 45
arducam64mp - Failed to allocate buffers: Cannot allocate memory - fix the error
1:19
MEU IRMÃO FICOU FAMOSO
00:52
Matheus Kriwat
Рет қаралды 45 МЛН