2017-01-20
APRS on the Raspberry Pi: talking to the mobilinkd
So I want to run APRS on the Raspberry Pi. My ultimate goal is to announce the meeting of our local radio club over 2 meter APRS but I will start with just playing "I-gate" which means I receive messages over the air and forward them to the nearest APRS server on the Internet which will then probably reject them because I'm not the only one receiving them. The first step is to link the Raspberry Pi to a radio. The easiest way is (in my opinion) to link using the mobilinkd which uses serial over bluetooth, something the Raspberry understands. I looked up how to use bluetooth on the raspberry and found Installing Bluetooth - Raspberry Pi Projects but using the suggested graphical tools requires a lot of packages:koos@joy:~ $ sudo apt-get install bluetooth bluez blueman Reading package lists... Done Building dependency tree Reading state information... Done bluez is already the newest version. bluez set to manually installed. The following extra packages will be installed: adwaita-icon-theme at-spi2-core colord colord-data dconf-gsettings-backend dconf-service fontconfig fontconfig-config fonts-dejavu-core fonts-droid gconf-service gconf2-common ghostscript gir1.2-appindicator3-0.1 gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gconf-2.0 gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-gtk-3.0 gir1.2-notify-0.7 gir1.2-pango-1.0 glib-networking glib-networking-common glib-networking-services gnome-icon-theme gsettings-desktop-schemas gsfonts hicolor-icon-theme imagemagick-common indicator-application libappindicator3-1 libasyncns0 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libbluetooth3 libcairo-gobject2 libcairo2 libcanberra-gtk3-0 libcanberra-gtk3-module libcanberra0 libcolord2 libcolorhug2 libcroco3 libcups2 libcupsfilters1 libcupsimage2 libdatrie1 libdbus-glib-1-2 libdbusmenu-glib4 libdbusmenu-gtk3-4 libdconf1 libexif12 libfftw3-double3 libfile-copy-recursive-perl libflac8 libfontconfig1 libgconf-2-4 libgd3 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgirepository-1.0-1 libgphoto2-6 libgphoto2-l10n libgphoto2-port10 libgraphite2-3 libgs9 libgs9-common libgtk-3-0 libgtk-3-bin libgtk-3-common libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libijs-0.35 libindicator3-7 libjasper1 libjbig0 libjbig2dec0 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 liblqr-1-0 libltdl7 libmagickcore-6.q16-2 libmagickwand-6.q16-2 libnotify4 libogg0 libopenobex1 libpam-systemd libpango-1.0-0 libpango1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpangox-1.0-0 libpangoxft-1.0-0 libpaper-utils libpaper1 libpixman-1-0 libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libproxy1 libpulse-mainloop-glib0 libpulse0 librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsane-extras libsane-extras-common libsm6 libsndfile1 libsoup-gnome2.4-1 libsoup2.4-1 libstartup-notification0 libtdb1 libthai-data libthai0 libtiff5 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx1 libwayland-client0 libwayland-cursor0 libx11-xcb1 libxcb-render0 libxcb-shm0 libxcb-util0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxpm4 libxrandr2 libxrender1 libxtst6 notification-daemon obex-data-server policykit-1 poppler-data python-cairo python-dbus python-dbus-dev python-gi python-gi-cairo python-gobject python-gobject-2 sane-utils update-inetd x11-common Suggested packages: bluez-cups bluez-obexd ghostscript-x libcanberra-gtk0 libcanberra-pulse cups-common libfftw3-bin libfftw3-dev libgd-tools gphoto2 gtkam gvfs libjasper-runtime liblcms2-utils libmagickcore-6.q16-2-extra pulseaudio librsvg2-bin hplip hpoj poppler-utils fonts-japanese-mincho fonts-ipafont-mincho fonts-japanese-gothic fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-nanum python-dbus-doc python-dbus-dbg python-gobject-2-dbg unpaper The following NEW packages will be installed: adwaita-icon-theme at-spi2-core blueman bluetooth colord colord-data dconf-gsettings-backend dconf-service fontconfig fontconfig-config fonts-dejavu-core fonts-droid gconf-service gconf2-common ghostscript gir1.2-appindicator3-0.1 gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gconf-2.0 gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-gtk-3.0 gir1.2-notify-0.7 gir1.2-pango-1.0 glib-networking glib-networking-common glib-networking-services gnome-icon-theme gsettings-desktop-schemas gsfonts hicolor-icon-theme imagemagick-common indicator-application libappindicator3-1 libasyncns0 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libbluetooth3 libcairo-gobject2 libcairo2 libcanberra-gtk3-0 libcanberra-gtk3-module libcanberra0 libcolord2 libcolorhug2 libcroco3 libcups2 libcupsfilters1 libcupsimage2 libdatrie1 libdbus-glib-1-2 libdbusmenu-glib4 libdbusmenu-gtk3-4 libdconf1 libexif12 libfftw3-double3 libfile-copy-recursive-perl libflac8 libfontconfig1 libgconf-2-4 libgd3 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgirepository-1.0-1 libgphoto2-6 libgphoto2-l10n libgphoto2-port10 libgraphite2-3 libgs9 libgs9-common libgtk-3-0 libgtk-3-bin libgtk-3-common libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libijs-0.35 libindicator3-7 libjasper1 libjbig0 libjbig2dec0 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 liblqr-1-0 libltdl7 libmagickcore-6.q16-2 libmagickwand-6.q16-2 libnotify4 libogg0 libopenobex1 libpam-systemd libpango-1.0-0 libpango1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpangox-1.0-0 libpangoxft-1.0-0 libpaper-utils libpaper1 libpixman-1-0 libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libproxy1 libpulse-mainloop-glib0 libpulse0 librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsane-extras libsane-extras-common libsm6 libsndfile1 libsoup-gnome2.4-1 libsoup2.4-1 libstartup-notification0 libtdb1 libthai-data libthai0 libtiff5 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx1 libwayland-client0 libwayland-cursor0 libx11-xcb1 libxcb-render0 libxcb-shm0 libxcb-util0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxpm4 libxrandr2 libxrender1 libxtst6 notification-daemon obex-data-server policykit-1 poppler-data python-cairo python-dbus python-dbus-dev python-gi python-gi-cairo python-gobject python-gobject-2 sane-utils update-inetd x11-common 0 upgraded, 165 newly installed, 0 to remove and 0 not upgraded. Need to get 65.6 MB of archives. After this operation, 189 MB of additional disk space will be used. Do you want to continue? [Y/n] n Abort.I don't need the whole graphical environment (I run my Raspberry Pi headless, so it doesn't have a graphical environment). So I searched some more and found the command bluetoothctl which does pairing in text mode, exactly what I want. It took some trying:koos@joy:~ $ hcitool scan Scanning ... 30:14:11:xx:xx:xx Mobilinkd TNC2 koos@joy:~ $ bluetoothctl [NEW] Controller B8:27:EB:xx:xx:xx joy [default] bluetooth]# pair Missing device address argument [bluetooth]# scan Missing on/off argument [bluetooth]# scan on Discovery started [CHG] Controller B8:27:EB:xx:xx:xx Discovering: yes [NEW] Device 9C:20:7B:xx:xx:xx 9C-20-7B-XX-XX-XX [NEW] Device D0:03:4B:xx:xx:xx D0-03-4B-XX-XX-XX [NEW] Device F4:F5:D8:xx:xx:xx F4-F5-D8-XX-XX-XX [NEW] Device 30:14:11:xx:xx:xx 30-14-11-XX-XX-XX [bluetooth]# pair 30:14:11:xx:xx:xx Attempting to pair with 30:14:11:xx:xx:xx Failed to pair: org.bluez.Error.AuthenticationFailed [bluetooth]# ? Invalid command [bluetooth]# help Available commands: list List available controllers show [ctrl] Controller information select <ctrl> Select default controller devices List available devices paired-devices List paired devices power <on/off> Set controller power pairable <on/off> Set controller pairable mode discoverable <on/off> Set controller discoverable mode agent <on/off/capability> Enable/disable agent with given capability default-agent Set agent as the default one scan <on/off> Scan for devices info <dev> Device information pair <dev> Pair with device trust <dev> Trust device untrust <dev> Untrust device block <dev> Block device unblock <dev> Unblock device remove <dev> Remove device connect <dev> Connect device disconnect <dev> Disconnect device version Display version quit Quit program [bluetooth]# pairable on Changing pairable on succeeded [bluetooth]# pair 30:14:11:xx:xx:xx Attempting to pair with 30:14:11:xx:xx:xx [CHG] Device 30:14:11:xx:xx:xx Connected: yes [CHG] Device 30:14:11:xx:xx:xx Name: Mobilinkd TNC2 [CHG] Device 30:14:11:xx:xx:xx Alias: Mobilinkd TNC2 Failed to pair: org.bluez.Error.AuthenticationFailed [CHG] Device 30:14:11:xx:xx:xx Connected: no [bluetooth]# agent on Agent registered [bluetooth]# pair 30:14:11:xx:xx:xx Attempting to pair with 30:14:11:xx:xx:xx [CHG] Device 30:14:11:xx:xx:xx Connected: yes Request PIN code [agent] Enter PIN code: 1234 [CHG] Device 30:14:11:xx:xx:xx UUIDs: 00001101-0000-1000-8000-00805f9b34fb [CHG] Device 30:14:11:xx:xx:xx Paired: yes Pairing successful [CHG] Device 30:14:11:xx:xx:xx Connected: no [bluetooth]#So I have to set 'scan on', 'pairable on' and 'agent on' to get in a state where a 'pair' command will start the bluetooth pairing process and ask for a pincode. Now we have a pairing, and I could add a serial connection over this. By hand this can be done with commandline rfcomm:koos@joy:~ $ sudo rfcomm connect /dev/rfcomm0 30:14:11:xx:xx:xx Connected /dev/rfcomm0 to 30:14:11:xx:xx:xx on channel 1 Press CTRL-C for hangupAnd in another terminal:koos@joy:~ $ cat /dev/rfcomm0 == BeRTOS AVR/Mobilinkd TNC2 == Version 2.0.1.571 == Voltage: 4045mV == Starting.So there is communications possible! Now to get aprs data from the mobilinkd. This should happen via the KISS protocol, but at this time I have no idea what that would like.