« ubuntuでFitbit_OS_Simulator(windows版)を動かす | トップページ | fitbitアプリのアイコンの作成とインストール方法 »

2018年12月16日 (日)

Fitbit OS コマンドラインツールを使う

Fitbit OS コマンドラインツールを使う

0.概要
Fitbit Versaは、Javacriptなどのプログラムが組み込める機能があり、 Fitbit_Studioというweb上での開発ツールがあるが、ローカルでプログラムが組めるコマンドラインツールも用意されている。
本メモは、それについて記する。参照URLで説明されているものを日本語で簡単に説明したものになる。

1.インストールと新規アプリ作成
# エディターとして、Microsoft VSCodeを使うのであれば
以下のURLから必要なバイナリー(ubuntuなら.deb)をダウンロードして
インストールする。コマンド名としては、codeになる。

# Node.js 8.xi以上が必要となるので以下のようにnodeのバージョンを確認する。
node -v
v10.11.0

# 作業用のディレクトリを作る
mkdir FitbitWS
cd FitbitWS/

#以下のコマンドでアプリのテンプレート(my-app)を作成する:
npx create-fitbit-app my-app

以下のように色々な質問が来るので適切に応える:
? What type of application should be created? clockface
? What should the name of this application be? cli-cf01
? Should this application contain a companion component? Yes
? Should this application contain a settings component? Yes
? Which platforms should this application be built for? (Press to select

# ここで、実機(versa)と実機とペアリングしたスマフォ(iPhone)のBrigeを有効にするか
# Fitbit OS Simulatorを起動する。(Simulatorは同一PCでなくても良い)

npx bitbit
# ここで、fitbitのアカウントにログインすることになるので
# 聞かれたら、IDとパスワードを入力する

fitbit$ build

fitbit$ install
# ここで自動的にスマフォとversa(またはシミュレータ)に接続され
# ビルドしたプログラムがインストールされる。

# 実機にとシミュレータが同時に動作している場合、どちらにするか聞かれるので選択する。
# 以下のコマンドで、こちらから接続することもできる。
connect device
connect phone

# ここでは以下のコマンドが使用できる:
help [command...] Provides help for a given command.
exit Exits application.
build Build application
connect device Connect a device
connect phone Connect a phone
install [packagePath] Install an app package
screenshot [path] Capture a screenshot from the connected device
logout Log out of your Fitbit account

2.既存アプリのアップデート
(1)まずは、Fitbit Studioにあるアプリをエクスポート(ダウンロード)する。zip形式なので解凍(unzip)する。

(2)package.json修正
package.jsonの一部を以下のように修正する:

"devDependencies": {
"@fitbit/sdk": "~2.0.0",
"@fitbit/sdk-cli": "^1.0.0"
},

(3)以下を実行する:
npm install

(4)ここからは新規アプリの場合と同様に以下を実行する:
npx fitbit
build
connect device
connect phone
install


3.参照URL
https://dev.fitbit.com/blog/2018-08-23-cli-tools/#highway-to-shell
By Your Command! Meet the Command Line Interface

以上

|

« ubuntuでFitbit_OS_Simulator(windows版)を動かす | トップページ | fitbitアプリのアイコンの作成とインストール方法 »

脈拍計付き活動量計」カテゴリの記事

linux」カテゴリの記事

コメント

コメントを書く



(ウェブ上には掲載しません)




トラックバック


この記事へのトラックバック一覧です: Fitbit OS コマンドラインツールを使う:

« ubuntuでFitbit_OS_Simulator(windows版)を動かす | トップページ | fitbitアプリのアイコンの作成とインストール方法 »