Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscoverConnect.ino displays the incorrect value for COD (Class of Device). #8684

Closed
1 task done
esp32beans opened this issue Sep 29, 2023 · 1 comment · Fixed by #8691
Closed
1 task done

DiscoverConnect.ino displays the incorrect value for COD (Class of Device). #8684

esp32beans opened this issue Sep 29, 2023 · 1 comment · Fixed by #8691
Assignees
Labels
Area: BT&Wifi BT & Wifi related issues Status: Solved Type: Bug 🐛 All bugs

Comments

@esp32beans
Copy link

esp32beans commented Sep 29, 2023

Board

ESP32 devkit

Device Description

ESP32 devkit board plugged in via USB to PC. No other hardware plugged into the board.

Hardware Configuration

No connections to GPIO pins.

Version

v2.0.13

IDE Name

Arduino IDE 1.8.19

Operating System

Ubuntu 22.04

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

Logging shows the correct value ESP_BT_GAP_DEV_PROP_COD 0x40680 but the sketch shows cod: 26380. Note 0x40680 = 263808 (base 10) so the incorrect value is the decimal value with the least significant digit chopped off.

[  7020][D][BluetoothSerial.cpp:467] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_COD 0x40680
[  7027][D][BluetoothSerial.cpp:477] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_RSSI 189
[  7034][I][BluetoothSerial.cpp:435] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT : EIR : BlueTooth Printer : 17
>>>>>>>>>>>Found a new device asynchronously: Name: BlueTooth Printer, Address: 66:12:56:03:28:18, cod: 26380, rssi: -67

The COD is a 24 bit value so "val[6]" is too small. It would be better to display COD in hex like the log message.

char val[6+1];  // +1 for NUL terminator
snprintf(val, sizeof(val), "%06x", getCOD() & 0xFFFFFF);
res += ", cod: 0x";

Fixing BTAdvertisedDeviceSet::toString() will also make other examples show the correct COD.

Sketch

https://github.com/espressif/arduino-esp32/blob/master/libraries/BluetoothSerial/examples/DiscoverConnect/DiscoverConnect.ino

Debug Message

[  7020][D][BluetoothSerial.cpp:467] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_COD 0x40680
[  7027][D][BluetoothSerial.cpp:477] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_RSSI 189
[  7034][I][BluetoothSerial.cpp:435] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT : EIR : BlueTooth Printer : 17
>>>>>>>>>>>Found a new device asynchronously: Name: BlueTooth Printer, Address: 66:12:56:03:28:18, cod: 26380, rssi: -67

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@esp32beans esp32beans added the Status: Awaiting triage Issue is waiting for triage label Sep 29, 2023
@VojtechBartoska
Copy link
Collaborator

Can you please help with triage of this issue @lucasssvaz? Thanks!

@lucasssvaz lucasssvaz added Type: Bug 🐛 All bugs Area: BT&Wifi BT & Wifi related issues and removed Status: Awaiting triage Issue is waiting for triage labels Oct 2, 2023
@lucasssvaz lucasssvaz added the Status: Review needed Issue or PR is awaiting review label Oct 2, 2023
@lucasssvaz lucasssvaz added Status: Solved and removed Status: Review needed Issue or PR is awaiting review labels Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues Status: Solved Type: Bug 🐛 All bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants