head

2017年4月20日木曜日

esp32+ BLE, Eddystone対応 (Beacon 編)



前回と同様、esp32 +BLE
Broadcast network のテストのついでに、
googleのEddystone試してみました。
*) BLE Beacon系で Appleの iBeaconの対抗馬らしいですね。

テストは、
スマホで、パケット受信して表示。
URLスキーマが使えて、リンクをタップすると対象ページが開いたり。
できました


# 参考のコード
https://github.com/pcbreflux/espressif/tree/master/esp32/app/ble_app_eddystone

Advertisingの配信に、処理は似てました



# アプリ起動画面



RAW DATA が見れたり、
[OPEN] おすと、ブラウザ起動で送信したページが開けます、



適当な、短縮URLを
GAP profileにセットして、配信してみました。

#
Eddystone  対応のスマホアプリや、デバイスで使えそうですね。
esp32 で配信装置は、安価で作れそうです。






esp32+ BLE, Advertising パケットを受信する。




前回と同様、esp32 +BLEで、デバイス間通信で
Broadcast Networkの、Advertising を使って通信のテストしてみました。
一方向の送信のみで、GAP Profileで、最大 31 byteらしいのですが、
GATT に比べて、connect不要でも通信できそうです。


# 参考のコード
adv(配信側 / Peripheral device):
examples/bluetooth/ble_adv
https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/ble_adv

client(Central device):
前回の Gatt Client実装 参考にしています。
http://knaka0209.blogspot.jp/2017/04/esp32-7-BLE.html

# 解説
Advertising(配信):
ble_adv/main/app_bt.c
 static void hci_cmd_send_ble_set_adv_data(void) で、
 配信データを作成部、デバイス名の後ろに、
送信データを追加しておきます。(センサ値/デバイス制御コード等 )

client(受信):
 esp_gap_cb()
  adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,
    ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
*) esp_ble_resolve_adv_dataの戻り値で、データ部(デバイス名 含む)が取得できましたので
 追加したデータ取得できました。

#Log ,client




# 参考のサイト
https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gap

https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/ble_adv

http://esp-idf.readthedocs.io/en/latest/api/bluetooth/esp_gap_ble.html




# 関連の esp32まとめ
http://kuc-arc-f.com/make/?p=1288




2017年4月18日火曜日

esp32+ BLE, デバイス間通信、 GattC to GattS



前回の続編で、esp32でBLE 関係となります。

2台の esp32を使用した、 デバイス間の通信を確認できました。
主要なデータは、Gatt Client ⇒ Gatt Serverの方向で送信



# 参考のページ、thanks
複数のデバイス間、通信を探し。このページを発見できました
https://www.esp32.com/viewtopic.php?f=18&t=1184&hilit=gatt

記載されている
[ Nicholas3388/LuaNode/tree/master/LuaNode_Esp32/LuaNode32/examples/esp32_nrf51822_ble_conn ]
あたりのコード参考にしましたが、Serverが nrf51x で手持ちの部品が無かったので、両方esp32の

https://github.com/Nicholas3388/LuaNode/tree/master/LuaNode_Esp32/LuaNode32/examples/ble_led_control
を検索できました。thanks!!

gatt Client から、esp_ble_gattc_write_char_descr()
で、送信できるようですので。

内容は、Gatt Client からLED制御データを送信、
 Gatt Server側で BLE受信しているようです。


# Server Log,


[0;32mI (1353179) GATTS_DEMO: GATT_WRITE_EVT, value len 2, value 00000001
> value=受信値、その後 LED制御 判定してるようですね。

*) Gatt Server側に、LED 結線しています。


# 参考のサイト
https://www.esp32.com/viewtopic.php?f=18&t=1184&hilit=gatt

https://github.com/Nicholas3388/LuaNode/tree/master/LuaNode_Esp32/LuaNode32/examples/esp32_nrf51822_ble_conn

https://github.com/Nicholas3388/LuaNode/tree/master/LuaNode_Esp32/LuaNode32/examples/ble_led_control

http://esp-idf.readthedocs.io/en/latest/api/bluetooth/esp_gattc.html




# 関連の esp32まとめ
http://kuc-arc-f.com/make/?p=1288



2017年4月16日日曜日

ESP32, Gatt Server (+BLE Gateway)




esp32で、BLE試してみました。
カンタンなBLE通信と、wifi-http転送機能も追加した仕組みも検証できました。
*) ESP-IDFで開発してます。

# 概要、2種類
[1] BLE通信
Gatt Server : esp32
Gatt Client : android(アプリ Nordic/nRF connect )

[2] BLE通信 +WIFIブリッジ的な BLE Gateway


[1] Gatt Server - Client(android)
ESP-IDFの、 examples/bluetooth/gatt_server 、参考してます。
https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/gatt_server

#Client (ホスト側) データ送信 /アプリの操作例 (TEXT 形式)
Gatt Serverを起動し ,
アプリ起動すると、server検証が実行され、一覧に追加されます。
NAME = ESP_GATTS_DEMO (* 修正しない場合。
データ送信する場合、接続先の [connect] おします。



タブが追加されて、下の Serviceを押します



[↑] みたいな送信押して、
送信画面が開きます。
種類= TEXT
値= 123 (Write value の下)
[SEND] 押すと、送信されます


# Log , Gatt Server


[0;32mI (52334) GATTS_DEMO: GATT_WRITE_EVT, value len 3, value 00333231
の行が、受信した行で。 value が値(16進)

# gatts_demo.c
gatts_profile_a_event_handler()
 case ESP_GATTS_WRITE_EVT
あたりが実行されているようです。




[2] BLE通信 +WIFIブリッジ的な BLE Gateway



1 の、Gatt serverが受信した、値をWIFI経由で
クラウド転送します。

追加した処理は、
http の別Taskを追加し、値を転送している程度です

# 送信した値。




# 参考
https://ja.wikipedia.org/wiki/Bluetooth_Low_Energy

https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt

https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gap

https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/



# まとめ
今回はClient(子機)は、アプリで手動送信でしたが、
次回は 自作デバイスで、自動実行 -送信とか検討したいと思います。


# 関連の esp32まとめ
http://kuc-arc-f.com/make/?p=1288




google colaboratory お試し編 、GPUも使える機械学習の環境構築

前回続き、機械学習の関連となります。 開発環境まわりの内容となり。先人様の情報を元に調査しました。 google colab(google colaboratory) を試してみました。機械学習系の いくつかのライブラリがインストール済みで、 クラウド上で、ある程度機械学...

AD-parts

Shop
Bluetooth搭載
ベース基板

Social