概要
GooglePlay AgribusNAVIに、Raspberry PiのBluetoothからNMEAを流せたら(諸所もろもろの事情で)便利だなと思い立ち、とりあえず目標達成はできたのでメモがわりに公開します。
参考文献
・RaspberryPi (jessie)とMac間のBluetooth通信[16/10/12時点 最新版]
bluetoothの設定
参考文献のほうが詳しく書いてあるので、そちらも参照してください。
#ExecStart=/usr/lib/bluetooth/bluetoothd
ExecStart=/usr/lib/bluetooth/bluetoothd --compat
ペアリング
$ sudo bluetoothctl
trust XX:XX:(AndroidのBluetoothアドレス)
quit
Androidの操作
「設定」にある「Bluetooth」からRaspberry Piを見つけてペアリングする。
「AgriBusNAVI」の設定にあるGPSの設定をBluetoothに設定。接続するBluetoothをRaspberry Piに設定する。
Bluetooth SPPを自動起動
末尾にあるexit 0の前に追加。
sdptool add --channel=22 SP &
sudo rfcomm listen /dev/rfcomm0 22 &
rtklibのソースをgitで拾ってきてコンパイル
$ sudo apt-get install git
$ mkdir RTKLIB
$ cd RTKLIB
$ git clone https://github.com/tomojitakasu/RTKLIB.git
$ sh makeall.sh
$ cd ~/
実行権限を付与。ついでにconfファイルをコピー。
$ cd RTKLIB/RTKLIB/app/rtkrcv/gcc/
$ chmod 755 rtkstart.sh
$ chmod 755 rtkshut.sh
$ cp ../rtk.conf ./
rtk.confを編集する
熟知してるレベルからは遥かに遠いレベルなので、とりあえずRTKLIBの説明書とトラ技jrのアドレス貼っておきます。
http://toragi.cqpub.co.jp/Portals/0/support/junior/index.html
http://www.rtklib.com/prog/manual_2.2.0.pdf
rtklibの起動スクリプトを用意
#/bin/sh
cd /home/pi/RTKLIB/app/rtkrcv/gcc/
screen -dm -S rtkrcv ./rtkrcv -s -o ./rtk.conf
screenで起動しているので、起動後にrootからはアタッチできます。
自動起動するように設定
末尾にあるexit 0の前に追加。
sh /home/pi/rtkstart.sh &
おまけ(シャットダウンスイッチを付ける)
あとがき
とりあえず接続はできたものの、自分の環境ではbluetoothが数分-10分程度で切断されてしまって、不安定すぎて使い物にならないレベル。
bluetoothに流れてるnmeaデータが文字化けして落ちてるような気がするけれども、今日のところはここまで。