Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu to set Bluetooth connection #2

Open
condoratberlin opened this issue May 22, 2020 · 12 comments
Open

Menu to set Bluetooth connection #2

condoratberlin opened this issue May 22, 2020 · 12 comments

Comments

@condoratberlin
Copy link

I have connected a bluetooth adapter to connect my lx nano to my openvario. Currently i establish a bluetooth connection by command line and a two line in the start up script. It would be great if an interface for a bluetooth connection could be implemented.

@condoratberlin
Copy link
Author

If you can provide me some quick start for adding a new python based menu entry, i will contribute. My Python knowledge is quiet good, but not with the GUI-stuff.

@kedder
Copy link
Owner

kedder commented May 22, 2020

The API is a bit volatile at this stage, but you can more or less get the idea what it takes if you look at file manager (ovshell_fileman):

You create the extension, and reference it in setup.py of the project:

def extension(id: str, shell: protocol.OpenVarioShell) -> protocol.Extension:
return ext.FileManagerExtension(id, shell)

openvario-shell/setup.py

Lines 40 to 44 in 72ab73a

"ovshell.extensions": [
"core=ovshell_core:extension",
"xcsoar=ovshell_xcsoar:extension",
"fileman=ovshell_fileman:extension",
],

Extension provides one or more apps

def list_apps(self) -> Sequence[protocol.App]:
return [LogDownloaderApp(self.shell)]

App pushes activity (the UI screen) to the stack

def launch(self) -> None:
act = LogDownloaderActivity(
self.shell, self._make_mountwatcher(), self._make_downloader()
)
self.shell.screen.push_activity(act)

And create() method of activity creates the actual urwid widget to show on the screen. The menu item you see is the title of the app.

I would start a new package (ovshell_wireless) for these conectivity apps.

@kedder
Copy link
Owner

kedder commented Mar 21, 2021

I expect Bluetooth connections to work in the newest version of openvario-shell (0.7.1), but I did not have a chance to test it myself (I don't have a bluetooth usb dongle at hand). The "Networking" app in ovshell is generic enough to handle anything that connman supports, so (in theory) that should also include bluetooth connections.

Please try it out with your hardware and let me know. I'll close this issue meanwhile.

@kedder kedder closed this as completed Mar 21, 2021
@condoratberlin
Copy link
Author

Thanks a lot for the great work. The wlan menue works as expected very well, exept an issue i will post in issue #3.
The bluetooth menu does not work for my configuration. I was not able to see my nano logger!

I managed to connect to my bluetooth nano logger by another approach using bluetoothctl.

Here my approach connecting to a bluetooth device:

Instruction inspired from open-vario-bluetooth with slight modifactions worked for Stefly OpenVArio with Linux 5.2 Kernel.

first install your linux friendy usb bluetooth dongle...

  1. interupt the OVmenu at startup and then exit to the shell so you get a command prompt

  2. check the usb bluetooth device recognised

root@openvario-57lvds:~# lsusb
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

you can see mine is the Cambridge Silicon Radio one.

  1. create a main.conf under /etc/bluetooth/main.conf with:
[Policy]
AutoEnable=true

to enable bluetooth at boot up.

  1. search for the device by starting bluetooth service and scan for your device and the corresponding MAC-Addr.
root@openvario-57lvds:~# systemctl enable bluetooth.service
root@openvario-57lvds:~# systemctl start bluetooth.service
root@openvario-57lvds:~# hcitool scan
Scanning ...
        <MAC-Addr>       Nano-Logger 239

here its detected my soartronic module , yay !

  1. Now use bluetoothctl to pair with the device:
[bluetooth]# power on
[bluetooth]#pair <MAC-Addr>
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device 12:34:56:78:9A:BC UUIDs:
        xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
[CHG] Device 12:34:56:78:9A:BC Paired: yes
Pairing successful
[bluetooth]#trust <MAC-Addr>
  1. now test connect the dongle to your bluetooth source
root@openvario-57lvds:~# rfcomm connect 0  <MAC-Addr>
Connected /dev/rfcomm0 to <MAC-Addr> on channel 1

Press CTRL-C for hangup

If you get this then you have paired successfully !
do the CTRL -C to exit out

  1. edit or create a .bashrc file in /home/root/.bashrc with:
rfcomm bind 0 <MAC-Addr>

now the paired and connected bluetooth device in binded to the channel 0 and will be connected if somethings tries to access the channel.

  1. reboot the OV with CTRL-ALT-DEL

  2. when OV restarts, let it get to Xcsoar

make sure your bluetooth device is on and transmitting, connected to your flarm

  1. from XCSoar menu, go to config-devices
    add a new device,
    select rfcomm0 as the device
    suggest baud rate as 19200 ( it should match your BT transmitter )
    driver FLARM

  2. thats it, the flarm data should be appearing on your new device

I hope this helps other people to use bluetooth with OpenVario

@kedder
Copy link
Owner

kedder commented Mar 27, 2021

Hm, can you try connecting to bluetooth through connmanctl? I've seen connman does support bluetooth devices, but not sure how that actually work.

@condoratberlin
Copy link
Author

I had tried but didn't managed to connect bluetooth wit connman.
If i have time to check againn I will report, but my solution described above works very stable, so I'm not sure when I will try again.

@kedder kedder reopened this Mar 28, 2021
@condoratberlin

This comment has been minimized.

@kedder

This comment has been minimized.

@condoratberlin

This comment has been minimized.

@kedder

This comment has been minimized.

@condoratberlin

This comment has been minimized.

@kedder

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants