Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
「BluetoothでLinuxマシンとAndroidを繋いで話が出来るようにした話」「台風で...
Search
Kenichiro MATOHARA
October 25, 2014
Technology
14
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
「BluetoothでLinuxマシンとAndroidを繋いで話が出来るようにした話」「台風で停電になって省電力の設定をした話」「ネットワークの設定が引き継がれなくて困ったので調べた話」 の3本です
鹿児島Linux勉強会 第06回
http://kagolug.doorkeeper.jp/events/16112
Kenichiro MATOHARA
October 25, 2014
More Decks by Kenichiro MATOHARA
See All by Kenichiro MATOHARA
ターミナルグラフィックウェブブラウザ!?
matoken
0
36
軽量ウェブブラウザDilloのPlugin
matoken
0
48
今更LLMを触り始める(ローカルLLM bonsai)
matoken
0
160
念願のNDLOCR-Lite を試す
matoken
0
120
Nextcloud と互換性のある軽量WebDAV server のKaraDAV を試す
matoken
0
120
ActivityPub Server の snac その3
matoken
0
87
ActivityPub Server の snac その2
matoken
0
62
端末録画再生共有アプリ asciinema 3.0 リリース
matoken
0
100
アナウンス向けにミニマリスト向け ActivityPub Server の snac を利用
matoken
0
150
Other Decks in Technology
See All in Technology
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
140
Reactの設計論
uhyo
14
7.8k
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
350
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
140
GoCon2026 - Open Source, Open World
sanposhiho
3
3.1k
あるけみー式LTスライド作成術
alchemy1115
1
170
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
180
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
25k
コスト最適化の「めんどくさい」を AWS FinOps Agent でチョット楽にする
classmethod_kaz
0
300
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
2
460
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
2.6k
WAF 運用改善の承認サイクル/SRE_BizReach_MIXI_1
visional_engineering_and_design
2
420
Featured
See All Featured
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
490
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Embracing the Ebb and Flow
colly
88
5.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Crafting Experiences
bethany
1
310
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
270
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
520
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
Transcript
「BluetoothでLinuxマシンとAndroidを繋いで 話が出来るようにした話」「台風で停電になっ て省電力の設定をした話」「ネットワークの設 定が引き継がれなくて困ったので調べた話」 の3本です KenichiroMATOHARA(matoken) <
[email protected]
> Linux 06 鹿児島
勉強会 第 回 2014-10-25(Sat)
Kenichiro MATOHARA • @matoken • http://matoken.org/ • 興味 – Linux
– FLOSS – OpenSteetMap – 電子工作 – :
「鹿児島らぐ(Kagoshima Linux User Group)」を立ち上げました http://kagolug.org/ 鹿児島のお友達に教えてあげてね
鹿児島らぐ • 今のところ鹿児島Linux勉強会を月1回開催 – 今回第6回で0回目から数えて7回目の開催 • 鹿児島Linux勉強会 – Linux読書会 –
Linux関連の発表 – その他… • これからの予定 – 来月オープンソースカンファレンス2014福岡出展 http://www.ospn.jp/osc2014-fukuoka/ – オープンソースアンカンファレンス鹿児島開催 – OSMもそろそろやりたい
None
今日のネタ • BluetoothでLinuxマシンとAndroidを繋いで 話が出来るようにした話 • 台風で停電になって省電力の設定をした話 • ネットワークの設定が引き継がれなくて困っ たので調べた話
None
BluetoothでLinuxマシンとAndroidを繋いで話 が出来るようにした話 (RaspberryPiでSPP)
精度の高いGPSモジュールを利用 して位置測定をしたい • OpenStreetMap Foundation Japanの miurahrさんの小江戸らぐ9月のオフな集まり発 表資料を見る • "技適な
Bluetooth GNSS/GPS レシーバー の作成と活用” • 面白そう • BluethoothSPPモジュールは持ってないけれど RaspberryPiやUSB Bluethoothモジュールは あるのでこれで真似したい • ついでにログ取りとかもするようにしたい
用意したもの • RaspberryPi B+(A/Bでもok) • USB Bluethoothドングル – 5種類くらい持っていてこれまでに使えなかった 物はないが,購入前に型番で検索して利用でき
るか確認したほうが無難 • OSはRaspberryPi標準のRasbianを利用 (DebianWheezyベース) – GUIは重いのでCUIで設定 • Android端末にSPP接続が出来る Bluetooth Terminalを導入
RasbianへのBluetooth関連ソフト ウェアの導入 $ sudo apt-get update $ sudo apt-get upgrade
$ sudo apt-get install bluetooth bluez
デーモンが起動しているのを確認 $ /etc/init.d/bluetooth status bluetooth is running.
Bluetooth デバイスの確認 $ hcitool dev Devices: hci0 E0:91:53:77:E8:99 $ hciconfig
-a hci0: Type: BR/EDR Bus: USB BD Address: E0:91:53:77:E8:99 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:10030 acl:8 sco:0 events:191 errors:0 TX bytes:1702 acl:8 sco:0 commands:111 errors:0 Features: 0xff 0xff 0x8f 0xfe 0x9b 0xbf 0x59 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'raspberrypi-0' Class: 0x420100 Service Classes: Networking, Telephony Device Class: Computer, Uncategorized HCI Version: 3.0 (0x5) Revision: 0x1aa1 LMP Version: 3.0 (0x5) Subversion: 0x1aa1 Manufacturer: Cambridge Silicon Radio (10)
周りのデバイス検索 $ hcitool scan Scanning ... 78:DD:08:B0:1F:37 x201s-0 98:91:20:21:55:78 Bluetooth
Keyboard ※周りのデバイスは検索可能にしておく
ペアリングが可能なようにモード を変更してペアリング • ペアリング可能なようにモード変更 $ sudo hciconfig hci0 piscan •
ペアリング(ペアリングのキーはこの場合 4835) $ sudo bluetooth-agent 4835 Confirmation request of 396777 for device /org/bluez/2150/hci0/dev_70_F9_27_71_74_5 B ※ペア先のデバイスは検出可能にしておく
プロトコル確認 • SPPが利用できるのを確認する $ sdptool browse local • SPPが登録されていなかったら以下のように して登録する
$ sdptool add --channel=22 SP
SPPで接続して通信を試みる $ sudo rfcomm listen /dev/rfcomm0 22 Waiting for connection
on channel 22 Connection from 70:F9:27:71:74:5B to /dev/rfcomm0 Press CTRL-C for hangup • これで /dev/rfcomm0 を通してSPP通信が出 来る
実際に通信してみる • 別端末で受信したり $ cat /dev/rfcomm0 test hello hello pi
• 送信したり $ echo "hello android" > /dev/rfcomm0
ひとまず今回はここまで
これから • Bluethooth自動接続 • DiskのRO化(電源断に対処するため) • GPSを接続(以前確認済み) • GPSのデータをSPPに流すようにする •
GPSのデータをローカルに保存するようにする (領域を分けて保存できるようにする) • その他 – BUN/PAN等のプロトコルも試してみたい(Bluethooth モバイルルータ化)
• 参考URL "ja/BluetoothUser - Debian Wiki" https://wiki.debian.org/ja/BluetoothUser " 技適な Bluetooth
GNSS/GPS レシーバーの 作成と活用" https://dl.dropboxusercontent.com/u/90779 460/Bluetooth_GNSS_receiver_201409.pdf
None
台風で停電になって省電力の設定をした話 (powertop)
台風15号上陸>< • 停電になって半日復旧しなかった…. • NotePCで凌ぐ 気圧958mb迄下がりました!
省電力の設定をする • 必要ないデバイスは外す,停止する – 無線ヘッドホン,BTアダプタ取り外し – 液晶輝度を下げる • CPUを絞る(cpufreq) •
デバイスを設定で省電力にする – 今回はコレ ※以前小江戸らぐで発表したこちらも参考になるかも "最近の身の回りの電力事情" http://www.slideshare.net/matoken/ss-7961752
powertop • Intel謹製電力消費状況測定ツール • Intelプラットホーム向け • CPUを頻繁に起床させるプロセスをTOPライク に表示したり,省電力のアドバイスも • アドバイスに従いデバイスの設定をすることで
省電力に • 現在はpowertop2になっている "PowerTOP | 01.org" https://01.org/powertop/
導入 • 最近は普通にパッケージで用意されているの でパッケージで導入 – DebianJessieでの例 % sudo apt-get install
powertop
先ずはキャリブレーション • キャリブレーション % sudo powertop –calibrate – 確認したいデバイスが接続された状態かつバッ テリ稼動状態で実行すること
– キャリブレーション中液晶の輝度が最低になっ たりするけど正常な動作 実行例 > https://gist.github.com/113921d37a0180a71bed
• 起動 % sudo powertop • タブキーで項目移動
Tunables • Tunablesタブでデバイスの省電力の設定が可 能 • Bad となっているデバイスをカーソルで選択 し,Enterで設定 • この時上部に表示される設定をメモしておき
起動時に反映するようにするといい (powertopコマンドで設定した内容は再起動 で消えてしまう)
無線デバイスwlan8 を省電力設定 このとき設定された項目が 表示されるのでメモする
その他コマンド • 全項目の省電力設定を有効にする % sudo powertop –auto-tune – 内容に不満がないならおすすめ.rc.local辺り に書いておいても良さそう
• powertop の結果をhtmlに % sudo powertop --html=powertop.html • powertop の結果をcsvに % sudo powertop --csv=powertop.csv
注意 • 省電力にするといいことばかりではない • 動作が遅くなったり,diskへの書き込みが遅 延して思わぬデータ消失が生じるなどの可能 性もある
None
ネットワークの設定が引き継がれなくて困っ たので調べた話(nm-applet)
PCの本体を交換 • ストレージを引き継ぐ • ネットワークデバイスのMACアドレスが変わ り,デバイス名(wlan0->wlan1,2,3...)が変更 になる • これまで設定した接続情報が使えなくなる…
回避策 • その1 – デバイス名を合わせて設定を引き継ぐ(前のマシ ンに戻すと再度デバイス名の変更が必要) • その2 – デバイスごとに設定し直す.面倒だが,前のマ
シンに戻しても使える.
udevでデバイス名を合わせる方法 • /etc/udev/rules.d/70-persistent-net.rules を編集 – 旧マシン設定 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="60:67:20:dd:d9:f8",
ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0" – 新マシン設定 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:23:15:28:93:80", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan8" • MACアドレスやデバイス名を編集する(旧マシンの設定はコメントアウト) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:23:15:28:93:80", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
• 再起動で反映 • 旧マシンに戻す場合は再度編集が必要
デバイスごとに設定し直す方法 • Gnome NetworkManager の設定を確認 – GUI(nm-applet) ✘ – CLI(nmcli)
✘ – CLI(nmtui) ✔
nm-applet • Gnomeの場合「設定」->「ネットワーク」- >「履歴」で確認可能だが,接続されていな いデバイスで設定したものは確認できない – 旧マシンで設定したデバイスの設定は確認でき ない
nm-cli • 設定の一覧表示 % nmcli connection show % nmcli c
% nmcli connection show |head 名前 UUID タイプ デバイス 自動 Ideos c2bba3db-bd60-4e92-982d-419bea2ffb17 bluetooth -- 自動 Ideos 219f7cc1-9800-441a-8ba7-b94a4db8d8b3 bluetooth -- KU-SOFTPLAZA f0441dcc-0189-4f32-869a-197896610dfa 802-11-wireless -- 自動 010C61FF5CACC 8fb78aef-8d13-4b16-97dc-9c5707411c03 802-11-wireless -- π 1ac42d31-8a32-42b0-a094-9b4e34bf8d5b 802-11-wireless -- 自動 WARPSTAR-0F17A7-GW 2a34a574-20d2-4b01-813e-bbfe5890cc8f 802-11-wireless -- Nag-FreeSpot-WEP 640612cd-5e5d-4688-a0d6-fe7e8d9f8d8c 802-11-wireless -- FREESPOT 1 64703e39-7335-44e4-9dee-b2db03955ad3 802-11-wireless -- Wi2 c447c218-110f-44fe-bee5-7c1ae0bfc3df 802-11-wireless – :
nm-cli • 名前やUUID指定で詳細表示 % nmcli connection show 'KU-SOFTPLAZA' connection.id: KU-SOFTPLAZA
connection.uuid: f0441dcc-0189-4f32-869a-197896610dfa connection.interface-name: -- connection.type: 802-11-wireless connection.autoconnect: yes connection.timestamp: 1414157624 connection.read-only: no : • しかし,Passwordは表示され無い
nm-cli余録 • 接続 % nmcli connection up 接続名 • 切断
% nmcli connection down 接続名 • 接続状態表示 % nmcli device ※確認してないけど新規設定,設定変更など もok
nmtui • CLIだが対話形式 % nmtui
nmtui • Show password にチェックを入れることで確 認できた
パスワードはどこに保存されてい るのか? • 恐らくGnomeKeyring(Seahorse/パスワード と鍵)に保存されている? • 普通に起動して鍵束の中を見ても載ってい無 さそう • Keyringの中身を全部表示してみたが見当た
らない
Keyringのパスワードを表示する Script #!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk #
sets app name import gnomekeyring def hack(): for keyring in gnomekeyring.list_keyring_names_sync(): for id in gnomekeyring.list_item_ids_sync(keyring): item = gnomekeyring.item_get_info_sync(keyring, id) print '[%s] %s = %s' % ( keyring, item.get_display_name(), item.get_secret()) else: if len(gnomekeyring.list_item_ids_sync(keyring)) == 0: print '[%s] --empty--' % keyring if __name__ == '__main__': hack()
• keyringをunlockした状態で実行
力技で探してみる… % sudo sh -c 'find /etc -type f -print0
| \ xargs -0 grep KU-SOFTPLAZA' • /etc/NetworkManager/system-connections 以下に設定を発見! – 1接続1ファイルでファイル中に平文でパスワー ドが書かれている – UUID/MACを書き換えると一括で処理できそう?要 確認 • uuid=795e6e6c-0f34-4367-91b9-59f750968033 • mac-address=00:23:15:28:93:80
% sudo cat KU-SOFTPLAZA [connection] id=KU-SOFTPLAZA uuid=f0441dcc-0189-4f32-869a-197896610dfa type=wifi [wifi] ssid=KU-SOFTPLAZA
mode=infrastructure mac-address=00:23:15:28:93:80 [wifi-security] key-mgmt=wpa-psk auth-alg=open psk=XXXXXXXXXXXX [ipv4] method=auto [ipv6] method=auto