ATOM Lite をスマートキーとつなげた話

The story of connecting ATOM Lite with a smart key

Tam

Tam

概要(Abstract)

ネットワーク経由でスマートキーの暗証番号を変更するのに ATOM Lite を使ってみた。

I tried using ATOM Lite to change the password of the smart key via the network.

Tam

注意(Note)

スマートキーの製造会社との秘密保持契約のため、いろんなところを曖昧なままで表現してます。

Due to the non-disclosure agreement with the smart key manufacturer, various parts are expressed in vague terms.

Tam

実態(Reality)

BLE と WiFi が載ったデバイスということで、 ESP32 で開発を進めていた。

Since it is a device with BLE and WiFi, I was developing it with ESP32.

ESP32 に 3D プリンターでケースを用意するのが面倒になり、調べていたところ、 ATOM Lite が ESP32-PICO-D4 チップを載せている、かつケース付きコンパクトということで、後付けで ATOM Lite を使用することにした。

It became troublesome to prepare a case for ESP32 with a 3D printer, and when I was investigating, I decided to use ATOM Lite as an aftermarket because ATOM Lite has an ESP32-PICO-D4 chip and is compact with a case.

Tam

ATOM Lite を選んだ理由(Reasons for choosing ATOM Lite)

  • 開発した ESP32 用のプログラムがそのまま流用できる。
  • Programs developed for ESP32 can be used as they are.
  • ケース付きでコンパクト。今回の用途に不要なデバイスが少ない。
  • Compact with a case. Few devices are unnecessary for this application.
  • microB ではなく、 Type-C が採用されている。(重要)
  • Type-C is adopted instead of microB. (important)
Tam

構成(composition)

SmartKey <- BLE -> ATOM Lite <- WiFi -> Server

  • BLE で暗証番号が変更できる SmartKey を利用。
  • Use SmartKey that can change PIN with BLE.
  • 暗証番号は、オンラインでサーバーに問い合わせる。
  • Ask the server for the PIN online.
  • ATOM Lite がサーバーからの指令を受けて、 BLE でスマートキーの暗証番号を変更する。
  • ATOM Lite receives a command from the server and changes the PIN of the smart key with BLE.
Tam

問題その1(Problem 1)

BLE と WiFi の両方のライブラリを含めようとすると、プログラムが巨大になりすぎて、 4M のサイズに収まらなくなってしまった。

Attempting to include both the BLE and WiFi libraries made the program too large to fit in the 4M size.

Tam

解決法(Solution)

  • WiFi を諦めて、有線LAN の ESP32 を使う。
  • Give up WiFi and use wired LAN ESP32.
  • 8M の ESP32 を使う。
  • Using an 8M ESP32.
  • NimBLE ライブラリを使う。(採用)
  • Use the NimBLE library. (adoption)
Tam

問題その2(Problem 2)

SmartKey の BLE protocol スペックが、たまにバージョンアップする。

SmartKey's BLE protocol specs are occasionally upgraded.

解決法(Solution)

ATOM Lite 側では最低限の BLE のやり取りしか行わず、 BLE のプロトコルの組み立てはサーバーで行うようにした。

On the ATOM Lite side, only the minimum BLE communication is performed, and the BLE protocol is assembled on the server.

Tam

問題その3(Problem 3)

ペアリング情報を ATOM Lite 側に書き込みたくなく、そのために複数の SmartKey がある環境で、別の SmartKey と繋がってしまうことが発生。

I don't want to write the pairing information on the ATOM Lite side, so in an environment with multiple SmartKeys, it may be connected to another SmartKey.

Tam

解決法(Solution)

SmartKey の BLE address を鍵としてサーバーと Digest 認証に成功したときのみ、接続を成功させるようにした。

Only when Digest authentication with the server succeeds using SmartKey's BLE address as a key, the connection is allowed to succeed.

  • MD5 はオープンソースのライブラリを利用して、 Digest認証は自前で実装した。
  • MD5 uses an open source library and implements Digest authentication by myself.
Tam

まとめ(summary)

  • 今回の ATOM Lite 側のプログラムは必要最低限に絞っているが、 4M のサイズだとぎりぎり収まるくらい。
  • The program on the ATOM Lite side this time is narrowed down to the bare minimum, but if it's 4M size, it just fits.
  • OTA はまだ実験中だが、なんとかサイズに収まりそう。
  • OTA is still being experimented with, but it looks like it will fit the size.
  • Watch Dog とかは稼働させているものの、今のところ失敗やハングアップはまったくなし。
  • Although Watch Dog is running, there are no failures or hangs at all so far.
Tam

$theme: gaia template: invert