‘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_ */
相关推荐
你怎么知道我是队长3 天前
经典蓝牙(Classic Bluetooth / BR/EDR)--- 核心协议层1 --- 经典蓝牙(BR/EDR)物理层核心机制详解
bluetooth
sanzk4 天前
arduino+esp32
esp32
jianqiang.xue4 天前
系统服务层设计:沉淀通用能力,让业务层只专注业务
stm32·单片机·嵌入式硬件·mcu·物联网·esp32
零涂毕业设计12 天前
毕业设计模块开发-OLED显示屏(IIC协议0.96寸)STM32 ESP32 FPGA Linux驱动免费分享
linux·stm32·单片机·嵌入式·esp32·fpga·oled
乐鑫科技 Espressif16 天前
用 AI 开发 Zephyr-IoT 应用
人工智能·物联网·esp32·乐鑫科技·zephyr
nLif18 天前
Anemoia-ESP32 串口手柄代码
esp32
乐鑫科技 Espressif20 天前
ESP-Claw 全面升级,打造可共享、可复用的设备端 AI Skills 生态
人工智能·esp32·乐鑫科技
奔跑吧 android24 天前
【Bluetooth-SIG】【CoreV6.2】【Vol3 Part G】【GATT】【零】【GATT 逐句逐段学习计划 2】
ble·bluetooth·att·gatt·core_v6.2·sig
Starry-sky(jing)1 个月前
Win11 装 ESP32 Arduino 库卡 3 小时?我把官方 3.3.10 全平台 522MB 搬到了蓝奏云,解压即用
运维·windows·esp32·arduino·离线安装
奔跑吧 android1 个月前
【Bluetooth-SIG】【CoreV6.2】【Vol3 Part F】【十三】【Error Handling——ATT_ERROR_RSP】
ble·bluetooth·att·gatt·蓝牙协议·bt·core_v6.2