‘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_ */
相关推荐
龙大大L7 天前
5.4 ESP32物联网开发实战教学:三大项目详解
嵌入式硬件·物联网·esp32
信奥洪老师7 天前
2025-03 机器人等级考试三级理论真题 3级
算法·青少年编程·机器人·arduino
lishaoan778 天前
快速安装Arduino IED的STM32 MCU开发包
stm32·单片机·嵌入式硬件·arduino·arduino ide·stm32 arduino
奔跑吧 android8 天前
【android bluetooth 协议分析 06】【l2cap详解 11】【l2cap连接超时处理逻辑介绍】
android·bluetooth·l2cap·gd·aosp13
龙大大L11 天前
第五章:5.3 ESP32物联网应用:阿里云IoT平台与腾讯云IoT平台的数据上传与远程控制
java·物联网·struts·esp32
Dm_dotnet11 天前
ESP32教程:通过WIFI控制LED灯的开关
arduino
PassLink_13 天前
[ESP-IDF]:esp32-camera 使用指南 ESP32S3-OV2640 用例测试
esp32·c·esp-idf·ov2640·esp32-camera·esp32s3-cam
奔跑吧 android16 天前
【android bluetooth 框架分析 02】【Module详解 4】【Btaa 模块介绍】
android·bluetooth·bt·aosp13·btaa
优信电子17 天前
ESP8266_ESP32 Smartconfig一键配网功能
esp32·esp8266·smartconfig·无线配网
奔跑吧 android17 天前
【android bluetooth 框架分析 02】【Module详解 12】【 BidiQueue、BidiQueueEnd、Queue介绍】
android·queue·bluetooth·bt·aosp13·bidiqueue·bidiqueueend