Back to tech

Blenano2をBLE通信のCentralとして扱う自己的サンプルプログラム

2 min read
Table of Contents

以前にBLEnanoをPeripheralとして扱うサンプルプログラムを公開しました

Peripheralの他にもCentralとして役割ができるらしいので色々と調べていました

RedBearからもCentralのサンプルがあるのですが、見づらいため自分がわかりやすいように色々と書き換えました

なんとなーくわかったのでGithubにあげておいたので公開しておきます

はじめに作ったのがCentralとしてPeripheralの通知のみを受け取るプログラムです

プログラム

動作例

Scan CallBack
PerrAddress: 62 EA C5 7F 1F E4
The Rssi : -64
The adv_data : � MyBlePeripheral
#1
Device name is : MyBlePeripheral ⸮\
find device

The conn handle : 0
  The peerAddr : 62 EA C5 7F 1F E4
----startDiscovery

----Characteristic Discovered
Chars UUID             : 1E 94 8D F1 48 31 94 BA 75 4C 3E 50 1 0 3D 71

----discoveryTermination

----discovered descriptor
Desriptor UUID         : 2902

----discovery descriptor Termination
Open notify
GattClient notify call back
33333
GattClient notify call back
44444
GattClient notify call back
55555
GattClient notify call back
66666
GattClient notify call back
77777

以下のプログラムをダウンロードして違うBlenanoに書き込むとBlenano間で通信をすることができます

GitHub - Momijinn/mySimplePeriferalBlenano: Blenano2をble通信のPeripheralとして使うサンプルプログラム
github.com
image