mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Run clang-tidy against Arduino 3 (#2146)
* Add macros header with more usable Arduino version defines * Change Arduino version checking to use our version defines * Add missing ESP8266 check * Rename Arduino version macro to ARDUINO_VERSION_CODE * Upgrade clang-tidy to use Arduino 3 * Fix clang-tidy warnings * Upgrade NeoPixelBus to upstream 2.6.7 * Use Arduino-version-appropriate API to set redirect flags * Remove now unnecessary CLANG_TIDY ifdefs * Add preprocessor hackery to avoid including pgmspace.h * Bump base image to 4.1.1 and update lint * Fix nfctag * Fix make_unique ambiguous * Fix ignore name * Fix ambiguous v2 * Remove unused begin * Cast time_t to prevent issues on platforms where time_t is 32bit Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
parent
ed7983af41
commit
924df1e7de
30 changed files with 98 additions and 66 deletions
|
@ -63,11 +63,15 @@ Checks: >-
|
|||
-misc-no-recursion,
|
||||
-misc-unused-parameters,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-avoid-bind,
|
||||
-modernize-concat-nested-namespaces,
|
||||
-modernize-return-braced-init-list,
|
||||
-modernize-use-auto,
|
||||
-modernize-use-default-member-init,
|
||||
-modernize-use-equals-default,
|
||||
-modernize-use-trailing-return-type,
|
||||
-modernize-make-unique,
|
||||
-modernize-use-nodiscard,
|
||||
-mpi-*,
|
||||
-objc-*,
|
||||
-readability-braces-around-statements,
|
||||
|
@ -86,7 +90,6 @@ Checks: >-
|
|||
-readability-redundant-string-init,
|
||||
-readability-uppercase-literal-suffix,
|
||||
-readability-use-anyofallof,
|
||||
-warnings-as-errors
|
||||
WarningsAsErrors: '*'
|
||||
AnalyzeTemporaryDtors: false
|
||||
FormatStyle: google
|
||||
|
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -36,7 +36,7 @@ jobs:
|
|||
|
||||
# cpp lint job runs with esphome-lint docker image so that clang-format-*
|
||||
# doesn't have to be installed
|
||||
container: ghcr.io/esphome/esphome-lint:1.1
|
||||
container: ghcr.io/esphome/esphome-lint:1.2
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
|
|
4
.github/workflows/docker-lint-build.yml
vendored
4
.github/workflows/docker-lint-build.yml
vendored
|
@ -29,7 +29,7 @@ jobs:
|
|||
python-version: '3.9'
|
||||
- name: Set TAG
|
||||
run: |
|
||||
echo "TAG=1.1" >> $GITHUB_ENV
|
||||
echo "TAG=1.2" >> $GITHUB_ENV
|
||||
|
||||
- name: Run build
|
||||
run: |
|
||||
|
@ -74,7 +74,7 @@ jobs:
|
|||
python-version: '3.9'
|
||||
- name: Set TAG
|
||||
run: |
|
||||
echo "TAG=1.1" >> $GITHUB_ENV
|
||||
echo "TAG=1.2" >> $GITHUB_ENV
|
||||
- name: Enable experimental manifest support
|
||||
run: |
|
||||
mkdir -p ~/.docker
|
||||
|
|
|
@ -1 +1 @@
|
|||
FROM esphome/esphome-lint:1.1
|
||||
FROM esphome/esphome-lint:1.2
|
||||
|
|
|
@ -24,7 +24,7 @@ TYPE_LINT = 'lint'
|
|||
TYPES = [TYPE_DOCKER, TYPE_HA_ADDON, TYPE_LINT]
|
||||
|
||||
|
||||
BASE_VERSION = "3.6.0"
|
||||
BASE_VERSION = "4.1.1"
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
|
@ -148,7 +148,7 @@ float ADCSensor::sample() {
|
|||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#ifdef USE_ADC_SENSOR_VCC
|
||||
return ESP.getVcc() / 1024.0f;
|
||||
return ESP.getVcc() / 1024.0f; // NOLINT(readability-static-accessed-through-instance)
|
||||
#else
|
||||
return analogRead(this->pin_) / 1024.0f; // NOLINT
|
||||
#endif
|
||||
|
|
|
@ -21,11 +21,11 @@ void DebugComponent::dump_config() {
|
|||
#endif
|
||||
|
||||
ESP_LOGD(TAG, "ESPHome version %s", ESPHOME_VERSION);
|
||||
this->free_heap_ = ESP.getFreeHeap();
|
||||
this->free_heap_ = ESP.getFreeHeap(); // NOLINT(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Free Heap Size: %u bytes", this->free_heap_);
|
||||
|
||||
const char *flash_mode;
|
||||
switch (ESP.getFlashChipMode()) {
|
||||
switch (ESP.getFlashChipMode()) { // NOLINT(readability-static-accessed-through-instance)
|
||||
case FM_QIO:
|
||||
flash_mode = "QIO";
|
||||
break;
|
||||
|
@ -49,6 +49,7 @@ void DebugComponent::dump_config() {
|
|||
default:
|
||||
flash_mode = "UNKNOWN";
|
||||
}
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Flash Chip: Size=%ukB Speed=%uMHz Mode=%s", ESP.getFlashChipSize() / 1024,
|
||||
ESP.getFlashChipSpeed() / 1000000, flash_mode);
|
||||
|
||||
|
@ -87,7 +88,7 @@ void DebugComponent::dump_config() {
|
|||
|
||||
ESP_LOGD(TAG, "ESP-IDF Version: %s", esp_get_idf_version());
|
||||
|
||||
std::string mac = uint64_to_string(ESP.getEfuseMac());
|
||||
std::string mac = uint64_to_string(ESP.getEfuseMac()); // NOLINT(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "EFuse MAC: %s", mac.c_str());
|
||||
|
||||
const char *reset_reason;
|
||||
|
@ -186,7 +187,7 @@ void DebugComponent::dump_config() {
|
|||
ESP_LOGD(TAG, "Wakeup Reason: %s", wakeup_reason);
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#if defined(ARDUINO_ARCH_ESP8266) && !defined(CLANG_TIDY)
|
||||
ESP_LOGD(TAG, "Chip ID: 0x%08X", ESP.getChipId());
|
||||
ESP_LOGD(TAG, "SDK Version: %s", ESP.getSdkVersion());
|
||||
ESP_LOGD(TAG, "Core Version: %s", ESP.getCoreVersion().c_str());
|
||||
|
@ -198,7 +199,7 @@ void DebugComponent::dump_config() {
|
|||
#endif
|
||||
}
|
||||
void DebugComponent::loop() {
|
||||
uint32_t new_free_heap = ESP.getFreeHeap();
|
||||
uint32_t new_free_heap = ESP.getFreeHeap(); // NOLINT(readability-static-accessed-through-instance)
|
||||
if (new_free_heap < this->free_heap_ / 2) {
|
||||
this->free_heap_ = new_free_heap;
|
||||
ESP_LOGD(TAG, "Free Heap Size: %u bytes", this->free_heap_);
|
||||
|
|
|
@ -84,7 +84,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
|
|||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
ESP.deepSleep(*this->sleep_duration_);
|
||||
ESP.deepSleep(*this->sleep_duration_); // NOLINT(readability-static-accessed-through-instance)
|
||||
#endif
|
||||
}
|
||||
float DeepSleepComponent::get_setup_priority() const { return setup_priority::LATE; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "http_request.h"
|
||||
#include "esphome/core/macros.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
|
@ -31,11 +32,15 @@ void HttpRequestComponent::send(const std::vector<HttpRequestResponseTrigger *>
|
|||
begin_status = this->client_.begin(url);
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#ifndef CLANG_TIDY
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||
this->client_.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
this->client_.setFollowRedirects(true);
|
||||
this->client_.setRedirectLimit(3);
|
||||
begin_status = this->client_.begin(*this->get_wifi_client_(), url);
|
||||
#endif
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
this->client_.setRedirectLimit(3);
|
||||
#endif
|
||||
begin_status = this->client_.begin(*this->get_wifi_client_(), url);
|
||||
#endif
|
||||
|
||||
if (!begin_status) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "color_mode.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace esphome {
|
||||
namespace light {
|
||||
|
|
|
@ -205,4 +205,4 @@ async def to_code(config):
|
|||
cg.add(var.set_pixel_order(getattr(ESPNeoPixelOrder, config[CONF_TYPE])))
|
||||
|
||||
# https://github.com/Makuna/NeoPixelBus/blob/master/library.json
|
||||
cg.add_library("NeoPixelBus-esphome", "2.6.2")
|
||||
cg.add_library("NeoPixelBus", "2.6.7")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "nextion.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/macros.h"
|
||||
#include "esphome/core/util.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
|
@ -26,8 +27,12 @@ int Nextion::upload_by_chunks_(HTTPClient *http, int range_start) {
|
|||
range_end = this->tft_size_;
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#ifndef CLANG_TIDY
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||
http->setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http->setFollowRedirects(true);
|
||||
#endif
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http->setRedirectLimit(3);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -44,10 +49,8 @@ int Nextion::upload_by_chunks_(HTTPClient *http, int range_start) {
|
|||
#ifdef ARDUINO_ARCH_ESP32
|
||||
begin_status = http->begin(this->tft_url_.c_str());
|
||||
#endif
|
||||
#ifndef CLANG_TIDY
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
begin_status = http->begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
++tries;
|
||||
|
@ -140,11 +143,15 @@ void Nextion::upload_tft() {
|
|||
begin_status = http.begin(this->tft_url_.c_str());
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#ifndef CLANG_TIDY
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
http.setRedirectLimit(3);
|
||||
begin_status = http.begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http.setFollowRedirects(true);
|
||||
#endif
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http.setRedirectLimit(3);
|
||||
#endif
|
||||
begin_status = http.begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||
#endif
|
||||
|
||||
if (!begin_status) {
|
||||
|
@ -256,6 +263,7 @@ void Nextion::upload_tft() {
|
|||
}
|
||||
}
|
||||
#else
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
uint32_t chunk_size = ESP.getFreeHeap() < 10240 ? 4096 : 8192;
|
||||
#endif
|
||||
|
||||
|
@ -270,6 +278,7 @@ void Nextion::upload_tft() {
|
|||
}
|
||||
} else {
|
||||
#endif
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Allocating buffer size %d, Heap size is %u", chunk_size, ESP.getFreeHeap());
|
||||
this->transfer_buffer_ = new (std::nothrow) uint8_t[chunk_size]; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
if (this->transfer_buffer_ == nullptr) { // Try a smaller size
|
||||
|
@ -288,6 +297,7 @@ void Nextion::upload_tft() {
|
|||
this->transfer_buffer_size_ = chunk_size;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Updating tft from \"%s\" with a file size of %d using %zu chunksize, Heap Size %d",
|
||||
this->tft_url_.c_str(), this->content_length_, this->transfer_buffer_size_, ESP.getFreeHeap());
|
||||
|
||||
|
@ -299,6 +309,7 @@ void Nextion::upload_tft() {
|
|||
this->upload_end_();
|
||||
}
|
||||
App.feed_wdt();
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Heap Size %d, Bytes left %d", ESP.getFreeHeap(), this->content_length_);
|
||||
}
|
||||
ESP_LOGD(TAG, "Successfully updated Nextion!");
|
||||
|
@ -311,7 +322,7 @@ void Nextion::upload_end_() {
|
|||
this->soft_reset();
|
||||
delay(1500); // NOLINT
|
||||
ESP_LOGD(TAG, "Restarting esphome");
|
||||
ESP.restart();
|
||||
ESP.restart(); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
|
|
|
@ -83,11 +83,11 @@ bool NdefMessage::add_text_record(const std::string &text) { return this->add_te
|
|||
|
||||
bool NdefMessage::add_text_record(const std::string &text, const std::string &encoding) {
|
||||
std::string payload = to_string(text.length()) + encoding + text;
|
||||
return this->add_record(make_unique<NdefRecord>(TNF_WELL_KNOWN, "T", payload));
|
||||
return this->add_record(std::unique_ptr<NdefRecord>{new NdefRecord(TNF_WELL_KNOWN, "T", payload)});
|
||||
}
|
||||
|
||||
bool NdefMessage::add_uri_record(const std::string &uri) {
|
||||
return this->add_record(make_unique<NdefRecord>(TNF_WELL_KNOWN, "U", uri));
|
||||
return this->add_record(std::unique_ptr<NdefRecord>{new NdefRecord(TNF_WELL_KNOWN, "U", uri)});
|
||||
}
|
||||
|
||||
std::vector<uint8_t> NdefMessage::encode() {
|
||||
|
|
|
@ -31,13 +31,13 @@ class NfcTag {
|
|||
NfcTag(std::vector<uint8_t> &uid, const std::string &tag_type, std::vector<uint8_t> &ndef_data) {
|
||||
this->uid_ = uid;
|
||||
this->tag_type_ = tag_type;
|
||||
this->ndef_message_ = make_unique<NdefMessage>(ndef_data);
|
||||
this->ndef_message_ = std::unique_ptr<NdefMessage>(new NdefMessage(ndef_data));
|
||||
};
|
||||
NfcTag(const NfcTag &rhs) {
|
||||
uid_ = rhs.uid_;
|
||||
tag_type_ = rhs.tag_type_;
|
||||
if (rhs.ndef_message_ != nullptr)
|
||||
ndef_message_ = make_unique<NdefMessage>(*rhs.ndef_message_);
|
||||
ndef_message_ = std::unique_ptr<NdefMessage>(new NdefMessage(*rhs.ndef_message_));
|
||||
}
|
||||
|
||||
std::vector<uint8_t> &get_uid() { return this->uid_; };
|
||||
|
|
|
@ -104,7 +104,7 @@ void PN532::loop() {
|
|||
if (!success) {
|
||||
// Something failed
|
||||
if (!this->current_uid_.empty()) {
|
||||
auto tag = make_unique<nfc::NfcTag>(this->current_uid_);
|
||||
auto tag = std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(this->current_uid_)};
|
||||
for (auto *trigger : this->triggers_ontagremoved_)
|
||||
trigger->process(tag);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void PN532::loop() {
|
|||
if (num_targets != 1) {
|
||||
// no tags found or too many
|
||||
if (!this->current_uid_.empty()) {
|
||||
auto tag = make_unique<nfc::NfcTag>(this->current_uid_);
|
||||
auto tag = std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(this->current_uid_)};
|
||||
for (auto *trigger : this->triggers_ontagremoved_)
|
||||
trigger->process(tag);
|
||||
}
|
||||
|
@ -281,9 +281,9 @@ std::unique_ptr<nfc::NfcTag> PN532::read_tag_(std::vector<uint8_t> &uid) {
|
|||
return this->read_mifare_ultralight_tag_(uid);
|
||||
} else if (type == nfc::TAG_TYPE_UNKNOWN) {
|
||||
ESP_LOGV(TAG, "Cannot determine tag type");
|
||||
return make_unique<nfc::NfcTag>(uid);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid)};
|
||||
} else {
|
||||
return make_unique<nfc::NfcTag>(uid);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid)};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,15 +15,15 @@ std::unique_ptr<nfc::NfcTag> PN532::read_mifare_classic_tag_(std::vector<uint8_t
|
|||
std::vector<uint8_t> data;
|
||||
if (this->read_mifare_classic_block_(current_block, data)) {
|
||||
if (!nfc::decode_mifare_classic_tlv(data, message_length, message_start_index)) {
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::ERROR);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::ERROR)};
|
||||
}
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to read block %d", current_block);
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::MIFARE_CLASSIC);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::MIFARE_CLASSIC)};
|
||||
}
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Tag is not NDEF formatted");
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::MIFARE_CLASSIC);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::MIFARE_CLASSIC)};
|
||||
}
|
||||
|
||||
uint32_t index = 0;
|
||||
|
@ -51,7 +51,7 @@ std::unique_ptr<nfc::NfcTag> PN532::read_mifare_classic_tag_(std::vector<uint8_t
|
|||
}
|
||||
}
|
||||
buffer.erase(buffer.begin(), buffer.begin() + message_start_index);
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::MIFARE_CLASSIC, buffer);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::MIFARE_CLASSIC, buffer)};
|
||||
}
|
||||
|
||||
bool PN532::read_mifare_classic_block_(uint8_t block_num, std::vector<uint8_t> &data) {
|
||||
|
|
|
@ -9,25 +9,25 @@ static const char *const TAG = "pn532.mifare_ultralight";
|
|||
std::unique_ptr<nfc::NfcTag> PN532::read_mifare_ultralight_tag_(std::vector<uint8_t> &uid) {
|
||||
if (!this->is_mifare_ultralight_formatted_()) {
|
||||
ESP_LOGD(TAG, "Not NDEF formatted");
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
|
||||
}
|
||||
|
||||
uint8_t message_length;
|
||||
uint8_t message_start_index;
|
||||
if (!this->find_mifare_ultralight_ndef_(message_length, message_start_index)) {
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
|
||||
}
|
||||
ESP_LOGVV(TAG, "message length: %d, start: %d", message_length, message_start_index);
|
||||
|
||||
if (message_length == 0) {
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
|
||||
}
|
||||
std::vector<uint8_t> data;
|
||||
for (uint8_t page = nfc::MIFARE_ULTRALIGHT_DATA_START_PAGE; page < nfc::MIFARE_ULTRALIGHT_MAX_PAGE; page++) {
|
||||
std::vector<uint8_t> page_data;
|
||||
if (!this->read_mifare_ultralight_page_(page, page_data)) {
|
||||
ESP_LOGE(TAG, "Error reading page %d", page);
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
|
||||
}
|
||||
data.insert(data.end(), page_data.begin(), page_data.end());
|
||||
|
||||
|
@ -38,7 +38,7 @@ std::unique_ptr<nfc::NfcTag> PN532::read_mifare_ultralight_tag_(std::vector<uint
|
|||
data.erase(data.begin(), data.begin() + message_start_index);
|
||||
data.erase(data.begin() + message_length, data.end());
|
||||
|
||||
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2, data);
|
||||
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2, data)};
|
||||
}
|
||||
|
||||
bool PN532::read_mifare_ultralight_page_(uint8_t page_num, std::vector<uint8_t> &data) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "esphome/core/log.h"
|
||||
#include "sgp40.h"
|
||||
#include <cinttypes>
|
||||
|
||||
namespace esphome {
|
||||
namespace sgp40 {
|
||||
|
|
|
@ -18,7 +18,7 @@ void ShutdownSwitch::write_state(bool state) {
|
|||
|
||||
App.run_safe_shutdown_hooks();
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
ESP.deepSleep(0);
|
||||
ESP.deepSleep(0); // NOLINT(readability-static-accessed-through-instance)
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
esp_deep_sleep_start();
|
||||
|
|
|
@ -95,12 +95,12 @@ void SPIComponent::debug_rx(uint8_t value) {
|
|||
void SPIComponent::debug_enable(uint8_t pin) { ESP_LOGVV(TAG, "Enabling SPI Chip on pin %u...", pin); }
|
||||
|
||||
void SPIComponent::cycle_clock_(bool value) {
|
||||
uint32_t start = ESP.getCycleCount();
|
||||
while (start - ESP.getCycleCount() < this->wait_cycle_)
|
||||
uint32_t start = ESP.getCycleCount(); // NOLINT(readability-static-accessed-through-instance)
|
||||
while (start - ESP.getCycleCount() < this->wait_cycle_) // NOLINT(readability-static-accessed-through-instance)
|
||||
;
|
||||
this->clk_->digital_write(value);
|
||||
start += this->wait_cycle_;
|
||||
while (start - ESP.getCycleCount() < this->wait_cycle_)
|
||||
while (start - ESP.getCycleCount() < this->wait_cycle_) // NOLINT(readability-static-accessed-through-instance)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ void CronTrigger::loop() {
|
|||
this->last_check_ = time;
|
||||
if (!time.fields_in_range()) {
|
||||
ESP_LOGW(TAG, "Time is out of range!");
|
||||
ESP_LOGD(TAG, "Second=%02u Minute=%02u Hour=%02u DayOfWeek=%u DayOfMonth=%u DayOfYear=%u Month=%u time=%ld",
|
||||
ESP_LOGD(TAG, "Second=%02u Minute=%02u Hour=%02u DayOfWeek=%u DayOfMonth=%u DayOfYear=%u Month=%u time=%" PRId64,
|
||||
time.second, time.minute, time.hour, time.day_of_week, time.day_of_month, time.day_of_year, time.month,
|
||||
time.timestamp);
|
||||
(int64_t) time.timestamp);
|
||||
}
|
||||
|
||||
if (this->matches(time))
|
||||
|
|
|
@ -233,7 +233,7 @@ void ESP8266SoftwareSerial::setup(int8_t tx_pin, int8_t rx_pin, uint32_t baud_ra
|
|||
}
|
||||
void ICACHE_RAM_ATTR ESP8266SoftwareSerial::gpio_intr(ESP8266SoftwareSerial *arg) {
|
||||
uint32_t wait = arg->bit_time_ + arg->bit_time_ / 3 - 500;
|
||||
const uint32_t start = ESP.getCycleCount();
|
||||
const uint32_t start = ESP.getCycleCount(); // NOLINT(readability-static-accessed-through-instance)
|
||||
uint8_t rec = 0;
|
||||
// Manually unroll the loop
|
||||
for (int i = 0; i < arg->data_bits_; i++)
|
||||
|
@ -273,7 +273,7 @@ void ICACHE_RAM_ATTR HOT ESP8266SoftwareSerial::write_byte(uint8_t data) {
|
|||
{
|
||||
InterruptLock lock;
|
||||
uint32_t wait = this->bit_time_;
|
||||
const uint32_t start = ESP.getCycleCount();
|
||||
const uint32_t start = ESP.getCycleCount(); // NOLINT(readability-static-accessed-through-instance)
|
||||
// Start bit
|
||||
this->write_bit_(false, &wait, start);
|
||||
for (int i = 0; i < this->data_bits_; i++) {
|
||||
|
@ -291,7 +291,7 @@ void ICACHE_RAM_ATTR HOT ESP8266SoftwareSerial::write_byte(uint8_t data) {
|
|||
}
|
||||
}
|
||||
void ICACHE_RAM_ATTR ESP8266SoftwareSerial::wait_(uint32_t *wait, const uint32_t &start) {
|
||||
while (ESP.getCycleCount() - start < *wait)
|
||||
while (ESP.getCycleCount() - start < *wait) // NOLINT(readability-static-accessed-through-instance)
|
||||
;
|
||||
*wait += this->bit_time_;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ void OTARequestHandler::handleUpload(AsyncWebServerRequest *request, const Strin
|
|||
this->ota_read_length_ = 0;
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
Update.runAsync(true);
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
success = Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000);
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
|
|
@ -127,7 +127,7 @@ void Application::reboot() {
|
|||
ESP_LOGI(TAG, "Forcing a reboot...");
|
||||
for (auto *comp : this->components_)
|
||||
comp->on_shutdown();
|
||||
ESP.restart();
|
||||
ESP.restart(); // NOLINT(readability-static-accessed-through-instance)
|
||||
// restart() doesn't always end execution
|
||||
while (true) {
|
||||
yield();
|
||||
|
@ -139,7 +139,7 @@ void Application::safe_reboot() {
|
|||
comp->on_safe_shutdown();
|
||||
for (auto *comp : this->components_)
|
||||
comp->on_shutdown();
|
||||
ESP.restart();
|
||||
ESP.restart(); // NOLINT(readability-static-accessed-through-instance)
|
||||
// restart() doesn't always end execution
|
||||
while (true) {
|
||||
yield();
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace esphome {
|
|||
|
||||
static const char *const TAG = "app_esp8266";
|
||||
|
||||
void ICACHE_RAM_ATTR HOT Application::feed_wdt_arch_() { ESP.wdtFeed(); }
|
||||
void ICACHE_RAM_ATTR HOT Application::feed_wdt_arch_() {
|
||||
ESP.wdtFeed(); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
|
|
@ -12,13 +12,6 @@
|
|||
|
||||
#include "esphome/core/optional.h"
|
||||
|
||||
#ifdef CLANG_TIDY
|
||||
#undef ICACHE_RAM_ATTR
|
||||
#define ICACHE_RAM_ATTR
|
||||
#undef ICACHE_RODATA_ATTR
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#endif
|
||||
|
||||
#define HOT __attribute__((hot))
|
||||
#define ESPDEPRECATED(msg, when) __attribute__((deprecated(msg)))
|
||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
||||
|
|
|
@ -75,12 +75,12 @@ static const uint8_t WEBSERVER_PORT = 80;
|
|||
|
||||
#ifdef USE_MDNS
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
void network_setup_mdns(IPAddress address, int interface) {
|
||||
void network_setup_mdns(const IPAddress &address, int interface) {
|
||||
// Latest arduino framework breaks mDNS for AP interface
|
||||
// see https://github.com/esp8266/Arduino/issues/6114
|
||||
if (interface == 1)
|
||||
return;
|
||||
MDNS.begin(App.get_name().c_str(), std::move(address));
|
||||
MDNS.begin(App.get_name().c_str(), address);
|
||||
mdns_setup = true;
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
|
|
@ -21,7 +21,7 @@ bool remote_is_connected();
|
|||
|
||||
/// Manually set up the network stack (outside of the App.setup() loop, for example in OTA safe mode)
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
void network_setup_mdns(IPAddress address, int interface);
|
||||
void network_setup_mdns(const IPAddress &address, int interface);
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
void network_setup_mdns();
|
||||
|
|
|
@ -30,7 +30,7 @@ lib_deps =
|
|||
ArduinoJson-esphomelib@5.13.3
|
||||
esphome/ESPAsyncWebServer-esphome@1.3.0
|
||||
FastLED@3.3.2
|
||||
NeoPixelBus-esphome@2.6.2
|
||||
NeoPixelBus@2.6.7
|
||||
1655@1.0.2 ; TinyGPSPlus (has name conflict)
|
||||
6865@1.0.0 ; TM1651 Battery Display
|
||||
6306@1.0.3 ; HM3301
|
||||
|
@ -47,8 +47,7 @@ src_filter =
|
|||
+<.temp/all-include.cpp>
|
||||
|
||||
[common:esp8266]
|
||||
; use Arduino framework v2.4.2 for clang-tidy (latest 2.5.2 breaks static code analysis, see #760)
|
||||
platform = platformio/espressif8266@1.8.0
|
||||
platform = platformio/espressif8266@3.1.0
|
||||
framework = arduino
|
||||
board = nodemcuv2
|
||||
lib_deps =
|
||||
|
|
|
@ -27,6 +27,21 @@ def clang_options(idedata):
|
|||
# disable built-in include directories from the host
|
||||
'-nostdinc',
|
||||
'-nostdinc++',
|
||||
# replace pgmspace.h, as it uses GNU extensions clang doesn't support
|
||||
# https://github.com/earlephilhower/newlib-xtensa/pull/18
|
||||
'-D_PGMSPACE_H_',
|
||||
'-Dpgm_read_byte(s)=(*(const uint8_t *)(s))',
|
||||
'-Dpgm_read_byte_near(s)=(*(const uint8_t *)(s))',
|
||||
'-Dpgm_read_dword(s)=(*(const uint32_t *)(s))',
|
||||
'-DPROGMEM=',
|
||||
'-DPGM_P=const char *',
|
||||
'-DPSTR(s)=(s)',
|
||||
# this next one is also needed with upstream pgmspace.h
|
||||
# suppress warning about identifier naming in expansion of this macro
|
||||
'-DPSTRN(s, n)=(s)',
|
||||
# suppress warning about attribute cannot be applied to type
|
||||
# https://github.com/esp8266/Arduino/pull/8258
|
||||
'-Ddeprecated(x)=',
|
||||
# pretend we're an Xtensa compiler, which gates some features in the headers
|
||||
'-D__XTENSA__',
|
||||
# allow to condition code on the presence of clang-tidy
|
||||
|
|
Loading…
Reference in a new issue