我正在使用 ESP32 的示例项目,并将主 C 文件拆分为两个文件,main.c并wifi.c使用一个包含共享变量的头文件。
头文件:
#ifndef WIFI_TEST_H
#define WIFI_TEST_H
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_log.h"
#include "esp_ota_ops.h"
#include "esp_http_client.h"
#include "esp_flash_partitions.h"
#include "esp_partition.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID
#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD
const char *TAG = "wifi_test";
/* FreeRTOS event group to signal when we are connected & ready to make a request */
EventGroupHandle_t wifi_event_group;
/* The event group allows multiple bits for each event,
but we only care …Run Code Online (Sandbox Code Playgroud)