9
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LTE-M Button管理にはQRコード

Last updated at Posted at 2018-12-05

はじめに

SORACOM LTE-M Button powered by AWS Advent Calendar 2018 - Qiita
の5日目です。

あのボタンとは

SORACOM LTE-M Button powered by AWS - SORACOM

さっき開けて電池をいれました。

オイコラ、( ゚Д゚)ドルァ!!

IMG_6953_2.png

登録から初期設定は

2018/12/02のアドカレを参考にしました。

SORACOM LTE-M Button powered by AWS 「ご購入、利用開始方法」のチュートリアル #SORACOM – サーバーワークスエンジニアブログ

ボタンで何をするか?

そもそも何ができるの?

AWS IoT エンタープライズボタン ユーザーガイド - AWS IoT 1-Click

  • シングルクリック
  • ダブルクリック
  • 長押し

の3種類のみです。

3種類でどうするか?
長押しをキャンセルとすると2つしかありません。
ここは悩みどころですね。

さて今回何をやるのか

国内初!セルラー通信内蔵「AWS IoT 1-Click」対応ボタン「SORACOM LTE-M Button powered by AWS」1年間1,500回分の通信込みで3,980円、10月17日より発売開始
こちらに、

例:オフィスビル内数箇所に設置されたゴミ箱の回収時期を発見者がボタンを1回押すことで通知、作業員の到着を作業者が2回押すことで通知というシステム

とありますので、必要なものは

どのボタンが
どう押されたか

です。シンプルですが、難しいところでもあります。

scVkCarO1Nm4NmJrMnkjfQw.png

JAWS FESTA 2018 OSAKA | 世界一早い(?)「SORACOM LTE-M Button powered by AWS」…

であったように、カオスになります。
そこで今回は、デバイスごとにQRを生成したいと思います。

準備

QRを生成する環境は、Macでやります。

[f_prg@Documents] $ brew install qrencode

デバイス情報を取得する

AWS CLIで取得します。

[f_prg@Documents] $ aws --region=us-east-1 iot1click-devices list-devices

Could not connect to the endpoint URL: "https://devices.iot1click.us-east-1.amazonaws.com/devices"

ほうほう。。。

AWS のリージョンとエンドポイント - アマゾン ウェブ サービス

リージョン名 リージョン エンドポイント プロトコル
米国西部 (オレゴン) us-west-2 devices.iot1click.us-west-2.amazonaws.com HTTPS
[f_prg@Documents] $ aws --region=us-west-2 iot1click-devices list-devices
{
    "Devices": [
        {
            "Attributes": {
                "projectName": "anodebug",
                "projectRegion": "us-east-1",
                "placementName": "anodebug",
                "deviceTemplateName": "anobutton"
            },
            "Type": "button",
            "Enabled": true,
            "DeviceId": "SSSSSSSSSSSSS",
            "RemainingLife": 98.5
        },
        {
            "Attributes": {
                "projectName": "soracom-lte-m-button",
                "projectRegion": "us-east-1",
                "placementName": "soracom-lte-m-button",
                "deviceTemplateName": "soracom-lte-m-button"
            },
            "Type": "button",
            "Enabled": true,
            "DeviceId": "QRDEVICEID",
            "RemainingLife": 99.86666666666667
        }
    ]
}
[f_prg@Documents] $ aws --region=us-west-2 iot1click-devices describe-device --device-id QRDEVICEID
{
    "DeviceDescription": {
        "Attributes": {
            "projectName": "soracom-lte-m-button",
            "projectRegion": "us-east-1",
            "placementName": "soracom-lte-m-button",
            "deviceTemplateName": "soracom-lte-m-button"
        },
        "Type": "button",
        "Enabled": true,
        "DeviceId": "QRDEVICEID",
        "RemainingLife": 99.86666666666667
    }
}

AWS CLIでフィルタできないので、jqで絞り込びます。

上記で例に挙げた
オフィスビル内数箇所に設置されたゴミ箱の回収時期 に対して
デバイスのプロジェクト名soracom-lte-m-button
ボタンで何をするのか という想定です。

[f_prg@Documents] $ aws --region=us-west-2 iot1click-devices describe-device --device-id QRDEVICEID |jq -r '.|if .DeviceDescription.Attributes.projectName == "soracom-lte-m-button" then .DeviceDescription.DeviceId else empty end'
"QRDEVICEID"

デバイスIDから、QRを生成します。(管理上、デバイスIDのままでいいかどうかは割愛します。)

qrencode -o QRDEVICEID.png -t PNG QRDEVICEID

QRDEVICEID.png

となります。

最後に

今回はデバイスを管理する際に、必要そうなことを書いてみました。
QRと文字を一緒にしたり、
テプラとか連結してみたいけど、どっかに方法はあるはずかと。

ではでは。

9
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?