fix formating

This commit is contained in:
Tomasz Duda 2024-02-13 20:17:21 +01:00
parent 3fb3f3e098
commit fe48c0e97d
6 changed files with 23 additions and 23 deletions

View File

@ -15,14 +15,14 @@
#define MANUFACTURER_ID 0x0059
// "nRF Connect" app can be used to detect beacon
uint8_t beaconUuid[16] = {0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
const uint8_t BEACON_UUID[16] = {0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0};
// A valid Beacon packet consists of the following information:
// UUID, Major, Minor, RSSI @ 1M
BLEBeacon ble_beacon(beaconUuid, 1, 2, -54);
BLEBeacon ble_beacon(BEACON_UUID, 1, 2, -54);
void startAdv(void) {
void start_adv() {
// Advertising packet
// Set the beacon payload using the BLEBeacon class populated
// earlier in this example
@ -65,7 +65,7 @@ void Beacon::setup() {
ble_beacon.setManufacturer(MANUFACTURER_ID);
// Setup the advertising packet
startAdv();
start_adv();
}
} // namespace beacon

View File

@ -41,7 +41,7 @@ void Logger::write_header_(int level, const char *tag, int line) {
const char *letter = LOG_LEVEL_LETTERS[level];
#ifdef USE_ARDUINO
void *current_task = xTaskGetCurrentTaskHandle();
if (current_task == main_task) {
if (current_task == main_task_) {
#endif
this->printf_to_buffer_("%s[%s][%s:%03u]: ", color, letter, tag, line);
#ifdef USE_ARDUINO
@ -148,7 +148,7 @@ Logger::Logger(uint32_t baud_rate, size_t tx_buffer_size) : baud_rate_(baud_rate
// add 1 to buffer size for null terminator
this->tx_buffer_ = new char[this->tx_buffer_size_ + 1]; // NOLINT
#ifdef USE_ARDUINO
this->main_task = xTaskGetCurrentTaskHandle();
this->main_task_ = xTaskGetCurrentTaskHandle();
#endif
}

View File

@ -171,7 +171,7 @@ class Logger : public Component {
CallbackManager<void(int, const char *, const char *)> log_callback_{};
/// Prevents recursive log calls, if true a log message is already being processed.
bool recursion_guard_ = false;
void *main_task = nullptr;
void *main_task_ = nullptr;
};
extern Logger *global_logger; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

View File

@ -10,7 +10,7 @@ namespace zephyr_ble_server {
static const char *const TAG = "zephyr_ble_server";
static struct k_work advertise_work;
static const struct bt_data ad[] = {
static const struct bt_data AD[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
#ifdef USE_OTA
@ -19,12 +19,12 @@ static const struct bt_data ad[] = {
#endif
};
const struct bt_le_adv_param *adv_param = BT_LE_ADV_CONN_NAME;
const struct bt_le_adv_param* const ADV_PARAM = BT_LE_ADV_CONN_NAME;
static void advertise(struct k_work *work) {
bt_le_adv_stop();
int rc = bt_le_adv_start(adv_param, ad, ARRAY_SIZE(ad), NULL, 0);
int rc = bt_le_adv_start(ADV_PARAM, AD, ARRAY_SIZE(AD), NULL, 0);
if (rc) {
ESP_LOGE(TAG, "Advertising failed to start (rc %d)", rc);
return;

View File

@ -40,19 +40,19 @@ static enum mgmt_cb_return mcumgr_img_mgmt_cb(uint32_t event, enum mgmt_cb_retur
return MGMT_CB_OK;
}
static struct mgmt_callback img_mgmt_callback = {
static struct mgmt_callback IMG_MGMT_CALLBACK = {
.callback = mcumgr_img_mgmt_cb,
.event_id = MGMT_EVT_OP_IMG_MGMT_ALL,
};
OTAComponent::OTAComponent() { ota::global_ota_component = this; }
void OTAComponent::setup() { mgmt_callback_register(&img_mgmt_callback); }
void OTAComponent::setup() { mgmt_callback_register(&IMG_MGMT_CALLBACK); }
void OTAComponent::loop() {
if (false == _is_confirmed) {
_is_confirmed = boot_is_img_confirmed();
if (false == _is_confirmed) {
if (!is_confirmed_) {
is_confirmed_ = boot_is_img_confirmed();
if (!is_confirmed_) {
if (boot_write_img_confirmed()) {
ESP_LOGD(TAG, "Unable to confirm image");
// TODO reboot
@ -85,7 +85,7 @@ void OTAComponent::dump_config() {
}
void OTAComponent::update_chunk(const img_mgmt_upload_check &upload) {
_percentage = (upload.req->off * 100.0f) / upload.action->size;
percentage_ = (upload.req->off * 100.0f) / upload.action->size;
}
void OTAComponent::update_started() {
@ -97,11 +97,11 @@ void OTAComponent::update_started() {
void OTAComponent::update_chunk_wrote() {
uint32_t now = millis();
if (now - _last_progress > 1000) {
_last_progress = now;
ESP_LOGD(TAG, "OTA in progress: %0.1f%%", _percentage);
if (now - last_progress_ > 1000) {
last_progress_ = now;
ESP_LOGD(TAG, "OTA in progress: %0.1f%%", percentage_);
#ifdef USE_OTA_STATE_CALLBACK
this->state_callback_.call(ota::OTA_IN_PROGRESS, _percentage, 0);
this->state_callback_.call(ota::OTA_IN_PROGRESS, percentage_, 0);
#endif
}
}

View File

@ -19,9 +19,9 @@ class OTAComponent : public ota::OTAComponent {
void update_pending();
protected:
uint32_t _last_progress = 0;
float _percentage = 0;
bool _is_confirmed = false;
uint32_t last_progress_ = 0;
float percentage_ = 0;
bool is_confirmed_ = false;
};
} // namespace zephyr_ota_mcumgr