Arduino开发esp32使用蓝牙用到,英文粗略翻译
- BluetoothSerial(void) :构造函数,用于初始化BluetoothSerial对象。
- ~BluetoothSerial(void) :析构函数,用于释放BluetoothSerial对象使用的资源。
- bool begin(String localName=String(), bool isMaster=false) :开始蓝牙连接。如果需要,可以设置本地名称(localName)和主/从设备角色(isMaster)。
- bool begin(unsigned long baud) :这是一个兼容函数,用于与Arduino的Serial.begin()兼容。实际上,它只是调用了begin()函数。
- int available(void) :返回可读取的字节数。
- int peek(void) :返回缓冲区中的首个字节,但不会将其从缓冲区中移除。
- bool hasClient(void) :检查是否已连接到客户端设备。
- int read(void) :从缓冲区中读取一个字节。
- size_t write(uint8_t c) :将一字节写入缓冲区。
- *size_t write(const uint8_t buffer, size_t size) :将缓冲区中的数据写入蓝牙设备。
- void flush() :刷新缓冲区,将数据发送到蓝牙设备。
- void end(void) :关闭蓝牙连接。
- void setTimeout(int timeoutMS) :设置超时时间(以毫秒为单位)。
- void onData(BluetoothSerialDataCb cb) :设置数据接收回调函数。当接收到数据时,将调用该函数。
- esp_err_t register_callback(esp_spp_cb_t callback) :注册SPP回调函数。当发生SPP事件时,将调用该函数。
- void onConfirmRequest(ConfirmRequestCb cb) :设置确认请求回调函数。当接收到确认请求时,将调用该函数。
- void onAuthComplete(AuthCompleteCb cb) :设置身份验证完成回调函数。当身份验证完成后,将调用该函数。
- void confirmReply(boolean confirm) :回复确认请求。
- void enableSSP() :启用SSP(Secure Simple Pairing)功能。
- *bool setPin(const char pin) :设置PIN码。
- bool connect(String remoteName) :连接到指定名称的远程设备。
- bool connect(uint8_t remoteAddress[], int channel=0, esp_spp_sec_t sec_mask=(ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE), esp_spp_role_t role=ESP_SPP_ROLE_MASTER) :连接到指定地址的远程设备,并设置通道、安全模式和角色。
- bool connect() :连接到最近连接的设备。
- bool connected(int timeout=0) :检查是否已连接到远程设备。
- bool isClosed() :检查连接是否已关闭。
- bool isReady(bool checkMaster=false, int timeout=0) :检查设备是否准备好进行数据传输。
- bool disconnect() :断开与远程设备的连接。
- bool unpairDevice(uint8_t remoteAddress[]) :解除与指定地址的设备的配对。
- BTScanResults discover(int timeout=0x301280)**:扫描周围的蓝牙设备,并返回发现的设备列表。
- bool discoverAsync(BTAdvertisedDeviceCb cb, int timeout=0x30*1280) :异步扫描周围的蓝牙设备,并调用回调函数以返回发现的设备。
- void discoverAsyncStop() :停止异步扫描。
- void discoverClear() :清除发现的设备列表。
- *BTScanResults getScanResults()**:返回最近一次扫描发现的设备列表。
- std::map<int, std::string> getChannels(const BTAddress &remoteAddress) :获取指定远程设备的可用通道列表。
- const int INQ_TIME = 1280:设置查询时间,单位为毫秒。
- const int MIN_INQ_TIME = (ESP_BT_GAP_MIN_INQ_LEN * INQ_TIME) :设置最小查询时间。
- const int MAX_INQ_TIME = (ESP_BT_GAP_MAX_INQ_LEN * INQ_TIME) :设置最大查询时间。
- operator bool() const:将BluetoothSerial对象转换为布尔值。
- *void getBtAddress(uint8_t mac) :获取蓝牙设备的MAC地址,并将其复制到提供的数组中。
- BTAddress getBtAddressObject() :获取蓝牙设备的MAC地址,作为BTAddress对象返回。
- String getBtAddressString() :获取蓝牙设备的MAC地址,作为字符串返回。