在Zephyr ESP32 藍牙驅(qū)動簡析一文中簡要分析了esp32 藍牙如何集成進Zephyr,本文接著說明如果在Zephyr內(nèi)使用ESP32藍牙。
在Zepher中使用ESP32藍牙比WIFI還要簡單只要基于esp32 board編譯的APP配置了CONFIG_BT=y就會默認打開ESP32藍牙的配置CONFIG_BT_ESP32,詳細可見boardsxtensaesp32Kconfig.defconfig.
之后就直接使用zephyr提供的藍牙API進行應(yīng)用編程即可。
本文不說明如何進行藍牙編程,試跑一個Zephyr的藍牙例程eddystone,這是Google BLE Beacon,用于藍牙定位。
例程的配置文件如下
1
2
3
4
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME=“Zephyr Eddystone”
應(yīng)用主程序如下, 實際的各種流程都在bt_ready中展開
void main(void)
{
int err;
bt_conn_cb_register(&conn_callbacks);
k_work_init_delayable(&idle_work, idle_timeout);
/* Initialize the Bluetooth Subsystem */
err = bt_enable(bt_ready);
if (err) {
printk(“Bluetooth init failed (err %d)
”, err);
}
}
編譯并下載
1
2
west build -p -b esp32 zephyrproject/zephyr/samples/bluetooth/eddystone
west flash --esp-device /dev/ttyS11
運行l(wèi)og如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
??*** Booting Zephyr OS build v2.6.0-rc1-300-g6ce0f2ee6606 ***
phy_version: 4500, 0cd6843, Sep 17 2020, 1507, 0, 2
Coex register schm btdm cb faild
Bluetooth initialized
Initial advertising as C457F8:DE (public)
Configuration mode: waiting connections.。。
[0000.911,000] 《dbg》 bt_hci_driver_esp32.hci_esp_host_rcv_pkt: Calling bt_recv(0x3fff4c28)
--- 98 messages dropped ---
[0000.911,000] 《inf》 bt_hci_core: Identity: C457F8:DE (public)
[0000.911,000] 《inf》 bt_hci_core: HCI: version 4.2 (0x08) revision 0x030e, manufacturer 0x0060
[0000.911,000] 《inf》 bt_hci_core: LMP: version 4.2 (0x08) subver 0x030e
[0000.911,000] 《dbg》 bt_hci_driver_esp32.bt_esp32_send: buf 0x3fff4c28 type 0 len 18
[0000.911,000] 《dbg》 bt_hci_driver_esp32: Final HCI buffer:
01 06 20 0f a0 00 f0 00 00 00 00 00 00 00 00 00 |。。 。。.。。 。。.。。.。。
00 07 00 |。。.
在手機上通過nrf connect可以看到”Zephyr Eddystone”
從上面可以看到zephyr上面使用ESP32藍牙完全可以不用關(guān)心驅(qū)動,是單純應(yīng)用層的編程。
編輯:jq
-
藍牙
+關(guān)注
關(guān)注
116文章
6037瀏覽量
173232 -
API
+關(guān)注
關(guān)注
2文章
1563瀏覽量
63559 -
編程
+關(guān)注
關(guān)注
88文章
3683瀏覽量
94885 -
Zephyr
+關(guān)注
關(guān)注
0文章
35瀏覽量
6236
原文標(biāo)題:Zephyr ESP32 藍牙試用
文章出處:【微信號:ZephyrProject,微信公眾號:ZephyrProject】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
【AI技術(shù)支持】ESP32-S3模組EspBleOTA搜索不到ble_ota例程的藍牙問題處理

esp32和esp8266代碼共用嗎
esp8266和esp32區(qū)別是什么
esp32用什么軟件編程
ESP32-WROOM-32E、ESP32-WROOM-32D、ESP32-WROOM-32U 有什么區(qū)別?ESP32-WROOM-32 后綴字母代表的意思是?

ESP32能取代STM32嗎?哪個更好?

請問ESP32-S3藍牙是否支持SPP?
請問ESP32藍牙連接數(shù)如何設(shè)置?
ESP32-AT開啟經(jīng)典藍牙作為藍牙模塊,和MCU連接發(fā)送AT之后,返回值沒有OK是怎么回事?
請問ESP32如何讀取周圍藍牙廣播的數(shù)據(jù)?
樂鑫esp32系列在睡眠模式下保持藍牙連接的功耗測試

評論