‘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_ */
相关推荐
mingupup1 小时前
ESP32+Arduino入门(三):连接WIFI获取当前时间
esp32·arduino
奔跑吧 android2 天前
【android bluetooth 框架分析 02】【Module详解 3】【HciHal 模块介绍】
android·bluetooth·bt·gd·aosp13·hcihal
奔跑吧 android3 天前
【android bluetooth 协议分析 01】【HCI 层介绍 1】【hci_packets.pdl 介绍】
android·bluetooth·bt·gabeldorsche·gd·aosp13·bluedroid
Dm_dotnet4 天前
ESP32+Arduino入门(四):OLED屏随机显示古诗
arduino
Dm_dotnet5 天前
ESP32+Arduino入门(三):连接WIFI获取当前时间
arduino
Dm_dotnet7 天前
ESP32+Arduino入门教程(二):连接OLED屏
arduino
~照猫画虎~7 天前
ESP32系列,IDF官方实例——外设:通用GPIO
esp32·esp idf
Dm_dotnet7 天前
ESP32+Arduino入门(一):开发环境搭建
arduino
余衫马17 天前
从零到一:ESP32与豆包大模型的RTC连续对话实现指南
esp32·实时音视频·智能对话·esp-adf·sparkbot
北京自在科技1 个月前
蓝牙技术联盟中国实体成立!华为、小米发声支持本土化战略
华为·蓝牙·小米·bluetooth