0

BLE113 モジュールにデータを送信する Android アプリがあります。タイプが「ユーザー」の GATT 特性を介してデータを受信します。データを文字列として取得できます。24 などの整数を送信すると、文字列 '24' として受信されます。この文字列番号を整数型に変換できる方法はありますか?

これは gatt.xml からのものです。

<characteristic uuid="xxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxx" id="configuration">
    <description>Config Register</description>
    <properties read="true" write="true"/>
    <value type="user" />
</characteristic>

これは、整数値「1」を書き込む Android 側のスニペットです。

String str = "1";
    try {
      byte[] value = str.getBytes("UTF-8");
      chara.setValue(value);
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
.
.
.
boolean status = mBluetoothGatt.writeCharacteristic(chara);

BGScript側でデータを整数'1'そのものとして受け取りたい。変換に何か問題がありますか? 整数を送るのを手伝ってください。

GATT特性の「USER」タイプと何か関係あるの?「hex」または「utf-8」に変更すると、問題は解決しますか?

4

1 に答える 1