Python Forum
Sending string commands from Python to a bluetooth device
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending string commands from Python to a bluetooth device
#11
You'll need to install a bluetooth library like PyBluez or you can implement your own bluetooth interface using Python sockets. I suggest the library route.
Reply
#12
Thanks for your efforts , you are literally helping too much. I couldn't understand how can I sent the string without using bluetooth import. And as I understand you didn't attach any command to the button_click except the response. Now I'm trying to understand where should I attach the codes of "deanhystad" to the last code that you shared.
Reply
#13
(Aug-31-2021, 05:43 PM)deanhystad Wrote: Instead of a list I would use a dictionary that maps button labels to commands.
commands = {
    'TV Standby':'standby',
    ...
    'Air Conditioning On': 'ac on',
    'Air Conditioning Off': 'ac off'
}
btn_titles = list(command.keys())
Then use the dictionary to get the command.
    def button_clicked(self, idx, title):
        command = commands[title]
        # send command

Hi, thank you for your comment. Can you please show me how to attach these parts in to the code ? And I should use import bluetooth right ?
Reply
#14
I don't know. What bluetooth library are you using? Maybe you should do some investigation. See if you can find a tutorial that does something like what you want to do.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending a text from Python sawtooth500 2 198 Apr-14-2024, 01:56 PM
Last Post: sawtooth500
  Read data via bluetooth frohr 9 3,422 Jul-10-2022, 09:51 AM
Last Post: frohr
  Connect to HC-05 Bluetooth (NOT BLE) korenron 0 1,481 Jun-26-2022, 09:06 AM
Last Post: korenron
  Read buffer from bluetooth frohr 2 2,158 Jun-01-2022, 01:31 PM
Last Post: frohr
  Scan for Bluetooth device korenron 0 2,631 Jan-10-2022, 01:06 PM
Last Post: korenron
  ModuleNotFoundError: No module named 'bluetooth' Error Rovelin 4 12,210 Aug-31-2021, 04:04 PM
Last Post: Rovelin
  Python library for win32 console commands eldiener 3 3,489 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,015 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 2,282 May-18-2021, 06:31 AM
Last Post: Skaperen
  Bluetooth send message after connecting? korenron 2 2,682 Apr-26-2021, 05:50 AM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020