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

ESP-IDF: Format string fixes #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/miot/miot_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ void dump(const char *const TAG, const MiBeacon &mib) {
}
if (mib.frame_control.object_include) {
ESP_LOGD(TAG, " Object:");
ESP_LOGD(TAG, " ID : %04X", mib.object.id);
ESP_LOGD(TAG, " ID : %04" PRIX16, mib.object.id);
ESP_LOGD(TAG, " data: %s", format_hex_pretty(mib.object.data.data(), mib.object.data.size()).c_str());
}
if (mib.frame_control.is_encrypted) {
ESP_LOGD(TAG, " RND: %06X", mib.random_number >> 8);
ESP_LOGD(TAG, " MIC: %08X", mib.message_integrity_check);
ESP_LOGD(TAG, " RND: %06" PRIX32, mib.random_number >> 8);
ESP_LOGD(TAG, " MIC: %08" PRIX32, mib.message_integrity_check);
}
}

Expand Down
24 changes: 12 additions & 12 deletions components/miot/miot_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
#define CHECK_MIID(miid) \
if (this->id != miid) { \
ESP_LOGW(TAG, "BLEObject.id %04X does not match %04X (" #miid ")", this->id, miid); \
ESP_LOGW(TAG, "BLEObject.id %04" PRIX16 " does not match %04" PRIX16 " (" #miid ")", this->id, miid); \
return {}; \
}
#else
Expand Down Expand Up @@ -39,7 +39,7 @@ optional<uint32_t> BLEObject::get_idle_time() const {
CHECK_MIID(MIID_IDLE_TIME);
const auto idle_time = this->get_uint32();
if (idle_time.has_value()) {
ESP_LOGD(TAG, "Idle time: %u s", *idle_time);
ESP_LOGD(TAG, "Idle time: %" PRIu32 " s", *idle_time);
}
return idle_time;
}
Expand All @@ -48,7 +48,7 @@ optional<uint32_t> BLEObject::get_timeout() const {
CHECK_MIID(MIID_TIMEOUT);
const auto timeout = this->get_uint32();
if (timeout.has_value()) {
ESP_LOGD(TAG, "Timeout: %u s", *timeout);
ESP_LOGD(TAG, "Timeout: %" PRIu32 " s", *timeout);
}
return timeout;
}
Expand All @@ -57,7 +57,7 @@ optional<uint32_t> BLEObject::get_motion_with_light_event() const {
CHECK_MIID(MIID_MOTION_WITH_LIGHT_EVENT);
const auto illuminance = this->get_uint24();
if (illuminance.has_value()) {
ESP_LOGD(TAG, "Motion with light: %u lx", *illuminance);
ESP_LOGD(TAG, "Motion with light: %" PRIu32 " lx", *illuminance);
}
return illuminance;
}
Expand Down Expand Up @@ -115,12 +115,12 @@ const TemperatureHumidity *BLEObject::get_temperature_humidity() const {
std::string ButtonEvent::str() const {
switch (this->type) {
case ButtonEvent::BUTTON_CLICK:
return str_sprintf("Button click: %u", this->button.index);
return str_sprintf("Button click: %" PRIu16, this->button.index);
case ButtonEvent::BUTTON_DOUBLE_CLICK:
return str_sprintf("Button double click: %u", this->button.index);
return str_sprintf("Button double click: %" PRIu16, this->button.index);

case ButtonEvent::BUTTON_LONG_PRESS:
return str_sprintf("Button long press: %u", this->button.index);
return str_sprintf("Button long press: %" PRIu16, this->button.index);

case ButtonEvent::KNOB: {
uint8_t value = this->knob.short_press();
Expand Down Expand Up @@ -155,7 +155,7 @@ std::string ButtonEvent::str() const {
this->dimmer.value);
}
default:
return str_sprintf("Button unknown event %02" PRIx8 ": %04X", this->type, this->button.index);
return str_sprintf("Button unknown event %02" PRIx8 ": %04" PRIX16, this->type, this->button.index);
}
}

Expand All @@ -174,7 +174,7 @@ optional<float> BLEObject::get_illuminance() const {
CHECK_MIID(MIID_ILLUMINANCE);
const auto illuminance = this->get_uint24();
if (illuminance.has_value()) {
ESP_LOGD(TAG, "Illuminance %u lx", *illuminance);
ESP_LOGD(TAG, "Illuminance %" PRIu32 " lx", *illuminance);
}
return *illuminance;
}
Expand All @@ -183,7 +183,7 @@ optional<MIID> BLEObject::get_pairing_object() const {
CHECK_MIID(MIID_PAIRING_EVENT);
const auto event = this->get_uint16();
if (event.has_value()) {
ESP_LOGD(TAG, "Paring object %04X", *event);
ESP_LOGD(TAG, "Paring object %04" PRIX16, *event);
}
return static_cast<MIID>(*event);
}
Expand Down Expand Up @@ -275,9 +275,9 @@ optional<ToothbrushEvent> BLEObject::get_toothbrush_event() const {
}

if (toothbrush_event.type == ToothbrushEvent::BRUSHING_START) {
ESP_LOGD(TAG, "Toothbrush start event: timestamp=%d", toothbrush_event.timestamp);
ESP_LOGD(TAG, "Toothbrush start event: timestamp=%" PRIu32, toothbrush_event.timestamp);
} else {
ESP_LOGD(TAG, "Toothbrush end event: timestamp=%d, score=%u", toothbrush_event.timestamp, toothbrush_event.score);
ESP_LOGD(TAG, "Toothbrush end event: timestamp=%" PRIu32 ", score=%" PRIu8, toothbrush_event.timestamp, toothbrush_event.score);
}

return toothbrush_event;
Expand Down