6

最近、BLE モジュールを備えたマイクロコントローラ ベースのデバイスの開発を学び始めました。このデバイスは、センサーから取得したアナログ読み取り値を、これから開発する Android アプリケーションに送信することになっています。
GATTの仕組みについて私が研究したことは次のとおりです。

  1. マイクロコントローラーベースのデバイスは GATT サーバーになります。
  2. Android アプリケーションは GATT クライアントになります。
  3. 通信の観点から見ると、microntroller ベースのデバイスはスレーブであり、Android アプリケーションはマスターです。

質問:

  1. GATT クライアントからコマンドを受信し、応答 (float 値になる) を送信するために定義する必要がある属性の数を決定するにはどうすればよいですか? Android がコマンドを送信するための属性と、microncontroller ベースのデバイスが Android にデータを送信するための属性の 2 つの異なる属性が必要ですか? または、単一の属性を使用できますか?
  2. GATT はイベント ドリブン システムのようです。
    2.1: Android がマイクロコントローラ ベースのデバイス (クライアントからサーバー) にコマンドを送信すると、どのようなイベントが生成されますか?
    2.2: Android アプリケーション (サーバーからクライアント) によって読み取られる属性にデータが書き込まれると、イベントが生成されますか?
  3. Android アプリケーション (GATT クライアント) は、読み取り/書き込みコマンドを使用して、microncontroller ベースのデバイス (GATT サーバー) と通信する必要があります。また、GATT サーバーは Notify/Indicate を使用してデータを GATT クライアントに渡す必要があります。私の理解は正しいですか?

この BlueGiga BLE112 Moduleを開発に使用しています。

これまでに作成した gatt.xml ファイルは次のとおりです。

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<!-- 1800: org.bluetooth.service.generic_access -->
<service uuid="1800" id="generic_access">
  <description>Generic Access</description>
  <!-- 2A00: org.bluetooth.characteristic.gap.device_name -->
    <characteristic uuid="2A00" id="c_device_name">
      <description>Device Name</description>
      <properties read="true" const="true" />
      <value>MyBLEDev</value>
    </characteristic>
  <!-- 2A01: org.bluetooth.characteristic.gap.appearance -->
    <characteristic uuid="2A01" id="c_appearance">
      <description>Appearance</description>
      <properties read="true" const="true" />
      <value type="hex">0300</value>
    </characteristic>
  </service>

  <!-- custom service -->
  <service uuid="624e957f-cb42-4cd6-bacc-84aeb898f69b" advertise="true">
    <description>Custom Device Service</description>

    <!-- custom write-only characteristic for Client to send commands to fetch reading -->
    <characteristic uuid="a57892fe-4f58-97d4-a5245-78a4125d3e6" id="c_cmd_TxReading">
      <description>Request for Reading</description>
      <properties write="true" />
      <value length="4" />
    </characteristic>

    <characteristic uuid="8fde302a-56ac-b289-65ed-a577ed66b89c" id="c_reading">
      <description>Measurement</description>
      <properties read="true" write="true" />
      <value length="4" type="float32" />
    </characteristic>
</service>

4

1 に答える 1