Skip to content

Commit 555e290

Browse files
committed
Reformat project using clang-format
1 parent 567d3eb commit 555e290

70 files changed

Lines changed: 3448 additions & 3594 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4
3+
TabWidth: 4
4+
UseTab: Never
5+
BreakBeforeBraces: Allman
6+
ColumnLimit: 160
7+
IncludeBlocks: Preserve
8+
IndentCaseLabels: false
9+
AllowShortIfStatementsOnASingleLine: false
10+
AllowShortLoopsOnASingleLine: false
11+
AllowShortFunctionsOnASingleLine: Empty
12+
AllowShortBlocksOnASingleLine: Never

bootloader_components/boot_hooks.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// source: https://github.com/espressif/esp-iot-solution/blob/4730d91db70df7e6e0a3191d725ab1c5f98ff9ce/examples/usb/device/usb_webcam/bootloader_components/boot_hooks/boot_hooks.c
1+
// source:
2+
// https://github.com/espressif/esp-iot-solution/blob/4730d91db70df7e6e0a3191d725ab1c5f98ff9ce/examples/usb/device/usb_webcam/bootloader_components/boot_hooks/boot_hooks.c
23

34
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
45
#include "esp_log.h"
@@ -9,16 +10,13 @@
910
* with all its symbols.
1011
*/
1112

12-
void bootloader_hooks_include(void)
13-
{
14-
}
13+
void bootloader_hooks_include(void) {}
1514

1615
void bootloader_before_init(void)
1716
{
18-
19-
// Disable D+ pullup, to prevent the USB host from retrieving USB-Serial-JTAG's descriptor.
20-
SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE);
21-
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);
22-
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
17+
// Disable D+ pullup, to prevent the USB host from retrieving USB-Serial-JTAG's descriptor.
18+
SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE);
19+
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);
20+
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
2321
}
2422
#endif

components/CameraManager/CameraManager/CameraManager.cpp

Lines changed: 179 additions & 187 deletions
Large diffs are not rendered by default.

components/CameraManager/CameraManager/CameraManager.hpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@
22
#ifndef CAMERAMANAGER_HPP
33
#define CAMERAMANAGER_HPP
44

5-
#include "esp_log.h"
6-
#include "esp_camera.h"
75
#include "driver/gpio.h"
6+
#include "esp_camera.h"
7+
#include "esp_log.h"
88
#include "esp_psram.h"
99
#include "sdkconfig.h"
1010

1111
#include "freertos/FreeRTOS.h"
1212
#include "freertos/queue.h"
1313

14-
#include <StateManager.hpp>
1514
#include <ProjectConfig.hpp>
15+
#include <StateManager.hpp>
1616

1717
#define OV5640_XCLK_FREQ_HZ CONFIG_CAMERA_WIFI_XCLK_FREQ
1818

1919
class CameraManager
2020
{
21-
private:
22-
sensor_t *camera_sensor;
23-
std::shared_ptr<ProjectConfig> projectConfig;
24-
QueueHandle_t eventQueue;
25-
camera_config_t config;
26-
27-
public:
28-
CameraManager(std::shared_ptr<ProjectConfig> projectConfig, QueueHandle_t eventQueue);
29-
int setCameraResolution(framesize_t frameSize);
30-
bool setupCamera();
31-
int setVFlip(int direction);
32-
int setHFlip(int direction);
33-
int setVieWindow(int offsetX, int offsetY, int outputX, int outputY);
34-
35-
private:
36-
void loadConfigData();
37-
void setupCameraPinout();
38-
void setupCameraSensor();
21+
private:
22+
sensor_t* camera_sensor;
23+
std::shared_ptr<ProjectConfig> projectConfig;
24+
QueueHandle_t eventQueue;
25+
camera_config_t config;
26+
27+
public:
28+
CameraManager(std::shared_ptr<ProjectConfig> projectConfig, QueueHandle_t eventQueue);
29+
int setCameraResolution(framesize_t frameSize);
30+
bool setupCamera();
31+
int setVFlip(int direction);
32+
int setHFlip(int direction);
33+
int setVieWindow(int offsetX, int offsetY, int outputX, int outputY);
34+
35+
private:
36+
void loadConfigData();
37+
void setupCameraPinout();
38+
void setupCameraSensor();
3939
};
4040

41-
#endif // CAMERAMANAGER_HPP
41+
#endif // CAMERAMANAGER_HPP

components/CommandManager/CommandManager/CommandManager.cpp

Lines changed: 95 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -30,140 +30,117 @@ std::unordered_map<std::string, CommandType> commandTypeMap = {
3030
{"get_who_am_i", CommandType::GET_WHO_AM_I},
3131
};
3232

33-
std::function<CommandResult()> CommandManager::createCommand(const CommandType type, const nlohmann::json &json) const
33+
std::function<CommandResult()> CommandManager::createCommand(const CommandType type, const nlohmann::json& json) const
3434
{
35-
switch (type)
36-
{
37-
case CommandType::PING:
38-
return {PingCommand};
39-
case CommandType::PAUSE:
40-
return [json]
41-
{ return PauseCommand(json); };
42-
case CommandType::UPDATE_OTA_CREDENTIALS:
43-
return [this, json]
44-
{ return updateOTACredentialsCommand(this->registry, json); };
45-
case CommandType::SET_WIFI:
46-
return [this, json]
47-
{ return setWiFiCommand(this->registry, json); };
48-
case CommandType::UPDATE_WIFI:
49-
return [this, json]
50-
{ return updateWiFiCommand(this->registry, json); };
51-
case CommandType::UPDATE_AP_WIFI:
52-
return [this, json]
53-
{ return updateAPWiFiCommand(this->registry, json); };
54-
case CommandType::DELETE_NETWORK:
55-
return [this, json]
56-
{ return deleteWiFiCommand(this->registry, json); };
57-
case CommandType::SET_MDNS:
58-
return [this, json]
59-
{ return setMDNSCommand(this->registry, json); };
60-
case CommandType::GET_MDNS_NAME:
61-
return [this]
62-
{ return getMDNSNameCommand(this->registry); };
63-
case CommandType::UPDATE_CAMERA:
64-
return [this, json]
65-
{ return updateCameraCommand(this->registry, json); };
66-
case CommandType::GET_CONFIG:
67-
return [this]
68-
{ return getConfigCommand(this->registry); };
69-
case CommandType::SAVE_CONFIG:
70-
return [this]
71-
{ return saveConfigCommand(this->registry); };
72-
case CommandType::RESET_CONFIG:
73-
return [this, json]
74-
{ return resetConfigCommand(this->registry, json); };
75-
case CommandType::RESTART_DEVICE:
76-
return restartDeviceCommand;
77-
case CommandType::SCAN_NETWORKS:
78-
return [this, json]
79-
{ return scanNetworksCommand(this->registry, json); };
80-
case CommandType::START_STREAMING:
81-
return startStreamingCommand;
82-
case CommandType::GET_WIFI_STATUS:
83-
return [this]
84-
{ return getWiFiStatusCommand(this->registry); };
85-
case CommandType::CONNECT_WIFI:
86-
return [this]
87-
{ return connectWiFiCommand(this->registry); };
88-
case CommandType::SWITCH_MODE:
89-
return [this, json]
90-
{ return switchModeCommand(this->registry, json); };
91-
case CommandType::GET_DEVICE_MODE:
92-
return [this]
93-
{ return getDeviceModeCommand(this->registry); };
94-
case CommandType::SET_LED_DUTY_CYCLE:
95-
return [this, json]
96-
{ return updateLEDDutyCycleCommand(this->registry, json); };
97-
case CommandType::GET_LED_DUTY_CYCLE:
98-
return [this]
99-
{ return getLEDDutyCycleCommand(this->registry); };
100-
case CommandType::GET_SERIAL:
101-
return [this]
102-
{ return getSerialNumberCommand(this->registry); };
103-
case CommandType::GET_LED_CURRENT:
104-
return [this]
105-
{ return getLEDCurrentCommand(this->registry); };
106-
case CommandType::GET_BATTERY_STATUS:
107-
return [this]
108-
{ return getBatteryStatusCommand(this->registry); };
109-
case CommandType::GET_WHO_AM_I:
110-
return [this]
111-
{ return getInfoCommand(this->registry); };
112-
default:
113-
return nullptr;
114-
}
35+
switch (type)
36+
{
37+
case CommandType::PING:
38+
return {PingCommand};
39+
case CommandType::PAUSE:
40+
return [json] { return PauseCommand(json); };
41+
case CommandType::UPDATE_OTA_CREDENTIALS:
42+
return [this, json] { return updateOTACredentialsCommand(this->registry, json); };
43+
case CommandType::SET_WIFI:
44+
return [this, json] { return setWiFiCommand(this->registry, json); };
45+
case CommandType::UPDATE_WIFI:
46+
return [this, json] { return updateWiFiCommand(this->registry, json); };
47+
case CommandType::UPDATE_AP_WIFI:
48+
return [this, json] { return updateAPWiFiCommand(this->registry, json); };
49+
case CommandType::DELETE_NETWORK:
50+
return [this, json] { return deleteWiFiCommand(this->registry, json); };
51+
case CommandType::SET_MDNS:
52+
return [this, json] { return setMDNSCommand(this->registry, json); };
53+
case CommandType::GET_MDNS_NAME:
54+
return [this] { return getMDNSNameCommand(this->registry); };
55+
case CommandType::UPDATE_CAMERA:
56+
return [this, json] { return updateCameraCommand(this->registry, json); };
57+
case CommandType::GET_CONFIG:
58+
return [this] { return getConfigCommand(this->registry); };
59+
case CommandType::SAVE_CONFIG:
60+
return [this] { return saveConfigCommand(this->registry); };
61+
case CommandType::RESET_CONFIG:
62+
return [this, json] { return resetConfigCommand(this->registry, json); };
63+
case CommandType::RESTART_DEVICE:
64+
return restartDeviceCommand;
65+
case CommandType::SCAN_NETWORKS:
66+
return [this, json] { return scanNetworksCommand(this->registry, json); };
67+
case CommandType::START_STREAMING:
68+
return startStreamingCommand;
69+
case CommandType::GET_WIFI_STATUS:
70+
return [this] { return getWiFiStatusCommand(this->registry); };
71+
case CommandType::CONNECT_WIFI:
72+
return [this] { return connectWiFiCommand(this->registry); };
73+
case CommandType::SWITCH_MODE:
74+
return [this, json] { return switchModeCommand(this->registry, json); };
75+
case CommandType::GET_DEVICE_MODE:
76+
return [this] { return getDeviceModeCommand(this->registry); };
77+
case CommandType::SET_LED_DUTY_CYCLE:
78+
return [this, json] { return updateLEDDutyCycleCommand(this->registry, json); };
79+
case CommandType::GET_LED_DUTY_CYCLE:
80+
return [this] { return getLEDDutyCycleCommand(this->registry); };
81+
case CommandType::GET_SERIAL:
82+
return [this] { return getSerialNumberCommand(this->registry); };
83+
case CommandType::GET_LED_CURRENT:
84+
return [this] { return getLEDCurrentCommand(this->registry); };
85+
case CommandType::GET_BATTERY_STATUS:
86+
return [this] { return getBatteryStatusCommand(this->registry); };
87+
case CommandType::GET_WHO_AM_I:
88+
return [this] { return getInfoCommand(this->registry); };
89+
default:
90+
return nullptr;
91+
}
11592
}
11693

11794
CommandManagerResponse CommandManager::executeFromJson(const std::string_view json) const
11895
{
119-
if (!nlohmann::json::accept(json))
120-
{
121-
return CommandManagerResponse(nlohmann::json{{"error", "Initial JSON Parse - Invalid JSON"}});
122-
}
123-
124-
nlohmann::json parsedJson = nlohmann::json::parse(json);
125-
if (!parsedJson.contains("commands") || !parsedJson["commands"].is_array() || parsedJson["commands"].empty())
126-
{
127-
return CommandManagerResponse(CommandResult::getErrorResult("Commands missing"));
128-
}
129-
130-
nlohmann::json results = nlohmann::json::array();
131-
132-
for (auto &commandObject : parsedJson["commands"].items())
133-
{
134-
auto commandData = commandObject.value();
135-
if (!commandData.contains("command"))
96+
if (!nlohmann::json::accept(json))
13697
{
137-
return CommandManagerResponse({{"command", "Unknown command"}, {"error", "Missing command type"}});
98+
return CommandManagerResponse(nlohmann::json{{"error", "Initial JSON Parse - Invalid JSON"}});
13899
}
139100

140-
const auto commandName = commandData["command"].get<std::string>();
141-
if (!commandTypeMap.contains(commandName))
101+
nlohmann::json parsedJson = nlohmann::json::parse(json);
102+
if (!parsedJson.contains("commands") || !parsedJson["commands"].is_array() || parsedJson["commands"].empty())
142103
{
143-
return CommandManagerResponse({{"command", commandName}, {"error", "Unknown command"}});
104+
return CommandManagerResponse(CommandResult::getErrorResult("Commands missing"));
144105
}
145106

146-
const auto commandType = commandTypeMap.at(commandName);
147-
const auto commandPayload = commandData.contains("data") ? commandData["data"] : nlohmann::json::object();
107+
nlohmann::json results = nlohmann::json::array();
108+
109+
for (auto& commandObject : parsedJson["commands"].items())
110+
{
111+
auto commandData = commandObject.value();
112+
if (!commandData.contains("command"))
113+
{
114+
return CommandManagerResponse({{"command", "Unknown command"}, {"error", "Missing command type"}});
115+
}
116+
117+
const auto commandName = commandData["command"].get<std::string>();
118+
if (!commandTypeMap.contains(commandName))
119+
{
120+
return CommandManagerResponse({{"command", commandName}, {"error", "Unknown command"}});
121+
}
122+
123+
const auto commandType = commandTypeMap.at(commandName);
124+
const auto commandPayload = commandData.contains("data") ? commandData["data"] : nlohmann::json::object();
148125

149-
auto command = createCommand(commandType, commandPayload);
150-
results.push_back({
151-
{"command", commandName},
152-
{"result", command()},
153-
});
154-
}
155-
auto response = nlohmann::json{{"results", results}};
156-
return CommandManagerResponse(response);
126+
auto command = createCommand(commandType, commandPayload);
127+
results.push_back({
128+
{"command", commandName},
129+
{"result", command()},
130+
});
131+
}
132+
auto response = nlohmann::json{{"results", results}};
133+
return CommandManagerResponse(response);
157134
}
158135

159136
CommandManagerResponse CommandManager::executeFromType(const CommandType type, const std::string_view json) const
160137
{
161-
const auto command = createCommand(type, json);
138+
const auto command = createCommand(type, json);
162139

163-
if (command == nullptr)
164-
{
165-
return CommandManagerResponse({{"command", type}, {"error", "Unknown command"}});
166-
}
140+
if (command == nullptr)
141+
{
142+
return CommandManagerResponse({{"command", type}, {"error", "Unknown command"}});
143+
}
167144

168-
return CommandManagerResponse(nlohmann::json{{"result", command()}});
145+
return CommandManagerResponse(nlohmann::json{{"result", command()}});
169146
}

0 commit comments

Comments
 (0)