Google OS実験室 ~Moonlight 明日香~

GoogleのAndroidで遊び始めて, すでに6年以上が経った. Androidは思った以上の発展を遂げている. この技術を使って, 新しいことにチャレンジだ!!

Android Things

Android Things 1.0のSetup UtilityはステルスSSID未対応!?

先日(2018/5/8-10)開催されたGoogleの開発者向けイベント「Google I/O 2018」でAndroid Things 1.0が発表された.
先週さっそく試そうと, Android Things Setup Utility v1.0.20を使ってセットアップを試みたが, すんなり動いてくれなかったので, 少し状況をまとめておく.

1. Android Thingsのインストール[1]
今回の開発環境は以下の通り.
- Host PC : Windows 10 Pro
- Hardware : Raspberry Pi 3
- WiFi AP : Buffalo WZR-300HP

Android Thingsのインストールは, ここからSetup Utilityをダウンロードし, 実行することで簡単に行える.

[実行ログ]
 Android Things Setup Utility (version 1.0.20)
 ============================
 This tool will help you install Android Things on your board and set up Wi-Fi.

 What do you want to do?
 1 - Install Android Things and optionally set up Wi-Fi
 2 - Set up Wi-Fi on an existing Android Things device
 1
 What hardware are you using?
 1 - Raspberry Pi 3
 2 - NXP Pico i.MX7D
 1
 You chose Raspberry Pi 3.

 Setting up required tools...
 Fetching additional configuration...
 Downloading platform tools...
 4.74 MB/4.74 MB
 Unzipping platform tools...
 Finished setting up required tools.

 Raspberry Pi 3
 Do you want to use the default image or a custom image?
 1 - Default image: Used for development purposes. No access to the Android
 Things Console features such as metrics, crash reports, and OTA updates.
 2 - Custom image: Upload your custom image for full device development and
 management with all Android Things Console features.
 1
 Downloading Android Things image...
 331 MB/331 MB
 Unzipping image...

 Downloading Etcher-cli, a tool to flash your SD card...
 19.8 MB/19.8 MB
 Unzipping Etcher-cli...

 Plug the SD card into your computer. Press [Enter] when ready

 Running Etcher-cli...
 ? Select drive \\.\PHYSICALDRIVE2 (32.0 GB) - USB Mass  Storage Device USB Device
 ? This will erase the selected drive. Are you sure? Yes
 Flashing [========================] 100% eta 0s
 Validating [========================] 100% eta 0s
 iot_rpi3.img was successfully written to USB Mass  Storage Device USB Device (H:)
 Checksum: e41d659a

 If you have successfully installed Android Things on your SD card, you can now
 put the SD card into the Raspberry Pi and power it up. Otherwise you can abort
 and run the tool again.

 Would you like to set up Wi-Fi on this device? (y/n)

インストールは特に問題なし.

2. Wifiの設定[2]
次に, WiFiの設定を行う.

[実行ログ]
 Would you like to set up Wi-Fi on this device? (y/n) y
 Please plug your Raspberry Pi to your router with an Ethernet cable, then press [Enter].

  Attempting to connect to your Raspberry Pi at Android.local...
 Connected to device through Ethernet.
 Enter the Wi-Fi network name: XXXXXX
 Enter the Wi-Fi network password (leave empty if no password):
 Connecting to Wi-Fi network XXXXXX...
 Looking for device... This can take up to 3 minutes.
 Error: unable to connect to Wifi: device not found: timed out
 Stopping adb server...
 Stopped adb server...

 If you are having trouble using the Setup Utility, please file a ticket at
 https://issuetracker.google.com/issues/new?component=1xxxxx.

 Press [Enter] to quit.

と, デバイス(ここではAPかな?)が見つけられず, WiFi接続に失敗した.

things01

Logcatのログなども少し確認したが原因がよくわからない.
Google Issue Trackerに報告しろとのことなので, とりあえずバグ登録した.

今日少し時間があったので再度トライ.
いろいろと試している中で, WiFi APのSSIDをステルス設定していることを思い出した.
そこで, ステルス設定を解除し試すと, いとも簡単にWiFi接続できてしまった.
WiFi接続できない直接の原因は, Setup UtilityがステルスSSIDに未対応だったことのようだ...

では, ステルスSSIDのWiFi APに接続するにはどうすればよいのか?
答えは, ここを参考に, 以下のようなコマンドで接続できることを確認した.

 > adb connect Android.local
 connected to Android.local:5555
 > adb shell am startservice \
    -n com.google.wifisetup/.WifiSetupService \
    -a WifiSetupService.Connect \
    -e ssid <Network_SSID> \
    -e passphrase <Network_Passcode> \
    --ez hidden true

things02

Issue Trackerには, ステルスSSIDが原因でつながらなかったと, 追加メッセージを書き込んでおいた.
ただ, できればSetup UtilityでもステルスSSIDに対応してほしいものだ...

----
参照URL:
[1] Raspberry Pi 3 | Android Things | Android Developers
[2] Connecting to Wi-Fi with adb | Android Things | Android Developers

Android ThingsのDoorbellサンプルを試す

先週末に, Android Thingsを試してみようと, Raspberry Pi 3を購入してみた.

まずは, LチカやPeripheral I/Oの使い方など1週間試してみた.

led01

GPIO, I2C, PWM、UARTなどの基本的な使い方は, こちらの「Androidプログラマへの道[1]に少し記載しておいた.

今週末も, 台風で勉強会などが延期になったので, Android  Things Doorbell sample[2]でAndroid Things + クラウド連携の動きを試してみることにした.

このサンプルは, Android Thingsのカメラで撮影した画像を, Cloud Vision APIを使ってアノテーションし, Firebaseのデータベースへ画像を送る.
Androidスマフォからは, リアルタイムで撮影した画像を閲覧できるというもの.

[ハードウェア]

pi3button
これに, 昔使っていた初代Raspberry Piのカメラモジュールを接続した.

サンプルのビルドやクラウド側の設定は, GithubのSetup and Build[2]やQiitaの記事[3]などに記載の手順で, 特にハマるところもなく, 一応動いた.

bell02

Cloud Vision APIやFirebaseはあまり詳しくないので, 書かれているままに設定したのだが, "no annotations yet"となっている.
bell03
Cloud Vision APIの使い方間違ってるのかな~.

何はともあれ, 一応Android Things + クラウド連携で動いているので, これを参考に何か作ってみよう...

----
参照URL:
[1] Androidプログラマへの道 ~ Moonlight 明日香 ~
[2] androidthings/doorbell
[3] Android ThingsのサンプルDoorBellアプリを試してみた

プロフィール

明日香

アクセスカウンター
  • 今日:
  • 昨日:
  • 累計:

記事検索



  • ライブドアブログ