3
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?

Nordic UART 通信する Andorid BLE アプリをつくる (blecommunicator編)

3
Last updated at Posted at 2019-05-10

以下のシリーズの収録記事です

「Android アプリを作ってみよう 記事 index」
https://qiita.com/nanbuwks/items/9455e3354a86ad50723e

BLEアプリ(1)

hiramine.com の素晴らしい step-to-step 解説ページ 「BLE通信ソフトを作る ( Android Studio 2.3.3 + RN4020 )」があります。
https://www.hiramine.com/programming/blecommunicator/index.html
こちらで作成されたプログラム「blecommunicator」を基にして、Nordic UART通信に対応させます。

アプリのソースは
https://github.com/nobukihiramine/BLECommunicator
で公開されています。
ライセンスは Apache License 2.0 なので、これを書き換えて自分のアプリを作ることが可能です。

改造

オリジナルのプログラムはマイクロチップ社のRN4020と接続しますが、Nordic UART 対応にするにはソース中のUUIDを書き換えます。

app/src/main/java/com/hiramine/blecommunicator/MainActivity.java
から、以下の箇所を変更します。


< 	private static final UUID UUID_SERVICE_PRIVATE         = UUID.fromString( "FF6B1160-8FE6-11E7-ABC4-CEC278B6B50A" );
< 	private static final UUID UUID_CHARACTERISTIC_PRIVATE1 = UUID.fromString( "FF6B1426-8FE6-11E7-ABC4-CEC278B6B50A" );
< 	private static final UUID UUID_CHARACTERISTIC_PRIVATE2 = UUID.fromString( "FF6B1548-8FE6-11E7-ABC4-CEC278B6B50A" );
---
> 	private static final UUID UUID_SERVICE_PRIVATE         = UUID.fromString( "6e400001-b5a3-f393-e0a9-e50e24dcca9e" );
> 	private static final UUID UUID_CHARACTERISTIC_PRIVATE1 = UUID.fromString( "6e400003-b5a3-f393-e0a9-e50e24dcca9e" ); // CHARACTERISTIC_TX_UUID for Read
> 	private static final UUID UUID_CHARACTERISTIC_PRIVATE2 = UUID.fromString( "6e400002-b5a3-f393-e0a9-e50e24dcca9e" ); // CHARACTERISTIC_RX_UUID for Write
3
2
0

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
3
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?