‘BLEUUID‘ does not name a type错误怎么解决?

摘要:arduino环境下对esp32蓝牙编程时会遇到'BLEUUID' does not name a type错误,本文介绍解决方法。

硬件设备是安信可ESP32-S模组。

错误发生在代码最开始的地方,include了一个蓝牙设备头文件,然后定义了UUID,注意看,这个UUID的数据类型是BLEUUID,并不是数组、字符串、整数、浮点数等。看来BLUEUUID是专门定义的一个类型。那么为什么编译还会出错呢?

cpp 复制代码
#include "BLEDevice.h"


// The remote service we wish to connect to.
static BLEUUID serviceUUID("0000ffe0-0000-1000-8000-00805f9b34fb");
// The characteristic of the remote service we are interested in.
static BLEUUID    charUUID("0000ffe1-0000-1000-8000-00805f9b34fb");

解决方法是设置一下开发板的型号,之前设置的型号是ESP32S2 Dev Module,将开发板型号修改成为ESP32 Dev Module即可。

原因分析:有可能是ESP32 Dev Module开发板对应的支持库中,有对BLEUUID数据类型的定义。

找到了一个ESP32_BLE_Arduino-1.0.1安装包。从这个安装包的src目录下找到了BLEUUID.h头文件,这个头文件的定义不一定是解决前面所提到问题的定义,但是应该差不多。作为参考使用,如果有需要更深入研究的同学,可以在本文基础上进一步分析。

cpp 复制代码
/*
 * BLEUUID.h
 *
 *  Created on: Jun 21, 2017
 *      Author: kolban
 */

#ifndef COMPONENTS_CPP_UTILS_BLEUUID_H_
#define COMPONENTS_CPP_UTILS_BLEUUID_H_
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#include <esp_gatt_defs.h>
#include <string>

/**
 * @brief A model of a %BLE UUID.
 */
class BLEUUID {
public:
	BLEUUID(std::string uuid);
	BLEUUID(uint16_t uuid);
	BLEUUID(uint32_t uuid);
	BLEUUID(esp_bt_uuid_t uuid);
	BLEUUID(uint8_t* pData, size_t size, bool msbFirst);
	BLEUUID(esp_gatt_id_t gattId);
	BLEUUID();
	uint8_t        bitSize();   // Get the number of bits in this uuid.
	bool           equals(BLEUUID uuid);
	esp_bt_uuid_t* getNative();
	BLEUUID        to128();
	std::string    toString();
	static BLEUUID fromString(std::string uuid);  // Create a BLEUUID from a string

private:
	esp_bt_uuid_t m_uuid;       		// The underlying UUID structure that this class wraps.
	bool          m_valueSet = false;   // Is there a value set for this instance.
}; // BLEUUID
#endif /* CONFIG_BT_ENABLED */
#endif /* COMPONENTS_CPP_UTILS_BLEUUID_H_ */
相关推荐
sz4972385996 小时前
vscode多种编译环境共存的方法
ide·vscode·stm32·编辑器·esp32
飞睿科技13 小时前
乐鑫信息推出ESP-Claw AI智能体框架,物联网进入“聊天造物”时代
人工智能·物联网·esp32·乐鑫科技·ai智能体
阿昊真人4 天前
esp12F 无法进入运行模式 (按复位后闪烁一次无响应)
esp32
weixin_459548905 天前
立创实战派S3-文件管理器
esp32
π同学6 天前
ESP-IDF+vscode开发ESP32第六讲——SPI
vscode·esp32·spi
sz4972385998 天前
WSL2+VSCode搭建ESP-IDF 开发环境
ide·vscode·编辑器·esp32·wsl
奔跑吧 android10 天前
【BT-SIG】【Core_v6.2】【Vol 3 Host】【Part G: GATT】【3.1 Service definition】
ble·bluetooth·gatt·蓝牙协议·bt·core_v6.2·bt-sig
奔跑吧 android10 天前
【BT-SIG】【Core_v6.2】【Vol 3 Host】【Part G: GATT】【2.Profile overview】
ble·bluetooth·协议解析·gatt·bt-sig解析·core_v6.2
deepwater_zone12 天前
ESP32芯片对比
esp32
乐鑫科技 Espressif15 天前
使用 MCP 服务器,把乐鑫文档接入 AI 工作流
人工智能·ai·esp32·乐鑫科技