‘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_ */
相关推荐
凌盛羽13 小时前
ESP32-S3定时器组Timer Group0/1的使用
stm32·单片机·嵌入式硬件·链表·esp32·定时器
欢乐熊嵌入式编程2 天前
用 ESP32 + WiFi 做远程控制插座(从原理到实战)
单片机·wifi·智能路由器·esp32·远程控制插座
π同学2 天前
ESP-IDF+vscode开发ESP32第四讲——I2C
vscode·esp32·i2c
凌盛羽2 天前
在MDK-ARM编译后用python解析map文件在编译窗口输出Flash和RAM使用及剩余情况
arm开发·python·stm32·单片机·mysql·链表·esp32
@haihi5 天前
ESP32 MQTT示例解析
开发语言·网络·mqtt·github·esp32
乐鑫科技 Espressif6 天前
乐鑫发布 ESP32-S31:高性能多协议双核 RISC-V,面向 AI 智能交互
人工智能·mcu·esp32·乐鑫科技
π同学6 天前
ESP-IDF+vscode开发ESP32第三讲——UART
vscode·esp32·uart·esp-idf
小贺儿开发7 天前
【Arduino与Unity交互探究】03 超声波测距模块
unity·arduino·串口通信·传感器·videoplayer·硬件交互
七夜zippoe9 天前
边缘计算:Python在IoT中的应用
python·物联网·esp32·边缘计算·iot
lingzhilab9 天前
零知IDE——基于ESP32的BLE Mesh蓝牙组网多灯智能控制系统
ide·单片机·esp32