Skip to content

Commit

Permalink
feat: Add precommit & update
Browse files Browse the repository at this point in the history
  • Loading branch information
JahazielLem committed Jan 16, 2025
1 parent 5e6e98f commit aa9f4ca
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 93 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: no-commit-to-branch # This hook prevents direct commits to main branch
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2 # Use the sha / tag you want to point at
rev: v19.1.7 # Use the sha / tag you want to point at
hooks:
- id: clang-format
types_or: [c++, c]
args: ['--style=file']
exclude: ^firmware/components/openthread
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.2.0
rev: v4.0.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
54 changes: 31 additions & 23 deletions firmware/components/console/esp_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ typedef struct {
* @brief Default console configuration value
*
*/
#define ESP_CONSOLE_CONFIG_DEFAULT() \
{ \
.max_cmdline_length = 256, .max_cmdline_args = 32, \
.heap_alloc_caps = MALLOC_CAP_DEFAULT, .hint_color = 39, .hint_bold = 0 \
}
#define ESP_CONSOLE_CONFIG_DEFAULT() \
{.max_cmdline_length = 256, \
.max_cmdline_args = 32, \
.heap_alloc_caps = MALLOC_CAP_DEFAULT, \
.hint_color = 39, \
.hint_bold = 0}

/**
* @brief Parameters for console REPL (Read Eval Print Loop)
Expand All @@ -62,11 +63,15 @@ typedef struct {
* @brief Default console repl configuration value
*
*/
#define ESP_CONSOLE_REPL_CONFIG_DEFAULT() \
{ \
.max_history_len = 32, .history_save_path = NULL, .task_stack_size = 4096, \
.task_priority = 2, .task_core_id = tskNO_AFFINITY, .prompt = NULL, \
.max_cmdline_length = 0, \
#define ESP_CONSOLE_REPL_CONFIG_DEFAULT() \
{ \
.max_history_len = 32, \
.history_save_path = NULL, \
.task_stack_size = 4096, \
.task_priority = 2, \
.task_core_id = tskNO_AFFINITY, \
.prompt = NULL, \
.max_cmdline_length = 0, \
}

#if CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM
Expand All @@ -82,19 +87,20 @@ typedef struct {
} esp_console_dev_uart_config_t;

#if CONFIG_ESP_CONSOLE_UART_CUSTOM
#define ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT() \
{ \
.channel = CONFIG_ESP_CONSOLE_UART_NUM, \
.baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE, \
.tx_gpio_num = CONFIG_ESP_CONSOLE_UART_TX_GPIO, \
.rx_gpio_num = CONFIG_ESP_CONSOLE_UART_RX_GPIO, \
#define ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT() \
{ \
.channel = CONFIG_ESP_CONSOLE_UART_NUM, \
.baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE, \
.tx_gpio_num = CONFIG_ESP_CONSOLE_UART_TX_GPIO, \
.rx_gpio_num = CONFIG_ESP_CONSOLE_UART_RX_GPIO, \
}
#else
#define ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT() \
{ \
.channel = CONFIG_ESP_CONSOLE_UART_NUM, \
.baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE, .tx_gpio_num = -1, \
.rx_gpio_num = -1, \
#define ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT() \
{ \
.channel = CONFIG_ESP_CONSOLE_UART_NUM, \
.baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE, \
.tx_gpio_num = -1, \
.rx_gpio_num = -1, \
}
#endif // CONFIG_ESP_CONSOLE_UART_CUSTOM
#endif // CONFIG_ESP_CONSOLE_UART_DEFAULT || CONFIG_ESP_CONSOLE_UART_CUSTOM
Expand All @@ -110,7 +116,8 @@ typedef struct {
} esp_console_dev_usb_cdc_config_t;

#define ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT() \
{}
{ \
}
#endif // CONFIG_ESP_CONSOLE_USB_CDC || (defined __DOXYGEN__ &&
// SOC_USB_OTG_SUPPORTED)

Expand All @@ -126,7 +133,8 @@ typedef struct {
} esp_console_dev_usb_serial_jtag_config_t;

#define ESP_CONSOLE_DEV_USB_SERIAL_JTAG_CONFIG_DEFAULT() \
{}
{ \
}
#endif // CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || (defined __DOXYGEN__ &&
// SOC_USB_SERIAL_JTAG_SUPPORTED)

Expand Down
20 changes: 8 additions & 12 deletions firmware/components/nmea_parser/include/nmea_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,14 @@ typedef void* nmea_parser_handle_t;
* @brief Default configuration for NMEA Parser
*
*/
#define NMEA_PARSER_CONFIG_DEFAULT() \
{ \
.uart = { \
.uart_port = UART_NUM_1, \
.rx_pin = CONFIG_NMEA_PARSER_UART_RXD, \
.baud_rate = CONFIG_NMEA_PARSE_UART_BAUDRATE, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.event_queue_size = 16 \
} \
}
#define NMEA_PARSER_CONFIG_DEFAULT() \
{.uart = {.uart_port = UART_NUM_1, \
.rx_pin = CONFIG_NMEA_PARSER_UART_RXD, \
.baud_rate = CONFIG_NMEA_PARSE_UART_BAUDRATE, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.event_queue_size = 16}}

/**
* @brief NMEA Parser Event ID
Expand Down
56 changes: 31 additions & 25 deletions firmware/components/open_thread/include/open_thread_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,41 @@

#if SOC_IEEE802154_SUPPORTED
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ .radio_mode = RADIO_MODE_NATIVE, }
{ \
.radio_mode = RADIO_MODE_NATIVE, \
}

#else
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_UART_RCP, \
.radio_uart_config = { \
.port = 1, \
.uart_config = \
{ \
.baud_rate = 115200, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
.rx_flow_ctrl_thresh = 0, \
.source_clk = UART_SCLK_DEFAULT, \
}, \
.rx_pin = 4, \
.tx_pin = 5, \
}, \
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_UART_RCP, \
.radio_uart_config = \
{ \
.port = 1, \
.uart_config = \
{ \
.baud_rate = 115200, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
.rx_flow_ctrl_thresh = 0, \
.source_clk = UART_SCLK_DEFAULT, \
}, \
.rx_pin = 4, \
.tx_pin = 5, \
}, \
}
#endif

#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
{ .host_connection_mode = HOST_CONNECTION_MODE_NONE, }
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
{ \
.host_connection_mode = HOST_CONNECTION_MODE_NONE, \
}

#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
{ \
.storage_partition_name = "nvs", .netif_queue_size = 10, \
.task_queue_size = 10, \
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
{ \
.storage_partition_name = "nvs", \
.netif_queue_size = 10, \
.task_queue_size = 10, \
}
4 changes: 2 additions & 2 deletions firmware/components/open_thread/open_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static size_t hex_string_to_binary(const char* hex_string,
return buf_size;
}

void openthread_set_channel(uint8_t channel){
void openthread_set_channel(uint8_t channel) {
esp_openthread_lock_acquire(portMAX_DELAY);
otInstance* instance = esp_openthread_get_instance();
otLinkSetChannel(instance, channel);
Expand Down Expand Up @@ -353,7 +353,7 @@ void openthread_init() {
#if !defined(CONFIG_OPEN_THREAD_DEBUG)
esp_log_level_set(TAG, ESP_LOG_NONE);
#endif
esp_log_level_set(TAG, ESP_LOG_NONE);
esp_log_level_set(TAG, ESP_LOG_NONE);

esp_vfs_eventfd_config_t eventfd_config = {
.max_fds = 3,
Expand Down
27 changes: 16 additions & 11 deletions firmware/components/zigbee_switch/include/zigbee_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@
#define ESP_ZB_PRIMARY_CHANNEL_MASK \
(1l << 13) /* Zigbee primary channel mask use in the example */

#define ESP_ZB_ZC_CONFIG() \
{ \
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
.nwk_cfg.zczr_cfg = { \
.max_children = MAX_CHILDREN, \
}, \
#define ESP_ZB_ZC_CONFIG() \
{ \
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
.nwk_cfg.zczr_cfg = \
{ \
.max_children = MAX_CHILDREN, \
}, \
}

#define ESP_ZB_DEFAULT_RADIO_CONFIG() \
{ .radio_mode = ZB_RADIO_MODE_NATIVE, }
#define ESP_ZB_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = ZB_RADIO_MODE_NATIVE, \
}

#define ESP_ZB_DEFAULT_HOST_CONFIG() \
{ .host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE, }
#define ESP_ZB_DEFAULT_HOST_CONFIG() \
{ \
.host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE, \
}

typedef enum {
CREATING_NETWORK = 0,
Expand Down
24 changes: 9 additions & 15 deletions firmware/main/modules/gps/war_thread/warthread_module.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#include "warthread_module.h"
#include <string.h>
#include "esp_log.h"
#include "esp_mac.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "general_submenu.h"
#include "gps_module.h"
#include "menus_module.h"
#include "oled_screen.h"
#include "open_thread.h"
#include "radio_selector.h"
#include "sd_card.h"
#include "thread_sniffer_bitmaps.h"
#include "wardriving_common.h"
#include "wardriving_screens_module.h"
#include "open_thread.h"
#include "radio_selector.h"
#include "esp_mac.h"
#include "thread_sniffer_bitmaps.h"


#define FILE_NAME WARTH_DIR_NAME "/WarThread"

Expand Down Expand Up @@ -109,16 +107,14 @@ static void thread_gps_event_handler_cb(gps_t* gps) {
context_session.session_str = get_str_date_time(gps);
context_session.session_records_count = 0;
update_file_name(context_session.session_str);
ESP_LOGI(TAG, "Creating Session File: %s",
context_session.session_str);
ESP_LOGI(TAG, "Creating Session File: %s", context_session.session_str);
sd_card_write_file(csv_file_name, csv_file_buffer);
csv_lines = CSV_HEADER_LINES;
free(csv_file_buffer);

ESP_LOGI(TAG, "Free heap size before allocation: %" PRIu32 " bytes",
esp_get_free_heap_size());
ESP_LOGI(TAG, "Allocating %d bytes for csv_file_buffer",
CSV_FILE_SIZE);
ESP_LOGI(TAG, "Allocating %d bytes for csv_file_buffer", CSV_FILE_SIZE);
csv_file_buffer = malloc(CSV_FILE_SIZE);
if (csv_file_buffer == NULL) {
ESP_LOGE(TAG, "Failed to allocate memory for csv_file_buffer");
Expand Down Expand Up @@ -146,8 +142,7 @@ static void thread_gps_event_handler_cb(gps_t* gps) {
}
}


static void warthread_packet_handler(const otRadioFrame* aFrame, bool aIsTx){
static void warthread_packet_handler(const otRadioFrame* aFrame, bool aIsTx) {
ESP_LOGI(TAG, "Packet received");

if (gps_ctx->sats_in_use == 0) {
Expand Down Expand Up @@ -211,11 +206,11 @@ static void warthread_packet_handler(const otRadioFrame* aFrame, bool aIsTx){
}

void warthread_module_begin() {
ESP_LOGI(TAG, "Thread module begin");
ESP_LOGI(TAG, "Thread module begin");
if (wardriving_module_verify_sd_card() != ESP_OK) {
return;
}

csv_lines = CSV_HEADER_LINES;
ESP_LOGI(TAG, "Free heap size before allocation: %" PRIu32 " bytes",
esp_get_free_heap_size());
Expand Down Expand Up @@ -253,7 +248,6 @@ void warthread_module_begin() {
menus_module_set_app_state(true, thread_module_cb_event);
}


void warthread_module_exit() {
sd_card_read_file(csv_file_name);
sd_card_unmount();
Expand Down
4 changes: 2 additions & 2 deletions firmware/main/modules/menus_module/menus_include/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include "warbee_module.h"
#include "wardriving_module.h"
#include "wardriving_screens_module.h"
#include "warthread_module.h"
#include "web_file_browser_module.h"
#include "wifi_analyzer.h"
#include "wifi_settings.h"
#include "zigbee_module.h"
#include "warthread_module.h"

typedef enum {
MENU_MAIN = 0,
Expand Down Expand Up @@ -419,7 +419,7 @@ menu_t menus[] = { //////////////////////////////////
.on_exit_cb = warbee_module_exit,
.is_visible = true},
#endif
#ifdef CONFIG_GPS_APP_WARDRIVING_TH
#ifdef CONFIG_GPS_APP_WARDRIVING_TH
{.display_name = "Thread Start",
.menu_idx = MENU_GPS_WARDRIVING_THREAD_START,
.parent_idx = MENU_GPS_WARDRIVING,
Expand Down

0 comments on commit aa9f4ca

Please sign in to comment.